cosmos 4.2.4-java → 4.3.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/Gemfile +1 -1
  4. data/Manifest.txt +12 -0
  5. data/autohotkey/tools/cmd_sequence.ahk +21 -20
  6. data/autohotkey/tools/cmd_sequence2.ahk +1 -1
  7. data/autohotkey/tools/config_editor.ahk +1 -1
  8. data/autohotkey/tools/launcher.ahk +1 -0
  9. data/autohotkey/tools/packet_viewer.ahk +6 -5
  10. data/autohotkey/tools/test_runner.ahk +8 -8
  11. data/bin/cosmos +37 -0
  12. data/bin/dart_util +0 -0
  13. data/data/config/item_modifiers.yaml +9 -0
  14. data/data/crc.txt +91 -86
  15. data/demo/Rakefile +2 -0
  16. data/demo/config/dart/Gemfile +1 -1
  17. data/demo/config/data/crc.txt +8 -5
  18. data/demo/config/system/system.txt +28 -0
  19. data/demo/config/system/system2.txt +21 -3
  20. data/demo/config/system/system_alt_ports.txt +69 -0
  21. data/demo/config/targets/INST/cmd_tlm/inst_tlm.txt +1 -0
  22. data/demo/config/tools/cmd_tlm_server/cmd_tlm_server_chain.txt +18 -0
  23. data/demo/procedures/cosmos_api_test.rb +18 -14
  24. data/demo/procedures/local_screen_example.rb +51 -0
  25. data/ext/cosmos/ext/cosmos_io/cosmos_io.c +32 -4
  26. data/ext/cosmos/ext/packet/packet.c +6 -0
  27. data/ext/mkrf_conf.rb +2 -2
  28. data/install/config/dart/Gemfile +1 -1
  29. data/install/config/data/crc.txt +2 -2
  30. data/install/config/system/system.txt +23 -1
  31. data/lib/cosmos/conversions.rb +2 -0
  32. data/lib/cosmos/conversions/packet_time_formatted_conversion.rb +38 -0
  33. data/lib/cosmos/conversions/packet_time_seconds_conversion.rb +38 -0
  34. data/lib/cosmos/core_ext/cosmos_io.rb +2 -1
  35. data/lib/cosmos/dart/Gemfile +1 -1
  36. data/lib/cosmos/dart/examples/dart_stream_client.rb +6 -2
  37. data/lib/cosmos/dart/lib/dart_common.rb +1 -1
  38. data/lib/cosmos/dart/lib/dart_database_cleaner.rb +2 -2
  39. data/lib/cosmos/dart/lib/dart_decommutator.rb +4 -4
  40. data/lib/cosmos/dart/lib/dart_importer.rb +3 -3
  41. data/lib/cosmos/dart/lib/dart_packet_log_writer.rb +2 -2
  42. data/lib/cosmos/dart/processes/dart_ingester.rb +2 -0
  43. data/lib/cosmos/dart/processes/dart_util.rb +4 -4
  44. data/lib/cosmos/dart/spec/dart/dart_reducer_manager_spec.rb +3 -3
  45. data/lib/cosmos/gui/dialogs/cmd_tlm_raw_dialog.rb +9 -5
  46. data/lib/cosmos/gui/dialogs/details_dialog.rb +29 -29
  47. data/lib/cosmos/gui/dialogs/exception_list_dialog.rb +1 -1
  48. data/lib/cosmos/gui/dialogs/find_replace_dialog.rb +3 -3
  49. data/lib/cosmos/gui/dialogs/interface_raw_dialog.rb +2 -2
  50. data/lib/cosmos/gui/dialogs/set_tlm_dialog.rb +1 -1
  51. data/lib/cosmos/gui/dialogs/tlm_details_dialog.rb +10 -10
  52. data/lib/cosmos/gui/qt.rb +10 -1
  53. data/lib/cosmos/gui/qt_tool.rb +17 -10
  54. data/lib/cosmos/gui/text/ruby_editor.rb +47 -8
  55. data/lib/cosmos/gui/utilities/classification_banner.rb +60 -0
  56. data/lib/cosmos/gui/utilities/script_module_gui.rb +26 -0
  57. data/lib/cosmos/interfaces.rb +1 -0
  58. data/lib/cosmos/interfaces/interface.rb +4 -0
  59. data/lib/cosmos/interfaces/protocols/ignore_packet_protocol.rb +46 -0
  60. data/lib/cosmos/interfaces/protocols/preidentified_protocol.rb +68 -23
  61. data/lib/cosmos/packet_logs/packet_log_reader.rb +69 -26
  62. data/lib/cosmos/packet_logs/packet_log_writer.rb +13 -1
  63. data/lib/cosmos/packets/commands.rb +5 -1
  64. data/lib/cosmos/packets/packet.rb +36 -2
  65. data/lib/cosmos/packets/packet_config.rb +0 -1
  66. data/lib/cosmos/packets/parsers/format_string_parser.rb +0 -1
  67. data/lib/cosmos/packets/parsers/xtce_parser.rb +1 -1
  68. data/lib/cosmos/packets/telemetry.rb +4 -0
  69. data/lib/cosmos/script/api_shared.rb +2 -0
  70. data/lib/cosmos/script/limits.rb +4 -0
  71. data/lib/cosmos/script/script.rb +27 -11
  72. data/lib/cosmos/script/telemetry.rb +3 -1
  73. data/lib/cosmos/script/tools.rb +18 -8
  74. data/lib/cosmos/system/system.rb +21 -0
  75. data/lib/cosmos/tools/cmd_extractor/cmd_extractor.rb +26 -24
  76. data/lib/cosmos/tools/cmd_sender/cmd_sender.rb +29 -29
  77. data/lib/cosmos/tools/cmd_sequence/cmd_sequence.rb +65 -40
  78. data/lib/cosmos/tools/cmd_sequence/sequence_item.rb +6 -6
  79. data/lib/cosmos/tools/cmd_tlm_server/api.rb +13 -0
  80. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb +12 -9
  81. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_config.rb +7 -1
  82. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb +8 -8
  83. data/lib/cosmos/tools/cmd_tlm_server/commanding.rb +13 -2
  84. data/lib/cosmos/tools/cmd_tlm_server/gui/interfaces_tab.rb +2 -2
  85. data/lib/cosmos/tools/cmd_tlm_server/gui/logging_tab.rb +13 -13
  86. data/lib/cosmos/tools/cmd_tlm_server/gui/packets_tab.rb +4 -4
  87. data/lib/cosmos/tools/cmd_tlm_server/gui/status_tab.rb +8 -8
  88. data/lib/cosmos/tools/cmd_tlm_server/gui/targets_tab.rb +5 -5
  89. data/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb +35 -20
  90. data/lib/cosmos/tools/cmd_tlm_server/replay_backend.rb +15 -11
  91. data/lib/cosmos/tools/config_editor/config_editor.rb +69 -69
  92. data/lib/cosmos/tools/data_viewer/data_viewer.rb +42 -38
  93. data/lib/cosmos/tools/data_viewer/data_viewer_component.rb +1 -0
  94. data/lib/cosmos/tools/data_viewer/dump_component.rb +1 -0
  95. data/lib/cosmos/tools/handbook_creator/handbook_creator.rb +4 -4
  96. data/lib/cosmos/tools/launcher/launcher.rb +1 -1
  97. data/lib/cosmos/tools/limits_monitor/limits_monitor.rb +28 -24
  98. data/lib/cosmos/tools/opengl_builder/opengl_builder.rb +42 -42
  99. data/lib/cosmos/tools/packet_viewer/packet_viewer.rb +56 -53
  100. data/lib/cosmos/tools/script_runner/script_runner.rb +112 -95
  101. data/lib/cosmos/tools/script_runner/script_runner_frame.rb +48 -30
  102. data/lib/cosmos/tools/table_manager/table_manager.rb +42 -42
  103. data/lib/cosmos/tools/test_runner/test_runner.rb +45 -27
  104. data/lib/cosmos/tools/test_runner/test_runner_chooser.rb +3 -3
  105. data/lib/cosmos/tools/tlm_extractor/tlm_extractor.rb +45 -45
  106. data/lib/cosmos/tools/tlm_extractor/tlm_extractor_config.rb +4 -4
  107. data/lib/cosmos/tools/tlm_grapher/data_object_adders/xy_data_object_adder.rb +3 -3
  108. data/lib/cosmos/tools/tlm_grapher/data_object_editors/housekeeping_data_object_editor.rb +7 -7
  109. data/lib/cosmos/tools/tlm_grapher/data_object_editors/xy_data_object_editor.rb +10 -10
  110. data/lib/cosmos/tools/tlm_grapher/data_objects/housekeeping_data_object.rb +10 -3
  111. data/lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb +6 -6
  112. data/lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb +14 -14
  113. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_tool.rb +83 -83
  114. data/lib/cosmos/tools/tlm_viewer/screen.rb +73 -13
  115. data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +15 -15
  116. data/lib/cosmos/tools/tlm_viewer/widgets.rb +1 -0
  117. data/lib/cosmos/tools/tlm_viewer/widgets/canvasellipse_widget.rb +40 -0
  118. data/lib/cosmos/tools/tlm_viewer/widgets/timegraph_widget.rb +1 -1
  119. data/lib/cosmos/tools/tlm_viewer/widgets/widget.rb +6 -1
  120. data/lib/cosmos/top_level.rb +14 -1
  121. data/lib/cosmos/version.rb +5 -5
  122. data/lib/cosmos/win32/excel.rb +63 -12
  123. data/make_gems.sh +10 -0
  124. data/spec/conversions/packet_time_formatted_conversion_spec.rb +58 -0
  125. data/spec/conversions/packet_time_seconds_conversion_spec.rb +60 -0
  126. data/spec/interfaces/protocols/ignore_packet_protocol_spec.rb +243 -0
  127. data/spec/interfaces/protocols/preidentified_protocol_spec.rb +227 -4
  128. data/spec/io/serial_driver_spec.rb +15 -13
  129. data/spec/packet_logs/packet_log_reader_spec.rb +72 -17
  130. data/spec/packets/packet_config_spec.rb +5 -16
  131. data/spec/packets/parsers/format_string_parser_spec.rb +0 -11
  132. data/spec/packets/parsers/macro_parser_spec.rb +36 -36
  133. data/spec/packets/parsers/state_parser_spec.rb +36 -0
  134. data/spec/packets/telemetry_spec.rb +11 -9
  135. data/spec/script/script_spec.rb +2 -3
  136. data/spec/script/scripting_spec.rb +2 -1
  137. data/spec/script/tools_spec.rb +0 -1
  138. data/spec/tools/cmd_tlm_server/api_spec.rb +28 -20
  139. data/spec/tools/cmd_tlm_server/cmd_tlm_server_config_spec.rb +33 -0
  140. data/spec/tools/cmd_tlm_server/commanding_spec.rb +25 -1
  141. data/spec/tools/cmd_tlm_server/interface_thread_spec.rb +15 -0
  142. data/tasks/gemfile_stats.rake +3 -2
  143. metadata +14 -2
