cosmos 4.4.0-java → 4.4.1-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) 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 +65 -0
  6. data/Manifest.txt +12 -2
  7. data/README.md +5 -0
  8. data/Rakefile +52 -0
  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_sender.ahk +34 -6
  17. data/autohotkey/tools/cmd_sender2.ahk +4 -0
  18. data/autohotkey/tools/cmd_sequence.ahk +21 -8
  19. data/autohotkey/tools/config_editor.ahk +4 -4
  20. data/bin/cstol_converter +1 -1
  21. data/cosmos.gemspec +1 -1
  22. data/data/config/command_modifiers.yaml +16 -1
  23. data/data/config/param_item_modifiers.yaml +5 -0
  24. data/data/config/system.yaml +31 -1
  25. data/data/config/telemetry_modifiers.yaml +16 -1
  26. data/data/crc.txt +415 -410
  27. data/demo/config/dart/Gemfile +1 -6
  28. data/demo/config/data/crc.txt +244 -243
  29. data/demo/config/system/system.txt +3 -0
  30. data/demo/config/system/system2.txt +3 -0
  31. data/demo/config/system/system_alt_ports.txt +3 -0
  32. data/demo/config/targets/INST/cmd_tlm/inst_cmds.txt +3 -3
  33. data/demo/config/targets/INST/cmd_tlm/inst_tlm.txt +4 -0
  34. data/demo/config/targets/INST/cmd_tlm/inst_tlm_override.txt +12 -0
  35. data/demo/config/targets/INST/lib/sim_inst.rb +2 -2
  36. data/demo/config/targets/INST/target.txt +1 -0
  37. data/demo/procedures/cosmos_api_test.rb +8 -8
  38. data/install/config/dart/Gemfile +2 -7
  39. data/install/config/data/crc.txt +143 -143
  40. data/install/config/system/system.txt +3 -0
  41. data/lib/cosmos/dart/config/boot.rb +1 -1
  42. data/lib/cosmos/dart/config/database.yml +2 -0
  43. data/lib/cosmos/dart/lib/dart_common.rb +11 -4
  44. data/lib/cosmos/dart/lib/dart_constants.rb +15 -0
  45. data/lib/cosmos/dart/lib/dart_decom_query.rb +5 -6
  46. data/lib/cosmos/dart/lib/dart_decommutator.rb +66 -56
  47. data/lib/cosmos/dart/lib/dart_master_query.rb +71 -0
  48. data/lib/cosmos/dart/lib/dart_reducer_worker_thread.rb +165 -134
  49. data/lib/cosmos/dart/processes/dart.rb +4 -2
  50. data/lib/cosmos/dart/processes/dart_decom_server.rb +2 -2
  51. data/lib/cosmos/dart/processes/dart_ingester.rb +38 -1
  52. data/lib/cosmos/dart/processes/dart_master.rb +44 -0
  53. data/lib/cosmos/dart/processes/dart_util.rb +115 -0
  54. data/lib/cosmos/gui/widgets/dart_meta_frame.rb +21 -2
  55. data/lib/cosmos/interfaces/protocols/length_protocol.rb +5 -0
  56. data/lib/cosmos/io/json_drb.rb +3 -3
  57. data/lib/cosmos/io/posix_serial_driver.rb +1 -1
  58. data/lib/cosmos/io/win32_serial_driver.rb +23 -2
  59. data/lib/cosmos/packet_logs/packet_log_reader.rb +2 -2
  60. data/lib/cosmos/packets/packet.rb +1 -1
  61. data/lib/cosmos/packets/packet_config.rb +26 -8
  62. data/lib/cosmos/packets/structure.rb +17 -0
  63. data/lib/cosmos/packets/structure_item.rb +5 -1
  64. data/lib/cosmos/packets/telemetry.rb +7 -1
  65. data/lib/cosmos/system/system.rb +115 -48
  66. data/lib/cosmos/tools/cmd_sender/cmd_params.rb +360 -0
  67. data/lib/cosmos/tools/cmd_sender/cmd_sender.rb +23 -319
  68. data/lib/cosmos/tools/cmd_sequence/cmd_sequence.rb +14 -17
  69. data/lib/cosmos/tools/cmd_sequence/sequence_item.rb +43 -331
  70. data/lib/cosmos/tools/cmd_sequence/sequence_list.rb +16 -11
  71. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb +1 -0
  72. data/lib/cosmos/tools/config_editor/config_editor.rb +33 -2
  73. data/lib/cosmos/tools/config_editor/config_editor_frame.rb +8 -9
  74. data/lib/cosmos/tools/config_editor/system_config_dialog.rb +158 -0
  75. data/lib/cosmos/tools/script_runner/script_runner_frame.rb +2 -2
  76. data/lib/cosmos/tools/test_runner/test.rb +5 -2
  77. data/lib/cosmos/tools/test_runner/test_runner.rb +2 -2
  78. data/lib/cosmos/tools/tlm_extractor/tlm_extractor_processor.rb +17 -13
  79. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_dart_thread.rb +20 -16
  80. data/lib/cosmos/tools/tlm_grapher/tlm_grapher.rb +18 -11
  81. data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +16 -5
  82. data/lib/cosmos/utilities/ruby_lex_utils.rb +34 -30
  83. data/lib/cosmos/version.rb +4 -4
  84. data/lib/cosmos/win32/excel.rb +23 -17
  85. data/run_gui_tests.bat +1 -0
  86. data/spec/core_ext/socket_spec.rb +1 -1
  87. data/spec/install/yaml_docs_spec.rb +26 -6
  88. data/spec/interfaces/protocols/length_protocol_spec.rb +39 -0
  89. data/spec/io/json_drb_spec.rb +14 -0
  90. data/spec/io/win32_serial_driver_spec.rb +16 -2
  91. data/spec/packet_logs/packet_log_reader_spec.rb +2 -2
  92. data/spec/packets/structure_spec.rb +52 -2
  93. data/spec/packets/telemetry_spec.rb +29 -1
  94. data/spec/system/system_spec.rb +2 -2
  95. data/spec/utilities/message_log_spec.rb +6 -3
  96. data/tasks/gemfile_stats.rake +22 -13
  97. metadata +15 -5
  98. data/lib/cosmos/dart/Gemfile +0 -69
