cosmos 3.9.1 → 3.9.2
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/.travis.yml +4 -3
- data/Manifest.txt +7 -0
- data/autohotkey/tools/cmd_extractor.ahk +17 -0
- data/autohotkey/tools/tlm_extractor.ahk +62 -1
- data/bin/cosmos +182 -12
- data/data/crc.txt +35 -34
- data/demo/config/data/crc.txt +6 -2
- data/demo/config/targets/INST/screens/adcs.txt +1 -1
- data/demo/config/tools/cmd_tlm_server/cmd_tlm_server2.txt +1 -1
- data/demo/config/tools/example_application.css +58 -0
- data/demo/config/tools/launcher/launcher.css +7 -0
- data/demo/config/tools/launcher/launcher2.css +10 -0
- data/demo/config/tools/test_runner/test_runner.css +45 -0
- data/ext/cosmos/ext/packet/packet.c +6 -0
- data/lib/cosmos/gui/dialogs/scroll_text_dialog.rb +15 -6
- data/lib/cosmos/gui/qt_tool.rb +58 -8
- data/lib/cosmos/gui/text/ruby_editor.rb +54 -6
- data/lib/cosmos/gui/utilities/analyze_log.rb +153 -0
- data/lib/cosmos/interfaces/interface.rb +6 -0
- data/lib/cosmos/packets/packet_item_limits.rb +14 -2
- data/lib/cosmos/packets/structure_item.rb +22 -3
- data/lib/cosmos/script/cmd_tlm_server.rb +28 -0
- data/lib/cosmos/script/extract.rb +10 -9
- data/lib/cosmos/script/tools.rb +10 -4
- data/lib/cosmos/system/system.rb +2 -1
- data/lib/cosmos/tools/cmd_extractor/cmd_extractor.rb +12 -0
- data/lib/cosmos/tools/cmd_tlm_server/api.rb +84 -0
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb +3 -2
- data/lib/cosmos/tools/cmd_tlm_server/commanding.rb +9 -0
- data/lib/cosmos/tools/cmd_tlm_server/gui/interfaces_tab.rb +2 -2
- data/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb +26 -17
- data/lib/cosmos/tools/cmd_tlm_server/interfaces.rb +26 -0
- data/lib/cosmos/tools/cmd_tlm_server/packet_logging.rb +29 -0
- data/lib/cosmos/tools/cmd_tlm_server/routers.rb +33 -0
- data/lib/cosmos/tools/data_viewer/data_viewer.rb +1 -1
- data/lib/cosmos/tools/launcher/launcher.rb +14 -25
- data/lib/cosmos/tools/limits_monitor/limits_monitor.rb +3 -7
- data/lib/cosmos/tools/packet_viewer/packet_viewer.rb +6 -4
- data/lib/cosmos/tools/script_runner/script_runner.rb +58 -9
- data/lib/cosmos/tools/script_runner/script_runner_frame.rb +45 -19
- data/lib/cosmos/tools/table_manager/table_manager.rb +7 -7
- data/lib/cosmos/tools/test_runner/test_runner.rb +6 -0
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor.rb +145 -8
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor_config.rb +89 -19
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_config.rb +14 -0
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_realtime_thread.rb +1 -1
- data/lib/cosmos/tools/tlm_viewer/screen.rb +15 -3
- data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +23 -12
- data/lib/cosmos/version.rb +4 -4
- data/spec/packets/packet_item_limits_spec.rb +33 -6
- data/spec/packets/packet_item_spec.rb +9 -9
- data/spec/packets/packet_spec.rb +18 -6
- data/spec/packets/structure_item_spec.rb +22 -4
- data/spec/script/cmd_tlm_server_spec.rb +66 -0
- data/spec/script/extract_spec.rb +144 -0
- data/spec/script/tools_spec.rb +17 -2
- data/spec/system/system_spec.rb +1 -1
- data/spec/tools/cmd_tlm_server/api_spec.rb +6 -0
- data/spec/tools/cmd_tlm_server/cmd_tlm_server_spec.rb +1 -1
- data/spec/tools/table_manager/table_item_parser_spec.rb +61 -0
- data/spec/tools/table_manager/table_item_spec.rb +1 -1
- metadata +9 -2
data/spec/packets/packet_spec.rb
CHANGED
@@ -53,7 +53,7 @@ module Cosmos
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it "complains about non String target_names" do
|
56
|
-
expect { Packet.new(5, "pkt") }.to raise_error(ArgumentError, "target_name must be a String but is a
|
56
|
+
expect { Packet.new(5.1, "pkt") }.to raise_error(ArgumentError, "target_name must be a String but is a Float")
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -69,7 +69,7 @@ module Cosmos
|
|
69
69
|
end
|
70
70
|
|
71
71
|
it "complains about non String packet_names" do
|
72
|
-
expect { Packet.new("tgt", 5) }.to raise_error(ArgumentError, "packet_name must be a String but is a
|
72
|
+
expect { Packet.new("tgt", 5.1) }.to raise_error(ArgumentError, "packet_name must be a String but is a Float")
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -87,7 +87,7 @@ module Cosmos
|
|
87
87
|
|
88
88
|
it "complains about non String descriptions" do
|
89
89
|
p = Packet.new("tgt","pkt")
|
90
|
-
expect { p.description = 5 }.to raise_error(ArgumentError, "description must be a String but is a
|
90
|
+
expect { p.description = 5.1 }.to raise_error(ArgumentError, "description must be a String but is a Float")
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
@@ -140,12 +140,24 @@ module Cosmos
|
|
140
140
|
|
141
141
|
it "complains about nil received_count" do
|
142
142
|
p = Packet.new("tgt","pkt")
|
143
|
-
|
143
|
+
if 0.class == Integer
|
144
|
+
# Ruby version >= 2.4.0
|
145
|
+
expect {p.received_count = nil }.to raise_error(ArgumentError, "received_count must be an Integer but is a NilClass")
|
146
|
+
else
|
147
|
+
# Ruby version < 2.4.0
|
148
|
+
expect {p.received_count = nil }.to raise_error(ArgumentError, "received_count must be a Fixnum but is a NilClass")
|
149
|
+
end
|
144
150
|
end
|
145
151
|
|
146
152
|
it "complains about non Fixnum received_counts" do
|
147
153
|
p = Packet.new("tgt","pkt")
|
148
|
-
|
154
|
+
if 0.class == Integer
|
155
|
+
# Ruby version >= 2.4.0
|
156
|
+
expect {p.received_count = "5" }.to raise_error(ArgumentError, "received_count must be an Integer but is a String")
|
157
|
+
else
|
158
|
+
# Ruby version < 2.4.0
|
159
|
+
expect {p.received_count = "5" }.to raise_error(ArgumentError, "received_count must be a Fixnum but is a String")
|
160
|
+
end
|
149
161
|
end
|
150
162
|
end
|
151
163
|
|
@@ -164,7 +176,7 @@ module Cosmos
|
|
164
176
|
|
165
177
|
it "complains about non String hazardous_descriptions" do
|
166
178
|
p = Packet.new("tgt","pkt")
|
167
|
-
expect {p.hazardous_description = 5 }.to raise_error(ArgumentError, "hazardous_description must be a String but is a
|
179
|
+
expect {p.hazardous_description = 5.1 }.to raise_error(ArgumentError, "hazardous_description must be a String but is a Float")
|
168
180
|
end
|
169
181
|
end
|
170
182
|
|
@@ -23,7 +23,7 @@ module Cosmos
|
|
23
23
|
|
24
24
|
it "complains about non String names" do
|
25
25
|
expect { StructureItem.new(nil, 0, 8, :UINT, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "name must be a String but is a NilClass")
|
26
|
-
expect { StructureItem.new(5, 0, 8, :UINT, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "name must be a String but is a
|
26
|
+
expect { StructureItem.new(5.1, 0, 8, :UINT, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "name must be a String but is a Float")
|
27
27
|
end
|
28
28
|
|
29
29
|
it "complains about blank names" do
|
@@ -69,7 +69,13 @@ module Cosmos
|
|
69
69
|
|
70
70
|
describe "bit_offset=" do
|
71
71
|
it "compains about bad bit offsets types" do
|
72
|
-
|
72
|
+
if 0.class == Integer
|
73
|
+
# Ruby version >= 2.4.0
|
74
|
+
expect { StructureItem.new("test", nil, 8, :UINT, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: bit_offset must be an Integer")
|
75
|
+
else
|
76
|
+
# Ruby version < 2.4.0
|
77
|
+
expect { StructureItem.new("test", nil, 8, :UINT, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: bit_offset must be a Fixnum")
|
78
|
+
end
|
73
79
|
end
|
74
80
|
|
75
81
|
it "complains about unaligned bit offsets" do
|
@@ -85,7 +91,13 @@ module Cosmos
|
|
85
91
|
|
86
92
|
describe "bit_size=" do
|
87
93
|
it "complains about bad bit sizes types" do
|
88
|
-
|
94
|
+
if 0.class == Integer
|
95
|
+
# Ruby version >= 2.4.0
|
96
|
+
expect { StructureItem.new("test", 0, nil, :UINT, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: bit_size must be an Integer")
|
97
|
+
else
|
98
|
+
# Ruby version < 2.4.0
|
99
|
+
expect { StructureItem.new("test", 0, nil, :UINT, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: bit_size must be a Fixnum")
|
100
|
+
end
|
89
101
|
end
|
90
102
|
|
91
103
|
it "complains about 0 size INT, UINT, and FLOAT" do
|
@@ -110,7 +122,13 @@ module Cosmos
|
|
110
122
|
|
111
123
|
describe "array_size=" do
|
112
124
|
it "complains about bad array size types" do
|
113
|
-
|
125
|
+
if 0.class == Integer
|
126
|
+
# Ruby version >= 2.4.0
|
127
|
+
expect { StructureItem.new("test", 0, 8, :UINT, :BIG_ENDIAN, "") }.to raise_error(ArgumentError, "TEST: array_size must be an Integer")
|
128
|
+
else
|
129
|
+
# Ruby version < 2.4.0
|
130
|
+
expect { StructureItem.new("test", 0, 8, :UINT, :BIG_ENDIAN, "") }.to raise_error(ArgumentError, "TEST: array_size must be a Fixnum")
|
131
|
+
end
|
114
132
|
end
|
115
133
|
|
116
134
|
it "complains about array size != multiple of bit size" do
|
@@ -70,6 +70,72 @@ module Cosmos
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
+
describe "get_interface_info" do
|
74
|
+
it "returns interface info" do
|
75
|
+
state, clients, tx_q_size, rx_q_size, bytes_tx, bytes_rx, cmd_cnt, tlm_cnt = get_interface_info("INST_INT")
|
76
|
+
connect_interface("INST_INT")
|
77
|
+
expect(state).to eql "CONNECTED"
|
78
|
+
disconnect_interface("INST_INT")
|
79
|
+
expect(clients).to be >= 0
|
80
|
+
expect(tx_q_size).to be >= 0
|
81
|
+
expect(rx_q_size).to be >= 0
|
82
|
+
expect(bytes_tx).to be >= 0
|
83
|
+
expect(bytes_rx).to be >= 0
|
84
|
+
expect(cmd_cnt).to be >= 0
|
85
|
+
expect(tlm_cnt).to be >= 0
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "get_router_info" do
|
90
|
+
it "returns router info" do
|
91
|
+
connect_router("PREIDENTIFIED_ROUTER")
|
92
|
+
state, clients, tx_q_size, rx_q_size, bytes_tx, bytes_rx, pkts_rcvd, pkts_sent = get_router_info("PREIDENTIFIED_ROUTER")
|
93
|
+
disconnect_router("PREIDENTIFIED_ROUTER")
|
94
|
+
expect(state).to eql "CONNECTED"
|
95
|
+
expect(clients).to be >= 0
|
96
|
+
expect(tx_q_size).to be >= 0
|
97
|
+
expect(rx_q_size).to be >= 0
|
98
|
+
expect(bytes_tx).to be >= 0
|
99
|
+
expect(bytes_rx).to be >= 0
|
100
|
+
expect(pkts_rcvd).to be >= 0
|
101
|
+
expect(pkts_sent).to be >= 0
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "get_target_info" do
|
106
|
+
it "returns target info" do
|
107
|
+
cmd_cnt, tlm_cnt = get_target_info("INST")
|
108
|
+
expect(cmd_cnt).to be >= 0
|
109
|
+
expect(tlm_cnt).to be >= 0
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe "get_cmd_cnt" do
|
114
|
+
it "returns cmd count" do
|
115
|
+
expect(get_cmd_cnt("INST", "COLLECT")).to be >= 0
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "get_tlm_cnt" do
|
120
|
+
it "returns tlm count" do
|
121
|
+
expect(get_tlm_cnt("INST", "HEALTH_STATUS")).to be >= 0
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe "get_packet_logger_info" do
|
126
|
+
it "returns packet logger info" do
|
127
|
+
interfaces, cmd_logging, cmd_q_size, cmd_filename, cmd_file_size,
|
128
|
+
tlm_logging, tlm_q_size, tlm_filename, tlm_file_size, = get_packet_logger_info("DEFAULT")
|
129
|
+
expect(interfaces).to include("INST_INT")
|
130
|
+
expect(cmd_logging).to eql true
|
131
|
+
expect(cmd_q_size).to be >= 0
|
132
|
+
expect(cmd_file_size).to be >= 0
|
133
|
+
expect(tlm_logging).to eql true
|
134
|
+
expect(tlm_q_size).to be >= 0
|
135
|
+
expect(tlm_file_size).to be >= 0
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
73
139
|
describe "connect_router, disconnect_router, get_router_names, router_state" do
|
74
140
|
it "returns connect, disconnect, and list the routers CTS-11" do
|
75
141
|
expect(get_router_names).to include("PREIDENTIFIED_ROUTER")
|
@@ -0,0 +1,144 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
|
3
|
+
# Copyright 2014 Ball Aerospace & Technologies Corp.
|
4
|
+
# All Rights Reserved.
|
5
|
+
#
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
7
|
+
# under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
10
|
+
|
11
|
+
require 'spec_helper'
|
12
|
+
require 'cosmos/script'
|
13
|
+
require 'tempfile'
|
14
|
+
|
15
|
+
module Cosmos
|
16
|
+
|
17
|
+
describe Extract do
|
18
|
+
|
19
|
+
describe "add_cmd_parameter" do
|
20
|
+
it "should remove quotes and preserve quoted strings" do
|
21
|
+
cmd_params = {}
|
22
|
+
add_cmd_parameter('TEST', '"3"', cmd_params)
|
23
|
+
expect(cmd_params['TEST']).to eql('3')
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should convert unquoted strings to the correct value type" do
|
27
|
+
cmd_params = {}
|
28
|
+
add_cmd_parameter('TEST', '3', cmd_params)
|
29
|
+
expect(cmd_params['TEST']).to eql(3)
|
30
|
+
add_cmd_parameter('TEST2', '3.0', cmd_params)
|
31
|
+
expect(cmd_params['TEST2']).to eql(3.0)
|
32
|
+
add_cmd_parameter('TEST3', '0xA', cmd_params)
|
33
|
+
expect(cmd_params['TEST3']).to eql(0xA)
|
34
|
+
add_cmd_parameter('TEST4', '3e3', cmd_params)
|
35
|
+
expect(cmd_params['TEST4']).to eql(3e3)
|
36
|
+
add_cmd_parameter('TEST5', 'Ryan', cmd_params)
|
37
|
+
expect(cmd_params['TEST5']).to eql('Ryan')
|
38
|
+
add_cmd_parameter('TEST6', '3 4', cmd_params)
|
39
|
+
expect(cmd_params['TEST6']).to eql('3 4')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "extract_fields_from_cmd_text" do
|
44
|
+
it "should complain about empty strings" do
|
45
|
+
expect { extract_fields_from_cmd_text("") }.to raise_error(/text must not be empty/)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should complain about strings that end in with but have no other text" do
|
49
|
+
expect { extract_fields_from_cmd_text("TEST COMMAND with") }.to raise_error(/must be followed by parameters/)
|
50
|
+
expect { extract_fields_from_cmd_text("TEST COMMAND with ") }.to raise_error(/must be followed by parameters/)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should complain if target name or packet name are missing" do
|
54
|
+
expect { extract_fields_from_cmd_text("TEST") }.to raise_error(/Both Target Name and Command Name must be given/)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should complain if there are too many words before with" do
|
58
|
+
expect { extract_fields_from_cmd_text("TEST TEST TEST") }.to raise_error(/Only Target Name and Command Name must be given/)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should complain if any key value pairs are misformed" do
|
62
|
+
expect { extract_fields_from_cmd_text("TEST TEST with KEY VALUE, KEY VALUE, VALUE") }.to raise_error(/Missing value for last command parameter/)
|
63
|
+
expect { extract_fields_from_cmd_text("TEST TEST with KEY VALUE KEY VALUE") }.to raise_error(/Missing comma in command parameters/)
|
64
|
+
expect { extract_fields_from_cmd_text("TEST TEST with KEY VALUE KEY, KEY VALUE") }.to raise_error(/Missing comma in command parameters/)
|
65
|
+
expect { extract_fields_from_cmd_text("TEST TEST with KEY VALUE, KEY") }.to raise_error(/Missing value for last command parameter/)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should parse commands correctly" do
|
69
|
+
expect(extract_fields_from_cmd_text("TARGET PACKET with KEY1 VALUE1, KEY2 2, KEY3 '3', KEY4 4.0")).to eql(
|
70
|
+
['TARGET', 'PACKET', {'KEY1' => 'VALUE1', 'KEY2' => 2, 'KEY3' => '3', 'KEY4' => 4.0}])
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should handle multiple array parameters" do
|
74
|
+
expect(extract_fields_from_cmd_text("TARGET PACKET with KEY1 [1,2,3,4], KEY2 2, KEY3 '3', KEY4 [5, 6, 7, 8]")).to eql(
|
75
|
+
['TARGET', 'PACKET', {'KEY1' => [1,2,3,4], 'KEY2' => 2, 'KEY3' => '3', 'KEY4' => [5,6,7,8]}])
|
76
|
+
expect(extract_fields_from_cmd_text("TARGET PACKET with KEY1 [1,2,3,4], KEY2 2, KEY3 '3', KEY4 ['1', '2', '3', '4']")).to eql(
|
77
|
+
['TARGET', 'PACKET', {'KEY1' => [1,2,3,4], 'KEY2' => 2, 'KEY3' => '3', 'KEY4' => ['1', '2', '3', '4']}])
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "extract_fields_from_tlm_text" do
|
82
|
+
it "should require exactly TARGET_NAME PACKET_NAME ITEM_NAME" do
|
83
|
+
expect { extract_fields_from_tlm_text("") }.to raise_error(/Telemetry Item must be specified as/)
|
84
|
+
expect { extract_fields_from_tlm_text("TARGET") }.to raise_error(/Telemetry Item must be specified as/)
|
85
|
+
expect { extract_fields_from_tlm_text("TARGET PACKET") }.to raise_error(/Telemetry Item must be specified as/)
|
86
|
+
expect { extract_fields_from_tlm_text("TARGET PACKET ") }.to raise_error(/Telemetry Item must be specified as/)
|
87
|
+
expect { extract_fields_from_tlm_text("TARGET PACKET ITEM OTHER") }.to raise_error(/Telemetry Item must be specified as/)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should parse telemetry names correctly" do
|
91
|
+
expect(extract_fields_from_tlm_text("TARGET PACKET ITEM")).to eql(['TARGET', 'PACKET', 'ITEM'])
|
92
|
+
expect(extract_fields_from_tlm_text(" TARGET PACKET ITEM ")).to eql(['TARGET', 'PACKET', 'ITEM'])
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "extract_fields_from_set_tlm_text" do
|
97
|
+
it "should complain if formatted incorrectly" do
|
98
|
+
expect { extract_fields_from_set_tlm_text("") }.to raise_error(/Set Telemetry Item must be specified as/)
|
99
|
+
expect { extract_fields_from_set_tlm_text("TARGET") }.to raise_error(/Set Telemetry Item must be specified as/)
|
100
|
+
expect { extract_fields_from_set_tlm_text("TARGET PACKET") }.to raise_error(/Set Telemetry Item must be specified as/)
|
101
|
+
expect { extract_fields_from_set_tlm_text("TARGET PACKET ITEM") }.to raise_error(/Set Telemetry Item must be specified as/)
|
102
|
+
expect { extract_fields_from_set_tlm_text("TARGET PACKET ITEM=") }.to raise_error(/Set Telemetry Item must be specified as/)
|
103
|
+
expect { extract_fields_from_set_tlm_text("TARGET PACKET ITEM= ") }.to raise_error(/Set Telemetry Item must be specified as/)
|
104
|
+
expect { extract_fields_from_set_tlm_text("TARGET PACKET ITEM =") }.to raise_error(/Set Telemetry Item must be specified as/)
|
105
|
+
expect { extract_fields_from_set_tlm_text("TARGET PACKET ITEM = ") }.to raise_error(/Set Telemetry Item must be specified as/)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should parse set_tlm text correctly" do
|
109
|
+
expect(extract_fields_from_set_tlm_text("TARGET PACKET ITEM= 5")).to eql(['TARGET', 'PACKET', 'ITEM', 5])
|
110
|
+
expect(extract_fields_from_set_tlm_text("TARGET PACKET ITEM = 5")).to eql(['TARGET', 'PACKET', 'ITEM', 5])
|
111
|
+
expect(extract_fields_from_set_tlm_text("TARGET PACKET ITEM =5")).to eql(['TARGET', 'PACKET', 'ITEM', 5])
|
112
|
+
expect(extract_fields_from_set_tlm_text("TARGET PACKET ITEM=5")).to eql(['TARGET', 'PACKET', 'ITEM', 5])
|
113
|
+
expect(extract_fields_from_set_tlm_text("TARGET PACKET ITEM = 5.0")).to eql(['TARGET', 'PACKET', 'ITEM', 5.0])
|
114
|
+
expect(extract_fields_from_set_tlm_text("TARGET PACKET ITEM = Ryan")).to eql(['TARGET', 'PACKET', 'ITEM', 'Ryan'])
|
115
|
+
expect(extract_fields_from_set_tlm_text("TARGET PACKET ITEM = [1,2,3]")).to eql(['TARGET', 'PACKET', 'ITEM', [1,2,3]])
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "extract_fields_from_check_text" do
|
120
|
+
it "should complain if formatted incorrectly" do
|
121
|
+
expect { extract_fields_from_check_text("") }.to raise_error(/Check improperly specified/)
|
122
|
+
expect { extract_fields_from_check_text("TARGET") }.to raise_error(/Check improperly specified/)
|
123
|
+
expect { extract_fields_from_check_text("TARGET PACKET") }.to raise_error(/Check improperly specified/)
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should support no comparison" do
|
127
|
+
expect(extract_fields_from_check_text("TARGET PACKET ITEM")).to eql(['TARGET', 'PACKET', 'ITEM', nil])
|
128
|
+
expect(extract_fields_from_check_text("TARGET PACKET ITEM ")).to eql(['TARGET', 'PACKET', 'ITEM', nil])
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should support comparisons" do
|
132
|
+
expect(extract_fields_from_check_text("TARGET PACKET ITEM == 5")).to eql(['TARGET', 'PACKET', 'ITEM', '== 5'])
|
133
|
+
expect(extract_fields_from_check_text("TARGET PACKET ITEM > 5")).to eql(['TARGET', 'PACKET', 'ITEM', '> 5'])
|
134
|
+
expect(extract_fields_from_check_text("TARGET PACKET ITEM < 5")).to eql(['TARGET', 'PACKET', 'ITEM', '< 5'])
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should complain about trying to do an = comparison" do
|
138
|
+
expect { extract_fields_from_check_text("TARGET PACKET ITEM = 5") }.to raise_error(/ERROR: Use/)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
data/spec/script/tools_spec.rb
CHANGED
@@ -63,7 +63,7 @@ module Cosmos
|
|
63
63
|
allow_any_instance_of(Object).to receive(:sleep)
|
64
64
|
allow_any_instance_of(Object).to receive(:cosmos_script_sleep).and_return(true)
|
65
65
|
allow(Cosmos).to receive(:run_process)
|
66
|
-
expect { display("HI") }.to raise_error(RuntimeError, /
|
66
|
+
expect { display("HI") }.to raise_error(RuntimeError, /Could not display HI/)
|
67
67
|
end
|
68
68
|
|
69
69
|
it "complains if the screen doesn't exist" do
|
@@ -83,7 +83,7 @@ module Cosmos
|
|
83
83
|
allow_any_instance_of(Object).to receive(:sleep)
|
84
84
|
allow_any_instance_of(Object).to receive(:cosmos_script_sleep).and_return(true)
|
85
85
|
allow(Cosmos).to receive(:run_process)
|
86
|
-
expect { clear("HI") }.to raise_error(RuntimeError, /
|
86
|
+
expect { clear("HI") }.to raise_error(RuntimeError, /Could not clear HI/)
|
87
87
|
end
|
88
88
|
|
89
89
|
it "complains if the screen doesn't exist" do
|
@@ -92,6 +92,21 @@ module Cosmos
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
+
describe "clear_all" do
|
96
|
+
it "closes all telemetry viewer screens" do
|
97
|
+
allow_any_instance_of(JsonDRbObject).to receive(:clear_all)
|
98
|
+
clear_all
|
99
|
+
end
|
100
|
+
|
101
|
+
it "complains if unable to start telemetry viewer" do
|
102
|
+
# Avoid the needless delay by stubbing sleep
|
103
|
+
allow_any_instance_of(Object).to receive(:sleep)
|
104
|
+
allow_any_instance_of(Object).to receive(:cosmos_script_sleep).and_return(true)
|
105
|
+
allow(Cosmos).to receive(:run_process)
|
106
|
+
expect { clear_all }.to raise_error(RuntimeError, /Could not clear_all/)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
95
110
|
describe "ScriptRunnerFrame methods" do
|
96
111
|
it "calls various ScriptRunnerFrame methods" do
|
97
112
|
class Dummy; def method_missing(meth, *args, &block); end; end
|
data/spec/system/system_spec.rb
CHANGED
@@ -43,7 +43,7 @@ module Cosmos
|
|
43
43
|
describe "instance" do
|
44
44
|
it "creates default ports" do
|
45
45
|
# Don't check the actual port numbers but just that they exist
|
46
|
-
expect(System.ports.keys).to eql %w(CTS_API TLMVIEWER_API CTS_PREIDENTIFIED)
|
46
|
+
expect(System.ports.keys).to eql %w(CTS_API TLMVIEWER_API CTS_PREIDENTIFIED CTS_CMD_ROUTER)
|
47
47
|
end
|
48
48
|
|
49
49
|
it "creates default paths" do
|
@@ -1094,6 +1094,12 @@ module Cosmos
|
|
1094
1094
|
@api.disconnect_interface("INT")
|
1095
1095
|
@api.interface_state("INT")
|
1096
1096
|
@api.map_target_to_interface("INST", "INT")
|
1097
|
+
@api.get_interface_info("INT")
|
1098
|
+
@api.get_target_info("INST")
|
1099
|
+
@api.get_cmd_cnt("INST", "COLLECT")
|
1100
|
+
@api.get_tlm_cnt("INST", "HEALTH_STATUS")
|
1101
|
+
@api.get_router_info("ROUTE")
|
1102
|
+
@api.get_packet_logger_info('DEFAULT')
|
1097
1103
|
@api.get_router_names
|
1098
1104
|
@api.connect_router("ROUTE")
|
1099
1105
|
@api.disconnect_router("ROUTE")
|
@@ -55,7 +55,7 @@ module Cosmos
|
|
55
55
|
it "creates the CTS in production mode" do
|
56
56
|
# Production mode means we start logging
|
57
57
|
expect_any_instance_of(PacketLogging).to receive(:start)
|
58
|
-
cts = CmdTlmServer.new(
|
58
|
+
cts = CmdTlmServer.new(CmdTlmServer::DEFAULT_CONFIG_FILE, true)
|
59
59
|
# Verify we disabled the ability to stop logging
|
60
60
|
expect(CmdTlmServer.json_drb.method_whitelist).to include('start_logging')
|
61
61
|
expect(CmdTlmServer.json_drb.method_whitelist).not_to include('stop_logging')
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
|
3
|
+
# Copyright 2014 Ball Aerospace & Technologies Corp.
|
4
|
+
# All Rights Reserved.
|
5
|
+
#
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
7
|
+
# under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
10
|
+
|
11
|
+
require 'spec_helper'
|
12
|
+
require 'cosmos'
|
13
|
+
require 'cosmos/tools/table_manager/table_item_parser'
|
14
|
+
require 'cosmos/tools/table_manager/table_config'
|
15
|
+
require 'tempfile'
|
16
|
+
|
17
|
+
module Cosmos
|
18
|
+
|
19
|
+
describe TableItemParser do
|
20
|
+
|
21
|
+
describe "process_file" do
|
22
|
+
before(:each) do
|
23
|
+
@tc = TableConfig.new
|
24
|
+
end
|
25
|
+
|
26
|
+
it "handles errors parsing" do
|
27
|
+
tf = Tempfile.new('unittest')
|
28
|
+
tf.puts 'TABLE table LITTLE_ENDIAN ONE_DIMENSIONAL "Table"'
|
29
|
+
tf.puts ' APPEND_PARAMETER ITEM1 ZERO UINT 0 2 0 "Description"'
|
30
|
+
tf.close
|
31
|
+
expect { @tc.process_file(tf.path) }.to raise_error(ConfigParser::Error)
|
32
|
+
tf.unlink
|
33
|
+
end
|
34
|
+
|
35
|
+
it "renames items in TWO_DIMENSIONAL tables by appending their column number" do
|
36
|
+
tf = Tempfile.new('unittest')
|
37
|
+
tf.puts 'TABLE table LITTLE_ENDIAN TWO_DIMENSIONAL 100 "Table"'
|
38
|
+
tf.puts ' APPEND_PARAMETER FIRST 32 UINT 0 2 0 "Description"'
|
39
|
+
tf.puts ' APPEND_PARAMETER SECOND 32 UINT 0 2 0 "Description"'
|
40
|
+
tf.puts ' APPEND_PARAMETER THIRD 32 UINT 0 2 0 "Description"'
|
41
|
+
tf.close
|
42
|
+
@tc.process_file(tf.path)
|
43
|
+
items = @tc.table("TABLE").items.collect { |item_name, item| item_name }
|
44
|
+
expect(items.length).to eq 300
|
45
|
+
first = items.select { |item| item =~ /FIRST/ }
|
46
|
+
expect(first.length).to eq 100
|
47
|
+
expect(first.sort[0]).to eq 'FIRST0'
|
48
|
+
expect(first.sort[-1]).to eq 'FIRST99'
|
49
|
+
second = items.select { |item| item =~ /SECOND/ }
|
50
|
+
expect(second.length).to eq 100
|
51
|
+
expect(second.sort[0]).to eq 'SECOND0'
|
52
|
+
expect(second.sort[-1]).to eq 'SECOND99'
|
53
|
+
third = items.select { |item| item =~ /THIRD/ }
|
54
|
+
expect(third.length).to eq 100
|
55
|
+
expect(third.sort[0]).to eq 'THIRD0'
|
56
|
+
expect(third.sort[-1]).to eq 'THIRD99'
|
57
|
+
tf.unlink
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|