openc3-cosmos-demo 5.2.0 → 5.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23530204cfaedbd0c8ae5eb0af5a696e83da0bb20c838f0f291c7f0012dea548
4
- data.tar.gz: 1fd70065638e1fd360247607715766fc7a300015de033eed33a6a61823349ba6
3
+ metadata.gz: 235a69629911dd8dc15706733821bf9312faeac565ad81973054a3b44c021df3
4
+ data.tar.gz: 92ba9c815129d51a34972c607307b58f17243c72a955d6e1e70c6c84f6af9678
5
5
  SHA512:
6
- metadata.gz: 4357fd9b36217037c237d6b09925570e836169c6c188089590886df46fc97faf501db34743620f945fcdee6f541c0c7c32eb3135d898ab8199393ca1543d9db7
7
- data.tar.gz: 01e244d8ffd4504e09ee54058dd7b6b8f457bec4bf0824751c3dfb71f2097355cc17bbc254835078a1217f33c1af1ab45a56ac3a6ed9d213b9fbc8c663cc3250
6
+ metadata.gz: b1dc661ba5354a53f4b1fed8e9291ea31b1571a145554f4b69d8c90611f24dc62654557ef16b3553f66b2e580dd7d906bf34fe57e5c0578495899f5797538a0b
7
+ data.tar.gz: c7bbcbb72693194a7cce38991161bbec89849d1f8bcb0eae26eaf85b9536c01a294fd2af8faa9ab7dfe7839472e1610e36fb1debdefba14475281b9c8c5bd420
@@ -22,10 +22,11 @@
22
22
 
23
23
  require 'openc3'
24
24
  require 'openc3/interfaces'
25
+ require 'openc3/microservices/microservice'
25
26
  require 'openc3/tools/cmd_tlm_server/interface_thread'
26
27
 
27
28
  module OpenC3
28
- class ExampleTarget
29
+ class ExampleTarget < Microservice
29
30
  class ExampleServerInterface < TcpipServerInterface
30
31
  def initialize(port)
31
32
  super(port.to_i, port.to_i, 5.0, nil, 'LENGTH', 0, 32, 4, 1, 'BIG_ENDIAN', 4, nil, nil, true)
@@ -83,9 +84,15 @@ module OpenC3
83
84
  end
84
85
  end
85
86
 
86
- def initialize(target_name, port)
87
+ def initialize(name)
88
+ super(name)
89
+ @sleep_period = 1 # 1 second between runs
90
+ # @target_names is an array of all the names mapped to this microservice
91
+ @target_name = @target_names[0] # Should only be 1
92
+ # ports is an array of arrays consisting of the port number and protocol
93
+ # e.g. [[1234, "UDP"], [5678, "TCP"]]
94
+ port = @config["ports"][0][0] # Should only be 1
87
95
  # Create interface to receive commands and send telemetry
88
- @target_name = target_name
89
96
  @interface = ExampleServerInterface.new(port)
90
97
  @interface_thread = nil
91
98
  @telemetry_thread = nil
@@ -104,23 +111,22 @@ module OpenC3
104
111
  @interface_thread.stop if @interface_thread
105
112
  end
106
113
 
107
- def self.run(target_name, port)
114
+ def run
108
115
  Logger.level = Logger::INFO
109
116
  Thread.abort_on_exception = true
110
- temp_dir = Dir.mktmpdir
111
- System.setup_targets([target_name], temp_dir, scope: ENV['OPENC3_SCOPE'])
112
- target = self.new(target_name, port)
113
- begin
114
- target.start
115
- while true
116
- sleep 1
117
- end
118
- rescue SystemExit, SignalException
119
- target.stop
120
- FileUtils.remove_entry(temp_dir) if File.exist?(temp_dir)
117
+
118
+ @state = 'STARTING'
119
+ start()
120
+ @state = 'RUNNING'
121
+ while true
122
+ break if @cancel_thread
123
+ sleep @sleep_period
121
124
  end