@@ -17,6 +17,7 @@ Cosmos.catch_fatal_exception do
17
17
  require 'cosmos/gui/dialogs/cmd_details_dialog'
18
18
  require 'cosmos/gui/widgets/full_text_search_line_edit'
19
19
  require 'cosmos/tools/cmd_sender/cmd_sender_text_edit'
20
+ require 'cosmos/tools/cmd_sender/cmd_params'
20
21
  require 'cosmos/tools/cmd_sender/cmd_param_table_item_delegate'
21
22
  require 'cosmos/config/config_parser'
22
23
  require 'cosmos/script'
@@ -41,15 +42,6 @@ module Cosmos
41
42
  # command is sent it is added to the command history window which allows the
42
43
  # user to resend the command or copy it for use in a script.
43
44
  class CmdSender < QtTool
44
- slots 'file_send_raw()'
45
- slots 'update_cmd_params(bool)'
46
- slots 'menu_states_in_hex(bool)'
47
- slots 'target_changed(const QString&)'
48
- slots 'cmd_changed(const QString&)'
49
- slots 'send_button()'
50
- slots 'context_menu(const QPoint&)'
51
- slots 'click_callback(QTableWidgetItem*)'
52
-
53
45
  MANUALLY = CmdParamTableItemDelegate::MANUALLY
54
46
 
55
47
  # @return [Integer] Number of commands sent
@@ -62,20 +54,6 @@ module Cosmos
62
54
  @@send_count = val
63
55
  end
64
56
 
65
- # @return [Array<PacketItem, Qt::TableWidgetItem, Qt::TableWidgetItem>]
66
- # Array of the packet item, the table widget item representing the value,
67
- # and the table widget item representing states if the packet item has
68
- # states.
69
- def self.param_widgets
70
- @@param_widgets
71
- end
72
-
73
- # @return [Qt::TableWidget] Table holding the command parameters. Each
74
- # parameter is a separate row in the table.
75
- def self.table
76
- @@table
77
- end
78
-
79
57
  # Create the application by building the GUI and loading an initial target
80
58
  # and command packet. This can be passed on the command line or the first
81
59
  # target and packet will be loaded.
@@ -85,13 +63,11 @@ module Cosmos
85
63
  super(options)
86
64
  Cosmos.load_cosmos_icon("cmd_sender.png")
87
65
 
88
- @file_dir = System.paths['LOGS']
89
66
  @message_log = MessageLog.new('cmdsender')