@@ -11,8 +11,10 @@
11
11
  require 'cosmos'
12
12
  require 'cosmos/gui/qt'
13
13
  require 'cosmos/gui/qt_tool'
14
+ require 'cosmos/gui/utilities/classification_banner'
14
15
  require 'cosmos/script'
15
16
  require 'cosmos/tools/tlm_viewer/widgets'
17
+ require 'tempfile'
16
18
 
17
19
  module Cosmos
18
20
 
@@ -23,6 +25,8 @@ module Cosmos
23
25
 
24
26
  attr_accessor :full_name, :width, :height, :window, :replay_flag
25
27
 
28
+ include ClassificationBanner
29
+
26
30
  class Widgets
27
31
  # Flag to indicate all screens should close
28
32
  @@closing_all = false
@@ -33,10 +37,12 @@ module Cosmos
33
37
  @@closing_all = value
34
38
  end
35
39
 
36
- def initialize(screen, mode)
40
+ def initialize(screen, mode, local_binding = nil)
37
41
  @screen = screen
38
42
  # The telemetry viewer mode. Must be :REALTIME or basically anything else?
39
43
  @mode = mode
44
+ # Local binding to evaluate LOCAL target
45
+ @local_binding = local_binding
40
46
  # Hash of only the named widgets identifed by the NAMED_WIDGET keyword
