Class: Cosmos::ReplayServer
- Inherits:
-
CmdTlmServer
- Object
- CmdTlmServer
- Cosmos::ReplayServer
- Defined in:
- lib/cosmos/tools/replay/replay_server.rb
Constant Summary
Constants inherited from CmdTlmServer
CmdTlmServer::DEFAULT_CONFIG_FILE, CmdTlmServer::DEFAULT_HOST, CmdTlmServer::DEFAULT_LIMITS_EVENT_QUEUE_SIZE, CmdTlmServer::DEFAULT_PACKET_DATA_QUEUE_SIZE
Constants included from Extract
Extract::SCANNING_REGULAR_EXPRESSION
Instance Attribute Summary
Attributes inherited from CmdTlmServer
#limits_event_queue_mutex, #limits_event_queues, #next_limits_event_queue_id, #next_packet_data_queue_id, #packet_data_queue_mutex, #packet_data_queues
Instance Method Summary collapse
-
#limits_change_callback(packet, item, old_limits_state, value, log_change) ⇒ Object
Called when an item in any packet changes limits states.
-
#start(production = false) ⇒ Object
Start up the system by starting the JSON-RPC server, interfaces, routers, and background tasks.
-
#stop ⇒ Object
Properly shuts down the command and telemetry server by stoping the JSON-RPC server, background tasks, routers, and interfaces.
Methods inherited from CmdTlmServer
#background_tasks, clear_counters, #commanding, get_limits_event, get_packet_data, #graceful_kill, #initialize, instance, #interfaces, #json_drb, #message_log, meta_callback=, #packet_logging, #post_limits_event, #post_packet, #routers, #stop_callback=, subscribe_limits_events, subscribe_packet_data, #title, unsubscribe_limits_events, unsubscribe_packet_data
Methods included from Api
#cmd, #cmd_no_checks, #cmd_no_hazardous_check, #cmd_no_range_check, #cmd_raw, #cmd_raw_no_checks, #cmd_raw_no_hazardous_check, #cmd_raw_no_range_check, #connect_interface, #connect_router, #disable_limits, #disable_limits_group, #disconnect_interface, #disconnect_router, #enable_limits, #enable_limits_group, #get_cmd_hazardous, #get_cmd_list, #get_cmd_log_filename, #get_cmd_param_list, #get_cmd_time, #get_cmd_value, #get_interface_names, #get_limits, #get_limits_event, #get_limits_groups, #get_limits_set, #get_limits_sets, #get_out_of_limits, #get_overall_limits_state, #get_packet_data, #get_router_names, #get_server_message_log_filename, #get_stale, #get_target_list, #get_tlm_details, #get_tlm_item_list, #get_tlm_list, #get_tlm_log_filename, #get_tlm_packet, #get_tlm_values, #initialize, #interface_state, #limits_enabled?, #map_target_to_interface, #router_state, #send_raw, #set_limits, #set_limits_set, #set_tlm, #set_tlm_raw, #start_cmd_log, #start_logging, #start_new_server_message_log, #start_raw_logging_interface, #start_raw_logging_router, #start_tlm_log, #stop_cmd_log, #stop_logging, #stop_raw_logging_interface, #stop_raw_logging_router, #stop_tlm_log, #subscribe_limits_events, #subscribe_packet_data, #tlm, #tlm_formatted, #tlm_raw, #tlm_variable, #tlm_with_units, #unsubscribe_limits_events, #unsubscribe_packet_data
Constructor Details
This class inherits a constructor from Cosmos::CmdTlmServer
Instance Method Details
#limits_change_callback(packet, item, old_limits_state, value, log_change) ⇒ Object
Called when an item in any packet changes limits states.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/cosmos/tools/replay/replay_server.rb', line 65 def limits_change_callback(packet, item, old_limits_state, value, log_change) if log_change # Write to Server Messages that limits state has changed tgt_pkt_item_str = "#{packet.target_name} #{packet.packet_name} #{item.name} = #{value} is" time_string = '' time_string = packet.received_time.formatted << ' ' if packet.received_time case item.limits.state when :BLUE puts "<B>#{time_string}INFO: #{tgt_pkt_item_str} #{item.limits.state}" when :GREEN, :GREEN_LOW, :GREEN_HIGH puts "<G>#{time_string}INFO: #{tgt_pkt_item_str} #{item.limits.state}" when :YELLOW, :YELLOW_LOW, :YELLOW_HIGH puts "<Y>#{time_string}WARN: #{tgt_pkt_item_str} #{item.limits.state}" when :RED, :RED_LOW, :RED_HIGH puts "<R>#{time_string}ERROR: #{tgt_pkt_item_str} #{item.limits.state}" else puts "ERROR: #{tgt_pkt_item_str} UNKNOWN" end end post_limits_event(:LIMITS_CHANGE, [packet.target_name, packet.packet_name, item.name, old_limits_state, item.limits.state]) end |
#start(production = false) ⇒ Object
Start up the system by starting the JSON-RPC server, interfaces, routers, and background tasks. Starts a thread to monitor all packets for staleness so other tools (such as Packet Viewer or Telemetry Viewer) can react accordingly.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cosmos/tools/replay/replay_server.rb', line 23 def start(production = false) # Prevent access to interfaces or packet_logging @interfaces = nil @packet_logging = nil System.telemetry # Make sure definitions are loaded by starting anything return unless @json_drb.nil? # Start DRb with access control @json_drb = JsonDRb.new @json_drb.acl = System.acl if System.acl @json_drb.method_whitelist = @api_whitelist begin @json_drb.start_service("localhost", System.ports['CTS_API'], self) rescue Exception raise FatalError.new("Error starting JsonDRb on port #{System.ports['CTS_API']}.\nPerhaps a Command and Telemetry Server is already running?") end @routers.add_preidentified('PREIDENTIFIED_ROUTER', System.instance.ports['CTS_PREIDENTIFIED']) System.telemetry.limits_change_callback = method(:limits_change_callback) @routers.start end |
#stop ⇒ Object
Properly shuts down the command and telemetry server by stoping the JSON-RPC server, background tasks, routers, and interfaces. Also kills the packet staleness monitor thread.
50 51 52 53 54 55 |
# File 'lib/cosmos/tools/replay/replay_server.rb', line 50 def stop # Shutdown DRb @json_drb.stop_service @routers.stop @json_drb = nil end |