125
+ @state = 'STOPPING'
126
+ stop()
127
+ @state = 'STOPPED'
122
128
  end
123
129
  end
124
130
  end
125
131
 
126
- OpenC3::ExampleTarget.run(ARGV[0], ARGV[1]) if __FILE__ == $0
132
+ OpenC3::ExampleTarget.run if __FILE__ == $0
@@ -22,10 +22,11 @@
22
22
 
23
23
  require 'openc3'
24
24
  require 'openc3/interfaces'
25
+ require 'openc3/microservices/microservice'
25
26
  require 'openc3/tools/cmd_tlm_server/interface_thread'
26
27
 
27
28
  module OpenC3
28
- class ScpiTarget
29
+ class ScpiTarget < Microservice
29
30
  class ScpiServerInterface < TcpipServerInterface
30
31
  def initialize(port)
31
32
  super(port.to_i, port.to_i, 5.0, nil, 'TERMINATED', '0xA', '0xA')
@@ -48,7 +49,12 @@ module OpenC3
48
49
  end
49
50
  end
50
51
 
51
- def initialize(port)
52
+ def initialize(name)
53
+ super(name)
54
+ @sleep_period = 1 # 1 second between runs
55
+ # ports is an array of arrays consisting of the port number and protocol
56
+ # e.g. [[1234, "UDP"], [5678, "TCP"]]
57
+ port = @config["ports"][0][0] # Should only be 1
52
58
  # Create interface to receive commands and send telemetry
53
59
  @target_interface = ScpiServerInterface.new(port)
54
60
  @interface_thread = nil
@@ -63,20 +69,22 @@ module OpenC3
63
69
  @interface_thread.stop if @interface_thread
64
70
  end
65
71
 
66
- def self.run(target_name, port)
72
+ def run
67
73
  Logger.level = Logger::INFO
68
- temp_dir = Dir.mktmpdir
69
- System.setup_targets([target_name], temp_dir, scope: ENV['OPENC3_SCOPE'])
70
- target = self.new(port)
71
- begin
72
- target.start
73
- loop { sleep 1 }
74
- rescue SystemExit, SignalException
75
- target.stop
76
- FileUtils.remove_entry(temp_dir) if File.exist?(temp_dir)
74
+ Thread.abort_on_exception = true
75
+
76
+ @state = 'STARTING'
77
+ start()
78
+ @state = 'RUNNING'
79
+ while true
80
+ break if @cancel_thread
81
+ sleep @sleep_period
77
82
  end
83
+ @state = 'STOPPING'
84
+ stop()
85
+ @state = 'STOPPED'
78
86
  end
79
87
  end
80
88
  end
81
89
 
82
- OpenC3::ScpiTarget.run(ARGV[0], ARGV[1]) if __FILE__ == $0
90
+ OpenC3::ScpiTarget.run if __FILE__ == $0
data/plugin.txt CHANGED
@@ -23,18 +23,18 @@ VARIABLE inst_router_port 7779
23
23
  VARIABLE log_retain_time 172800
24
24
  VARIABLE reduced_log_retain_time 2592000
25
25
 