41
47
  @named = {}
42
48
  # Array of all widgets which take a value
@@ -84,7 +90,7 @@ module Cosmos
84
90
 
85
91
  def add_widget(klass, parameters, widget, widget_name, substitute, original_target_name, force_substitute)
86
92
  # Add to item or non_item widgets
87
- if klass.takes_value?
93
+ if klass.takes_value? and substitute != 'LOCAL' and parameters[0] != 'LOCAL'
88
94
  if substitute and (original_target_name == parameters[0].upcase or force_substitute)
89
95
  @items << [substitute, parameters[1], parameters[2]]
90
96
  else
@@ -113,7 +119,7 @@ module Cosmos
113
119
  @value_thread = Thread.new do
114
120
  begin
115
121
  while(true)
116
- break if @@closing_all
122
+ break if @@closing_all or !@alive
117
123
  time = Time.now.sys
118
124
 
119
125
  if !@item.empty?
@@ -137,7 +143,7 @@ module Cosmos
137
143
  @limits_set = limits_set
138
144
  end
139
145
  rescue DRb::DRbConnError
140
- break if @@closing_all
146
+ break if @@closing_all or !@alive
141
147
  break if @value_sleeper.sleep(1)
142
148
  next
143
149
  end
@@ -145,7 +151,7 @@ module Cosmos
145
151
 
