cosmos 4.4.0-java → 4.5.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +2 -0
  3. data/.gitignore +1 -0
  4. data/.travis.yml +6 -6
  5. data/Dockerfile +70 -0
  6. data/Manifest.txt +37 -2
  7. data/README.md +9 -0
  8. data/Rakefile +55 -5
  9. data/appveyor.yml +18 -8
  10. data/autohotkey/config/tools/cmd_sequence/cmd_sequence.txt +2 -0
  11. data/autohotkey/lib/cmd_sequence_exporter.rb +52 -0
  12. data/autohotkey/procedures/collect.rb +2 -2
  13. data/autohotkey/procedures/collect_util.rb +1 -1
  14. data/autohotkey/procedures/script_test.rb +1 -1
  15. data/autohotkey/tools/CmdSenderAHK2 +18 -0
  16. data/autohotkey/tools/cmd_extractor.ahk +11 -9
  17. data/autohotkey/tools/cmd_sender.ahk +35 -7
  18. data/autohotkey/tools/cmd_sender2.ahk +4 -0
  19. data/autohotkey/tools/cmd_sequence.ahk +22 -9
  20. data/autohotkey/tools/config_editor.ahk +4 -4
  21. data/autohotkey/tools/data_viewer.ahk +1 -1
  22. data/autohotkey/tools/limits_monitor.ahk +1 -1
  23. data/autohotkey/tools/packet_viewer.ahk +1 -1
  24. data/autohotkey/tools/script_runner.ahk +1 -1
  25. data/autohotkey/tools/test_runner2.ahk +1 -1
  26. data/autohotkey/tools/tlm_grapher.ahk +1 -1
  27. data/autohotkey/tools/tlm_grapher3.ahk +1 -1
  28. data/autohotkey/tools/tlm_viewer.ahk +1 -1
  29. data/autohotkey/tools/tlm_viewer2.ahk +1 -1
  30. data/autohotkey/tools/tlm_viewer5.ahk +1 -1
  31. data/bin/cstol_converter +1 -1
  32. data/bin/rubysloc +73 -28
  33. data/bin/xtce_converter +1 -1
  34. data/cosmos.gemspec +2 -2
  35. data/data/config/command_modifiers.yaml +16 -1
  36. data/data/config/interface_modifiers.yaml +3 -2
  37. data/data/config/param_item_modifiers.yaml +5 -0
  38. data/data/config/system.yaml +110 -23
  39. data/data/config/telemetry_modifiers.yaml +16 -1
  40. data/data/crc.txt +416 -411
  41. data/demo/Rakefile +4 -4
  42. data/demo/config/dart/Gemfile +1 -6
  43. data/demo/config/data/crc.txt +233 -232
  44. data/demo/config/system/system.txt +17 -6
  45. data/demo/config/system/system2.txt +17 -6
  46. data/demo/config/system/system_alt_ports.txt +17 -6
  47. data/demo/config/targets/INST/cmd_tlm/inst_cmds.txt +4 -4
  48. data/demo/config/targets/INST/cmd_tlm/inst_tlm.txt +4 -0
  49. data/demo/config/targets/INST/cmd_tlm/inst_tlm_override.txt +12 -0
  50. data/demo/config/targets/INST/lib/sim_inst.rb +2 -2
  51. data/demo/config/targets/INST/target.txt +1 -0
  52. data/demo/config/tools/handbook_creator/default_toc.xsl +59 -59
  53. data/demo/procedures/cosmos_api_test.rb +8 -8
  54. data/ext/cosmos/ext/buffered_file/buffered_file.c +2 -2
  55. data/ext/cosmos/ext/config_parser/config_parser.c +1 -2
  56. data/ext/cosmos/ext/line_graph/line_graph.c +53 -94
  57. data/ext/cosmos/ext/platform/platform.c +56 -21
  58. data/ext/cosmos/ext/polynomial_conversion/polynomial_conversion.c +4 -8
  59. data/ext/cosmos/ext/structure/structure.c +12 -0
  60. data/extensions/vscode/.gitignore +4 -0
  61. data/extensions/vscode/.vscode/launch.json +32 -0
  62. data/extensions/vscode/.vscode/settings.json +13 -0
  63. data/extensions/vscode/.vscode/tasks.json +79 -0
  64. data/extensions/vscode/License.txt +879 -0
  65. data/extensions/vscode/README.md +9 -0
  66. data/extensions/vscode/client/License.txt +879 -0
  67. data/extensions/vscode/client/README.md +39 -0
  68. data/extensions/vscode/client/cosmos.configuration.json +23 -0
  69. data/extensions/vscode/client/images/icon.png +0 -0
  70. data/extensions/vscode/client/package-lock.json +414 -0
  71. data/extensions/vscode/client/package.json +105 -0
  72. data/extensions/vscode/client/src/extension.ts +132 -0
  73. data/extensions/vscode/client/src/screen_preview.rb +25 -0
  74. data/extensions/vscode/client/syntaxes/cosmos.tmLanguage.json +219 -0
  75. data/extensions/vscode/client/tsconfig.json +17 -0
  76. data/extensions/vscode/package-lock.json +26 -0
  77. data/extensions/vscode/package.json +35 -0
  78. data/extensions/vscode/server/License.txt +879 -0
  79. data/extensions/vscode/server/package-lock.json +236 -0
  80. data/extensions/vscode/server/package.json +29 -0
  81. data/extensions/vscode/server/src/server.ts +59 -0
  82. data/extensions/vscode/server/tsconfig.json +16 -0
  83. data/install/Rakefile +4 -4
  84. data/install/config/dart/Gemfile +2 -7
  85. data/install/config/data/crc.txt +137 -137
  86. data/install/config/system/system.txt +17 -6
  87. data/install/config/tools/handbook_creator/default_toc.xsl +59 -59
  88. data/lib/cosmos/config/config_parser.rb +2 -10
  89. data/lib/cosmos/core_ext/class.rb +10 -0
  90. data/lib/cosmos/core_ext/time.rb +5 -3
  91. data/lib/cosmos/dart/config/boot.rb +1 -1
  92. data/lib/cosmos/dart/config/database.yml +2 -0
  93. data/lib/cosmos/dart/examples/dart_decom_client.rb +1 -1
  94. data/lib/cosmos/dart/lib/dart_common.rb +12 -5
  95. data/lib/cosmos/dart/lib/dart_constants.rb +15 -0
  96. data/lib/cosmos/dart/lib/dart_decom_query.rb +5 -6
  97. data/lib/cosmos/dart/lib/dart_decommutator.rb +64 -54
  98. data/lib/cosmos/dart/lib/dart_master_query.rb +71 -0
  99. data/lib/cosmos/dart/lib/dart_reducer_worker_thread.rb +165 -134
  100. data/lib/cosmos/dart/processes/dart.rb +4 -2
  101. data/lib/cosmos/dart/processes/dart_decom_server.rb +3 -3
  102. data/lib/cosmos/dart/processes/dart_ingester.rb +38 -1
  103. data/lib/cosmos/dart/processes/dart_master.rb +44 -0
  104. data/lib/cosmos/dart/processes/dart_util.rb +115 -0
  105. data/lib/cosmos/dart/spec/dart/dart_database_cleaner_spec.rb +2 -2
  106. data/lib/cosmos/gui/qt.rb +10 -10
  107. data/lib/cosmos/gui/qt_tool.rb +17 -12
  108. data/lib/cosmos/gui/text/completion_text_edit.rb +2 -0
  109. data/lib/cosmos/gui/widgets/dart_meta_frame.rb +22 -3
  110. data/lib/cosmos/interfaces/dart_status_interface.rb +1 -1
  111. data/lib/cosmos/interfaces/linc_interface.rb +3 -3
  112. data/lib/cosmos/interfaces/protocols/burst_protocol.rb +1 -1
  113. data/lib/cosmos/interfaces/protocols/crc_protocol.rb +1 -1
  114. data/lib/cosmos/interfaces/protocols/length_protocol.rb +5 -0
  115. data/lib/cosmos/interfaces/protocols/template_protocol.rb +3 -3
  116. data/lib/cosmos/interfaces/serial_interface.rb +7 -1
  117. data/lib/cosmos/interfaces/stream_interface.rb +1 -1
  118. data/lib/cosmos/interfaces/tcpip_server_interface.rb +16 -16
  119. data/lib/cosmos/io/io_multiplexer.rb +6 -2
  120. data/lib/cosmos/io/json_drb.rb +5 -5
  121. data/lib/cosmos/io/json_drb_object.rb +7 -2
  122. data/lib/cosmos/io/json_drb_rack.rb +25 -5
  123. data/lib/cosmos/io/json_rpc.rb +1 -1
  124. data/lib/cosmos/io/posix_serial_driver.rb +60 -22
  125. data/lib/cosmos/io/serial_driver.rb +11 -8
  126. data/lib/cosmos/io/win32_serial_driver.rb +31 -3
  127. data/lib/cosmos/packet_logs/packet_log_reader.rb +2 -2
  128. data/lib/cosmos/packets/packet.rb +9 -9
  129. data/lib/cosmos/packets/packet_config.rb +27 -9
  130. data/lib/cosmos/packets/parsers/xtce_converter.rb +10 -10
  131. data/lib/cosmos/packets/parsers/xtce_parser.rb +3 -0
  132. data/lib/cosmos/packets/structure.rb +35 -5
  133. data/lib/cosmos/packets/structure_item.rb +5 -1
  134. data/lib/cosmos/packets/telemetry.rb +7 -1
  135. data/lib/cosmos/script/api_shared.rb +18 -1
  136. data/lib/cosmos/script/extract.rb +1 -1
  137. data/lib/cosmos/script/script.rb +4 -11
  138. data/lib/cosmos/streams/serial_stream.rb +11 -6
  139. data/lib/cosmos/system/system.rb +155 -57
  140. data/lib/cosmos/tools/cmd_sender/cmd_param_table_item_delegate.rb +15 -0
  141. data/lib/cosmos/tools/cmd_sender/cmd_params.rb +382 -0
  142. data/lib/cosmos/tools/cmd_sender/cmd_sender.rb +29 -318
  143. data/lib/cosmos/tools/cmd_sequence/cmd_sequence.rb +14 -17
  144. data/lib/cosmos/tools/cmd_sequence/sequence_item.rb +38 -331
  145. data/lib/cosmos/tools/cmd_sequence/sequence_list.rb +16 -11
  146. data/lib/cosmos/tools/cmd_tlm_server/api.rb +10 -8
  147. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb +2 -2
  148. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb +1 -0
  149. data/lib/cosmos/tools/cmd_tlm_server/gui/logging_tab.rb +1 -1
  150. data/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb +29 -26
  151. data/lib/cosmos/tools/cmd_tlm_server/limits_groups_background_task.rb +1 -1
  152. data/lib/cosmos/tools/cmd_tlm_server/router_thread.rb +5 -0
  153. data/lib/cosmos/tools/config_editor/config_editor.rb +34 -3
  154. data/lib/cosmos/tools/config_editor/config_editor_frame.rb +8 -9
  155. data/lib/cosmos/tools/config_editor/system_config_dialog.rb +158 -0
  156. data/lib/cosmos/tools/handbook_creator/handbook_creator.rb +1 -1
  157. data/lib/cosmos/tools/handbook_creator/handbook_creator_config.rb +1 -1
  158. data/lib/cosmos/tools/script_runner/script_runner_frame.rb +7 -4
  159. data/lib/cosmos/tools/test_runner/test.rb +6 -3
  160. data/lib/cosmos/tools/test_runner/test_runner.rb +6 -6
  161. data/lib/cosmos/tools/tlm_extractor/tlm_extractor.rb +3 -3
  162. data/lib/cosmos/tools/tlm_extractor/tlm_extractor_config.rb +1 -4
  163. data/lib/cosmos/tools/tlm_extractor/tlm_extractor_processor.rb +20 -16
  164. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_dart_thread.rb +21 -17
  165. data/lib/cosmos/tools/tlm_grapher/tlm_grapher.rb +18 -11
  166. data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +17 -6
  167. data/lib/cosmos/tools/tlm_viewer/widgets/canvasdot_widget.rb +2 -0
  168. data/lib/cosmos/top_level.rb +1 -1
  169. data/lib/cosmos/utilities/ruby_lex_utils.rb +34 -30
  170. data/lib/cosmos/utilities/simulated_target.rb +1 -1
  171. data/lib/cosmos/version.rb +5 -5
  172. data/lib/cosmos/win32/excel.rb +23 -17
  173. data/run_gui_tests.bat +1 -0
  174. data/spec/core_ext/class_spec.rb +54 -0
  175. data/spec/core_ext/socket_spec.rb +1 -1
  176. data/spec/core_ext/time_spec.rb +4 -0
  177. data/spec/install/yaml_docs_spec.rb +26 -6
  178. data/spec/interfaces/linc_interface_spec.rb +1 -1
  179. data/spec/interfaces/protocols/length_protocol_spec.rb +39 -0
  180. data/spec/interfaces/serial_interface_spec.rb +1 -5
  181. data/spec/io/json_drb_rack_spec.rb +166 -0
  182. data/spec/io/json_drb_spec.rb +14 -0
  183. data/spec/io/json_rpc_spec.rb +4 -5
  184. data/spec/io/posix_serial_driver_spec.rb +81 -0
  185. data/spec/io/win32_serial_driver_spec.rb +33 -3
  186. data/spec/packet_logs/packet_log_reader_spec.rb +36 -37
  187. data/spec/packets/structure_spec.rb +52 -2
  188. data/spec/packets/telemetry_spec.rb +29 -1
  189. data/spec/script/extract_spec.rb +4 -1
  190. data/spec/system/system_spec.rb +111 -3
  191. data/spec/tools/cmd_tlm_server/api_spec.rb +12 -12
  192. data/spec/tools/cmd_tlm_server/background_tasks_spec.rb +2 -2
  193. data/spec/tools/cmd_tlm_server/interface_thread_spec.rb +4 -3
  194. data/spec/tools/cmd_tlm_server/router_thread_spec.rb +2 -3
  195. data/spec/utilities/logger_spec.rb +3 -3
  196. data/spec/utilities/message_log_spec.rb +6 -3
  197. data/tasks/gemfile_stats.rake +22 -13
  198. data/test/performance/Rakefile +4 -4
  199. data/test/performance/config/data/crc.txt +67 -48
  200. metadata +44 -9
  201. data/demo/outputs/dart/logs/README.txt +0 -1
  202. data/lib/cosmos/dart/Gemfile +0 -69
