openc3 5.0.8 → 5.0.10

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.

Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/bin/openc3cli +128 -95
  3. data/data/config/_id_items.yaml +2 -1
  4. data/data/config/_id_params.yaml +2 -1
  5. data/data/config/_items.yaml +2 -1
  6. data/data/config/_params.yaml +2 -1
  7. data/data/config/command_modifiers.yaml +30 -0
  8. data/data/config/item_modifiers.yaml +10 -0
  9. data/data/config/microservice.yaml +12 -0
  10. data/data/config/param_item_modifiers.yaml +10 -0
  11. data/data/config/plugins.yaml +0 -9
  12. data/data/config/telemetry_modifiers.yaml +10 -0
  13. data/data/config/widgets.yaml +49 -73
  14. data/ext/openc3/ext/packet/packet.c +20 -2
  15. data/ext/openc3/ext/structure/structure.c +12 -17
  16. data/lib/openc3/accessors/accessor.rb +71 -0
  17. data/lib/openc3/accessors/binary_accessor.rb +1226 -0
  18. data/lib/openc3/accessors/cbor_accessor.rb +83 -0
  19. data/lib/openc3/accessors/html_accessor.rb +28 -0
  20. data/lib/openc3/accessors/json_accessor.rb +131 -0
  21. data/lib/openc3/accessors/xml_accessor.rb +67 -0
  22. data/lib/openc3/accessors.rb +23 -0
  23. data/lib/openc3/api/cmd_api.rb +5 -2
  24. data/lib/openc3/api/interface_api.rb +15 -0
  25. data/lib/openc3/api/limits_api.rb +3 -3
  26. data/lib/openc3/config/config_parser.rb +10 -4
  27. data/lib/openc3/core_ext/file.rb +5 -0
  28. data/lib/openc3/core_ext/tempfile.rb +20 -0
  29. data/lib/openc3/io/json_rpc.rb +3 -3
  30. data/lib/openc3/microservices/cleanup_microservice.rb +7 -5
  31. data/lib/openc3/models/cvt_model.rb +1 -10
  32. data/lib/openc3/models/interface_model.rb +41 -0
  33. data/lib/openc3/models/microservice_model.rb +33 -1
  34. data/lib/openc3/models/plugin_model.rb +1 -1
  35. data/lib/openc3/models/target_model.rb +85 -68
  36. data/lib/openc3/packets/binary_accessor.rb +2 -1207
  37. data/lib/openc3/packets/packet.rb +106 -6
  38. data/lib/openc3/packets/packet_config.rb +30 -7
  39. data/lib/openc3/packets/parsers/limits_response_parser.rb +1 -3
  40. data/lib/openc3/packets/parsers/processor_parser.rb +1 -2
  41. data/lib/openc3/packets/parsers/xtce_parser.rb +68 -3
  42. data/lib/openc3/packets/structure.rb +39 -14
  43. data/lib/openc3/packets/structure_item.rb +15 -1
  44. data/lib/openc3/script/storage.rb +19 -1
  45. data/lib/openc3/utilities/local_mode.rb +521 -0
  46. data/lib/openc3/utilities/simulated_target.rb +3 -2
  47. data/lib/openc3/utilities/target_file.rb +146 -0
  48. data/lib/openc3/version.rb +5 -5
  49. data/lib/openc3.rb +1 -0
  50. metadata +45 -7
@@ -24,6 +24,7 @@ require 'openc3/models/microservice_model'
24
24
  require 'openc3/topics/limits_event_topic'
25
25
  require 'openc3/topics/config_topic'
26
26
  require 'openc3/system'
27
+ require 'openc3/utilities/local_mode'
27
28
  require 'openc3/utilities/s3'
28
29
  require 'openc3/utilities/zip'
29
30
  require 'fileutils'
@@ -87,29 +88,36 @@ module OpenC3
87
88
  targets = self.all(scope: scope)
88
89
  targets.each { |target_name, target| target['modified'] = false }
89
90
 
