Method: OpenC3::LimitsEventTopic.sync_system_thread_body
- Defined in:
- lib/openc3/topics/limits_event_topic.rb
.sync_system_thread_body(scope:, block_ms: nil) ⇒ Object
Update the local system based on limits events
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/openc3/topics/limits_event_topic.rb', line 198 def self.sync_system_thread_body(scope:, block_ms: nil) telemetry = System.telemetry.all topics = ["#{scope}__openc3_limits_events"] Topic.read_topics(topics, nil, block_ms) do |topic, msg_id, event, redis| event = JSON.parse(event['event'], :allow_nan => true, :create_additions => true) case event['type'] when 'LIMITS_CHANGE' # Ignore when 'LIMITS_SETTINGS' target_name = event['target_name'] packet_name = event['packet_name'] item_name = event['item_name'] target = telemetry[target_name] if target packet = target[packet_name] if packet enabled = ConfigParser.handle_true_false_nil(event['enabled']) persistence = event['persistence'] System.limits.set(target_name, packet_name, item_name, event['red_low'], event['yellow_low'], event['yellow_high'], event['red_high'], event['green_low'], event['green_high'], event['limits_set'], persistence, enabled) end end when 'LIMITS_ENABLE_STATE' target_name = event['target_name'] packet_name = event['packet_name'] item_name = event['item_name'] target = telemetry[target_name] if target packet = target[packet_name] if packet enabled = ConfigParser.handle_true_false_nil(event['enabled']) if enabled System.limits.enable(target_name, packet_name, item_name) else System.limits.disable(target_name, packet_name, item_name) end end end when 'LIMITS_SET' System.limits_set = event['set'] end end end |