@@ -14,7 +14,7 @@ Cosmos.catch_fatal_exception do
14
14
  require 'cosmos/script'
15
15
  require 'cosmos/gui/dialogs/calendar_dialog'
16
16
  require 'cosmos/gui/dialogs/cmd_details_dialog'
17
- require 'cosmos/tools/cmd_sender/cmd_param_table_item_delegate'
17
+ require 'cosmos/tools/cmd_sender/cmd_params'
18
18
  end
19
19
 
20
20
  module Cosmos
@@ -26,36 +26,18 @@ module Cosmos
26
26
  signals 'modified()'
27
27
  MANUALLY = "MANUALLY ENTERED"
28
28
 
29
- # Parse a time and command string into a SequenceItem which is returned
30
- # @param time [String] Time (absolute or relative delay). Supports a single
31
- # float value (relative delay) or a absolute time specified as
32
- # "YYYY/MM/DD HH:MM:SS.MS"
33
- # @param command [String] Command String which should not be
34
- # quoted and is everything inside the quotes of a command.
35
- # For example: TGT PKT with STRING 'HI', VALUE 12. Parse errors are
36
- # raised as execptions which must be handled by higher level code.
37
- # @return [SequenceItem] SequenceItem which the line represents
38
- def self.parse(time, command)
39
- tgt_name, pkt_name, cmd_params = extract_fields_from_cmd_text(command)
40
- packet = System.commands.packet(tgt_name, pkt_name).dup
41
- packet.restore_defaults
42
- cmd_params.each do |param_name, param_value|
43
- packet.write(param_name, param_value)
44
- end
45
- SequenceItem.new(packet, time)
46
- end
47
-
48
29
  # Create a new SequenceItem based on the given command with the given delay