146
152
  Qt.execute_in_main_thread {update_gui()} if @alive and (@mode == :REALTIME)
147
153
  delta = Time.now.sys - time
148
- break if @@closing_all
154
+ break if @@closing_all or !@alive
149
155
  if @polling_period - delta > 0
150
156
  break if @value_sleeper.sleep(@polling_period - delta)
151
157
  else
@@ -178,7 +184,27 @@ module Cosmos
178
184
 
179
185
  # Update non_item widgets
180
186
  @non_item.each do |widget|
181
- widget.update_widget
187
+ if widget.class.takes_value?
188
+ # LOCAL value
189
+ eval_binding = @local_binding
190
+ begin
191
+ eval_binding = ScriptRunnerFrame.instance.script_binding
192
+ @local_binding = eval_binding
193
+ rescue Exception
194
+ # Fall back on @local_binding
195
+ end
196
+
197
+ begin
198
+ widget.limits_state = nil
199
+ widget.value = eval_binding.eval(widget.item_name)
200
+ rescue Exception
201
+ # Bad local variable or binding no longer valid
202
+ widget.limits_state = :STALE
203
+ widget.value = widget.value
204
+ end
205
+ else
206
+ widget.update_widget
207
+ end
182
208
  end
183
209
  end
184
210
  rescue Exception => error
@@ -190,7 +216,7 @@ module Cosmos
190
216
 
191
217
  def shutdown
192
218
  @alive = false
193
- Cosmos.kill_thread(self, @value_thread)
219
+ Cosmos.kill_thread(self, @value_thread, 2, 0.1, 2)
194
220
 
195
221
  # Shutdown All Widgets
196
222
  widgets().each do |widget|
@@ -203,7 +229,7 @@ module Cosmos
203
229
  end
204
230
  end
205
231
 
206
- def initialize(full_name, filename, notify_on_close = nil, mode = :REALTIME, x_pos = nil, y_pos = nil, original_target_name = nil, substitute = nil, force_substitute = false, single_screen = false)
232
+ def initialize(full_name, filename_or_screen_def, notify_on_close = nil, mode = :REALTIME, x_pos = nil, y_pos = nil, original_target_name = nil, substitute = nil, force_substitute = false, single_screen = false, local_binding = nil)
207
233
  super(nil)
208
234
  # The full name of the widget which goes in the title
209
235
  @full_name = full_name
@@ -224,15 +250,20 @@ module Cosmos
224
250
  # displayed as a stand alone screen and not launched as a part of the
225
251
  # regular TlmViewer application
226
252
  @single_screen = single_screen
253
+ # Binding for use with LOCAL LOCAL
254
+ @local_binding = local_binding
227
255
 
228
256
  # Read the application wide stylesheet if it exists
229
257
  app_style = File.join(Cosmos::USERPATH, 'config', 'tools', 'application.css')
230
258
  setStyleSheet(File.read(app_style)) if File.exist? app_style
231
259
 
232
260
  @replay_flag = nil
233
- @widgets = Widgets.new(self, mode)
234
- @window = process(filename)
261
+ @widgets = Widgets.new(self, mode, @local_binding)
262
+ @window = process(filename_or_screen_def)
235
263
  @@open_screens << self if @window
264
+
265
+ # Add a banner based on system configuration
266
+ add_classification_banner
236
267
  end
237
268
 
238
269
  def widgets
@@ -247,7 +278,7 @@ module Cosmos
247
278
  @widgets.mode
248
279
  end
249
280
 
250
- def process(filename)
281
+ def process(filename_or_screen_def)
251
282
  layout_stack = []
252
283
  layout_stack[0] = nil
253
284
 
@@ -256,6 +287,16 @@ module Cosmos
256
287
  global_settings = {}
257
288
  global_subsettings = {}
258
289
 
