openc3 7.5.1 → 7.6.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/Gemfile +0 -0
- data/bin/openc3cli +82 -5
- data/data/config/_params.yaml +3 -0
- data/data/config/command_modifiers.yaml +5 -3
- data/data/config/default_plugins.yaml +1 -0
- data/data/config/interface_modifiers.yaml +17 -1
- data/data/config/item_modifiers.yaml +24 -1
- data/data/config/microservice.yaml +15 -1
- data/data/config/parameter_modifiers.yaml +4 -4
- data/data/config/plugins.yaml +511 -3
- data/data/config/settings.yaml +17 -0
- data/data/config/target.yaml +53 -0
- data/data/config/telemetry.yaml +58 -2
- data/data/config/widgets.yaml +30 -0
- data/lib/openc3/accessors/accessor.rb +14 -2
- data/lib/openc3/accessors/binary_accessor.rb +25 -5
- data/lib/openc3/api/CLAUDE.md +1 -0
- data/lib/openc3/api/api.rb +1 -0
- data/lib/openc3/api/cmd_api.rb +9 -1
- data/lib/openc3/api/interface_api.rb +7 -2
- data/lib/openc3/api/limits_api.rb +93 -41
- data/lib/openc3/api/router_api.rb +7 -2
- data/lib/openc3/api/settings_api.rb +4 -1
- data/lib/openc3/api/shared_resource_api.rb +107 -0
- data/lib/openc3/api/tlm_api.rb +10 -0
- data/lib/openc3/interfaces/http_client_interface.rb +84 -27
- data/lib/openc3/interfaces/protocols/preidentified_protocol.rb +6 -2
- data/lib/openc3/interfaces/tcpip_server_interface.rb +205 -125
- data/lib/openc3/io/json_api.rb +2 -10
- data/lib/openc3/io/json_api_object.rb +2 -10
- data/lib/openc3/logs/packet_log_writer.rb +8 -3
- data/lib/openc3/microservices/decom_common.rb +4 -1
- data/lib/openc3/microservices/decom_microservice.rb +52 -6
- data/lib/openc3/microservices/interface_decom_common.rb +13 -0
- data/lib/openc3/microservices/interface_microservice.rb +50 -11
- data/lib/openc3/microservices/limits_group_microservice.rb +513 -0
- data/lib/openc3/microservices/log_microservice.rb +22 -8
- data/lib/openc3/microservices/microservice.rb +8 -2
- data/lib/openc3/microservices/multi_microservice.rb +76 -22
- data/lib/openc3/microservices/queue_microservice.rb +29 -24
- data/lib/openc3/migrations/20260704000000_default_bridge.rb +1 -2
- data/lib/openc3/migrations/20261103000001_limits_group_backfill.rb +193 -0
- data/lib/openc3/models/bridge_model.rb +3 -3
- data/lib/openc3/models/cvt_model.rb +3 -1
- data/lib/openc3/models/host_interface_microservice_model.rb +4 -4
- data/lib/openc3/models/interface_model.rb +27 -7
- data/lib/openc3/models/microservice_group.rb +167 -0
- data/lib/openc3/models/microservice_model.rb +88 -2
- data/lib/openc3/models/panel_model.rb +109 -0
- data/lib/openc3/models/plugin_model.rb +1006 -26
- data/lib/openc3/models/plugin_store_model.rb +6 -1
- data/lib/openc3/models/protected_storage_model.rb +64 -0
- data/lib/openc3/models/queue_model.rb +19 -10
- data/lib/openc3/models/scope_model.rb +80 -3
- data/lib/openc3/models/setting_model.rb +2 -2
- data/lib/openc3/models/shared_resource_model.rb +381 -0
- data/lib/openc3/models/target_model.rb +324 -68
- data/lib/openc3/operators/microservice_operator.rb +76 -9
- data/lib/openc3/operators/operator.rb +29 -0
- data/lib/openc3/packets/commands.rb +16 -16
- data/lib/openc3/packets/limits.rb +2 -0
- data/lib/openc3/packets/packet.rb +75 -4
- data/lib/openc3/packets/packet_config.rb +152 -13
- data/lib/openc3/packets/packet_item.rb +35 -14
- data/lib/openc3/packets/packet_item_limits.rb +67 -6
- data/lib/openc3/packets/parsers/limits_parser.rb +69 -2
- data/lib/openc3/packets/parsers/packet_item_parser.rb +6 -0
- data/lib/openc3/packets/parsers/packet_parser.rb +45 -0
- data/lib/openc3/packets/parsers/state_parser.rb +1 -1
- data/lib/openc3/script/CLAUDE.md +1 -0
- data/lib/openc3/script/api_shared.rb +17 -9
- data/lib/openc3/script/calendar.rb +18 -6
- data/lib/openc3/script/commands.rb +11 -9
- data/lib/openc3/script/critical_cmd.rb +22 -2
- data/lib/openc3/script/metadata.rb +30 -4
- data/lib/openc3/script/plugins.rb +8 -0
- data/lib/openc3/script/script.rb +8 -24
- data/lib/openc3/script/web_socket_api.rb +23 -17
- data/lib/openc3/system/system.rb +9 -3
- data/lib/openc3/top_level.rb +17 -0
- data/lib/openc3/topics/command_topic.rb +7 -1
- data/lib/openc3/topics/decom_interface_topic.rb +9 -3
- data/lib/openc3/topics/discovery_topic.rb +84 -0
- data/lib/openc3/topics/limits_event_topic.rb +236 -17
- data/lib/openc3/topics/telemetry_decom_topic.rb +12 -3
- data/lib/openc3/topics/topic.rb +2 -1
- data/lib/openc3/utilities/authentication.rb +67 -16
- data/lib/openc3/utilities/cli_generator.rb +117 -25
- data/lib/openc3/utilities/client_ip_header_filter.rb +38 -0
- data/lib/openc3/utilities/config_overlay.rb +24 -1
- data/lib/openc3/utilities/cosmos_rails_formatter.rb +18 -10
- data/lib/openc3/utilities/hardware_discovery.rb +279 -0
- data/lib/openc3/utilities/limits_rollup.rb +81 -0
- data/lib/openc3/utilities/local_mode.rb +48 -5
- data/lib/openc3/utilities/questdb_client.rb +130 -22
- data/lib/openc3/utilities/reingest_job.rb +12 -3
- data/lib/openc3/utilities/running_script.rb +206 -49
- data/lib/openc3/utilities/script.rb +24 -12
- data/lib/openc3/utilities/script_env.rb +164 -0
- data/lib/openc3/utilities/script_message_signing.rb +133 -0
- data/lib/openc3/utilities/store_autoload.rb +32 -1
- data/lib/openc3/utilities/store_queued.rb +5 -1
- data/lib/openc3/version.rb +6 -6
- data/templates/command_validator/command_validator.py +9 -9
- data/templates/{tool_react/pnpm-workspace.yaml → panel/.prettierrc.cjs} +7 -5
- data/templates/panel/Rakefile +24 -0
- data/templates/panel/package.json +17 -0
- data/templates/{tool_angular → panel}/pnpm-workspace.yaml +5 -0
- data/templates/panel/src/Panel.js +52 -0
- data/templates/panel/src/Panel.vue +60 -0
- data/templates/panel/src/panelSdk.js +24 -0
- data/templates/panel/vite-Panel.config.js +43 -0
- data/templates/tool_vue/package.json +3 -3
- data/templates/widget/package.json +2 -2
- metadata +24 -56
- data/templates/tool_angular/.editorconfig +0 -16
- data/templates/tool_angular/.gitignore +0 -44
- data/templates/tool_angular/.vscode/extensions.json +0 -4
- data/templates/tool_angular/.vscode/launch.json +0 -20
- data/templates/tool_angular/.vscode/tasks.json +0 -42
- data/templates/tool_angular/angular.json +0 -111
- data/templates/tool_angular/extra-webpack.config.js +0 -8
- data/templates/tool_angular/package.json +0 -48
- data/templates/tool_angular/src/app/app-routing.module.ts +0 -15
- data/templates/tool_angular/src/app/app.component.html +0 -22
- data/templates/tool_angular/src/app/app.component.scss +0 -18
- data/templates/tool_angular/src/app/app.component.spec.ts +0 -29
- data/templates/tool_angular/src/app/app.component.ts +0 -52
- data/templates/tool_angular/src/app/app.module.ts +0 -30
- data/templates/tool_angular/src/app/custom-overlay-container.ts +0 -17
- data/templates/tool_angular/src/app/empty-route/empty-route.component.ts +0 -7
- data/templates/tool_angular/src/app/openc3-api.d.ts +0 -1
- data/templates/tool_angular/src/assets/.gitkeep +0 -0
- data/templates/tool_angular/src/environments/environment.prod.ts +0 -3
- data/templates/tool_angular/src/environments/environment.ts +0 -16
- data/templates/tool_angular/src/favicon.ico +0 -0
- data/templates/tool_angular/src/index.html +0 -13
- data/templates/tool_angular/src/main.single-spa.ts +0 -40
- data/templates/tool_angular/src/single-spa/asset-url.ts +0 -12
- data/templates/tool_angular/src/single-spa/single-spa-props.ts +0 -8
- data/templates/tool_angular/src/styles.scss +0 -1
- data/templates/tool_angular/tsconfig.app.json +0 -13
- data/templates/tool_angular/tsconfig.json +0 -33
- data/templates/tool_angular/tsconfig.spec.json +0 -14
- data/templates/tool_react/.eslintrc +0 -7
- data/templates/tool_react/.gitignore +0 -71
- data/templates/tool_react/.prettierignore +0 -8
- data/templates/tool_react/babel.config.json +0 -29
- data/templates/tool_react/jest.config.js +0 -12
- data/templates/tool_react/package.json +0 -51
- data/templates/tool_react/src/openc3-tool_name.js +0 -24
- data/templates/tool_react/src/root.component.js +0 -88
- data/templates/tool_react/src/root.component.test.js +0 -9
- data/templates/tool_react/webpack.config.js +0 -27
- data/templates/tool_svelte/.gitignore +0 -71
- data/templates/tool_svelte/.prettierignore +0 -8
- data/templates/tool_svelte/.prettierrc.js +0 -5
- data/templates/tool_svelte/babel.config.js +0 -12
- data/templates/tool_svelte/build/smui.css +0 -1
- data/templates/tool_svelte/jest.config.js +0 -9
- data/templates/tool_svelte/package.json +0 -49
- data/templates/tool_svelte/pnpm-workspace.yaml +0 -20
- data/templates/tool_svelte/rollup.config.js +0 -74
- data/templates/tool_svelte/src/App.svelte +0 -42
- data/templates/tool_svelte/src/App.test.js +0 -9
- data/templates/tool_svelte/src/theme/_smui-theme.scss +0 -25
- data/templates/tool_svelte/src/tool_name.js +0 -17
- data/templates/widget/LICENSE.md +0 -20
|
@@ -85,6 +85,9 @@ module OpenC3
|
|
|
85
85
|
# The allowable state colors
|
|
86
86
|
STATE_COLORS = [:GREEN, :YELLOW, :RED]
|
|
87
87
|
|
|
88
|
+
# Default values (case insensitive) meaning a REQUIRED parameter has no default
|
|
89
|
+
NIL_DEFAULTS = ['NIL', 'NONE', 'NULL']
|
|
90
|
+
|
|
88
91
|
# PacketItemLimits is created on first access since most items have no
|
|
89
92
|
# limits and large definitions have hundreds of thousands of items.
|
|
90
93
|
# @return [PacketItemLimits] All information regarding limits for this PacketItem
|
|
@@ -102,6 +105,11 @@ module OpenC3
|
|
|
102
105
|
@limits ? @limits.values : nil
|
|
103
106
|
end
|
|
104
107
|
|
|
108
|
+
# @return [Symbol, nil] The change limits type without creating PacketItemLimits
|
|
109
|
+
def limits_change_type
|
|
110
|
+
@limits ? @limits.change_type : nil
|
|
111
|
+
end
|
|
112
|
+
|
|
105
113
|
# @return [Boolean] Whether the parameter must be obfuscated from logs or not
|
|
106
114
|
attr_accessor :obfuscate
|
|
107
115
|
|
|
@@ -428,8 +436,12 @@ module OpenC3
|
|
|
428
436
|
config << "\n"
|
|
429
437
|
end
|
|
430
438
|
end
|
|
431
|
-
|
|
439
|
+
elsif limits_change_type
|
|
440
|
+
config << " LIMITS DEFAULT #{@limits.persistence_setting} #{@limits.enabled ? 'ENABLED' : 'DISABLED'} #{@limits.change_type} #{@limits.change_color}"
|
|
441
|
+
config << " #{@limits.sequence_step}" if @limits.change_type == :SEQUENCE && @limits.sequence_step != 1
|
|
442
|
+
config << "\n"
|
|
432
443
|
end
|
|
444
|
+
config << @limits.response.to_config if @limits && @limits.response
|
|
433
445
|
|
|
434
446
|
if @meta
|
|
435
447
|
@meta.each do |key, values|
|
|
@@ -476,25 +488,30 @@ module OpenC3
|
|
|
476
488
|
config['limits'] ||= {}
|
|
477
489
|
if @limits && @limits.enabled
|
|
478
490
|
config['limits']['enabled'] = true
|
|
479
|
-
elsif limits_values || (self.state_colors && self.state_colors.length > 0)
|
|
491
|
+
elsif limits_values || limits_change_type || (self.state_colors && self.state_colors.length > 0)
|
|
480
492
|
# Only set to false if there are limits or state colors
|
|
481
493
|
# to avoid items without limits acting like they can be enabled
|
|
482
494
|
config['limits']['enabled'] = false
|
|
483
495
|
end
|
|
484
|
-
if limits_values
|
|
485
|
-
# Only set these if there are limits
|
|
496
|
+
if limits_values || limits_change_type
|
|
497
|
+
# Only set these if there are limits because persistence_setting has a default
|
|
486
498
|
# and we don't want keys on the 'limits' hash if there aren't any limits
|
|
487
499
|
config['limits']['persistence_setting'] = @limits.persistence_setting if @limits.persistence_setting
|
|
488
500
|
config['limits']['response'] = @limits.response.to_s if @limits.response
|
|
489
|
-
|
|
490
|
-
limits
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
501
|
+
if limits_values
|
|
502
|
+
@limits.values.each do |limits_set, limits_values|
|
|
503
|
+
limits = {}
|
|
504
|
+
limits['red_low'] = limits_values[0]
|
|
505
|
+
limits['yellow_low'] = limits_values[1]
|
|
506
|
+
limits['yellow_high'] = limits_values[2]
|
|
507
|
+
limits['red_high'] = limits_values[3]
|
|
508
|
+
limits['green_low'] = limits_values[4] if limits_values[4]
|
|
509
|
+
limits['green_high'] = limits_values[5] if limits_values[5]
|
|
510
|
+
config['limits'][limits_set] = limits
|
|
511
|
+
end
|
|
512
|
+
else
|
|
513
|
+
config['limits']['DEFAULT'] = { 'change_type' => @limits.change_type.to_s, 'change_color' => @limits.change_color.to_s }
|
|
514
|
+
config['limits']['DEFAULT']['sequence_step'] = @limits.sequence_step if @limits.change_type == :SEQUENCE
|
|
498
515
|
end
|
|
499
516
|
end
|
|
500
517
|
|
|
@@ -515,7 +532,11 @@ module OpenC3
|
|
|
515
532
|
end
|
|
516
533
|
config << "#{@name.to_s.quote_if_necessary} #{@bit_offset} #{@bit_size} #{@data_type} "
|
|
517
534
|
|
|
518
|
-
if
|
|
535
|
+
if value.nil?
|
|
536
|
+
# Only REQUIRED parameters have no default. Only numeric types have a range.
|
|
537
|
+
config << "#{calculate_range().join(' ')} " if [:INT, :UINT, :FLOAT].include?(@data_type)
|
|
538
|
+
val_string = 'nil'
|
|
539
|
+
elsif @data_type == :BLOCK || @data_type == :STRING
|
|
519
540
|
unless value.is_printable?
|
|
520
541
|
val_string = "0x" + value.simple_formatted
|
|
521
542
|
else
|
|
@@ -22,9 +22,17 @@ module OpenC3
|
|
|
22
22
|
# Maintains knowledge of limits for a PacketItem
|
|
23
23
|
class PacketItemLimits
|
|
24
24
|
# Array of all limit states
|
|
25
|
+
# :STALE is never set on an item. It is only returned by
|
|
26
|
+
# CvtModel.get_tlm_values for items whose packet hasn't been received recently.
|
|
25
27
|
LIMITS_STATES = [:RED, :RED_HIGH, :RED_LOW, :YELLOW, :YELLOW_HIGH, :YELLOW_LOW, :GREEN, :GREEN_HIGH, :GREEN_LOW, :BLUE, :STALE, nil]
|
|
26
28
|
# Array of all limit states which should be considered in error
|
|
27
29
|
OUT_OF_LIMITS_STATES = [:RED, :RED_HIGH, :RED_LOW, :YELLOW, :YELLOW_HIGH, :YELLOW_LOW]
|
|
30
|
+
# Array of change limits types. SEQUENCE means the value must increment by
|
|
31
|
+
# the sequence step (default 1) each sample, CHANGE means the value must change each sample, and
|
|
32
|
+
# STATIC means the value must not change.
|
|
33
|
+
CHANGE_TYPES = [:SEQUENCE, :CHANGE, :STATIC]
|
|
34
|
+
# Array of limits states a change limit can go to when violated
|
|
35
|
+
CHANGE_COLORS = [:RED, :YELLOW]
|
|
28
36
|
|
|
29
37
|
# Hash of arrays - Hash key is uppercase symbol designating limits set.
|
|
30
38
|
# :DEFAULT limits set is required if item has limits. nil indicates the
|
|
@@ -36,18 +44,19 @@ module OpenC3
|
|
|
36
44
|
# limits.
|
|
37
45
|
attr_reader :values
|
|
38
46
|
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
#
|
|
47
|
+
# Whether limits checking is enabled for an item with defined limit values
|
|
48
|
+
# or state colors. When enabled the state transitions from nil to the
|
|
49
|
+
# various other states as the item value changes.
|
|
42
50
|
#
|
|
43
51
|
# @return [Boolean] Whether limits are enabled on this item
|
|
44
52
|
attr_accessor :enabled
|
|
45
53
|
|
|
46
|
-
# Current limits state of the item. One of nil, :
|
|
54
|
+
# Current limits state of the item. One of nil, :BLUE, :GREEN,
|
|
47
55
|
# :GREEN_HIGH, :GREEN_LOW, :YELLOW, :YELLOW_HIGH, :YELLOW_LOW,
|
|
48
|
-
# :RED, :RED_HIGH, :RED_LOW. Items initialize to
|
|
56
|
+
# :RED, :RED_HIGH, :RED_LOW. Items initialize to nil and change states
|
|
49
57
|
# as the item value changes. If the limits are disabled the state changes
|
|
50
|
-
# to nil.
|
|
58
|
+
# to nil. :STALE is never set here. It is only returned by
|
|
59
|
+
# CvtModel.get_tlm_values for items whose packet hasn't been received recently.
|
|
51
60
|
# @return [Symbol, nil] Current limits state of the item
|
|
52
61
|
attr_reader :state
|
|
53
62
|
|
|
@@ -63,6 +72,27 @@ module OpenC3
|
|
|
63
72
|
# @return [Integer] Current running persistence count
|
|
64
73
|
attr_reader :persistence_count
|
|
65
74
|
|
|
75
|
+
# Change limits type. One of nil, :SEQUENCE, :CHANGE, :STATIC. Items with a
|
|
76
|
+
# change type are checked against their previous value rather than
|
|
77
|
+
# numeric limits values.
|
|
78
|
+
# @return [Symbol, nil] Change limits type
|
|
79
|
+
attr_reader :change_type
|
|
80
|
+
|
|
81
|
+
# @return [Symbol, nil] Limits state (:RED or :YELLOW) when a change limit is violated
|
|
82
|
+
attr_reader :change_color
|
|
83
|
+
|
|
84
|
+
# @return [Integer] Amount a SEQUENCE value must change by each sample.
|
|
85
|
+
# Negative values count down.
|
|
86
|
+
attr_reader :sequence_step
|
|
87
|
+
|
|
88
|
+
# @return [Object, nil] Previous value used to evaluate change limits
|
|
89
|
+
attr_accessor :last_value
|
|
90
|
+
|
|
91
|
+
# @return [Object, nil] Previous stored (non-realtime) value used to evaluate
|
|
92
|
+
# change limits. Kept separate so interleaved stored and realtime packets
|
|
93
|
+
# are each compared against their own stream.
|
|
94
|
+
attr_accessor :last_stored_value
|
|
95
|
+
|
|
66
96
|
# Create a PacketItemLimits
|
|
67
97
|
def initialize
|
|
68
98
|
@values = nil
|
|
@@ -71,6 +101,11 @@ module OpenC3
|
|
|
71
101
|
@response = nil
|
|
72
102
|
@persistence_setting = 1
|
|
73
103
|
@persistence_count = 0
|
|
104
|
+
@change_type = nil
|
|
105
|
+
@change_color = nil
|
|
106
|
+
@sequence_step = 1
|
|
107
|
+
@last_value = nil
|
|
108
|
+
@last_stored_value = nil
|
|
74
109
|
end
|
|
75
110
|
|
|
76
111
|
def values=(values)
|
|
@@ -122,6 +157,24 @@ module OpenC3
|
|
|
122
157
|
@persistence_count = persistence_count
|
|
123
158
|
end
|
|
124
159
|
|
|
160
|
+
def change_type=(change_type)
|
|
161
|
+
raise ArgumentError, "change_type must be one of #{CHANGE_TYPES} but is #{change_type}" unless change_type.nil? || CHANGE_TYPES.include?(change_type)
|
|
162
|
+
|
|
163
|
+
@change_type = change_type
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def change_color=(change_color)
|
|
167
|
+
raise ArgumentError, "change_color must be one of #{CHANGE_COLORS} but is #{change_color}" unless change_color.nil? || CHANGE_COLORS.include?(change_color)
|
|
168
|
+
|
|
169
|
+
@change_color = change_color
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def sequence_step=(sequence_step)
|
|
173
|
+
raise ArgumentError, "sequence_step must be a non-zero Integer but is #{sequence_step}" unless Integer === sequence_step && sequence_step != 0
|
|
174
|
+
|
|
175
|
+
@sequence_step = sequence_step
|
|
176
|
+
end
|
|
177
|
+
|
|
125
178
|
# Make a light weight clone of this limits
|
|
126
179
|
def clone
|
|
127
180
|
limits = super()
|
|
@@ -143,6 +196,11 @@ module OpenC3
|
|
|
143
196
|
end
|
|
144
197
|
hash['persistence_setting'] = self.persistence_setting
|
|
145
198
|
hash['persistence_count'] = self.persistence_count
|
|
199
|
+
if self.change_type
|
|
200
|
+
hash['change_type'] = self.change_type.to_s
|
|
201
|
+
hash['change_color'] = self.change_color.to_s
|
|
202
|
+
hash['sequence_step'] = self.sequence_step if self.change_type == :SEQUENCE
|
|
203
|
+
end
|
|
146
204
|
hash
|
|
147
205
|
end
|
|
148
206
|
|
|
@@ -155,6 +213,9 @@ module OpenC3
|
|
|
155
213
|
# limits.response = hash['response']
|
|
156
214
|
limits.persistence_setting = hash['persistence_setting'] if hash['persistence_setting']
|
|
157
215
|
limits.persistence_count = hash['persistence_count'] if hash['persistence_count']
|
|
216
|
+
limits.change_type = hash['change_type'].to_sym if hash['change_type']
|
|
217
|
+
limits.change_color = hash['change_color'].to_sym if hash['change_color']
|
|
218
|
+
limits.sequence_step = hash['sequence_step'] if hash['sequence_step']
|
|
158
219
|
limits
|
|
159
220
|
end
|
|
160
221
|
end
|
|
@@ -41,12 +41,23 @@ module OpenC3
|
|
|
41
41
|
raise @parser.error("LIMITS only applies to telemetry items")
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
if change_limits?
|
|
45
|
+
@usage = "LIMITS <LIMITS SET> <PERSISTENCE> <ENABLED/DISABLED> <SEQUENCE/CHANGE/STATIC> <RED/YELLOW> <SEQUENCE STEP (Optional)>"
|
|
46
|
+
@parser.verify_num_parameters(5, 6, @usage)
|
|
47
|
+
else
|
|
48
|
+
@usage = "LIMITS <LIMITS SET> <PERSISTENCE> <ENABLED/DISABLED> <RED LOW LIMIT> <YELLOW LOW LIMIT> <YELLOW HIGH LIMIT> <RED HIGH LIMIT> <GREEN LOW LIMIT (Optional)> <GREEN HIGH LIMIT (Optional)>"
|
|
49
|
+
@parser.verify_num_parameters(7, 9, @usage)
|
|
50
|
+
end
|
|
46
51
|
end
|
|
47
52
|
|
|
48
53
|
# @param packet [Packet] The packet the item should be added to
|
|
49
54
|
def create_limits(packet, item, warnings)
|
|
55
|
+
return create_change_limits(packet, item) if change_limits?
|
|
56
|
+
|
|
57
|
+
if item.limits.change_type
|
|
58
|
+
raise @parser.error("Item #{item.name} already has #{item.limits.change_type} limits and can't also define numeric LIMITS", @usage)
|
|
59
|
+
end
|
|
60
|
+
|
|
50
61
|
limits_set = get_limits_set()
|
|
51
62
|
initialize_limits_values(packet, item)
|
|
52
63
|
ensure_consistency_with_default(packet, item, warnings)
|
|
@@ -62,6 +73,62 @@ module OpenC3
|
|
|
62
73
|
|
|
63
74
|
private
|
|
64
75
|
|
|
76
|
+
# @return [Boolean] Whether the LIMITS keyword defines change limits
|
|
77
|
+
# (SEQUENCE, CHANGE, or STATIC) rather than numeric limits
|
|
78
|
+
def change_limits?
|
|
79
|
+
type = @parser.parameters[3]
|
|
80
|
+
type && PacketItemLimits::CHANGE_TYPES.include?(type.upcase.to_sym)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def create_change_limits(packet, item)
|
|
84
|
+
limits_set = get_limits_set()
|
|
85
|
+
if limits_set != :DEFAULT
|
|
86
|
+
raise @parser.error("#{@parser.parameters[3].upcase} limits can only be defined in the DEFAULT limits set", @usage)
|
|
87
|
+
end
|
|
88
|
+
if item.limits.values || item.limits.change_type
|
|
89
|
+
raise @parser.error("Item #{item.name} already has LIMITS defined", @usage)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
change_type = @parser.parameters[3].upcase.to_sym
|
|
93
|
+
if change_type == :SEQUENCE && item.array_size
|
|
94
|
+
raise @parser.error("SEQUENCE limits can't be applied to array items", @usage)
|
|
95
|
+
end
|
|
96
|
+
if change_type == :SEQUENCE && ![:INT, :UINT, :FLOAT, :DERIVED].include?(item.data_type)
|
|
97
|
+
raise @parser.error("SEQUENCE limits can only be applied to INT, UINT, FLOAT, or DERIVED items", @usage)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
change_color = @parser.parameters[4].upcase.to_sym
|
|
101
|
+
unless PacketItemLimits::CHANGE_COLORS.include?(change_color)
|
|
102
|
+
raise @parser.error("#{change_type} limits color must be RED or YELLOW", @usage)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
sequence_step = get_sequence_step(change_type)
|
|
106
|
+
|
|
107
|
+
item.limits.change_type = change_type
|
|
108
|
+
item.limits.change_color = change_color
|
|
109
|
+
item.limits.sequence_step = sequence_step
|
|
110
|
+
item.limits.enabled = get_enabled()
|
|
111
|
+
item.limits.persistence_setting = get_persistence()
|
|
112
|
+
|
|
113
|
+
packet.update_limits_items_cache(item)
|
|
114
|
+
limits_set
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def get_sequence_step(change_type)
|
|
118
|
+
step = @parser.parameters[5]
|
|
119
|
+
return 1 unless step
|
|
120
|
+
raise @parser.error("Only SEQUENCE limits take a step parameter", @usage) unless change_type == :SEQUENCE
|
|
121
|
+
|
|
122
|
+
begin
|
|
123
|
+
step = Integer(step, 10)
|
|
124
|
+
rescue ArgumentError, TypeError
|
|
125
|
+
raise @parser.error("SEQUENCE step must be an integer", @usage)
|
|
126
|
+
end
|
|
127
|
+
raise @parser.error("SEQUENCE step can't be zero", @usage) if step == 0
|
|
128
|
+
|
|
129
|
+
step
|
|
130
|
+
end
|
|
131
|
+
|
|
65
132
|
def initialize_limits_values(packet, item)
|
|
66
133
|
limits_set = get_limits_set()
|
|
67
134
|
# Values must be initialized with a :DEFAULT key
|
|
@@ -240,6 +240,12 @@ module OpenC3
|
|
|
240
240
|
|
|
241
241
|
index = append? ? 3 : 4
|
|
242
242
|
data_type = get_data_type()
|
|
243
|
+
# nil, none, or null means no default which is only allowed for REQUIRED
|
|
244
|
+
# parameters. REQUIRED comes later so PacketParser.check_item_data_types
|
|
245
|
+
# resolves it. STRING, BLOCK, and numeric types already keep it as is.
|
|
246
|
+
nil_default = PacketItem::NIL_DEFAULTS.include?(@parser.parameters[index].to_s.upcase)
|
|
247
|
+
return @parser.parameters[index] if nil_default and [:BOOL, :ARRAY, :OBJECT].include?(data_type)
|
|
248
|
+
|
|
243
249
|
if data_type == :BOOL
|
|
244
250
|
value = @parser.parameters[index].to_s.upcase
|
|
245
251
|
if value == "TRUE" or value == "FALSE"
|
|
@@ -54,6 +54,7 @@ module OpenC3
|
|
|
54
54
|
# appropriate data types. Only applicable to COMMAND packets.
|
|
55
55
|
def self.check_item_data_types(packet)
|
|
56
56
|
packet.sorted_items.each do |item|
|
|
57
|
+
resolve_nil_default(item)
|
|
57
58
|
item.check_default_and_range_data_types()
|
|
58
59
|
end
|
|
59
60
|
rescue
|
|
@@ -62,6 +63,50 @@ module OpenC3
|
|
|
62
63
|
raise $!, "#{packet.target_name} #{packet.packet_name} #{$!}", $!.backtrace
|
|
63
64
|
end
|
|
64
65
|
|
|
66
|
+
# REQUIRED parameters can use nil, none, or null as the default since their
|
|
67
|
+
# default is never used. This is resolved once the packet is complete
|
|
68
|
+
# because REQUIRED comes after the PARAMETER line.
|
|
69
|
+
#
|
|
70
|
+
# @param item [PacketItem] Command parameter to check
|
|
71
|
+
def self.resolve_nil_default(item)
|
|
72
|
+
return unless String === item.default and PacketItem::NIL_DEFAULTS.include?(item.default.upcase)
|
|
73
|
+
|
|
74
|
+
if item.required
|
|
75
|
+
item.default = nil
|
|
76
|
+
elsif !item.write_conversion and ![:STRING, :BLOCK, :ANY, :DERIVED].include?(item.data_type)
|
|
77
|
+
# STRING, BLOCK, ANY, and DERIVED keep it as a literal value, as does
|
|
78
|
+
# any parameter with a WRITE_CONVERSION which converts it
|
|
79
|
+
raise ArgumentError, "#{item.name}: default of #{item.default} is only allowed for REQUIRED parameters"
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Check that each STRING and BLOCK default fits in its item. A default that
|
|
84
|
+
# doesn't fit makes the command impossible to build unless the parameter
|
|
85
|
+
# is given. This only runs at plugin install (TargetModel#deploy) so
|
|
86
|
+
# targets installed before this check was added still load.
|
|
87
|
+
#
|
|
88
|
+
# @param packet [Packet] Command packet to check
|
|
89
|
+
def self.check_item_default_sizes(packet)
|
|
90
|
+
return unless packet.accessor.is_a?(BinaryAccessor)
|
|
91
|
+
|
|
92
|
+
packet.sorted_items.each do |item|
|
|
93
|
+
next unless item.data_type == :STRING or item.data_type == :BLOCK
|
|
94
|
+
next unless String === item.default
|
|
95
|
+
next if item.array_size or item.variable_bit_size or item.parent_item or item.write_conversion
|
|
96
|
+
next if item.bit_size <= 0 or item.overflow == :TRUNCATE
|
|
97
|
+
|
|
98
|
+
# A default that names a state writes the state's value
|
|
99
|
+
default = item.default
|
|
100
|
+
default = item.states[default.upcase] || default if item.states
|
|
101
|
+
next unless String === default
|
|
102
|
+
|
|
103
|
+
byte_size = item.bit_size / 8
|
|
104
|
+
next if default.bytesize <= byte_size
|
|
105
|
+
|
|
106
|
+
raise ArgumentError, "#{packet.target_name} #{packet.packet_name} #{item.name}: default value of #{default.bytesize} bytes does not fit into #{byte_size} bytes for data_type #{item.data_type}"
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
65
110
|
# @param parser [ConfigParser] Configuration parser
|
|
66
111
|
def initialize(parser)
|
|
67
112
|
@parser = parser
|
|
@@ -26,7 +26,7 @@ module OpenC3
|
|
|
26
26
|
# @param warnings [Array<String>] Array of string warnings which will be
|
|
27
27
|
# appended with any warnings found when parsing the limits
|
|
28
28
|
def self.parse(parser, packet, cmd_or_tlm, item, warnings)
|
|
29
|
-
raise parser.error("Items with LIMITS can't define STATE") if item.limits_values
|
|
29
|
+
raise parser.error("Items with LIMITS can't define STATE") if item.limits_values || item.limits_change_type
|
|
30
30
|
raise parser.error("Items with UNITS can't define STATE") if item.units
|
|
31
31
|
|
|
32
32
|
parser = StateParser.new(parser)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
When any files in this directory are modified, update the appropriate documentation in docs.openc3.com/docs/guides/scripting-api.md and docs.openc3.com/docs/guides/script-writing.md
|
|
@@ -50,25 +50,33 @@ module OpenC3
|
|
|
50
50
|
|
|
51
51
|
# @deprecated
|
|
52
52
|
def check_with_units(*args, scope: $openc3_scope, token: $openc3_token)
|
|
53
|
+
OpenC3.deprecation_warning("`check_with_units` is deprecated. Please use `check_formatted` instead.", uplevel: 1)
|
|
53
54
|
check(*args, type: :FORMATTED, scope: scope, token: token)
|
|
54
55
|
end
|
|
55
56
|
|
|
56
57
|
# Executes the passed method and expects an exception to be raised.
|
|
57
|
-
# Raises a CheckError if an Exception is not raised.
|
|
58
|
+
# Raises a CheckError if the method does not exist or an Exception is not raised.
|
|
58
59
|
# Usage:
|
|
59
60
|
# check_exception(method_name, method_params}
|
|
60
61
|
def check_exception(method_name, *args, **kwargs)
|
|
62
|
+
# Check outside the rescue so an unknown method doesn't count as the expected exception
|
|
63
|
+
unless respond_to?(method_name.intern, true)
|
|
64
|
+
raise(CheckError, "check_exception: #{method_name} is not a scripting method")
|
|
65
|
+
end
|
|
66
|
+
|
|
61
67
|
orig_kwargs = kwargs.clone
|
|
62
68
|
kwargs[:scope] = $openc3_scope unless kwargs[:scope]
|
|
63
69
|
kwargs[:token] = $openc3_token unless kwargs[:token]
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
begin
|
|
71
|
+
send(method_name.intern, *args, **kwargs)
|
|
72
|
+
rescue Exception => e
|
|
73
|
+
puts "CHECK: #{method_name} raised #{e.class}:#{e.message}"
|
|
74
|
+
else
|
|
75
|
+
method = "#{method_name}(#{args.join(", ")}"
|
|
76
|
+
method += ", #{orig_kwargs}" unless orig_kwargs.empty?
|
|
77
|
+
method += ")"
|
|
78
|
+
raise(CheckError, "#{method} should have raised an exception but did not.")
|
|
79
|
+
end
|
|
72
80
|
end
|
|
73
81
|
|
|
74
82
|
# Check the converted value of a telmetry item against an expected value with a tolerance.
|
|
@@ -90,18 +90,30 @@ module OpenC3
|
|
|
90
90
|
|
|
91
91
|
def get_timeline_activities(name, start: nil, stop: nil, limit: nil, scope: $openc3_scope)
|
|
92
92
|
url = "/openc3-api/timeline/#{name}/activities"
|
|
93
|
+
params = []
|
|
93
94
|
if start and stop
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if limit
|
|
97
|
-
url += "?limit=#{limit}"
|
|
95
|
+
params << "start=#{start}"
|
|
96
|
+
params << "stop=#{stop}"
|
|
98
97
|
end
|
|
98
|
+
params << "limit=#{limit}" if limit
|
|
99
|
+
url += "?#{params.join('&')}" unless params.empty?
|
|
99
100
|
response = $api_server.request('get', url, scope: scope)
|
|
100
101
|
return _cal_handle_response(response, 'Failed to get timeline activities')
|
|
101
102
|
end
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
# Deletes an activity from the specified timeline.
|
|
105
|
+
#
|
|
106
|
+
# @param name [String] The name of the timeline.
|
|
107
|
+
# @param start [Integer] The start time of the activity (Unix seconds). With recurring,
|
|
108
|
+
# the start of an occurrence of the group that still exists.
|
|
109
|
+
# @param uuid [String] The UUID of the activity. With recurring, the recurring group UUID
|
|
110
|
+
# (activity['recurring']['uuid']).
|
|
111
|
+
# @param recurring [Boolean] Whether to also delete every activity in the same recurring group.
|
|
112
|
+
# @param scope [String, optional] The scope of the timeline. Defaults to OPENC3_SCOPE.
|
|
113
|
+
def delete_timeline_activity(name, start, uuid, recurring: false, scope: $openc3_scope)
|
|
114
|
+
url = "/openc3-api/timeline/#{name}/activity/#{start}/#{uuid}"
|
|
115
|
+
url += "?recurring=true" if recurring
|
|
116
|
+
response = $api_server.request('delete', url, scope: scope)
|
|
105
117
|
return _cal_handle_response(response, 'Failed to delete timeline activity')
|
|
106
118
|
end
|
|
107
119
|
|
|
@@ -84,7 +84,7 @@ module OpenC3
|
|
|
84
84
|
def _cmd_disconnect(cmd, raw, no_range, no_hazardous, *args, scope: $openc3_scope)
|
|
85
85
|
case args.length
|
|
86
86
|
when 1
|
|
87
|
-
target_name, cmd_name, cmd_params = extract_fields_from_cmd_text(args[0])
|
|
87
|
+
target_name, cmd_name, cmd_params = extract_fields_from_cmd_text(args[0], scope: scope)
|
|
88
88
|
when 2, 3
|
|
89
89
|
target_name = args[0]
|
|
90
90
|
cmd_name = args[1]
|
|
@@ -117,17 +117,19 @@ module OpenC3
|
|
|
117
117
|
# except for range_check, hazardous_check, and raw as they are part of the cmd name
|
|
118
118
|
# manual is always false since this is called from script and that is the default
|
|
119
119
|
# NOTE: This is a helper method and should not be called directly
|
|
120
|
-
def _cmd(cmd, cmd_no_hazardous, *args, timeout: nil, log_message: nil, validate: true, queue: nil, scope: $openc3_scope, token: $openc3_token, **kwargs)
|
|
120
|
+
def _cmd(cmd, cmd_no_hazardous, *args, timeout: nil, log_message: nil, validate: true, queue: nil, extra: nil, scope: $openc3_scope, token: $openc3_token, **kwargs)
|
|
121
121
|
extract_string_kwargs_to_args(args, kwargs)
|
|
122
122
|
raw = cmd.include?('raw')
|
|
123
123
|
no_range = cmd.include?('no_range') || cmd.include?('no_checks')
|
|
124
124
|
no_hazardous = cmd.include?('no_hazardous') || cmd.include?('no_checks')
|
|
125
|
+
# Only send extra when given so commands still work against servers that predate it
|
|
126
|
+
extra_kwargs = extra.nil? ? {} : { extra: extra }
|
|
125
127
|
if $disconnect
|
|
126
128
|
_cmd_disconnect(cmd, raw, no_range, no_hazardous, *args, scope: scope)
|
|
127
129
|
else
|
|
128
130
|
begin
|
|
129
131
|
begin
|
|
130
|
-
command = $api_server.method_missing(cmd, *args, timeout: timeout, log_message: log_message, validate: validate, queue: queue, scope: scope, token: token)
|
|
132
|
+
command = $api_server.method_missing(cmd, *args, timeout: timeout, log_message: log_message, validate: validate, queue: queue, **extra_kwargs, scope: scope, token: token)
|
|
131
133
|
if log_message.nil? or log_message
|
|
132
134
|
_log_cmd(command, raw, no_range, no_hazardous)
|
|
133
135
|
end
|
|
@@ -135,14 +137,14 @@ module OpenC3
|
|
|
135
137
|
# This opens a prompt at which point they can cancel and stop the script
|
|
136
138
|
# or say Yes and send the command. Thus we don't care about the return value.
|
|
137
139
|
prompt_for_hazardous(e.target_name, e.cmd_name, e.hazardous_description)
|
|
138
|
-
command = $api_server.method_missing(cmd_no_hazardous, *args, timeout: timeout, log_message: log_message, validate: validate, queue: queue, scope: scope, token: token)
|
|
140
|
+
command = $api_server.method_missing(cmd_no_hazardous, *args, timeout: timeout, log_message: log_message, validate: validate, queue: queue, **extra_kwargs, scope: scope, token: token)
|
|
139
141
|
if log_message.nil? or log_message
|
|
140
142
|
_log_cmd(command, raw, no_range, no_hazardous)
|
|
141
143
|
end
|
|
142
144
|
end
|
|
143
145
|
rescue CriticalCmdError => e
|
|
144
146
|
# This should not return until the critical command has been approved
|
|
145
|
-
prompt_for_critical_cmd(e.uuid, e.command['username'], e.command['target_name'], e.command['cmd_name'], e.command['cmd_params'], e.command['cmd_string'])
|
|
147
|
+
prompt_for_critical_cmd(e.uuid, e.command['username'], e.command['target_name'], e.command['cmd_name'], e.command['cmd_params'], e.command['cmd_string'], scope: scope)
|
|
146
148
|
if log_message.nil? or log_message
|
|
147
149
|
_log_cmd(e.command, raw, no_range, no_hazardous)
|
|
148
150
|
end
|
|
@@ -193,9 +195,9 @@ module OpenC3
|
|
|
193
195
|
# Accepts two different calling styles:
|
|
194
196
|
# build_cmd("TGT CMD with PARAM1 val, PARAM2 val")
|
|
195
197
|
# build_cmd('TGT','CMD',{'PARAM1'=>val,'PARAM2'=>val})
|
|
196
|
-
def build_cmd(*args, range_check: true, raw: false, scope: $openc3_scope, **kwargs)
|
|
198
|
+
def build_cmd(*args, range_check: true, raw: false, timeout: 5, scope: $openc3_scope, **kwargs)
|
|
197
199
|
extract_string_kwargs_to_args(args, kwargs)
|
|
198
|
-
$api_server.build_cmd(*args)
|
|
200
|
+
$api_server.build_cmd(*args, range_check: range_check, raw: raw, timeout: timeout, scope: scope)
|
|
199
201
|
end
|
|
200
202
|
# build_command is DEPRECATED
|
|
201
203
|
alias build_command build_cmd
|
|
@@ -205,9 +207,9 @@ module OpenC3
|
|
|
205
207
|
# Accepts two different calling styles:
|
|
206
208
|
# get_cmd_hazardous("TGT CMD with PARAM1 val, PARAM2 val")
|
|
207
209
|
# get_cmd_hazardous('TGT','CMD',{'PARAM1'=>val,'PARAM2'=>val})
|
|
208
|
-
def get_cmd_hazardous(*args, **kwargs)
|
|
210
|
+
def get_cmd_hazardous(*args, scope: $openc3_scope, **kwargs)
|
|
209
211
|
extract_string_kwargs_to_args(args, kwargs)
|
|
210
|
-
$api_server.get_cmd_hazardous(*args)
|
|
212
|
+
$api_server.get_cmd_hazardous(*args, scope: scope)
|
|
211
213
|
end
|
|
212
214
|
|
|
213
215
|
# Returns the time the most recent command was sent
|
|
@@ -29,6 +29,26 @@ module OpenC3
|
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
# Returns a Hash with 'status', 'approvers' (users who have approved so far)
|
|
33
|
+
# and 'approvers_required' (number of approvals needed to send the command)
|
|
34
|
+
def critical_cmd_info(uuid, scope: $openc3_scope)
|
|
35
|
+
begin
|
|
36
|
+
endpoint = "/openc3-api/criticalcmd/status/#{uuid}"
|
|
37
|
+
response = $api_server.request('get', endpoint, scope: scope)
|
|
38
|
+
if response.nil? || response.status != 200
|
|
39
|
+
raise "Unexpected response to critical_cmd_info: #{response.inspect}"
|
|
40
|
+
end
|
|
41
|
+
result = JSON.parse(response.body)
|
|
42
|
+
return {
|
|
43
|
+
'status' => result['status'],
|
|
44
|
+
'approvers' => result['approvers'] || [],
|
|
45
|
+
'approvers_required' => result['approvers_required'] || 1,
|
|
46
|
+
}
|
|
47
|
+
rescue => error
|
|
48
|
+
raise "critical_cmd_info failed due to #{error.formatted}"
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
32
52
|
def critical_cmd_approve(uuid, scope: $openc3_scope)
|
|
33
53
|
begin
|
|
34
54
|
endpoint = "/openc3-api/criticalcmd/approve/#{uuid}"
|
|
@@ -36,7 +56,7 @@ module OpenC3
|
|
|
36
56
|
if response.nil? || response.status != 200
|
|
37
57
|
if response
|
|
38
58
|
parsed = JSON.parse(response.body)
|
|
39
|
-
raise "critical_cmd_approve error: #{parsed['error']}"
|
|
59
|
+
raise "critical_cmd_approve error: #{parsed['message'] || parsed['error']}"
|
|
40
60
|
else
|
|
41
61
|
raise "critical_cmd_approve failed"
|
|
42
62
|
end
|
|
@@ -54,7 +74,7 @@ module OpenC3
|
|
|
54
74
|
if response.nil? || response.status != 200
|
|
55
75
|
if response
|
|
56
76
|
parsed = JSON.parse(response.body)
|
|
57
|
-
raise "critical_cmd_reject error: #{parsed['error']}"
|
|
77
|
+
raise "critical_cmd_reject error: #{parsed['message'] || parsed['error']}"
|
|
58
78
|
else
|
|
59
79
|
raise "critical_cmd_reject failed"
|
|
60
80
|
end
|