openc3 5.1.1 → 5.2.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/bin/openc3cli +48 -9
- data/data/config/interface_modifiers.yaml +14 -0
- data/data/config/parameter_modifiers.yaml +5 -3
- data/data/config/screen.yaml +12 -8
- data/data/config/target.yaml +33 -0
- data/ext/openc3/ext/config_parser/config_parser.c +66 -63
- data/ext/openc3/ext/packet/packet.c +1 -4
- data/lib/openc3/api/README.md +5 -0
- data/lib/openc3/api/api.rb +3 -1
- data/lib/openc3/api/cmd_api.rb +43 -112
- data/lib/openc3/api/interface_api.rb +3 -3
- data/lib/openc3/api/offline_access_api.rb +78 -0
- data/lib/openc3/api/settings_api.rb +3 -1
- data/lib/openc3/api/stash_api.rb +63 -0
- data/lib/openc3/api/target_api.rb +4 -5
- data/lib/openc3/config/config_parser.rb +47 -47
- data/lib/openc3/interfaces/interface.rb +11 -1
- data/lib/openc3/interfaces/protocols/burst_protocol.rb +30 -16
- data/lib/openc3/interfaces/protocols/fixed_protocol.rb +8 -2
- data/lib/openc3/interfaces/protocols/ignore_packet_protocol.rb +2 -2
- data/lib/openc3/interfaces/protocols/override_protocol.rb +2 -2
- data/lib/openc3/interfaces/tcpip_server_interface.rb +3 -1
- data/lib/openc3/io/json_api_object.rb +30 -9
- data/lib/openc3/io/json_drb.rb +6 -1
- data/lib/openc3/io/json_drb_object.rb +18 -9
- data/lib/openc3/io/json_rpc.rb +5 -3
- data/lib/openc3/logs/buffered_packet_log_writer.rb +1 -1
- data/lib/openc3/logs/log_writer.rb +8 -2
- data/lib/openc3/microservices/cleanup_microservice.rb +3 -3
- data/lib/openc3/microservices/decom_microservice.rb +8 -8
- data/lib/openc3/microservices/interface_microservice.rb +86 -71
- data/lib/openc3/microservices/log_microservice.rb +5 -3
- data/lib/openc3/microservices/microservice.rb +18 -14
- data/lib/openc3/microservices/multi_microservice.rb +62 -0
- data/lib/openc3/microservices/periodic_microservice.rb +58 -0
- data/lib/openc3/microservices/reaction_microservice.rb +61 -47
- data/lib/openc3/microservices/reducer_microservice.rb +64 -40
- data/lib/openc3/microservices/router_microservice.rb +4 -4
- data/lib/openc3/microservices/text_log_microservice.rb +2 -2
- data/lib/openc3/microservices/timeline_microservice.rb +44 -30
- data/lib/openc3/microservices/trigger_group_microservice.rb +39 -36
- data/lib/openc3/migrations/20221202214600_add_target_names.rb +30 -0
- data/lib/openc3/migrations/20221210174900_convert_to_multi.rb +65 -0
- data/lib/openc3/models/cvt_model.rb +1 -1
- data/lib/openc3/models/gem_model.rb +24 -20
- data/lib/openc3/models/interface_model.rb +69 -35
- data/lib/openc3/models/metadata_model.rb +1 -1
- data/lib/openc3/models/microservice_model.rb +7 -24
- data/lib/openc3/models/migration_model.rb +52 -0
- data/lib/openc3/models/model.rb +2 -7
- data/lib/openc3/models/note_model.rb +1 -1
- data/lib/openc3/models/offline_access_model.rb +55 -0
- data/lib/openc3/models/plugin_model.rb +12 -3
- data/lib/openc3/models/reaction_model.rb +6 -2
- data/lib/openc3/models/scope_model.rb +89 -13
- data/lib/openc3/models/settings_model.rb +1 -1
- data/lib/openc3/models/stash_model.rb +53 -0
- data/lib/openc3/models/target_model.rb +301 -130
- data/lib/openc3/models/tool_model.rb +1 -12
- data/lib/openc3/models/widget_model.rb +1 -6
- data/lib/openc3/operators/microservice_operator.rb +45 -6
- data/lib/openc3/operators/operator.rb +27 -5
- data/lib/openc3/packets/commands.rb +1 -25
- data/lib/openc3/packets/limits.rb +0 -75
- data/lib/openc3/packets/packet.rb +0 -28
- data/lib/openc3/packets/packet_item.rb +23 -0
- data/lib/openc3/packets/packet_item_limits.rb +2 -2
- data/lib/openc3/packets/parsers/state_parser.rb +10 -6
- data/lib/openc3/packets/telemetry.rb +1 -45
- data/lib/openc3/script/commands.rb +41 -71
- data/lib/openc3/script/extract.rb +15 -1
- data/lib/openc3/script/{calendar.rb → metadata.rb} +42 -17
- data/lib/openc3/script/script.rb +13 -5
- data/lib/openc3/script/storage.rb +3 -1
- data/lib/openc3/system/system.rb +19 -17
- data/lib/openc3/tools/cmd_tlm_server/interface_thread.rb +4 -4
- data/lib/openc3/top_level.rb +3 -3
- data/lib/openc3/topics/command_decom_topic.rb +2 -2
- data/lib/openc3/topics/command_topic.rb +7 -6
- data/lib/openc3/topics/interface_topic.rb +2 -2
- data/lib/openc3/topics/router_topic.rb +1 -1
- data/lib/openc3/topics/telemetry_topic.rb +2 -1
- data/lib/openc3/utilities/authentication.rb +35 -14
- data/lib/openc3/utilities/aws_bucket.rb +4 -3
- data/lib/openc3/utilities/bucket.rb +4 -2
- data/lib/openc3/utilities/bucket_file_cache.rb +3 -8
- data/lib/openc3/utilities/bucket_utilities.rb +77 -15
- data/lib/openc3/utilities/local_mode.rb +12 -9
- data/lib/openc3/utilities/logger.rb +17 -9
- data/lib/openc3/utilities/message_log.rb +6 -5
- data/lib/openc3/utilities/migration.rb +22 -0
- data/lib/openc3/utilities/store_autoload.rb +7 -5
- data/lib/openc3/utilities/target_file.rb +9 -7
- data/lib/openc3/version.rb +6 -6
- data/lib/openc3.rb +2 -1
- metadata +14 -3
|
@@ -17,11 +17,12 @@
|
|
|
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/models/model'
|
|
24
24
|
require 'openc3/models/microservice_model'
|
|
25
|
+
require 'openc3/models/target_model'
|
|
25
26
|
|
|
26
27
|
module OpenC3
|
|
27
28
|
class InterfaceModel < Model
|
|
@@ -29,7 +30,9 @@ module OpenC3
|
|
|
29
30
|
ROUTERS_PRIMARY_KEY = 'openc3_routers'
|
|
30
31
|
|
|
31
32
|
attr_accessor :config_params
|
|
32
|
-
attr_accessor :target_names
|
|
33
|
+
attr_accessor :target_names # Redundant superset of cmd_target_names and tlm_target_names for backwards compat
|
|
34
|
+
attr_accessor :cmd_target_names
|
|
35
|
+
attr_accessor :tlm_target_names
|
|
33
36
|
attr_accessor :connect_on_startup
|
|
34
37
|
attr_accessor :auto_reconnect
|
|
35
38
|
attr_accessor :reconnect_delay
|
|
@@ -91,6 +94,8 @@ module OpenC3
|
|
|
91
94
|
name:,
|
|
92
95
|
config_params: [],
|
|
93
96
|
target_names: [],
|
|
97
|
+
cmd_target_names: [],
|
|
98
|
+
tlm_target_names: [],
|
|
94
99
|
connect_on_startup: true,
|
|
95
100
|
auto_reconnect: true,
|
|
96
101
|
reconnect_delay: 5.0,
|
|
@@ -111,6 +116,8 @@ module OpenC3
|
|
|
111
116
|
end
|
|
112
117
|
@config_params = config_params
|
|
113
118
|
@target_names = target_names
|
|
119
|
+
@cmd_target_names = cmd_target_names
|
|
120
|
+
@tlm_target_names = tlm_target_names
|
|
114
121
|
@connect_on_startup = connect_on_startup
|
|
115
122
|
@auto_reconnect = auto_reconnect
|
|
116
123
|
@reconnect_delay = reconnect_delay
|
|
@@ -133,6 +140,8 @@ module OpenC3
|
|
|
133
140
|
interface_or_router = klass.new
|
|
134
141
|
end
|
|
135
142
|
interface_or_router.target_names = @target_names.dup
|
|
143
|
+
interface_or_router.cmd_target_names = @cmd_target_names.dup
|
|
144
|
+
interface_or_router.tlm_target_names = @tlm_target_names.dup
|
|
136
145
|
interface_or_router.connect_on_startup = @connect_on_startup
|
|
137
146
|
interface_or_router.auto_reconnect = @auto_reconnect
|
|
138
147
|
interface_or_router.reconnect_delay = @reconnect_delay
|
|
@@ -152,6 +161,8 @@ module OpenC3
|
|
|
152
161
|
'name' => @name,
|
|
153
162
|
'config_params' => @config_params,
|
|
154
163
|
'target_names' => @target_names,
|
|
164
|
+
'cmd_target_names' => @cmd_target_names,
|
|
165
|
+
'tlm_target_names' => @tlm_target_names,
|
|
155
166
|
'connect_on_startup' => @connect_on_startup,
|
|
156
167
|
'auto_reconnect' => @auto_reconnect,
|
|
157
168
|
'reconnect_delay' => @reconnect_delay,
|
|
@@ -166,25 +177,10 @@ module OpenC3
|
|
|
166
177
|
}
|
|
167
178
|
end
|
|
168
179
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
result << " MAP_TARGET #{target_name}\n"
|
|
174
|
-
end
|
|
175
|
-
result << " DONT_CONNECT\n" unless @connect_on_startup
|
|
176
|
-
result << " DONT_RECONNECT\n" unless @auto_reconnect
|
|
177
|
-
result << " RECONNECT_DELAY #{@reconnect_delay}\n"
|
|
178
|
-
result << " DISABLE_DISCONNECT\n" if @disable_disconnect
|
|
179
|
-
@options.each do |option|
|
|
180
|
-
result << " OPTION #{option.join(' ')}\n"
|
|
181
|
-
end
|
|
182
|
-
@protocols.each do |protocol|
|
|
183
|
-
result << " PROTOCOL #{protocol.join(' ')}\n"
|
|
184
|
-
end
|
|
185
|
-
result << " DONT_LOG" unless @log
|
|
186
|
-
result << " LOG_RAW" if @log_raw
|
|
187
|
-
result
|
|
180
|
+
def ensure_target_exists(target_name)
|
|
181
|
+
target = TargetModel.get(name: target_name, scope: @scope)
|
|
182
|
+
raise "Target #{target_name} does not exist" unless target
|
|
183
|
+
target
|
|
188
184
|
end
|
|
189
185
|
|
|
190
186
|
# Handles Interface/Router specific configuration keywords
|
|
@@ -192,7 +188,22 @@ module OpenC3
|
|
|
192
188
|
case keyword
|
|
193
189
|
when 'MAP_TARGET'
|
|
194
190
|
parser.verify_num_parameters(1, 1, "#{keyword} <Target Name>")
|
|
195
|
-
|
|
191
|
+
target_name = parameters[0].upcase
|
|
192
|
+
@target_names << target_name unless @target_names.include?(target_name)
|
|
193
|
+
@cmd_target_names << target_name unless @cmd_target_names.include?(target_name)
|
|
194
|
+
@tlm_target_names << target_name unless @tlm_target_names.include?(target_name)
|
|
195
|
+
|
|
196
|
+
when 'MAP_CMD_TARGET'
|
|
197
|
+
parser.verify_num_parameters(1, 1, "#{keyword} <Target Name>")
|
|
198
|
+
target_name = parameters[0].upcase
|
|
199
|
+
@target_names << target_name unless @target_names.include?(target_name)
|
|
200
|
+
@cmd_target_names << target_name unless @cmd_target_names.include?(target_name)
|
|
201
|
+
|
|
202
|
+
when 'MAP_TLM_TARGET'
|
|
203
|
+
parser.verify_num_parameters(1, 1, "#{keyword} <Target Name>")
|
|
204
|
+
target_name = parameters[0].upcase
|
|
205
|
+
@target_names << target_name unless @target_names.include?(target_name)
|
|
206
|
+
@tlm_target_names << target_name unless @tlm_target_names.include?(target_name)
|
|
196
207
|
|
|
197
208
|
when 'DONT_CONNECT'
|
|
198
209
|
parser.verify_num_parameters(0, 0, "#{keyword}")
|
|
@@ -253,6 +264,7 @@ module OpenC3
|
|
|
253
264
|
scope: @scope
|
|
254
265
|
)
|
|
255
266
|
unless validate_only
|
|
267
|
+
@target_names.each { |target_name| ensure_target_exists(target_name) }
|
|
256
268
|
microservice.create
|
|
257
269
|
microservice.deploy(gem_path, variables)
|
|
258
270
|
ConfigTopic.write({ kind: 'created', type: type.downcase, name: @name, plugin: @plugin }, scope: @scope)
|
|
@@ -281,37 +293,59 @@ module OpenC3
|
|
|
281
293
|
status_model.destroy if status_model
|
|
282
294
|
end
|
|
283
295
|
|
|
284
|
-
def unmap_target(target_name)
|
|
296
|
+
def unmap_target(target_name, cmd_only: false, tlm_only: false)
|
|
297
|
+
if cmd_only and tlm_only
|
|
298
|
+
cmd_only = false
|
|
299
|
+
tlm_only = false
|
|
300
|
+
end
|
|
285
301
|
target_name = target_name.to_s.upcase
|
|
286
302
|
|
|
287
303
|
# Remove from this interface
|
|
288
|
-
|
|
304
|
+
if cmd_only
|
|
305
|
+
@cmd_target_names.delete(target_name)
|
|
306
|
+
@target_names.delete(target_name) unless @tlm_target_names.include?(target_name)
|
|
307
|
+
elsif tlm_only
|
|
308
|
+
@tlm_target_names.delete(target_name)
|
|
309
|
+
@target_names.delete(target_name) unless @cmd_target_names.include?(target_name)
|
|
310
|
+
else
|
|
311
|
+
@cmd_target_names.delete(target_name)
|
|
312
|
+
@tlm_target_names.delete(target_name)
|
|
313
|
+
@target_names.delete(target_name)
|
|
314
|
+
end
|
|
289
315
|
update()
|
|
290
316
|
|
|
291
317
|
# Respawn the microservice
|
|
292
318
|
type = self.class._get_type
|
|
293
319
|
microservice_name = "#{@scope}__#{type}__#{@name}"
|
|
294
320
|
microservice = MicroserviceModel.get_model(name: microservice_name, scope: scope)
|
|
295
|
-
microservice.target_names.delete(target_name)
|
|
321
|
+
microservice.target_names.delete(target_name) unless @target_names.include?(target_name)
|
|
296
322
|
microservice.update
|
|
297
323
|
end
|
|
298
324
|
|
|
299
|
-
def map_target(target_name)
|
|
325
|
+
def map_target(target_name, cmd_only: false, tlm_only: false, unmap_old: true)
|
|
326
|
+
if cmd_only and tlm_only
|
|
327
|
+
cmd_only = false
|
|
328
|
+
tlm_only = false
|
|
329
|
+
end
|
|
300
330
|
target_name = target_name.to_s.upcase
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
331
|
+
ensure_target_exists(target_name)
|
|
332
|
+
|
|
333
|
+
if unmap_old
|
|
334
|
+
# Remove from old interface
|
|
335
|
+
all_interfaces = InterfaceModel.all(scope: scope)
|
|
336
|
+
old_interface = nil
|
|
337
|
+
all_interfaces.each do |old_interface_name, old_interface_details|
|
|
338
|
+
if old_interface_details['target_names'].include?(target_name)
|
|
339
|
+
old_interface = InterfaceModel.from_json(old_interface_details, scope: scope)
|
|
340
|
+
old_interface.unmap_target(target_name, cmd_only: cmd_only, tlm_only: tlm_only) if old_interface
|
|
341
|
+
end
|
|
309
342
|
end
|
|
310
343
|
end
|
|
311
|
-
old_interface.unmap_target(target_name) if old_interface
|
|
312
344
|
|
|
313
345
|
# Add to this interface
|
|
314
346
|
@target_names << target_name unless @target_names.include?(target_name)
|
|
347
|
+
@cmd_target_names << target_name unless @cmd_target_names.include?(target_name) or tlm_only
|
|
348
|
+
@tlm_target_names << target_name unless @tlm_target_names.include?(target_name) or cmd_only
|
|
315
349
|
update()
|
|
316
350
|
|
|
317
351
|
# Respawn the microservice
|
|
@@ -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
|
# https://www.rubydoc.info/gems/redis/Redis/Commands/SortedSets
|
|
@@ -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/top_level'
|
|
@@ -38,6 +38,7 @@ module OpenC3
|
|
|
38
38
|
attr_accessor :topics
|
|
39
39
|
attr_accessor :work_dir
|
|
40
40
|
attr_accessor :ports
|
|
41
|
+
attr_accessor :parent
|
|
41
42
|
|
|
42
43
|
# NOTE: The following three class methods are used by the ModelController
|
|
43
44
|
# and are reimplemented to enable various Model class methods to work
|
|
@@ -90,6 +91,7 @@ module OpenC3
|
|
|
90
91
|
topics: [],
|
|
91
92
|
target_names: [],
|
|
92
93
|
options: [],
|
|
94
|
+
parent: nil,
|
|
93
95
|
container: nil,
|
|
94
96
|
updated_at: nil,
|
|
95
97
|
plugin: nil,
|
|
@@ -113,6 +115,7 @@ module OpenC3
|
|
|
113
115
|
@topics = topics
|
|
114
116
|
@target_names = target_names
|
|
115
117
|
@options = options
|
|
118
|
+
@parent = parent
|
|
116
119
|
@container = container
|
|
117
120
|
@needs_dependencies = needs_dependencies
|
|
118
121
|
@bucket = Bucket.getClient()
|
|
@@ -129,6 +132,7 @@ module OpenC3
|
|
|
129
132
|
'topics' => @topics,
|
|
130
133
|
'target_names' => @target_names,
|
|
131
134
|
'options' => @options,
|
|
135
|
+
'parent' => @parent,
|
|
132
136
|
'container' => @container,
|
|
133
137
|
'updated_at' => @updated_at,
|
|
134
138
|
'plugin' => @plugin,
|
|
@@ -136,29 +140,6 @@ module OpenC3
|
|
|
136
140
|
}
|
|
137
141
|
end
|
|
138
142
|
|
|
139
|
-
def as_config
|
|
140
|
-
result = "MICROSERVICE #{@folder_name ? @folder_name : 'nil'} #{@name.split("__")[-1]}\n"
|
|
141
|
-
result << " CMD #{@cmd.join(' ')}\n"
|
|
142
|
-
result << " WORK_DIR \"#{@work_dir}\"\n"
|
|
143
|
-
@ports.each do |port|
|
|
144
|
-
result << " PORT #{port}\n"
|
|
145
|
-
end
|
|
146
|
-
@topics.each do |topic_name|
|
|
147
|
-
result << " TOPIC #{topic_name}\n"
|
|
148
|
-
end
|
|
149
|
-
@target_names.each do |target_name|
|
|
150
|
-
result << " TARGET_NAME #{target_name}\n"
|
|
151
|
-
end
|
|
152
|
-
@env.each do |key, value|
|
|
153
|
-
result << " ENV #{key} \"#{value}\"\n"
|
|
154
|
-
end
|
|
155
|
-
@options.each do |option|
|
|
156
|
-
result << " OPTION #{option.join(" ")}\n"
|
|
157
|
-
end
|
|
158
|
-
result << " CONTAINER #{@container}\n" if @container != 'openc3-base'
|
|
159
|
-
result
|
|
160
|
-
end
|
|
161
|
-
|
|
162
143
|
def handle_config(parser, keyword, parameters)
|
|
163
144
|
case keyword
|
|
164
145
|
when 'ENV'
|
|
@@ -236,6 +217,8 @@ module OpenC3
|
|
|
236
217
|
@bucket.delete_object(bucket: ENV['OPENC3_CONFIG_BUCKET'], key: object.key)
|
|
237
218
|
end
|
|
238
219
|
ConfigTopic.write({ kind: 'deleted', type: 'microservice', name: @name, plugin: @plugin }, scope: @scope)
|
|
220
|
+
rescue Exception => error
|
|
221
|
+
Logger.error("Error undeploying microservice model #{@name} in scope #{@scope} due to #{error}")
|
|
239
222
|
end
|
|
240
223
|
end
|
|
241
224
|
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# encoding: ascii-8bit
|
|
2
|
+
|
|
3
|
+
# Copyright 2022 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 'openc3/models/model'
|
|
20
|
+
|
|
21
|
+
module OpenC3
|
|
22
|
+
class MigrationModel < Model
|
|
23
|
+
PRIMARY_KEY = 'openc3__migrations'
|
|
24
|
+
|
|
25
|
+
# NOTE: The following three class methods are used by the ModelController
|
|
26
|
+
# and are reimplemented to enable various Model class methods to work
|
|
27
|
+
def self.get(name:, scope: nil)
|
|
28
|
+
super(PRIMARY_KEY, name: name)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.names(scope: nil)
|
|
32
|
+
super(PRIMARY_KEY)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.all(scope: nil)
|
|
36
|
+
super(PRIMARY_KEY)
|
|
37
|
+
end
|
|
38
|
+
# END NOTE
|
|
39
|
+
|
|
40
|
+
def initialize(name:)
|
|
41
|
+
super(PRIMARY_KEY, name: name)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# @return [Hash] JSON encoding of this model
|
|
45
|
+
def as_json(*a)
|
|
46
|
+
{
|
|
47
|
+
'name' => @name,
|
|
48
|
+
'updated_at' => @updated_at
|
|
49
|
+
}
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
data/lib/openc3/models/model.rb
CHANGED
|
@@ -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/utilities/store'
|
|
@@ -128,7 +128,7 @@ module OpenC3
|
|
|
128
128
|
result
|
|
129
129
|
end
|
|
130
130
|
|
|
131
|
-
def self.handle_config(parser,
|
|
131
|
+
def self.handle_config(parser, keyword, parameters)
|
|
132
132
|
raise "must be implemented by subclass"
|
|
133
133
|
end
|
|
134
134
|
|
|
@@ -192,11 +192,6 @@ module OpenC3
|
|
|
192
192
|
'plugin' => @plugin,
|
|
193
193
|
'scope' => @scope }
|
|
194
194
|
end
|
|
195
|
-
|
|
196
|
-
# TODO: Not currently used but may be used by a XTCE or other format to OpenC3 conversion
|
|
197
|
-
def as_config
|
|
198
|
-
""
|
|
199
|
-
end
|
|
200
195
|
end
|
|
201
196
|
|
|
202
197
|
class EphemeralModel < Model
|
|
@@ -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
|
# https://www.rubydoc.info/gems/redis/Redis/Commands/SortedSets
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# encoding: ascii-8bit
|
|
2
|
+
|
|
3
|
+
# Copyright 2022 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 'openc3/models/model'
|
|
20
|
+
|
|
21
|
+
module OpenC3
|
|
22
|
+
class OfflineAccessModel < Model
|
|
23
|
+
PRIMARY_KEY = 'openc3__offline_access'
|
|
24
|
+
|
|
25
|
+
attr_accessor :offline_access_token
|
|
26
|
+
|
|
27
|
+
# NOTE: The following three class methods are used by the ModelController
|
|
28
|
+
# and are reimplemented to enable various Model class methods to work
|
|
29
|
+
def self.get(name:, scope:)
|
|
30
|
+
super("#{scope}__#{PRIMARY_KEY}", name: name)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.names(scope:)
|
|
34
|
+
super("#{scope}__#{PRIMARY_KEY}")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.all(scope:)
|
|
38
|
+
super("#{scope}__#{PRIMARY_KEY}")
|
|
39
|
+
end
|
|
40
|
+
# END NOTE
|
|
41
|
+
|
|
42
|
+
def initialize(name:, offline_access_token: nil, updated_at: nil, scope:)
|
|
43
|
+
super("#{scope}__#{PRIMARY_KEY}", name: name, scope: scope)
|
|
44
|
+
@offline_access_token = offline_access_token
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# @return [Hash] JSON encoding of this model
|
|
48
|
+
def as_json(*a)
|
|
49
|
+
{ 'name' => @name,
|
|
50
|
+
'updated_at' => @updated_at,
|
|
51
|
+
'offline_access_token' => @offline_access_token,
|
|
52
|
+
'scope' => @scope }
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -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 'rubygems'
|
|
@@ -43,6 +43,8 @@ module OpenC3
|
|
|
43
43
|
# as destroys them all when the plugin is removed.
|
|
44
44
|
class PluginModel < Model
|
|
45
45
|
PRIMARY_KEY = 'openc3_plugins'
|
|
46
|
+
# Reserved VARIABLE names. See local_mode.rb: update_local_plugin()
|
|
47
|
+
RESERVED_VARIABLE_NAMES = ['target_name', 'microservice_name']
|
|
46
48
|
|
|
47
49
|
attr_accessor :variables
|
|
48
50
|
attr_accessor :plugin_txt_lines
|
|
@@ -112,6 +114,9 @@ module OpenC3
|
|
|
112
114
|
usage = "#{keyword} <Variable Name> <Default Value>"
|
|
113
115
|
parser.verify_num_parameters(2, nil, usage)
|
|
114
116
|
variable_name = params[0]
|
|
117
|
+
if RESERVED_VARIABLE_NAMES.include?(variable_name)
|
|
118
|
+
raise "VARIABLE name '#{variable_name}' is reserved"
|
|
119
|
+
end
|
|
115
120
|
value = params[1..-1].join(" ")
|
|
116
121
|
variables[variable_name] = value
|
|
117
122
|
if existing_variables && existing_variables.key?(variable_name)
|
|
@@ -159,10 +164,15 @@ module OpenC3
|
|
|
159
164
|
pkg = Gem::Package.new(gem_file_path)
|
|
160
165
|
needs_dependencies = pkg.spec.runtime_dependencies.length > 0
|
|
161
166
|
pkg.extract_files(gem_path)
|
|
167
|
+
Dir[File.join(gem_path, '**/screens/*.txt')].each do |filename|
|
|
168
|
+
if File.basename(filename) != File.basename(filename).downcase
|
|
169
|
+
raise "Invalid screen name: #{filename}. Screen names must be lowercase."
|
|
170
|
+
end
|
|
171
|
+
end
|
|
162
172
|
needs_dependencies = true if Dir.exist?(File.join(gem_path, 'lib'))
|
|
163
173
|
if needs_dependencies
|
|
164
174
|
plugin_model.needs_dependencies = true
|
|
165
|
-
plugin_model.update
|
|
175
|
+
plugin_model.update unless validate_only
|
|
166
176
|
end
|
|
167
177
|
|
|
168
178
|
# Temporarily add all lib folders from the gem to the end of the load path
|
|
@@ -224,7 +234,6 @@ module OpenC3
|
|
|
224
234
|
FileUtils.remove_entry(temp_dir) if temp_dir and File.exist?(temp_dir)
|
|
225
235
|
tf.unlink if tf
|
|
226
236
|
end
|
|
227
|
-
|
|
228
237
|
return plugin_model.as_json(:allow_nan => true)
|
|
229
238
|
end
|
|
230
239
|
|
|
@@ -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/models/model'
|
|
@@ -54,7 +54,7 @@ module OpenC3
|
|
|
54
54
|
|
|
55
55
|
def self.create_mini_id
|
|
56
56
|
time = (Time.now.to_f * 10_000_000).to_i
|
|
57
|
-
jitter = rand(10_000_000)
|
|
57
|
+
jitter = rand(10_000_000)
|
|
58
58
|
key = "#{jitter}#{time}".to_i.to_s(36)
|
|
59
59
|
return "RV0-#{key}"
|
|
60
60
|
end
|
|
@@ -160,6 +160,7 @@ module OpenC3
|
|
|
160
160
|
end
|
|
161
161
|
|
|
162
162
|
attr_reader :name, :scope, :description, :snooze, :triggers, :actions, :active, :review, :snoozed_until
|
|
163
|
+
attr_accessor :username
|
|
163
164
|
|
|
164
165
|
def initialize(
|
|
165
166
|
name:,
|
|
@@ -171,6 +172,7 @@ module OpenC3
|
|
|
171
172
|
active: true,
|
|
172
173
|
review: true,
|
|
173
174
|
snoozed_until: nil,
|
|
175
|
+
username: nil,
|
|
174
176
|
updated_at: nil
|
|
175
177
|
)
|
|
176
178
|
if name.nil? || scope.nil? || description.nil? || snooze.nil? || triggers.nil? || actions.nil?
|
|
@@ -185,6 +187,7 @@ module OpenC3
|
|
|
185
187
|
@snooze = validate_snooze(snooze: snooze)
|
|
186
188
|
@actions = validate_actions(actions: actions)
|
|
187
189
|
@triggers = validate_triggers(triggers: triggers)
|
|
190
|
+
@username = username
|
|
188
191
|
@updated_at = updated_at
|
|
189
192
|
end
|
|
190
193
|
|
|
@@ -269,6 +272,7 @@ module OpenC3
|
|
|
269
272
|
'snoozed_until' => @snoozed_until,
|
|
270
273
|
'triggers' => @triggers,
|
|
271
274
|
'actions' => @actions,
|
|
275
|
+
'username' => @username,
|
|
272
276
|
'updated_at' => @updated_at
|
|
273
277
|
}
|
|
274
278
|
end
|