26
- <% include_inst = (inst_target_name.strip.length > 0) %>
27
- <% include_inst2 = (inst2_target_name.strip.length > 0) %>
28
- <% include_example = (example_target_name.strip.length > 0) %>
29
- <% include_templated = (templated_target_name.strip.length > 0) %>
30
- <% include_system = (system_target_name.strip.length > 0) %>
31
- <% include_inst_int = (inst_int_name.strip.length > 0) %>
32
- <% include_inst_router = (inst_router_name.strip.length > 0) %>
33
- <% include_inst2_int = (inst2_int_name.strip.length > 0) %>
34
- <% include_example_int = (example_int_name.strip.length > 0) %>
35
- <% include_templated_int = (templated_int_name.strip.length > 0) %>
36
- <% include_example_microservice = (example_microservice_name.strip.length > 0) %>
37
- <% include_templated_microservice = (templated_microservice_name.strip.length > 0) %>
26
+ <% include_inst = (inst_target_name.to_s.strip.length > 0) %>
27
+ <% include_inst2 = (inst2_target_name.to_s.strip.length > 0) %>
28
+ <% include_example = (example_target_name.to_s.strip.length > 0) %>
29
+ <% include_templated = (templated_target_name.to_s.strip.length > 0) %>
30
+ <% include_system = (system_target_name.to_s.strip.length > 0) %>
31
+ <% include_inst_int = (inst_int_name.to_s.strip.length > 0) %>
32
+ <% include_inst_router = (inst_router_name.to_s.strip.length > 0) %>
33
+ <% include_inst2_int = (inst2_int_name.to_s.strip.length > 0) %>
34
+ <% include_example_int = (example_int_name.to_s.strip.length > 0) %>
35
+ <% include_templated_int = (templated_int_name.to_s.strip.length > 0) %>
36
+ <% include_example_microservice = (example_microservice_name.to_s.strip.length > 0) %>
37
+ <% include_templated_microservice = (templated_microservice_name.to_s.strip.length > 0) %>
38
38
 
39
39
  <% if include_inst %>
40
40
  TARGET INST <%= inst_target_name %>
@@ -69,14 +69,12 @@ VARIABLE reduced_log_retain_time 2592000
69
69
  <% if include_inst and include_inst_int %>
70
70
  INTERFACE <%= inst_int_name %> simulated_target_interface.rb sim_inst.rb
71
71
  MAP_TARGET <%= inst_target_name %>
72
- PROTOCOL READ OverrideProtocol
73
72
  <% end %>
74
73
 
75
74
  <% if include_inst2 and include_inst2_int %>
76
75
  INTERFACE <%= inst2_int_name %> simulated_target_interface.rb sim_inst.rb
77
76
  MAP_TARGET <%= inst2_target_name %>
78
77
  DONT_LOG
79
- PROTOCOL READ_WRITE OverrideProtocol
80
78
  <% end %>
81
79
 
82
80
  <% if include_example and include_example_int %>
@@ -99,16 +97,16 @@ VARIABLE reduced_log_retain_time 2592000
99
97
 
100
98
  <% if include_example_microservice %>
101
99
  MICROSERVICE EXAMPLE <%= example_microservice_name %>
102
- WORK_DIR .
100
+ CMD ruby example_target.rb
101
+ TARGET_NAME <%= example_target_name %>
103
102
  PORT <%= example_port %>
104
- CMD ruby example_target.rb <%= example_target_name %> <%= example_port %>
105
103
  <% end %>
106
104
 
107
105
  <% if include_templated_microservice %>
108
106
  MICROSERVICE TEMPLATED <%= templated_microservice_name %>
109
- WORK_DIR .
107
+ CMD ruby scpi_target.rb
108
+ TARGET_NAME <%= templated_target_name %>
110
109
  PORT <%= templated_port %>
111
- CMD ruby scpi_target.rb <%= templated_target_name %> <%= templated_port %>
112
110
  <% end %>
113
111
 
114
112
  WIDGET BIG
@@ -30,9 +30,9 @@ COMMAND <%= target_name %> SETPARAMS BIG_ENDIAN "Sets numbered parameters"
30
30
  COMMAND <%= target_name %> ASCIICMD BIG_ENDIAN "Enumerated ASCII command"
31
31
  <%= render "_ccsds_cmd.txt", locals: {id: 5} %>
32
32
  APPEND_PARAMETER STRING 2048 STRING "NOOP" "Enumerated string parameter"
33
- STATE "NOOP" "NOOP" DISABLE_MESSAGES
34
33
  STATE "ARM LASER" "ARM LASER" HAZARDOUS "Arming the laser poses an eye safety hazard."
