cosmos 3.3.3 → 3.4.0
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/.gitattributes +2 -0
- data/.travis.yml +2 -1
- data/Gemfile +4 -3
- data/Manifest.txt +22 -0
- data/autohotkey/tools/handbook_creator.ahk +9 -0
- data/autohotkey/tools/packet_viewer.ahk +4 -0
- data/bin/exchndl20-x64.dll +0 -0
- data/bin/exchndl20.dll +0 -0
- data/bin/exchndl21-x64.dll +0 -0
- data/bin/exchndl21.dll +0 -0
- data/bin/exchndl22-x64.dll +0 -0
- data/bin/exchndl22.dll +0 -0
- data/bin/mgwhelp-x64.dll +0 -0
- data/bin/mgwhelp.dll +0 -0
- data/cosmos.gemspec +1 -0
- data/data/crc.txt +30 -24
- data/demo/config/data/crc.txt +3 -3
- data/demo/config/tools/handbook_creator/templates/command_packets.html.erb +3 -1
- data/demo/config/tools/handbook_creator/templates/telemetry_packets.html.erb +3 -1
- data/demo/procedures/cosmos_api_test.rb +1 -1
- data/ext/cosmos/ext/low_fragmentation_array/low_fragmentation_array.c +4 -0
- data/ext/cosmos/ext/platform/platform.c +22 -2
- data/ext/cosmos/ext/structure/structure.c +631 -104
- data/ext/cosmos/ext/telemetry/telemetry.c +3 -2
- data/lib/cosmos/gui/line_graph/line_graph_drawing.rb +71 -92
- data/lib/cosmos/gui/line_graph/overview_graph.rb +1 -1
- data/lib/cosmos/gui/qt.rb +38 -24
- data/lib/cosmos/gui/text/ruby_editor.rb +1 -1
- data/lib/cosmos/packets/binary_accessor.rb +1 -288
- data/lib/cosmos/packets/telemetry.rb +2 -1
- data/lib/cosmos/script/cmd_tlm_server.rb +110 -0
- data/lib/cosmos/script/commands.rb +166 -0
- data/lib/cosmos/script/extract.rb +2 -2
- data/lib/cosmos/script/limits.rb +108 -0
- data/lib/cosmos/script/script.rb +28 -1487
- data/lib/cosmos/script/scripting.rb +889 -0
- data/lib/cosmos/script/telemetry.rb +174 -0
- data/lib/cosmos/script/tools.rb +138 -0
- data/lib/cosmos/streams/stream_protocol.rb +9 -6
- data/lib/cosmos/system/target.rb +55 -38
- data/lib/cosmos/tools/cmd_tlm_server/api.rb +6 -3
- data/lib/cosmos/tools/cmd_tlm_server/connections.rb +0 -1
- data/lib/cosmos/tools/cmd_tlm_server/gui/interfaces_tab.rb +17 -7
- data/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb +15 -4
- data/lib/cosmos/tools/handbook_creator/handbook_creator.rb +15 -8
- data/lib/cosmos/tools/handbook_creator/handbook_creator_config.rb +41 -13
- data/lib/cosmos/tools/packet_viewer/packet_viewer.rb +18 -1
- data/lib/cosmos/tools/tlm_viewer/widgets/canvasline_widget.rb +1 -1
- data/lib/cosmos/tools/tlm_viewer/widgets/canvaslinevalue_widget.rb +1 -1
- data/lib/cosmos/tools/tlm_viewer/widgets/limitsbar_widget.rb +1 -1
- data/lib/cosmos/tools/tlm_viewer/widgets/rangebar_widget.rb +1 -1
- data/lib/cosmos/top_level.rb +1 -1
- data/lib/cosmos/utilities/ruby_lex_utils.rb +1 -1
- data/lib/cosmos/version.rb +5 -5
- data/spec/gui/line_graph/line_clip_spec.rb +6 -6
- data/spec/gui/qt_spec.rb +102 -0
- data/spec/interfaces/interface_spec.rb +9 -9
- data/spec/interfaces/linc_interface_spec.rb +72 -15
- data/spec/interfaces/serial_interface_spec.rb +9 -9
- data/spec/interfaces/simulated_target_interface_spec.rb +7 -7
- data/spec/interfaces/stream_interface_spec.rb +4 -4
- data/spec/interfaces/tcpip_client_interface_spec.rb +8 -8
- data/spec/interfaces/tcpip_server_interface_spec.rb +9 -9
- data/spec/interfaces/udp_interface_spec.rb +20 -20
- data/spec/io/json_drb_spec.rb +4 -4
- data/spec/io/raw_logger_pair_spec.rb +20 -20
- data/spec/io/raw_logger_spec.rb +3 -3
- data/spec/io/tcpip_server_spec.rb +9 -9
- data/spec/io/udp_sockets_spec.rb +2 -2
- data/spec/io/win32_serial_driver_spec.rb +2 -2
- data/spec/packets/binary_accessor_spec.rb +143 -6
- data/spec/packets/commands_spec.rb +5 -5
- data/spec/packets/limits_spec.rb +15 -15
- data/spec/packets/packet_config_spec.rb +19 -19
- data/spec/packets/packet_item_limits_spec.rb +3 -3
- data/spec/packets/packet_item_spec.rb +4 -4
- data/spec/packets/packet_spec.rb +33 -33
- data/spec/packets/structure_item_spec.rb +19 -19
- data/spec/packets/telemetry_spec.rb +6 -6
- data/spec/script/cmd_tlm_server_spec.rb +110 -0
- data/spec/script/commands_disconnect_spec.rb +270 -0
- data/spec/script/commands_spec.rb +288 -0
- data/spec/script/limits_spec.rb +153 -0
- data/spec/script/script_spec.rb +32 -696
- data/spec/script/scripting_spec.rb +436 -0
- data/spec/script/telemetry_spec.rb +130 -0
- data/spec/script/tools_spec.rb +117 -0
- data/spec/spec_helper.rb +10 -5
- data/spec/streams/preidentified_stream_protocol_spec.rb +4 -4
- data/spec/streams/serial_stream_spec.rb +8 -8
- data/spec/streams/stream_protocol_spec.rb +4 -4
- data/spec/streams/tcpip_client_stream_spec.rb +3 -3
- data/spec/streams/tcpip_socket_stream_spec.rb +7 -7
- data/spec/streams/template_stream_protocol_spec.rb +1 -1
- data/spec/system/system_spec.rb +6 -6
- data/spec/system/target_spec.rb +2 -0
- data/spec/tools/cmd_tlm_server/api_spec.rb +17 -17
- data/spec/tools/cmd_tlm_server/cmd_tlm_server_config_spec.rb +5 -5
- data/spec/tools/cmd_tlm_server/interface_thread_spec.rb +3 -3
- data/spec/top_level/top_level_spec.rb +8 -8
- data/spec/utilities/csv_spec.rb +3 -3
- data/spec/utilities/message_log_spec.rb +3 -3
- data/spec/utilities/ruby_lex_utils_spec.rb +7 -7
- data/test/performance/config/tools/launcher/launcher_threads.txt +8 -1
- data/test/performance/tools/CmdTlmServerMemProf +1 -1
- data/test/performance/tools/TlmGrapherMemProf +19 -0
- data/test/performance/tools/TlmGrapherMemProf.bat +59 -0
- metadata +38 -2
|
@@ -0,0 +1,153 @@
|
|
|
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/script/script'
|
|
14
|
+
require 'tempfile'
|
|
15
|
+
|
|
16
|
+
module Cosmos
|
|
17
|
+
|
|
18
|
+
describe Script do
|
|
19
|
+
|
|
20
|
+
before(:all) do
|
|
21
|
+
cts = File.join(Cosmos::USERPATH,'config','tools','cmd_tlm_server','cmd_tlm_server.txt')
|
|
22
|
+
FileUtils.mkdir_p(File.dirname(cts))
|
|
23
|
+
File.open(cts,'w') do |file|
|
|
24
|
+
file.puts 'INTERFACE INST_INT interface.rb'
|
|
25
|
+
file.puts 'TARGET INST'
|
|
26
|
+
end
|
|
27
|
+
System.class_eval('@@instance = nil')
|
|
28
|
+
|
|
29
|
+
require 'cosmos/script'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
after(:all) do
|
|
33
|
+
clean_config()
|
|
34
|
+
FileUtils.rm_rf File.join(Cosmos::USERPATH,'config','tools')
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
before(:each) do
|
|
38
|
+
allow_any_instance_of(Interface).to receive(:connected?).and_return(true)
|
|
39
|
+
allow_any_instance_of(Interface).to receive(:disconnect)
|
|
40
|
+
allow_any_instance_of(Interface).to receive(:write)
|
|
41
|
+
allow_any_instance_of(Interface).to receive(:read)
|
|
42
|
+
|
|
43
|
+
@server = CmdTlmServer.new
|
|
44
|
+
shutdown_cmd_tlm()
|
|
45
|
+
initialize_script_module()
|
|
46
|
+
sleep 0.1
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
after(:each) do
|
|
50
|
+
@server.stop
|
|
51
|
+
shutdown_cmd_tlm()
|
|
52
|
+
sleep(0.1)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
describe "get_out_of_limits" do
|
|
56
|
+
it "gets all out of limits items" do
|
|
57
|
+
set_tlm_raw("INST HEALTH_STATUS TEMP1 = 0")
|
|
58
|
+
expect(get_out_of_limits).to include(["INST","HEALTH_STATUS","TEMP1",:RED_LOW])
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe "get_overall_limits_state" do
|
|
63
|
+
it "gets the overall limits state of the system" do
|
|
64
|
+
set_tlm_raw("INST HEALTH_STATUS TEMP1 = 0")
|
|
65
|
+
expect(get_overall_limits_state).to eql :RED
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "ignores specified items" do
|
|
69
|
+
ignore = []
|
|
70
|
+
ignore << %w(INST HEALTH_STATUS TEMP1)
|
|
71
|
+
ignore << %w(INST HEALTH_STATUS TEMP2)
|
|
72
|
+
ignore << %w(INST HEALTH_STATUS TEMP3)
|
|
73
|
+
ignore << %w(INST HEALTH_STATUS TEMP4)
|
|
74
|
+
ignore << %w(INST HEALTH_STATUS GROUND1STATUS)
|
|
75
|
+
ignore << %w(INST HEALTH_STATUS GROUND2STATUS)
|
|
76
|
+
expect(get_overall_limits_state(ignore)).to eql :STALE
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
describe "limits_enabled?, disable_limits, enable_limits" do
|
|
81
|
+
it "enables, disable, and check limits for an item" do
|
|
82
|
+
expect(limits_enabled?("INST HEALTH_STATUS TEMP1")).to be true
|
|
83
|
+
disable_limits("INST HEALTH_STATUS TEMP1")
|
|
84
|
+
expect(limits_enabled?("INST HEALTH_STATUS TEMP1")).to be false
|
|
85
|
+
enable_limits("INST HEALTH_STATUS TEMP1")
|
|
86
|
+
expect(limits_enabled?("INST HEALTH_STATUS TEMP1")).to be true
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
describe "get_limits, set_limits" do
|
|
91
|
+
it "gets and set limits for an item" do
|
|
92
|
+
expect(get_limits("INST", "HEALTH_STATUS", "TEMP1")).to eql [:DEFAULT, 1, true, -80.0, -70.0, 60.0, 80.0, -20.0, 20.0]
|
|
93
|
+
expect(set_limits("INST", "HEALTH_STATUS", "TEMP1", 1, 2, 5, 6, 3, 4)).to eql [:CUSTOM, 1, true, 1.0, 2.0, 5.0, 6.0, 3.0, 4.0]
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
describe "get_limits_groups, enable_limits_group, disable_limits_group" do
|
|
98
|
+
it "enables, disable, and get groups" do
|
|
99
|
+
expect(get_limits_groups).to include("FIRST")
|
|
100
|
+
enable_limits_group("FIRST")
|
|
101
|
+
disable_limits_group("FIRST")
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
describe "get_limits_sets, enable_limits_set, disable_limits_set" do
|
|
106
|
+
it "enables, disable, and get sets CTS-16" do
|
|
107
|
+
if get_limits_sets.include?(:CUSTOM)
|
|
108
|
+
expect(get_limits_sets).to eql [:DEFAULT,:TVAC,:CUSTOM]
|
|
109
|
+
else
|
|
110
|
+
expect(get_limits_sets).to eql [:DEFAULT,:TVAC]
|
|
111
|
+
end
|
|
112
|
+
set_limits_set(:TVAC)
|
|
113
|
+
expect(get_limits_set).to eql :TVAC
|
|
114
|
+
set_limits_set(:DEFAULT)
|
|
115
|
+
expect(get_limits_set).to eql :DEFAULT
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
describe "subscribe_limits_events, get_limits_event, unsubscribe_limits_events" do
|
|
120
|
+
it "raises an error if non_block and the queue is empty" do
|
|
121
|
+
id = subscribe_limits_events
|
|
122
|
+
expect { get_limits_event(id, true) }.to raise_error(ThreadError, "queue empty")
|
|
123
|
+
unsubscribe_limits_events(id)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it "subscribes and get limits change events" do
|
|
127
|
+
id = subscribe_limits_events
|
|
128
|
+
CmdTlmServer.instance.post_limits_event(:LIMITS_CHANGE, ['TGT','PKT','ITEM',:YELLOW,:RED])
|
|
129
|
+
result = get_limits_event(id, true)
|
|
130
|
+
expect(result[0]).to eql :LIMITS_CHANGE
|
|
131
|
+
unsubscribe_limits_events(id)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it "subscribes and get limits settings events" do
|
|
135
|
+
id = subscribe_limits_events
|
|
136
|
+
CmdTlmServer.instance.post_limits_event(:LIMITS_SETTINGS, ['TGT','PKT','ITEM',:DEFAULT])
|
|
137
|
+
result = get_limits_event(id, true)
|
|
138
|
+
expect(result[0]).to eql :LIMITS_SETTINGS
|
|
139
|
+
unsubscribe_limits_events(id)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it "handles unknown limits events" do
|
|
143
|
+
id = subscribe_limits_events
|
|
144
|
+
CmdTlmServer.instance.post_limits_event(:UNKNOWN, "This is a test")
|
|
145
|
+
result = get_limits_event(id, true)
|
|
146
|
+
expect(result[0]).to eql :UNKNOWN
|
|
147
|
+
unsubscribe_limits_events(id)
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
data/spec/script/script_spec.rb
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
require 'spec_helper'
|
|
12
12
|
require 'cosmos'
|
|
13
|
-
require 'cosmos/script
|
|
13
|
+
require 'cosmos/script'
|
|
14
14
|
require 'tempfile'
|
|
15
15
|
|
|
16
16
|
module Cosmos
|
|
@@ -34,714 +34,50 @@ module Cosmos
|
|
|
34
34
|
FileUtils.rm_rf File.join(Cosmos::USERPATH,'config','tools')
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
@server = CmdTlmServer.new
|
|
44
|
-
shutdown_cmd_tlm()
|
|
45
|
-
initialize_script_module()
|
|
46
|
-
sleep 0.1
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
after(:each) do
|
|
50
|
-
@server.stop
|
|
51
|
-
shutdown_cmd_tlm()
|
|
52
|
-
sleep(0.1)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
describe "cmd" do
|
|
56
|
-
it "sends a command" do
|
|
57
|
-
capture_io do |stdout|
|
|
58
|
-
cmd("INST ABORT")
|
|
59
|
-
expect(stdout.string).to match /cmd\(\'INST ABORT\'\)/ #'
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it "checks parameter ranges" do
|
|
64
|
-
expect { cmd("INST COLLECT with TYPE NORMAL, DURATION 20") }.to raise_error(/Command parameter 'INST COLLECT DURATION' = 20 not in valid range/)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it "prompts for a hazardous command" do
|
|
68
|
-
capture_io do |stdout|
|
|
69
|
-
expect(self).to receive(:gets) { 'y' } # Send hazardous command
|
|
70
|
-
cmd("INST COLLECT with TYPE SPECIAL")
|
|
71
|
-
|
|
72
|
-
expect(stdout.string).to match "Warning: Command INST COLLECT is Hazardous"
|
|
73
|
-
expect(stdout.string).to match /cmd\(\'INST COLLECT/ # '
|
|
74
|
-
stdout.rewind
|
|
75
|
-
|
|
76
|
-
expect(self).to receive(:gets) { 'n' } # Don't send hazardous
|
|
77
|
-
expect(self).to receive(:gets) { 'y' } # Stop running script
|
|
78
|
-
cmd("INST COLLECT with TYPE SPECIAL")
|
|
79
|
-
expect(stdout.string).to match "Warning: Command INST COLLECT is Hazardous"
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
describe "cmd_no_range_check" do
|
|
85
|
-
it "sends an out of range command" do
|
|
86
|
-
expect { cmd_no_range_check("INST COLLECT with TYPE NORMAL, DURATION 20") }.to_not raise_error
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it "prompts for a hazardous command" do
|
|
90
|
-
capture_io do |stdout|
|
|
91
|
-
expect(self).to receive(:gets) { 'y' } # Send hazardous command
|
|
92
|
-
cmd_no_range_check("INST COLLECT with TYPE SPECIAL")
|
|
93
|
-
|
|
94
|
-
expect(stdout.string).to match "Warning: Command INST COLLECT is Hazardous"
|
|
95
|
-
expect(stdout.string).to match /cmd\(\'INST COLLECT/ # '
|
|
96
|
-
stdout.rewind
|
|
97
|
-
|
|
98
|
-
expect(self).to receive(:gets) { 'n' } # Don't send hazardous
|
|
99
|
-
expect(self).to receive(:gets) { 'y' } # Stop running script
|
|
100
|
-
cmd_no_range_check("INST COLLECT with TYPE SPECIAL")
|
|
101
|
-
expect(stdout.string).to match "Warning: Command INST COLLECT is Hazardous"
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
describe "cmd_no_hazardous_check" do
|
|
107
|
-
it "checks parameter ranges" do
|
|
108
|
-
expect { cmd_no_hazardous_check("INST COLLECT with TYPE SPECIAL, DURATION 20") }.to raise_error(/Command parameter 'INST COLLECT DURATION' = 20 not in valid range/)
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
it "sends a hazardous command without prompting" do
|
|
112
|
-
capture_io do |stdout|
|
|
113
|
-
cmd_no_hazardous_check("INST COLLECT with TYPE SPECIAL")
|
|
114
|
-
|
|
115
|
-
expect(stdout.string).to match "Command INST COLLECT being sent ignoring hazardous warnings"
|
|
116
|
-
expect(stdout.string).to match /cmd\(\'INST COLLECT/ # '
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
describe "cmd_no_checks" do
|
|
122
|
-
it "sends an out of range hazardous command without prompting" do
|
|
123
|
-
capture_io do |stdout|
|
|
124
|
-
cmd_no_checks("INST COLLECT with TYPE SPECIAL, DURATION 20")
|
|
125
|
-
|
|
126
|
-
expect(stdout.string).to match "Command INST COLLECT being sent ignoring hazardous warnings"
|
|
127
|
-
expect(stdout.string).to match /cmd\(\'INST COLLECT/ # '
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
describe "cmd_raw" do
|
|
133
|
-
it "sends a command" do
|
|
134
|
-
capture_io do |stdout|
|
|
135
|
-
cmd_raw("INST ABORT")
|
|
136
|
-
expect(stdout.string).to match /cmd_raw\(\'INST ABORT\'\)/ # '
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
it "checks parameter ranges" do
|
|
141
|
-
expect { cmd_raw("INST COLLECT with TYPE 0, DURATION 20") }.to raise_error(/Command parameter 'INST COLLECT DURATION' = 20 not in valid range/) # '
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
it "prompts for a hazardous command" do
|
|
145
|
-
capture_io do |stdout|
|
|
146
|
-
expect(self).to receive(:gets) { 'y' } # Send hazardous command
|
|
147
|
-
cmd_raw("INST COLLECT with TYPE 1")
|
|
148
|
-
|
|
149
|
-
expect(stdout.string).to match "Warning: Command INST COLLECT is Hazardous"
|
|
150
|
-
expect(stdout.string).to match /cmd_raw\(\'INST COLLECT/ # '
|
|
151
|
-
stdout.rewind
|
|
152
|
-
|
|
153
|
-
expect(self).to receive(:gets) { 'n' } # Don't send hazardous
|
|
154
|
-
expect(self).to receive(:gets) { 'y' } # Stop running script
|
|
155
|
-
cmd_raw("INST COLLECT with TYPE 1")
|
|
156
|
-
expect(stdout.string).to match "Warning: Command INST COLLECT is Hazardous"
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
describe "cmd_raw_no_range_check" do
|
|
162
|
-
it "sends an out of range command" do
|
|
163
|
-
expect { cmd_raw_no_range_check("INST COLLECT with TYPE 0, DURATION 20") }.to_not raise_error
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
it "prompts for a hazardous command" do
|
|
167
|
-
capture_io do |stdout|
|
|
168
|
-
expect(self).to receive(:gets) { 'y' } # Send hazardous command
|
|
169
|
-
cmd_raw_no_range_check("INST COLLECT with TYPE 1")
|
|
170
|
-
|
|
171
|
-
expect(stdout.string).to match "Warning: Command INST COLLECT is Hazardous"
|
|
172
|
-
expect(stdout.string).to match /cmd_raw\(\'INST COLLECT/ # '
|
|
173
|
-
stdout.rewind
|
|
174
|
-
|
|
175
|
-
expect(self).to receive(:gets) { 'n' } # Don't send hazardous
|
|
176
|
-
expect(self).to receive(:gets) { 'y' } # Stop running script
|
|
177
|
-
cmd_raw_no_range_check("INST COLLECT with TYPE 1")
|
|
178
|
-
expect(stdout.string).to match "Warning: Command INST COLLECT is Hazardous"
|
|
179
|
-
end
|
|
180
|
-
end
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
describe "cmd_raw_no_hazardous_check" do
|
|
184
|
-
it "checks parameter ranges" do
|
|
185
|
-
expect { cmd_raw_no_hazardous_check("INST COLLECT with TYPE 1, DURATION 20") }.to raise_error(/Command parameter 'INST COLLECT DURATION' = 20 not in valid range/)
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
it "sends a hazardous command without prompting" do
|
|
189
|
-
capture_io do |stdout|
|
|
190
|
-
cmd_raw_no_hazardous_check("INST COLLECT with TYPE 1")
|
|
191
|
-
expect(stdout.string).to match "Command INST COLLECT being sent ignoring hazardous warnings"
|
|
192
|
-
expect(stdout.string).to match /cmd_raw\(\'INST COLLECT/ #'
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
describe "cmd_raw_no_checks" do
|
|
198
|
-
it "sends an out of range hazardous command without prompting" do
|
|
199
|
-
capture_io do |stdout|
|
|
200
|
-
cmd_raw_no_checks("INST COLLECT with TYPE 1, DURATION 20")
|
|
201
|
-
expect(stdout.string).to match "Command INST COLLECT being sent ignoring hazardous warnings"
|
|
202
|
-
expect(stdout.string).to match /cmd_raw\(\'INST COLLECT/ #'
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
describe "send_raw" do
|
|
208
|
-
it "sends data to the write_raw interface method" do
|
|
209
|
-
expect_any_instance_of(Interface).to receive(:write_raw).with('\x00')
|
|
210
|
-
send_raw('INST_INT', '\x00')
|
|
211
|
-
end
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
describe "send_raw_file" do
|
|
215
|
-
it "sends file data to the write_raw interface method" do
|
|
216
|
-
file = File.open('raw_test_file.bin','wb')
|
|
217
|
-
file.write '\x00\x01\x02\x03'
|
|
218
|
-
file.close
|
|
219
|
-
|
|
220
|
-
expect_any_instance_of(Interface).to receive(:write_raw).with('\x00\x01\x02\x03')
|
|
221
|
-
|
|
222
|
-
send_raw_file('INST_INT', 'raw_test_file.bin')
|
|
223
|
-
|
|
224
|
-
File.delete('raw_test_file.bin')
|
|
225
|
-
end
|
|
226
|
-
end
|
|
227
|
-
|
|
228
|
-
describe "get_cmd_list" do
|
|
229
|
-
it "returns all the target commands" do
|
|
230
|
-
list = get_cmd_list("INST")
|
|
231
|
-
# Only check for the collect command to make this test list dependent
|
|
232
|
-
# on the demo INST command definition file
|
|
233
|
-
expect(list).to include(["COLLECT", "Starts a collect on the instrument"])
|
|
234
|
-
end
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
describe "get_cmd_param_list" do
|
|
238
|
-
it "returns all the parameters for a command" do
|
|
239
|
-
list = get_cmd_param_list("INST", "COLLECT")
|
|
240
|
-
expect(list).to include(["TYPE", 0, {"NORMAL"=>0, "SPECIAL"=>1}, "Collect type", nil, nil, true])
|
|
241
|
-
end
|
|
242
|
-
end
|
|
243
|
-
|
|
244
|
-
describe "get_cmd_hazardous" do
|
|
245
|
-
it "returns whether a command is hazardous" do
|
|
246
|
-
expect(get_cmd_hazardous("INST", "COLLECT", {"TYPE"=>"NORMAL"})).to be_falsey
|
|
247
|
-
expect(get_cmd_hazardous("INST", "COLLECT", {"TYPE"=>"SPECIAL"})).to be_truthy
|
|
248
|
-
end
|
|
249
|
-
end
|
|
250
|
-
|
|
251
|
-
describe "tlm, tlm_raw, tlm_formatted, tlm_with_units, tlm_variable, set_tlm, set_tlm_raw" do
|
|
252
|
-
it "passes through to the cmd_tlm_server" do
|
|
253
|
-
expect {
|
|
254
|
-
expect(tlm("INST HEALTH_STATUS TEMP1")).to eql -100.0
|
|
255
|
-
expect(tlm_raw("INST HEALTH_STATUS TEMP1")).to eql 0
|
|
256
|
-
expect(tlm_formatted("INST HEALTH_STATUS TEMP1")).to eql "-100.000"
|
|
257
|
-
expect(tlm_with_units("INST HEALTH_STATUS TEMP1")).to eql "-100.000 C"
|
|
258
|
-
expect(tlm_variable("INST HEALTH_STATUS TEMP1", :RAW)).to eql 0
|
|
259
|
-
set_tlm("INST HEALTH_STATUS TEMP1 = 1")
|
|
260
|
-
set_tlm_raw("INST HEALTH_STATUS TEMP1 = 0")
|
|
261
|
-
}.to_not raise_error
|
|
262
|
-
end
|
|
263
|
-
end
|
|
264
|
-
|
|
265
|
-
describe "get_tlm_packet" do
|
|
266
|
-
it "gets the packet values" do
|
|
267
|
-
expect(get_tlm_packet("INST", "HEALTH_STATUS", :RAW)).to include(["TEMP1", 0, :RED_LOW])
|
|
268
|
-
end
|
|
269
|
-
end
|
|
270
|
-
|
|
271
|
-
describe "get_tlm_values" do
|
|
272
|
-
it "gets the given values" do
|
|
273
|
-
vals = get_tlm_values([["INST", "HEALTH_STATUS", "TEMP1"], ["INST", "HEALTH_STATUS", "TEMP2"]])
|
|
274
|
-
expect(vals[0][0]).to eql -100.0
|
|
275
|
-
expect(vals[1][0]).to eql :RED_LOW
|
|
276
|
-
expect(vals[2][0]).to eql [-80.0, -70.0, 60.0, 80.0, -20.0, 20.0]
|
|
277
|
-
expect(vals[3]).to eql :DEFAULT
|
|
278
|
-
end
|
|
279
|
-
end
|
|
280
|
-
|
|
281
|
-
describe "get_tlm_list" do
|
|
282
|
-
it "gets packets for a given target" do
|
|
283
|
-
expect(get_tlm_list("INST")).to include(["HEALTH_STATUS", "Health and status from the instrument"])
|
|
284
|
-
end
|
|
285
|
-
end
|
|
286
|
-
|
|
287
|
-
describe "get_tlm_item_list" do
|
|
288
|
-
it "gets telemetry for a given packet" do
|
|
289
|
-
expect(get_tlm_item_list("INST", "HEALTH_STATUS")).to include(["TEMP1",nil,"Temperature #1"])
|
|
290
|
-
end
|
|
291
|
-
end
|
|
292
|
-
|
|
293
|
-
describe "get_tlm_details" do
|
|
294
|
-
it "gets telemetry for a given packet" do
|
|
295
|
-
details = get_tlm_details([["INST", "HEALTH_STATUS", "TEMP1"], ["INST", "HEALTH_STATUS", "TEMP2"]])
|
|
296
|
-
expect(details[0]["name"]).to eql "TEMP1"
|
|
297
|
-
expect(details[1]["name"]).to eql "TEMP2"
|
|
298
|
-
end
|
|
299
|
-
end
|
|
300
|
-
|
|
301
|
-
describe "get_out_of_limits" do
|
|
302
|
-
it "gets all out of limits items" do
|
|
303
|
-
expect(get_out_of_limits).to include(["INST","HEALTH_STATUS","TEMP1",:RED_LOW])
|
|
304
|
-
end
|
|
305
|
-
end
|
|
306
|
-
|
|
307
|
-
describe "get_overall_limits_state" do
|
|
308
|
-
it "gets the overall limits state of the system" do
|
|
309
|
-
expect(get_overall_limits_state).to eql :RED
|
|
310
|
-
end
|
|
311
|
-
|
|
312
|
-
it "ignores specified items" do
|
|
313
|
-
ignore = []
|
|
314
|
-
ignore << %w(INST HEALTH_STATUS TEMP1)
|
|
315
|
-
ignore << %w(INST HEALTH_STATUS TEMP2)
|
|
316
|
-
ignore << %w(INST HEALTH_STATUS TEMP3)
|
|
317
|
-
ignore << %w(INST HEALTH_STATUS TEMP4)
|
|
318
|
-
ignore << %w(INST HEALTH_STATUS GROUND1STATUS)
|
|
319
|
-
ignore << %w(INST HEALTH_STATUS GROUND2STATUS)
|
|
320
|
-
expect(get_overall_limits_state(ignore)).to eql :STALE
|
|
321
|
-
end
|
|
322
|
-
end
|
|
323
|
-
|
|
324
|
-
describe "limits_enabled?, disable_limits, enable_limits" do
|
|
325
|
-
it "enables, disable, and check limits for an item" do
|
|
326
|
-
expect(limits_enabled?("INST HEALTH_STATUS TEMP1")).to be_truthy
|
|
327
|
-
disable_limits("INST HEALTH_STATUS TEMP1")
|
|
328
|
-
expect(limits_enabled?("INST HEALTH_STATUS TEMP1")).to be_falsey
|
|
329
|
-
enable_limits("INST HEALTH_STATUS TEMP1")
|
|
330
|
-
expect(limits_enabled?("INST HEALTH_STATUS TEMP1")).to be_truthy
|
|
331
|
-
end
|
|
332
|
-
end
|
|
333
|
-
|
|
334
|
-
describe "get_limits, set_limits" do
|
|
335
|
-
it "gets and set limits for an item" do
|
|
336
|
-
expect(get_limits("INST", "HEALTH_STATUS", "TEMP1")).to eql [:DEFAULT, 1, true, -80.0, -70.0, 60.0, 80.0, -20.0, 20.0]
|
|
337
|
-
expect(set_limits("INST", "HEALTH_STATUS", "TEMP1", 1, 2, 5, 6, 3, 4)).to eql [:CUSTOM, 1, true, 1.0, 2.0, 5.0, 6.0, 3.0, 4.0]
|
|
338
|
-
end
|
|
339
|
-
end
|
|
340
|
-
|
|
341
|
-
describe "get_limits_groups, enable_limits_group, disable_limits_group" do
|
|
342
|
-
it "enables, disable, and get groups" do
|
|
343
|
-
expect(get_limits_groups).to include("FIRST")
|
|
344
|
-
enable_limits_group("FIRST")
|
|
345
|
-
disable_limits_group("FIRST")
|
|
346
|
-
end
|
|
347
|
-
end
|
|
348
|
-
|
|
349
|
-
describe "get_limits_sets, enable_limits_set, disable_limits_set" do
|
|
350
|
-
it "enables, disable, and get sets CTS-16" do
|
|
351
|
-
if get_limits_sets.include?(:CUSTOM)
|
|
352
|
-
expect(get_limits_sets).to eql [:DEFAULT,:TVAC,:CUSTOM]
|
|
353
|
-
else
|
|
354
|
-
expect(get_limits_sets).to eql [:DEFAULT,:TVAC]
|
|
355
|
-
end
|
|
356
|
-
set_limits_set(:TVAC)
|
|
357
|
-
expect(get_limits_set).to eql :TVAC
|
|
358
|
-
set_limits_set(:DEFAULT)
|
|
359
|
-
expect(get_limits_set).to eql :DEFAULT
|
|
360
|
-
end
|
|
361
|
-
end
|
|
362
|
-
|
|
363
|
-
describe "get_target_list" do
|
|
364
|
-
it "returns the list of targets" do
|
|
365
|
-
expect(get_target_list).to include("INST")
|
|
366
|
-
end
|
|
367
|
-
end
|
|
368
|
-
|
|
369
|
-
describe "subscribe_limits_events, get_limits_event, unsubscribe_limits_events" do
|
|
370
|
-
it "raises an error if non_block and the queue is empty" do
|
|
371
|
-
id = subscribe_limits_events
|
|
372
|
-
expect { get_limits_event(id, true) }.to raise_error(ThreadError, "queue empty")
|
|
373
|
-
unsubscribe_limits_events(id)
|
|
374
|
-
end
|
|
375
|
-
|
|
376
|
-
it "subscribes and get limits change events" do
|
|
377
|
-
id = subscribe_limits_events
|
|
378
|
-
CmdTlmServer.instance.post_limits_event(:LIMITS_CHANGE, ['TGT','PKT','ITEM',:YELLOW,:RED])
|
|
379
|
-
result = get_limits_event(id, true)
|
|
380
|
-
expect(result[0]).to eql :LIMITS_CHANGE
|
|
381
|
-
unsubscribe_limits_events(id)
|
|
382
|
-
end
|
|
383
|
-
|
|
384
|
-
it "subscribes and get limits settings events" do
|
|
385
|
-
id = subscribe_limits_events
|
|
386
|
-
CmdTlmServer.instance.post_limits_event(:LIMITS_SETTINGS, ['TGT','PKT','ITEM',:DEFAULT])
|
|
387
|
-
result = get_limits_event(id, true)
|
|
388
|
-
expect(result[0]).to eql :LIMITS_SETTINGS
|
|
389
|
-
unsubscribe_limits_events(id)
|
|
390
|
-
end
|
|
391
|
-
|
|
392
|
-
it "handles unknown limits events" do
|
|
393
|
-
id = subscribe_limits_events
|
|
394
|
-
CmdTlmServer.instance.post_limits_event(:UNKNOWN, "This is a test")
|
|
395
|
-
result = get_limits_event(id, true)
|
|
396
|
-
expect(result[0]).to eql :UNKNOWN
|
|
397
|
-
unsubscribe_limits_events(id)
|
|
398
|
-
end
|
|
399
|
-
end
|
|
400
|
-
|
|
401
|
-
describe "subscribe_packet_data, get_packet, unsubscribe_packet_data" do
|
|
402
|
-
it "raises an error if non_block and the queue is empty" do
|
|
403
|
-
id = subscribe_packet_data([["INST","HEALTH_STATUS"]])
|
|
404
|
-
expect { get_packet(id, true) }.to raise_error(ThreadError, "queue empty")
|
|
405
|
-
unsubscribe_packet_data(id)
|
|
406
|
-
end
|
|
407
|
-
|
|
408
|
-
it "subscribes and get limits events" do
|
|
409
|
-
id = subscribe_packet_data([["INST","HEALTH_STATUS"]])
|
|
410
|
-
CmdTlmServer.instance.post_packet(System.telemetry.packet("INST","HEALTH_STATUS"))
|
|
411
|
-
packet = get_packet(id, true)
|
|
412
|
-
expect(packet.target_name).to eql "INST"
|
|
413
|
-
expect(packet.packet_name).to eql "HEALTH_STATUS"
|
|
414
|
-
unsubscribe_packet_data(id)
|
|
415
|
-
end
|
|
416
|
-
end
|
|
417
|
-
|
|
418
|
-
describe "play_wav_file" do
|
|
419
|
-
it "plays a wav file if Qt is available" do
|
|
420
|
-
module Qt
|
|
421
|
-
def self.execute_in_main_thread(bool); yield; end
|
|
422
|
-
class CoreApplication; def self.instance; true; end; end;
|
|
423
|
-
class Sound; def self.isAvailable; true; end; end
|
|
424
|
-
end
|
|
425
|
-
expect(Qt::Sound).to receive(:play).with("sound.wav")
|
|
426
|
-
play_wav_file("sound.wav")
|
|
427
|
-
end
|
|
428
|
-
end
|
|
429
|
-
|
|
430
|
-
describe "status_bar" do
|
|
431
|
-
it "sets the ScriptRunner status bar" do
|
|
432
|
-
class ScriptRunner; end
|
|
433
|
-
sc = ScriptRunner.new
|
|
434
|
-
expect(sc).to receive(:script_set_status).with("HI")
|
|
435
|
-
status_bar("HI")
|
|
436
|
-
end
|
|
437
|
-
end
|
|
438
|
-
|
|
439
|
-
describe "ask_string, ask" do
|
|
440
|
-
it "gets user input" do
|
|
441
|
-
$stdout = StringIO.new
|
|
442
|
-
expect(self).to receive(:gets) { '10' }
|
|
443
|
-
expect(ask_string("")).to eql '10'
|
|
444
|
-
expect(self).to receive(:gets) { '10' }
|
|
445
|
-
expect(ask("")).to eql 10
|
|
446
|
-
$stdout = STDOUT
|
|
447
|
-
end
|
|
448
|
-
end
|
|
449
|
-
|
|
450
|
-
describe "prompt, prompt_message_box" do
|
|
451
|
-
it "prompts the user for input" do
|
|
452
|
-
$stdout = StringIO.new
|
|
453
|
-
expect(self).to receive(:gets) { 'message' }
|
|
454
|
-
expect(prompt("")).to eql 'message'
|
|
455
|
-
expect(self).to receive(:gets) { 'b1' }
|
|
456
|
-
expect(message_box("",["b1","b2"])).to eql 'b1'
|
|
457
|
-
$stdout = STDOUT
|
|
458
|
-
end
|
|
459
|
-
end
|
|
460
|
-
|
|
461
|
-
describe "check, check_formatted, check_with_units, check_raw" do
|
|
462
|
-
it "checks a telemetry item vs a condition" do
|
|
463
|
-
capture_io do |stdout|
|
|
464
|
-
check("INST HEALTH_STATUS TEMP1 == -100")
|
|
465
|
-
expect(stdout.string).to match "CHECK: INST HEALTH_STATUS TEMP1 == -100 success"
|
|
466
|
-
stdout.rewind
|
|
467
|
-
|
|
468
|
-
check("INST","HEALTH_STATUS","TEMP1","== -100")
|
|
469
|
-
expect(stdout.string).to match "CHECK: INST HEALTH_STATUS TEMP1 == -100 success"
|
|
470
|
-
stdout.rewind
|
|
471
|
-
|
|
472
|
-
check_formatted("INST HEALTH_STATUS TEMP1 == '-100.000'")
|
|
473
|
-
expect(stdout.string).to match "CHECK: INST HEALTH_STATUS TEMP1 == '-100.000' success"
|
|
474
|
-
stdout.rewind
|
|
475
|
-
|
|
476
|
-
check_formatted("INST","HEALTH_STATUS","TEMP1","== '-100.000'")
|
|
477
|
-
expect(stdout.string).to match "CHECK: INST HEALTH_STATUS TEMP1 == '-100.000' success"
|
|
478
|
-
stdout.rewind
|
|
479
|
-
|
|
480
|
-
check_with_units("INST HEALTH_STATUS TEMP1 == '-100.000 C'")
|
|
481
|
-
expect(stdout.string).to match "CHECK: INST HEALTH_STATUS TEMP1 == '-100.000 C' success"
|
|
482
|
-
stdout.rewind
|
|
483
|
-
|
|
484
|
-
check_with_units("INST","HEALTH_STATUS","TEMP1","== '-100.000 C'")
|
|
485
|
-
expect(stdout.string).to match "CHECK: INST HEALTH_STATUS TEMP1 == '-100.000 C' success"
|
|
486
|
-
stdout.rewind
|
|
487
|
-
|
|
488
|
-
check_raw("INST HEALTH_STATUS TEMP1")
|
|
489
|
-
expect(stdout.string).to match "CHECK: INST HEALTH_STATUS TEMP1 == 0"
|
|
490
|
-
end
|
|
491
|
-
|
|
492
|
-
check("INST HEALTH_STATUS TEMP1 < 0")
|
|
493
|
-
expect { check("INST HEALTH_STATUS TEMP1 > 0") }.to raise_error(Cosmos::CheckError)
|
|
494
|
-
end
|
|
495
|
-
end
|
|
496
|
-
|
|
497
|
-
describe "check_tolerance, check_tolerance_raw" do
|
|
498
|
-
it "checks a telemetry item vs tolerance" do
|
|
499
|
-
capture_io do |stdout|
|
|
500
|
-
check_tolerance("INST HEALTH_STATUS TEMP1", -100.0, 1)
|
|
501
|
-
expect(stdout.string).to match "CHECK: INST HEALTH_STATUS TEMP1 was within range"
|
|
502
|
-
stdout.rewind
|
|
503
|
-
|
|
504
|
-
expect { check_tolerance("INST HEALTH_STATUS TEMP1", -200.0, 1) }.to raise_error(CheckError, /CHECK: INST HEALTH_STATUS TEMP1 failed to be within range/)
|
|
505
|
-
stdout.rewind
|
|
506
|
-
|
|
507
|
-
check_tolerance_raw("INST HEALTH_STATUS TEMP1", 0, 1)
|
|
508
|
-
expect(stdout.string).to match "CHECK: INST HEALTH_STATUS TEMP1 was within range"
|
|
509
|
-
stdout.rewind
|
|
510
|
-
|
|
511
|
-
expect { check_tolerance_raw("INST HEALTH_STATUS TEMP1", 100, 1) }.to raise_error(CheckError, /CHECK: INST HEALTH_STATUS TEMP1 failed to be within range/)
|
|
512
|
-
stdout.rewind
|
|
513
|
-
end
|
|
514
|
-
end
|
|
515
|
-
end
|
|
516
|
-
|
|
517
|
-
describe "check_expression" do
|
|
518
|
-
it "checks an arbitrary expression" do
|
|
519
|
-
capture_io do |stdout|
|
|
520
|
-
check_expression("true == true")
|
|
521
|
-
expect(stdout.string).to match "CHECK: true == true is TRUE"
|
|
522
|
-
end
|
|
523
|
-
|
|
524
|
-
expect { check_expression("true == false") }.to raise_error(CheckError, "CHECK: true == false is FALSE")
|
|
525
|
-
end
|
|
526
|
-
end
|
|
527
|
-
|
|
528
|
-
describe "wait, wait_raw, wait_tolerance, wait_tolerance_raw" do
|
|
529
|
-
it "waits for telemetry check to be true" do
|
|
530
|
-
capture_io do |stdout|
|
|
531
|
-
# Success
|
|
532
|
-
wait("INST HEALTH_STATUS TEMP1 == -100.0", 5)
|
|
533
|
-
expect(stdout.string).to match "WAIT: INST HEALTH_STATUS TEMP1 == -100.0"
|
|
534
|
-
stdout.rewind
|
|
535
|
-
wait_raw("INST HEALTH_STATUS TEMP1 == 0", 5)
|
|
536
|
-
expect(stdout.string).to match "WAIT: INST HEALTH_STATUS TEMP1 == 0"
|
|
537
|
-
stdout.rewind
|
|
538
|
-
wait_tolerance("INST HEALTH_STATUS TEMP1", -100.0, 1, 5)
|
|
539
|
-
expect(stdout.string).to match "WAIT: INST HEALTH_STATUS TEMP1 was within"
|
|
540
|
-
stdout.rewind
|
|
541
|
-
wait_tolerance_raw("INST HEALTH_STATUS TEMP1", 0, 1, 5)
|
|
542
|
-
expect(stdout.string).to match "WAIT: INST HEALTH_STATUS TEMP1 was within"
|
|
543
|
-
stdout.rewind
|
|
544
|
-
|
|
545
|
-
# Failure
|
|
546
|
-
wait("INST HEALTH_STATUS TEMP1 == -200.0", 0.1)
|
|
547
|
-
expect(stdout.string).to match "WAIT: INST HEALTH_STATUS TEMP1 == -200.0 failed"
|
|
548
|
-
stdout.rewind
|
|
549
|
-
wait_raw("INST HEALTH_STATUS TEMP1 == 100", 0.1)
|
|
550
|
-
expect(stdout.string).to match "WAIT: INST HEALTH_STATUS TEMP1 == 100 failed"
|
|
551
|
-
stdout.rewind
|
|
552
|
-
wait_tolerance("INST HEALTH_STATUS TEMP1", -200.0, 1, 0.1)
|
|
553
|
-
expect(stdout.string).to match "WAIT: INST HEALTH_STATUS TEMP1 failed to be within"
|
|
554
|
-
stdout.rewind
|
|
555
|
-
wait_tolerance_raw("INST HEALTH_STATUS TEMP1", 100, 1, 0.1)
|
|
556
|
-
expect(stdout.string).to match "WAIT: INST HEALTH_STATUS TEMP1 failed to be within"
|
|
557
|
-
stdout.rewind
|
|
558
|
-
end
|
|
559
|
-
end
|
|
560
|
-
end
|
|
561
|
-
|
|
562
|
-
describe "wait_expression" do
|
|
563
|
-
it "waits for an expression to be true" do
|
|
564
|
-
capture_io do |stdout|
|
|
565
|
-
# Success
|
|
566
|
-
wait_expression("true == true", 5)
|
|
567
|
-
expect(stdout.string).to match "WAIT: true == true is TRUE"
|
|
568
|
-
stdout.rewind
|
|
569
|
-
|
|
570
|
-
# Failure
|
|
571
|
-
wait_expression("true == false", 0.1)
|
|
572
|
-
expect(stdout.string).to match "WAIT: true == false is FALSE"
|
|
573
|
-
stdout.rewind
|
|
574
|
-
end
|
|
575
|
-
end
|
|
576
|
-
end
|
|
577
|
-
|
|
578
|
-
describe "wait_check, wait_check_raw, wait_check_tolerance, wait_check_tolerance_raw" do
|
|
579
|
-
it "waits for telemetry check to be true" do
|
|
580
|
-
capture_io do |stdout|
|
|
581
|
-
# Success
|
|
582
|
-
wait_check("INST HEALTH_STATUS TEMP1 == -100.0", 5)
|
|
583
|
-
expect(stdout.string).to match "CHECK: INST HEALTH_STATUS TEMP1 == -100.0"
|
|
584
|
-
stdout.rewind
|
|
585
|
-
wait_check_raw("INST HEALTH_STATUS TEMP1 == 0", 5)
|
|
586
|
-
expect(stdout.string).to match "CHECK: INST HEALTH_STATUS TEMP1 == 0"
|
|
587
|
-
stdout.rewind
|
|
588
|
-
wait_check_tolerance("INST HEALTH_STATUS TEMP1", -100.0, 1, 5)
|
|
589
|
-
expect(stdout.string).to match "CHECK: INST HEALTH_STATUS TEMP1 was within"
|
|
590
|
-
stdout.rewind
|
|
591
|
-
wait_check_tolerance_raw("INST HEALTH_STATUS TEMP1", 0, 1, 5)
|
|
592
|
-
expect(stdout.string).to match "CHECK: INST HEALTH_STATUS TEMP1 was within"
|
|
593
|
-
stdout.rewind
|
|
594
|
-
end
|
|
595
|
-
|
|
596
|
-
# Failure
|
|
597
|
-
expect { wait_check("INST HEALTH_STATUS TEMP1 == -200.0", 0.1) }.to raise_error(CheckError, /CHECK: INST HEALTH_STATUS TEMP1 == -200.0 failed/)
|
|
598
|
-
expect { wait_check_raw("INST HEALTH_STATUS TEMP1 == 100", 0.1) }.to raise_error(CheckError, /CHECK: INST HEALTH_STATUS TEMP1 == 100 failed/)
|
|
599
|
-
expect { wait_check_tolerance("INST HEALTH_STATUS TEMP1", -200.0, 1, 0.1) }.to raise_error(CheckError, /CHECK: INST HEALTH_STATUS TEMP1 failed to be within/)
|
|
600
|
-
|
|
601
|
-
expect { wait_check_tolerance_raw("INST HEALTH_STATUS TEMP1", 100, 1, 0.1) }.to raise_error(CheckError, /CHECK: INST HEALTH_STATUS TEMP1 failed to be within/)
|
|
602
|
-
|
|
603
|
-
end
|
|
604
|
-
end
|
|
605
|
-
|
|
606
|
-
describe "wait_check_expression" do
|
|
607
|
-
it "waits for an expression to be true" do
|
|
608
|
-
capture_io do |stdout|
|
|
609
|
-
# Success
|
|
610
|
-
wait_check_expression("true == true", 5)
|
|
611
|
-
expect(stdout.string).to match "CHECK: true == true is TRUE"
|
|
612
|
-
stdout.rewind
|
|
613
|
-
end
|
|
614
|
-
|
|
615
|
-
# Failure
|
|
616
|
-
expect { wait_check_expression("true == false", 0.1) }.to raise_error(CheckError, /CHECK: true == false is FALSE/)
|
|
37
|
+
describe "require cosmos/script.rb" do
|
|
38
|
+
it "should raise when inside CmdTlmServer" do
|
|
39
|
+
save = $0
|
|
40
|
+
$0 = "CmdTlmServer"
|
|
41
|
+
expect { load 'cosmos/script.rb' }.to raise_error(/must not be required/)
|
|
42
|
+
$0 = save
|
|
617
43
|
end
|
|
618
|
-
end
|
|
619
44
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
expect { wait_check_packet("INST","HEALTH_STATUS",1,0.1) }.to raise_error(CheckError, /INST HEALTH_STATUS expected to be received 1 times but only received 0 times/)
|
|
45
|
+
it "should raise when inside Replay" do
|
|
46
|
+
save = $0
|
|
47
|
+
$0 = "Replay"
|
|
48
|
+
expect { load 'cosmos/script.rb' }.to raise_error(/must not be required/)
|
|
49
|
+
$0 = save
|
|
627
50
|
end
|
|
628
51
|
end
|
|
629
52
|
|
|
630
|
-
describe "
|
|
631
|
-
it "
|
|
632
|
-
|
|
53
|
+
describe "shutdown_cmd_tlm" do
|
|
54
|
+
it "should call shutdown on the server" do
|
|
55
|
+
set_cmd_tlm_disconnect(false)
|
|
56
|
+
expect($cmd_tlm_server).to receive(:shutdown)
|
|
57
|
+
shutdown_cmd_tlm()
|
|
633
58
|
end
|
|
634
|
-
end
|
|
635
|
-
|
|
636
|
-
describe "connect_interface, disconnect_interface, interface_state" do
|
|
637
|
-
it "connects, disconnect and return the state of the interface CTS-3" do
|
|
638
|
-
connect_interface("INST_INT")
|
|
639
|
-
expect(interface_state("INST_INT")).to eql "CONNECTED"
|
|
640
|
-
disconnect_interface("INST_INT")
|
|
641
|
-
end
|
|
642
|
-
end
|
|
643
59
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
60
|
+
it "should not call shutdown in disconnect mode" do
|
|
61
|
+
set_cmd_tlm_disconnect(true)
|
|
62
|
+
expect($cmd_tlm_server).to_not receive(:shutdown)
|
|
63
|
+
shutdown_cmd_tlm()
|
|
64
|
+
set_cmd_tlm_disconnect(false)
|
|
647
65
|
end
|
|
648
66
|
end
|
|
649
67
|
|
|
650
|
-
describe "
|
|
651
|
-
it "
|
|
652
|
-
expect(
|
|
653
|
-
|
|
654
|
-
expect(router_state("PREIDENTIFIED_ROUTER")).to eql "CONNECTED"
|
|
655
|
-
disconnect_router("PREIDENTIFIED_ROUTER")
|
|
68
|
+
describe "script_disconnect" do
|
|
69
|
+
it "should disconnect from the server" do
|
|
70
|
+
expect($cmd_tlm_server).to receive(:disconnect)
|
|
71
|
+
script_disconnect()
|
|
656
72
|
end
|
|
657
73
|
end
|
|
658
74
|
|
|
659
|
-
describe "
|
|
660
|
-
it "
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
start_cmd_log
|
|
666
|
-
start_tlm_log
|
|
667
|
-
get_cmd_log_filename
|
|
668
|
-
get_tlm_log_filename
|
|
669
|
-
stop_cmd_log
|
|
670
|
-
stop_tlm_log
|
|
671
|
-
get_cmd_log_filename
|
|
672
|
-
get_tlm_log_filename
|
|
673
|
-
start_raw_logging_interface
|
|
674
|
-
start_raw_logging_router
|
|
675
|
-
stop_raw_logging_interface
|
|
676
|
-
stop_raw_logging_router
|
|
677
|
-
|
|
678
|
-
start_new_server_message_log
|
|
679
|
-
sleep 0.1
|
|
680
|
-
filename = get_server_message_log_filename
|
|
681
|
-
expect(filename).to match /server_messages.txt/
|
|
682
|
-
end
|
|
683
|
-
end
|
|
684
|
-
|
|
685
|
-
describe "display" do
|
|
686
|
-
it "displays a telemetry viewer screen" do
|
|
687
|
-
expect { display("HI") }.to raise_error(RuntimeError, /HI could not be displayed/)
|
|
688
|
-
end
|
|
689
|
-
end
|
|
690
|
-
describe "clear" do
|
|
691
|
-
it "closes a telemetry viewer screen" do
|
|
692
|
-
expect { clear("HI") }.to raise_error(RuntimeError, /HI could not be cleared/)
|
|
693
|
-
end
|
|
694
|
-
end
|
|
695
|
-
|
|
696
|
-
describe "ScriptRunnerFrame methods" do
|
|
697
|
-
it "calls various ScriptRunnerFrame methods" do
|
|
698
|
-
class Dummy; def method_missing(meth, *args, &block); end; end
|
|
699
|
-
class ScriptRunnerFrame
|
|
700
|
-
def self.method_missing(meth, *args, &block); end
|
|
701
|
-
def self.instance; Dummy.new; end
|
|
702
|
-
end
|
|
703
|
-
set_line_delay(1.0)
|
|
704
|
-
get_line_delay
|
|
705
|
-
get_scriptrunner_message_log_filename
|
|
706
|
-
start_new_scriptrunner_message_log
|
|
707
|
-
disable_instrumentation do
|
|
708
|
-
value = 1
|
|
709
|
-
end
|
|
710
|
-
set_stdout_max_lines(1000)
|
|
711
|
-
insert_return
|
|
712
|
-
step_mode
|
|
713
|
-
run_mode
|
|
714
|
-
show_backtrace
|
|
715
|
-
end
|
|
716
|
-
end
|
|
717
|
-
|
|
718
|
-
describe "start" do
|
|
719
|
-
it "starts a script locally" do
|
|
720
|
-
class ScriptRunnerFrame; def self.instance; false; end; end
|
|
721
|
-
start("cosmos.rb")
|
|
722
|
-
end
|
|
723
|
-
|
|
724
|
-
it "starts a script without the .rb extension" do
|
|
725
|
-
class ScriptRunnerFrame; def self.instance; false; end; end
|
|
726
|
-
start("cosmos")
|
|
727
|
-
end
|
|
728
|
-
|
|
729
|
-
it "raises an error if the script can't be found" do
|
|
730
|
-
class ScriptRunnerFrame; def self.instance; false; end; end
|
|
731
|
-
expect { start("unknown_script.rb") }.to raise_error(RuntimeError)
|
|
732
|
-
end
|
|
733
|
-
|
|
734
|
-
it "starts a script within ScriptRunnerFrame" do
|
|
735
|
-
class ScriptRunnerFrame
|
|
736
|
-
@@instrumented_cache = {}
|
|
737
|
-
def self.instance; true; end
|
|
738
|
-
def self.instrumented_cache; @@instrumented_cache; end
|
|
739
|
-
def self.instrumented_cache=(value); @@instrumented_cache = value; end
|
|
740
|
-
def self.instrument_script(file_text, path, bool); "#"; end
|
|
741
|
-
end
|
|
742
|
-
start("cosmos.rb")
|
|
743
|
-
# This one should use the cached version
|
|
744
|
-
start("cosmos.rb")
|
|
75
|
+
describe "set_cmd_tlm_disconnect and get_cmd_tlm_disconnect" do
|
|
76
|
+
it "set and get the disconnect status" do
|
|
77
|
+
set_cmd_tlm_disconnect(true)
|
|
78
|
+
expect(get_cmd_tlm_disconnect()).to be true
|
|
79
|
+
set_cmd_tlm_disconnect(false)
|
|
80
|
+
expect(get_cmd_tlm_disconnect()).to be false
|
|
745
81
|
end
|
|
746
82
|
end
|
|
747
83
|
|