90
67
  @production = options.production
91
68
  @send_raw_dir = nil
92
69
  @@send_count = 0
93
- @@param_widgets = []
94
- @@table = nil
70
+ @cmd_params = CmdParams.new
95
71
 
96
72
  initialize_actions()
97
73
  initialize_menus()
@@ -146,7 +122,7 @@ module Cosmos
146
122
  @send_raw_action.setEnabled(false)
147
123
  end
148
124
  @send_raw_action.statusTip = tip
149
- connect(@send_raw_action, SIGNAL('triggered()'), self, SLOT('file_send_raw()'))
125
+ @send_raw_action.connect(SIGNAL('triggered()')) { file_send_raw }
150
126
 
151
127
  # Mode menu actions
152
128
  @ignore_range = Qt::Action.new('&Ignore Range Checks', self)
@@ -162,14 +138,18 @@ module Cosmos
162
138
  @states_in_hex = Qt::Action.new('&Display State Values in Hex', self)
163
139
  @states_in_hex.statusTip = 'Display states values in hex instead of decimal'
164
140
  @states_in_hex.setCheckable(true)
165
- @states_in_hex.setChecked(false)
166
- connect(@states_in_hex, SIGNAL('toggled(bool)'), self, SLOT('menu_states_in_hex(bool)'))
141
+ @states_in_hex.setChecked(CmdParams.states_in_hex)
142
+ @states_in_hex.connect(SIGNAL('toggled(bool)')) do |checked|
143
+ @cmd_params.states_in_hex(checked)
144
+ end
167
145
 
168
146
  @show_ignored = Qt::Action.new('&Show Ignored Parameters', self)
169
147
  @show_ignored.statusTip = 'Show ignored parameters which are normally hidden'
170
148
  @show_ignored.setCheckable(true)
171
- @show_ignored.setChecked(false)
172
- connect(@show_ignored, SIGNAL('toggled(bool)'), self, SLOT('update_cmd_params(bool)'))
149
+ @show_ignored.setChecked(CmdParams.show_ignored)
150
+ @show_ignored.connect(SIGNAL('toggled(bool)')) do |checked|
151
+ update_cmd_params(checked)
152
+ end
173
153
 
174
154
  @cmd_raw = Qt::Action.new('Disable &Parameter Conversions', self)
175
155
  tip = 'Send the command without running write or state conversions'
@@ -243,20 +223,23 @@ module Cosmos
243
223
  # Set the target combobox selection
244
224
  @target_select = Qt::ComboBox.new
245
225
  @target_select.setMaxVisibleItems(6)
246
- connect(@target_select, SIGNAL('activated(const QString&)'), self, SLOT('target_changed(const QString&)'))
226
+ @target_select.connect(SIGNAL('activated(const QString&)')) do |target|
227
+ update_commands()
228
+ update_cmd_params()
229
+ end
247
230
  target_label = Qt::Label.new("&Target:")
248
231
  target_label.setBuddy(@target_select)
249
232
 
250
233
  # Set the comamnd combobox selection
251
234
  @cmd_select = Qt::ComboBox.new
252
235
  @cmd_select.setMaxVisibleItems(20)
253
- connect(@cmd_select, SIGNAL('activated(const QString&)'), self, SLOT('cmd_changed(const QString&)'))
236
+ @cmd_select.connect(SIGNAL('activated(const QString&)')) {|command| update_cmd_params }
254
237
  cmd_label = Qt::Label.new("&Command:")
255
238
  cmd_label.setBuddy(@cmd_select)
256
239
 
257
240
  # Button to send command
258
241
  send = Qt::PushButton.new("Send")
259
- connect(send, SIGNAL('clicked()'), self, SLOT('send_button()'))
242
+ send.connect(SIGNAL('clicked()')) { send_button }
260
243
 
261
244
  # Layout the top level selection
262
245
  select_layout = Qt::HBoxLayout.new
@@ -326,32 +309,6 @@ module Cosmos
326
309
  history
327
310
  end
328
311
 