290
+ if File.exist?(filename_or_screen_def) or !filename_or_screen_def.to_s.index("SCREEN")
291
+ tempfile = false
292
+ filename = filename_or_screen_def
293
+ else
294
+ tempfile = Tempfile.new('screen')
295
+ tempfile.write(filename_or_screen_def)
296
+ tempfile.close
297
+ filename = tempfile.path
298
+ end
299
+
259
300
  begin
260
301
  parser = ConfigParser.new("http://cosmosrb.com/docs/screens/")
261
302
  parser.instance_variable_set(:@original_target_name, @original_target_name)
@@ -322,6 +363,8 @@ module Cosmos
322
363
  klass = Cosmos.require_class(parameters[0].to_s.downcase + '_widget')
323
364
  global_subsettings[klass] ||= []
324
365
  global_subsettings[klass] << [parameters[1]].concat(parameters[2..-1])
366
+ when 'STAY_ON_TOP'
367
+ setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint)
325
368
  else
326
369
  current_widget = process_widget(parser, keyword, parameters, layout_stack, global_settings, global_subsettings)
327
370
  end # case keyword
@@ -336,6 +379,8 @@ module Cosmos
336
379
  end
337
380
  shutdown()
338
381
  return nil
382
+ ensure
383
+ tempfile.unlink if tempfile
339
384
  end
340
385
 
341
386
  unless @widgets.invalid.empty?
@@ -387,10 +432,14 @@ module Cosmos
387
432
  parser.verify_num_parameters(3, nil, "#{keyword} <Target Name> <Packet Name> <Item Name> <Widget Settings... (optional)>")
388
433
  begin
389
434
  if @substitute and (@original_target_name == parameters[0].upcase or @force_substitute)
390
- System.telemetry.packet_and_item(@substitute, parameters[1], parameters[2])
435
+ if @substitute != 'LOCAL' or parameters[1] != 'LOCAL'
436
+ System.telemetry.packet_and_item(@substitute, parameters[1], parameters[2])
437
+ end
391
438
  widget = klass.new(layout_stack[-1], @substitute, *parameters[1..(parameters.length - 1)])
392
439
  else
393
- System.telemetry.packet_and_item(*parameters[0..2])
440
+ if parameters[0] != 'LOCAL' or parameters[1] != 'LOCAL'
441
+ System.telemetry.packet_and_item(*parameters[0..2])
442
+ end
394
443
  widget = klass.new(layout_stack[-1], *parameters)
395
444
  end
396
445
  rescue => err
@@ -470,6 +519,8 @@ module Cosmos
470
519
  end
471
520
 
472
521
  self.dispose
522
+
523
+ @window = nil
473
524
  end
474
525
 
475
526
  def get_named_widget(widget_name)
@@ -488,6 +539,15 @@ module Cosmos
488
539
  @widgets.graceful_kill
489
540
  end
490
541
 
542
+ def close
543
+ Qt.execute_in_main_thread(true) do
544
+ if @window
545
+ super()
546
+ @window = nil
547
+ end
548
+ end
549
+ end
550
+
491
551
  def self.open_screens
492
552
  @@open_screens
493
553
  end
@@ -10,14 +10,14 @@
10
10
 
11
11
  require 'cosmos'
12
12
  Cosmos.catch_fatal_exception do
13
- require 'cosmos/script'
14
- require 'cosmos/tools/tlm_viewer/screen'
15
13
  require 'cosmos/gui/qt_tool'
16
14
  require 'cosmos/gui/dialogs/splash'
17
15
  require 'cosmos/gui/dialogs/progress_dialog'
18
16
  require 'cosmos/gui/dialogs/select_dialog'
19
17
  require 'cosmos/gui/widgets/full_text_search_line_edit'
20
18
  require 'cosmos/tools/tlm_viewer/tlm_viewer_config'
19
+ require 'cosmos/tools/tlm_viewer/screen'
20
+ require 'cosmos/script'
21
21
  require 'find'
22
22
  require 'fileutils'
23
23
  end
@@ -164,32 +164,32 @@ module Cosmos
164
164
  super()
165
165
 
166
166
  # File actions
167
- @file_save = Qt::Action.new(Cosmos.get_icon('save.png'), tr('&Save Configuration'), self)
168
- @file_save_keyseq = Qt::KeySequence.new(tr('Ctrl+S'))
167
+ @file_save = Qt::Action.new(Cosmos.get_icon('save.png'), '&Save Configuration', self)
168
+ @file_save_keyseq = Qt::KeySequence.new('Ctrl+S')
169
169
  @file_save.shortcut = @file_save_keyseq
