cosmos 3.8.3 → 3.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -3
  3. data/Manifest.txt +14 -0
  4. data/Rakefile +35 -2
  5. data/autohotkey/config/targets/INST/screens/_footer.txt +4 -0
  6. data/autohotkey/config/targets/INST/screens/hs.txt +1 -4
  7. data/autohotkey/config/tools/table_manager/OldOneDimensionalTable_def.txt +19 -0
  8. data/autohotkey/config/tools/table_manager/OldTwoDimensionalTable_def.txt +248 -0
  9. data/autohotkey/config/tools/table_manager/OneDimensionalTable_def.txt +27 -15
  10. data/autohotkey/config/tools/table_manager/TwoDimensionalTable_def.txt +12 -232
  11. data/autohotkey/procedures/example_test.rb +4 -0
  12. data/autohotkey/tools/TableManagerAHK +4 -9
  13. data/autohotkey/tools/TableManagerAHK2 +18 -0
  14. data/autohotkey/tools/TableManagerAHK3 +18 -0
  15. data/autohotkey/tools/TableManagerAHK4 +24 -0
  16. data/autohotkey/tools/TlmViewerAHK +1 -1
  17. data/autohotkey/tools/autohotkey.rb +2 -1
  18. data/autohotkey/tools/open_gl_builder.ahk +1 -1
  19. data/autohotkey/tools/table_manager.ahk +141 -70
  20. data/cosmos.gemspec +3 -3
  21. data/data/crc.txt +70 -68
  22. data/data/legal.txt +4 -5
  23. data/demo/config/data/crc.txt +10 -9
  24. data/demo/config/targets/INST/screens/_footer.txt +4 -0
  25. data/demo/config/targets/INST/screens/hs.txt +1 -6
  26. data/demo/config/targets/INST/screens/limits.txt +3 -11
  27. data/demo/config/tools/cmd_tlm_server/cmd_tlm_server.txt +1 -0
  28. data/demo/config/tools/table_manager/MCConfigurationTable_fsw1_def.txt +33 -22
  29. data/demo/config/tools/table_manager/MCConfigurationTable_fsw2_def.txt +30 -22
  30. data/demo/config/tools/table_manager/PPSSelectionTable_def.txt +8 -7
  31. data/demo/config/tools/table_manager/TLMMonitoringTable_def.txt +13 -13
  32. data/demo/lib/example_background_task.rb +6 -12
  33. data/demo/procedures/example_test.rb +5 -0
  34. data/lib/cosmos/conversions/conversion.rb +3 -7
  35. data/lib/cosmos/core_ext/class.rb +3 -1
  36. data/lib/cosmos/core_ext/file.rb +1 -0
  37. data/lib/cosmos/core_ext/io.rb +18 -0
  38. data/lib/cosmos/core_ext/range.rb +1 -5
  39. data/lib/cosmos/core_ext/time.rb +3 -3
  40. data/lib/cosmos/gui/dialogs/about_dialog.rb +60 -36
  41. data/lib/cosmos/gui/dialogs/calendar_dialog.rb +10 -14
  42. data/lib/cosmos/gui/dialogs/cmd_details_dialog.rb +4 -5
  43. data/lib/cosmos/gui/dialogs/cmd_tlm_raw_dialog.rb +31 -17
  44. data/lib/cosmos/gui/dialogs/details_dialog.rb +63 -47
  45. data/lib/cosmos/gui/dialogs/exception_dialog.rb +77 -68
  46. data/lib/cosmos/gui/dialogs/exception_list_dialog.rb +6 -5
  47. data/lib/cosmos/gui/dialogs/legal_dialog.rb +34 -21
  48. data/lib/cosmos/gui/dialogs/packet_log_dialog.rb +19 -43
  49. data/lib/cosmos/gui/dialogs/progress_dialog.rb +79 -42
  50. data/lib/cosmos/gui/dialogs/pry_dialog.rb +9 -5
  51. data/lib/cosmos/gui/dialogs/scroll_text_dialog.rb +6 -4
  52. data/lib/cosmos/gui/dialogs/select_dialog.rb +23 -18
  53. data/lib/cosmos/gui/dialogs/set_tlm_dialog.rb +34 -10
  54. data/lib/cosmos/gui/dialogs/splash.rb +18 -8
  55. data/lib/cosmos/gui/dialogs/tlm_details_dialog.rb +38 -43
  56. data/lib/cosmos/gui/dialogs/tlm_edit_dialog.rb +51 -53
  57. data/lib/cosmos/gui/line_graph/line_graph_scaling.rb +1 -1
  58. data/lib/cosmos/gui/line_graph/lines.rb +1 -1
  59. data/lib/cosmos/gui/qt.rb +9 -2
  60. data/lib/cosmos/gui/qt_tool.rb +50 -8
  61. data/lib/cosmos/gui/widgets/packet_log_frame.rb +53 -27
  62. data/lib/cosmos/interfaces/linc_interface.rb +103 -62
  63. data/lib/cosmos/io/json_drb_object.rb +3 -3
  64. data/lib/cosmos/io/raw_logger.rb +4 -8
  65. data/lib/cosmos/io/tcpip_server.rb +2 -2
  66. data/lib/cosmos/packets/binary_accessor.rb +1 -1
  67. data/lib/cosmos/packets/limits.rb +2 -5
  68. data/lib/cosmos/packets/packet.rb +1 -1
  69. data/lib/cosmos/packets/packet_config.rb +54 -19
  70. data/lib/cosmos/packets/parsers/packet_item_parser.rb +7 -1
  71. data/lib/cosmos/script/scripting.rb +4 -5
  72. data/lib/cosmos/system/system.rb +2 -1
  73. data/lib/cosmos/system/target.rb +4 -0
  74. data/lib/cosmos/tools/cmd_tlm_server/background_task.rb +13 -5
  75. data/lib/cosmos/tools/cmd_tlm_server/background_tasks.rb +37 -27
  76. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb +6 -2
  77. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_config.rb +7 -5
  78. data/lib/cosmos/tools/cmd_tlm_server/gui/status_tab.rb +21 -10
  79. data/lib/cosmos/tools/limits_monitor/limits_monitor.rb +11 -11
  80. data/lib/cosmos/tools/script_runner/script_runner.rb +2 -18
  81. data/lib/cosmos/tools/script_runner/script_runner_frame.rb +6 -6
  82. data/lib/cosmos/tools/table_manager/table.rb +32 -41
  83. data/lib/cosmos/tools/table_manager/table_config.rb +140 -729
  84. data/lib/cosmos/tools/table_manager/table_item.rb +20 -36
  85. data/lib/cosmos/tools/table_manager/table_item_parser.rb +46 -0
  86. data/lib/cosmos/tools/table_manager/table_manager.rb +754 -691
  87. data/lib/cosmos/tools/table_manager/table_manager_core.rb +172 -358
  88. data/lib/cosmos/tools/table_manager/table_parser.rb +75 -0
  89. data/lib/cosmos/tools/test_runner/results_writer.rb +1 -1
  90. data/lib/cosmos/tools/test_runner/test_runner.rb +11 -0
  91. data/lib/cosmos/tools/tlm_grapher/data_object_adders/housekeeping_data_object_adder.rb +2 -2
  92. data/lib/cosmos/tools/tlm_grapher/data_object_adders/singlexy_data_object_adder.rb +2 -2
  93. data/lib/cosmos/tools/tlm_grapher/data_object_adders/xy_data_object_adder.rb +2 -2
  94. data/lib/cosmos/tools/tlm_grapher/data_objects/data_object.rb +4 -4
  95. data/lib/cosmos/tools/tlm_grapher/data_objects/housekeeping_data_object.rb +13 -13
  96. data/lib/cosmos/tools/tlm_grapher/data_objects/linegraph_data_object.rb +9 -9
  97. data/lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb +9 -9
  98. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_config.rb +4 -4
  99. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_tool.rb +1 -1
  100. data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +8 -18
  101. data/lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb +7 -4
  102. data/lib/cosmos/top_level.rb +12 -0
  103. data/lib/cosmos/version.rb +5 -5
  104. data/run_gui_tests.bat +6 -0
  105. data/spec/core_ext/array_spec.rb +1 -1
  106. data/spec/interfaces/linc_interface_spec.rb +4 -4
  107. data/spec/io/json_drb_spec.rb +2 -2
  108. data/spec/io/json_rpc_spec.rb +1 -1
  109. data/spec/io/raw_logger_spec.rb +5 -1
  110. data/spec/packet_logs/packet_log_writer_spec.rb +1 -1
  111. data/spec/packets/packet_config_spec.rb +144 -0
  112. data/spec/packets/parsers/packet_item_parser_spec.rb +60 -0
  113. data/spec/spec_helper.rb +11 -0
  114. data/spec/system/target_spec.rb +5 -1
  115. data/spec/tools/cmd_tlm_server/background_task_spec.rb +15 -3
  116. data/spec/tools/cmd_tlm_server/background_tasks_spec.rb +117 -31
  117. data/spec/tools/cmd_tlm_server/cmd_tlm_server_spec.rb +4 -0
  118. data/spec/tools/launcher/launcher_config_spec.rb +1 -1
  119. data/spec/tools/table_manager/table_config_spec.rb +226 -0
  120. data/spec/tools/table_manager/table_item_spec.rb +57 -0
  121. data/spec/tools/table_manager/table_parser_spec.rb +96 -0
  122. data/spec/tools/table_manager/table_spec.rb +90 -0
  123. data/spec/tools/table_manager/tablemanager_core_spec.rb +557 -0
  124. data/spec/top_level/top_level_spec.rb +9 -0
  125. data/spec/utilities/csv_spec.rb +3 -3
  126. metadata +30 -11