329
- # Changes the display of items with states to hex if checked is true.
330
- # Otherwise state values are displayed as decimal.
331
- # @param checked [Boolean] Whether to display state values in hex
332
- def menu_states_in_hex(checked)
333
- @@param_widgets.each do |_, _, state_value_item|
334
- next unless state_value_item
335
- text = state_value_item.text
336
- quotes_removed = text.remove_quotes
337
- if text == quotes_removed
338
- if checked
339
- if text.is_int?
340
- @@table.blockSignals(true)
341
- state_value_item.text = sprintf("0x%X", text.to_i)
342
- @@table.blockSignals(false)
343
- end
344
- else
345
- if text.is_hex?
346
- @@table.blockSignals(true)
347
- state_value_item.text = Integer(text).to_s
348
- @@table.blockSignals(false)
349
- end
350
- end
351
- end
352
- end
353
- end
354
-
355
312
  # Opens a dialog which allows the user to select a file to read and send
356
313
  # directly over the interface.
357
314
  def file_send_raw
@@ -417,17 +374,6 @@ module Cosmos
417
374
  super(event)
418
375
  end
419
376
 
420
- # Updates the commands combobox and command parameters table
421
- def target_changed(_)
422
- update_commands()
423
- update_cmd_params()
424
- end
425
-
426
- # Updates the command parameters table
427
- def cmd_changed(_)
428
- update_cmd_params()
429
- end
430
-
431
377
  # Sends the current command and parameters to the target
432
378
  def send_button
433
379
  target_name = @target_select.text
@@ -470,26 +416,8 @@ module Cosmos
470
416
 
471
417
  # @return [String, Hash] Command as it would appear in a ScriptRunner script
472
418
  def view_as_script
473
- params = {}
474
-
475
- @@param_widgets.each do |packet_item, value_item, state_value_item|
476
- text = value_item.text
477
-
478
- text = state_value_item.text if state_value_item && (text == MANUALLY or @cmd_raw.checked?)
479
- quotes_removed = text.remove_quotes
480
- if text == quotes_removed
481
- if (packet_item.data_type == :STRING or packet_item.data_type == :BLOCK) and text.upcase.start_with?("0X")
482
- params[packet_item.name] = text.hex_to_byte_string
483
- else
484
- params[packet_item.name] = text.convert_to_value
485
- end
486
- else
487
- params[packet_item.name] = quotes_removed
488
- end
489
- raise "#{packet_item.name} is required." if quotes_removed == '' && packet_item.required
490
- end
491
419
  statusBar.clearMessage()
492
-
420
+ params = @cmd_params.params_text(@cmd_raw.checked?)
493
421
  output_string = System.commands.build_cmd_output_string(@target_select.text, @cmd_select.text, params, @cmd_raw.checked?)
494
422
  if output_string =~ /[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F-\xFF]/
495
423
  output_string = output_string.inspect.remove_quotes
@@ -552,22 +480,9 @@ module Cosmos
552
480
 
553
481
  # Updates the command parameters table based on the selected target and
554
482
  # packet comboboxes
555
- # @param ignored_toggle [Boolean] Whether to display the ignored
556
- # parameters. Pass nil (the default) to keep the existing setting.
557
- def update_cmd_params(ignored_toggle = nil)
558
- old_params = {}
559
- if !ignored_toggle.nil?
560
- # Save parameter values
561
- @@param_widgets.each do |packet_item, value_item, state_value_item|
562
- text = value_item.text
563
- if state_value_item
564
- old_params[packet_item.name] = [text, state_value_item.text]
565
- else
566
- old_params[packet_item.name] = text
567
- end
568
- end
569
- end
570
-
483
+ # @param checked [Boolean] Whether the show ignored parameters option
484
+ # is checked. Pass nil (the default) to keep the existing setting.
485
+ def update_cmd_params(checked = nil)
571
486
  # Clear Status Bar
572
487
  statusBar.showMessage("")
573
488
 
@@ -576,222 +491,11 @@ module Cosmos
576
491
  packet_name = @cmd_select.text
577
492
  if target_name && packet_name
578
493
  packet = System.commands.packet(target_name, packet_name)