170
- @file_save.statusTip = tr('Save all screen positions')
170
+ @file_save.statusTip = 'Save all screen positions'
171
171
  @file_save.connect(SIGNAL('triggered()')) { file_save() }
172
172
 
173
- @file_generate = Qt::Action.new(tr('&Generate Screens'), self)
174
- @file_generate_keyseq = Qt::KeySequence.new(tr('Ctrl+G'))
173
+ @file_generate = Qt::Action.new('&Generate Screens', self)
174
+ @file_generate_keyseq = Qt::KeySequence.new('Ctrl+G')
175
175
  @file_generate.shortcut = @file_generate_keyseq
176
- @file_generate.statusTip = tr('Generate screen definition files')
176
+ @file_generate.statusTip = 'Generate screen definition files'
177
177
  @file_generate.connect(SIGNAL('triggered()')) { file_generate() }
178
178
 
179
- @file_audit = Qt::Action.new(tr('Audi&t Screens vs Tlm'), self)
180
- @file_audit_keyseq = Qt::KeySequence.new(tr('Ctrl+T'))
179
+ @file_audit = Qt::Action.new('Audi&t Screens vs Tlm', self)
180
+ @file_audit_keyseq = Qt::KeySequence.new('Ctrl+T')
181
181
  @file_audit.shortcut = @file_audit_keyseq
182
- @file_audit.statusTip = tr('Create a report listing which telemetry points are not on screens')
182
+ @file_audit.statusTip = 'Create a report listing which telemetry points are not on screens'
183
183
  @file_audit.connect(SIGNAL('triggered()')) { file_audit() }
184
184
 
185
- @replay_action = Qt::Action.new(tr('Toggle Replay Mode'), self)
186
- @replay_action.statusTip = tr('Toggle Replay Mode')
185
+ @replay_action = Qt::Action.new('Toggle Replay Mode', self)
186
+ @replay_action.statusTip = 'Toggle Replay Mode'
187
187
  @replay_action.connect(SIGNAL('triggered()')) { toggle_replay_mode() }
188
188
  end
189
189
 
190
190
  def initialize_menus(options)
191
191
  # File Menu
192
- @file_menu = menuBar.addMenu(tr('&File'))
192
+ @file_menu = menuBar.addMenu('&File')
193
193
  @file_menu.addAction(@file_save)
194
194
  @file_menu.addAction(@file_generate)
195
195
  @file_menu.addAction(@file_audit)
@@ -552,7 +552,7 @@ module Cosmos
552
552
 
553
553
  option_parser.separator "Telemetry Viewer Specific Options:"
554
554
  option_parser.on("-c", "--config FILE", "Use the specified config file") { |arg| options.config_file = arg }
555
- option_parser.on("-s", "--screen FILE", "Start up the specified screen") { |arg| options.screen = arg }
555
+ option_parser.on("-s", "--screen SCREEN_NAME", "Start up the specified screen") { |arg| options.screen = arg }
556
556
  option_parser.on("-n", "--nolisten", "Don't listen for requests") do
557
557
  options.listen = false
558
558
  options.title << ' : Not Listening'
@@ -4,6 +4,7 @@ require 'cosmos/tools/tlm_viewer/widgets/block_widget.rb'
4
4
  require 'cosmos/tools/tlm_viewer/widgets/button_widget.rb'
5
5
  require 'cosmos/tools/tlm_viewer/widgets/backgroundbutton_widget.rb'
6
6
  require 'cosmos/tools/tlm_viewer/widgets/canvasdot_widget.rb'
7
+ require 'cosmos/tools/tlm_viewer/widgets/canvasellipse_widget.rb'
7
8
  require 'cosmos/tools/tlm_viewer/widgets/canvasimagevalue_widget.rb'
8
9
  require 'cosmos/tools/tlm_viewer/widgets/canvasimage_widget.rb'
9
10
  require 'cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb'
