openc3 5.11.3 → 5.13.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of openc3 might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/bin/openc3cli +29 -15
- data/data/config/_id_items.yaml +6 -4
- data/data/config/_id_params.yaml +9 -6
- data/data/config/_items.yaml +6 -4
- data/data/config/_params.yaml +3 -2
- data/data/config/graph_settings.yaml +1 -1
- data/data/config/interface_modifiers.yaml +1 -1
- data/data/config/item_modifiers.yaml +1 -2
- data/data/config/microservice.yaml +10 -1
- data/data/config/parameter_modifiers.yaml +13 -14
- data/data/config/plugins.yaml +13 -3
- data/data/config/screen.yaml +1 -2
- data/data/config/target.yaml +9 -0
- data/data/config/target_config.yaml +14 -6
- data/data/config/tool.yaml +12 -3
- data/lib/openc3/api/api.rb +1 -1
- data/lib/openc3/api/cmd_api.rb +123 -59
- data/lib/openc3/api/config_api.rb +12 -12
- data/lib/openc3/api/limits_api.rb +4 -3
- data/lib/openc3/api/settings_api.rb +5 -2
- data/lib/openc3/api/tlm_api.rb +70 -34
- data/lib/openc3/conversions/unix_time_conversion.rb +8 -6
- data/lib/openc3/interfaces/mqtt_interface.rb +11 -9
- data/lib/openc3/interfaces/mqtt_stream_interface.rb +78 -0
- data/lib/openc3/interfaces/tcpip_server_interface.rb +0 -7
- data/lib/openc3/io/json_drb.rb +3 -2
- data/lib/openc3/io/json_rpc.rb +6 -6
- data/lib/openc3/logs/buffered_packet_log_writer.rb +4 -2
- data/lib/openc3/logs/packet_log_reader.rb +2 -2
- data/lib/openc3/logs/packet_log_writer.rb +22 -7
- data/lib/openc3/logs/text_log_writer.rb +3 -2
- data/lib/openc3/microservices/cleanup_microservice.rb +8 -1
- data/lib/openc3/microservices/decom_microservice.rb +1 -1
- data/lib/openc3/microservices/interface_microservice.rb +2 -2
- data/lib/openc3/microservices/microservice.rb +5 -2
- data/lib/openc3/microservices/reaction_microservice.rb +1 -0
- data/lib/openc3/microservices/timeline_microservice.rb +7 -5
- data/lib/openc3/microservices/trigger_group_microservice.rb +2 -1
- data/lib/openc3/migrations/20231022000000_tlm_viewer_config.rb +22 -0
- data/lib/openc3/models/activity_model.rb +21 -3
- data/lib/openc3/models/cvt_model.rb +2 -1
- data/lib/openc3/models/gem_model.rb +4 -1
- data/lib/openc3/models/interface_model.rb +11 -5
- data/lib/openc3/models/metadata_model.rb +11 -0
- data/lib/openc3/models/microservice_model.rb +16 -3
- data/lib/openc3/models/model.rb +18 -0
- data/lib/openc3/models/note_model.rb +11 -0
- data/lib/openc3/models/plugin_model.rb +56 -4
- data/lib/openc3/models/python_package_model.rb +104 -0
- data/lib/openc3/models/scope_model.rb +2 -0
- data/lib/openc3/models/sorted_model.rb +17 -8
- data/lib/openc3/models/target_model.rb +53 -18
- data/lib/openc3/models/tool_config_model.rb +9 -3
- data/lib/openc3/models/tool_model.rb +22 -7
- data/lib/openc3/models/widget_model.rb +19 -3
- data/lib/openc3/operators/microservice_operator.rb +2 -0
- data/lib/openc3/packets/json_packet.rb +46 -15
- data/lib/openc3/packets/limits.rb +6 -18
- data/lib/openc3/packets/packet.rb +1 -0
- data/lib/openc3/packets/packet_config.rb +2 -1
- data/lib/openc3/packets/parsers/format_string_parser.rb +4 -4
- data/lib/openc3/packets/parsers/limits_parser.rb +4 -4
- data/lib/openc3/packets/parsers/limits_response_parser.rb +5 -5
- data/lib/openc3/packets/parsers/processor_parser.rb +4 -4
- data/lib/openc3/packets/parsers/state_parser.rb +3 -3
- data/lib/openc3/packets/parsers/xtce_parser.rb +5 -1
- data/lib/openc3/script/api_shared.rb +81 -63
- data/lib/openc3/script/calendar.rb +109 -0
- data/lib/openc3/script/commands.rb +18 -19
- data/lib/openc3/script/limits.rb +1 -1
- data/lib/openc3/script/{gems.rb → packages.rb} +20 -16
- data/lib/openc3/script/script.rb +49 -38
- data/lib/openc3/script/storage.rb +4 -4
- data/lib/openc3/script/web_socket_api.rb +2 -2
- data/lib/openc3/streams/mqtt_stream.rb +109 -0
- data/lib/openc3/system/system.rb +2 -0
- data/lib/openc3/system/target.rb +10 -1
- data/lib/openc3/top_level.rb +2 -2
- data/lib/openc3/utilities/aws_bucket.rb +3 -2
- data/lib/openc3/utilities/bucket_file_cache.rb +1 -1
- data/lib/openc3/utilities/cli_generator.rb +33 -20
- data/lib/openc3/utilities/local_mode.rb +5 -3
- data/lib/openc3/utilities/logger.rb +18 -17
- data/lib/openc3/utilities/process_manager.rb +1 -1
- data/lib/openc3/utilities/ruby_lex_utils.rb +0 -8
- data/lib/openc3/version.rb +6 -6
- data/templates/conversion/conversion.py +28 -0
- data/templates/conversion/conversion.rb +1 -18
- data/templates/limits_response/response.py +37 -0
- data/templates/limits_response/response.rb +0 -17
- data/templates/microservice/microservices/TEMPLATE/microservice.py +54 -0
- data/templates/microservice/microservices/TEMPLATE/microservice.rb +0 -7
- data/templates/plugin/.gitignore +1 -0
- data/templates/target/targets/TARGET/lib/target.py +9 -0
- data/templates/target/targets/TARGET/procedures/procedure.py +3 -0
- data/templates/tool_angular/package.json +22 -21
- data/templates/tool_angular/yarn.lock +2319 -3156
- data/templates/tool_react/package.json +16 -16
- data/templates/tool_react/yarn.lock +763 -645
- data/templates/tool_svelte/package.json +15 -14
- data/templates/tool_svelte/src/services/openc3-api.js +33 -82
- data/templates/tool_svelte/yarn.lock +748 -538
- data/templates/tool_vue/package.json +15 -14
- data/templates/tool_vue/yarn.lock +150 -64
- data/templates/widget/package.json +14 -13
- data/templates/widget/yarn.lock +133 -58
- metadata +60 -7
@@ -17,7 +17,7 @@
|
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
19
|
#
|
20
|
-
# This file may also be used under the terms of a commercial license
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
21
|
# if purchased from OpenC3, Inc.
|
22
22
|
|
23
23
|
require 'openc3/processors'
|
@@ -28,9 +28,9 @@ module OpenC3
|
|
28
28
|
# @param packet [Packet] The current packet
|
29
29
|
# @param cmd_or_tlm [String] Whether this is a command or telemetry packet
|
30
30
|
def self.parse(parser, packet, cmd_or_tlm)
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
parser = ProcessorParser.new(parser)
|
32
|
+
parser.verify_parameters(cmd_or_tlm)
|
33
|
+
parser.create_processor(packet)
|
34
34
|
end
|
35
35
|
|
36
36
|
# @param parser [ConfigParser] Configuration parser
|
@@ -34,9 +34,9 @@ module OpenC3
|
|
34
34
|
raise parser.error("Items with LIMITS can't define STATE") if item.limits.values
|
35
35
|
raise parser.error("Items with UNITS can't define STATE") if item.units
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
parser = StateParser.new(parser)
|
38
|
+
parser.verify_parameters(cmd_or_tlm)
|
39
|
+
parser.create_state(packet, cmd_or_tlm, item, warnings)
|
40
40
|
end
|
41
41
|
|
42
42
|
# @param parser [ConfigParser] Configuration parser
|
@@ -181,7 +181,8 @@ module OpenC3
|
|
181
181
|
when 'ParameterTypeSet', 'EnumerationList', 'ParameterSet', 'ContainerSet',
|
182
182
|
'EntryList', 'DefaultCalibrator', 'DefaultAlarm', 'RestrictionCriteria',
|
183
183
|
'ComparisonList', 'MetaCommandSet', 'ArgumentTypeSet', 'ArgumentList',
|
184
|
-
'ArgumentAssignmentList', 'LocationInContainerInBits', 'ReferenceTime'
|
184
|
+
'ArgumentAssignmentList', 'LocationInContainerInBits', 'ReferenceTime',
|
185
|
+
'AncillaryDataSet', 'AncillaryData'
|
185
186
|
# Do Nothing
|
186
187
|
|
187
188
|
when 'ErrorDetectCorrect'
|
@@ -446,6 +447,9 @@ module OpenC3
|
|
446
447
|
process_ref_entry(element)
|
447
448
|
return false # Already recursed
|
448
449
|
|
450
|
+
when 'ContainerRefEntry'
|
451
|
+
xtce_handle_base_container('ContainerRefEntry', element)
|
452
|
+
|
449
453
|
when 'BaseContainer'
|
450
454
|
# Handled in SequenceContainer/CommandContainer
|
451
455
|
|
@@ -14,7 +14,7 @@
|
|
14
14
|
# GNU Affero General Public License for more details.
|
15
15
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
|
-
# All changes Copyright
|
17
|
+
# All changes Copyright 2023, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
19
|
#
|
20
20
|
# This file may also be used under the terms of a commercial license
|
@@ -69,7 +69,7 @@ module OpenC3
|
|
69
69
|
method += ", #{orig_kwargs}" unless orig_kwargs.empty?
|
70
70
|
method += ")"
|
71
71
|
rescue Exception => error
|
72
|
-
|
72
|
+
puts "CHECK: #{method} raised #{error.class}:#{error.message}"
|
73
73
|
else
|
74
74
|
raise(CheckError, "#{method} should have raised an exception but did not.")
|
75
75
|
end
|
@@ -107,10 +107,10 @@ module OpenC3
|
|
107
107
|
end
|
108
108
|
|
109
109
|
if all_checks_ok
|
110
|
-
|
110
|
+
puts message
|
111
111
|
else
|
112
112
|
if $disconnect
|
113
|
-
|
113
|
+
puts "ERROR: #{message}"
|
114
114
|
else
|
115
115
|
raise CheckError, message
|
116
116
|
end
|
@@ -120,11 +120,11 @@ module OpenC3
|
|
120
120
|
check_str = "CHECK: #{_upcase(target_name, packet_name, item_name)}"
|
121
121
|
range_str = "range #{range.first} to #{range.last} with value == #{value}"
|
122
122
|
if range.include?(value)
|
123
|
-
|
123
|
+
puts "#{check_str} was within #{range_str}"
|
124
124
|
else
|
125
125
|
message = "#{check_str} failed to be within #{range_str}"
|
126
126
|
if $disconnect
|
127
|
-
|
127
|
+
puts "ERROR: #{message}"
|
128
128
|
else
|
129
129
|
raise CheckError, message
|
130
130
|
end
|
@@ -140,13 +140,13 @@ module OpenC3
|
|
140
140
|
# Check to see if an expression is true without waiting. If the expression
|
141
141
|
# is not true, the script will pause.
|
142
142
|
def check_expression(exp_to_eval, context = nil, scope: $openc3_scope, token: $openc3_token)
|
143
|
-
success =
|
143
|
+
success = _openc3_script_wait_implementation_expression(exp_to_eval, 0, DEFAULT_TLM_POLLING_RATE, context, scope: scope, token: token)
|
144
144
|
if success
|
145
|
-
|
145
|
+
puts "CHECK: #{exp_to_eval} is TRUE"
|
146
146
|
else
|
147
147
|
message = "CHECK: #{exp_to_eval} is FALSE"
|
148
148
|
if $disconnect
|
149
|
-
|
149
|
+
puts "ERROR: #{message}"
|
150
150
|
else
|
151
151
|
raise CheckError, message
|
152
152
|
end
|
@@ -171,7 +171,7 @@ module OpenC3
|
|
171
171
|
start_time = Time.now.sys
|
172
172
|
openc3_script_sleep()
|
173
173
|
time_diff = Time.now.sys - start_time
|
174
|
-
|
174
|
+
puts "WAIT: Indefinite for actual time of #{time_diff} seconds" unless quiet
|
175
175
|
|
176
176
|
# wait(5) # absolute wait time
|
177
177
|
when 1
|
@@ -179,7 +179,7 @@ module OpenC3
|
|
179
179
|
start_time = Time.now.sys
|
180
180
|
openc3_script_sleep(args[0])
|
181
181
|
time_diff = Time.now.sys - start_time
|
182
|
-
|
182
|
+
puts "WAIT: #{args[0]} seconds with actual time of #{time_diff} seconds" unless quiet
|
183
183
|
else
|
184
184
|
raise "Non-numeric wait time specified"
|
185
185
|
end
|
@@ -238,7 +238,7 @@ module OpenC3
|
|
238
238
|
if value.is_a?(Array)
|
239
239
|
expected_value, tolerance = _array_tolerance_process_args(value.size, expected_value, tolerance, 'wait_tolerance')
|
240
240
|
|
241
|
-
success, value =
|
241
|
+
success, value = _openc3_script_wait_implementation_array_tolerance(value.size, target_name, packet_name, item_name, type, expected_value, tolerance, timeout, polling_rate, scope: scope, token: token)
|
242
242
|
time = Time.now.sys - start_time
|
243
243
|
|
244
244
|
message = ""
|
@@ -254,20 +254,20 @@ module OpenC3
|
|
254
254
|
end
|
255
255
|
|
256
256
|
if success
|
257
|
-
|
257
|
+
puts message unless quiet
|
258
258
|
else
|
259
|
-
|
259
|
+
puts "WARN: #{message}" unless quiet
|
260
260
|
end
|
261
261
|
else
|
262
|
-
success, value =
|
262
|
+
success, value = _openc3_script_wait_implementation_tolerance(target_name, packet_name, item_name, type, expected_value, tolerance, timeout, polling_rate, scope: scope, token: token)
|
263
263
|
time = Time.now.sys - start_time
|
264
264
|
range = (expected_value - tolerance)..(expected_value + tolerance)
|
265
265
|
wait_str = "WAIT: #{_upcase(target_name, packet_name, item_name)}"
|
266
266
|
range_str = "range #{range.first} to #{range.last} with value == #{value} after waiting #{time} seconds"
|
267
267
|
if success
|
268
|
-
|
268
|
+
puts "#{wait_str} was within #{range_str}" unless quiet
|
269
269
|
else
|
270
|
-
|
270
|
+
puts "WARN: #{wait_str} failed to be within #{range_str}" unless quiet
|
271
271
|
end
|
272
272
|
end
|
273
273
|
time
|
@@ -281,12 +281,12 @@ module OpenC3
|
|
281
281
|
# Wait on a custom expression to be true
|
282
282
|
def wait_expression(exp_to_eval, timeout, polling_rate = DEFAULT_TLM_POLLING_RATE, context = nil, quiet: false, scope: $openc3_scope, token: $openc3_token)
|
283
283
|
start_time = Time.now.sys
|
284
|
-
success =
|
284
|
+
success = _openc3_script_wait_implementation_expression(exp_to_eval, timeout, polling_rate, context, scope: scope, token: token)
|
285
285
|
time_diff = Time.now.sys - start_time
|
286
286
|
if success
|
287
|
-
|
287
|
+
puts "WAIT: #{exp_to_eval} is TRUE after waiting #{time_diff} seconds" unless quiet
|
288
288
|
else
|
289
|
-
|
289
|
+
puts "WARN: WAIT: #{exp_to_eval} is FALSE after waiting #{time_diff} seconds" unless quiet
|
290
290
|
end
|
291
291
|
time_diff
|
292
292
|
end
|
@@ -303,17 +303,20 @@ module OpenC3
|
|
303
303
|
def wait_check(*args, type: :CONVERTED, scope: $openc3_scope, token: $openc3_token, &block)
|
304
304
|
target_name, packet_name, item_name, comparison_to_eval, timeout, polling_rate = _wait_check_process_args(args)
|
305
305
|
start_time = Time.now.sys
|
306
|
-
success, value =
|
306
|
+
success, value = _openc3_script_wait_implementation_comparison(target_name, packet_name, item_name, type, comparison_to_eval, timeout, polling_rate, scope: scope, token: token, &block)
|
307
307
|
value = "'#{value}'" if value.is_a? String # Show user the check against a quoted string
|
308
308
|
time_diff = Time.now.sys - start_time
|
309
|
-
check_str = "CHECK: #{_upcase(target_name, packet_name, item_name)}
|
309
|
+
check_str = "CHECK: #{_upcase(target_name, packet_name, item_name)}"
|
310
|
+
if comparison_to_eval
|
311
|
+
check_str += " #{comparison_to_eval}"
|
312
|
+
end
|
310
313
|
with_value_str = "with value == #{value} after waiting #{time_diff} seconds"
|
311
314
|
if success
|
312
|
-
|
315
|
+
puts "#{check_str} success #{with_value_str}"
|
313
316
|
else
|
314
317
|
message = "#{check_str} failed #{with_value_str}"
|
315
318
|
if $disconnect
|
316
|
-
|
319
|
+
puts "ERROR: #{message}"
|
317
320
|
else
|
318
321
|
raise CheckError, message
|
319
322
|
end
|
@@ -344,7 +347,7 @@ module OpenC3
|
|
344
347
|
if value.is_a?(Array)
|
345
348
|
expected_value, tolerance = _array_tolerance_process_args(value.size, expected_value, tolerance, 'wait_check_tolerance')
|
346
349
|
|
347
|
-
success, value =
|
350
|
+
success, value = _openc3_script_wait_implementation_array_tolerance(value.size, target_name, packet_name, item_name, type, expected_value, tolerance, timeout, polling_rate, scope: scope, token: token, &block)
|
348
351
|
time_diff = Time.now.sys - start_time
|
349
352
|
|
350
353
|
message = ""
|
@@ -360,26 +363,26 @@ module OpenC3
|
|
360
363
|
end
|
361
364
|
|
362
365
|
if success
|
363
|
-
|
366
|
+
puts message
|
364
367
|
else
|
365
368
|
if $disconnect
|
366
|
-
|
369
|
+
puts "ERROR: #{message}"
|
367
370
|
else
|
368
371
|
raise CheckError, message
|
369
372
|
end
|
370
373
|
end
|
371
374
|
else
|
372
|
-
success, value =
|
375
|
+
success, value = _openc3_script_wait_implementation_tolerance(target_name, packet_name, item_name, type, expected_value, tolerance, timeout, polling_rate, scope: scope, token: token)
|
373
376
|
time_diff = Time.now.sys - start_time
|
374
377
|
range = (expected_value - tolerance)..(expected_value + tolerance)
|
375
378
|
check_str = "CHECK: #{_upcase(target_name, packet_name, item_name)}"
|
376
379
|
range_str = "range #{range.first} to #{range.last} with value == #{value} after waiting #{time_diff} seconds"
|
377
380
|
if success
|
378
|
-
|
381
|
+
puts "#{check_str} was within #{range_str}"
|
379
382
|
else
|
380
383
|
message = "#{check_str} failed to be within #{range_str}"
|
381
384
|
if $disconnect
|
382
|
-
|
385
|
+
puts "ERROR: #{message}"
|
383
386
|
else
|
384
387
|
raise CheckError, message
|
385
388
|
end
|
@@ -400,17 +403,17 @@ module OpenC3
|
|
400
403
|
context = nil,
|
401
404
|
scope: $openc3_scope, token: $openc3_token, &block)
|
402
405
|
start_time = Time.now.sys
|
403
|
-
success =
|
406
|
+
success = _openc3_script_wait_implementation_expression(exp_to_eval,
|
404
407
|
timeout,
|
405
408
|
polling_rate,
|
406
409
|
context, scope: scope, token: token, &block)
|
407
410
|
time_diff = Time.now.sys - start_time
|
408
411
|
if success
|
409
|
-
|
412
|
+
puts "CHECK: #{exp_to_eval} is TRUE after waiting #{time_diff} seconds"
|
410
413
|
else
|
411
414
|
message = "CHECK: #{exp_to_eval} is FALSE after waiting #{time_diff} seconds"
|
412
415
|
if $disconnect
|
413
|
-
|
416
|
+
puts "ERROR: #{message}"
|
414
417
|
else
|
415
418
|
raise CheckError, message
|
416
419
|
end
|
@@ -537,7 +540,7 @@ module OpenC3
|
|
537
540
|
if comparison_to_eval
|
538
541
|
_check_eval(target_name, packet_name, item_name, comparison_to_eval, value)
|
539
542
|
else
|
540
|
-
|
543
|
+
puts "CHECK: #{_upcase(target_name, packet_name, item_name)} == #{value}"
|
541
544
|
end
|
542
545
|
end
|
543
546
|
|
@@ -545,6 +548,10 @@ module OpenC3
|
|
545
548
|
case args.length
|
546
549
|
when 1
|
547
550
|
target_name, packet_name, item_name, comparison_to_eval = extract_fields_from_check_text(args[0])
|
551
|
+
when 3
|
552
|
+
target_name = args[0]
|
553
|
+
packet_name = args[1]
|
554
|
+
item_name = args[2]
|
548
555
|
when 4
|
549
556
|
target_name = args[0]
|
550
557
|
packet_name = args[1]
|
@@ -554,7 +561,9 @@ module OpenC3
|
|
554
561
|
# Invalid number of arguments
|
555
562
|
raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{method_name}()"
|
556
563
|
end
|
557
|
-
|
564
|
+
if comparison_to_eval and !comparison_to_eval.is_printable?
|
565
|
+
raise "ERROR: Invalid comparison to non-ascii value"
|
566
|
+
end
|
558
567
|
return [target_name, packet_name, item_name, comparison_to_eval]
|
559
568
|
end
|
560
569
|
|
@@ -599,30 +608,30 @@ module OpenC3
|
|
599
608
|
# If the packet has not been received the initial_count could be nil
|
600
609
|
initial_count = 0 unless initial_count
|
601
610
|
start_time = Time.now.sys
|
602
|
-
success, value =
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
+
success, value = _openc3_script_wait_implementation_comparison(target_name,
|
612
|
+
packet_name,
|
613
|
+
'RECEIVED_COUNT',
|
614
|
+
:CONVERTED,
|
615
|
+
">= #{initial_count + num_packets}",
|
616
|
+
timeout,
|
617
|
+
polling_rate,
|
618
|
+
scope: scope,
|
619
|
+
token: token)
|
611
620
|
# If the packet has not been received the value could be nil
|
612
621
|
value = 0 unless value
|
613
622
|
time_diff = Time.now.sys - start_time
|
614
623
|
if success
|
615
|
-
|
624
|
+
puts "#{type}: #{target_name.upcase} #{packet_name.upcase} received #{value - initial_count} times after waiting #{time_diff} seconds" unless quiet
|
616
625
|
else
|
617
626
|
message = "#{type}: #{target_name.upcase} #{packet_name.upcase} expected to be received #{num_packets} times but only received #{value - initial_count} times after waiting #{time_diff} seconds"
|
618
627
|
if check
|
619
628
|
if $disconnect
|
620
|
-
|
629
|
+
puts "ERROR: #{message}"
|
621
630
|
else
|
622
631
|
raise CheckError, message
|
623
632
|
end
|
624
633
|
else
|
625
|
-
|
634
|
+
puts "WARN: #{message}" unless quiet
|
626
635
|
end
|
627
636
|
end
|
628
637
|
time_diff
|
@@ -630,15 +639,15 @@ module OpenC3
|
|
630
639
|
|
631
640
|
def _execute_wait(target_name, packet_name, item_name, value_type, comparison_to_eval, timeout, polling_rate, quiet: false, scope: $openc3_scope, token: $openc3_token)
|
632
641
|
start_time = Time.now.sys
|
633
|
-
success, value =
|
642
|
+
success, value = _openc3_script_wait_implementation_comparison(target_name, packet_name, item_name, value_type, comparison_to_eval, timeout, polling_rate, scope: scope, token: token)
|
634
643
|
value = "'#{value}'" if value.is_a? String # Show user the check against a quoted string
|
635
644
|
time_diff = Time.now.sys - start_time
|
636
645
|
wait_str = "WAIT: #{_upcase(target_name, packet_name, item_name)} #{comparison_to_eval}"
|
637
646
|
value_str = "with value == #{value} after waiting #{time_diff} seconds"
|
638
647
|
if success
|
639
|
-
|
648
|
+
puts "#{wait_str} success #{value_str}" unless quiet
|
640
649
|
else
|
641
|
-
|
650
|
+
puts "WARN: #{wait_str} failed #{value_str}" unless quiet
|
642
651
|
end
|
643
652
|
end
|
644
653
|
|
@@ -732,8 +741,9 @@ module OpenC3
|
|
732
741
|
|
733
742
|
def _openc3_script_wait_implementation(target_name, packet_name, item_name, value_type, timeout, polling_rate, exp_to_eval, scope: $openc3_scope, token: $openc3_token, &block)
|
734
743
|
end_time = Time.now.sys + timeout
|
735
|
-
|
736
|
-
|
744
|
+
if exp_to_eval and !exp_to_eval.is_printable?
|
745
|
+
raise "ERROR: Invalid comparison to non-ascii value"
|
746
|
+
end
|
737
747
|
while true
|
738
748
|
work_start = Time.now.sys
|
739
749
|
value = tlm(target_name, packet_name, item_name, type: value_type, scope: scope, token: token)
|
@@ -762,15 +772,23 @@ module OpenC3
|
|
762
772
|
|
763
773
|
if canceled
|
764
774
|
value = tlm(target_name, packet_name, item_name, type: value_type, scope: scope, token: token)
|
765
|
-
|
766
|
-
if
|
775
|
+
if not block.nil?
|
776
|
+
if block.call(value)
|
767
777
|
return true, value
|
768
778
|
else
|
769
779
|
return false, value
|
770
780
|
end
|
771
|
-
|
772
|
-
|
773
|
-
|
781
|
+
else
|
782
|
+
begin
|
783
|
+
if eval(exp_to_eval)
|
784
|
+
return true, value
|
785
|
+
else
|
786
|
+
return false, value
|
787
|
+
end
|
788
|
+
# NoMethodError is raised when the tlm() returns nil and we try to eval the expression
|
789
|
+
rescue NoMethodError
|
790
|
+
return false, value
|
791
|
+
end
|
774
792
|
end
|
775
793
|
end
|
776
794
|
end
|
@@ -787,7 +805,7 @@ module OpenC3
|
|
787
805
|
end
|
788
806
|
|
789
807
|
# Wait for a converted telemetry item to pass a comparison
|
790
|
-
def
|
808
|
+
def _openc3_script_wait_implementation_comparison(target_name, packet_name, item_name, value_type, comparison_to_eval, timeout, polling_rate = DEFAULT_TLM_POLLING_RATE, scope: $openc3_scope, token: $openc3_token, &block)
|
791
809
|
if comparison_to_eval
|
792
810
|
exp_to_eval = "value " + comparison_to_eval
|
793
811
|
else
|
@@ -796,12 +814,12 @@ module OpenC3
|
|
796
814
|
_openc3_script_wait_implementation(target_name, packet_name, item_name, value_type, timeout, polling_rate, exp_to_eval, scope: scope, token: token, &block)
|
797
815
|
end
|
798
816
|
|
799
|
-
def
|
817
|
+
def _openc3_script_wait_implementation_tolerance(target_name, packet_name, item_name, value_type, expected_value, tolerance, timeout, polling_rate = DEFAULT_TLM_POLLING_RATE, scope: $openc3_scope, token: $openc3_token, &block)
|
800
818
|
exp_to_eval = "((#{expected_value} - #{tolerance})..(#{expected_value} + #{tolerance})).include? value"
|
801
819
|
_openc3_script_wait_implementation(target_name, packet_name, item_name, value_type, timeout, polling_rate, exp_to_eval, scope: scope, token: token, &block)
|
802
820
|
end
|
803
821
|
|
804
|
-
def
|
822
|
+
def _openc3_script_wait_implementation_array_tolerance(array_size, target_name, packet_name, item_name, value_type, expected_value, tolerance, timeout, polling_rate = DEFAULT_TLM_POLLING_RATE, scope: $openc3_scope, token: $openc3_token, &block)
|
805
823
|
statements = []
|
806
824
|
array_size.times { |i| statements << "(((#{expected_value[i]} - #{tolerance[i]})..(#{expected_value[i]} + #{tolerance[i]})).include? value[#{i}])" }
|
807
825
|
exp_to_eval = statements.join(" && ")
|
@@ -809,7 +827,7 @@ module OpenC3
|
|
809
827
|
end
|
810
828
|
|
811
829
|
# Wait on an expression to be true.
|
812
|
-
def
|
830
|
+
def _openc3_script_wait_implementation_expression(exp_to_eval, timeout, polling_rate, context, scope: $openc3_scope, token: $openc3_token)
|
813
831
|
end_time = Time.now.sys + timeout
|
814
832
|
raise "Invalid comparison to non-ascii value" unless exp_to_eval.is_printable?
|
815
833
|
|
@@ -855,11 +873,11 @@ module OpenC3
|
|
855
873
|
value_str = value.is_a?(String) ? "'#{value}'" : value
|
856
874
|
with_value = "with value == #{value_str}"
|
857
875
|
if eval(string)
|
858
|
-
|
876
|
+
puts "#{check_str} success #{with_value}"
|
859
877
|
else
|
860
878
|
message = "#{check_str} failed #{with_value}"
|
861
879
|
if $disconnect
|
862
|
-
|
880
|
+
puts "ERROR: #{message}"
|
863
881
|
else
|
864
882
|
raise CheckError, message
|
865
883
|
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
|
3
|
+
# Copyright 2023 OpenC3, Inc.
|
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 Affero 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
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Affero General Public License for more details.
|
15
|
+
|
16
|
+
# This file may also be used under the terms of a commercial license
|
17
|
+
# if purchased from OpenC3, Inc.
|
18
|
+
|
19
|
+
require 'date'
|
20
|
+
|
21
|
+
module OpenC3
|
22
|
+
module Script
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def list_timelines(scope: $openc3_scope, token: $openc3_token)
|
27
|
+
response = $api_server.request('get', "/openc3-api/timeline", scope: scope)
|
28
|
+
return _handle_response(response, 'Failed to list timelines')
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_timeline(name, color: nil, scope: $openc3_scope, token: $openc3_token)
|
32
|
+
data = {}
|
33
|
+
data['name'] = name
|
34
|
+
data['color'] = color if color
|
35
|
+
response = $api_server.request('post', "/openc3-api/timeline", data: data, json: true, scope: scope)
|
36
|
+
return _handle_response(response, 'Failed to create timeline')
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_timeline(name, scope: $openc3_scope, token: $openc3_token)
|
40
|
+
response = $api_server.request('get', "/openc3-api/timeline/#{name}", scope: scope)
|
41
|
+
return _handle_response(response, 'Failed to get timeline')
|
42
|
+
end
|
43
|
+
|
44
|
+
def set_timeline_color(name, color, scope: $openc3_scope, token: $openc3_token)
|
45
|
+
post_data = {}
|
46
|
+
post_data['color'] = color
|
47
|
+
response = $api_server.request('post', "/openc3-api/timeline/#{name}/color", data: post_data, json: true, scope: scope)
|
48
|
+
return _handle_response(response, 'Failed to set timeline color')
|
49
|
+
end
|
50
|
+
|
51
|
+
def delete_timeline(name, force: false, scope: $openc3_scope, token: $openc3_token)
|
52
|
+
url = "/openc3-api/timeline/#{name}"
|
53
|
+
if force
|
54
|
+
url += "?force=true"
|
55
|
+
end
|
56
|
+
response = $api_server.request('delete', url, scope: scope)
|
57
|
+
return _handle_response(response, 'Failed to delete timeline')
|
58
|
+
end
|
59
|
+
|
60
|
+
def get_timeline_activities(name, start: nil, stop: nil, scope: $openc3_scope, token: $openc3_token)
|
61
|
+
url = "/openc3-api/timeline/#{name}/activities"
|
62
|
+
if start and stop
|
63
|
+
url += "?start=#{start}&stop=#{stop}"
|
64
|
+
end
|
65
|
+
response = $api_server.request('get', url, scope: scope)
|
66
|
+
return _handle_response(response, 'Failed to get timeline activities')
|
67
|
+
end
|
68
|
+
|
69
|
+
def create_timeline_activity(name, kind:, start:, stop:, data: {}, scope: $openc3_scope, token: $openc3_token)
|
70
|
+
kind = kind.to_s.downcase()
|
71
|
+
kinds = %w(command script reserve)
|
72
|
+
unless kinds.include?(kind)
|
73
|
+
raise "Unknown kind: #{kind}. Must be one of #{kinds.join(', ')}."
|
74
|
+
end
|
75
|
+
post_data = {}
|
76
|
+
post_data['start'] = start.to_datetime.iso8601
|
77
|
+
post_data['stop'] = stop.to_datetime.iso8601
|
78
|
+
post_data['kind'] = kind
|
79
|
+
post_data['data'] = data
|
80
|
+
response = $api_server.request('post', "/openc3-api/timeline/#{name}/activities", data: post_data, json: true, scope: scope)
|
81
|
+
return _handle_response(response, 'Failed to create timeline activity')
|
82
|
+
end
|
83
|
+
|
84
|
+
def get_timeline_activity(name, start: nil, scope: $openc3_scope, token: $openc3_token)
|
85
|
+
response = $api_server.request('get', "/openc3-api/timeline/#{name}/activity/#{start}", scope: scope)
|
86
|
+
return _handle_response(response, 'Failed to get timeline activity')
|
87
|
+
end
|
88
|
+
|
89
|
+
def delete_timeline_activity(name, start, scope: $openc3_scope, token: $openc3_token)
|
90
|
+
response = $api_server.request('delete', "/openc3-api/timeline/#{name}/activity/#{start}", scope: scope)
|
91
|
+
return _handle_response(response, 'Failed to delete timeline activity')
|
92
|
+
end
|
93
|
+
|
94
|
+
# Helper method to handle the response
|
95
|
+
def _handle_response(response, error_message)
|
96
|
+
return nil if response.nil?
|
97
|
+
if response.status >= 400
|
98
|
+
result = JSON.parse(response.body, :allow_nan => true, :create_additions => true)
|
99
|
+
raise "#{error_message} due to #{result['message']}"
|
100
|
+
end
|
101
|
+
# TODO: Not sure why the response body is empty (on delete) but check for that
|
102
|
+
if response.body.nil? or response.body.empty?
|
103
|
+
return nil
|
104
|
+
else
|
105
|
+
return JSON.parse(response.body, :allow_nan => true, :create_additions => true)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -69,12 +69,12 @@ module OpenC3
|
|
69
69
|
# NOTE: This is a helper method and should not be called directly
|
70
70
|
def _log_cmd(target_name, cmd_name, cmd_params, raw, no_range, no_hazardous)
|
71
71
|
if no_range
|
72
|
-
|
72
|
+
puts "WARN: Command #{target_name} #{cmd_name} being sent ignoring range checks"
|
73
73
|
end
|
74
74
|
if no_hazardous
|
75
|
-
|
75
|
+
puts "WARN: Command #{target_name} #{cmd_name} being sent ignoring hazardous warnings"
|
76
76
|
end
|
77
|
-
|
77
|
+
puts _cmd_string(target_name, cmd_name, cmd_params, raw)
|
78
78
|
end
|
79
79
|
|
80
80
|
def _cmd_disconnect(cmd, raw, no_range, no_hazardous, *args, scope: $openc3_scope)
|
@@ -95,7 +95,7 @@ module OpenC3
|
|
95
95
|
end
|
96
96
|
|
97
97
|
# Get the command and validate the parameters
|
98
|
-
command = $api_server.
|
98
|
+
command = $api_server.get_cmd(target_name, cmd_name, scope: scope)
|
99
99
|
cmd_params.each do |param_name, param_value|
|
100
100
|
param = command['items'].find { |item| item['name'] == param_name }
|
101
101
|
unless param
|
@@ -108,7 +108,7 @@ module OpenC3
|
|
108
108
|
# Send the command and log the results
|
109
109
|
# This method signature has to include the keyword params present in cmd_api.rb cmd_implementation()
|
110
110
|
# NOTE: This is a helper method and should not be called directly
|
111
|
-
def _cmd(cmd, cmd_no_hazardous, *args, scope: $openc3_scope, token: $openc3_token,
|
111
|
+
def _cmd(cmd, cmd_no_hazardous, *args, timeout: nil, log_message: nil, scope: $openc3_scope, token: $openc3_token, **kwargs)
|
112
112
|
extract_string_kwargs_to_args(args, kwargs)
|
113
113
|
raw = cmd.include?('raw')
|
114
114
|
no_range = cmd.include?('no_range') || cmd.include?('no_checks')
|
@@ -118,14 +118,18 @@ module OpenC3
|
|
118
118
|
_cmd_disconnect(cmd, raw, no_range, no_hazardous, *args, scope: scope)
|
119
119
|
else
|
120
120
|
begin
|
121
|
-
target_name, cmd_name, cmd_params = $api_server.method_missing(cmd, *args, scope: scope, token: token
|
122
|
-
|
121
|
+
target_name, cmd_name, cmd_params = $api_server.method_missing(cmd, *args, timeout: timeout, log_message: log_message, scope: scope, token: token)
|
122
|
+
if log_message.nil? or log_message
|
123
|
+
_log_cmd(target_name, cmd_name, cmd_params, raw, no_range, no_hazardous)
|
124
|
+
end
|
123
125
|
rescue HazardousError => e
|
124
126
|
# This opens a prompt at which point they can cancel and stop the script
|
125
127
|
# or say Yes and send the command. Thus we don't care about the return value.
|
126
128
|
prompt_for_hazardous(e.target_name, e.cmd_name, e.hazardous_description)
|
127
|
-
target_name, cmd_name, cmd_params = $api_server.method_missing(cmd_no_hazardous, *args, scope: scope, token: token
|
128
|
-
|
129
|
+
target_name, cmd_name, cmd_params = $api_server.method_missing(cmd_no_hazardous, *args, timeout: timeout, log_message: log_message, scope: scope, token: token)
|
130
|
+
if log_message.nil? or log_message
|
131
|
+
_log_cmd(target_name, cmd_name, cmd_params, raw, no_range, no_hazardous)
|
132
|
+
end
|
129
133
|
end
|
130
134
|
end
|
131
135
|
end
|
@@ -171,12 +175,14 @@ module OpenC3
|
|
171
175
|
# Builds a command binary
|
172
176
|
#
|
173
177
|
# Accepts two different calling styles:
|
174
|
-
#
|
175
|
-
#
|
176
|
-
def
|
178
|
+
# build_cmd("TGT CMD with PARAM1 val, PARAM2 val")
|
179
|
+
# build_cmd('TGT','CMD',{'PARAM1'=>val,'PARAM2'=>val})
|
180
|
+
def build_cmd(*args, range_check: true, raw: false, scope: $openc3_scope, **kwargs)
|
177
181
|
extract_string_kwargs_to_args(args, kwargs)
|
178
182
|
$api_server.build_command(*args)
|
179
183
|
end
|
184
|
+
# build_command is DEPRECATED
|
185
|
+
alias build_command build_cmd
|
180
186
|
|
181
187
|
# Returns whether the specified command is hazardous
|
182
188
|
#
|
@@ -188,13 +194,6 @@ module OpenC3
|
|
188
194
|
$api_server.get_cmd_hazardous(*args)
|
189
195
|
end
|
190
196
|
|
191
|
-
# Sends raw data through an interface from a file
|
192
|
-
def send_raw_file(interface_name, filename, scope: $openc3_scope)
|
193
|
-
data = nil
|
194
|
-
File.open(filename, 'rb') { |file| data = file.read }
|
195
|
-
$api_server.send_raw(interface_name, data, scope: scope)
|
196
|
-
end
|
197
|
-
|
198
197
|
# Returns the time the most recent command was sent
|
199
198
|
def get_cmd_time(target_name = nil, command_name = nil, scope: $openc3_scope)
|
200
199
|
results = $api_server.get_cmd_time(target_name, command_name, scope: scope)
|
data/lib/openc3/script/limits.rb
CHANGED
@@ -29,7 +29,7 @@ module OpenC3
|
|
29
29
|
define_method(method_name) do |*args, **kw_args, &block|
|
30
30
|
kw_args[:scope] = $openc3_scope unless kw_args[:scope]
|
31
31
|
if $disconnect
|
32
|
-
|
32
|
+
puts "DISCONNECT: #{method_name}(#{args}) ignored"
|
33
33
|
else
|
34
34
|
$api_server.public_send(method_name, *args, **kw_args, &block)
|
35
35
|
end
|