579
- packet_items = packet.sorted_items
580
- shown_packet_items = []
581
- packet_items.each do |packet_item|
582
- next if target && target.ignored_parameters.include?(packet_item.name) && !@show_ignored.checked?
583
- shown_packet_items << packet_item
584
- end
585
-
586
- # Update Command Description
587
- @description.text = packet.description.to_s
588
-
589
- # Destroy the old table widget
590
- @@table.dispose if @@table
591
- @@table = nil
592
-
593
- # Update Parameters
594
- @@param_widgets = []
595
- drawn_header = false
596
-
597
- row = 0
598
- shown_packet_items.each do |packet_item|
599
- next if target && target.ignored_parameters.include?(packet_item.name) && !@show_ignored.checked?
600
- value_item = nil
601
- state_value_item = nil
602
-
603
- unless drawn_header
604
- @@table = Qt::TableWidget.new()
605
- @@table.setSizePolicy(Qt::SizePolicy::Expanding, Qt::SizePolicy::Expanding)
606
- @@table.setWordWrap(true)
607
- @@table.setRowCount(shown_packet_items.length)
608
- @@table.setColumnCount(5)
609
- @@table.setHorizontalHeaderLabels(['Name', ' Value or State ', ' ', 'Units', 'Description'])
610
- @@table.horizontalHeader.setStretchLastSection(true)
611
- @@table.verticalHeader.setVisible(false)
612
- @@table.setItemDelegate(CmdParamTableItemDelegate.new(@@table, @@param_widgets, @production))
613
- @@table.setContextMenuPolicy(Qt::CustomContextMenu)
614
- @@table.verticalHeader.setResizeMode(Qt::HeaderView::ResizeToContents)
615
- @@table.setEditTriggers(Qt::AbstractItemView::DoubleClicked | Qt::AbstractItemView::SelectedClicked | Qt::AbstractItemView::AnyKeyPressed)
616
- @@table.setSelectionMode(Qt::AbstractItemView::NoSelection)
617
- connect(@@table, SIGNAL('customContextMenuRequested(const QPoint&)'), self, SLOT('context_menu(const QPoint&)'))
618
- connect(@@table, SIGNAL('itemClicked(QTableWidgetItem*)'), self, SLOT('click_callback(QTableWidgetItem*)'))
619
- drawn_header = true
620
- end
621
-
622
- # Parameter Name
623
- item = Qt::TableWidgetItem.new("#{packet_item.name}:")
624
- item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
625
- item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled)
626
- @@table.setItem(row, 0, item)
627
-
628
- if packet_item.states
629
- default_state = packet_item.states.key(packet_item.default)
630
- if old_params[packet_item.name]
631
- value_item = Qt::TableWidgetItem.new(old_params[packet_item.name][0])
632
- else
633
- if default_state
634
- value_item = Qt::TableWidgetItem.new(default_state.to_s)
635
- elsif @production
636
- value_item = Qt::TableWidgetItem.new(packet_item.states.keys[0])
637
- else
638
- value_item = Qt::TableWidgetItem.new(MANUALLY)
639
- end
640
- end
641
- value_item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
642
- value_item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable)
643
- @@table.setItem(row, 1, value_item)
644
-
645
- if old_params[packet_item.name]
646
- state_value_item = Qt::TableWidgetItem.new(old_params[packet_item.name][1])
647
- else
648
- if @states_in_hex.checked? && packet_item.default.kind_of?(Integer)
649
- state_value_item = Qt::TableWidgetItem.new(sprintf("0x%X", packet_item.default))
650
- else
651
- default_str = packet_item.default.to_s
652
- if default_str.is_printable?
653
- state_value_item = Qt::TableWidgetItem.new(default_str)
654
- else
655
- state_value_item = Qt::TableWidgetItem.new("0x" + default_str.simple_formatted)
656
- end
657
- end
658
- end
659
- state_value_item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
660
- if @production
661
- state_value_item.setFlags(Qt::NoItemFlags)
662
- else
663
- state_value_item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable)
664
- end
665
- @@table.setItem(row, 2, state_value_item)
666
-
667
- # If the parameter is required clear the combobox and
668
- # clear the value field so they have to choose something
669
- if packet_item.required && !old_params[packet_item.name]
670
- value_item.setText('')
671
- state_value_item.setText('')
672
- end
673
- else
674
- # Parameter Value
675
- if old_params[packet_item.name]
676
- value_item = Qt::TableWidgetItem.new(old_params[packet_item.name])
677
- else
678
- if packet_item.required
679
- value_text = ''
680
- else
681
- if packet_item.format_string
682
- begin
683
- value_text = sprintf(packet_item.format_string, packet_item.default)
684
- rescue
685
- # Oh well - Don't use the format string
686
- value_text = packet_item.default.to_s
687
- end
688
- else
689
- value_text = packet_item.default.to_s
690
- end
691
- if !value_text.is_printable?
692
- value_text = "0x" + value_text.simple_formatted
693
- # Add quotes around STRING or BLOCK defaults so CmdSender interprets them correctly
694
- elsif (packet_item.data_type == :STRING or packet_item.data_type == :BLOCK)
695
- value_text = "'#{packet_item.default}'"
696
- end
697
- end
698
- value_item = Qt::TableWidgetItem.new(value_text)
699
- end
700
- value_item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
701
- value_item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable)
702
- @@table.setItem(row, 1, value_item)
703
- @@table.setSpan(row, 1, 1, 2)
704
- end
705
-
706
- # Units
707
- item = Qt::TableWidgetItem.new(packet_item.units.to_s)
708
- item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
709
- item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled)
710
- @@table.setItem(row, 3, item)
711
-
712
- # Description
713
- item = Qt::TableWidgetItem.new(packet_item.description.to_s)
714
- item.setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter)
715
- item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled)
716
- @@table.setItem(row, 4, item)
717
-
718
- @@param_widgets << [packet_item, value_item, state_value_item]
719
- row += 1
720
- end
721
-
722
- if @@table
723
- @@table.connect(SIGNAL('itemChanged(QTableWidgetItem*)')) do |item|
724
- packet_item, value_item, state_value_item = @@param_widgets[item.row]
725
- if item.column == 1
726
- if packet_item.states
727
- value = packet_item.states[value_item.text]
728
- @@table.blockSignals(true)
729
- if @states_in_hex.checked? && value.kind_of?(Integer)
730
- state_value_item.setText(sprintf("0x%X", value))
731
- else
732
- state_value_item.setText(value.to_s)
733
- end
734
- @@table.blockSignals(false)
735
- end
736
- elsif item.column == 2
737
- @@table.blockSignals(true)
738
- @@table.item(item.row, 1).setText(MANUALLY)
739
- @@table.blockSignals(false)
740
- end
741
- end
742
- @table_layout.addWidget(@@table, 500)
743
- @@table.resizeColumnsToContents()
744
- @@table.resizeRowsToContents()
745
- end
746
- end # if target_name && packet_name
747
- end
748
-
749
- # If the user right clicks over a table item, this method displays a context
750
- # menu with various options.
751
- # @param point [Qt::Point] Point to display the context menu
752
- def context_menu(point)
753
- target_name = @target_select.text
754
- packet_name = @cmd_select.text
755
- item = @@table.itemAt(point)
756
- if item
757
- item_name = @@table.item(item.row, 0).text[0..-2] # Remove :
758
- if target_name.length > 0 && packet_name.length > 0 && item_name.length > 0
759
- menu = Qt::Menu.new()
760
-
761
- details_action = Qt::Action.new("Details #{target_name} #{packet_name} #{item_name}", self)
762
- details_action.statusTip = "Popup details about #{target_name} #{packet_name} #{item_name}"
763
- details_action.connect(SIGNAL('triggered()')) do
764
- CmdDetailsDialog.new(nil, target_name, packet_name, item_name)
765
- end
766
- menu.addAction(details_action)
767
-
768
- file_chooser_action = Qt::Action.new("Insert Filename", self)
769
- file_chooser_action.statusTip = "Select a file and place its name into this parameter"
770
- file_chooser_action.connect(SIGNAL('triggered()')) do
771
- filename = Qt::FileDialog::getOpenFileName(self, "Insert Filename:", @file_dir, "All Files (*)")
772
- if filename && !filename.empty?
773
- @file_dir = File.dirname(filename)
774
- _, value_item, state_value_item = @@param_widgets[item.row]
775
- if state_value_item
776
- state_value_item.setText(filename)
777
- elsif value_item
778
- value_item.setText(filename)
779
- end
780
- end
781
- end
782
- menu.addAction(file_chooser_action)
783
-
784
- menu.exec(@@table.mapToGlobal(point))
785
- menu.dispose
786
- end
494
+ table = @cmd_params.update_cmd_params(packet, show_ignored: checked)
495
+ @table_layout.addWidget(table, 500) if table
787
496
  end