35
34
  STATE "FIRE LASER" "FIRE LASER" HAZARDOUS "WARNING Laser will be fired!"
35
+ STATE "NOOP" "NOOP" DISABLE_MESSAGES
36
36
  APPEND_PARAMETER BINARY 32 STRING 0xDEADBEEF "Binary string"
37
37
  APPEND_PARAMETER ASCII 80 STRING "0xDEADBEEF" "ASCII string"
38
38
 
@@ -59,7 +59,7 @@ COMMAND <%= target_name %> MEMLOAD BIG_ENDIAN "Load memory"
59
59
 
60
60
  COMMAND <%= target_name %> QUIET BIG_ENDIAN "Enable/disable no out of limits in the demo"
61
61
  <%= render "_ccsds_cmd.txt", locals: {id: 11} %>
62
- APPEND_PARAMETER STATE 8 UINT 0 1 0
62
+ APPEND_PARAMETER STATE 8 UINT 0 1 1
63
63
  STATE FALSE 0
64
64
  STATE TRUE 1
65
65
 
@@ -368,7 +368,7 @@ module OpenC3
368
368
 
369
369
  # Every 10s throw an unknown packet at the server just to demo that
370
370
  data = Array.new(10) { rand(0..255) }.pack("C*")
371
- if @get_count % 1000 == 999
371
+ if @get_count % 1000 == 900
372
372
  pending_packets << Packet.new(nil, nil, :BIG_ENDIAN, nil, data)
373
373
  end
374
374
 
@@ -7,23 +7,15 @@ cmd_raw_no_range_check("<%= target_name %> COLLECT with TYPE 0, TEMP 100")
7
7
  cmd_raw_no_hazardous_check("<%= target_name %> CLEAR")
8
8
  cmd_raw_no_checks("<%= target_name %> COLLECT with TYPE 1, TEMP 100.0")
9
9
  check("<%= target_name %> ADCS BIASX == 100")
10
- check_formatted("<%= target_name %> ADCS BIASX == 100")
11
- check_with_units("<%= target_name %> ADCS BIASX == 100")
12
- check_raw("<%= target_name %> ADCS BIASX == 100")
13
10
  check_tolerance("<%= target_name %> ADCS BIASX", 5, 0.5)
14
- check_tolerance_raw("<%= target_name %> ADCS BIASX", 5, 0.5)
15
11
  check_expression("true == false")
16
12
  wait
17
13
  wait 5
18
14
  wait("<%= target_name %> ADCS BIASX > 100", 5)
19
- wait_raw("<%= target_name %> ADCS BIASX > 100", 5)
20
15
  wait_tolerance("<%= target_name %> ADCS BIASX", 5, 0.5, 5)
21
- wait_tolerance_raw("<%= target_name %> ADCS BIASX", 5, 0.5, 5)
22
16
  wait_expression("true == false", 5)
23
17
  wait_packet("<%= target_name %>","ADCS", 2, 5)
24
18
  wait_check("<%= target_name %> ADCS BIASX == 100", 5)
25
- wait_check_raw("<%= target_name %> ADCS BIASX == 100", 5)
26
19
  wait_check_tolerance("<%= target_name %> ADCS BIASX", 5, 0.5, 5)
27
- wait_check_tolerance_raw("<%= target_name %> ADCS BIASX", 5, 0.5, 5)
28
20
  wait_check_expression("true == false", 5)
29
21
  wait_check_packet("<%= target_name %>","ADCS", 2, 5)
@@ -176,11 +176,19 @@ tlm("INST HEALTH_STATUS ARY")
176
176
  tlm("INST HEALTH_STATUS ASCIICMD")
177
177
  tlm("INST HEALTH_STATUS CCSDSAPID")
178
178
  tlm("INST HEALTH_STATUS TEMP1")