@@ -0,0 +1,40 @@
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2018 Ball Aerospace & Technologies Corp.
4
+ # All Rights Reserved.
5
+ #
6
+ # This program is free software; you can modify and/or redistribute it
7
+ # under the terms of the GNU General Public License
8
+ # as published by the Free Software Foundation; version 3 with
9
+ # attribution addendums as found in the LICENSE.txt
10
+
11
+ require 'cosmos/tools/tlm_viewer/widgets/widget'
12
+
13
+ module Cosmos
14
+ class CanvasellipseWidget
15
+ include Widget
16
+
17
+ def initialize(parent_layout, center_x, center_y, width, height, color = 'black', line_width = 1, fill = false)
18
+ super()
19
+ @center_x = center_x.to_i
20
+ @center_y = center_y.to_i
21
+ @width = width.to_i
22
+ @height = height.to_i
23
+ @line_width = line_width.to_i
24
+ @fill = ConfigParser::handle_true_false(fill)
25
+ @color = Cosmos::getColor(color)
26
+ @pen = Cosmos.getPen(color)
27
+ parent_layout.add_repaint(self)
28
+ end
29
+
30
+ def paint(painter)
31
+ painter.save
32
+ @pen.setWidth(@line_width)
33
+ painter.setPen(@pen)
34
+ painter.setBrush(@color) if @fill
35
+ painter.drawEllipse(@center_x, @center_y, @width, @height)
36
+ painter.restore
37
+ end
38
+
39
+ end
40
+ end
@@ -19,7 +19,7 @@ module Cosmos
19
19
  # This class creates a graph of the supplied data value versus time.
20
20
  class TimegraphWidget < LinegraphWidget
21
21
 
22
- def initialize(parent_layout, target_name, packet_name, item_name, num_samples = 100, width = 300, height = 200, point_size = 5, time_item_name = 'RECEIVED_TIMESECONDS', value_type = :CONVERTED)
22
+ def initialize(parent_layout, target_name, packet_name, item_name, num_samples = 100, width = 300, height = 200, point_size = 5, time_item_name = 'PACKET_TIMESECONDS', value_type = :CONVERTED)
23
23
  super(parent_layout, target_name, packet_name, item_name, num_samples, width, height, value_type)
24
24
  @time_item_name = time_item_name.to_s
25
25
  @time = []
@@ -41,7 +41,12 @@ module Cosmos
41
41
  @item_name = ConfigParser.handle_nil(item_name)
42
42
  @item = nil
43
43
  if @item_name
44
- @packet, @item = System.telemetry.packet_and_item(@target_name, @packet_name, @item_name)
44
+ if @target_name == 'LOCAL' and @packet_name == 'LOCAL'
45
+ @packet = nil
46
+ @item = nil
47
+ else
48
+ @packet, @item = System.telemetry.packet_and_item(@target_name, @packet_name, @item_name)
49
+ end
45
50
  end
46
51
  if value_type
47
52
  @value_type = value_type.to_s.upcase.to_sym
@@ -186,6 +186,19 @@ module Cosmos
186
186
  user_path = File.join(Cosmos::USERPATH, partial_path)
187
187
  return user_path if File.exist?(user_path)
188
188
 
189
+ # Check cosmos extensions
190
+ begin
191
+ Bundler.load.specs.each do |spec|
192
+ spec_name_split = spec.name.split('-')
193
+ if spec_name_split.length > 1 and spec_name_split[0] == 'cosmos'
194
+ filename = File.join(spec.gem_dir, partial_path)
195
+ return filename if File.exist? filename
196
+ end
197
+ end
198
+ rescue Bundler::GemfileNotFound
199
+ # No Gemfile - so no gem based extensions
200
+ end
201
+
189
202
  # Then look relative to the calling file
190
203
  if Pathname.new(calling_file).absolute?
191
204
  current_dir = File.dirname(calling_file)
@@ -572,7 +585,7 @@ module Cosmos
572
585
  # @param try_gui [Boolean] Whether to try and create a GUI exception popup
573
586
  def self.handle_critical_exception(error, try_gui = true)
574
587
  Logger.error "Critical Exception! #{error.formatted}"
575
- if defined? ExceptionDialog and !ExceptionDialog.dialog_open?
588
+ if defined? ExceptionDialog and !ExceptionDialog.dialog_open? and $qApp
576
589
  log_file = self.write_exception_file(error)
577
590
  if try_gui
578
591
  Qt.execute_in_main_thread(true) {|| ExceptionDialog.new(nil, error, '', false, false, log_file)}
@@ -1,12 +1,12 @@
1
1
  # encoding: ascii-8bit
2
2
 
3
- COSMOS_VERSION = '4.2.4'
3
+ COSMOS_VERSION = '4.3.0'
4
4
  module Cosmos
5
5
  module Version
6
6
  MAJOR = '4'
7
- MINOR = '2'
8
- PATCH = '4'
9
- BUILD = '4c60966285c2f7a5a050bfec88cb081b8662fac9'
7
+ MINOR = '3'
8
+ PATCH = '0'
9
+ BUILD = '3588276d89cb9d934e0e51ad8c6e2426fc5dafb5'
10
10
  end
