Method: OpenC3::LimitsEventTopic.sync_system
- Defined in:
- lib/openc3/topics/limits_event_topic.rb
.sync_system(scope:) ⇒ Object
Update the local System based on overall state
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/openc3/topics/limits_event_topic.rb', line 169 def self.sync_system(scope:) all_limits_settings = Store.hgetall("#{scope}__current_limits_settings") telemetry = System.telemetry.all all_limits_settings.each do |item, limits_settings| target_name, packet_name, item_name = item.split('__') target = telemetry[target_name] if target packet = target[packet_name] if packet limits_settings = JSON.parse(limits_settings, :allow_nan => true, :create_additions => true) enabled = limits_settings['enabled'] persistence = limits_settings['persistence_setting'] limits_settings.each do |limits_set, settings| next unless Hash === limits_set System.limits.set(target_name, packet_name, item_name, settings['red_low'], settings['yellow_low'], settings['yellow_high'], settings['red_high'], settings['green_low'], settings['green_high'], limits_set.to_s.intern, persistence, enabled) end if not enabled.nil? if enabled System.limits.enable(target_name, packet_name, item_name) else System.limits.disable(target_name, packet_name, item_name) end end end end end end |