788
497
  end
789
498
 
790
- # @param item [Qt::TableWidgetItem] Item which was left clicked
791
- def click_callback(item)
792
- @@table.editItem(item) if (item.flags & Qt::ItemIsEditable) != 0
793
- end
794
-
795
499
  # (see QtTool.run)
796
500
  def self.run(option_parser = nil, options = nil)
797
501
  Cosmos.catch_fatal_exception do
@@ -135,17 +135,21 @@ module Cosmos
135
135
  @show_ignored = Qt::Action.new('&Show Ignored Parameters', self)
136
136
  @show_ignored.statusTip = 'Show ignored parameters which are normally hidden'
137
137
  @show_ignored.setCheckable(true)
138
- @show_ignored.setChecked(false)
139
- @show_ignored.connect(SIGNAL('toggled(bool)')) do |bool|
140
- @sequence_list.map {|item| item.show_ignored(bool) }
138
+ @show_ignored.setChecked(CmdParams.show_ignored)
139
+ @show_ignored.connect(SIGNAL('toggled(bool)')) do |checked|
140
+ # In case there aren't any sequences open, make sure to store the current value
141
+ CmdParams.show_ignored = checked
142
+ @sequence_list.map {|item| item.show_ignored(checked) }
141
143
  end
142
144
 
