openc3 5.4.3.pre.beta0 → 5.5.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of openc3 might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/bin/openc3cli +58 -74
- data/data/config/item_modifiers.yaml +1 -1
- data/data/config/plugins.yaml +5 -0
- data/data/config/widgets.yaml +13 -11
- data/lib/openc3/api/cmd_api.rb +43 -17
- data/lib/openc3/api/tlm_api.rb +37 -4
- data/lib/openc3/bridge/bridge.rb +3 -3
- data/lib/openc3/bridge/bridge_config.rb +68 -20
- data/lib/openc3/interfaces/interface.rb +8 -0
- data/lib/openc3/microservices/decom_microservice.rb +0 -3
- data/lib/openc3/microservices/interface_microservice.rb +2 -0
- data/lib/openc3/microservices/reaction_microservice.rb +0 -1
- data/lib/openc3/models/cvt_model.rb +1 -2
- data/lib/openc3/models/metadata_model.rb +1 -1
- data/lib/openc3/models/microservice_model.rb +1 -1
- data/lib/openc3/models/note_model.rb +1 -1
- data/lib/openc3/models/plugin_model.rb +14 -7
- data/lib/openc3/models/timeline_model.rb +1 -1
- data/lib/openc3/models/trigger_group_model.rb +1 -1
- data/lib/openc3/packets/packet_item.rb +1 -1
- data/lib/openc3/script/script.rb +10 -0
- data/lib/openc3/script/storage.rb +5 -5
- data/lib/openc3/script/web_socket_api.rb +423 -0
- data/lib/openc3/streams/tcpip_client_stream.rb +1 -1
- data/lib/openc3/streams/web_socket_client_stream.rb +98 -0
- data/lib/openc3/tools/table_manager/table_manager_core.rb +1 -2
- data/lib/openc3/utilities/aws_bucket.rb +22 -4
- data/lib/openc3/utilities/bucket_file_cache.rb +3 -2
- data/lib/openc3/utilities/bucket_utilities.rb +1 -1
- data/lib/openc3/utilities/cli_generator.rb +210 -0
- data/lib/openc3/utilities/local_mode.rb +2 -2
- data/lib/openc3/utilities/target_file.rb +43 -32
- data/lib/openc3/version.rb +7 -7
- data/templates/conversion/conversion.rb +43 -0
- data/templates/limits_response/response.rb +51 -0
- data/templates/microservice/microservices/TEMPLATE/microservice.rb +62 -0
- data/templates/plugin/plugin.txt +1 -0
- metadata +49 -15
- data/templates/plugin-template/plugin.txt +0 -9
- /data/templates/{plugin-template → plugin}/LICENSE.txt +0 -0
- /data/templates/{plugin-template → plugin}/README.md +0 -0
- /data/templates/{plugin-template → plugin}/Rakefile +0 -0
- /data/templates/{plugin-template → plugin}/plugin.gemspec +0 -0
- /data/templates/{plugin-template → target}/targets/TARGET/cmd_tlm/cmd.txt +0 -0
- /data/templates/{plugin-template → target}/targets/TARGET/cmd_tlm/tlm.txt +0 -0
- /data/templates/{plugin-template → target}/targets/TARGET/lib/target.rb +0 -0
- /data/templates/{plugin-template → target}/targets/TARGET/procedures/procedure.rb +0 -0
- /data/templates/{plugin-template → target}/targets/TARGET/screens/status.txt +0 -0
- /data/templates/{plugin-template → target}/targets/TARGET/target.txt +0 -0
@@ -0,0 +1,210 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
|
3
|
+
# Copyright 2023 OpenC3, Inc.
|
4
|
+
# All Rights Reserved.
|
5
|
+
#
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
7
|
+
# under the terms of the GNU Affero General Public License
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Affero General Public License for more details.
|
15
|
+
|
16
|
+
# This file may also be used under the terms of a commercial license
|
17
|
+
# if purchased from OpenC3, Inc.
|
18
|
+
|
19
|
+
module OpenC3
|
20
|
+
class CliGenerator
|
21
|
+
GENERATORS = %w(plugin target microservice conversion limits_response)
|
22
|
+
TEMPLATES_DIR = "#{File.dirname(__FILE__)}/../../../templates"
|
23
|
+
|
24
|
+
# Called by openc3cli with ARGV[1..-1]
|
25
|
+
def self.generate(args)
|
26
|
+
unless GENERATORS.include?(args[0])
|
27
|
+
abort("Unknown generator '#{args[0]}'. Valid generators: #{GENERATORS.join(', ')}")
|
28
|
+
end
|
29
|
+
check_args(args)
|
30
|
+
send("generate_#{args[0]}", args)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.check_args(args)
|
34
|
+
args.each do |arg|
|
35
|
+
if arg =~ /\s/
|
36
|
+
abort("#{args[0].capitalize} arguments can not have spaces!")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
# All generators except 'plugin' must be within an existing plugin
|
40
|
+
if args[0] != 'plugin' and Dir.glob("*.gemspec").empty?
|
41
|
+
abort("No gemspec file detected. #{args[0].capitalize} generator should be run within an existing plugin.")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.process_template(template_dir, the_binding)
|
46
|
+
Dir.glob("#{template_dir}/**/*").each do |file|
|
47
|
+
base_name = file.sub("#{template_dir}/", '')
|
48
|
+
yield base_name
|
49
|
+
if File.directory?(file)
|
50
|
+
FileUtils.mkdir(base_name)
|
51
|
+
next
|
52
|
+
end
|
53
|
+
output = ERB.new(File.read(file), trim_mode: "-").result(the_binding)
|
54
|
+
File.open(base_name, 'w') do |file|
|
55
|
+
file.write output
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.generate_plugin(args)
|
61
|
+
if args.length != 2
|
62
|
+
abort("Usage: cli generate #{args[0]} <NAME>")
|
63
|
+
end
|
64
|
+
|
65
|
+
# Create the local variables
|
66
|
+
plugin = args[1].downcase.gsub(/_+|-+/, '-')
|
67
|
+
plugin_name = "openc3-cosmos-#{plugin}"
|
68
|
+
if File.exist?(plugin_name)
|
69
|
+
abort("Plugin #{plugin_name} already exists!")
|
70
|
+
end
|
71
|
+
FileUtils.mkdir(plugin_name)
|
72
|
+
Dir.chdir(plugin_name) # Change to the plugin path to make copying easier
|
73
|
+
|
74
|
+
process_template("#{TEMPLATES_DIR}/plugin", binding) do |filename|
|
75
|
+
filename.sub!("plugin.gemspec", "#{plugin_name}.gemspec")
|
76
|
+
end
|
77
|
+
|
78
|
+
puts "Plugin #{plugin_name} successfully generated!"
|
79
|
+
return plugin_name
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.generate_target(args)
|
83
|
+
if args.length != 2
|
84
|
+
abort("Usage: cli generate #{args[0]} <NAME>")
|
85
|
+
end
|
86
|
+
|
87
|
+
# Create the local variables
|
88
|
+
target_name = args[1].upcase.gsub(/_+|-+/, '_')
|
89
|
+
target_path = "targets/#{target_name}"
|
90
|
+
if File.exist?(target_path)
|
91
|
+
abort("Target #{target_path} already exists!")
|
92
|
+
end
|
93
|
+
target_lib_filename = "#{target_name.downcase}.rb"
|
94
|
+
target_class = target_lib_filename.filename_to_class_name
|
95
|
+
target_object = target_name.downcase
|
96
|
+
|
97
|
+
process_template("#{TEMPLATES_DIR}/target", binding) do |filename|
|
98
|
+
# Rename the template TARGET to our actual target named after the plugin
|
99
|
+
filename.sub!("targets/TARGET", "targets/#{target_name}")
|
100
|
+
filename.sub!("target.rb", target_lib_filename)
|
101
|
+
end
|
102
|
+
|
103
|
+
# Add this target to plugin.txt
|
104
|
+
File.open("plugin.txt", 'a') do |file|
|
105
|
+
file.puts <<~DOC
|
106
|
+
|
107
|
+
VARIABLE #{target_name.downcase}_target_name #{target_name}
|
108
|
+
|
109
|
+
TARGET #{target_name} <%= #{target_name.downcase}_target_name %>
|
110
|
+
INTERFACE <%= #{target_name.downcase}_target_name %>_INT tcpip_client_interface.rb host.docker.internal 8080 8081 10.0 nil BURST
|
111
|
+
MAP_TARGET <%= #{target_name.downcase}_target_name %>
|
112
|
+
DOC
|
113
|
+
end
|
114
|
+
|
115
|
+
puts "Target #{target_name} successfully generated!"
|
116
|
+
return target_name
|
117
|
+
end
|
118
|
+
|
119
|
+
def self.generate_microservice(args)
|
120
|
+
if args.length != 2
|
121
|
+
abort("Usage: cli generate #{args[0]} <NAME>")
|
122
|
+
end
|
123
|
+
|
124
|
+
# Create the local variables
|
125
|
+
microservice_name = args[1].upcase.gsub(/_+|-+/, '_')
|
126
|
+
microservice_path = "microservices/#{microservice_name}"
|
127
|
+
if File.exist?(microservice_path)
|
128
|
+
abort("Microservice #{microservice_path} already exists!")
|
129
|
+
end
|
130
|
+
microservice_filename = "#{microservice_name.downcase}.rb"
|
131
|
+
microservice_class = microservice_filename.filename_to_class_name
|
132
|
+
|
133
|
+
process_template("#{TEMPLATES_DIR}/microservice", binding) do |filename|
|
134
|
+
# Rename the template MICROSERVICE to our actual microservice name
|
135
|
+
filename.sub!("microservices/TEMPLATE", "microservices/#{microservice_name}")
|
136
|
+
filename.sub!("microservice.rb", microservice_filename)
|
137
|
+
end
|
138
|
+
|
139
|
+
# Add this microservice to plugin.txt
|
140
|
+
File.open("plugin.txt", 'a') do |file|
|
141
|
+
file.puts <<~DOC
|
142
|
+
|
143
|
+
MICROSERVICE #{microservice_name} #{microservice_name.downcase.gsub('_','-')}-microservice
|
144
|
+
CMD ruby #{microservice_name.downcase}.rb
|
145
|
+
DOC
|
146
|
+
end
|
147
|
+
|
148
|
+
puts "Microservice #{microservice_name} successfully generated!"
|
149
|
+
return microservice_name
|
150
|
+
end
|
151
|
+
|
152
|
+
def self.generate_conversion(args)
|
153
|
+
if args.length != 3
|
154
|
+
abort("Usage: cli generate conversion <TARGET> <NAME>")
|
155
|
+
end
|
156
|
+
|
157
|
+
# Create the local variables
|
158
|
+
target_name = args[1].upcase
|
159
|
+
unless File.exist?("targets/#{target_name}")
|
160
|
+
abort("Target '#{target_name}' does not exist! Conversions must be created for existing targets.")
|
161
|
+
end
|
162
|
+
conversion_name = "#{args[2].upcase.gsub(/_+|-+/, '_')}_CONVERSION"
|
163
|
+
conversion_path = "targets/#{target_name}/lib/"
|
164
|
+
conversion_basename = "#{conversion_name.downcase}.rb"
|
165
|
+
conversion_class = conversion_basename.filename_to_class_name
|
166
|
+
conversion_filename = "targets/#{target_name}/lib/#{conversion_basename}"
|
167
|
+
if File.exist?(conversion_filename)
|
168
|
+
abort("Conversion #{conversion_filename} already exists!")
|
169
|
+
end
|
170
|
+
|
171
|
+
process_template("#{TEMPLATES_DIR}/conversion", binding) do |filename|
|
172
|
+
filename.sub!("conversion.rb", conversion_filename)
|
173
|
+
end
|
174
|
+
|
175
|
+
puts "Conversion #{conversion_filename} successfully generated!"
|
176
|
+
puts "To use the conversion add the following to a telemetry item:"
|
177
|
+
puts " READ_CONVERSION #{conversion_basename}"
|
178
|
+
return conversion_name
|
179
|
+
end
|
180
|
+
|
181
|
+
def self.generate_limits_response(args)
|
182
|
+
if args.length != 3
|
183
|
+
abort("Usage: cli generate limits_response <TARGET> <NAME>")
|
184
|
+
end
|
185
|
+
|
186
|
+
# Create the local variables
|
187
|
+
target_name = args[1].upcase
|
188
|
+
unless File.exist?("targets/#{target_name}")
|
189
|
+
abort("Target '#{target_name}' does not exist! Limits responses must be created for existing targets.")
|
190
|
+
end
|
191
|
+
response_name = "#{args[2].upcase.gsub(/_+|-+/, '_')}_LIMITS_RESPONSE"
|
192
|
+
response_path = "targets/#{target_name}/lib/"
|
193
|
+
response_basename = "#{response_name.downcase}.rb"
|
194
|
+
response_class = response_basename.filename_to_class_name
|
195
|
+
response_filename = "targets/#{target_name}/lib/#{response_basename}"
|
196
|
+
if File.exist?(response_filename)
|
197
|
+
abort("response #{response_filename} already exists!")
|
198
|
+
end
|
199
|
+
|
200
|
+
process_template("#{TEMPLATES_DIR}/limits_response", binding) do |filename|
|
201
|
+
filename.sub!("response.rb", response_filename)
|
202
|
+
end
|
203
|
+
|
204
|
+
puts "Limits response #{response_filename} successfully generated!"
|
205
|
+
puts "To use the limits response add the following to a telemetry item:"
|
206
|
+
puts " LIMITS_RESPONSE #{response_basename}"
|
207
|
+
return response_name
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
@@ -275,13 +275,13 @@ module OpenC3
|
|
275
275
|
return if DEFAULT_PLUGINS.include?(gem_name)
|
276
276
|
puts "Updating local plugin files: #{full_folder_path}"
|
277
277
|
FileUtils.mkdir_p(full_folder_path)
|
278
|
-
gems,
|
278
|
+
gems, _ = scan_plugin_dir(full_folder_path)
|
279
279
|
gems.each do |gem|
|
280
280
|
File.delete(gem)
|
281
281
|
end
|
282
282
|
temp_dir = Dir.mktmpdir
|
283
283
|
begin
|
284
|
-
unless File.
|
284
|
+
unless File.exist?(plugin_file_path)
|
285
285
|
plugin_file_path = OpenC3::GemModel.get(plugin_file_path)
|
286
286
|
end
|
287
287
|
File.open(File.join(full_folder_path, File.basename(plugin_file_path)), 'wb') do |file|
|
@@ -26,41 +26,19 @@ module OpenC3
|
|
26
26
|
# Matches ScriptRunner.vue const TEMP_FOLDER
|
27
27
|
TEMP_FOLDER = '__TEMP__'
|
28
28
|
|
29
|
-
def self.all(scope, path_matchers, include_temp: false)
|
30
|
-
|
31
|
-
modified = []
|
32
|
-
temp = []
|
29
|
+
def self.all(scope, path_matchers, target: nil, include_temp: false)
|
30
|
+
target = target.upcase if target
|
33
31
|
|
34
32
|
bucket = Bucket.getClient()
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
# DEFAULT/targets_modified/__TEMP__/YYYY_MM_DD_HH_MM_SS_mmm_temp.rb
|
42
|
-
if split_key[2] == TEMP_FOLDER
|
43
|
-
temp << split_key[2..-1].join('/') if include_temp
|
44
|
-
next
|
45
|
-
end
|
46
|
-
|
47
|
-
if path_matchers
|
48
|
-
found = false
|
49
|
-
path_matchers.each do |path|
|
50
|
-
if split_key.include?(path)
|
51
|
-
found = true
|
52
|
-
break
|
53
|
-
end
|
54
|
-
end
|
55
|
-
next unless found
|
56
|
-
end
|
57
|
-
result_no_scope_or_target_folder = split_key[2..-1].join('/')
|
58
|
-
if object.key.include?("#{scope}/targets_modified")
|
59
|
-
modified << result_no_scope_or_target_folder
|
60
|
-
else
|
61
|
-
result << result_no_scope_or_target_folder
|
62
|
-
end
|
33
|
+
if target
|
34
|
+
prefix = "#{scope}/targets/#{target}/"
|
35
|
+
modified_prefix = "#{scope}/targets_modified/#{target}/"
|
36
|
+
else
|
37
|
+
prefix = "#{scope}/targets/"
|
38
|
+
modified_prefix = "#{scope}/targets_modified/"
|
63
39
|
end
|
40
|
+
result, _ = remote_target_files(bucket_client: bucket, prefix: prefix, include_temp: false, path_matchers: path_matchers)
|
41
|
+
modified, temp = remote_target_files(bucket_client: bucket, prefix: modified_prefix, include_temp: include_temp, path_matchers: path_matchers)
|
64
42
|
|
65
43
|
# Add in local targets_modified if present
|
66
44
|
if ENV['OPENC3_LOCAL_MODE']
|
@@ -172,5 +150,38 @@ module OpenC3
|
|
172
150
|
)
|
173
151
|
true
|
174
152
|
end
|
153
|
+
|
154
|
+
# protected
|
155
|
+
|
156
|
+
def self.remote_target_files(bucket_client:, prefix:, include_temp: false, path_matchers: nil)
|
157
|
+
result = []
|
158
|
+
temp = []
|
159
|
+
resp = bucket_client.list_objects(
|
160
|
+
bucket: ENV['OPENC3_CONFIG_BUCKET'],
|
161
|
+
prefix: prefix,
|
162
|
+
)
|
163
|
+
resp.each do |object|
|
164
|
+
split_key = object.key.split('/')
|
165
|
+
# DEFAULT/targets_modified/__TEMP__/YYYY_MM_DD_HH_MM_SS_mmm_temp.rb
|
166
|
+
if split_key[2] == TEMP_FOLDER
|
167
|
+
temp << split_key[2..-1].join('/') if include_temp
|
168
|
+
next
|
169
|
+
end
|
170
|
+
|
171
|
+
if path_matchers
|
172
|
+
found = false
|
173
|
+
path_matchers.each do |path|
|
174
|
+
if split_key.include?(path)
|
175
|
+
found = true
|
176
|
+
break
|
177
|
+
end
|
178
|
+
end
|
179
|
+
next unless found
|
180
|
+
end
|
181
|
+
result_no_scope_or_target_folder = split_key[2..-1].join('/')
|
182
|
+
result << result_no_scope_or_target_folder
|
183
|
+
end
|
184
|
+
return result, temp
|
185
|
+
end
|
175
186
|
end
|
176
187
|
end
|
data/lib/openc3/version.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# encoding: ascii-8bit
|
2
2
|
|
3
|
-
OPENC3_VERSION = '5.
|
3
|
+
OPENC3_VERSION = '5.5.0'
|
4
4
|
module OpenC3
|
5
5
|
module Version
|
6
6
|
MAJOR = '5'
|
7
|
-
MINOR = '
|
8
|
-
PATCH = '
|
9
|
-
OTHER = '
|
10
|
-
BUILD = '
|
7
|
+
MINOR = '5'
|
8
|
+
PATCH = '0'
|
9
|
+
OTHER = ''
|
10
|
+
BUILD = '6e9e3efe6170bd7adca14b849620f03fb622338d'
|
11
11
|
end
|
12
|
-
VERSION = '5.
|
13
|
-
GEM_VERSION = '5.
|
12
|
+
VERSION = '5.5.0'
|
13
|
+
GEM_VERSION = '5.5.0'
|
14
14
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
|
3
|
+
# Copyright 2023 OpenC3, Inc
|
4
|
+
# All Rights Reserved.
|
5
|
+
#
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
7
|
+
# under the terms of the GNU Affero General Public License
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Affero General Public License for more details.
|
15
|
+
|
16
|
+
# This file may also be used under the terms of a commercial license
|
17
|
+
# if purchased from OpenC3, Inc.
|
18
|
+
|
19
|
+
require 'openc3/conversions/conversion'
|
20
|
+
|
21
|
+
module OpenC3
|
22
|
+
# Custom conversion class
|
23
|
+
# See https://openc3.com/docs/v5/telemetry#read_conversion
|
24
|
+
class <%= conversion_class %> < Conversion
|
25
|
+
def initialize
|
26
|
+
super()
|
27
|
+
# Should be one of :INT, :UINT, :FLOAT, :STRING, :BLOCK
|
28
|
+
@converted_type = :STRING
|
29
|
+
# Size of the converted type in bits
|
30
|
+
# Use 0 for :STRING or :BLOCK where the size can be variable
|
31
|
+
@converted_bit_size = 0
|
32
|
+
end
|
33
|
+
|
34
|
+
# @param value [Object] Value based on the item definition. This could be
|
35
|
+
# a string, integer, float, or array of values.
|
36
|
+
# @param packet [Packet] The packet object where the conversion is defined
|
37
|
+
# @param buffer [String] The raw packet buffer
|
38
|
+
def call(value, packet, buffer)
|
39
|
+
# Typically perform conversion logic directly on value
|
40
|
+
# e.g. value.upcase()
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,51 @@
|
|
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/packets/limits_response'
|
20
|
+
|
21
|
+
module OpenC3
|
22
|
+
class <%= response_class %> < LimitsResponse
|
23
|
+
# @param packet [Packet] Packet the limits response is assigned to
|
24
|
+
# @param item [PacketItem] PacketItem the limits response is assigned to
|
25
|
+
# @param old_limits_state [Symbol] Previous value of the limit. One of nil,
|
26
|
+
# :GREEN_HIGH, :GREEN_LOW, :YELLOW, :YELLOW_HIGH, :YELLOW_LOW,
|
27
|
+
# :RED, :RED_HIGH, :RED_LOW. nil if the previous limit state has not yet
|
28
|
+
# been established.
|
29
|
+
def call(packet, item, old_limits_state)
|
30
|
+
# Take action based on the current limits state
|
31
|
+
# Delete any of the 'when' lines that do not apply or you don't care about
|
32
|
+
case item.limits.state
|
33
|
+
when :RED_HIGH
|
34
|
+
# Take action like sending a command:
|
35
|
+
# cmd('TARGET SAFE')
|
36
|
+
when :RED_LOW
|
37
|
+
when :YELLOW_LOW
|
38
|
+
when :YELLOW_HIGH
|
39
|
+
# GREEN limits are only available if a telemetry item has them defined
|
40
|
+
# COSMOS refers to these as "operational limits"
|
41
|
+
# See https://openc3.com/docs/v5/telemetry#limits
|
42
|
+
when :GREEN_LOW
|
43
|
+
when :GREEN_HIGH
|
44
|
+
# :RED and :YELLOW limits are triggered for STATES with defined RED and YELLOW states
|
45
|
+
# See https://openc3.com/docs/v5/telemetry#state
|
46
|
+
when :RED
|
47
|
+
when :YELLOW
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
|
3
|
+
# Copyright 2023 OpenC3, Inc.
|
4
|
+
# All Rights Reserved.
|
5
|
+
#
|
6
|
+
# This file may also be used under the terms of a commercial license
|
7
|
+
# if purchased from OpenC3, Inc.
|
8
|
+
|
9
|
+
require 'openc3/microservices/microservice'
|
10
|
+
require 'openc3/api/api'
|
11
|
+
|
12
|
+
module OpenC3
|
13
|
+
class <%= microservice_class %> < Microservice
|
14
|
+
include Api # Provides access to api methods
|
15
|
+
|
16
|
+
def initialize(name)
|
17
|
+
super(name)
|
18
|
+
@config['options'].each do |option|
|
19
|
+
# Update with your own OPTION handling
|
20
|
+
case option[0].upcase
|
21
|
+
when 'PERIOD'
|
22
|
+
@period = option[1].to_i
|
23
|
+
else
|
24
|
+
@logger.error("Unknown option passed to microservice #{@name}: #{option}")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
@period = 60 unless @period # 1 minutes
|
29
|
+
@sleeper = Sleeper.new
|
30
|
+
end
|
31
|
+
|
32
|
+
def run
|
33
|
+
while true
|
34
|
+
start_time = Time.now
|
35
|
+
break if @cancel_thread
|
36
|
+
|
37
|
+
# Do your microservice work here
|
38
|
+
Logger.info("Template Microservice ran")
|
39
|
+
# cmd("INST ABORT")
|
40
|
+
|
41
|
+
# The @state variable is set to 'RUNNING' by the microservice base class
|
42
|
+
# The @state is reflected to the user in the MICROSERVICES tab so you can
|
43
|
+
# convey long running actions by changing it, e.g. @state = 'CALCULATING ...'
|
44
|
+
|
45
|
+
run_time = Time.now - start_time
|
46
|
+
delta = @period - run_time
|
47
|
+
if delta > 0
|
48
|
+
# Delay till the next period
|
49
|
+
break if @sleeper.sleep(delta) # returns true and breaks loop on shutdown
|
50
|
+
end
|
51
|
+
@count += 1
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def shutdown
|
56
|
+
@sleeper.cancel # Breaks out of run()
|
57
|
+
super()
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
OpenC3::<%= microservice_class %>.run if __FILE__ == $0
|
@@ -0,0 +1 @@
|
|
1
|
+
# Set VARIABLEs here to allow variation in your plugin
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openc3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Melton
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-02-
|
12
|
+
date: 2023-02-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -445,6 +445,34 @@ dependencies:
|
|
445
445
|
- - "~>"
|
446
446
|
- !ruby/object:Gem::Version
|
447
447
|
version: '0.3'
|
448
|
+
- !ruby/object:Gem::Dependency
|
449
|
+
name: websocket
|
450
|
+
requirement: !ruby/object:Gem::Requirement
|
451
|
+
requirements:
|
452
|
+
- - ">="
|
453
|
+
- !ruby/object:Gem::Version
|
454
|
+
version: '0'
|
455
|
+
type: :runtime
|
456
|
+
prerelease: false
|
457
|
+
version_requirements: !ruby/object:Gem::Requirement
|
458
|
+
requirements:
|
459
|
+
- - ">="
|
460
|
+
- !ruby/object:Gem::Version
|
461
|
+
version: '0'
|
462
|
+
- !ruby/object:Gem::Dependency
|
463
|
+
name: websocket-native
|
464
|
+
requirement: !ruby/object:Gem::Requirement
|
465
|
+
requirements:
|
466
|
+
- - ">="
|
467
|
+
- !ruby/object:Gem::Version
|
468
|
+
version: '0'
|
469
|
+
type: :runtime
|
470
|
+
prerelease: false
|
471
|
+
version_requirements: !ruby/object:Gem::Requirement
|
472
|
+
requirements:
|
473
|
+
- - ">="
|
474
|
+
- !ruby/object:Gem::Version
|
475
|
+
version: '0'
|
448
476
|
- !ruby/object:Gem::Dependency
|
449
477
|
name: dead_end
|
450
478
|
requirement: !ruby/object:Gem::Requirement
|
@@ -916,10 +944,12 @@ files:
|
|
916
944
|
- lib/openc3/script/suite_results.rb
|
917
945
|
- lib/openc3/script/suite_runner.rb
|
918
946
|
- lib/openc3/script/telemetry.rb
|
947
|
+
- lib/openc3/script/web_socket_api.rb
|
919
948
|
- lib/openc3/streams/serial_stream.rb
|
920
949
|
- lib/openc3/streams/stream.rb
|
921
950
|
- lib/openc3/streams/tcpip_client_stream.rb
|
922
951
|
- lib/openc3/streams/tcpip_socket_stream.rb
|
952
|
+
- lib/openc3/streams/web_socket_client_stream.rb
|
923
953
|
- lib/openc3/system.rb
|
924
954
|
- lib/openc3/system/system.rb
|
925
955
|
- lib/openc3/system/system_config.rb
|
@@ -955,6 +985,7 @@ files:
|
|
955
985
|
- lib/openc3/utilities/bucket.rb
|
956
986
|
- lib/openc3/utilities/bucket_file_cache.rb
|
957
987
|
- lib/openc3/utilities/bucket_utilities.rb
|
988
|
+
- lib/openc3/utilities/cli_generator.rb
|
958
989
|
- lib/openc3/utilities/crc.rb
|
959
990
|
- lib/openc3/utilities/csv.rb
|
960
991
|
- lib/openc3/utilities/local_bucket.rb
|
@@ -982,17 +1013,20 @@ files:
|
|
982
1013
|
- lib/openc3/win32/win32_main.rb
|
983
1014
|
- tasks/gemfile_stats.rake
|
984
1015
|
- tasks/spec.rake
|
985
|
-
- templates/
|
986
|
-
- templates/
|
987
|
-
- templates/
|
988
|
-
- templates/plugin
|
989
|
-
- templates/plugin
|
990
|
-
- templates/plugin
|
991
|
-
- templates/plugin
|
992
|
-
- templates/plugin
|
993
|
-
- templates/
|
994
|
-
- templates/
|
995
|
-
- templates/
|
1016
|
+
- templates/conversion/conversion.rb
|
1017
|
+
- templates/limits_response/response.rb
|
1018
|
+
- templates/microservice/microservices/TEMPLATE/microservice.rb
|
1019
|
+
- templates/plugin/LICENSE.txt
|
1020
|
+
- templates/plugin/README.md
|
1021
|
+
- templates/plugin/Rakefile
|
1022
|
+
- templates/plugin/plugin.gemspec
|
1023
|
+
- templates/plugin/plugin.txt
|
1024
|
+
- templates/target/targets/TARGET/cmd_tlm/cmd.txt
|
1025
|
+
- templates/target/targets/TARGET/cmd_tlm/tlm.txt
|
1026
|
+
- templates/target/targets/TARGET/lib/target.rb
|
1027
|
+
- templates/target/targets/TARGET/procedures/procedure.rb
|
1028
|
+
- templates/target/targets/TARGET/screens/status.txt
|
1029
|
+
- templates/target/targets/TARGET/target.txt
|
996
1030
|
homepage: https://github.com/OpenC3/openc3
|
997
1031
|
licenses:
|
998
1032
|
- AGPL-3.0-only
|
@@ -1011,9 +1045,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1011
1045
|
version: '2.7'
|
1012
1046
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1013
1047
|
requirements:
|
1014
|
-
- - "
|
1048
|
+
- - ">="
|
1015
1049
|
- !ruby/object:Gem::Version
|
1016
|
-
version:
|
1050
|
+
version: '0'
|
1017
1051
|
requirements: []
|
1018
1052
|
rubygems_version: 3.3.14
|
1019
1053
|
signing_key:
|
@@ -1,9 +0,0 @@
|
|
1
|
-
# Set VARIABLEs here to allow variation in your plugin
|
2
|
-
# See https://openc3.com/docs/v5/plugins for more information
|
3
|
-
VARIABLE <%= target_name.downcase %>_target_name <%= target_name %>
|
4
|
-
|
5
|
-
# Modify this according to your actual target connection
|
6
|
-
# See https://openc3.com/docs/v5/interfaces for more information
|
7
|
-
TARGET <%= target_name %> <%%= <%= target_name.downcase %>_target_name %>
|
8
|
-
INTERFACE <%%= <%= target_name.downcase %>_target_name %>_INT tcpip_client_interface.rb host.docker.internal 8080 8081 10.0 nil BURST
|
9
|
-
MAP_TARGET <%%= <%= target_name.downcase %>_target_name %>
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|