Class: Cosmos::TargetsTab

Inherits:
Object show all
Defined in:
lib/cosmos/tools/cmd_tlm_server/gui/targets_tab.rb

Overview

Implements the targets tab in the Command and Telemetry Server GUI

Instance Method Summary collapse

Instance Method Details

#populate(tab_widget) ⇒ Object

Create the targets tab and add it to the tab_widget

Parameters:

  • tab_widget (Qt::TabWidget)

    The tab widget to add the tab to



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
# File 'lib/cosmos/tools/cmd_tlm_server/gui/targets_tab.rb', line 22

def populate(tab_widget)
  num_targets = System.targets.length
  if num_targets > 0
    return if num_targets == 1 and System.targets['SYSTEM']
    num_targets -= 1 if System.targets['SYSTEM']

    scroll = Qt::ScrollArea.new
    widget = Qt::Widget.new
    layout = Qt::VBoxLayout.new(widget)
    # Since the layout will be inside a scroll area make sure it respects the sizes we set
    layout.setSizeConstraint(Qt::Layout::SetMinAndMaxSize)

    @targets_table = Qt::TableWidget.new()
    @targets_table.verticalHeader.hide()
    @targets_table.setRowCount(num_targets)
    @targets_table.setColumnCount(4)
    @targets_table.setHorizontalHeaderLabels(["Target Name", "Interface", "Command Count", "Telemetry Count"])

    populate_targets_table()

    @targets_table.displayFullSize

    layout.addWidget(@targets_table)
    scroll.setWidget(widget)
    tab_widget.addTab(scroll, "Targets")
  end
end

#updateObject

Update the targets tab gui



51
52
53
54
55
56
57
58
59
# File 'lib/cosmos/tools/cmd_tlm_server/gui/targets_tab.rb', line 51

def update
  row = 0
  System.targets.sort.each do |target_name, target|
    next if target_name == 'SYSTEM'
    @targets_table.item(row,2).setText(target.cmd_cnt.to_s)
    @targets_table.item(row,3).setText(target.tlm_cnt.to_s)
    row += 1
  end
end