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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aff3df27d8a9cde6fb3e45403131ff0a29fbb5abb2e204e398e33d79c2bb7ead
|
|
4
|
+
data.tar.gz: ae3041bbd1868d8f3c5627dd5a6ebc381397deae7d27d997e7dfee009683175c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 967885d19c2ccf945765d355346ffde2aca982e65993630f4a4c4fe36a7f04c425176f50b9a8e4c639a21a5cc673f87928513047c84fccc3d12a8d59762fe44e
|
|
7
|
+
data.tar.gz: 2d11de60af3e15328db350cd278dc4ec79a848bb8bfbcb5f6f1a819f052f93f37397f2f23e1a1ebc1868b002f9568262599e05aa9c33f960f8fef31fe25e221b
|
data/bin/openc3cli
CHANGED
|
@@ -29,6 +29,8 @@ require 'openc3/utilities/bucket'
|
|
|
29
29
|
require 'openc3/models/scope_model'
|
|
30
30
|
require 'openc3/models/plugin_model'
|
|
31
31
|
require 'openc3/models/gem_model'
|
|
32
|
+
require 'openc3/models/migration_model'
|
|
33
|
+
require 'openc3/models/tool_model'
|
|
32
34
|
require 'openc3/packets/packet_config'
|
|
33
35
|
require 'openc3/bridge/bridge'
|
|
34
36
|
require 'ostruct'
|
|
@@ -38,9 +40,9 @@ require 'fileutils'
|
|
|
38
40
|
require 'find'
|
|
39
41
|
require 'json'
|
|
40
42
|
require 'redis'
|
|
41
|
-
require 'psych'
|
|
42
43
|
require 'erb'
|
|
43
44
|
require 'pp'
|
|
45
|
+
# require 'psych' # Psych code is commented out
|
|
44
46
|
|
|
45
47
|
$redis_url = "redis://#{ENV['OPENC3_REDIS_HOSTNAME']}:#{ENV['OPENC3_REDIS_PORT']}"
|
|
46
48
|
# Initialize the connection to the bucket library
|
|
@@ -62,16 +64,16 @@ def print_usage
|
|
|
62
64
|
puts "Usage:"
|
|
63
65
|
puts " cli help # Displays this information"
|
|
64
66
|
puts " cli rake # Runs rake in the local directory"
|
|
65
|
-
puts " cli validate /PATH/FILENAME.gem SCOPE variables.txt # Validate a
|
|
66
|
-
puts " cli load /PATH/FILENAME.gem SCOPE variables.txt # Loads a
|
|
67
|
-
puts " cli generate plugin PLUGIN_NAME # Generate a
|
|
67
|
+
puts " cli validate /PATH/FILENAME.gem SCOPE variables.txt # Validate a COSMOS plugin gem file"
|
|
68
|
+
puts " cli load /PATH/FILENAME.gem SCOPE variables.txt # Loads a COSMOS plugin gem file"
|
|
69
|
+
puts " cli generate plugin PLUGIN_NAME # Generate a COSMOS plugin"
|
|
68
70
|
puts " #{MIGRATE_PARSER}"
|
|
69
|
-
puts " cli bridge CONFIG_FILENAME # Run
|
|
71
|
+
puts " cli bridge CONFIG_FILENAME # Run COSMOS host bridge"
|
|
70
72
|
puts " cli bridgesetup CONFIG_FILENAME # Create a default config file"
|
|
71
73
|
puts " cli geminstall GEMFILENAME SCOPE # Install loaded gem to /gems"
|
|
72
74
|
puts " cli rubysloc # Counts Ruby SLOC recursively. Run with --help for more info."
|
|
73
75
|
puts " cli xtce_converter # Convert to and from the XTCE format. Run with --help for more info."
|
|
74
|
-
puts " cli cstol_converter # Converts CSTOL files (.prc) to
|
|
76
|
+
puts " cli cstol_converter # Converts CSTOL files (.prc) to COSMOS. Run with --help for more info."
|
|
75
77
|
puts ""
|
|
76
78
|
end
|
|
77
79
|
|
|
@@ -240,7 +242,7 @@ def xtce_converter(args)
|
|
|
240
242
|
packet_config = OpenC3::PacketConfig.new
|
|
241
243
|
puts "Processing #{options[:import]}..."
|
|
242
244
|
packet_config.process_file(options[:import], nil)
|
|
243
|
-
puts "Writing
|
|
245
|
+
puts "Writing COSMOS config files to #{options[:output]}/"
|
|
244
246
|
packet_config.to_config(options[:output])
|
|
245
247
|
exit(0)
|
|
246
248
|
elsif options[:plugin] && options[:output]
|
|
@@ -297,7 +299,7 @@ def put_into_archive(disk_file_path, io, zip_file_path)
|
|
|
297
299
|
end
|
|
298
300
|
|
|
299
301
|
def validate_plugin(plugin_file_path, scope:, variables_file: nil)
|
|
300
|
-
ENV['
|
|
302
|
+
ENV['OPENC3_NO_STORE'] = '1' # it can be anything
|
|
301
303
|
OpenC3::Logger.stdout = false
|
|
302
304
|
OpenC3::Logger.level = OpenC3::Logger::DEBUG
|
|
303
305
|
scope ||= 'DEFAULT'
|
|
@@ -457,7 +459,7 @@ end
|
|
|
457
459
|
|
|
458
460
|
def get_redis_keys
|
|
459
461
|
redis = Redis.new(url: $redis_url, username: ENV['OPENC3_REDIS_USERNAME'], password: ENV['OPENC3_REDIS_PASSWORD'])
|
|
460
|
-
puts "\n---
|
|
462
|
+
puts "\n--- COSMOS Redis database keys ---"
|
|
461
463
|
cursor = 0
|
|
462
464
|
keys = []
|
|
463
465
|
loop do
|
|
@@ -481,6 +483,40 @@ def get_redis_keys
|
|
|
481
483
|
puts "Packets Defs: #{keys.select { |item| item[/^tlm__/] }}"
|
|
482
484
|
end
|
|
483
485
|
|
|
486
|
+
def run_migrations(folder)
|
|
487
|
+
# Determine if this is a brand new installation (no tools installed)
|
|
488
|
+
# We don't run migrations on new installations
|
|
489
|
+
tools = OpenC3::ToolModel.names(scope: 'DEFAULT')
|
|
490
|
+
if tools.length <= 0
|
|
491
|
+
puts "Brand new installation detected"
|
|
492
|
+
brand_new = true
|
|
493
|
+
else
|
|
494
|
+
puts "Checking for needed migrations..."
|
|
495
|
+
brand_new = false
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
# Run each newly discovered migration unless brand_new
|
|
499
|
+
folder = "/openc3/lib/openc3/migrations" unless folder
|
|
500
|
+
migrations = OpenC3::MigrationModel.all
|
|
501
|
+
entries = Dir.entries(folder).sort # run in alphabetical order
|
|
502
|
+
entries.each do |entry|
|
|
503
|
+
name = File.basename(entry)
|
|
504
|
+
extension = File.extname(name)
|
|
505
|
+
if extension == '.rb' and not migrations[name]
|
|
506
|
+
unless brand_new
|
|
507
|
+
puts "Running Migration: #{name}"
|
|
508
|
+
require File.join(folder, entry)
|
|
509
|
+
end
|
|
510
|
+
OpenC3::MigrationModel.new(name: name).create
|
|
511
|
+
end
|
|
512
|
+
end
|
|
513
|
+
if brand_new
|
|
514
|
+
puts "All migrations skipped"
|
|
515
|
+
else
|
|
516
|
+
puts "Migrations complete"
|
|
517
|
+
end
|
|
518
|
+
end
|
|
519
|
+
|
|
484
520
|
if __FILE__ == $0
|
|
485
521
|
if not ARGV[0].nil? # argument(s) given
|
|
486
522
|
|
|
@@ -594,6 +630,9 @@ if __FILE__ == $0
|
|
|
594
630
|
client.create(ENV['OPENC3_TOOLS_BUCKET'])
|
|
595
631
|
client.ensure_public(ENV['OPENC3_TOOLS_BUCKET'])
|
|
596
632
|
|
|
633
|
+
when 'runmigrations'
|
|
634
|
+
run_migrations(ARGV[1])
|
|
635
|
+
|
|
597
636
|
else # Unknown task
|
|
598
637
|
print_usage()
|
|
599
638
|
abort("Unknown task: #{ARGV[0]}")
|
|
@@ -6,6 +6,20 @@ MAP_TARGET:
|
|
|
6
6
|
required: true
|
|
7
7
|
description: Target name to map to this interface
|
|
8
8
|
values: .+
|
|
9
|
+
MAP_CMD_TARGET:
|
|
10
|
+
summary: Maps a target name to an interface for commands only
|
|
11
|
+
parameters:
|
|
12
|
+
- name: Target Name
|
|
13
|
+
required: true
|
|
14
|
+
description: Command target name to map to this interface
|
|
15
|
+
values: .+
|
|
16
|
+
MAP_TLM_TARGET:
|
|
17
|
+
summary: Maps a target name to an interface for telemetry only
|
|
18
|
+
parameters:
|
|
19
|
+
- name: Target Name
|
|
20
|
+
required: true
|
|
21
|
+
description: Telemetry target name to map to this interface
|
|
22
|
+
values: .+
|
|
9
23
|
DONT_CONNECT:
|
|
10
24
|
summary: Server will not automatically try to connect to the interface at startup
|
|
11
25
|
DONT_RECONNECT:
|
|
@@ -38,7 +38,7 @@ STATE:
|
|
|
38
38
|
STATE FALSE 0
|
|
39
39
|
STATE TRUE 1
|
|
40
40
|
APPEND_PARAMETER STRING 1024 STRING "NOOP" "String parameter"
|
|
41
|
-
STATE "NOOP" "NOOP"
|
|
41
|
+
STATE "NOOP" "NOOP" DISABLE_MESSAGES
|
|
42
42
|
STATE "ARM LASER" "ARM LASER" HAZARDOUS "Arming the laser is an eye safety hazard"
|
|
43
43
|
STATE "FIRE LASER" "FIRE LASER" HAZARDOUS "WARNING! Laser will be fired!"
|
|
44
44
|
parameters:
|
|
@@ -50,10 +50,12 @@ STATE:
|
|
|
50
50
|
required: true
|
|
51
51
|
description: The numerical state value
|
|
52
52
|
values: .*
|
|
53
|
-
- name: Hazardous
|
|
53
|
+
- name: Hazardous / Disable Messages
|
|
54
54
|
required: false
|
|
55
55
|
description: Indicates the state is hazardous. This will cause a popup
|
|
56
|
-
to ask for user confirmation when sending this command.
|
|
56
|
+
to ask for user confirmation when sending this command. For non-hazardous
|
|
57
|
+
states you can also set DISABLE_MESSAGES which will not print the command
|
|
58
|
+
when using that state.
|
|
57
59
|
values: ['HAZARDOUS']
|
|
58
60
|
- name: Hazardous Description
|
|
59
61
|
required: false
|
data/data/config/screen.yaml
CHANGED
|
@@ -48,8 +48,9 @@ GLOBAL_SETTING:
|
|
|
48
48
|
description: >
|
|
49
49
|
The setting value which varies by setting. Note that color
|
|
50
50
|
settings can be given as a common string, e.g. 'red', or by RGB values,
|
|
51
|
-
e.g. 255 0 0. If the setting is
|
|
52
|
-
|
|
51
|
+
e.g. 255 0 0. If the setting is a length the units are required, e.g. 200px.
|
|
52
|
+
If the setting is RAW the value should be the raw stylesheet
|
|
53
|
+
key and value, e.g. font-size 10px
|
|
53
54
|
values: .*
|
|
54
55
|
GLOBAL_SUBSETTING:
|
|
55
56
|
summary: Applies a widget subsetting to all widgets of a certain type
|
|
@@ -81,8 +82,9 @@ GLOBAL_SUBSETTING:
|
|
|
81
82
|
description: >
|
|
82
83
|
The setting value which varies by setting. Note that color
|
|
83
84
|
settings can be given as a common string, e.g. 'red', or by RGB values,
|
|
84
|
-
e.g. 255 0 0. If the setting is
|
|
85
|
-
|
|
85
|
+
e.g. 255 0 0. If the setting is a length the units are required, e.g. 200px.
|
|
86
|
+
If the setting is RAW the value should be the raw stylesheet
|
|
87
|
+
key and value, e.g. font-size 10px
|
|
86
88
|
values: .*
|
|
87
89
|
SETTING:
|
|
88
90
|
summary: Applies a widget setting to the previously defined widget
|
|
@@ -98,8 +100,9 @@ SETTING:
|
|
|
98
100
|
description: >
|
|
99
101
|
The setting value which varies by setting. Note that color
|
|
100
102
|
settings can be given as a common string, e.g. 'red', or by RGB values,
|
|
101
|
-
e.g. 255 0 0. If the setting is
|
|
102
|
-
|
|
103
|
+
e.g. 255 0 0. If the setting is a length the units are required, e.g. 200px.
|
|
104
|
+
If the setting is RAW the value should be the raw stylesheet
|
|
105
|
+
key and value, e.g. font-size 10px
|
|
103
106
|
values: .*
|
|
104
107
|
SUBSETTING:
|
|
105
108
|
summary: Applies a widget subsetting to the previously defined widget
|
|
@@ -126,8 +129,9 @@ SUBSETTING:
|
|
|
126
129
|
description: >
|
|
127
130
|
The setting value which varies by setting. Note that color
|
|
128
131
|
settings can be given as a common string, e.g. 'red', or by RGB values,
|
|
129
|
-
e.g. 255 0 0. If the setting is
|
|
130
|
-
|
|
132
|
+
e.g. 255 0 0. If the setting is a length the units are required, e.g. 200px.
|
|
133
|
+
If the setting is RAW the value should be the raw stylesheet
|
|
134
|
+
key and value, e.g. font-size 10px
|
|
131
135
|
values: .*
|
|
132
136
|
NAMED_WIDGET:
|
|
133
137
|
summary: Name a widget to allow access to it via the getNamedWidget method
|
data/data/config/target.yaml
CHANGED
|
@@ -14,6 +14,13 @@ TARGET:
|
|
|
14
14
|
it can be different to create multiple targets based on the same target folder.
|
|
15
15
|
values: .*
|
|
16
16
|
modifiers:
|
|
17
|
+
CMD_BUFFER_DEPTH:
|
|
18
|
+
summary: Number of commands to buffer to ensure logged in order
|
|
19
|
+
parameters:
|
|
20
|
+
- name: Buffer Depth
|
|
21
|
+
required: true
|
|
22
|
+
description: Buffer depth in packets (Default = 5)
|
|
23
|
+
values: \d+
|
|
17
24
|
CMD_LOG_CYCLE_TIME:
|
|
18
25
|
summary: Command binary logs can be cycled on a time interval.
|
|
19
26
|
parameters:
|
|
@@ -56,6 +63,13 @@ TARGET:
|
|
|
56
63
|
required: true
|
|
57
64
|
description: Number of seconds to keep decom command logs (default = nil = Forever)
|
|
58
65
|
values: \d+
|
|
66
|
+
TLM_BUFFER_DEPTH:
|
|
67
|
+
summary: Number of telemetry packets to buffer to ensure logged in order
|
|
68
|
+
parameters:
|
|
69
|
+
- name: Buffer Depth
|
|
70
|
+
required: true
|
|
71
|
+
description: Buffer depth in packets (Default = 60)
|
|
72
|
+
values: \d+
|
|
59
73
|
TLM_LOG_CYCLE_TIME:
|
|
60
74
|
summary: Telemetry binary logs can be cycled on a time interval.
|
|
61
75
|
parameters:
|
|
@@ -140,3 +154,22 @@ TARGET:
|
|
|
140
154
|
required: true
|
|
141
155
|
description: Number of seconds between runs of the cleanup process (default = 900 = 15 minutes)
|
|
142
156
|
values: \d+
|
|
157
|
+
TARGET_MICROSERVICE:
|
|
158
|
+
summary: Breaks a target microservice out into its own process.
|
|
159
|
+
Can be used to give more resources to processing that is falling behind.
|
|
160
|
+
If defined multiple times for the same type, will create multiple processes.
|
|
161
|
+
Each process can be given specific packets to process with the PACKET keyword.
|
|
162
|
+
parameters:
|
|
163
|
+
- name: Type
|
|
164
|
+
required: true
|
|
165
|
+
description: The target microservice type. Must be one of
|
|
166
|
+
DECOM, COMMANDLOG, DECOMCMDLOG, PACKETLOG, DECOMLOG, REDUCER, or CLEANUP
|
|
167
|
+
values: .*
|
|
168
|
+
PACKET:
|
|
169
|
+
summary: Packet Name to allocate to the current TARGET_MICROSERVICE.
|
|
170
|
+
parameters:
|
|
171
|
+
- name: Packet Name
|
|
172
|
+
required: true
|
|
173
|
+
description: The packet name. Does not apply to
|
|
174
|
+
REDUCER or CLEANUP target microservice types.
|
|
175
|
+
values: .*
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
# All changes Copyright 2022, OpenC3, Inc.
|
|
19
19
|
# All Rights Reserved
|
|
20
20
|
#
|
|
21
|
-
# This file may also be used under the terms of a commercial license
|
|
21
|
+
# This file may also be used under the terms of a commercial license
|
|
22
22
|
# if purchased from OpenC3, Inc.
|
|
23
23
|
*/
|
|
24
24
|
|
|
@@ -96,13 +96,13 @@ static VALUE parse_loop(VALUE self, VALUE io, VALUE yield_non_keyword_lines, VAL
|
|
|
96
96
|
volatile VALUE progress_callback = rb_cvar_get(cConfigParser, id_cvar_progress_callback);
|
|
97
97
|
volatile VALUE line = Qnil;
|
|
98
98
|
volatile VALUE data = Qnil;
|
|
99
|
-
volatile VALUE
|
|
99
|
+
volatile VALUE string_concat = Qfalse;
|
|
100
100
|
volatile VALUE string = Qnil;
|
|
101
101
|
volatile VALUE array = rb_ary_new();
|
|
102
102
|
volatile VALUE first_item = Qnil;
|
|
103
103
|
volatile VALUE ivar_keyword = Qnil;
|
|
104
104
|
volatile VALUE ivar_parameters = rb_ary_new();
|
|
105
|
-
volatile VALUE ivar_line =
|
|
105
|
+
volatile VALUE ivar_line = rb_str_new2("");
|
|
106
106
|
|
|
107
107
|
rb_ivar_set(self, id_ivar_line_number, INT2FIX(0));
|
|
108
108
|
rb_ivar_set(self, id_ivar_keyword, ivar_keyword);
|
|
@@ -130,57 +130,88 @@ static VALUE parse_loop(VALUE self, VALUE io, VALUE yield_non_keyword_lines, VAL
|
|
|
130
130
|
break;
|
|
131
131
|
}
|
|
132
132
|
line = rb_funcall(line, id_method_strip, 0);
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
// Ensure the line length is not 0
|
|
134
|
+
if (RSTRING_LEN(line) == 0) {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
135
137
|
|
|
136
|
-
if (RTEST(
|
|
138
|
+
if (RTEST(string_concat))
|
|
137
139
|
{
|
|
138
|
-
|
|
139
|
-
|
|
140
|
+
/* Skip comment lines after a string concat */
|
|
141
|
+
if (RSTRING_PTR(line)[0] == '#')
|
|
142
|
+
{
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
/* Remove the opening quote if we're continuing the line */
|
|
146
|
+
line = rb_str_new(RSTRING_PTR(line) + 1, RSTRING_LEN(line) - 1);
|
|
140
147
|
}
|
|
141
|
-
|
|
148
|
+
|
|
149
|
+
/* Check for string continuation */
|
|
150
|
+
if ((RSTRING_PTR(line)[RSTRING_LEN(line) - 1] == '+') ||
|
|
151
|
+
(RSTRING_PTR(line)[RSTRING_LEN(line) - 1] == '\\'))
|
|
142
152
|
{
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if ((RSTRING_LEN(first_item) == 0) || (RSTRING_PTR(first_item)[0] == '#'))
|
|
153
|
+
int newline = 0;
|
|
154
|
+
if (RSTRING_PTR(line)[RSTRING_LEN(line) - 1] == '+')
|
|
146
155
|
{
|
|
147
|
-
|
|
156
|
+
newline = 1;
|
|
148
157
|
}
|
|
149
|
-
|
|
158
|
+
rb_str_resize(line, RSTRING_LEN(line) - 1);
|
|
159
|
+
line = rb_funcall(line, id_method_strip, 0);
|
|
160
|
+
rb_str_append(ivar_line, line);
|
|
161
|
+
rb_str_resize(ivar_line, RSTRING_LEN(ivar_line) - 1);
|
|
162
|
+
if (newline == 1)
|
|
150
163
|
{
|
|
151
|
-
|
|
164
|
+
rb_str_cat2(ivar_line, "\n");
|
|
152
165
|
}
|
|
153
|
-
rb_ivar_set(self,
|
|
154
|
-
|
|
155
|
-
|
|
166
|
+
rb_ivar_set(self, id_ivar_line, ivar_line);
|
|
167
|
+
string_concat = Qtrue;
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
if (RSTRING_PTR(line)[RSTRING_LEN(line) - 1] == '&')
|
|
171
|
+
{
|
|
172
|
+
rb_str_append(ivar_line, line);
|
|
173
|
+
rb_str_resize(ivar_line, RSTRING_LEN(ivar_line) - 1);
|
|
174
|
+
rb_ivar_set(self, id_ivar_line, ivar_line);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
rb_str_append(ivar_line, line);
|
|
178
|
+
rb_ivar_set(self, id_ivar_line, ivar_line);
|
|
179
|
+
string_concat = Qfalse;
|
|
180
|
+
|
|
181
|
+
data = rb_funcall(ivar_line, id_method_scan, 1, rx);
|
|
182
|
+
first_item = rb_str_new2("");
|
|
183
|
+
if (RARRAY_LEN(data) > 0)
|
|
184
|
+
{
|
|
185
|
+
rb_str_cat2(first_item, RSTRING_PTR(rb_ary_entry(data, 0)));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if ((RSTRING_LEN(first_item) == 0) || (RSTRING_PTR(first_item)[0] == '#'))
|
|
189
|
+
{
|
|
190
|
+
ivar_keyword = Qnil;
|
|
191
|
+
}
|
|
192
|
+
else
|
|
193
|
+
{
|
|
194
|
+
ivar_keyword = rb_funcall(first_item, id_method_upcase, 0);
|
|
156
195
|
}
|
|
196
|
+
rb_ivar_set(self, id_ivar_keyword, ivar_keyword);
|
|
197
|
+
ivar_parameters = rb_ary_new();
|
|
198
|
+
rb_ivar_set(self, id_ivar_parameters, ivar_parameters);
|
|
157
199
|
|
|
158
|
-
/* Ignore comments and blank lines */
|
|
200
|
+
/* Ignore lines without keywords: comments and blank lines */
|
|
159
201
|
if (ivar_keyword == Qnil)
|
|
160
202
|
{
|
|
161
|
-
if (
|
|
203
|
+
if (RTEST(yield_non_keyword_lines))
|
|
162
204
|
{
|
|
163
205
|
rb_ary_clear(array);
|
|
164
206
|
rb_ary_push(array, ivar_keyword);
|
|
165
207
|
rb_ary_push(array, ivar_parameters);
|
|
166
208
|
rb_yield(array);
|
|
167
209
|
}
|
|
210
|
+
ivar_line = rb_str_new2("");
|
|
211
|
+
rb_ivar_set(self, id_ivar_line, ivar_line);
|
|
168
212
|
continue;
|
|
169
213
|
}
|
|
170
214
|
|
|
171
|
-
if (RTEST(line_continuation))
|
|
172
|
-
{
|
|
173
|
-
if (RTEST(remove_quotes))
|
|
174
|
-
{
|
|
175
|
-
rb_ary_push(ivar_parameters, string_remove_quotes(first_item));
|
|
176
|
-
}
|
|
177
|
-
else
|
|
178
|
-
{
|
|
179
|
-
rb_ary_push(ivar_parameters, first_item);
|
|
180
|
-
}
|
|
181
|
-
line_continuation = Qfalse;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
215
|
length = RARRAY_LEN(data);
|
|
185
216
|
if (length > 1)
|
|
186
217
|
{
|
|
@@ -202,16 +233,6 @@ static VALUE parse_loop(VALUE self, VALUE io, VALUE yield_non_keyword_lines, VAL
|
|
|
202
233
|
}
|
|
203
234
|
}
|
|
204
235
|
|
|
205
|
-
/*
|
|
206
|
-
* If the string is simply '&' and its the last string then its a line continuation so break the loop
|
|
207
|
-
*/
|
|
208
|
-
if ((RSTRING_LEN(string) == 1) && (RSTRING_PTR(string)[0] == '&') && (index == (length - 1)))
|
|
209
|
-
{
|
|
210
|
-
line_continuation = Qtrue;
|
|
211
|
-
continue;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
line_continuation = Qfalse;
|
|
215
236
|
if (RTEST(remove_quotes))
|
|
216
237
|
{
|
|
217
238
|
rb_ary_push(ivar_parameters, string_remove_quotes(string));
|
|
@@ -223,30 +244,12 @@ static VALUE parse_loop(VALUE self, VALUE io, VALUE yield_non_keyword_lines, VAL
|
|
|
223
244
|
}
|
|
224
245
|
}
|
|
225
246
|
|
|
226
|
-
/*
|
|
227
|
-
* If we detected a line continuation while going through all the
|
|
228
|
-
* strings on the line then we strip off the continuation character and
|
|
229
|
-
* return to the top of the loop to continue processing the line.
|
|
230
|
-
*/
|
|
231
|
-
if (RTEST(line_continuation))
|
|
232
|
-
{
|
|
233
|
-
/* Strip the continuation character */
|
|
234
|
-
if (RSTRING_LEN(ivar_line) >= 1)
|
|
235
|
-
{
|
|
236
|
-
ivar_line = rb_str_new(RSTRING_PTR(ivar_line), RSTRING_LEN(ivar_line) - 1);
|
|
237
|
-
}
|
|
238
|
-
else
|
|
239
|
-
{
|
|
240
|
-
ivar_line = rb_str_new2("");
|
|
241
|
-
}
|
|
242
|
-
rb_ivar_set(self, id_ivar_line, ivar_line);
|
|
243
|
-
continue;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
247
|
rb_ary_clear(array);
|
|
247
248
|
rb_ary_push(array, ivar_keyword);
|
|
248
249
|
rb_ary_push(array, ivar_parameters);
|
|
249
250
|
rb_yield(array);
|
|
251
|
+
ivar_line = rb_str_new2("");
|
|
252
|
+
rb_ivar_set(self, id_ivar_line, ivar_line);
|
|
250
253
|
}
|
|
251
254
|
|
|
252
255
|
if (RTEST(progress_callback))
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
# All changes Copyright 2022, OpenC3, Inc.
|
|
19
19
|
# All Rights Reserved
|
|
20
20
|
#
|
|
21
|
-
# This file may also be used under the terms of a commercial license
|
|
21
|
+
# This file may also be used under the terms of a commercial license
|
|
22
22
|
# if purchased from OpenC3, Inc.
|
|
23
23
|
*/
|
|
24
24
|
|
|
@@ -47,7 +47,6 @@ static ID id_ivar_hazardous_description = 0;
|
|
|
47
47
|
static ID id_ivar_given_values = 0;
|
|
48
48
|
static ID id_ivar_limits_items = 0;
|
|
49
49
|
static ID id_ivar_processors = 0;
|
|
50
|
-
static ID id_ivar_stale = 0;
|
|
51
50
|
static ID id_ivar_limits_change_callback = 0;
|
|
52
51
|
static ID id_ivar_read_conversion_cache = 0;
|
|
53
52
|
static ID id_ivar_raw = 0;
|
|
@@ -274,7 +273,6 @@ static VALUE packet_initialize(int argc, VALUE *argv, VALUE self)
|
|
|
274
273
|
rb_ivar_set(self, id_ivar_given_values, Qnil);
|
|
275
274
|
rb_ivar_set(self, id_ivar_limits_items, Qnil);
|
|
276
275
|
rb_ivar_set(self, id_ivar_processors, Qnil);
|
|
277
|
-
rb_ivar_set(self, id_ivar_stale, Qtrue);
|
|
278
276
|
rb_ivar_set(self, id_ivar_limits_change_callback, Qnil);
|
|
279
277
|
rb_ivar_set(self, id_ivar_read_conversion_cache, Qnil);
|
|
280
278
|
rb_ivar_set(self, id_ivar_raw, Qnil);
|
|
@@ -312,7 +310,6 @@ void Init_packet(void)
|
|
|
312
310
|
id_ivar_given_values = rb_intern("@given_values");
|
|
313
311
|
id_ivar_limits_items = rb_intern("@limits_items");
|
|
314
312
|
id_ivar_processors = rb_intern("@processors");
|
|
315
|
-
id_ivar_stale = rb_intern("@stale");
|
|
316
313
|
id_ivar_limits_change_callback = rb_intern("@limits_change_callback");
|
|
317
314
|
id_ivar_read_conversion_cache = rb_intern("@read_conversion_cache");
|
|
318
315
|
id_ivar_raw = rb_intern("@raw");
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# API Architecture
|
|
2
|
+
|
|
3
|
+
All the files under lib/openc3/api define methods which are added to the WHITELIST. Then in lib/openc3/script/script.rb they are defined as methods on the $api_server which proxies the methods as requests to the JsonDRbObject.
|
|
4
|
+
|
|
5
|
+
They use Models to store data back to the Redis data store after using authorize() to ensure permission.
|
data/lib/openc3/api/api.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/script/extract'
|
|
@@ -26,8 +26,10 @@ require 'openc3/api/cmd_api'
|
|
|
26
26
|
require 'openc3/api/config_api'
|
|
27
27
|
require 'openc3/api/interface_api'
|
|
28
28
|
require 'openc3/api/limits_api'
|
|
29
|
+
require 'openc3/api/offline_access_api'
|
|
29
30
|
require 'openc3/api/router_api'
|
|
30
31
|
require 'openc3/api/settings_api'
|
|
32
|
+
require 'openc3/api/stash_api'
|
|
31
33
|
require 'openc3/api/target_api'
|
|
32
34
|
require 'openc3/api/tlm_api'
|
|
33
35
|
require 'openc3/utilities/authorization'
|