49
- # @param command [Packet] Command packet
50
30
  # @param time [String] Absolute time in YYYY/MM/DD HH:MM:SS format or a
51
31
  # single float value representing the delta delay time
52
- def initialize(command, time = nil)
32
+ def initialize(parent, target_name, packet_name, params = nil, time = nil)
53
33
  super()
54
- @command = command
55
- @table = nil
56
- @param_widgets = []
57
- @show_ignored = false
58
- @states_in_hex = false
34
+ @cmd_params = CmdParams.new
35
+ # Propagate the modified signal up
36
+ @cmd_params.connect(SIGNAL('modified()')) do
37
+ set_cmd_name_info()
38
+ emit modified
39
+ end
40
+ @command = System.commands.packet(target_name, packet_name)
59
41
  @expanded = false
60
42
  @file_dir = System.paths['LOGS']
61
43
 
@@ -66,50 +48,30 @@ module Cosmos
66
48
  top_layout = Qt::VBoxLayout.new
67
49
  top_layout.setContentsMargins(2, 0, 0, 0)
68
50
  setLayout(top_layout)
69
- top_layout.addLayout(create_cmd_layout(command, time))
51
+ top_layout.addLayout(create_cmd_layout(target_name, packet_name, time))
70
52
  top_layout.addWidget(create_parameters())