@@ -17,7 +17,7 @@ Cosmos.catch_fatal_exception do
17
17
  end
18
18
 
19
19
  module Cosmos
20
-
20
+ # Class to intercept keyPressEvents
21
21
  class PryLineEdit < Qt::LineEdit
22
22
  attr_accessor :keyPressCallback
23
23
  def keyPressEvent(event)
@@ -26,7 +26,11 @@ module Cosmos
26
26
  end
27
27
  end
28
28
 
29
+ # Creates a dialog with a {http://pryrepl.org pry instance}.
29
30
  class PryDialog < Qt::Dialog
31
+ # @param parent [Qt::Widget] Parent to this dialog
32
+ # @param pry_binding [Object] Ruby binding
33
+ # @param title [String] Dialog title
30
34
  def initialize(parent, pry_binding, title = 'Pry Dialog')
31
35
  super(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
32
36
  setMinimumWidth(700)
@@ -102,6 +106,8 @@ module Cosmos
102
106
  end
103
107
  end
104
108
 
109
+ # @param text [String] Text to append to the dialog and send to the pry
110
+ # instance
105
111
  def sendToPry(text)
106
112
  @text_edit.appendPlainText(text)
107
113
  @queue << text
@@ -159,7 +165,5 @@ module Cosmos
159
165
  def graceful_kill
160
166
  sendToPry("throw :breakout")
161
167
  end
162
-
163
- end # class PryDialog
164
-
165
- end # module Cosmos
168
+ end
169
+ end
@@ -11,8 +11,11 @@
11
11
  require 'cosmos/gui/qt'
12
12
 
13
13
  module Cosmos
14
-
14
+ # Dialog which creates a read only list of text
15
15
  class ScrollTextDialog < Qt::Dialog
16
+ # @param parent [Qt::Widget] Parent of this dialog
17
+ # @param title [String] Dialog title
18
+ # @param text [String] Text to display
16
19
  def initialize(parent, title, text)
17
20
  super(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
18
21
  setMinimumWidth(700)
@@ -32,6 +35,5 @@ module Cosmos
32
35
  self.exec
33
36
  self.dispose
34
37
  end
35
- end # class ScrollTextDialog
36
-
37
- end # module Cosmos
38
+ end
39
+ end
@@ -13,42 +13,47 @@ require 'cosmos/gui/qt'
13
13
  require 'cosmos/gui/choosers/combobox_chooser'
14
14
 
15
15
  module Cosmos
16
-
17
- class SelectDialog
16
+ # Dialog which displays a label and comobox of items along with Ok and Cancel
17
+ # buttons.
18
+ class SelectDialog < Qt::Dialog
19
+ # @return [String] The current combobox item when the dialog was accepte
20
+ # with the Ok button
18
21
  attr_accessor :result
19
22
 
23
+ # @param parent [Qt::Widget] Parent of this dialog
24
+ # @param label_text [String] Text to display for the label
25
+ # @param items [Array<String>] Items to display in the combobox
26
+ # @param title [String] Dialog title
20
27
  def initialize(parent, label_text, items, title = 'Select Item')
28
+ super(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
21
29
  @result = nil
22
30
 
23
- dialog = Qt::Dialog.new(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
24
- dialog.setWindowTitle(title)
25
- dialog_layout = Qt::VBoxLayout.new
26
-
27
- chooser = ComboboxChooser.new(dialog, label_text, items)
28
- dialog_layout.addWidget(chooser)
31
+ setWindowTitle(title)
32
+ layout = Qt::VBoxLayout.new
33
+ chooser = ComboboxChooser.new(self, label_text, items)
34
+ layout.addWidget(chooser)
29
35
 
30
36
  button_layout = Qt::HBoxLayout.new
31
37
  ok = Qt::PushButton.new("Ok")
32
38
  ok.connect(SIGNAL('clicked()')) do
33
- dialog.accept()
39
+ accept()
34
40
  end
35
41
  button_layout.addWidget(ok)
36
42
  cancel = Qt::PushButton.new("Cancel")
37
43
  cancel.connect(SIGNAL('clicked()')) do
38
- dialog.reject()
44
+ reject()
39
45
  end
40
46
  button_layout.addWidget(cancel)
41
- dialog_layout.addLayout(button_layout)
47
+ layout.addLayout(button_layout)
42
48
 
43
- dialog.setLayout(dialog_layout)
44
- dialog.raise
45
- if dialog.exec == Qt::Dialog::Accepted
49
+ setLayout(layout)
50
+ self.raise
51
+ if self.exec == Qt::Dialog::Accepted
46
52
  @result = chooser.string
47
53
  else
48
54
  @result = nil
49
55
  end
50
- dialog.dispose
56
+ self.dispose
51
57
  end
52
- end # class TlmEditDialog
53
-
54
- end # module Cosmos
58
+ end
59
+ end
@@ -14,14 +14,38 @@ require 'cosmos/tools/cmd_tlm_server/cmd_tlm_server'
14
14
  require 'cosmos/tools/cmd_tlm_server/api'
15
15
 
16
16
  module Cosmos
17
-
17
+ # Dialog which parses the specified packet and creates labels and values for
18
+ # each packet item. Items with states are displayed as comboboxes. The user
19
+ # can change any of the values and upon clicking the done button the values
20
+ # are written back into the packet.
18
21
  class SetTlmDialog < Qt::Dialog
22
+ # @return [Array<String>] Items which should not be displayed in the dialog
19
23
  IGNORED_ITEMS = ['RECEIVED_TIMESECONDS', 'RECEIVED_TIMEFORMATTED', 'RECEIVED_COUNT']
20
24
 
25
+ # @return [String] Errors encountered when trying to set the values back
26
+ # into the packet
21
27
  attr_reader :error_label
28
+ # @return [String] Name of the item which has encountered an error
22
29
  attr_accessor :current_item_name
23
30
 
24
- def initialize(parent, title, done_label, cancel_label, target_name, packet_name, packet = nil)
31
+ # @param parent [Qt::Widget] Parent of this dialog
32
+ # @param title [String] Dialog title
33
+ # @param done_button [String] Text to place on the button which will close
34
+ # the dialog and update the packet
35
+ # @param cancel_button [String] Text to place on the button which will close
36
+ # the dialog without setting the packet
37
+ # @param target_name [String] Name of the target
38
+ # @param packet_name [String] Name of the packet
39
+ # @param packet [Packet] If the packet is given the items will be taken
40
+ # from the packet instead of using the target_name and packet_name to look
41
+ # up the packet from the system.
42
+ def initialize(parent,
43
+ title,
44
+ done_button,
45
+ cancel_button,
46
+ target_name,
47
+ packet_name,
48
+ packet = nil)
25
49
  super(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
26
50
  @target_name = target_name
27
51
  @packet_name = packet_name
@@ -85,12 +109,12 @@ module Cosmos
85
109
 
86
110
  button_layout = Qt::HBoxLayout.new
87
111
  # Create Done Button
88
- done_button = Qt::PushButton.new(done_label)
112
+ done_button = Qt::PushButton.new(done_button)
89
113
  connect(done_button, SIGNAL('clicked()'), self, SLOT('accept()'))
90
114
  button_layout.addWidget(done_button)
91
115
 
92
116
  # Create Cancel Button
93
- cancel_button = Qt::PushButton.new(cancel_label)
117
+ cancel_button = Qt::PushButton.new(cancel_button)
94
118
  connect(cancel_button, SIGNAL('clicked()'), self, SLOT('reject()'))
95
119
  button_layout.addWidget(cancel_button)
96
120
  layout.addLayout(button_layout)
@@ -98,6 +122,7 @@ module Cosmos
98
122
  self.setLayout(layout)
99
123
  end
100
124
 
125
+ # Set all user edited items from the dialog back into the packet
101
126
  def set_items
102
127
  index = 0
103
128
  @items.each do |item_name, _, _|
@@ -107,8 +132,9 @@ module Cosmos
107
132
  end
108
133
  end
109
134
 
110
- def self.execute(parent, title, done_label, cancel_label, target_name, packet_name, packet = nil)
111
- dialog = self.new(parent, title, done_label, cancel_label, target_name, packet_name, packet)
135
+ # (see #initialize)
136
+ def self.execute(parent, title, done_button, cancel_button, target_name, packet_name, packet = nil)
137
+ dialog = self.new(parent, title, done_button, cancel_button, target_name, packet_name, packet)
112
138
  begin
113
139
  dialog.raise
114
140
  if dialog.exec == Qt::Dialog::Accepted
@@ -125,7 +151,5 @@ module Cosmos
125
151
  end
126
152
  result
127
153
  end
128
-
129
- end # class SetTlmDialog
130
-
131
- end # module Cosmos
154
+ end
155
+ end
@@ -15,10 +15,12 @@ require 'cosmos/gui/qt_tool'
15
15
  require 'cosmos/gui/dialogs/exception_dialog'
16
16
 
17
17
  module Cosmos
18
-
18
+ # Provides a single class method which creates a splash screen dialog box.
19
+ # This dialog has both a text message box and progress bar.
19
20
  class Splash
20
-
21
+ # Creates a dialog with a message box and a progress bar.
21
22
  class SplashDialogBox < Qt::Dialog
23
+ # @param parent [Qt::Widget] The dialog parent
22
24
  def initialize(parent)
23
25
  super(parent, Qt::WindowTitleHint | Qt::CustomizeWindowHint)
24
26
  setWindowTitle(parent.windowTitle)
@@ -43,6 +45,8 @@ module Cosmos
43
45
  @complete = false
44
46
  end
45
47
 
48
+ # @param message [String] Text to place in the message box. Text is
49
+ # replaced and not appended.
46
50
  def message=(message)
47
51
  unless @complete
48
52
  Qt.execute_in_main_thread(false) do
@@ -51,6 +55,7 @@ module Cosmos
51
55
  end
52
56
  end
53
57
 
58
+ # @param progress [Float] Set the progress bar to a percentage from 0 to 1
54
59
  def progress=(progress)
55
60
  progress_int = (progress * 100).to_i
56
61
  if !@complete and @progress != progress_int
@@ -61,14 +66,18 @@ module Cosmos
61
66
  end
62
67
  end
63
68
 
69
+ # @return [Method] message= method
64
70
  def message_callback
65
71
  method(:message=)
66
72
  end
67
73
 
74
+ # @return [Method] progress= method
68
75
  def progress_callback
69
76
  method(:progress=)
70
77
  end
71
78
 
79
+ # Override keyPressEvent to prevent Esc from closing the splash dialog
80
+ # @param event [Qt::KeyEvent] Pressed key event
72
81
  def keyPressEvent(event)
73
82
  # Don't allow the Escape key to close this dialog
74
83
  if event.key == Qt::Key_Escape
@@ -79,6 +88,10 @@ module Cosmos
79
88
  end
80
89
  end
81
90
 
91
+ # @param parent [Qt::Widget] Dialog parent
92
+ # @param wait_for_complete [Boolean] Whether to call dialog.exec and block
93
+ # other threads from running until this dialog is closed
94
+ # @yieldparam dialog [SplashDialogBox] The dialog box
82
95
  def self.execute(parent, wait_for_complete = false, &block)
83
96
  # Create the dialog and show it
84
97
  dialog = SplashDialogBox.new(parent)
@@ -122,14 +135,11 @@ module Cosmos
122
135
  end
123
136
  if wait_for_complete
124
137
  dialog.exec
125
-
126
- # Need to make sure all Qt.execute_in_main_thread() have completed before disposing or
127
- # we will segfault
138
+ # Need to make sure all Qt.execute_in_main_thread() have completed
139
+ # before disposing or we will segfault
128
140
  Qt::RubyThreadFix.queue.pop.call until Qt::RubyThreadFix.queue.empty?
129
-
130
141
  dialog.dispose
131
142
  end
132
143
  end
133
144
  end
134
-
135
- end # module Cosmos
145
+ end
@@ -13,15 +13,23 @@
13
13
 
14
14
  require 'cosmos'
15
15
  require 'cosmos/gui/dialogs/details_dialog'
16
+ require 'cosmos/packets/packet'
16
17
 
17
18
  module Cosmos
18
-
19
+ # Creates a dialog which shows the details of the given telemetry item.
19
20
  class TlmDetailsDialog < DetailsDialog
20
21
  slots 'value_update_timeout()'
21
22
 
23
+ # Period for the update thread which updates the dialog values
22
24
  VALUE_UPDATE_PERIOD_MS = 1000
23
- VALUE_TYPES = [:RAW, :CONVERTED, :FORMATTED, :WITH_UNITS]
24
25
 
26
+ # @param parent (see DetailsDialog#initialize)
27
+ # @param target_name (see DetailsDialog#initialize)
28
+ # @param packet_name (see DetailsDialog#initialize)
29
+ # @param item_name (see DetailsDialog#initialize)
30
+ # @param packet [Packet] If a Packet is given the dialog will read the
31
+ # value from the given packet and will not update. If the packet
32
+ # parameters is nil the value will be read continously from the System.
25
33
  def initialize(parent, target_name, packet_name, item_name, packet = nil)
26
34
  super(parent, target_name, packet_name, item_name)
27
35
 
@@ -116,14 +124,12 @@ module Cosmos
116
124
  end
117
125
 
118
126
  def value_update_timeout
119
- begin
120
- # Gather updated values
121
- values, limits_states, limits_settings, limits_set = get_tlm_values(@item_array, VALUE_TYPES)
122
- update_limits_details(limits_settings, limits_set)
123
- update_text_fields(values, limits_states[0])
124
- rescue DRb::DRbConnError
125
- # Just do nothing
126
- end
127
+ # Gather updated values
128
+ values, limits_states, limits_settings, limits_set = get_tlm_values(@item_array, Packet::VALUE_TYPES)
129
+ update_limits_details(limits_settings, limits_set)
130
+ update_text_fields(values, limits_states[0])
131
+ rescue DRb::DRbConnError
132
+ # Just do nothing
127
133
  end
128
134
 
129
135
  protected
@@ -143,44 +149,35 @@ module Cosmos
143
149
  end
144
150
 
145
151
  def update_limits_details(limits_settings, limits_set)
146
- if limits_settings[0]
147
- label_text = "RL/#{limits_settings[0][0]} YL/#{limits_settings[0][1]} YH/#{limits_settings[0][2]} RH/#{limits_settings[0][3]}"
148
- if limits_settings[0][4] and limits_settings[0][5]
149
- label_text << " GL/#{limits_settings[0][4]} GH/#{limits_settings[0][5]}"
150
- end
151
- if @limits_labels[limits_set]
152
- @limits_labels[limits_set].text = label_text
153
- elsif @limits_layout
154
- label = Qt::Label.new(label_text)
155
- @limits_labels[limits_set] = label
156
- @limits_layout.addRow(tr("#{limits_set}:"), label)
157
- end
152
+ return unless limits_settings[0]
153
+ label_text = "RL/#{limits_settings[0][0]} YL/#{limits_settings[0][1]} YH/#{limits_settings[0][2]} RH/#{limits_settings[0][3]}"
154
+ if limits_settings[0][4] and limits_settings[0][5]
155
+ label_text << " GL/#{limits_settings[0][4]} GH/#{limits_settings[0][5]}"
156
+ end
157
+ if @limits_labels[limits_set]
158
+ @limits_labels[limits_set].text = label_text
159
+ elsif @limits_layout
160
+ label = Qt::Label.new(label_text)
161
+ @limits_labels[limits_set] = label
162
+ @limits_layout.addRow(tr("#{limits_set}:"), label)
158
163
  end
159
164
  end
160
165
 
161
166
  def determine_limits_color(limit_state)
162
- color = nil
163
167
  case limit_state
164
- when :RED, :RED_HIGH
165
- color = Cosmos::RED
166
- when :RED_LOW
167
- color = Cosmos::RED
168
- when :YELLOW, :YELLOW_HIGH
169
- color = Cosmos::YELLOW
170
- when :YELLOW_LOW
171
- color = Cosmos::YELLOW
172
- when :GREEN, :GREEN_HIGH
173
- color = Cosmos::GREEN
174
- when :GREEN_LOW
175
- color = Cosmos::GREEN
168
+ when :RED, :RED_HIGH, :RED_LOW
169
+ Cosmos::RED
170
+ when :YELLOW, :YELLOW_HIGH, :YELLOW_LOW
171
+ Cosmos::YELLOW
172
+ when :GREEN, :GREEN_HIGH, :GREEN_LOW
173
+ Cosmos::GREEN
176
174
  when :BLUE
177
- color = Cosmos::BLUE
175
+ Cosmos::BLUE
178
176
  when :STALE
179
- color = Cosmos::PURPLE
177
+ Cosmos::PURPLE
180
178
  else
181
- color = Cosmos::BLACK
179
+ Cosmos::BLACK
182
180
  end
183
- color
184
181
  end
185
182
 
186
183
  def update_text_fields(values, limits_state)
@@ -200,7 +197,5 @@ module Cosmos
200
197
  @limits_state.setColors(color, Cosmos::WHITE)
201
198
  @limits_state.text = limits_state.to_s
202
199
  end
203
-
204
- end # class TlmDetailsDialog
205
-
206
- end # module Cosmos
200
+ end
201
+ end
@@ -16,66 +16,64 @@ require 'cosmos/gui/qt'
16
16
  require 'cosmos/script'
17
17
 
18
18
  module Cosmos
19
-
20
- # TlmEditDialog class
21
- #
19
+ # Dialog which allows the user to enable or disable limits checking for the
20
+ # given item.
22
21
  class TlmEditDialog
23
- def initialize (parent, target_name, packet_name, item_name)
22
+ # @param parent [Qt::Widget] Dialog parent
23
+ # @param target_name [String] Name of the target
24
+ # @param packet_name [String] Name of the packet
25
+ # @param item_name [String] Name of the item
26
+ def initialize(parent, target_name, packet_name, item_name)
24
27
  begin
25
- begin
26
- limits_enabled = limits_enabled?(target_name, packet_name, item_name)
27
- rescue RuntimeError
28
- # Error most likely due to LATEST packet - Ignore
29
- limits_enabled = nil
30
- end
28
+ limits_enabled = limits_enabled?(target_name, packet_name, item_name)
29
+ rescue RuntimeError
30
+ # Error most likely due to LATEST packet - Ignore
31
+ limits_enabled = nil
32
+ end
31
33
 
32
- unless limits_enabled.nil?
33
- dialog = Qt::Dialog.new(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
34
- dialog.setWindowTitle("Edit Settings for #{target_name} #{packet_name} #{item_name}")
35
- dialog_layout = Qt::VBoxLayout.new
36
- dialog_layout.addWidget(Qt::Label.new("Warning: Edits affect all COSMOS tools, not just this application!"))
34
+ # Check for nil because true and false are both valid values
35
+ if limits_enabled.nil?
36
+ Qt::MessageBox.information(parent, "Edit Settings for #{target_name} #{packet_name} #{item_name}",
37
+ 'No Editable Fields for this Item')
38
+ return
39
+ end
40
+
41
+ dialog = Qt::Dialog.new(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
42
+ dialog.setWindowTitle("Edit Settings for #{target_name} #{packet_name} #{item_name}")
43
+ dialog_layout = Qt::VBoxLayout.new
44
+ dialog_layout.addWidget(Qt::Label.new("Warning: Edits affect all COSMOS tools, not just this application!"))
37
45
 
38
- check_layout = Qt::HBoxLayout.new
39
- check_label = Qt::Label.new("Limits Checking Enabled:")
40
- checkbox = Qt::CheckBox.new
41
- checkbox.setChecked(limits_enabled)
42
- check_label.setBuddy(checkbox)
43
- check_layout.addWidget(check_label)
44
- check_layout.addWidget(checkbox)
45
- dialog_layout.addLayout(check_layout)
46
+ check_layout = Qt::HBoxLayout.new
47
+ check_label = Qt::Label.new("Limits Checking Enabled:")
48
+ checkbox = Qt::CheckBox.new
49
+ checkbox.setChecked(limits_enabled)
50
+ check_label.setBuddy(checkbox)
51
+ check_layout.addWidget(check_label)
52
+ check_layout.addWidget(checkbox)
53
+ dialog_layout.addLayout(check_layout)
46
54
 
47
- button_layout = Qt::HBoxLayout.new
48
- ok = Qt::PushButton.new("Ok")
49
- ok.connect(SIGNAL('clicked()')) do
50
- dialog.accept()
51
- end
52
- button_layout.addWidget(ok)
53
- cancel = Qt::PushButton.new("Cancel")
54
- cancel.connect(SIGNAL('clicked()')) do
55
- dialog.reject()
56
- end
57
- button_layout.addWidget(cancel)
58
- dialog_layout.addLayout(button_layout)
55
+ button_layout = Qt::HBoxLayout.new
56
+ ok = Qt::PushButton.new("Ok")
57
+ ok.connect(SIGNAL('clicked()')) { dialog.accept }
58
+ button_layout.addWidget(ok)
59
+ cancel = Qt::PushButton.new("Cancel")
60
+ cancel.connect(SIGNAL('clicked()')) { dialog.reject }
61
+ button_layout.addWidget(cancel)
62
+ dialog_layout.addLayout(button_layout)
59
63
 
60
- dialog.setLayout(dialog_layout)
61
- dialog.show
62
- dialog.raise
63
- if dialog.exec == Qt::Dialog::Accepted
64
- if checkbox.isChecked()
65
- enable_limits(target_name, packet_name, item_name)
66
- else
67
- disable_limits(target_name, packet_name, item_name)
68
- end
69
- end
70
- dialog.dispose
64
+ dialog.setLayout(dialog_layout)
65
+ dialog.show
66
+ dialog.raise
67
+ if dialog.exec == Qt::Dialog::Accepted
68
+ if checkbox.isChecked()
69
+ enable_limits(target_name, packet_name, item_name)
71
70
  else
72
- Qt::MessageBox.information(parent, "Edit Settings for #{target_name} #{packet_name} #{item_name}",
73
- 'No Editable Fields for this Item')
71
+ disable_limits(target_name, packet_name, item_name)
74
72
  end
75
- rescue DRb::DRbConnError
76
- #Just do nothing
77
73
  end
74
+ dialog.dispose
75
+ rescue DRb::DRbConnError
76
+ # Just do nothing
78
77
  end
79
- end # class TlmEditDialog
80
-
81
- end # module Cosmos
78
+ end
79
+ end