90
- rubys3_client = Aws::S3::Client.new
91
- token = nil
92
- while true
93
- resp = rubys3_client.list_objects_v2({
94
- bucket: 'config',
95
- max_keys: 1000,
96
- # The trailing slash is important!
97
- prefix: "#{scope}/targets_modified/",
98
- delimiter: '/',
99
- continuation_token: token
100
- })
101
- resp.common_prefixes.each do |item|
102
- # Results look like DEFAULT/targets_modified/INST/
103
- # so split on '/' and pull out the last value
104
- target_name = item.prefix.split('/')[-1]
105
- # A target could have been deleted without removing the modified files
106
- # Thus we have to check for the existance of the target_name key
107
- if targets.has_key?(target_name)
108
- targets[target_name]['modified'] = true
91
+ if ENV['OPENC3_LOCAL_MODE']
92
+ modified_targets = OpenC3::LocalMode.modified_targets(scope: scope)
93
+ modified_targets.each do |target_name|
94
+ targets[target_name]['modified'] = true if targets[target_name]
95
+ end
96
+ else
97
+ rubys3_client = Aws::S3::Client.new
98
+ token = nil
99
+ while true
100
+ resp = rubys3_client.list_objects_v2({
101
+ bucket: 'config',
102
+ max_keys: 1000,
103
+ # The trailing slash is important!
104
+ prefix: "#{scope}/targets_modified/",
105
+ delimiter: '/',
106
+ continuation_token: token
107
+ })
108
+ resp.common_prefixes.each do |item|
109
+ # Results look like DEFAULT/targets_modified/INST/
110
+ # so split on '/' and pull out the last value
111
+ target_name = item.prefix.split('/')[-1]
112
+ # A target could have been deleted without removing the modified files
113
+ # Thus we have to check for the existance of the target_name key
114
+ if targets.has_key?(target_name)
115
+ targets[target_name]['modified'] = true
116
+ end
109
117
  end
118
+ break unless resp.is_truncated
119
+ token = resp.next_continuation_token
110
120
  end
111
- break unless resp.is_truncated
112
- token = resp.next_continuation_token
113
121
  end
114
122
  # Sort (which turns hash to array) and return hash
115
123
  # This enables a consistent listing of the targets
@@ -117,31 +125,41 @@ module OpenC3
117
125
  end
118
126
 
119
127
  # Given target's modified file list
120
- def self.modified_files(name, scope:)
128
+ def self.modified_files(target_name, scope:)
121
129
  modified = []
122
- rubys3_client = Aws::S3::Client.new
123
- token = nil
124
- while true
125
- resp = rubys3_client.list_objects_v2({
126
- bucket: 'config',
127
- max_keys: 1000,
128
- # The trailing slash is important!
129
- prefix: "#{scope}/targets_modified/#{name}/",
130
- continuation_token: token
131
- })
132
- resp.contents.each do |item|
133
- # Results look like DEFAULT/targets_modified/INST/procedures/new.rb
134
- # so split on '/' and ignore the first two values
135
- modified << item.key.split('/')[2..-1].join('/')
130
+
131
+ if ENV['OPENC3_LOCAL_MODE']
132
+ modified = OpenC3::LocalMode.modified_files(target_name, scope: scope)
133
+ else
134
+ rubys3_client = Aws::S3::Client.new
135
+ token = nil
136
+ while true
137
+ resp = rubys3_client.list_objects_v2({
138
+ bucket: 'config',
139
+ max_keys: 1000,
140
+ # The trailing slash is important!
141
+ prefix: "#{scope}/targets_modified/#{target_name}/",
142
+ continuation_token: token
143
+ })
144
+ resp.contents.each do |item|
145
+ # Results look like DEFAULT/targets_modified/INST/procedures/new.rb
146
+ # so split on '/' and ignore the first two values
147
+ modified << item.key.split('/')[2..-1].join('/')
148
+ end
149
+ break unless resp.is_truncated
150
+ token = resp.next_continuation_token
136
151
  end
137
- break unless resp.is_truncated
138
- token = resp.next_continuation_token
139
152
  end
140
153
  # Sort to enable a consistent listing of the modified files
141
154
  modified.sort
142
155
  end