71
- update_cmd_params()
53
+ add_table(@cmd_params.update_cmd_params(@command, existing: params))
72
54
  set_cmd_name_info()
73
55
  end
74
56
 
75
- # Set or clear read only status on the item
76
- # @param bool [Boolean] Whether to make the item read only
77
- def read_only(bool)
78
- @time.setReadOnly(bool)
57
+ def add_table(table)
58
+ return unless table
59
+ @table_layout.addWidget(table)
79
60
  end
80
-
81
- # Show or hide ignored parameters
82
- # @param bool [Boolean] Whether to show ignored command items
83
- def show_ignored(bool)
84
- @show_ignored = bool
85
- update_cmd_params(bool)
61
+
62
+ def states_in_hex(checked)
63
+ @cmd_params.states_in_hex(checked)
86
64
  end
87
65
 
88
- # Display state values in hex (or decimal)
89
- # @param bool [Boolean] Whether to display state values in hex
90
- def states_in_hex(bool)
91
- @states_in_hex = bool
92
- @param_widgets.each do |_, _, state_value_item|
93
- next unless state_value_item
94
- text = state_value_item.text
95
- quotes_removed = text.remove_quotes
96
- if text == quotes_removed
97
- if bool
98
- if text.is_int?
99
- @table.blockSignals(true)
100
- state_value_item.text = sprintf("0x%X", text.to_i)
101
- @table.blockSignals(false)
102
- end
103
- else
104
- if text.is_hex?
105
- @table.blockSignals(true)
106
- state_value_item.text = Integer(text).to_s
107
- @table.blockSignals(false)
108
- end
109
- end
110
- end
111
- end
66
+ def show_ignored(checked)
67
+ add_table(@cmd_params.update_cmd_params(@command, show_ignored: checked))
68
+ set_cmd_name_info()
69
+ end
112
70
 
71
+ # Set or clear read only status on the item
72
+ # @param bool [Boolean] Whether to make the item read only
73
+ def read_only(bool)
74
+ @time.setReadOnly(bool)
113
75
  end
114
76
 
115
77
  # Show the command parameters part of the GUI
@@ -124,33 +86,9 @@ module Cosmos
124
86
  @parameters.hide
125
87
  end
126
88
 
127
- # @return [Hash] All the parameter item values keyed by their name
128
- def command_params
129
- params = {}
130
- @param_widgets.each do |packet_item, value_item, state_value_item|
131
- text = ''
132
- Qt.execute_in_main_thread do
133
- text = value_item.text
134
- text = state_value_item.text if state_value_item && (text == MANUALLY)
135
- end
136
- quotes_removed = text.remove_quotes
137
- if text == quotes_removed
138
- if (packet_item.data_type == :STRING or packet_item.data_type == :BLOCK) and text.upcase.start_with?("0X")
139
- params[packet_item.name] = text.hex_to_byte_string
140
- else
141
- params[packet_item.name] = text.convert_to_value
142
- end
143
- else
144
- params[packet_item.name] = quotes_removed
145
- end
146
- raise "#{packet_item.name} is required" if quotes_removed == '' && packet_item.required
147
- end
148
- params
149
- end
150
-
151
89
  # @return [String] Command to be executed with no quotes or other decorations
152
90
  def command_string
153
- output_string = System.commands.build_cmd_output_string(@command.target_name, @command.packet_name, command_params(), false)
91
+ output_string = System.commands.build_cmd_output_string(@command.target_name, @command.packet_name, @cmd_params.params_text, false)
154
92
  if output_string =~ /[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F-\xFF]/
155
93
  output_string = output_string.inspect.remove_quotes
156
94
  end
@@ -165,7 +103,7 @@ module Cosmos
165
103
  end
166
104
 
167
105
  def command
168
- System.commands.build_cmd(@command.target_name, @command.packet_name, command_params(), false)
106
+ System.commands.build_cmd(@command.target_name, @command.packet_name, @cmd_params.params_text, false)
169
107
  end