143
145
  @states_in_hex = Qt::Action.new('&Display State Values in Hex', self)
144
146
  @states_in_hex.statusTip = 'Display states values in hex instead of decimal'
145
147
  @states_in_hex.setCheckable(true)
146
- @states_in_hex.setChecked(false)
147
- @states_in_hex.connect(SIGNAL('toggled(bool)')) do |bool|
148
- @sequence_list.map {|item| item.states_in_hex(bool) }
148
+ @states_in_hex.setChecked(CmdParams.states_in_hex)
149
+ @states_in_hex.connect(SIGNAL('toggled(bool)')) do |checked|
150
+ # In case there aren't any sequences open, make sure to store the current value
151
+ CmdParams.states_in_hex = checked
152
+ @sequence_list.map {|item| item.states_in_hex(checked) }
149
153
  end
150
154
 
151
155
  @expand_action = Qt::Action.new('&Expand All', self)
@@ -226,9 +230,7 @@ module Cosmos
226
230
 
227
231
  @target_select = Qt::ComboBox.new
228
232
  @target_select.setMaxVisibleItems(6)
229
- @target_select.connect(SIGNAL('activated(const QString&)')) do |target|
230
- target_changed()
231
- end
233
+ @target_select.connect(SIGNAL('activated(const QString&)')) {|target| target_changed() }
232
234
  target_label = Qt::Label.new("&Target:")
233
235
  target_label.setBuddy(@target_select)
234
236
 
@@ -253,7 +255,7 @@ module Cosmos
253
255
  splitter = Qt::Splitter.new(Qt::Vertical, self)
254
256
  central_layout.addWidget(splitter)
255
257
 
256
- @sequence_list = SequenceList.new
258
+ @sequence_list = SequenceList.new(self)
257
259
  @sequence_list.connect(SIGNAL("modified()")) { update_title }
258
260
 
259
261
  @scroll = Qt::ScrollArea.new()
@@ -278,11 +280,7 @@ module Cosmos
278
280
  end
279
281
 
280
282
  def add_command
281
- command = System.commands.packet(@target_select.text, @cmd_select.text).dup
282
- command.restore_defaults
283
- item = @sequence_list.add(command)
284
- item.show_ignored(@show_ignored.isChecked())
285
- item.states_in_hex(@states_in_hex.isChecked())
283
+ item = @sequence_list.add(@target_select.text.strip, @cmd_select.text.strip)
286
284
  end
287
285
 
288
286
  # Export the sequence list into a custom binary format
@@ -300,6 +298,7 @@ module Cosmos
300
298
  return unless prompt_for_save_if_needed()
301
299
  @sequence_list.clear
302
300
  @filename = "Untitled"
301
+ update_title()
303
302
  end
304
303
 
305
304
  # Opens a sequence list file and populates the GUI
@@ -314,8 +313,6 @@ module Cosmos
314
313
  if !filename.nil? && File.exist?(filename) && !File.directory?(filename)
315
314
  # Try to open and load the file. Errors are handled here.
316
315
  @sequence_list.open(filename)
317
- @sequence_list.map {|item| item.show_ignored(@show_ignored.isChecked()) }
318
- @sequence_list.map {|item| item.states_in_hex(@states_in_hex.isChecked()) }
319
316
  @filename = filename
320
317
  @sequence_dir = File.dirname(filename)
321
318
  @sequence_dir << '/' if @sequence_dir[-1..-1] != '/' and @sequence_dir[-1..-1] != '\\'