179
+ tlm("INST HEALTH_STATUS TEMP1", type: :RAW)
180
+ tlm("INST HEALTH_STATUS TEMP1", type: :CONVERTED)
181
+ tlm("INST HEALTH_STATUS TEMP1", type: :FORMATTED)
182
+ tlm("INST HEALTH_STATUS TEMP1", type: :WITH_UNITS)
179
183
 
180
184
  tlm("INST", "HEALTH_STATUS", "ARY")
181
185
  tlm("INST", "HEALTH_STATUS", "ASCIICMD")
182
186
  tlm("INST", "HEALTH_STATUS", "CCSDSAPID")
183
187
  tlm("INST", "HEALTH_STATUS", "TEMP1")
188
+ tlm("INST", "HEALTH_STATUS", "TEMP1", type: :RAW)
189
+ tlm("INST", "HEALTH_STATUS", "TEMP1", type: :CONVERTED)
190
+ tlm("INST", "HEALTH_STATUS", "TEMP1", type: :FORMATTED)
191
+ tlm("INST", "HEALTH_STATUS", "TEMP1", type: :WITH_UNITS)
184
192
 
185
193
  # tlm should fail
186
194
  tlm()
@@ -195,92 +203,27 @@ tlm("INST", "HEALTH_STATUS")
195
203
  tlm("INST", "HEALTH_STATUS", "BOB")
196
204
  tlm("INST", "HEALTH_STATUS", "ARY", "BOB")
197
205
 
198
- # tlm_raw
199
- tlm_raw("INST HEALTH_STATUS ARY")
200
- tlm_raw("INST HEALTH_STATUS ASCIICMD")
201
- tlm_raw("INST HEALTH_STATUS CCSDSAPID")
202
- tlm_raw("INST HEALTH_STATUS TEMP1")
203
-
204
- tlm_raw("INST", "HEALTH_STATUS", "ARY")
205
- tlm_raw("INST", "HEALTH_STATUS", "ASCIICMD")
206
- tlm_raw("INST", "HEALTH_STATUS", "CCSDSAPID")
207
- tlm_raw("INST", "HEALTH_STATUS", "TEMP1")
208
-
209
- # tlm_raw should fail
210
- tlm_raw()
211
- tlm_raw("BOB")
212
- tlm_raw("INST")
213
- tlm_raw("INST BOB")
214
- tlm_raw("INST HEALTH_STATUS")
215
- tlm_raw("INST HEALTH_STATUS BOB")
216
- tlm_raw("INST HEALTH_STATUS ARY BOB")
217
- tlm_raw("INST", "BOB")
218
- tlm_raw("INST", "HEALTH_STATUS")
219
- tlm_raw("INST", "HEALTH_STATUS", "BOB")
220
- tlm_raw("INST", "HEALTH_STATUS", "ARY", "BOB")
221
-
222
- # tlm_formatted
223
- tlm_formatted("INST HEALTH_STATUS ARY")
224
- tlm_formatted("INST HEALTH_STATUS ASCIICMD")
225
- tlm_formatted("INST HEALTH_STATUS CCSDSAPID")
226
- tlm_formatted("INST HEALTH_STATUS TEMP1")
227
-
228
- tlm_formatted("INST", "HEALTH_STATUS", "ARY")
229
- tlm_formatted("INST", "HEALTH_STATUS", "ASCIICMD")
230
- tlm_formatted("INST", "HEALTH_STATUS", "CCSDSAPID")
231
- tlm_formatted("INST", "HEALTH_STATUS", "TEMP1")
232
-
233
- # tlm_formatted should fail
234
- tlm_formatted()
235
- tlm_formatted("BOB")
236
- tlm_formatted("INST")
237
- tlm_formatted("INST BOB")
238
- tlm_formatted("INST HEALTH_STATUS")
239
- tlm_formatted("INST HEALTH_STATUS BOB")
240
- tlm_formatted("INST HEALTH_STATUS ARY BOB")
241
- tlm_formatted("INST", "BOB")
242
- tlm_formatted("INST", "HEALTH_STATUS")
243
- tlm_formatted("INST", "HEALTH_STATUS", "BOB")
244
- tlm_formatted("INST", "HEALTH_STATUS", "ARY", "BOB")
245
-
246
- # tlm_with_units
247
- tlm_with_units("INST HEALTH_STATUS ARY")
248
- tlm_with_units("INST HEALTH_STATUS ASCIICMD")
249
- tlm_with_units("INST HEALTH_STATUS CCSDSAPID")
250
- tlm_with_units("INST HEALTH_STATUS TEMP1")
251
-
252
- tlm_with_units("INST", "HEALTH_STATUS", "ARY")
253
- tlm_with_units("INST", "HEALTH_STATUS", "ASCIICMD")
254
- tlm_with_units("INST", "HEALTH_STATUS", "CCSDSAPID")
255
- tlm_with_units("INST", "HEALTH_STATUS", "TEMP1")
256
-
257
- # tlm_with_units should fail
258
- tlm_with_units()
259
- tlm_with_units("BOB")
260
- tlm_with_units("INST")
261
- tlm_with_units("INST BOB")
262
- tlm_with_units("INST HEALTH_STATUS")
263
- tlm_with_units("INST HEALTH_STATUS BOB")
264
- tlm_with_units("INST HEALTH_STATUS ARY BOB")
265
- tlm_with_units("INST", "BOB")
266
- tlm_with_units("INST", "HEALTH_STATUS")
267
- tlm_with_units("INST", "HEALTH_STATUS", "BOB")
268
- tlm_with_units("INST", "HEALTH_STATUS", "ARY", "BOB")
269
-
270
206
  # override_tlm
