cosmos 4.4.0-java → 4.5.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.
- checksums.yaml +4 -4
- data/.dockerignore +2 -0
- data/.gitignore +1 -0
- data/.travis.yml +6 -6
- data/Dockerfile +70 -0
- data/Manifest.txt +37 -2
- data/README.md +9 -0
- data/Rakefile +55 -5
- data/appveyor.yml +18 -8
- data/autohotkey/config/tools/cmd_sequence/cmd_sequence.txt +2 -0
- data/autohotkey/lib/cmd_sequence_exporter.rb +52 -0
- data/autohotkey/procedures/collect.rb +2 -2
- data/autohotkey/procedures/collect_util.rb +1 -1
- data/autohotkey/procedures/script_test.rb +1 -1
- data/autohotkey/tools/CmdSenderAHK2 +18 -0
- data/autohotkey/tools/cmd_extractor.ahk +11 -9
- data/autohotkey/tools/cmd_sender.ahk +35 -7
- data/autohotkey/tools/cmd_sender2.ahk +4 -0
- data/autohotkey/tools/cmd_sequence.ahk +22 -9
- data/autohotkey/tools/config_editor.ahk +4 -4
- data/autohotkey/tools/data_viewer.ahk +1 -1
- data/autohotkey/tools/limits_monitor.ahk +1 -1
- data/autohotkey/tools/packet_viewer.ahk +1 -1
- data/autohotkey/tools/script_runner.ahk +1 -1
- data/autohotkey/tools/test_runner2.ahk +1 -1
- data/autohotkey/tools/tlm_grapher.ahk +1 -1
- data/autohotkey/tools/tlm_grapher3.ahk +1 -1
- data/autohotkey/tools/tlm_viewer.ahk +1 -1
- data/autohotkey/tools/tlm_viewer2.ahk +1 -1
- data/autohotkey/tools/tlm_viewer5.ahk +1 -1
- data/bin/cstol_converter +1 -1
- data/bin/rubysloc +73 -28
- data/bin/xtce_converter +1 -1
- data/cosmos.gemspec +2 -2
- data/data/config/command_modifiers.yaml +16 -1
- data/data/config/interface_modifiers.yaml +3 -2
- data/data/config/param_item_modifiers.yaml +5 -0
- data/data/config/system.yaml +110 -23
- data/data/config/telemetry_modifiers.yaml +16 -1
- data/data/crc.txt +416 -411
- data/demo/Rakefile +4 -4
- data/demo/config/dart/Gemfile +1 -6
- data/demo/config/data/crc.txt +233 -232
- data/demo/config/system/system.txt +17 -6
- data/demo/config/system/system2.txt +17 -6
- data/demo/config/system/system_alt_ports.txt +17 -6
- data/demo/config/targets/INST/cmd_tlm/inst_cmds.txt +4 -4
- data/demo/config/targets/INST/cmd_tlm/inst_tlm.txt +4 -0
- data/demo/config/targets/INST/cmd_tlm/inst_tlm_override.txt +12 -0
- data/demo/config/targets/INST/lib/sim_inst.rb +2 -2
- data/demo/config/targets/INST/target.txt +1 -0
- data/demo/config/tools/handbook_creator/default_toc.xsl +59 -59
- data/demo/procedures/cosmos_api_test.rb +8 -8
- data/ext/cosmos/ext/buffered_file/buffered_file.c +2 -2
- data/ext/cosmos/ext/config_parser/config_parser.c +1 -2
- data/ext/cosmos/ext/line_graph/line_graph.c +53 -94
- data/ext/cosmos/ext/platform/platform.c +56 -21
- data/ext/cosmos/ext/polynomial_conversion/polynomial_conversion.c +4 -8
- data/ext/cosmos/ext/structure/structure.c +12 -0
- data/extensions/vscode/.gitignore +4 -0
- data/extensions/vscode/.vscode/launch.json +32 -0
- data/extensions/vscode/.vscode/settings.json +13 -0
- data/extensions/vscode/.vscode/tasks.json +79 -0
- data/extensions/vscode/License.txt +879 -0
- data/extensions/vscode/README.md +9 -0
- data/extensions/vscode/client/License.txt +879 -0
- data/extensions/vscode/client/README.md +39 -0
- data/extensions/vscode/client/cosmos.configuration.json +23 -0
- data/extensions/vscode/client/images/icon.png +0 -0
- data/extensions/vscode/client/package-lock.json +414 -0
- data/extensions/vscode/client/package.json +105 -0
- data/extensions/vscode/client/src/extension.ts +132 -0
- data/extensions/vscode/client/src/screen_preview.rb +25 -0
- data/extensions/vscode/client/syntaxes/cosmos.tmLanguage.json +219 -0
- data/extensions/vscode/client/tsconfig.json +17 -0
- data/extensions/vscode/package-lock.json +26 -0
- data/extensions/vscode/package.json +35 -0
- data/extensions/vscode/server/License.txt +879 -0
- data/extensions/vscode/server/package-lock.json +236 -0
- data/extensions/vscode/server/package.json +29 -0
- data/extensions/vscode/server/src/server.ts +59 -0
- data/extensions/vscode/server/tsconfig.json +16 -0
- data/install/Rakefile +4 -4
- data/install/config/dart/Gemfile +2 -7
- data/install/config/data/crc.txt +137 -137
- data/install/config/system/system.txt +17 -6
- data/install/config/tools/handbook_creator/default_toc.xsl +59 -59
- data/lib/cosmos/config/config_parser.rb +2 -10
- data/lib/cosmos/core_ext/class.rb +10 -0
- data/lib/cosmos/core_ext/time.rb +5 -3
- data/lib/cosmos/dart/config/boot.rb +1 -1
- data/lib/cosmos/dart/config/database.yml +2 -0
- data/lib/cosmos/dart/examples/dart_decom_client.rb +1 -1
- data/lib/cosmos/dart/lib/dart_common.rb +12 -5
- data/lib/cosmos/dart/lib/dart_constants.rb +15 -0
- data/lib/cosmos/dart/lib/dart_decom_query.rb +5 -6
- data/lib/cosmos/dart/lib/dart_decommutator.rb +64 -54
- data/lib/cosmos/dart/lib/dart_master_query.rb +71 -0
- data/lib/cosmos/dart/lib/dart_reducer_worker_thread.rb +165 -134
- data/lib/cosmos/dart/processes/dart.rb +4 -2
- data/lib/cosmos/dart/processes/dart_decom_server.rb +3 -3
- data/lib/cosmos/dart/processes/dart_ingester.rb +38 -1
- data/lib/cosmos/dart/processes/dart_master.rb +44 -0
- data/lib/cosmos/dart/processes/dart_util.rb +115 -0
- data/lib/cosmos/dart/spec/dart/dart_database_cleaner_spec.rb +2 -2
- data/lib/cosmos/gui/qt.rb +10 -10
- data/lib/cosmos/gui/qt_tool.rb +17 -12
- data/lib/cosmos/gui/text/completion_text_edit.rb +2 -0
- data/lib/cosmos/gui/widgets/dart_meta_frame.rb +22 -3
- data/lib/cosmos/interfaces/dart_status_interface.rb +1 -1
- data/lib/cosmos/interfaces/linc_interface.rb +3 -3
- data/lib/cosmos/interfaces/protocols/burst_protocol.rb +1 -1
- data/lib/cosmos/interfaces/protocols/crc_protocol.rb +1 -1
- data/lib/cosmos/interfaces/protocols/length_protocol.rb +5 -0
- data/lib/cosmos/interfaces/protocols/template_protocol.rb +3 -3
- data/lib/cosmos/interfaces/serial_interface.rb +7 -1
- data/lib/cosmos/interfaces/stream_interface.rb +1 -1
- data/lib/cosmos/interfaces/tcpip_server_interface.rb +16 -16
- data/lib/cosmos/io/io_multiplexer.rb +6 -2
- data/lib/cosmos/io/json_drb.rb +5 -5
- data/lib/cosmos/io/json_drb_object.rb +7 -2
- data/lib/cosmos/io/json_drb_rack.rb +25 -5
- data/lib/cosmos/io/json_rpc.rb +1 -1
- data/lib/cosmos/io/posix_serial_driver.rb +60 -22
- data/lib/cosmos/io/serial_driver.rb +11 -8
- data/lib/cosmos/io/win32_serial_driver.rb +31 -3
- data/lib/cosmos/packet_logs/packet_log_reader.rb +2 -2
- data/lib/cosmos/packets/packet.rb +9 -9
- data/lib/cosmos/packets/packet_config.rb +27 -9
- data/lib/cosmos/packets/parsers/xtce_converter.rb +10 -10
- data/lib/cosmos/packets/parsers/xtce_parser.rb +3 -0
- data/lib/cosmos/packets/structure.rb +35 -5
- data/lib/cosmos/packets/structure_item.rb +5 -1
- data/lib/cosmos/packets/telemetry.rb +7 -1
- data/lib/cosmos/script/api_shared.rb +18 -1
- data/lib/cosmos/script/extract.rb +1 -1
- data/lib/cosmos/script/script.rb +4 -11
- data/lib/cosmos/streams/serial_stream.rb +11 -6
- data/lib/cosmos/system/system.rb +155 -57
- data/lib/cosmos/tools/cmd_sender/cmd_param_table_item_delegate.rb +15 -0
- data/lib/cosmos/tools/cmd_sender/cmd_params.rb +382 -0
- data/lib/cosmos/tools/cmd_sender/cmd_sender.rb +29 -318
- data/lib/cosmos/tools/cmd_sequence/cmd_sequence.rb +14 -17
- data/lib/cosmos/tools/cmd_sequence/sequence_item.rb +38 -331
- data/lib/cosmos/tools/cmd_sequence/sequence_list.rb +16 -11
- data/lib/cosmos/tools/cmd_tlm_server/api.rb +10 -8
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb +2 -2
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb +1 -0
- data/lib/cosmos/tools/cmd_tlm_server/gui/logging_tab.rb +1 -1
- data/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb +29 -26
- data/lib/cosmos/tools/cmd_tlm_server/limits_groups_background_task.rb +1 -1
- data/lib/cosmos/tools/cmd_tlm_server/router_thread.rb +5 -0
- data/lib/cosmos/tools/config_editor/config_editor.rb +34 -3
- data/lib/cosmos/tools/config_editor/config_editor_frame.rb +8 -9
- data/lib/cosmos/tools/config_editor/system_config_dialog.rb +158 -0
- data/lib/cosmos/tools/handbook_creator/handbook_creator.rb +1 -1
- data/lib/cosmos/tools/handbook_creator/handbook_creator_config.rb +1 -1
- data/lib/cosmos/tools/script_runner/script_runner_frame.rb +7 -4
- data/lib/cosmos/tools/test_runner/test.rb +6 -3
- data/lib/cosmos/tools/test_runner/test_runner.rb +6 -6
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor.rb +3 -3
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor_config.rb +1 -4
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor_processor.rb +20 -16
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_dart_thread.rb +21 -17
- data/lib/cosmos/tools/tlm_grapher/tlm_grapher.rb +18 -11
- data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +17 -6
- data/lib/cosmos/tools/tlm_viewer/widgets/canvasdot_widget.rb +2 -0
- data/lib/cosmos/top_level.rb +1 -1
- data/lib/cosmos/utilities/ruby_lex_utils.rb +34 -30
- data/lib/cosmos/utilities/simulated_target.rb +1 -1
- data/lib/cosmos/version.rb +5 -5
- data/lib/cosmos/win32/excel.rb +23 -17
- data/run_gui_tests.bat +1 -0
- data/spec/core_ext/class_spec.rb +54 -0
- data/spec/core_ext/socket_spec.rb +1 -1
- data/spec/core_ext/time_spec.rb +4 -0
- data/spec/install/yaml_docs_spec.rb +26 -6
- data/spec/interfaces/linc_interface_spec.rb +1 -1
- data/spec/interfaces/protocols/length_protocol_spec.rb +39 -0
- data/spec/interfaces/serial_interface_spec.rb +1 -5
- data/spec/io/json_drb_rack_spec.rb +166 -0
- data/spec/io/json_drb_spec.rb +14 -0
- data/spec/io/json_rpc_spec.rb +4 -5
- data/spec/io/posix_serial_driver_spec.rb +81 -0
- data/spec/io/win32_serial_driver_spec.rb +33 -3
- data/spec/packet_logs/packet_log_reader_spec.rb +36 -37
- data/spec/packets/structure_spec.rb +52 -2
- data/spec/packets/telemetry_spec.rb +29 -1
- data/spec/script/extract_spec.rb +4 -1
- data/spec/system/system_spec.rb +111 -3
- data/spec/tools/cmd_tlm_server/api_spec.rb +12 -12
- data/spec/tools/cmd_tlm_server/background_tasks_spec.rb +2 -2
- data/spec/tools/cmd_tlm_server/interface_thread_spec.rb +4 -3
- data/spec/tools/cmd_tlm_server/router_thread_spec.rb +2 -3
- data/spec/utilities/logger_spec.rb +3 -3
- data/spec/utilities/message_log_spec.rb +6 -3
- data/tasks/gemfile_stats.rake +22 -13
- data/test/performance/Rakefile +4 -4
- data/test/performance/config/data/crc.txt +67 -48
- metadata +44 -9
- data/demo/outputs/dart/logs/README.txt +0 -1
- data/lib/cosmos/dart/Gemfile +0 -69
|
@@ -30,7 +30,8 @@ class Dart
|
|
|
30
30
|
# streamed from the packet log binary file
|
|
31
31
|
# 4. Decom Server - JSON DRB server which handles requests for decommutated
|
|
32
32
|
# or reduced data from the database
|
|
33
|
-
# 5
|
|
33
|
+
# 5. Master - Hands out packets to be decommutated by workers
|
|
34
|
+
# 6..n Worker - Decommutates data from the packet log binary file into the DB
|
|
34
35
|
def run
|
|
35
36
|
Cosmos::Logger.level = Cosmos::Logger::INFO
|
|
36
37
|
dart_logging = DartLogging.new('dart')
|
|
@@ -53,7 +54,8 @@ class Dart
|
|
|
53
54
|
[ruby_process_name, File.join(__dir__, 'dart_ingester.rb')],
|
|
54
55
|
[ruby_process_name, File.join(__dir__, 'dart_reducer.rb')],
|
|
55
56
|
[ruby_process_name, File.join(__dir__, 'dart_stream_server.rb')],
|
|
56
|
-
[ruby_process_name, File.join(__dir__, 'dart_decom_server.rb')]
|
|
57
|
+
[ruby_process_name, File.join(__dir__, 'dart_decom_server.rb')],
|
|
58
|
+
[ruby_process_name, File.join(__dir__, 'dart_master.rb')]
|
|
57
59
|
]
|
|
58
60
|
|
|
59
61
|
num_workers.times do |index|
|
|
@@ -25,9 +25,9 @@ Cosmos.catch_fatal_exception do
|
|
|
25
25
|
json_drb.method_whitelist = ['query', 'item_names', 'dart_status', 'clear_errors']
|
|
26
26
|
begin
|
|
27
27
|
json_drb.start_service(Cosmos::System.listen_hosts['DART_DECOM'],
|
|
28
|
-
Cosmos::System.ports['DART_DECOM'], DartDecomQuery.new)
|
|
29
|
-
rescue Exception
|
|
30
|
-
raise Cosmos::FatalError.new("Error starting JsonDRb on port #{Cosmos::System.ports['DART_DECOM']}.\nPerhaps another DART Decom Server is already running
|
|
28
|
+
Cosmos::System.ports['DART_DECOM'], DartDecomQuery.new, 1000, Cosmos::System)
|
|
29
|
+
rescue Exception => error
|
|
30
|
+
raise Cosmos::FatalError.new("Error starting JsonDRb on port #{Cosmos::System.ports['DART_DECOM']}.\nPerhaps another DART Decom Server is already running?\n#{error.formatted}")
|
|
31
31
|
end
|
|
32
32
|
["TERM", "INT"].each {|sig| Signal.trap(sig) {exit}}
|
|
33
33
|
Cosmos::Logger.info("Dart Decom Server Started...")
|
|
@@ -16,20 +16,57 @@ require 'dart_logging'
|
|
|
16
16
|
# Handles packets by writing them to the dart log file. New SYSTEM META packets
|
|
17
17
|
# cause a new log file to be started.
|
|
18
18
|
class DartInterfaceThread < Cosmos::InterfaceThread
|
|
19
|
+
include DartCommon
|
|
20
|
+
|
|
19
21
|
attr_writer :packet_log_writer
|
|
20
22
|
attr_writer :log_type
|
|
21
|
-
|
|
23
|
+
|
|
22
24
|
def handle_packet(packet)
|
|
23
25
|
if packet.target_name == 'SYSTEM'.freeze and packet.packet_name == 'META'.freeze
|
|
24
26
|
Cosmos::Logger.info("#{@log_type}: #{packet.target_name} #{packet.packet_name}")
|
|
27
|
+
|
|
28
|
+
# Manually read the configuration from the buffer because the packet might not be identified if
|
|
29
|
+
# identify_and_define is false
|
|
30
|
+
buffer = packet.buffer(false)
|
|
31
|
+
if buffer.length >= 33
|
|
32
|
+
system_config_name = Cosmos::BinaryAccessor.read(8, 256, :STRING, buffer, :BIG_ENDIAN)
|
|
33
|
+
# Switch to this system_config
|
|
34
|
+
begin
|
|
35
|
+
switch_and_get_system_config(system_config_name)
|
|
36
|
+
rescue Exception => e
|
|
37
|
+
Cosmos::Logger.error(e.formatted)
|
|
38
|
+
Cosmos::Logger.error("Could not load system_config: #{system_config_name}")
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
25
42
|
# Update Current Value Table Used By Packet Log Writer
|
|
26
43
|
cvt_packet = Cosmos::System.telemetry.update!(packet.target_name, packet.packet_name, packet.buffer)
|
|
27
44
|
cvt_packet.received_time = packet.received_time
|
|
28
45
|
cvt_packet.stored = packet.stored
|
|
29
46
|
cvt_packet.extra = packet.extra
|
|
47
|
+
|
|
30
48
|
@packet_log_writer.start
|
|
31
49
|
@packet_log_writer.write(cvt_packet)
|
|
32
50
|
else
|
|
51
|
+
# Define the packet so that packet_time will work correctly
|
|
52
|
+
begin
|
|
53
|
+
packet_data = packet.buffer(false)
|
|
54
|
+
received_time = packet.received_time
|
|
55
|
+
stored = packet.stored
|
|
56
|
+
extra = packet.extra
|
|
57
|
+
if @log_type == :TLM
|
|
58
|
+
packet = Cosmos::System.telemetry.packet(packet.target_name, packet.packet_name)
|
|
59
|
+
else
|
|
60
|
+
packet = Cosmos::System.commands.packet(packet.target_name, packet.packet_name)
|
|
61
|
+
end
|
|
62
|
+
packet.buffer = packet_data
|
|
63
|
+
packet.received_time = received_time
|
|
64
|
+
packet.stored = stored
|
|
65
|
+
packet.extra = extra
|
|
66
|
+
rescue Exception => error
|
|
67
|
+
# Could not find a definition for this packet
|
|
68
|
+
Cosmos::Logger.error "Unknown packet #{target_name} #{packet_name}"
|
|
69
|
+
end
|
|
33
70
|
@packet_log_writer.write(packet)
|
|
34
71
|
end
|
|
35
72
|
end
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
ENV['RAILS_ENV'] = 'production'
|
|
12
|
+
require File.expand_path('../../config/environment', __FILE__)
|
|
13
|
+
require 'dart_common'
|
|
14
|
+
require 'dart_master_query'
|
|
15
|
+
|
|
16
|
+
ples_per_request = ENV['DART_PLE_REQ_SIZE']
|
|
17
|
+
ples_per_request ||= 5
|
|
18
|
+
ples_per_request = ples_per_request.to_i
|
|
19
|
+
|
|
20
|
+
Cosmos.catch_fatal_exception do
|
|
21
|
+
DartCommon.handle_argv
|
|
22
|
+
|
|
23
|
+
Cosmos::Logger.level = Cosmos::Logger::INFO
|
|
24
|
+
dart_logging = DartLogging.new('dart_master')
|
|
25
|
+
|
|
26
|
+
json_drb = Cosmos::JsonDRb.new
|
|
27
|
+
json_drb.acl = Cosmos::System.acl if Cosmos::System.acl
|
|
28
|
+
begin
|
|
29
|
+
json_drb.method_whitelist = ['get_decom_ple_ids']
|
|
30
|
+
begin
|
|
31
|
+
json_drb.start_service(Cosmos::System.listen_hosts['DART_MASTER'],
|
|
32
|
+
Cosmos::System.ports['DART_MASTER'], DartMasterQuery.new(ples_per_request), 1000, Cosmos::System)
|
|
33
|
+
rescue Exception => error
|
|
34
|
+
raise Cosmos::FatalError.new("Error starting JsonDRb on port #{Cosmos::System.ports['DART_MASTER']}.\nPerhaps another DART Master is already running?\n#{error.formatted}")
|
|
35
|
+
end
|
|
36
|
+
["TERM", "INT"].each {|sig| Signal.trap(sig) {exit}}
|
|
37
|
+
Cosmos::Logger.info("Dart Master Started...")
|
|
38
|
+
sleep(1) while true
|
|
39
|
+
rescue Interrupt
|
|
40
|
+
Cosmos::Logger.info("Dart Master Closing...")
|
|
41
|
+
json_drb.stop_service
|
|
42
|
+
dart_logging.stop
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -56,6 +56,8 @@ ENV['RAILS_ENV'] = 'production'
|
|
|
56
56
|
require File.expand_path('../../config/environment', __FILE__)
|
|
57
57
|
require 'dart_database_cleaner'
|
|
58
58
|
|
|
59
|
+
include DartCommon
|
|
60
|
+
|
|
59
61
|
Cosmos.catch_fatal_exception do
|
|
60
62
|
case action.downcase
|
|
61
63
|
when 'showpleerrors'
|
|
@@ -77,6 +79,119 @@ Cosmos.catch_fatal_exception do
|
|
|
77
79
|
Cosmos::Logger.level = Cosmos::Logger::INFO
|
|
78
80
|
DartDatabaseCleaner.new.remove_packet_log(ARGV[1])
|
|
79
81
|
|
|
82
|
+
when 'showdatabase'
|
|
83
|
+
puts "Status:"
|
|
84
|
+
status = Status.last
|
|
85
|
+
puts " Updated At: #{status.updated_at.formatted}"
|
|
86
|
+
puts " Decom Count: #{status.decom_count}"
|
|
87
|
+
puts " Decom Error Count: #{status.decom_error_count}"
|
|
88
|
+
puts " Decom Message: #{status.decom_message}"
|
|
89
|
+
puts " Decom Message Time: #{status.decom_message_time.formatted}"
|
|
90
|
+
puts " Reduction Count: #{status.reduction_count}"
|
|
91
|
+
puts " Reduction Error Count: #{status.reduction_error_count}"
|
|
92
|
+
puts " Reduction Message: #{status.reduction_message}"
|
|
93
|
+
puts " Reduction Message Time: #{status.reduction_message_time}"
|
|
94
|
+
puts ""
|
|
95
|
+
|
|
96
|
+
puts "System Configs:"
|
|
97
|
+
SystemConfig.all.each do |system_config|
|
|
98
|
+
puts " #{sprintf("%6d", system_config.id)} #{system_config.name}"
|
|
99
|
+
end
|
|
100
|
+
puts ""
|
|
101
|
+
|
|
102
|
+
puts "Targets:"
|
|
103
|
+
Target.all.each do |target|
|
|
104
|
+
puts " #{sprintf("%6d", target.id)} #{target.name}"
|
|
105
|
+
end
|
|
106
|
+
puts ""
|
|
107
|
+
|
|
108
|
+
puts "Packets:"
|
|
109
|
+
Packet.all.each do |packet|
|
|
110
|
+
target = Target.find(packet.target_id)
|
|
111
|
+
puts " #{sprintf("%6d", packet.id)} #{target.name} #{packet.name} (#{packet.is_tlm ? "TLM" : "CMD"})"
|
|
112
|
+
end
|
|
113
|
+
puts ""
|
|
114
|
+
|
|
115
|
+
puts "Items:"
|
|
116
|
+
Item.find_each do |item|
|
|
117
|
+
packet = Packet.find(item.packet_id)
|
|
118
|
+
target = Target.find(packet.target_id)
|
|
119
|
+
puts " #{sprintf("%6d", item.id)} #{target.name} #{packet.name} #{item.name}"
|
|
120
|
+
end
|
|
121
|
+
puts ""
|
|
122
|
+
|
|
123
|
+
puts "Packet Logs:"
|
|
124
|
+
PacketLog.all.each do |packet_log|
|
|
125
|
+
puts " #{sprintf("%6d", packet_log.id)} #{packet_log.filename} (#{packet_log.is_tlm ? "TLM" : "CMD"}) #{packet_log.created_at.formatted}"
|
|
126
|
+
end
|
|
127
|
+
puts ""
|
|
128
|
+
|
|
129
|
+
puts "Packet Log Entry Count: #{PacketLogEntry.count}"
|
|
130
|
+
puts ""
|
|
131
|
+
|
|
132
|
+
puts "Packet Configs:"
|
|
133
|
+
PacketConfig.all.each do |packet_config|
|
|
134
|
+
packet = Packet.find(packet_config.packet_id)
|
|
135
|
+
target = Target.find(packet.target_id)
|
|
136
|
+
puts " #{sprintf("%6d", packet_config.id)} #{target.name} #{packet.name} (#{packet_config.name}) sysconfig:#{packet_config.first_system_config_id} maxindex:#{packet_config.max_table_index} ready:#{packet_config.ready} start:#{packet_config.start_time.formatted} end:#{packet_config.end_time.formatted}"
|
|
137
|
+
end
|
|
138
|
+
puts ""
|
|
139
|
+
|
|
140
|
+
value_type_lookup = {0 => "RAW", 1 => "CONVERTED", 2 => "RAW_CON"}
|
|
141
|
+
puts "Item to Decom Table Mappings:"
|
|
142
|
+
ItemToDecomTableMapping.find_each do |itdtm|
|
|
143
|
+
item = Item.find(itdtm.item_id)
|
|
144
|
+
packet = Packet.find(item.packet_id)
|
|
145
|
+
target = Target.find(packet.target_id)
|
|
146
|
+
puts " #{sprintf("%6d", itdtm.id)} #{target.name} #{packet.name} #{item.name} #{value_type_lookup[itdtm.value_type]} packet_config:#{itdtm.packet_config_id} item_index:#{itdtm.item_index} table_index:#{itdtm.table_index} reduced:#{itdtm.reduced}"
|
|
147
|
+
end
|
|
148
|
+
puts ""
|
|
149
|
+
|
|
150
|
+
puts "Decom and Reduced Tables:"
|
|
151
|
+
each_decom_and_reduced_table do |packet_config_id, table_index, decom_model, minute_model, hour_model, day_model|
|
|
152
|
+
puts " t#{decom_model.name.split("::")[1][1..-1]}: (#{decom_model.count} entries)"
|
|
153
|
+
ItemToDecomTableMapping.where("packet_config_id = ? and table_index = ?", packet_config_id, table_index).order("item_index ASC").each do |itdtm|
|
|
154
|
+
item = Item.find(itdtm.item_id)
|
|
155
|
+
packet = Packet.find(item.packet_id)
|
|
156
|
+
target = Target.find(packet.target_id)
|
|
157
|
+
puts " i#{itdtm.item_index} #{target.name} #{packet.name} #{item.name} #{value_type_lookup[itdtm.value_type]}"
|
|
158
|
+
end
|
|
159
|
+
puts ""
|
|
160
|
+
puts " t#{minute_model.name.split("::")[1][1..-1]}: (#{minute_model.count} entries)"
|
|
161
|
+
ItemToDecomTableMapping.where("packet_config_id = ? and table_index = ? and reduced = true", packet_config_id, table_index).order("item_index ASC").each do |itdtm|
|
|
162
|
+
item = Item.find(itdtm.item_id)
|
|
163
|
+
packet = Packet.find(item.packet_id)
|
|
164
|
+
target = Target.find(packet.target_id)
|
|
165
|
+
puts " i#{itdtm.item_index}max #{target.name} #{packet.name} #{item.name} #{value_type_lookup[itdtm.value_type]}"
|
|
166
|
+
puts " i#{itdtm.item_index}min #{target.name} #{packet.name} #{item.name} #{value_type_lookup[itdtm.value_type]}"
|
|
167
|
+
puts " i#{itdtm.item_index}avg #{target.name} #{packet.name} #{item.name} #{value_type_lookup[itdtm.value_type]}"
|
|
168
|
+
puts " i#{itdtm.item_index}stddev #{target.name} #{packet.name} #{item.name} #{value_type_lookup[itdtm.value_type]}"
|
|
169
|
+
end
|
|
170
|
+
puts ""
|
|
171
|
+
puts " t#{hour_model.name.split("::")[1][1..-1]}: (#{hour_model.count} entries)"
|
|
172
|
+
ItemToDecomTableMapping.where("packet_config_id = ? and table_index = ? and reduced = true", packet_config_id, table_index).order("item_index ASC").each do |itdtm|
|
|
173
|
+
item = Item.find(itdtm.item_id)
|
|
174
|
+
packet = Packet.find(item.packet_id)
|
|
175
|
+
target = Target.find(packet.target_id)
|
|
176
|
+
puts " i#{itdtm.item_index}max #{target.name} #{packet.name} #{item.name} #{value_type_lookup[itdtm.value_type]}"
|
|
177
|
+
puts " i#{itdtm.item_index}min #{target.name} #{packet.name} #{item.name} #{value_type_lookup[itdtm.value_type]}"
|
|
178
|
+
puts " i#{itdtm.item_index}avg #{target.name} #{packet.name} #{item.name} #{value_type_lookup[itdtm.value_type]}"
|
|
179
|
+
puts " i#{itdtm.item_index}stddev #{target.name} #{packet.name} #{item.name} #{value_type_lookup[itdtm.value_type]}"
|
|
180
|
+
end
|
|
181
|
+
puts ""
|
|
182
|
+
puts " t#{day_model.name.split("::")[1][1..-1]}: (#{day_model.count} entries)"
|
|
183
|
+
ItemToDecomTableMapping.where("packet_config_id = ? and table_index = ? and reduced = true", packet_config_id, table_index).order("item_index ASC").each do |itdtm|
|
|
184
|
+
item = Item.find(itdtm.item_id)
|
|
185
|
+
packet = Packet.find(item.packet_id)
|
|
186
|
+
target = Target.find(packet.target_id)
|
|
187
|
+
puts " i#{itdtm.item_index}max #{target.name} #{packet.name} #{item.name} #{value_type_lookup[itdtm.value_type]}"
|
|
188
|
+
puts " i#{itdtm.item_index}min #{target.name} #{packet.name} #{item.name} #{value_type_lookup[itdtm.value_type]}"
|
|
189
|
+
puts " i#{itdtm.item_index}avg #{target.name} #{packet.name} #{item.name} #{value_type_lookup[itdtm.value_type]}"
|
|
190
|
+
puts " i#{itdtm.item_index}stddev #{target.name} #{packet.name} #{item.name} #{value_type_lookup[itdtm.value_type]}"
|
|
191
|
+
end
|
|
192
|
+
puts ""
|
|
193
|
+
end
|
|
194
|
+
|
|
80
195
|
when 'showpacketlogs'
|
|
81
196
|
total_size = 0
|
|
82
197
|
packet_logs = PacketLog.all
|
|
@@ -189,7 +189,7 @@ describe DartDatabaseCleaner do
|
|
|
189
189
|
end
|
|
190
190
|
model.reset_column_information
|
|
191
191
|
model_name = table_name.upcase
|
|
192
|
-
Cosmos.
|
|
192
|
+
Cosmos.public_send(:remove_const, model_name) if Cosmos.const_defined?(model_name)
|
|
193
193
|
Cosmos.const_set(model_name, model)
|
|
194
194
|
|
|
195
195
|
expect(model.column_names).to include("delete_me")
|
|
@@ -205,7 +205,7 @@ describe DartDatabaseCleaner do
|
|
|
205
205
|
end
|
|
206
206
|
model.reset_column_information
|
|
207
207
|
model_name = table_name.upcase
|
|
208
|
-
Cosmos.
|
|
208
|
+
Cosmos.public_send(:remove_const, model_name) if Cosmos.const_defined?(model_name)
|
|
209
209
|
Cosmos.const_set(model_name, model)
|
|
210
210
|
|
|
211
211
|
expect(model.column_names).to include("delete_me")
|
data/lib/cosmos/gui/qt.rb
CHANGED
|
@@ -101,22 +101,22 @@ module Cosmos
|
|
|
101
101
|
return color_r if (color_r.is_a? Qt::Color) || (color_r.is_a? Qt::Pen) || (color_r.is_a? Qt::LinearGradient)
|
|
102
102
|
|
|
103
103
|
color = nil
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
color_key = color_r
|
|
105
|
+
color_key = color_key.to_i if color_key.is_a? Qt::Enum
|
|
106
106
|
|
|
107
107
|
if color_r && color_g && color_b
|
|
108
|
-
|
|
108
|
+
color_key = (color_r.to_i << 24) + (color_g.to_i << 16) + (color_b.to_i << 8)
|
|
109
109
|
end
|
|
110
110
|
|
|
111
|
-
if Cosmos::COLORS[
|
|
112
|
-
color = Cosmos::COLORS[
|
|
111
|
+
if Cosmos::COLORS[color_key]
|
|
112
|
+
color = Cosmos::COLORS[color_key]
|
|
113
113
|
else
|
|
114
114
|
if color_r && color_g && color_b
|
|
115
115
|
color = Qt::Color.new(color_r.to_i, color_g.to_i, color_b.to_i)
|
|
116
116
|
else
|
|
117
117
|
color = Qt::Color.new(color_r)
|
|
118
118
|
end
|
|
119
|
-
Cosmos::COLORS[
|
|
119
|
+
Cosmos::COLORS[color_key] = color
|
|
120
120
|
end
|
|
121
121
|
color
|
|
122
122
|
end
|
|
@@ -214,12 +214,12 @@ module Cosmos
|
|
|
214
214
|
end
|
|
215
215
|
|
|
216
216
|
def self.getCursor(shape)
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
cursor = CURSORS[
|
|
217
|
+
shape_key = shape
|
|
218
|
+
shape_key = shape.to_i if shape.is_a? Qt::Enum
|
|
219
|
+
cursor = CURSORS[shape_key]
|
|
220
220
|
unless cursor
|
|
221
221
|
cursor = Qt::Cursor.new(shape)
|
|
222
|
-
CURSORS[
|
|
222
|
+
CURSORS[shape_key] = cursor
|
|
223
223
|
end
|
|
224
224
|
cursor
|
|
225
225
|
end
|
data/lib/cosmos/gui/qt_tool.rb
CHANGED
|
@@ -61,6 +61,7 @@ module Cosmos
|
|
|
61
61
|
@stylesheet = File.read(app_style) if File.exist? app_style
|
|
62
62
|
|
|
63
63
|
self.class.normalize_config_options(@options)
|
|
64
|
+
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint) if @options.stay_on_top
|
|
64
65
|
|
|
65
66
|
# Add a banner based on system configuration
|
|
66
67
|
add_classification_banner
|
|
@@ -82,7 +83,7 @@ module Cosmos
|
|
|
82
83
|
else
|
|
83
84
|
options.config_file = nil
|
|
84
85
|
options.stylesheet = nil
|
|
85
|
-
end
|
|
86
|
+
end
|
|
86
87
|
end
|
|
87
88
|
|
|
88
89
|
# Creates a path to a configuration file. If the file is given it is
|
|
@@ -209,28 +210,26 @@ module Cosmos
|
|
|
209
210
|
|
|
210
211
|
# Handle manually positioning the window
|
|
211
212
|
unless @options.auto_position
|
|
212
|
-
# Get the desktop's geometry
|
|
213
|
-
desktop = Qt::Application.desktop
|
|
214
|
-
|
|
215
|
-
# Handle position relative to right edge
|
|
216
|
-
@options.x = desktop.width - frameGeometry().width + @options.x + 1 if @options.x < 0
|
|
217
|
-
|
|
218
|
-
# Handle position relative to bottom edge
|
|
219
|
-
@options.y = desktop.height - frameGeometry().height + @options.y + 1 if @options.y < 0
|
|
220
|
-
|
|
221
213
|
# Move to the desired position
|
|
222
214
|
move(@options.x, @options.y)
|
|
223
215
|
end
|
|
224
216
|
|
|
225
217
|
if @options.remember_geometry and !@options.command_line_geometry
|
|
218
|
+
# Get the desktop's geometry
|
|
219
|
+
desktop = Qt::Application.desktop
|
|
220
|
+
screen = desktop.screen
|
|
226
221
|
settings = Qt::Settings.new('Ball Aerospace', self.class.to_s)
|
|
227
222
|
if settings.contains('size') and @options.restore_size and @options.startup_state != :DEFAULT
|
|
228
223
|
size = settings.value('size').toSize
|
|
229
|
-
|
|
224
|
+
if size.height > 0 and size.height < screen.height and size.width > 0 and size.width < screen.width
|
|
225
|
+
resize(size)
|
|
226
|
+
end
|
|
230
227
|
end
|
|
231
228
|
if settings.contains('position') and @options.restore_position
|
|
232
229
|
position = settings.value('position').toPoint
|
|
233
|
-
|
|
230
|
+
if position.x > 0 and position.y > 0 and position.x < screen.width and position.y < screen.height
|
|
231
|
+
move(position)
|
|
232
|
+
end
|
|
234
233
|
end
|
|
235
234
|
end
|
|
236
235
|
|
|
@@ -352,6 +351,7 @@ module Cosmos
|
|
|
352
351
|
options.remember_geometry = true
|
|
353
352
|
options.restore_position = true
|
|
354
353
|
options.restore_size = true
|
|
354
|
+
options.stay_on_top = false
|
|
355
355
|
options.redirect_io = true
|
|
356
356
|
options.title = "COSMOS Tool"
|
|
357
357
|
options.config_file = nil
|
|
@@ -403,6 +403,11 @@ module Cosmos
|
|
|
403
403
|
options.startup_state = :DEFAULT
|
|
404
404
|
end
|
|
405
405
|
|
|
406
|
+
# Create the defaultsize option
|
|
407
|
+
option_parser.on("--stay-on-top", "Force the tool to stay on top of all other windows") do |arg|
|
|
408
|
+
options.stay_on_top = true
|
|
409
|
+
end
|
|
410
|
+
|
|
406
411
|
# Create the x and y position options
|
|
407
412
|
option_parser.separator("")
|
|
408
413
|
option_parser.separator("Window X & Y Position Options:")
|
|
@@ -17,6 +17,7 @@ module Cosmos
|
|
|
17
17
|
# This calss also includes many helper methods to access various
|
|
18
18
|
# lines, indent selections, highlight lines and center the view.
|
|
19
19
|
class CompletionTextEdit < Qt::PlainTextEdit
|
|
20
|
+
attr_accessor :read_only
|
|
20
21
|
# Create a signal so users of CompletionTextEdit don't have to
|
|
21
22
|
# subclass in order to listen to keyPressEvents
|
|
22
23
|
signals 'key_pressed(QKeyEvent*)'
|
|
@@ -47,6 +48,7 @@ module Cosmos
|
|
|
47
48
|
|
|
48
49
|
@last_hightlighted_line = 1
|
|
49
50
|
@code_completion = nil
|
|
51
|
+
@read_only = false
|
|
50
52
|
begin
|
|
51
53
|
@code_completion = Completion.new(self)
|
|
52
54
|
rescue
|
|
@@ -16,6 +16,13 @@ module Cosmos
|
|
|
16
16
|
class DartMetaFrame < Qt::Widget
|
|
17
17
|
@@meta_filters = []
|
|
18
18
|
|
|
19
|
+
class LabelPopup < Qt::Label
|
|
20
|
+
attr_accessor :text
|
|
21
|
+
def mousePressEvent(event)
|
|
22
|
+
Qt::MessageBox.critical(self.parent, 'Error', @text)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
19
26
|
def initialize(parent)
|
|
20
27
|
super(parent)
|
|
21
28
|
|
|
@@ -27,6 +34,7 @@ module Cosmos
|
|
|
27
34
|
@groupbox = Qt::GroupBox.new("Meta Filter Selection")
|
|
28
35
|
@vbox = Qt::VBoxLayout.new(@groupbox)
|
|
29
36
|
@hbox1 = Qt::HBoxLayout.new
|
|
37
|
+
|
|
30
38
|
@label = Qt::Label.new("Meta Filters: ")
|
|
31
39
|
@hbox1.addWidget(@label)
|
|
32
40
|
@meta_filters_text = Qt::LineEdit.new
|
|
@@ -43,6 +51,10 @@ module Cosmos
|
|
|
43
51
|
@vbox.addLayout(@hbox1)
|
|
44
52
|
|
|
45
53
|
@hbox2 = Qt::HBoxLayout.new
|
|
54
|
+
@error = LabelPopup.new
|
|
55
|
+
@error.setPixmap(Qt::Application.style.standardIcon(Qt::Style::SP_MessageBoxCritical).pixmap(20, 20))
|
|
56
|
+
@error.hide
|
|
57
|
+
@hbox2.addWidget(@error)
|
|
46
58
|
@meta_item_name = Qt::ComboBox.new
|
|
47
59
|
@meta_item_name.setMinimumWidth(200)
|
|
48
60
|
@meta_item_name.setMaxVisibleItems(6)
|
|
@@ -102,7 +114,7 @@ module Cosmos
|
|
|
102
114
|
if !@got_meta_item_names and !@update_thread
|
|
103
115
|
@update_thread = Thread.new do
|
|
104
116
|
begin
|
|
105
|
-
server = JsonDRbObject.new(System.connect_hosts['DART_DECOM'], System.ports['DART_DECOM'])
|
|
117
|
+
server = JsonDRbObject.new(System.connect_hosts['DART_DECOM'], System.ports['DART_DECOM'], 1.0, Cosmos::System.x_csrf_token)
|
|
106
118
|
item_names = server.item_names("SYSTEM", "META")
|
|
107
119
|
Qt.execute_in_main_thread do
|
|
108
120
|
unless self.disposed?
|
|
@@ -113,8 +125,15 @@ module Cosmos
|
|
|
113
125
|
end
|
|
114
126
|
end
|
|
115
127
|
@got_meta_item_names = true
|
|
116
|
-
|
|
117
|
-
|
|
128
|
+
Qt.execute_in_main_thread { @error.hide }
|
|
129
|
+
rescue Exception => e
|
|
130
|
+
case e.message
|
|
131
|
+
when /execution expired/
|
|
132
|
+
@error.text = "Could not connect to the DART Decom Server. Is it running?"
|
|
133
|
+
else
|
|
134
|
+
@error.text = e.message
|
|
135
|
+
end
|
|
136
|
+
Qt.execute_in_main_thread { @error.show }
|
|
118
137
|
ensure
|
|
119
138
|
@update_thread = nil
|
|
120
139
|
server.disconnect if defined? server
|
|
@@ -36,7 +36,7 @@ module Cosmos
|
|
|
36
36
|
@status_packet.write('PACKET_ID', 1)
|
|
37
37
|
@clear_errors_command = System.commands.packet('DART', 'CLEAR_ERRORS')
|
|
38
38
|
@sleeper = Sleeper.new
|
|
39
|
-
@dart = JsonDRbObject.new(System.connect_hosts['DART_DECOM'], System.ports['DART_DECOM'])
|
|
39
|
+
@dart = JsonDRbObject.new(System.connect_hosts['DART_DECOM'], System.ports['DART_DECOM'], 1.0, Cosmos::System.x_csrf_token)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
# Indicates if the interface is connected to its target(s) or not. Must be
|
|
@@ -256,7 +256,7 @@ module Cosmos
|
|
|
256
256
|
# Handle handshake warnings and errors
|
|
257
257
|
if status == "OK" and code != 0
|
|
258
258
|
unless @ignored_error_codes[handshake_cmd.handshake.handshake.target_name].include? code
|
|
259
|
-
Logger.warn "Warning sending command (#{code}): #{source}"
|
|
259
|
+
Logger.warn "#{@name}: Warning sending command (#{code}): #{source}"
|
|
260
260
|
end
|
|
261
261
|
elsif status == "ERROR"
|
|
262
262
|
unless @ignored_error_codes[handshake_cmd.handshake.handshake.target_name].include? code
|
|
@@ -295,7 +295,7 @@ module Cosmos
|
|
|
295
295
|
command.received_count += 1
|
|
296
296
|
|
|
297
297
|
# Put a log of the command onto the server for the user to see
|
|
298
|
-
Logger.info("External Command: " + System.commands.format(linc_handshake.identified_command, System.targets[linc_handshake.identified_command.target_name].ignored_parameters))
|
|
298
|
+
Logger.info("#{@name}: External Command: " + System.commands.format(linc_handshake.identified_command, System.targets[linc_handshake.identified_command.target_name].ignored_parameters))
|
|
299
299
|
|
|
300
300
|
# Log the command to the command log(s)
|
|
301
301
|
@packet_log_writer_pairs.each do |packet_log_writer_pair|
|
|
@@ -361,7 +361,7 @@ module Cosmos
|
|
|
361
361
|
if @handshake
|
|
362
362
|
timed_out = false
|
|
363
363
|
else
|
|
364
|
-
Logger.warn "No handshake - must be timeout."
|
|
364
|
+
Logger.warn "#{@name}: No handshake - must be timeout."
|
|
365
365
|
timed_out = true
|
|
366
366
|
end
|
|
367
367
|
|
|
@@ -156,7 +156,7 @@ module Cosmos
|
|
|
156
156
|
end
|
|
157
157
|
|
|
158
158
|
def log_discard(length, found)
|
|
159
|
-
Logger.error("Sync #{'not ' unless found}found. Discarding #{length} bytes of data.")
|
|
159
|
+
Logger.error("#{@interface ? @interface.name : ""}: Sync #{'not ' unless found}found. Discarding #{length} bytes of data.")
|
|
160
160
|
if @data.length >= 0
|
|
161
161
|
Logger.error(sprintf("Starting: 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n",
|
|
162
162
|
@data.length >= 1 ? @data.getbyte(0) : 0,
|
|
@@ -140,7 +140,7 @@ module Cosmos
|
|
|
140
140
|
crc = BinaryAccessor.read(@bit_offset, @bit_size, :UINT, data, @endianness)
|
|
141
141
|
calculated_crc = @crc.calc(data[0...(@bit_offset / 8)])
|
|
142
142
|
if calculated_crc != crc
|
|
143
|
-
Logger.error "Invalid CRC detected! Calculated 0x#{calculated_crc.to_s(16).upcase} vs found 0x#{crc.to_s(16).upcase}."
|
|
143
|
+
Logger.error "#{@interface ? @interface.name : ""}: Invalid CRC detected! Calculated 0x#{calculated_crc.to_s(16).upcase} vs found 0x#{crc.to_s(16).upcase}."
|
|
144
144
|
if @bad_strategy == DISCONNECT
|
|
145
145
|
return :DISCONNECT
|
|
146
146
|
end
|
|
@@ -135,6 +135,11 @@ module Cosmos
|
|
|
135
135
|
@length_endianness)
|
|
136
136
|
raise "Length value received larger than max_length: #{length} > #{@max_length}" if @max_length and length > @max_length
|
|
137
137
|
packet_length = (length * @length_bytes_per_count) + @length_value_offset
|
|
138
|
+
# Ensure the calculated packet length is long enough to support the location of the length field
|
|
139
|
+
# without overlap into the next packet
|
|
140
|
+
if (packet_length * 8) < (@length_bit_offset + @length_bit_size)
|
|
141
|
+
raise "Calculated packet length of #{packet_length * 8} bits < (offset:#{@length_bit_offset} + size:#{@length_bit_size})"
|
|
142
|
+
end
|
|
138
143
|
|
|
139
144
|
# Make sure we have enough data for the packet
|
|
140
145
|
return :STOP if @data.length < packet_length
|
|
@@ -146,13 +146,13 @@ module Cosmos
|
|
|
146
146
|
# Write the packet value with each of the values received
|
|
147
147
|
response_values = response_string.scan(response_regexp)[0]
|
|
148
148
|
if !response_values || (response_values.length != response_item_names.length)
|
|
149
|
-
handle_error("#{@interface.name}: Unexpected response: #{response_string}")
|
|
149
|
+
handle_error("#{@interface ? @interface.name : ""}: Unexpected response: #{response_string}")
|
|
150
150
|
else
|
|
151
151
|
response_values.each_with_index do |value, i|
|
|
152
152
|
begin
|
|
153
153
|
result_packet.write(response_item_names[i], value)
|
|
154
154
|
rescue => error
|
|
155
|
-
handle_error("#{@interface.name}: Could not write value #{value} due to #{error.message}")
|
|
155
|
+
handle_error("#{@interface ? @interface.name : ""}: Could not write value #{value} due to #{error.message}")
|
|
156
156
|
break
|
|
157
157
|
end
|
|
158
158
|
end
|
|
@@ -234,7 +234,7 @@ module Cosmos
|
|
|
234
234
|
sleep(@response_polling_period)
|
|
235
235
|
retry if !response_timeout_time
|
|
236
236
|
retry if response_timeout_time and Time.now < response_timeout_time
|
|
237
|
-
handle_error("#{@interface.name}: Timeout waiting for response")
|
|
237
|
+
handle_error("#{@interface ? @interface.name : ""}: Timeout waiting for response")
|
|
238
238
|
end
|
|
239
239
|
|
|
240
240
|
@response_template = nil
|
|
@@ -52,6 +52,7 @@ module Cosmos
|
|
|
52
52
|
@read_allowed = false unless @read_port_name
|
|
53
53
|
@flow_control = :NONE
|
|
54
54
|
@data_bits = 8
|
|
55
|
+
@struct = []
|
|
55
56
|
end
|
|
56
57
|
|
|
57
58
|
# Creates a new {SerialStream} using the parameters passed in the constructor
|
|
@@ -65,13 +66,16 @@ module Cosmos
|
|
|
65
66
|
@write_timeout,
|
|
66
67
|
@read_timeout,
|
|
67
68
|
@flow_control,
|
|
68
|
-
@data_bits
|
|
69
|
+
@data_bits,
|
|
70
|
+
@struct
|
|
69
71
|
)
|
|
70
72
|
super()
|
|
71
73
|
end
|
|
72
74
|
|
|
73
75
|
# Supported Options
|
|
74
76
|
# FLOW_CONTROL - Flow control method NONE or RTSCTS. Defaults to NONE
|
|
77
|
+
# DATA_BITS - How many data bits to use
|
|
78
|
+
# STRUCT - Directly set fields in the Win32 DCB or POSIX termios structure
|
|
75
79
|
def set_option(option_name, option_values)
|
|
76
80
|
super(option_name, option_values)
|
|
77
81
|
case option_name.upcase
|
|
@@ -79,6 +83,8 @@ module Cosmos
|
|
|
79
83
|
@flow_control = option_values[0]
|
|
80
84
|
when 'DATA_BITS'
|
|
81
85
|
@data_bits = option_values[0].to_i
|
|
86
|
+
when 'STRUCT'
|
|
87
|
+
@struct << option_values
|
|
82
88
|
end
|
|
83
89
|
end
|
|
84
90
|
end
|
|
@@ -49,7 +49,7 @@ module Cosmos
|
|
|
49
49
|
begin
|
|
50
50
|
data = @stream.read
|
|
51
51
|
rescue Timeout::Error
|
|
52
|
-
Logger.instance.error "Timeout waiting for data to be read"
|
|
52
|
+
Logger.instance.error "#{@name}: Timeout waiting for data to be read"
|
|
53
53
|
data = nil
|
|
54
54
|
end
|
|
55
55
|
return nil if data.nil? or data.length <= 0
|