11
- VERSION = '4.2.4'
11
+ VERSION = '4.3.0'
12
12
  end
@@ -9,42 +9,78 @@
9
9
  # attribution addendums as found in the LICENSE.txt
10
10
 
11
11
  require 'win32ole'
12
+ require 'fileutils'
12
13
 
13
14
  module Cosmos
14
-
15
- #
16
- # This class will take an Excel spreadsheet and build an easily manipulated spreadsheet in ruby
17
- #
15
+ # Open an Excel spreadsheet and build an easily manipulated spreadsheet in ruby
18
16
  class ExcelSpreadsheet
19
-
20
17
  attr_reader :worksheets
21
18
 
19
+ # Class to allow easy manipulation to the data in an Excel worksheet
22
20
  class ExcelWorksheet
23
-
24
21
  attr_reader :name, :num_rows, :num_columns, :data
25
22
 
26
- def initialize (worksheet)
23
+ # @param worksheet [WIN32OLE] The underlying Excel worksheet object
24
+ def initialize(worksheet)
27
25
  @name = worksheet.name
28
26
  @num_rows = worksheet.UsedRange.rows.count
29
27
  @num_columns = worksheet.UsedRange.columns.count
30
28
 
31
- #Get Excel Data from Worksheet
29
+ # Get Excel Data from Worksheet
32
30
  @data = worksheet.UsedRange.value
31
+
32
+ # Build a lookup table based on the first column
33
+ @lkup = {}
34
+ @data.each do |row|
35
+ @lkup[row[0]] = row[1..-1]
36
+ end
33
37
  end
34
38
 
39
+ def keys
40
+ @lkup.keys
41
+ end
42
+
43
+ # Access the lookup values by string or the raw data by index
44
+ #
45
+ # @param index [String|Integer] Name of the first column or index
46
+ # @return [ExcelWorksheet] The data in that row
47
+ def [](index)
48
+ if index.is_a? String
49
+ @lkup[index]
50
+ else
51
+ @data[index]
52
+ end
53
+ end
35
54
  end
36
55
 
37
- def initialize (filename)
56
+ # @param filename [String] Name of the Excel file to open
57
+ # @param archive [true|String] If true, create an archive file in the
58
+ # default system LOGS directory. If an absolute path, create the
59
+ # archive file in the specified path.
60
+ def initialize(filename, archive: nil)
61
+ if archive
62
+ time = Time.now.sys
63
+ timestamp = sprintf("%04u_%02u_%02u_%02u_%02u_%02u", time.year, time.month, time.mday, time.hour, time.min, time.sec)
64
+ # If archive is true we use the system LOGS path
65
+ if archive == true
66
+ archive = Cosmos::System.paths['LOGS']
67
+ end
68
+ archive = File.join(archive, "#{timestamp}_#{File.basename(filename)}")
69
+ FileUtils.cp filename, archive
70
+ File.chmod(0444, archive) # Mark read-only
71
+ end
72
+
38
73
  excel = WIN32OLE.new('excel.application')
39
74
  excel.visible = false
40
75
  wb = excel.workbooks.open(filename)
41
76
 
42
77
  @worksheets = []
43
-
78
+ @lkup = {}
44
79
  count = wb.worksheets.count
45
80
  count.times do |index|
46
81
  ws = wb.worksheets(index + 1)
47
82
  @worksheets << ExcelWorksheet.new(ws)
83
+ @lkup[ws.name] = @worksheets[-1]
48
84
  end
49
85
 
50
86
  excel.DisplayAlerts = false
@@ -53,6 +89,22 @@ module Cosmos
53
89
  GC.start
54
90
  end
55
91
 
92
+ # @return [Array<String>] Array of all the worksheet names
93
+ def keys
94
+ @lkup.keys
95
+ end
96
+
97
+ # Access a worksheet by passing in the name or index
98
+ #
99
+ # @param index [String|Integer] Name of the worksheet or index
100
+ # @return [ExcelWorksheet] The worksheet object
101
+ def [](index)
102
+ if index.is_a? String
103
+ @lkup[index]
104
+ else
105
+ @worksheets[index]
106
+ end
107
+ end
56
108
  end
57
109
 
58
110
  module ExcelColumnConstants
@@ -62,5 +114,4 @@ module Cosmos
62
114
  index += 1
63
115
  end
64
116
  end
65
-
66
- end # module Cosmos
117
+ end