Class: Cosmos::InterfacesTab
- Defined in:
- lib/cosmos/tools/cmd_tlm_server/gui/interfaces_tab.rb
Overview
Implements the interfaces and routers tabs in the Command and Telemetry Server GUI
Constant Summary collapse
- INTERFACES =
'Interfaces'
- ROUTERS =
'Routers'
- ALIGN_CENTER =
Qt::AlignCenter
Instance Method Summary collapse
-
#initialize ⇒ InterfacesTab
constructor
A new instance of InterfacesTab.
-
#populate_interfaces(tab_widget) ⇒ Object
Create the interfaces tab and add it to the tab_widget.
-
#populate_routers(tab_widget) ⇒ Object
Create the routers tab and add it to the tab_widget.
-
#update(name) ⇒ Object
Update the interfaces or routers tab.
Constructor Details
#initialize ⇒ InterfacesTab
Returns a new instance of InterfacesTab.
22 23 24 |
# File 'lib/cosmos/tools/cmd_tlm_server/gui/interfaces_tab.rb', line 22 def initialize @interfaces_table = {} end |
Instance Method Details
#populate_interfaces(tab_widget) ⇒ Object
Create the interfaces tab and add it to the tab_widget
29 30 31 |
# File 'lib/cosmos/tools/cmd_tlm_server/gui/interfaces_tab.rb', line 29 def populate_interfaces() populate(INTERFACES, CmdTlmServer.interfaces, ) end |
#populate_routers(tab_widget) ⇒ Object
Create the routers tab and add it to the tab_widget
36 37 38 |
# File 'lib/cosmos/tools/cmd_tlm_server/gui/interfaces_tab.rb', line 36 def populate_routers() populate(ROUTERS, CmdTlmServer.routers, ) end |
#update(name) ⇒ Object
Update the interfaces or routers tab
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/cosmos/tools/cmd_tlm_server/gui/interfaces_tab.rb', line 43 def update(name) if name == ROUTERS interfaces = CmdTlmServer.routers else interfaces = CmdTlmServer.interfaces end row = 0 interfaces.all.each do |interface_name, interface| = @interfaces_table[name].cellWidget(row,1) state = @interfaces_table[name].item(row,2) if interface.connected? and interface.thread .setText('Disconnect') .setDisabled(true) if interface.disable_disconnect state.setText('true') state.textColor = Cosmos::GREEN elsif interface.thread .text = 'Cancel Connect' .setDisabled(false) state.setText('attempting') state.textColor = Cosmos::RED elsif interface.connected? .setText('Error') .setDisabled(false) state.setText('error') state.textColor = Cosmos::RED else .setText('Connect') .setDisabled(false) state.setText('false') state.textColor = Cosmos::BLACK end @interfaces_table[name].item(row,3).setText(interface.num_clients.to_s) @interfaces_table[name].item(row,4).setText(interface.write_queue_size.to_s) @interfaces_table[name].item(row,5).setText(interface.read_queue_size.to_s) @interfaces_table[name].item(row,6).setText(interface.bytes_written.to_s) @interfaces_table[name].item(row,7).setText(interface.bytes_read.to_s) if name == ROUTERS @interfaces_table[name].item(row,8).setText(interface.read_count.to_s) @interfaces_table[name].item(row,9).setText(interface.write_count.to_s) else @interfaces_table[name].item(row,8).setText(interface.write_count.to_s) @interfaces_table[name].item(row,9).setText(interface.read_count.to_s) end row += 1 end end |