170
108
 
171
109
  # @return [String] Time and command string
@@ -193,12 +131,12 @@ module Cosmos
193
131
  # and the delete button to remove the sequence item.
194
132
  # @param command [Packet] Command packet
195
133
  # @param time [String] Execution delay in absolute or relative time
196
- def create_cmd_layout(command, time)
134
+ def create_cmd_layout(target_name, packet_name, time)
197
135
  cmd_layout = Qt::HBoxLayout.new
198
136
  cmd_layout.setContentsMargins(0, 0, 0, 0)
199
137
  cmd_layout.addWidget(create_time_edit(time))
200
138
 
201
- @cmd_name = Qt::Label.new("#{command.target_name} #{command.packet_name}")
139
+ @cmd_name = Qt::Label.new("#{target_name} #{packet_name}")
202
140
  cmd_layout.addWidget(@cmd_name)
203
141
  @cmd_info = Qt::Label.new("") # Label for the hazardous designation
204
142
  cmd_layout.addWidget(@cmd_info)
@@ -263,252 +201,21 @@ module Cosmos
263
201
  @parameters
264
202
  end
265
203
 
266
- # Update the command parameters table for the given command
267
- # @param ignored_toggle [Boolean] Whether to display the ignored
268
- # parameters. Pass nil (the default) to keep the existing setting.
269
- def update_cmd_params(ignored_toggle = nil)
270
- old_params = {}
271
- if !ignored_toggle.nil?
272
- # Save parameter values
273
- @param_widgets.each do |packet_item, value_item, state_value_item|
274
- text = value_item.text
275
- if state_value_item
276
- old_params[packet_item.name] = [text, state_value_item.text]
277
- else
278
- old_params[packet_item.name] = text
279
- end
280
- end
281
- end
282
-
283
- target = System.targets[@command.target_name]
284
- packet_items = @command.sorted_items
285
- shown_packet_items = []
286
- packet_items.each do |packet_item|
287
- if target && target.ignored_parameters.include?(packet_item.name) && !@show_ignored
288
- if @param_widgets.empty? # First time rendering the parameters
289
- if packet_item.states
290
- # Skip this if the default matches the saved value
291
- next if @command.read_item(packet_item, :RAW) == packet_item.default
292
- else
293
- # Skip this if the default matches the saved value
294
- next if @command.read_item(packet_item) == packet_item.default
295
- end
296
- else # Check the current values
297
- result = @param_widgets.select {|item,_,_| item == packet_item }
298
- next if result.empty?
299
- _, value_item, state_value_item = result[0]
300
- value = state_value_item ? state_value_item.text : value_item.text
301
- # Skip this if the default matches the current value
302
- next if packet_item.default.to_s == value
303
- end
304
- end
305
- shown_packet_items << packet_item
306
- end
307
-
308
- @table.dispose if @table
309
- @table = nil
310
-
311
- # Update Parameters
312
- @param_widgets = []
313
- drawn_header = false
314
-
315
- row = 0
316
- shown_packet_items.each do |packet_item|
317
- value_item = nil
318
- state_value_item = nil
319
-
320
- unless drawn_header
321
- @table = Qt::TableWidget.new()
322
- @table.setSizePolicy(Qt::SizePolicy::Expanding, Qt::SizePolicy::Expanding)
323
- @table.setWordWrap(true)
324
- @table.setRowCount(shown_packet_items.length)
325
- @table.setColumnCount(5)
326
- @table.setHorizontalHeaderLabels(['Name', ' Value or State ', ' ', 'Units', 'Description'])
327
- @table.verticalHeader.setVisible(false)
328
- @table.setItemDelegate(CmdParamTableItemDelegate.new(@table, @param_widgets))
329
- @table.setEditTriggers(Qt::AbstractItemView::DoubleClicked | Qt::AbstractItemView::SelectedClicked | Qt::AbstractItemView::AnyKeyPressed)
330
- @table.setSelectionMode(Qt::AbstractItemView::NoSelection)
331
- @table.setContextMenuPolicy(Qt::CustomContextMenu)
332
- @table.connect(SIGNAL('customContextMenuRequested(const QPoint&)')) do |point|
333
- context_menu(point)
334
- end
335
- drawn_header = true
336
- end
337
-
338
- # Parameter Name
339
- item = Qt::TableWidgetItem.new("#{packet_item.name}:")
340
- item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
341
- item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled)
342
- @table.setItem(row, 0, item)
343
-
344
- if packet_item.states
345
- default = @command.read_item(packet_item, :RAW)
346
- default_state = packet_item.states.key(default)
347
- if old_params[packet_item.name]
348
- value_item = Qt::TableWidgetItem.new(old_params[packet_item.name][0])
349
- else
350
- if default_state
351
- value_item = Qt::TableWidgetItem.new(default_state.to_s)
352
- else
353
- value_item = Qt::TableWidgetItem.new(MANUALLY)
354
- end
355
- end
356
- value_item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
357
- value_item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable)
358
- @table.setItem(row, 1, value_item)
359
-
360
- if old_params[packet_item.name]
361
- state_value_item = Qt::TableWidgetItem.new(old_params[packet_item.name][1])
362
- else
363
- if @states_in_hex && packet_item.default.kind_of?(Integer)
364
- state_value_item = Qt::TableWidgetItem.new(sprintf("0x%X", default))
365
- else
366
- default_str = default.to_s
367
- if default_str.is_printable?
368
- state_value_item = Qt::TableWidgetItem.new(default_str)
369
- else
370
- state_value_item = Qt::TableWidgetItem.new("0x" + default_str.simple_formatted)
371
- end
372
- end
373
- end
374
- state_value_item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
375
- state_value_item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable)
376
- @table.setItem(row, 2, state_value_item)
377
- else # Parameter Value
378
- if old_params[packet_item.name]
379
- value_item = Qt::TableWidgetItem.new(old_params[packet_item.name])
380
- else
381
- default = @command.read_item(packet_item)
382
- if packet_item.format_string
383
- begin
384
- value_text = sprintf(packet_item.format_string, default)
385
- rescue
386
- # Oh well - Don't use the format string
387
- value_text = default.to_s
388
- end
389
- else
390
- value_text = default.to_s
391
- end
392
- if !value_text.is_printable?
393
- value_text = "0x" + value_text.simple_formatted
394
- end
395
- value_item = Qt::TableWidgetItem.new(value_text)
396
- end
397
- value_item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
398
- value_item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable)
399
- @table.setItem(row, 1, value_item)
400
- @table.setSpan(row, 1, 1, 2)
401
- end
402
-
403
- # Units
404
- item = Qt::TableWidgetItem.new(packet_item.units.to_s)
405
- item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
406
- item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled)
407
- @table.setItem(row, 3, item)
408
-
409
- # Description
410
- item = Qt::TableWidgetItem.new(packet_item.description.to_s)
411
- item.setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter)
412
- item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled)
413
- @table.setItem(row, 4, item)
414
-
415
- @param_widgets << [packet_item, value_item, state_value_item]
416
- row += 1
417
- end
418
-
419
- if @table
420
- connect_table_item_changed()
421
- @table.setSizePolicy(Qt::SizePolicy.Minimum, Qt::SizePolicy.Minimum)
422
- @table.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff)
423
- @table.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff)
424
- @table.resizeColumnsToContents()
425
- @table.resizeRowsToContents()
426
- @table.setFixedSize(@table.horizontalHeader.length + @table.verticalHeader.width,
427
- 2 + @table.verticalHeader.length + @table.horizontalHeader.height)
428
- @table_layout.addWidget(@table)
429
- end
430
- end
431
-
432
204
  # Sets the @cmd_name label to the command that will be sent. Also udpates