143
156
 
144
- def self.delete_modified(name, scope:)
157
+ def self.delete_modified(target_name, scope:)
158
+ if ENV['OPENC3_LOCAL_MODE']
159
+ OpenC3::LocalMode.delete_modified(target_name, scope: scope)
160
+ end
161
+
162
+ # Delete the remote files as well
145
163
  rubys3_client = Aws::S3::Client.new
146
164
  token = nil
147
165
  while true
@@ -149,7 +167,7 @@ module OpenC3
149
167
  bucket: 'config',
150
168
  max_keys: 1000,
151
169
  # The trailing slash is important!
152
- prefix: "#{scope}/targets_modified/#{name}/",
170
+ prefix: "#{scope}/targets_modified/#{target_name}/",
153
171
  continuation_token: token
154
172
  })
155
173
  resp.contents.each do |item|
@@ -158,41 +176,40 @@ module OpenC3
158
176
  break unless resp.is_truncated
159
177
  token = resp.next_continuation_token
160
178
  end
161
- # rubys3_client = Aws::S3::Client.new
162
- # prefix = "#{scope}/targets_modified/#{name}/"
163
- # rubys3_client.list_objects(bucket: 'config', prefix: prefix).contents.each do |object|
164
- # rubys3_client.delete_object(bucket: 'config', key: object.key)
165
- # end
166
179
  end
167
180
 
168
- def self.download(name, scope:)
181
+ def self.download(target_name, scope:)
169
182
  tmp_dir = Dir.mktmpdir
170
- zip_filename = File.join(tmp_dir, "#{name}.zip")
183
+ zip_filename = File.join(tmp_dir, "#{target_name}.zip")
171
184
  Zip.continue_on_exists_proc = true
172
185
  zip = Zip::File.open(zip_filename, Zip::File::CREATE)
173
186
 
174
- rubys3_client = Aws::S3::Client.new
175
- token = nil
176
- # The trailing slash is important!
177
- prefix = "#{scope}/targets_modified/#{name}/"
178
- while true
179
- resp = rubys3_client.list_objects_v2({
180
- bucket: 'config',
181
- max_keys: 1000,
182
- prefix: prefix,
183
- continuation_token: token
184
- })
185
- resp.contents.each do |item|
186
- # item.key looks like DEFAULT/targets_modified/INST/screens/blah.txt
187
- base_path = item.key.sub(prefix, '') # remove prefix
188
- local_path = File.join(tmp_dir, base_path)
189
- # Ensure dir structure exists, get_object fails if not
190
- FileUtils.mkdir_p(File.dirname(local_path))
191
- rubys3_client.get_object(bucket: 'config', key: item.key, response_target: local_path)
192
- zip.add(base_path, local_path)
187
+ if ENV['OPENC3_LOCAL_MODE']
188
+ OpenC3::LocalMode.zip_target(target_name, zip, scope: scope)
189
+ else
190
+ rubys3_client = Aws::S3::Client.new
191
+ token = nil
192
+ # The trailing slash is important!
193
+ prefix = "#{scope}/targets_modified/#{target_name}/"
194
+ while true
195
+ resp = rubys3_client.list_objects_v2({
196
+ bucket: 'config',
197
+ max_keys: 1000,
198
+ prefix: prefix,
199
+ continuation_token: token
200
+ })
201
+ resp.contents.each do |item|
202
+ # item.key looks like DEFAULT/targets_modified/INST/screens/blah.txt
203
+ base_path = item.key.sub(prefix, '') # remove prefix
204
+ local_path = File.join(tmp_dir, base_path)
205
+ # Ensure dir structure exists, get_object fails if not
206
+ FileUtils.mkdir_p(File.dirname(local_path))
207
+ rubys3_client.get_object(bucket: 'config', key: item.key, response_target: local_path)
208
+ zip.add(base_path, local_path)
209
+ end
210
+ break unless resp.is_truncated
211
+ token = resp.next_continuation_token
193
212
  end
194
- break unless resp.is_truncated
195
- token = resp.next_continuation_token
196
213
  end
197
214
  zip.close
198
215