Class: Cosmos::TabbedPlotsRealtimeThread
- Inherits:
-
InterfaceThread
- Object
- InterfaceThread
- Cosmos::TabbedPlotsRealtimeThread
- Defined in:
- lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_realtime_thread.rb
Overview
Thread used to gather telemetry in realtime and process it using a TabbedPlotsDefinition
Constant Summary
Constants inherited from InterfaceThread
InterfaceThread::UNKNOWN_BYTES_TO_PRINT
Instance Attribute Summary
Attributes inherited from InterfaceThread
#connection_failed_callback, #connection_lost_callback, #connection_success_callback, #fatal_exception_callback, #identified_packet_callback
Instance Method Summary collapse
-
#graceful_kill ⇒ Object
def kill.
-
#initialize(tabbed_plots_config, connection_success_callback = nil, connection_failed_callback = nil, connection_lost_callback = nil, fatal_exception_callback = nil) ⇒ TabbedPlotsRealtimeThread
constructor
Create a new TabbedPlotsRealtimeThread.
-
#kill ⇒ Object
Kills the realtime thread.
-
#received_packet_callback(packet) ⇒ Object
Callback to the system definition when a packet is received.
Methods inherited from InterfaceThread
Constructor Details
#initialize(tabbed_plots_config, connection_success_callback = nil, connection_failed_callback = nil, connection_lost_callback = nil, fatal_exception_callback = nil) ⇒ TabbedPlotsRealtimeThread
Create a new TabbedPlotsRealtimeThread
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_realtime_thread.rb', line 21 def initialize(tabbed_plots_config, connection_success_callback = nil, connection_failed_callback = nil, connection_lost_callback = nil, fatal_exception_callback = nil) interface = TcpipClientInterface.new('localhost', nil, System.ports['CTS_PREIDENTIFIED'], nil, 10.0, 'PREIDENTIFIED') super(interface) @queue = Queue.new @tabbed_plots_config = tabbed_plots_config # Connect callbacks self.identified_packet_callback = method(:received_packet_callback) self.connection_success_callback = connection_success_callback self.connection_failed_callback = connection_failed_callback self.connection_lost_callback = connection_lost_callback self.fatal_exception_callback = fatal_exception_callback @process_thread = Thread.new do begin loop do packet = @queue.pop break unless packet @tabbed_plots_config.process_packet(packet) end rescue Exception => error if self.fatal_exception_callback self.fatal_exception_callback.call(error) end end end # Start interface thread start() end |
Instance Method Details
#graceful_kill ⇒ Object
def kill
66 67 68 69 70 71 72 73 74 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_realtime_thread.rb', line 66 def graceful_kill # Allow the callbacks a chance to update the GUI so that they can die gracefully if defined? Qt and Thread.current == Thread.main 5.times do Qt::CoreApplication.instance.processEvents sleep(0.05) end end end |
#kill ⇒ Object
Kills the realtime thread
59 60 61 62 63 64 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_realtime_thread.rb', line 59 def kill @queue << nil stop() Cosmos.kill_thread(self, @process_thread) @process_thread = nil end |
#received_packet_callback(packet) ⇒ Object
Callback to the system definition when a packet is received
54 55 56 |
# File 'lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_realtime_thread.rb', line 54 def received_packet_callback(packet) @queue << packet.clone end |