433
205
  # the @cmd_info with whether this command is hazardous or not.
434
206
  def set_cmd_name_info
435
- @cmd_name.text = command_string
436
- hazardous, _ = System.commands.cmd_hazardous?(@command.target_name, @command.packet_name, command_params())
437
- if hazardous
438
- @cmd_info.text = "(Hazardous)"
439
- else
440
- @cmd_info.text = ""
207
+ Qt.execute_in_main_thread do
208
+ @cmd_name.text = command_string
209
+ hazardous, _ = System.commands.cmd_hazardous?(@command.target_name, @command.packet_name, @cmd_params.params_text)
210
+ if hazardous
211
+ @cmd_info.text = "(Hazardous)"
212
+ else
213
+ @cmd_info.text = ""
214
+ end
441
215
  end
442
216
  rescue => error
443
217
  @cmd_info.text = "(Error)"
444
- Qt::MessageBox.warning(self, 'Error', error.message)
445
- end
446
-
447
- # If the user right clicks over a table item, this method displays a context
448
- # menu with various options.
449
- # @param point [Qt::Point] Point to display the context menu
450
- def context_menu(point)
451
- target_name = @command.target_name
452
- packet_name = @command.packet_name
453
- item = @table.itemAt(point)
454
- if item
455
- item_name = @table.item(item.row, 0).text[0..-2] # Remove :
456
- if target_name.length > 0 && packet_name.length > 0 && item_name.length > 0
457
- menu = Qt::Menu.new()
458
-
459
- details_action = Qt::Action.new("Details #{target_name} #{packet_name} #{item_name}", self)
460
- details_action.statusTip = "Popup details about #{target_name} #{packet_name} #{item_name}"
461
- details_action.connect(SIGNAL('triggered()')) do
462
- CmdDetailsDialog.new(nil, target_name, packet_name, item_name)
463
- end
464
- menu.addAction(details_action)
465
-
466
- file_chooser_action = Qt::Action.new("Insert Filename", self)
467
- file_chooser_action.statusTip = "Select a file and place its name into this parameter"
468
- file_chooser_action.connect(SIGNAL('triggered()')) do
469
- filename = Qt::FileDialog::getOpenFileName(self, "Insert Filename:", @file_dir, "All Files (*)")
470
- if filename && !filename.empty?
471
- @file_dir = File.dirname(filename)
472
- _, value_item, state_value_item = @param_widgets[item.row]
473
- if state_value_item
474
- state_value_item.setText(filename)
475
- elsif value_item
476
- value_item.setText(filename)
477
- end
478
- end
479
- end
480
- menu.addAction(file_chooser_action)
481
-
482
- menu.exec(@table.mapToGlobal(point))
483
- menu.dispose
484
- end
485
- end # if item
486
- end
487
-
488
- # Connect the itemChanged signal to the table so we can handle user edits
489
- # of the table parameters. This method emits the modified signal.
490
- def connect_table_item_changed
491
- @table.connect(SIGNAL('itemChanged(QTableWidgetItem*)')) do |item|
492
- packet_item, value_item, state_value_item = @param_widgets[item.row]
493
- if item.column == 1
494
- if packet_item.states
495
- value = packet_item.states[value_item.text]
496
- @table.blockSignals(true)
497
- if @states_in_hex && value.kind_of?(Integer)
498
- state_value_item.setText(sprintf("0x%X", value))
499
- else
500
- state_value_item.setText(value.to_s)
501
- end
502
- @table.blockSignals(false)
503
- end
504
- elsif item.column == 2
505
- @table.blockSignals(true)
506
- @table.item(item.row, 1).setText(MANUALLY)
507
- @table.blockSignals(false)
508
- end
509
- set_cmd_name_info()
510
- emit modified # Tell the higher level that something changed
511
- end
218
+ Qt::MessageBox.warning(self, 'Error', "Error parsing #{@command.target_name} #{@command.packet_name} due to #{error.message}")
512
219
  end
