Class: Cosmos::RawDialog
- Inherits:
-
Qt::Dialog
- Object
- Qt::Dialog
- Cosmos::RawDialog
- Defined in:
- lib/cosmos/gui/dialogs/cmd_tlm_raw_dialog.rb
Direct Known Subclasses
Constant Summary collapse
- CMD_TYPE =
'cmd'
- TLM_TYPE =
'tlm'
- PACKET_UPDATE_PERIOD_MS =
1000
- HEADER1 =
"Address Data Ascii\n"
- HEADER2 =
"---------------------------------------------------------------------------\n"
- HEADER =
HEADER1 + HEADER2
- @@font =
nil
Instance Method Summary collapse
- #closeEvent(event) ⇒ Object
-
#initialize(parent, type, target_name, packet_name) ⇒ RawDialog
constructor
A new instance of RawDialog.
- #packet_update_timeout ⇒ Object
- #reject ⇒ Object
Methods inherited from Qt::Dialog
Constructor Details
#initialize(parent, type, target_name, packet_name) ⇒ RawDialog
Returns a new instance of RawDialog.
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 |
# File 'lib/cosmos/gui/dialogs/cmd_tlm_raw_dialog.rb', line 31 def initialize(parent, type, target_name, packet_name) super(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint) raise "RawDialog: Undefined type:#{type}" if type != CMD_TYPE and type != TLM_TYPE @type = type @done = false @target_name = target_name @packet_name = packet_name begin if @type == CMD_TYPE title = "Raw Command Packet: #{target_name} #{packet_name}" else title = "Raw Telemetry Packet: #{target_name} #{packet_name}" end setWindowTitle(title) @timer = Qt::Timer.new overall_layout = Qt::VBoxLayout.new top_layout = Qt::HBoxLayout.new text_layout = Qt::VBoxLayout.new title_label = Qt::Label.new(tr(title)) text_layout.addWidget(title_label) @packet_time = Qt::Label.new("Packet Received Time: ") text_layout.addWidget(@packet_time) top_layout.addLayout(text_layout) top_layout.addStretch(1) = Qt::PushButton.new(tr("Pause")) top_layout.addWidget() .connect(SIGNAL('clicked()')) do if .text == "Pause" .setText("Resume") @timer.method_missing(:stop) else .setText("Pause") @timer.method_missing(:start, PACKET_UPDATE_PERIOD_MS) end end overall_layout.addLayout(top_layout) @packet_data = Qt::PlainTextEdit.new @packet_data.setReadOnly(true) @packet_data.setWordWrapMode(Qt::TextOption::NoWrap) overall_layout.addWidget(@packet_data) if Kernel.is_windows? @@font = Cosmos.getFont('Courier', 10) unless @@font else @@font = Cosmos.getFont('Courier', 14) unless @@font end @format = @packet_data.currentCharFormat() @format.setFont(@@font) @packet_data.setCurrentCharFormat(@format) connect(@timer, SIGNAL('timeout()'), self, SLOT('packet_update_timeout()')) @timer.method_missing(:start, PACKET_UPDATE_PERIOD_MS) packet_update_timeout() self.setLayout(overall_layout) self.resize(700, 280) self.show self.raise rescue DRb::DRbConnError # Just do nothing end end |
Instance Method Details
#closeEvent(event) ⇒ Object
126 127 128 129 130 131 132 133 134 |
# File 'lib/cosmos/gui/dialogs/cmd_tlm_raw_dialog.rb', line 126 def closeEvent(event) super(event) if @timer @timer.stop @timer.dispose @timer = nil end self.dispose end |
#packet_update_timeout ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/cosmos/gui/dialogs/cmd_tlm_raw_dialog.rb', line 100 def packet_update_timeout if (@type == CMD_TYPE) packet = System.commands.packet(@target_name, @packet_name) else packet = System.telemetry.packet(@target_name, @packet_name) end packet_data = packet.buffer packet_time = packet.received_time @packet_time.setText("Received Time: #{packet_time.formatted}") if packet_time position_x = @packet_data.horizontalScrollBar.value position_y = @packet_data.verticalScrollBar.value @packet_data.setPlainText(HEADER + packet_data.formatted) @packet_data.horizontalScrollBar.setValue(position_x) @packet_data.verticalScrollBar.setValue(position_y) end |
#reject ⇒ Object
116 117 118 119 120 121 122 123 124 |
# File 'lib/cosmos/gui/dialogs/cmd_tlm_raw_dialog.rb', line 116 def reject super() if @timer @timer.stop @timer.dispose @timer = nil end self.dispose end |