271
207
  override_tlm("INST HEALTH_STATUS ARY = [0,0,0,0,0,0,0,0,0,0]")
272
208
  override_tlm("INST HEALTH_STATUS ASCIICMD = 'HI'")
273
209
  override_tlm("INST HEALTH_STATUS CCSDSAPID = 1000")
274
210
  override_tlm("INST HEALTH_STATUS TEMP1 = 15")
211
+ data = Array.new(131072 / 8) { rand(0..255) }.pack("C*")
212
+ override_tlm("INST", "IMAGE", "IMAGE", data)
275
213
 
276
- # override_tlm_raw
277
- override_tlm_raw("INST HEALTH_STATUS ARY = [0,0,0,0,0,0,0,0,0,0]")
278
- override_tlm_raw("INST HEALTH_STATUS ASCIICMD = 'HI'")
279
- override_tlm_raw("INST HEALTH_STATUS CCSDSAPID = 1000")
280
- override_tlm_raw("INST HEALTH_STATUS TEMP1 = 10000")
214
+ wait_check("INST HEALTH_STATUS ARY == [1,2,3]", 5)
215
+ wait_check("INST HEALTH_STATUS ASCIICMD == 'HI'", 5)
216
+ wait_check("INST HEALTH_STATUS CCSDSAPID == 1000", 5)
217
+ wait_check("INST HEALTH_STATUS TEMP1 == 15", 5)
281
218
 
282
219
  # normalize_tlm
283
220
  normalize_tlm("INST HEALTH_STATUS ARY")
284
221
  normalize_tlm("INST HEALTH_STATUS ASCIICMD")
285
222
  normalize_tlm("INST HEALTH_STATUS CCSDSAPID")
286
223
  normalize_tlm("INST HEALTH_STATUS TEMP1")
224
+ normalize_tlm("INST IMAGE IMAGE")
225
+
226
+ wait_check("INST HEALTH_STATUS ARY != [1,2,3]", 5)
227
+ wait_check("INST HEALTH_STATUS ASCIICMD != 'HI'", 5)
228
+ wait_check("INST HEALTH_STATUS CCSDSAPID != 1000", 5)
229
+ wait_check("INST HEALTH_STATUS TEMP1 != 15", 5)