513
220
  end
514
221
  end
@@ -19,8 +19,9 @@ module Cosmos
19
19
  signals 'modified()'
20
20
 
21
21
  # Create the SequenceList
22
- def initialize
22
+ def initialize(parent)
23
23
  super()
24
+ @parent = parent
24
25
  @modified = false
25
26
  layout = Qt::VBoxLayout.new()
26
27
  layout.setContentsMargins(0, 0, 0, 0)
@@ -45,7 +46,8 @@ module Cosmos
45
46
  usage = "#{keyword} <Delay Time> <Command>"
46
47
  parser.verify_num_parameters(2, 2, usage)
47
48
  begin
48
- item = SequenceItem.parse(params[0], params[1])
49
+ tgt_name, pkt_name, cmd_params = extract_fields_from_cmd_text(params[1])
50
+ item = SequenceItem.new(@parent, tgt_name, pkt_name, cmd_params, params[0])
49
51
  # Connect the SequenceItems modified signal to propagate it
50
52
  # forward by emitting our own modified signal
51
53
  item.connect(SIGNAL("modified()")) do
@@ -63,12 +65,13 @@ module Cosmos
63
65
  @modified = false # Initially we're not modified
64
66
  end
65
67
 
66
- # Add a new SequenceItem to the list.
67
- # @param command [Packet] Command packet to base the SequenceItem on
68
+ # Add a new SequenceItem to the list based on the given target and packet
69
+ # @param target_name [String] target name containing the command
70
+ # @param packet_name [String] packet name containing the command
68
71
  # @return [SequenceItem] The item added
69
- def add(command)
72
+ def add(target_name, packet_name)
70
73
  @modified = true
71
- item = SequenceItem.new(command)
74
+ item = SequenceItem.new(@parent, target_name, packet_name)
72
75
  # Connect the SequenceItems modified signal to propagate it
73
76
  # forward by emitting our own modified signal
74
77
  item.connect(SIGNAL("modified()")) do
@@ -118,11 +121,13 @@ module Cosmos
118
121
  # application.
119
122
  # @param filename [String] Filename to open and write the sequence
120
123
  def save(filename)
121
- @modified = false
122
- File.open(filename, "w") do |file|
123
- # Each SequenceItem's save method returns the save string
124
- file.write(collect {|item| item.save }.join("\n"))
125
- file.write("\n") # final newline
124
+ begin
125
+ sequence = collect {|item| item.save }.join("\n") + "\n"
126
+ @modified = false
127
+ File.open(filename, "w") {|file| file.write(sequence) }
128
+ rescue Exception => err
129
+ message = "Error saving due to #{err}"
130
+ Qt::MessageBox.critical(self, 'Error', message)
126
131
  end
127
132
  end
128
133
 
@@ -591,14 +591,16 @@ module Cosmos
591
591
  end
592
592
 
593
593
  # Update current value table
594
- cvt_packet.buffer = packet.buffer(false)
595
- cvt_packet.received_time = received_time
596
-
597
- # The interface does the following line, but I don't think inject_tlm should because it could confuse the interface
598
- target.tlm_cnt += 1
599
- packet.received_count += 1
600
- cvt_packet.received_count += 1
601
- CmdTlmServer.instance.identified_packet_callback(packet)
594
+ cvt_packet.synchronize do
595
+ cvt_packet.buffer = packet.buffer(false)
596
+ cvt_packet.received_time = received_time
597
+
598
+ # The interface does the following line, but I don't think inject_tlm should because it could confuse the interface
599
+ target.tlm_cnt += 1
600
+ packet.received_count += 1
601
+ cvt_packet.received_count += 1
602
+ CmdTlmServer.instance.identified_packet_callback(cvt_packet)
603
+ end
602
604
 
603
605
  # Find the interface for this target
604
606
  interface = target.interface
@@ -201,9 +201,9 @@ module Cosmos
201
201
  @json_drb.method_whitelist = @api_whitelist
202
202
  begin
203
203
  if @mode == :CMD_TLM_SERVER
204
- @json_drb.start_service(System.listen_hosts['CTS_API'], System.ports['CTS_API'], self)
204
+ @json_drb.start_service(System.listen_hosts['CTS_API'], System.ports['CTS_API'], self, 1000, System)
205
205
  else
206
- @json_drb.start_service(System.listen_hosts['REPLAY_API'], System.ports['REPLAY_API'], self)
206
+ @json_drb.start_service(System.listen_hosts['REPLAY_API'], System.ports['REPLAY_API'], self, 1000, System)
207
207
  end
208
208
  rescue Exception
209
209
  # Call packet_logging shutdown here to explicitly kill the logging
