Class: Cosmos::SetTlmDialog
- Inherits:
-
Qt::Dialog
- Object
- Qt::Dialog
- Cosmos::SetTlmDialog
- Defined in:
- lib/cosmos/gui/dialogs/set_tlm_dialog.rb
Constant Summary collapse
- IGNORED_ITEMS =
['RECEIVED_TIMESECONDS', 'RECEIVED_TIMEFORMATTED', 'RECEIVED_COUNT']
Instance Attribute Summary collapse
-
#current_item_name ⇒ Object
Returns the value of attribute current_item_name.
-
#error_label ⇒ Object
readonly
Returns the value of attribute error_label.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(parent, title, done_label, cancel_label, target_name, packet_name, packet = nil) ⇒ SetTlmDialog
constructor
A new instance of SetTlmDialog.
- #set_items ⇒ Object
Methods inherited from Qt::Dialog
Constructor Details
#initialize(parent, title, done_label, cancel_label, target_name, packet_name, packet = nil) ⇒ SetTlmDialog
Returns a new instance of SetTlmDialog.
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 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 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/cosmos/gui/dialogs/set_tlm_dialog.rb', line 24 def initialize(parent, title, done_label, cancel_label, target_name, packet_name, packet = nil) super(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint) @target_name = target_name @packet_name = packet_name @current_item_name = nil extend Api if CmdTlmServer.instance if !packet @items = get_tlm_packet(@target_name, @packet_name) else @items = packet.read_all_with_limits_states end @items.delete_if {|item_name, _, _| ['RECEIVED_TIMESECONDS', 'RECEIVED_TIMEFORMATTED', 'RECEIVED_COUNT'].include?(item_name)} setWindowTitle(title) Cosmos.load_cosmos_icon layout = Qt::VBoxLayout.new @tab_book = Qt::TabWidget.new values_layout = Qt::FormLayout.new = Qt::Widget.new .layout = values_layout page_count = 1 @tab_book.addTab(, "Page #{page_count}") @editors = [] @items.each do |item_name, item_value, _| _, item = System.telemetry.packet_and_item(@target_name, @packet_name, item_name) if item.states @editors << Qt::ComboBox.new @editors[-1].setSizeAdjustPolicy(Qt::ComboBox::AdjustToContents) current_index = 0 index = 0 item.states.each do |state_name, state_value| @editors[-1].addItem(state_name) current_index = index if state_name == item_value index += 1 end if item.states.length > 20 @editors[-1].setMaxVisibleItems(20) else @editors[-1].setMaxVisibleItems(item.states.length) end @editors[-1].setCurrentIndex(current_index) else @editors << Qt::LineEdit.new @editors[-1].text = item_value.to_s end values_layout.addRow(item_name, @editors[-1]) if ((@editors.length % 10) == 0 and @items.length > @editors.length) values_layout = Qt::FormLayout.new = Qt::Widget.new .layout = values_layout page_count += 1 @tab_book.addTab(, "Page #{page_count}") end end layout.addWidget(@tab_book) @error_label = Qt::Label.new('') layout.addWidget(@error_label) = Qt::HBoxLayout.new # Create Done Button = Qt::PushButton.new(done_label) connect(, SIGNAL('clicked()'), self, SLOT('accept()')) .addWidget() # Create Cancel Button = Qt::PushButton.new(cancel_label) connect(, SIGNAL('clicked()'), self, SLOT('reject()')) .addWidget() layout.addLayout() self.setLayout(layout) end |
Instance Attribute Details
#current_item_name ⇒ Object
Returns the value of attribute current_item_name.
22 23 24 |
# File 'lib/cosmos/gui/dialogs/set_tlm_dialog.rb', line 22 def current_item_name @current_item_name end |
#error_label ⇒ Object (readonly)
Returns the value of attribute error_label.
21 22 23 |
# File 'lib/cosmos/gui/dialogs/set_tlm_dialog.rb', line 21 def error_label @error_label end |
Class Method Details
.execute(parent, title, done_label, cancel_label, target_name, packet_name, packet = nil) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/cosmos/gui/dialogs/set_tlm_dialog.rb', line 110 def self.execute(parent, title, done_label, cancel_label, target_name, packet_name, packet = nil) dialog = self.new(parent, title, done_label, cancel_label, target_name, packet_name, packet) begin dialog.raise if dialog.exec == Qt::Dialog::Accepted dialog.set_items result = true else result = false end rescue => err dialog.error_label.setText("Error Setting #{dialog.current_item_name}: " + err.) retry ensure dialog.dispose end result end |
Instance Method Details
#set_items ⇒ Object
101 102 103 104 105 106 107 108 |
# File 'lib/cosmos/gui/dialogs/set_tlm_dialog.rb', line 101 def set_items index = 0 @items.each do |item_name, _, _| @current_item_name = item_name set_tlm(@target_name, @packet_name, item_name, @editors[index].text) index += 1 end end |