openc3 5.11.3 → 5.12.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.
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 +26 -12
- 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/interface_modifiers.yaml +1 -1
- data/data/config/microservice.yaml +10 -1
- data/data/config/plugins.yaml +13 -3
- data/data/config/target.yaml +9 -0
- data/data/config/target_config.yaml +12 -0
- data/data/config/tool.yaml +12 -3
- data/lib/openc3/api/api.rb +1 -1
- data/lib/openc3/api/cmd_api.rb +24 -24
- 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 +7 -10
- data/lib/openc3/conversions/unix_time_conversion.rb +8 -6
- 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_writer.rb +22 -7
- 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/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 +18 -0
- 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/limits.rb +6 -18
- data/lib/openc3/packets/packet.rb +1 -0
- 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/script/api_shared.rb +50 -32
- data/lib/openc3/script/calendar.rb +109 -0
- data/lib/openc3/script/commands.rb +1 -8
- data/lib/openc3/script/{gems.rb → packages.rb} +20 -16
- data/lib/openc3/script/script.rb +49 -38
- 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/local_mode.rb +3 -1
- data/lib/openc3/utilities/logger.rb +1 -1
- data/lib/openc3/utilities/ruby_lex_utils.rb +0 -8
- data/lib/openc3/version.rb +6 -6
- data/templates/tool_angular/package.json +14 -14
- data/templates/tool_angular/yarn.lock +282 -129
- data/templates/tool_react/package.json +11 -11
- data/templates/tool_react/yarn.lock +353 -300
- data/templates/tool_svelte/package.json +12 -12
- data/templates/tool_svelte/src/services/openc3-api.js +16 -60
- data/templates/tool_svelte/yarn.lock +338 -212
- data/templates/tool_vue/package.json +9 -9
- data/templates/tool_vue/yarn.lock +55 -41
- data/templates/widget/package.json +10 -10
- data/templates/widget/yarn.lock +59 -45
- metadata +36 -5
@@ -73,21 +73,21 @@ module OpenC3
|
|
73
73
|
# @param packet_name [String] The packet name. Must be a defined packet name and not 'LATEST'.
|
74
74
|
# @param item_name [String] The item name
|
75
75
|
def enabled?(target_name, packet_name, item_name)
|
76
|
-
|
76
|
+
_get_packet(target_name, packet_name).get_item(item_name).limits.enabled
|
77
77
|
end
|
78
78
|
|
79
79
|
# Enables limit checking for the specified item
|
80
80
|
#
|
81
81
|
# @param (see #enabled?)
|
82
82
|
def enable(target_name, packet_name, item_name)
|
83
|
-
|
83
|
+
_get_packet(target_name, packet_name).enable_limits(item_name)
|
84
84
|
end
|
85
85
|
|
86
86
|
# Disables limit checking for the specified item
|
87
87
|
#
|
88
88
|
# @param (see #enabled?)
|
89
89
|
def disable(target_name, packet_name, item_name)
|
90
|
-
|
90
|
+
_get_packet(target_name, packet_name).disable_limits(item_name)
|
91
91
|
end
|
92
92
|
|
93
93
|
# Get the limits for a telemetry item
|
@@ -98,7 +98,7 @@ module OpenC3
|
|
98
98
|
# @param limits_set [String or Symbol or nil] Desired Limits set. nil = current limits set
|
99
99
|
# @return [Array<limits_set, persistence, enabled, red_low, yellow_low, red_high, yellow_high, green_low (optional), green_high (optional)] Limits information
|
100
100
|
def get(target_name, packet_name, item_name, limits_set = nil)
|
101
|
-
limits =
|
101
|
+
limits = _get_packet(target_name, packet_name).get_item(item_name).limits
|
102
102
|
if limits.values
|
103
103
|
if limits_set
|
104
104
|
limits_set = limits_set.to_s.upcase.intern
|
@@ -132,7 +132,7 @@ module OpenC3
|
|
132
132
|
# @param enabled [Boolean] If limits monitoring is enabled for this item
|
133
133
|
# @return [Array<limits_set, persistence, enabled, red_low, yellow_low, red_high, yellow_high, green_low (optional), green_high (optional)] Limits information
|
134
134
|
def set(target_name, packet_name, item_name, red_low, yellow_low, yellow_high, red_high, green_low = nil, green_high = nil, limits_set = :CUSTOM, persistence = nil, enabled = true)
|
135
|
-
packet =
|
135
|
+
packet = _get_packet(target_name, packet_name)
|
136
136
|
item = packet.get_item(item_name)
|
137
137
|
limits = item.limits
|
138
138
|
if limits_set
|
@@ -172,7 +172,7 @@ module OpenC3
|
|
172
172
|
|
173
173
|
protected
|
174
174
|
|
175
|
-
def
|
175
|
+
def _get_packet(target_name, packet_name)
|
176
176
|
raise "LATEST packet not valid" if packet_name.upcase == LATEST_PACKET_NAME
|
177
177
|
|
178
178
|
packets = @config.telemetry[target_name.to_s.upcase]
|
@@ -183,17 +183,5 @@ module OpenC3
|
|
183
183
|
|
184
184
|
return packet
|
185
185
|
end
|
186
|
-
|
187
|
-
def includes_item?(ignored_items, target_name, packet_name, item_name)
|
188
|
-
ignored_items.each do |array_target_name, array_packet_name, array_item_name|
|
189
|
-
if (array_target_name == target_name) &&
|
190
|
-
(array_packet_name == packet_name) &&
|
191
|
-
# If the item name is nil we're ignoring an entire packet
|
192
|
-
(array_item_name == item_name || array_item_name.nil?)
|
193
|
-
return true
|
194
|
-
end
|
195
|
-
end
|
196
|
-
return false
|
197
|
-
end
|
198
186
|
end
|
199
187
|
end
|
@@ -1061,6 +1061,7 @@ module OpenC3
|
|
1061
1061
|
config['accessor'] = @accessor.class.to_s
|
1062
1062
|
config['accessor_args'] = @accessor.args
|
1063
1063
|
config['template'] = Base64.encode64(@template) if @template
|
1064
|
+
config['config_name'] = self.config_name
|
1064
1065
|
|
1065
1066
|
if @processors
|
1066
1067
|
processors = []
|
@@ -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
|
module OpenC3
|
@@ -25,9 +25,9 @@ module OpenC3
|
|
25
25
|
# @param parser [ConfigParser] Configuration parser
|
26
26
|
# @param item [Packet] The current item
|
27
27
|
def self.parse(parser, item)
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
parser = FormatStringParser.new(parser)
|
29
|
+
parser.verify_parameters()
|
30
|
+
parser.create_format_string(item)
|
31
31
|
end
|
32
32
|
|
33
33
|
# @param parser [ConfigParser] Configuration parser
|
@@ -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
|
module OpenC3
|
@@ -31,9 +31,9 @@ module OpenC3
|
|
31
31
|
def self.parse(parser, packet, cmd_or_tlm, item, warnings)
|
32
32
|
raise parser.error("Items with STATE can't define LIMITS") if item.states
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
parser = LimitsParser.new(parser)
|
35
|
+
parser.verify_parameters(cmd_or_tlm)
|
36
|
+
parser.create_limits(packet, item, warnings)
|
37
37
|
end
|
38
38
|
|
39
39
|
def initialize(parser)
|
@@ -14,10 +14,10 @@
|
|
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
|
-
# 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
|
module OpenC3
|
@@ -26,9 +26,9 @@ module OpenC3
|
|
26
26
|
# @param item [Packet] The current item
|
27
27
|
# @param cmd_or_tlm [String] Whether this is a command or telemetry packet
|
28
28
|
def self.parse(parser, item, cmd_or_tlm)
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
parser = LimitsResponseParser.new(parser)
|
30
|
+
parser.verify_parameters(cmd_or_tlm)
|
31
|
+
parser.create_limits_response(item)
|
32
32
|
end
|
33
33
|
|
34
34
|
# @param parser [ConfigParser] Configuration parser
|
@@ -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
|
@@ -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
|
@@ -140,7 +140,7 @@ 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
|
Logger.info "CHECK: #{exp_to_eval} is TRUE"
|
146
146
|
else
|
@@ -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 = ""
|
@@ -259,7 +259,7 @@ module OpenC3
|
|
259
259
|
Logger.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)}"
|
@@ -281,7 +281,7 @@ 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
|
Logger.info "WAIT: #{exp_to_eval} is TRUE after waiting #{time_diff} seconds" unless quiet
|
@@ -303,10 +303,13 @@ 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
|
Logger.info "#{check_str} success #{with_value_str}"
|
@@ -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 = ""
|
@@ -369,7 +372,7 @@ module OpenC3
|
|
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)}"
|
@@ -400,7 +403,7 @@ 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)
|
@@ -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,15 +608,15 @@ 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
|
@@ -630,7 +639,7 @@ 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}"
|
@@ -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
|
|
@@ -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
|
@@ -173,7 +173,7 @@ module OpenC3
|
|
173
173
|
# Accepts two different calling styles:
|
174
174
|
# build_command("TGT CMD with PARAM1 val, PARAM2 val")
|
175
175
|
# build_command('TGT','CMD',{'PARAM1'=>val,'PARAM2'=>val})
|
176
|
-
def build_command(*args, **kwargs)
|
176
|
+
def build_command(*args, range_check: true, raw: false, scope: $openc3_scope, **kwargs)
|
177
177
|
extract_string_kwargs_to_args(args, kwargs)
|
178
178
|
$api_server.build_command(*args)
|
179
179
|
end
|
@@ -188,13 +188,6 @@ module OpenC3
|
|
188
188
|
$api_server.get_cmd_hazardous(*args)
|
189
189
|
end
|
190
190
|
|
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
191
|
# Returns the time the most recent command was sent
|
199
192
|
def get_cmd_time(target_name = nil, command_name = nil, scope: $openc3_scope)
|
200
193
|
results = $api_server.get_cmd_time(target_name, command_name, scope: scope)
|
@@ -22,10 +22,10 @@ module OpenC3
|
|
22
22
|
module Script
|
23
23
|
private
|
24
24
|
|
25
|
-
def
|
25
|
+
def package_list(scope: $openc3_scope)
|
26
26
|
response_body = nil
|
27
27
|
begin
|
28
|
-
endpoint = "/openc3-api/
|
28
|
+
endpoint = "/openc3-api/packages?scope=#{scope}"
|
29
29
|
uri = URI.parse($api_server.generate_url + endpoint)
|
30
30
|
auth = $api_server.generate_auth
|
31
31
|
|
@@ -41,20 +41,21 @@ module OpenC3
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
rescue => error
|
44
|
-
raise "
|
44
|
+
raise "package_list failed due to #{error.formatted}\nResponse:\n#{response_body}"
|
45
45
|
end
|
46
46
|
end
|
47
|
+
alias gem_list package_list
|
47
48
|
|
48
|
-
def
|
49
|
+
def package_install(file_path, scope: $openc3_scope)
|
49
50
|
response_body = nil
|
50
51
|
begin
|
51
|
-
endpoint = "/openc3-api/
|
52
|
+
endpoint = "/openc3-api/packages?scope=#{scope}"
|
52
53
|
uri = URI.parse($api_server.generate_url + endpoint)
|
53
54
|
auth = $api_server.generate_auth
|
54
55
|
|
55
56
|
File.open(file_path, 'rb') do |file|
|
56
57
|
request = Net::HTTP::Post.new(uri)
|
57
|
-
form_data = [["
|
58
|
+
form_data = [["package", file]]
|
58
59
|
request.set_form(form_data, "multipart/form-data")
|
59
60
|
request['User-Agent'] = JsonDRbObject::USER_AGENT
|
60
61
|
request['Authorization'] = auth.token
|
@@ -67,14 +68,15 @@ module OpenC3
|
|
67
68
|
end
|
68
69
|
end
|
69
70
|
rescue => error
|
70
|
-
raise "
|
71
|
+
raise "package_install failed due to #{error.formatted}\nResponse:\n#{response_body}"
|
71
72
|
end
|
72
73
|
end
|
74
|
+
alias gem_install package_install
|
73
75
|
|
74
|
-
def
|
76
|
+
def package_uninstall(package_name, scope: $openc3_scope)
|
75
77
|
response_body = nil
|
76
78
|
begin
|
77
|
-
endpoint = "/openc3-api/
|
79
|
+
endpoint = "/openc3-api/packages/#{package_name}?scope=#{scope}"
|
78
80
|
uri = URI.parse($api_server.generate_url + endpoint)
|
79
81
|
auth = $api_server.generate_auth
|
80
82
|
request = Net::HTTP::Delete.new(uri)
|
@@ -84,22 +86,24 @@ module OpenC3
|
|
84
86
|
http.request(request) do |response|
|
85
87
|
response_body = response.body
|
86
88
|
response.value() # Raises an HTTP error if the response is not 2xx (success)
|
87
|
-
return
|
89
|
+
return response_body.remove_quotes
|
88
90
|
end
|
89
91
|
end
|
90
92
|
rescue => error
|
91
|
-
raise "
|
93
|
+
raise "package_uninstall failed due to #{error.formatted}\nResponse:\n#{response_body}"
|
92
94
|
end
|
93
95
|
end
|
96
|
+
alias package_uninstall package_uninstall
|
94
97
|
|
95
|
-
def
|
98
|
+
def package_status(process_name, scope: $openc3_scope)
|
96
99
|
return plugin_status(process_name, scope: scope)
|
97
100
|
end
|
101
|
+
alias gem_status package_status
|
98
102
|
|
99
|
-
def
|
103
|
+
def package_download(package_name, local_file_path, scope: $openc3_scope)
|
100
104
|
response_body = nil
|
101
105
|
begin
|
102
|
-
endpoint = "/openc3-api/
|
106
|
+
endpoint = "/openc3-api/packages/#{package_name}/download?scope=#{scope}"
|
103
107
|
uri = URI.parse($api_server.generate_url + endpoint)
|
104
108
|
auth = $api_server.generate_auth
|
105
109
|
request = Net::HTTP::Post.new(uri)
|
@@ -117,9 +121,9 @@ module OpenC3
|
|
117
121
|
end
|
118
122
|
end
|
119
123
|
rescue => error
|
120
|
-
raise "
|
124
|
+
raise "package_download failed due to #{error.formatted}\nResponse:\n#{response_body}"
|
121
125
|
end
|
122
126
|
end
|
123
|
-
|
127
|
+
alias gem_download package_download
|
124
128
|
end
|
125
129
|
end
|