@@ -191,6 +191,7 @@ module Cosmos
191
191
 
192
192
  # File actions
193
193
  @file_reload = Qt::Action.new('&Reload Configuration', self)
194
+ @file_reload.shortcut = Qt::KeySequence.new('Ctrl+Shift+R')
194
195
  @file_reload.statusTip = 'Reload configuraton and reset'
195
196
  @file_reload.connect(SIGNAL('triggered()')) do
196
197
  CmdTlmServer.instance.reload()
@@ -96,7 +96,7 @@ module Cosmos
96
96
  button_layout.addWidget(button, location[0], location[1])
97
97
  button.connect(SIGNAL('clicked()')) do
98
98
  begin
99
- CmdTlmServer.instance.send(method, 'ALL')
99
+ CmdTlmServer.instance.public_send(method, 'ALL')
100
100
  rescue Exception => error
101
101
  statusBar.showMessage(error.message)
102
102
  end
@@ -148,51 +148,54 @@ module Cosmos
148
148
  if packet.identified?
149
149
  begin
150
150
  # Preidentifed packet - place it into the current value table
151
- identified_packet = System.telemetry.update!(packet.target_name,
152
- packet.packet_name,
153
- packet.buffer)
151
+ identified_packet = System.telemetry.packet(packet.target_name, packet.packet_name)
154
152
  rescue RuntimeError
155
153
  # Packet identified but we don't know about it
156
154
  # Clear packet_name and target_name and try to identify
157
155
  Logger.warn "Received unknown identified telemetry: #{packet.target_name} #{packet.packet_name}"
158
156
  packet.target_name = nil
159
157
  packet.packet_name = nil
160
- identified_packet = System.telemetry.identify!(packet.buffer,
161
- @interface.target_names)
158
+ identified_packet = System.telemetry.identify(packet.buffer, @interface.target_names)
162
159
  end
163
160
  else
164
161
  # Packet needs to be identified
165
- identified_packet = System.telemetry.identify!(packet.buffer,
166
- @interface.target_names)
162
+ identified_packet = System.telemetry.identify(packet.buffer, @interface.target_names)
167
163
  end
168
164
  end
169
165
 
170
- if identified_packet
166
+ unknown = false
167
+ unless identified_packet
168
+ unknown = true
169
+ identified_packet = System.telemetry.packet('UNKNOWN', 'UNKNOWN')
170
+ end
171
+
172
+ identified_packet.synchronize do
173
+ identified_packet.buffer = packet.buffer unless packet.stored
171
174
  identified_packet.received_time = packet.received_time
172
175
  identified_packet.stored = packet.stored
173
176
  identified_packet.extra = packet.extra
174
177
  packet = identified_packet
175
- else
176
- unknown_packet = System.telemetry.update!('UNKNOWN', 'UNKNOWN', packet.buffer)
177
- unknown_packet.received_time = packet.received_time
178
- unknown_packet.stored = packet.stored
179
- unknown_packet.extra = packet.extra
180
- packet = unknown_packet
181
- data_length = packet.length
182
- string = "#{@interface.name} - Unknown #{data_length} byte packet starting: "
183
- num_bytes_to_print = [UNKNOWN_BYTES_TO_PRINT, data_length].min
184
- data_to_print = packet.buffer(false)[0..(num_bytes_to_print - 1)]
185
- data_to_print.each_byte do |byte|
186
- string << sprintf("%02X", byte)
178
+
179
+ if unknown
180
+ data_length = packet.length
181
+ string = "#{@interface.name} - Unknown #{data_length} byte packet starting: "
182
+ num_bytes_to_print = [UNKNOWN_BYTES_TO_PRINT, data_length].min
183
+ data_to_print = packet.buffer(false)[0..(num_bytes_to_print - 1)]
184
+ data_to_print.each_byte do |byte|
185
+ string << sprintf("%02X", byte)
186
+ end
187
+ Logger.error string
187
188
  end
188
- Logger.error string
189
- end
190
189
 
191
- target = System.targets[packet.target_name]
192
- target.tlm_cnt += 1 if target
193
- packet.received_count += 1
194
- @identified_packet_callback.call(packet) if @identified_packet_callback
190
+ target = System.targets[packet.target_name]
191
+ target.tlm_cnt += 1 if target
192
+ packet.received_count += 1
193
+ @identified_packet_callback.call(packet) if @identified_packet_callback
195
194
 
195
+ # So we can release the mutex
196
+ packet = packet.clone
197
+ end
198
+
196
199
  # Write to routers
197
200
  @interface.routers.each do |router|
198
201
  begin
@@ -86,7 +86,7 @@ module Cosmos
86
86
  return if @sleeper.sleep(@initial_delay)
87
87
  loop do
88
88
  start = Time.now
89
- check_methods.each {|method| self.send(method.intern) }
89
+ check_methods.each {|method| self.public_send(method.intern) }
90
90
  now = Time.now
91
91
  @status = "#{now.formatted}: Checking groups took #{now - start}s"
92
92
  sleep_time = @task_delay - (now - start)
@@ -19,6 +19,11 @@ module Cosmos
19
19
  protected
20
20
 
21
21
  def handle_packet(packet)
22
+ unless System.allow_router_commanding
23
+ Logger.error "Router received command with router commanding disabled"
24
+ return
25
+ end
26
+
22
27
  # Start out assuming we will route to all associated interfaces
23
28
  interfaces = @interface.interfaces
24
29