cosmos 3.8.2 → 3.8.3
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.
- checksums.yaml +4 -4
- data/Manifest.txt +5 -5
- data/Rakefile +8 -2
- data/autohotkey/tools/autohotkey.rb +3 -3
- data/data/crc.txt +27 -27
- data/demo/Launcher.bat +3 -3
- data/demo/config/data/crc.txt +27 -27
- data/demo/{procedures → config/targets/INST/procedures}/checks.rb +0 -0
- data/demo/{procedures → config/targets/INST/procedures}/collect.rb +2 -2
- data/demo/{procedures → config/targets/INST/procedures}/disconnect.rb +0 -0
- data/demo/{procedures/clear_util.rb → config/targets/INST/procedures/utilities/clear.rb} +0 -0
- data/demo/{procedures/collect_util.rb → config/targets/INST/procedures/utilities/collect.rb} +2 -2
- data/demo/config/targets/INST/screens/commanding.txt +3 -3
- data/demo/config/tools/table_manager/ExampleTableDefinition.txt +7 -7
- data/demo/procedures/plot_test.rb +1 -1
- data/demo/tools/CmdExtractor.bat +3 -3
- data/demo/tools/CmdSender.bat +3 -3
- data/demo/tools/CmdTlmServer.bat +3 -3
- data/demo/tools/DataViewer.bat +3 -3
- data/demo/tools/ExampleTarget.bat +3 -3
- data/demo/tools/HandbookCreator.bat +3 -3
- data/demo/tools/Launcher.bat +3 -3
- data/demo/tools/LimitsMonitor.bat +3 -3
- data/demo/tools/OpenGLBuilder.bat +3 -3
- data/demo/tools/PacketViewer.bat +3 -3
- data/demo/tools/Replay.bat +3 -3
- data/demo/tools/ScpiTarget.bat +3 -3
- data/demo/tools/ScriptRunner.bat +3 -3
- data/demo/tools/TableManager.bat +3 -3
- data/demo/tools/TestRunner.bat +3 -3
- data/demo/tools/TlmExtractor.bat +3 -3
- data/demo/tools/TlmGrapher.bat +3 -3
- data/demo/tools/TlmViewer.bat +3 -3
- data/demo/tools/ToolLaunch.bat +3 -6
- data/ext/cosmos/ext/packet/packet.c +10 -0
- data/install/config/data/crc.txt +17 -17
- data/install/tools/CmdExtractor.bat +3 -3
- data/install/tools/CmdSender.bat +3 -3
- data/install/tools/CmdTlmServer.bat +3 -3
- data/install/tools/DataViewer.bat +3 -3
- data/install/tools/HandbookCreator.bat +3 -3
- data/install/tools/Launcher.bat +3 -3
- data/install/tools/LimitsMonitor.bat +3 -3
- data/install/tools/OpenGLBuilder.bat +3 -3
- data/install/tools/PacketViewer.bat +3 -3
- data/install/tools/Replay.bat +3 -3
- data/install/tools/ScriptRunner.bat +3 -3
- data/install/tools/TableManager.bat +3 -3
- data/install/tools/TestRunner.bat +3 -3
- data/install/tools/TlmExtractor.bat +3 -3
- data/install/tools/TlmGrapher.bat +3 -3
- data/install/tools/TlmViewer.bat +3 -3
- data/install/tools/ToolLaunch.bat +3 -6
- data/lib/cosmos/config/config_parser.rb +10 -2
- data/lib/cosmos/gui/qt_tool.rb +6 -0
- data/lib/cosmos/gui/utilities/screenshot.rb +8 -0
- data/lib/cosmos/gui/utilities/script_module_gui.rb +37 -11
- data/lib/cosmos/interfaces/cmd_tlm_server_interface.rb +3 -3
- data/lib/cosmos/interfaces/udp_interface.rb +9 -2
- data/lib/cosmos/packet_logs/packet_log_reader.rb +1 -0
- data/lib/cosmos/packets/commands.rb +70 -74
- data/lib/cosmos/packets/packet.rb +14 -7
- data/lib/cosmos/script/scripting.rb +9 -7
- data/lib/cosmos/system/system.rb +4 -0
- data/lib/cosmos/system/target.rb +2 -0
- data/lib/cosmos/tools/cmd_tlm_server/api.rb +10 -10
- data/lib/cosmos/tools/cmd_tlm_server/gui/interfaces_tab.rb +2 -2
- data/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb +1 -1
- data/lib/cosmos/tools/packet_viewer/packet_viewer.rb +5 -15
- data/lib/cosmos/tools/script_runner/script_runner.rb +40 -21
- data/lib/cosmos/tools/table_manager/table.rb +2 -2
- data/lib/cosmos/tools/table_manager/table_config.rb +18 -10
- data/lib/cosmos/tools/table_manager/table_manager.rb +61 -59
- data/lib/cosmos/tools/table_manager/table_manager_core.rb +24 -56
- data/lib/cosmos/tools/test_runner/test_runner.rb +15 -10
- data/lib/cosmos/tools/tlm_viewer/widgets/checkbutton_widget.rb +9 -2
- data/lib/cosmos/tools/tlm_viewer/widgets/combobox_widget.rb +1 -1
- data/lib/cosmos/tools/tlm_viewer/widgets/radiobutton_widget.rb +9 -1
- data/lib/cosmos/top_level.rb +5 -5
- data/lib/cosmos/version.rb +4 -4
- data/spec/config/config_parser_spec.rb +40 -2
- data/spec/packet_logs/packet_log_reader_spec.rb +66 -2
- data/spec/packets/packet_spec.rb +27 -0
- data/spec/script/scripting_spec.rb +7 -2
- data/spec/spec_helper.rb +4 -5
- data/spec/system/system_spec.rb +18 -0
- metadata +7 -7
@@ -122,6 +122,11 @@ module Cosmos
|
|
122
122
|
def set_received_time_fast(received_time)
|
123
123
|
@received_time = received_time
|
124
124
|
@received_time.freeze if @received_time
|
125
|
+
if @read_conversion_cache
|
126
|
+
synchronize() do
|
127
|
+
@read_conversion_cache.clear
|
128
|
+
end
|
129
|
+
end
|
125
130
|
end
|
126
131
|
|
127
132
|
# Sets the received count of the packet
|
@@ -440,11 +445,6 @@ module Cosmos
|
|
440
445
|
# @param value_type (see #read_item)
|
441
446
|
# @param buffer (see Structure#write_item)
|
442
447
|
def write_item(item, value, value_type = :CONVERTED, buffer = @buffer)
|
443
|
-
if @read_conversion_cache
|
444
|
-
synchronize() do
|
445
|
-
@read_conversion_cache.clear
|
446
|
-
end
|
447
|
-
end
|
448
448
|
case value_type
|
449
449
|
when :RAW
|
450
450
|
super(item, value, value_type, buffer)
|
@@ -473,6 +473,11 @@ module Cosmos
|
|
473
473
|
else
|
474
474
|
raise ArgumentError, "Unknown value type on write: #{value_type}"
|
475
475
|
end
|
476
|
+
if @read_conversion_cache
|
477
|
+
synchronize() do
|
478
|
+
@read_conversion_cache.clear
|
479
|
+
end
|
480
|
+
end
|
476
481
|
end
|
477
482
|
|
478
483
|
# Read an item in the packet by name
|
@@ -551,9 +556,11 @@ module Cosmos
|
|
551
556
|
# Restore all items in the packet to their default value
|
552
557
|
#
|
553
558
|
# @param buffer [String] Raw buffer of binary data
|
554
|
-
|
559
|
+
# @param skip_items_names [Array] Array of item names to skip
|
560
|
+
def restore_defaults(buffer = @buffer, skip_item_names = nil)
|
561
|
+
upcase_skip_item_names = skip_item_names.map(&:upcase) if skip_item_names
|
555
562
|
@sorted_items.each do |item|
|
556
|
-
write_item(item, item.default, :CONVERTED, buffer)
|
563
|
+
write_item(item, item.default, :CONVERTED, buffer) unless (skip_item_names and upcase_skip_item_names.include?(item.name))
|
557
564
|
end
|
558
565
|
end
|
559
566
|
|
@@ -23,9 +23,11 @@ module Cosmos
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def status_bar(message)
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
if defined? ScriptRunner
|
27
|
+
script_runner = nil
|
28
|
+
ObjectSpace.each_object {|object| if ScriptRunner === object then script_runner = object; break; end}
|
29
|
+
script_runner.script_set_status(message) if script_runner
|
30
|
+
end
|
29
31
|
end
|
30
32
|
|
31
33
|
def ask_string(question, blank_or_default = false, password = false)
|
@@ -553,21 +555,21 @@ module Cosmos
|
|
553
555
|
|
554
556
|
# Require an additional ruby file
|
555
557
|
def load_utility(procedure_name)
|
556
|
-
|
558
|
+
not_cached = false
|
557
559
|
if defined? ScriptRunnerFrame and ScriptRunnerFrame.instance
|
558
560
|
saved = ScriptRunnerFrame.instance.use_instrumentation
|
559
561
|
begin
|
560
562
|
ScriptRunnerFrame.instance.use_instrumentation = false
|
561
|
-
|
563
|
+
not_cached = start(procedure_name)
|
562
564
|
ensure
|
563
565
|
ScriptRunnerFrame.instance.use_instrumentation = saved
|
564
566
|
end
|
565
567
|
else # Just call start
|
566
|
-
|
568
|
+
not_cached = start(procedure_name)
|
567
569
|
end
|
568
570
|
# Return whether we had to load and instrument this file, i.e. it was not cached
|
569
571
|
# This is designed to match the behavior of Ruby's require and load keywords
|
570
|
-
|
572
|
+
not_cached
|
571
573
|
end
|
572
574
|
alias require_utility load_utility
|
573
575
|
|
data/lib/cosmos/system/system.rb
CHANGED
@@ -367,6 +367,10 @@ module Cosmos
|
|
367
367
|
dirs.each do |dir_filename|
|
368
368
|
if dir_filename[0] != '.'
|
369
369
|
if dir_filename == dir_filename.upcase
|
370
|
+
# If any of the targets original directory name matches the
|
371
|
+
# current directory then it must have been already processed by
|
372
|
+
# DECLARE_TARGET so we skip it.
|
373
|
+
next if @targets.select {|name, target| target.original_name == dir_filename }.length > 0
|
370
374
|
if dir_filename == 'SYSTEM'
|
371
375
|
system_found = true
|
372
376
|
next
|
data/lib/cosmos/system/target.rb
CHANGED
@@ -168,6 +168,8 @@ module Cosmos
|
|
168
168
|
end
|
169
169
|
lib_dir = File.join(dir, 'lib')
|
170
170
|
Cosmos.add_to_search_path(lib_dir, false) if File.exist?(lib_dir)
|
171
|
+
proc_dir = File.join(dir, 'procedures')
|
172
|
+
Cosmos.add_to_search_path(proc_dir, false) if File.exist?(proc_dir)
|
171
173
|
dir
|
172
174
|
end
|
173
175
|
|
@@ -500,7 +500,7 @@ module Cosmos
|
|
500
500
|
def get_tlm_buffer(target_name, packet_name)
|
501
501
|
packet = System.telemetry.packet(target_name, packet_name)
|
502
502
|
return packet.buffer
|
503
|
-
end
|
503
|
+
end
|
504
504
|
|
505
505
|
# Returns all the values (along with their limits state) for a packet.
|
506
506
|
#
|
@@ -977,8 +977,16 @@ module Cosmos
|
|
977
977
|
raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{method_name}()"
|
978
978
|
end
|
979
979
|
|
980
|
+
# Build the command
|
981
|
+
begin
|
982
|
+
command = System.commands.build_cmd(target_name, cmd_name, cmd_params, range_check, raw)
|
983
|
+
rescue => e
|
984
|
+
Logger.error e.message
|
985
|
+
raise e
|
986
|
+
end
|
987
|
+
|
980
988
|
if hazardous_check
|
981
|
-
hazardous, hazardous_description = System.commands.
|
989
|
+
hazardous, hazardous_description = System.commands.cmd_pkt_hazardous?(command)
|
982
990
|
if hazardous
|
983
991
|
error = HazardousError.new
|
984
992
|
error.target_name = target_name
|
@@ -989,14 +997,6 @@ module Cosmos
|
|
989
997
|
end
|
990
998
|
end
|
991
999
|
|
992
|
-
# Build the command
|
993
|
-
begin
|
994
|
-
command = System.commands.build_cmd(target_name, cmd_name, cmd_params, range_check, raw)
|
995
|
-
rescue Exception => e
|
996
|
-
Logger.error e.message
|
997
|
-
raise e
|
998
|
-
end
|
999
|
-
|
1000
1000
|
# Send the command
|
1001
1001
|
@disconnect = false unless defined? @disconnect
|
1002
1002
|
CmdTlmServer.commanding.send_command_to_target(target_name, command) unless @disconnect
|
@@ -154,7 +154,7 @@ module Cosmos
|
|
154
154
|
button = Qt::PushButton.new(button_text)
|
155
155
|
if name == ROUTERS
|
156
156
|
button.connect(SIGNAL('clicked()')) do
|
157
|
-
if
|
157
|
+
if CmdTlmServer.routers.all[interface_name].thread
|
158
158
|
Logger.info "User disconnecting router #{interface_name}"
|
159
159
|
CmdTlmServer.instance.disconnect_router(interface_name)
|
160
160
|
else
|
@@ -164,7 +164,7 @@ module Cosmos
|
|
164
164
|
end
|
165
165
|
else
|
166
166
|
button.connect(SIGNAL('clicked()')) do
|
167
|
-
if
|
167
|
+
if CmdTlmServer.interfaces.all[interface_name].thread
|
168
168
|
Logger.info "User disconnecting interface #{interface_name}"
|
169
169
|
CmdTlmServer.instance.disconnect_interface(interface_name)
|
170
170
|
else
|
@@ -222,7 +222,7 @@ module Cosmos
|
|
222
222
|
if err
|
223
223
|
Logger.info "Connection Lost for #{@interface.name}: #{err.formatted(false, false)}"
|
224
224
|
case err
|
225
|
-
when Errno::ECONNABORTED, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EBADF, IOError
|
225
|
+
when Errno::ECONNABORTED, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EBADF, Errno::ENOTSOCK, IOError
|
226
226
|
# Do not write an exception file for these extremely common cases
|
227
227
|
else
|
228
228
|
Logger.error err.formatted
|
@@ -125,8 +125,6 @@ module Cosmos
|
|
125
125
|
@derived_last_action.connect(SIGNAL('triggered()')) { update_tlm_items() }
|
126
126
|
|
127
127
|
@formatted_tlm_units_action = Qt::Action.new(tr('Formatted Telemetry With &Units'), self)
|
128
|
-
@formatted_tlm_units_keyseq = Qt::KeySequence.new(tr('Ctrl+U'))
|
129
|
-
@formatted_tlm_units_action.shortcut = @formatted_tlm_units_keyseq
|
130
128
|
@formatted_tlm_units_action.statusTip = tr('Formatted Telemetry with Units')
|
131
129
|
@formatted_tlm_units_action.setCheckable(true)
|
132
130
|
@formatted_tlm_units_action.setChecked(true)
|
@@ -136,8 +134,6 @@ module Cosmos
|
|
136
134
|
end
|
137
135
|
|
138
136
|
@formatted_tlm_action = Qt::Action.new(tr('&Formatted Telemetry'), self)
|
139
|
-
@formatted_tlm_keyseq = Qt::KeySequence.new(tr('Ctrl+F'))
|
140
|
-
@formatted_tlm_action.shortcut = @formatted_tlm_keyseq
|
141
137
|
@formatted_tlm_action.statusTip = tr('Formatted Telemetry')
|
142
138
|
@formatted_tlm_action.setCheckable(true)
|
143
139
|
@formatted_tlm_action.connect(SIGNAL('triggered()')) do
|
@@ -146,8 +142,6 @@ module Cosmos
|
|
146
142
|
end
|
147
143
|
|
148
144
|
@normal_tlm_action = Qt::Action.new(tr('Normal &Converted Telemetry'), self)
|
149
|
-
@normal_tlm_keyseq = Qt::KeySequence.new(tr('Ctrl+C'))
|
150
|
-
@normal_tlm_action.shortcut = @normal_tlm_keyseq
|
151
145
|
@normal_tlm_action.statusTip = tr('Normal Converted Telemetry')
|
152
146
|
@normal_tlm_action.setCheckable(true)
|
153
147
|
@normal_tlm_action.connect(SIGNAL('triggered()')) do
|
@@ -156,8 +150,6 @@ module Cosmos
|
|
156
150
|
end
|
157
151
|
|
158
152
|
@raw_tlm_action = Qt::Action.new(tr('&Raw Telemetry'), self)
|
159
|
-
@raw_tlm_keyseq = Qt::KeySequence.new(tr('Ctrl+A'))
|
160
|
-
@raw_tlm_action.shortcut = @raw_tlm_keyseq
|
161
153
|
@raw_tlm_action.statusTip = tr('Raw Unprocessed Telemetry')
|
162
154
|
@raw_tlm_action.setCheckable(true)
|
163
155
|
@raw_tlm_action.connect(SIGNAL('triggered()')) do
|
@@ -319,9 +311,6 @@ module Cosmos
|
|
319
311
|
return
|
320
312
|
end
|
321
313
|
|
322
|
-
# Clear Status Bar
|
323
|
-
statusBar.clearMessage()
|
324
|
-
|
325
314
|
# Update Telemetry Description
|
326
315
|
@description.text = ""
|
327
316
|
@packets.each do |name, description|
|
@@ -351,7 +340,7 @@ module Cosmos
|
|
351
340
|
@derived_row += 1
|
352
341
|
end
|
353
342
|
end
|
354
|
-
|
343
|
+
tlm_items.concat(derived) # Tack the derived onto the end
|
355
344
|
else
|
356
345
|
System.telemetry.items(target_name, packet_name).each do |item|
|
357
346
|
tlm_items << [item.name, item.states, item.description]
|
@@ -411,15 +400,16 @@ module Cosmos
|
|
411
400
|
|
412
401
|
begin
|
413
402
|
tlm_items = get_tlm_packet(target_name || '', packet_name || '', @mode)
|
414
|
-
rescue DRb::DRbConnError =>
|
403
|
+
rescue DRb::DRbConnError => error
|
415
404
|
Qt.execute_in_main_thread(true) do
|
416
405
|
statusBar.showMessage(tr("Error Connecting to Command and Telemetry Server"))
|
417
406
|
end
|
418
407
|
tlm_items = nil
|
419
408
|
update_needed = false
|
420
|
-
rescue RuntimeError =>
|
409
|
+
rescue RuntimeError => error
|
421
410
|
Qt.execute_in_main_thread(true) do
|
422
|
-
|
411
|
+
Cosmos.handle_critical_exception(error)
|
412
|
+
statusBar.showMessage(tr("Packet #{target_name} #{packet_name} Error: #{error}"))
|
423
413
|
end
|
424
414
|
tlm_items = nil
|
425
415
|
update_needed = true
|
@@ -79,12 +79,6 @@ module Cosmos
|
|
79
79
|
@file_new.statusTip = tr('Start a new script')
|
80
80
|
@file_new.connect(SIGNAL('triggered()')) { file_new() }
|
81
81
|
|
82
|
-
@file_open = Qt::Action.new(Cosmos.get_icon('open.png'), tr('&Open'), self)
|
83
|
-
@file_open_keyseq = Qt::KeySequence.new(tr('Ctrl+O'))
|
84
|
-
@file_open.shortcut = @file_open_keyseq
|
85
|
-
@file_open.statusTip = tr('Open a script')
|
86
|
-
@file_open.connect(SIGNAL('triggered()')) { file_open() }
|
87
|
-
|
88
82
|
@file_close = Qt::Action.new(tr('&Close'), self)
|
89
83
|
@file_close_keyseq = Qt::KeySequence.new(tr('Ctrl+W'))
|
90
84
|
@file_close.shortcut = @file_close_keyseq
|
@@ -249,18 +243,43 @@ module Cosmos
|
|
249
243
|
|
250
244
|
def initialize_menus
|
251
245
|
# File Menu
|
252
|
-
file_menu = menuBar.addMenu(tr('&File'))
|
253
|
-
file_menu.addAction(@file_new)
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
file_menu.
|
261
|
-
|
262
|
-
|
263
|
-
|
246
|
+
@file_menu = menuBar.addMenu(tr('&File'))
|
247
|
+
@file_menu.addAction(@file_new)
|
248
|
+
|
249
|
+
open_action = Qt::Action.new(self)
|
250
|
+
open_action.shortcut = Qt::KeySequence.new(tr('Ctrl+O'))
|
251
|
+
open_action.connect(SIGNAL('triggered()')) { file_open(@procedure_dir) }
|
252
|
+
self.addAction(open_action)
|
253
|
+
|
254
|
+
@file_open = @file_menu.addMenu(tr('&Open'))
|
255
|
+
@file_open.setIcon(Cosmos.get_icon('open.png'))
|
256
|
+
System.paths['PROCEDURES'].each do |path|
|
257
|
+
next unless File.exist? path
|
258
|
+
path_context = path.split('/')[-2..-1].join('/')
|
259
|
+
action = Qt::Action.new(tr(path_context), self)
|
260
|
+
action.statusTip = "Open #{path}"
|
261
|
+
action.connect(SIGNAL('triggered()')) { file_open(path) }
|
262
|
+
@file_open.addAction(action)
|
263
|
+
end
|
264
|
+
@file_open.addSeparator()
|
265
|
+
System.targets.each do |target_name, target|
|
266
|
+
proc_dir = File.join(target.dir, 'procedures')
|
267
|
+
next unless File.exist? proc_dir
|
268
|
+
action = Qt::Action.new(tr("#{target_name}/procedures"), self)
|
269
|
+
action.statusTip = "Open #{proc_dir}"
|
270
|
+
action.connect(SIGNAL('triggered()')) { file_open(File.join(target.dir, 'procedures')) }
|
271
|
+
@file_open.addAction(action)
|
272
|
+
end
|
273
|
+
|
274
|
+
@file_menu.addAction(@file_close)
|
275
|
+
@file_menu.addAction(@file_reload)
|
276
|
+
@file_menu.addSeparator()
|
277
|
+
@file_menu.addAction(@file_save)
|
278
|
+
@file_menu.addAction(@file_save_as)
|
279
|
+
@file_menu.addSeparator()
|
280
|
+
@file_menu.addAction(@file_options)
|
281
|
+
@file_menu.addSeparator()
|
282
|
+
@file_menu.addAction(@exit_action)
|
264
283
|
|
265
284
|
# Edit Menu
|
266
285
|
mode_menu = menuBar.addMenu(tr('&Edit'))
|
@@ -366,8 +385,8 @@ module Cosmos
|
|
366
385
|
|
367
386
|
# File->Open
|
368
387
|
def file_open(filename = nil)
|
369
|
-
if
|
370
|
-
filename = Qt::FileDialog.getOpenFileName(self, "Select Script",
|
388
|
+
if File.directory?(filename)
|
389
|
+
filename = Qt::FileDialog.getOpenFileName(self, "Select Script", filename)
|
371
390
|
end
|
372
391
|
unless filename.nil? || filename.empty?
|
373
392
|
# If the user opens a file we already have open
|
@@ -905,7 +924,7 @@ module Cosmos
|
|
905
924
|
option_parser, options = create_default_options()
|
906
925
|
options.width = 750
|
907
926
|
options.height = 600
|
908
|
-
options.title = "Script Runner :
|
927
|
+
options.title = "Script Runner : Untitled"
|
909
928
|
options.auto_size = false
|
910
929
|
options.config_file = "script_runner.txt"
|
911
930
|
options.server_config_file = CmdTlmServer::DEFAULT_CONFIG_FILE
|
@@ -37,9 +37,9 @@ module Cosmos
|
|
37
37
|
|
38
38
|
# Calls define_item in Packet but also incrememts @num_columns
|
39
39
|
# if this table is a REPEATING table.
|
40
|
-
def create_param(name, bit_offset, bit_size, type, description, range, default, display_type, editable)
|
40
|
+
def create_param(name, bit_offset, bit_size, type, description, range, default, display_type, editable, endianness)
|
41
41
|
@num_columns += 1 if @type == :TWO_DIMENSIONAL
|
42
|
-
item = define_item(name, bit_offset, bit_size, type)
|
42
|
+
item = define_item(name, bit_offset, bit_size, type, nil, endianness)
|
43
43
|
item.description = description
|
44
44
|
item.range = range
|
45
45
|
item.default = default
|
@@ -115,8 +115,8 @@ module Cosmos
|
|
115
115
|
end
|
116
116
|
|
117
117
|
when 'PARAMETER'
|
118
|
-
usage = "PARAMETER <Parameter Name> <Parameter Description> <Data Type> <Bit Size> <Display Type> <Minimum Value> <Maximum Value> <Default Value
|
119
|
-
parser.verify_num_parameters(
|
118
|
+
usage = "PARAMETER <Parameter Name> <Parameter Description> <Data Type> <Bit Size> <Display Type> <Minimum Value> <Maximum Value> <Default Value (Only in ONE_DIMENTIONAL)> <ENDIANNESS (Optional)>"
|
119
|
+
parser.verify_num_parameters(6, 9, usage)
|
120
120
|
finish_parameter()
|
121
121
|
if @current_table
|
122
122
|
@current_table.num_rows += 1
|
@@ -134,21 +134,29 @@ module Cosmos
|
|
134
134
|
type = read_item_type(parameters[2])
|
135
135
|
bit_size = parameters[3].to_i
|
136
136
|
display_type, editable = read_display_type(parameters[4], type)
|
137
|
-
if type == :BLOCK
|
137
|
+
if type == :STRING || type == :BLOCK
|
138
138
|
range = nil
|
139
|
-
elsif type == :STRING
|
140
|
-
range = convert_to_range(parameters[5], parameters[6], :UINT, 0)
|
141
139
|
else
|
142
140
|
range = convert_to_range(parameters[5], parameters[6], type, bit_size)
|
143
141
|
end
|
144
142
|
if @current_table.type == :ONE_DIMENSIONAL
|
145
|
-
|
143
|
+
if type == :STRING || type == :BLOCK
|
144
|
+
default = convert_to_type(parameters[5], type)
|
145
|
+
else
|
146
|
+
default = convert_to_type(parameters[7], type)
|
147
|
+
end
|
146
148
|
else # TWO_DIMENSIONAL defaults are set by the DEFAULT keyword
|
147
149
|
default = 0
|
148
150
|
end
|
149
151
|
|
150
|
-
|
151
|
-
|
152
|
+
endianness = parameters[-1].to_s.upcase.intern
|
153
|
+
if endianness != :BIG_ENDIAN && endianness != :LITTLE_ENDIAN
|
154
|
+
endianness = @current_table.default_endianness
|
155
|
+
end
|
156
|
+
|
157
|
+
@current_parameter = @current_table.create_param(
|
158
|
+
name, @cur_bit_offset, bit_size, type, description,
|
159
|
+
range, default, display_type, editable, endianness)
|
152
160
|
@cur_bit_offset += parameters[3].to_i
|
153
161
|
rescue ArgumentError => err
|
154
162
|
raise parser.error("#{err.message} with #{keyword}.\nUSAGE: #{usage}")
|
@@ -664,8 +672,8 @@ module Cosmos
|
|
664
672
|
# backwards and that the minimum and maximum values make sense for the given
|
665
673
|
# type and bit_size. For example, a maximum of 256 doesn't make sense for a UINT8.
|
666
674
|
def convert_to_range(min, max, type, bit_size)
|
667
|
-
min =
|
668
|
-
max =
|
675
|
+
min = ConfigParser.handle_defined_constants(min.convert_to_value, type, bit_size)
|
676
|
+
max = ConfigParser.handle_defined_constants(max.convert_to_value, type, bit_size)
|
669
677
|
range = min..max
|
670
678
|
|
671
679
|
# First check for backwards ranges
|
@@ -463,7 +463,7 @@ module Cosmos
|
|
463
463
|
title = @currently_displayed_table_name
|
464
464
|
end
|
465
465
|
dialog.set_title_and_text("#{title} Hex Dump", str)
|
466
|
-
dialog.set_size(
|
466
|
+
dialog.set_size(650, 400)
|
467
467
|
dialog.exec
|
468
468
|
dialog.dispose
|
469
469
|
rescue => err
|
@@ -804,6 +804,10 @@ module Cosmos
|
|
804
804
|
|
805
805
|
when :STATE
|
806
806
|
x = item_def.states[gui_table.item(r,c).text]
|
807
|
+
|
808
|
+
when :STRING, :NONE
|
809
|
+
x = gui_table.item(r,c).text
|
810
|
+
|
807
811
|
end
|
808
812
|
|
809
813
|
# If there is a read conversion we first read the converted value before writing.
|
@@ -820,9 +824,7 @@ module Cosmos
|
|
820
824
|
# in this case force the range check to fail
|
821
825
|
rescue => error
|
822
826
|
text = gui_table.item(r,c).text
|
823
|
-
result << "Error saving #{item_def.name} value of #{text} due to #{error.message}.\
|
824
|
-
table.write(item_def.name, item_def.default)
|
825
|
-
update_gui_item(name, table, item_def, r, c)
|
827
|
+
result << "Error saving #{item_def.name} value of '#{text}' due to #{error.message}.\nDefault value is '#{item_def.default}'\n"
|
826
828
|
end
|
827
829
|
end # end each table column
|
828
830
|
end # end each table row
|
@@ -889,64 +891,64 @@ module Cosmos
|
|
889
891
|
gui_table = @gui_tables[table_name]
|
890
892
|
|
891
893
|
case item_def.display_type
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
894
|
+
when :STATE
|
895
|
+
item = Qt::TableWidgetItem.new
|
896
|
+
item.setData(Qt::DisplayRole, Qt::Variant.new(table_def.read(item_def.name)))
|
897
|
+
gui_table.setItem(table_row, table_column, item)
|
898
|
+
if item_def.editable
|
899
|
+
gui_table.item(table_row, table_column).setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable)
|
900
|
+
else
|
901
|
+
gui_table.item(table_row, table_column).setFlags(Qt::NoItemFlags)
|
902
|
+
end
|
901
903
|
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
904
|
+
when :CHECK
|
905
|
+
gui_table.setItem(table_row, table_column, Qt::TableWidgetItem.new(table_def.read(item_def.name)))
|
906
|
+
# the ItemData will be 0 for unchecked (corresponds with min value),
|
907
|
+
# and 1 for checked (corresponds with max value)
|
908
|
+
if table_def.read(item_def.name) == item_def.range.begin
|
909
|
+
gui_table.item(table_row, table_column).setCheckState(Qt::Unchecked)
|
910
|
+
else
|
911
|
+
gui_table.item(table_row, table_column).setCheckState(Qt::Checked)
|
912
|
+
end
|
913
|
+
if item_def.editable
|
914
|
+
gui_table.item(table_row, table_column).setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable)
|
915
|
+
else
|
916
|
+
gui_table.item(table_row, table_column).setFlags(Qt::NoItemFlags)
|
917
|
+
end
|
916
918
|
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
919
|
+
when :STRING, :NONE, :DEC
|
920
|
+
gui_table.setItem(table_row, table_column, Qt::TableWidgetItem.new(tr(table_def.read(item_def.name).to_s)))
|
921
|
+
if item_def.editable
|
922
|
+
gui_table.item(table_row, table_column).setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled)
|
923
|
+
else
|
924
|
+
gui_table.item(table_row, table_column).setFlags(Qt::NoItemFlags)
|
925
|
+
end
|
924
926
|
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
927
|
+
when :HEX
|
928
|
+
case item_def.bit_size
|
929
|
+
when 8
|
930
|
+
x = sprintf("%02X", table_def.read(item_def.name).to_s)
|
931
|
+
# if the number was negative x will have .. and possibly another
|
932
|
+
# F in the string which we remove by taking the last 4 digits
|
933
|
+
x = /\w{2}$/.match(x)[0]
|
934
|
+
when 16
|
935
|
+
x = sprintf("%04X", table_def.read(item_def.name).to_s)
|
936
|
+
# if the number was negative x will have .. and possibly another
|
937
|
+
# F in the string which we remove by taking the last 4 digits
|
938
|
+
x = /\w{4}$/.match(x)[0]
|
939
|
+
else
|
940
|
+
x = sprintf("%08X", table_def.read(item_def.name).to_s)
|
941
|
+
# if the number was negative x will have .. and possibly another
|
942
|
+
# F in the string which we remove by taking the last 8 digits
|
943
|
+
x = /\w{8}$/.match(x)[0]
|
944
|
+
end
|
945
|
+
x = Integer("0x#{x}") # convert to Integer
|
946
|
+
gui_table.setItem(table_row, table_column, Qt::TableWidgetItem.new(tr("0x%X" % x)))
|
947
|
+
if item_def.editable
|
948
|
+
gui_table.item(table_row, table_column).setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled)
|
949
|
+
else
|
950
|
+
gui_table.item(table_row, table_column).setFlags(Qt::NoItemFlags)
|
951
|
+
end
|
950
952
|
end
|
951
953
|
end
|
952
954
|
|