openc3 5.12.0 → 5.13.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.

Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/bin/openc3cli +3 -3
  4. data/data/config/graph_settings.yaml +1 -1
  5. data/data/config/item_modifiers.yaml +1 -2
  6. data/data/config/parameter_modifiers.yaml +13 -14
  7. data/data/config/screen.yaml +1 -2
  8. data/data/config/target_config.yaml +2 -6
  9. data/lib/openc3/api/cmd_api.rb +99 -35
  10. data/lib/openc3/api/tlm_api.rb +63 -24
  11. data/lib/openc3/interfaces/mqtt_interface.rb +11 -9
  12. data/lib/openc3/interfaces/mqtt_stream_interface.rb +78 -0
  13. data/lib/openc3/logs/packet_log_reader.rb +2 -2
  14. data/lib/openc3/logs/text_log_writer.rb +3 -2
  15. data/lib/openc3/microservices/trigger_group_microservice.rb +2 -1
  16. data/lib/openc3/models/plugin_model.rb +38 -4
  17. data/lib/openc3/packets/json_packet.rb +46 -15
  18. data/lib/openc3/packets/packet_config.rb +2 -1
  19. data/lib/openc3/packets/parsers/xtce_parser.rb +5 -1
  20. data/lib/openc3/script/api_shared.rb +31 -31
  21. data/lib/openc3/script/commands.rb +18 -12
  22. data/lib/openc3/script/limits.rb +1 -1
  23. data/lib/openc3/script/storage.rb +4 -4
  24. data/lib/openc3/script/web_socket_api.rb +2 -2
  25. data/lib/openc3/streams/mqtt_stream.rb +109 -0
  26. data/lib/openc3/utilities/cli_generator.rb +33 -20
  27. data/lib/openc3/utilities/local_mode.rb +2 -2
  28. data/lib/openc3/utilities/logger.rb +17 -16
  29. data/lib/openc3/utilities/process_manager.rb +1 -1
  30. data/lib/openc3/version.rb +5 -5
  31. data/templates/conversion/conversion.py +28 -0
  32. data/templates/conversion/conversion.rb +1 -18
  33. data/templates/limits_response/response.py +37 -0
  34. data/templates/limits_response/response.rb +0 -17
  35. data/templates/microservice/microservices/TEMPLATE/microservice.py +54 -0
  36. data/templates/microservice/microservices/TEMPLATE/microservice.rb +0 -7
  37. data/templates/plugin/.gitignore +1 -0
  38. data/templates/target/targets/TARGET/lib/target.py +9 -0
  39. data/templates/target/targets/TARGET/procedures/procedure.py +3 -0
  40. data/templates/tool_angular/package.json +20 -19
  41. data/templates/tool_angular/yarn.lock +2222 -3212
  42. data/templates/tool_react/package.json +12 -12
  43. data/templates/tool_react/yarn.lock +586 -521
  44. data/templates/tool_svelte/package.json +11 -10
  45. data/templates/tool_svelte/src/services/openc3-api.js +17 -22
  46. data/templates/tool_svelte/yarn.lock +600 -516
  47. data/templates/tool_vue/package.json +10 -9
  48. data/templates/tool_vue/yarn.lock +113 -41
  49. data/templates/widget/package.json +9 -8
  50. data/templates/widget/yarn.lock +96 -35
  51. metadata +26 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 056635373017dd511a8d049e778f59c7548c62dbae9b905effb03d447a0775ae
4
- data.tar.gz: bfe11cbba1792a9741d06f0c3ea9365757d5a3fac0f873cb2a86597796521a11
3
+ metadata.gz: 70d4819352855e3fdb8b4c4d39331968e3e60af59beb0555743b42669d5b4b4a
4
+ data.tar.gz: c906a678c11f68b8751000875fe5cfdfdbbe98880e182edc572791246d625491
5
5
  SHA512:
6
- metadata.gz: d113e832989cef2126d880d5bfb5281185bcf4d393066c8a58797c9178d49165be1c5179609baf665b4bc51d698c1dbd9ed038c580f20c66ac9bdd532eb03d15
7
- data.tar.gz: 6c6010c3310998627247edb81bd3958206e1756d87973a0c601183bc3f50ad8fddd1a2d22fd85d2368c9094a59f7e27f1031b80606f4bce0839d373a71213cf5
6
+ metadata.gz: 2adcf16c91e84be3d1ef2b412ffc57eda1e7ed87e2d808519f9502c2cd937dcc06e766fad4f74b346daa0122a08745442decdbeb9185990206d7098c0331bf51
7
+ data.tar.gz: 413edafbcaebcb868c68f1e0ddfeadc4ef32e4950be652a2520858060efd2274d28e9f15f85d944ae48058c1c52cc72ad768f097f5a7830217ae71345869044d
data/Gemfile CHANGED
@@ -14,4 +14,4 @@ gem 'tzinfo-data'
14
14
  gem 'rspec-rails', '~> 6.0'
15
15
  gem 'simplecov', '~> 0.20'
16
16
  gem 'simplecov-cobertura', '~> 2.1'
17
- gem 'mock_redis', '0.39'
17
+ gem 'mock_redis', '0.40'
data/bin/openc3cli CHANGED
@@ -42,9 +42,8 @@ require 'find'
42
42
  require 'json'
43
43
  require 'redis'
44
44
  require 'erb'
45
- require 'pp'
46
- require "irb"
47
- require "irb/completion"
45
+ require 'irb'
46
+ require 'irb/completion'
48
47
 
49
48
  $redis_url = "redis://#{ENV['OPENC3_REDIS_HOSTNAME']}:#{ENV['OPENC3_REDIS_PORT']}"
50
49
 
@@ -68,6 +67,7 @@ def print_usage
68
67
  puts " cli validate /PATH/FILENAME.gem SCOPE variables.txt # Validate a COSMOS plugin gem file"
69
68
  puts " cli load /PATH/FILENAME.gem SCOPE variables.txt # Loads a COSMOS plugin gem file"
70
69
  puts " cli generate TYPE OPTIONS # Generate various COSMOS entities"
70
+ puts " OPTIONS includes either --ruby or --python to specify the language in the generated code"
71
71
  puts " #{MIGRATE_PARSER}"
72
72
  puts " cli bridge CONFIG_FILENAME # Run COSMOS host bridge"
73
73
  puts " cli bridgegem gem_name variable1=value1 variable2=value2 # Runs bridge using gem bridge.txt"
@@ -18,7 +18,7 @@ HISTORY:
18
18
  parameters:
19
19
  - name: Value
20
20
  required: true
21
- description: Value{d,h,m,s}. For example 1d, 2h, 30m, 15s
21
+ description: Value(d,h,m,s). For example 1d, 2h, 30m, 15s
22
22
  values: .+
23
23
  SECONDSGRAPHED:
24
24
  summary: Display the specified number of seconds in the graph
@@ -32,8 +32,7 @@ STATE:
32
32
  READ_CONVERSION:
33
33
  summary: Applies a conversion to the current telemetry item
34
34
  description: Conversions are implemented in a custom Ruby file which should be
35
- located in the target's lib folder and required by the target's target.txt
36
- file (see REQUIRE). The class must require 'openc3/conversions/conversion'
35
+ located in the target's lib folder. The class must require 'openc3/conversions/conversion'
37
36
  and inherit from Conversion. It must implement the initialize method if it
38
37
  takes extra parameters and must always implement the call method. The conversion
39
38
  factor is applied to the raw value in the telemetry packet before it is displayed
@@ -63,23 +63,22 @@ STATE:
63
63
  values: "['\"].*['\"]"
64
64
  WRITE_CONVERSION:
65
65
  summary: Applies a conversion when writing the current command parameter
66
- description: Conversions are implemented in a custom Ruby file which should be
67
- located in the target's lib folder and required by the target's target.txt
68
- file (see REQUIRE). The class must require 'openc3/conversions/conversion'
66
+ description: |
67
+ Conversions are implemented in a custom Ruby file which should be
68
+ located in the target's lib folder. The class must require 'openc3/conversions/conversion'
69
69
  and inherit from Conversion. It must implement the initialize method if it
70
70
  takes extra parameters and must always implement the call method. The conversion
71
71
  factor is applied to the value entered by the user before it is written into
72
72
  the binary command packet and sent.
73
73
 
74
- <div class="note info">
75
- <h5>Multiple write conversions on command parameters</h5>
76
- <p>When a command is built, each item gets written (and write conversions are run)
74
+ :::info Multiple write conversions on command parameters
75
+ When a command is built, each item gets written (and write conversions are run)
77
76
  to set the default value. Then items are written (again write conversions are run)
78
77
  with user provided values. Thus write conversions can be run twice. Also there are
79
78
  no guarantees which parameters have already been written. The packet itself has a
80
79
  given_values() method which can be used to retrieve a hash of the user provided
81
- values to the command. That can be used to check parameter values passed in.</p>
82
- </div>
80
+ values to the command. That can be used to check parameter values passed in.
81
+ :::
83
82
  example: |
84
83
  WRITE_CONVERSION the_great_conversion.rb 1000
85
84
 
@@ -154,7 +153,8 @@ SEG_POLY_WRITE_CONVERSION:
154
153
  values: .*
155
154
  GENERIC_WRITE_CONVERSION_START:
156
155
  summary: Start a generic write conversion
157
- description: Adds a generic conversion function to the current command parameter.
156
+ description: |
157
+ Adds a generic conversion function to the current command parameter.
158
158
  This conversion factor is applied to the value entered by the user before it
159
159
  is written into the binary command packet and sent. The conversion is specified
160
160
  as ruby code that receives two implied parameters. 'value' which is the raw
@@ -164,15 +164,14 @@ GENERIC_WRITE_CONVERSION_START:
164
164
  value. The GENERIC_WRITE_CONVERSION_END keyword specifies that all lines of
165
165
  ruby code for the conversion have been given.
166
166
 
167
- <div class="note info">
168
- <h5>Multiple write conversions on command parameters</h5>
169
- <p>When a command is built, each item gets written (and write conversions are run)
167
+ :::info Multiple write conversions on command parameters
168
+ When a command is built, each item gets written (and write conversions are run)
170
169
  to set the default value. Then items are written (again write conversions are run)
171
170
  with user provided values. Thus write conversions can be run twice. Also there are
172
171
  no guarantees which parameters have already been written. The packet itself has a
173
172
  given_values() method which can be used to retrieve a hash of the user provided
174
- values to the command. That can be used to check parameter values passed in.</p>
175
- </div>
173
+ values to the command. That can be used to check parameter values passed in.
174
+ :::
176
175
  warning: Generic conversions are not a good long term solution. Consider creating
177
176
  a conversion class and using WRITE_CONVERSION instead. WRITE_CONVERSION is easier
178
177
  to debug and higher performance.
@@ -53,7 +53,7 @@ GLOBAL_SETTING:
53
53
  description: See SETTING for details.
54
54
  values: .*
55
55
  example: |
56
- GLOBAL_SETTING LABELVALUELIMITSBAR COLORBLIND TRUE
56
+ GLOBAL_SETTING LABELVALUELIMITSBAR TEXTCOLOR BLACK
57
57
  GLOBAL_SUBSETTING:
58
58
  summary: Applies a widget subsetting to all widgets of a certain type
59
59
  description: Subsettings are only valid for widgets that are
@@ -81,7 +81,6 @@ GLOBAL_SUBSETTING:
81
81
  description: See SETTING for details.
82
82
  values: .*
83
83
  example: |
84
- GLOBAL_SUBSETTING LABELVALUELIMITSBAR 1 COLORBLIND TRUE
85
84
  # Set all text color to white for labelvaluelimitsbars
86
85
  GLOBAL_SUBSETTING LABELVALUELIMITSBAR 0:0 TEXTCOLOR white
87
86
  SETTING:
@@ -13,10 +13,7 @@ LANGUAGE:
13
13
  since: 5.11.1
14
14
  REQUIRE:
15
15
  summary: Requires a Ruby file
16
- description:
17
- Ruby files must be required to be available to call in other code.
18
- Files are first required from the target's lib folder. If no file is found the
19
- Ruby system path is checked which includes the base openc3/lib folder.
16
+ description: Ruby files optionally be required to explicitly declare dependencies.
20
17
  example: REQUIRE limits_response.rb
21
18
  parameters:
22
19
  - name: Filename
@@ -25,8 +22,7 @@ REQUIRE:
25
22
  simply supply the filename, e.g. "REQUIRE my_file". Files in the base OpenC3
26
23
  lib directory also should just list the filename. If a file is in a folder
27
24
  under the lib directory then you must specify the folder name, e.g. "REQUIRE
28
- folder/my_file". The filename can also be an absolute path but this is not
29
- common. Note the ".rb" extension is optional when specifying the filename.
25
+ folder/my_file". Note the ".rb" extension is optional when specifying the filename.
30
26
  values: .+
31
27
  IGNORE_PARAMETER:
32
28
  summary: Ignore the given command parameter
@@ -39,12 +39,17 @@ module OpenC3
39
39
  'cmd_raw_no_range_check',
40
40
  'cmd_raw_no_hazardous_check',
41
41
  'cmd_raw_no_checks',
42
- 'build_command',
42
+ 'build_cmd',
43
+ 'build_command', # DEPRECATED
43
44
  'send_raw',
44
- 'get_all_commands',
45
- 'get_all_command_names',
46
- 'get_command',
47
- 'get_parameter',
45
+ 'get_all_cmds',
46
+ 'get_all_commands', # DEPRECATED
47
+ 'get_all_cmd_names',
48
+ 'get_all_command_names', # DEPRECATED
49
+ 'get_cmd',
50
+ 'get_command', # DEPRECATED
51
+ 'get_param',
52
+ 'get_parameter', # DEPRECATED
48
53
  'get_cmd_buffer',
49
54
  'get_cmd_hazardous',
50
55
  'get_cmd_value',
@@ -100,7 +105,7 @@ module OpenC3
100
105
  # Build a command binary
101
106
  #
102
107
  # @since 5.8.0
103
- def build_command(*args, range_check: true, raw: false, scope: $openc3_scope, token: $openc3_token, **kwargs)
108
+ def build_cmd(*args, range_check: true, raw: false, scope: $openc3_scope, token: $openc3_token, **kwargs)
104
109
  extract_string_kwargs_to_args(args, kwargs)
105
110
  case args.length
106
111
  when 1
@@ -123,6 +128,8 @@ module OpenC3
123
128
  authorize(permission: 'cmd_info', target_name: target_name, scope: scope, token: token)
124
129
  DecomInterfaceTopic.build_cmd(target_name, cmd_name, cmd_params, range_check, raw, scope: scope)
125
130
  end
131
+ # build_command is DEPRECATED
132
+ alias build_command build_cmd
126
133
 
127
134
  # Send a raw binary string to the specified interface.
128
135
  #
@@ -140,9 +147,8 @@ module OpenC3
140
147
  # @param target_name [String] Target name of the command
141
148
  # @param command_name [String] Packet name of the command
142
149
  # @return [Hash] command hash with last command buffer
143
- def get_cmd_buffer(target_name, command_name, scope: $openc3_scope, token: $openc3_token)
144
- target_name = target_name.upcase
145
- command_name = command_name.upcase
150
+ def get_cmd_buffer(*args, scope: $openc3_scope, token: $openc3_token)
151
+ target_name, command_name = _extract_target_command_names('get_cmd_buffer', *args)
146
152
  authorize(permission: 'cmd_info', target_name: target_name, packet_name: command_name, scope: scope, token: token)
147
153
  TargetModel.packet(target_name, command_name, type: :CMD, scope: scope)
148
154
  topic = "#{scope}__COMMAND__{#{target_name}}__#{command_name}"
@@ -159,35 +165,38 @@ module OpenC3
159
165
  # @since 5.0.0
160
166
  # @param target_name [String] Name of the target
161
167
  # @return [Array<Hash>] Array of all commands as a hash
162
- def get_all_commands(target_name, scope: $openc3_scope, token: $openc3_token)
168
+ def get_all_cmds(target_name, scope: $openc3_scope, token: $openc3_token)
163
169
  target_name = target_name.upcase
164
170
  authorize(permission: 'cmd_info', target_name: target_name, scope: scope, token: token)
165
171
  TargetModel.packets(target_name, type: :CMD, scope: scope)
166
172
  end
173
+ # get_all_commands is DEPRECATED
174
+ alias get_all_commands get_all_cmds
167
175
 
168
176
  # Returns an array of all the command packet names
169
177
  #
170
178
  # @since 5.0.6
171
179
  # @param target_name [String] Name of the target
172
180
  # @return [Array<String>] Array of all command packet names
173
- def get_all_command_names(target_name, scope: $openc3_scope, token: $openc3_token)
181
+ def get_all_cmd_names(target_name, scope: $openc3_scope, token: $openc3_token)
174
182
  target_name = target_name.upcase
175
183
  authorize(permission: 'cmd_info', target_name: target_name, scope: scope, token: token)
176
184
  TargetModel.packet_names(target_name, type: :CMD, scope: scope)
177
185
  end
186
+ # get_all_command_names is DEPRECATED
187
+ alias get_all_command_names get_all_cmd_names
178
188
 
179
189
  # Returns a hash of the given command
180
190
  #
181
191
  # @since 5.0.0
182
- # @param target_name [String] Name of the target
183
- # @param command_name [String] Name of the packet
184
192
  # @return [Hash] Command as a hash
185
- def get_command(target_name, command_name, scope: $openc3_scope, token: $openc3_token)
186
- target_name = target_name.upcase
187
- command_name = command_name.upcase
193
+ def get_cmd(*args, scope: $openc3_scope, token: $openc3_token)
194
+ target_name, command_name = _extract_target_command_names('get_cmd', *args)
188
195
  authorize(permission: 'cmd_info', target_name: target_name, scope: scope, token: token)
189
196
  TargetModel.packet(target_name, command_name, type: :CMD, scope: scope)
190
197
  end
198
+ # get_command is DEPRECATED
199
+ alias get_command get_cmd
191
200
 
192
201
  # Returns a hash of the given command parameter
193
202
  #
@@ -196,13 +205,13 @@ module OpenC3
196
205
  # @param command_name [String] Name of the packet
197
206
  # @param parameter_name [String] Name of the parameter
198
207
  # @return [Hash] Command parameter as a hash
199
- def get_parameter(target_name, command_name, parameter_name, scope: $openc3_scope, token: $openc3_token)
200
- target_name = target_name.upcase
201
- command_name = command_name.upcase
202
- parameter_name = parameter_name.upcase
208
+ def get_param(*args, scope: $openc3_scope, token: $openc3_token)
209
+ target_name, command_name, parameter_name = _extract_target_command_parameter_names('get_param', *args)
203
210
  authorize(permission: 'cmd_info', target_name: target_name, packet_name: command_name, scope: scope, token: token)
204
211
  TargetModel.packet_item(target_name, command_name, parameter_name, type: :CMD, scope: scope)
205
212
  end
213
+ # get_parameter is DEPRECATED
214
+ alias get_parameter get_param
206
215
 
207
216
  # Returns whether the specified command is hazardous
208
217
  #
@@ -257,19 +266,35 @@ module OpenC3
257
266
  end
258
267
 
259
268
  # Returns a value from the specified command
260
- #
261
- # @param target_name [String] Target name of the command
262
- # @param command_name [String] Packet name of the command
263
- # @param parameter_name [String] Parameter name in the command
264
- # @param value_type [Symbol] How the values should be converted. Must be
265
- # one of {Packet::VALUE_TYPES}
266
- # @return [Varies] value
267
- def get_cmd_value(target_name, command_name, parameter_name, value_type = :CONVERTED, scope: $openc3_scope, token: $openc3_token)
268
- target_name = target_name.upcase
269
- command_name = command_name.upcase
270
- parameter_name = parameter_name.upcase
269
+ # Supports the following call syntax:
270
+ # get_cmd_value("TGT PKT ITEM", type: :RAW)
271
+ # get_cmd_value("TGT", "PKT", "ITEM", type: :RAW)
272
+ # get_cmd_value("TGT", "PKT", "ITEM", :RAW) # DEPRECATED
273
+ def get_cmd_value(*args, type: :CONVERTED, scope: $openc3_scope, token: $openc3_token)
274
+ target_name = nil
275
+ command_name = nil
276
+ parameter_name = nil
277
+ case args.length
278
+ when 1
279
+ target_name, command_name, parameter_name = args[0].upcase.split
280
+ when 3
281
+ target_name = args[0].upcase
282
+ command_name = args[1].upcase
283
+ parameter_name = args[2].upcase
284
+ when 4
285
+ target_name = args[0].upcase
286
+ command_name = args[1].upcase
287
+ parameter_name = args[2].upcase
288
+ type = args[3].upcase
289
+ else
290
+ # Invalid number of arguments
291
+ raise "ERROR: Invalid number of arguments (#{args.length}) passed to get_cmd_value()"
292
+ end
293
+ if target_name.nil? or command_name.nil? or parameter_name.nil?
294
+ raise "ERROR: Target name, command name and parameter name required. Usage: get_cmd_value(\"TGT CMD PARAM\") or #{method_name}(\"TGT\", \"CMD\", \"PARAM\")"
295
+ end
271
296
  authorize(permission: 'cmd_info', target_name: target_name, packet_name: command_name, scope: scope, token: token)
272
- CommandDecomTopic.get_cmd_item(target_name, command_name, parameter_name, type: value_type, scope: scope)
297
+ CommandDecomTopic.get_cmd_item(target_name, command_name, parameter_name, type: type, scope: scope)
273
298
  end
274
299
 
275
300
  # Returns the time the most recent command was sent
@@ -317,9 +342,8 @@ module OpenC3
317
342
  # @param target_name [String] Target name of the command
318
343
  # @param command_name [String] Packet name of the command
319
344
  # @return [Numeric] Transmit count for the command
320
- def get_cmd_cnt(target_name, command_name, scope: $openc3_scope, token: $openc3_token)
321
- target_name = target_name.upcase
322
- command_name = command_name.upcase
345
+ def get_cmd_cnt(*args, scope: $openc3_scope, token: $openc3_token)
346
+ target_name, command_name = _extract_target_command_names('get_cmd_cnt', *args)
323
347
  authorize(permission: 'system', target_name: target_name, packet_name: command_name, scope: scope, token: token)
324
348
  TargetModel.packet(target_name, command_name, type: :CMD, scope: scope)
325
349
  Topic.get_cnt("#{scope}__COMMAND__{#{target_name}}__#{command_name}")
@@ -347,6 +371,46 @@ module OpenC3
347
371
  # PRIVATE implementation details
348
372
  ###########################################################################
349
373
 
374
+ def _extract_target_command_names(method_name, *args)
375
+ target_name = nil
376
+ command_name = nil
377
+ case args.length
378
+ when 1
379
+ target_name, command_name = args[0].upcase.split
380
+ when 2
381
+ target_name = args[0].upcase
382
+ command_name = args[1].upcase
383
+ else
384
+ # Invalid number of arguments
385
+ raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{method_name}()"
386
+ end
387
+ if target_name.nil? or command_name.nil?
388
+ raise "ERROR: Target name and command name required. Usage: #{method_name}(\"TGT CMD\") or #{method_name}(\"TGT\", \"CMD\")"
389
+ end
390
+ return [target_name, command_name]
391
+ end
392
+
393
+ def _extract_target_command_parameter_names(method_name, *args)
394
+ target_name = nil
395
+ command_name = nil
396
+ parameter_name = nil
397
+ case args.length
398
+ when 1
399
+ target_name, command_name, parameter_name = args[0].upcase.split
400
+ when 3
401
+ target_name = args[0].upcase
402
+ command_name = args[1].upcase
403
+ parameter_name = args[2].upcase
404
+ else
405
+ # Invalid number of arguments
406
+ raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{method_name}()"
407
+ end
408
+ if target_name.nil? or command_name.nil? or parameter_name.nil?
409
+ raise "ERROR: Target name, command name and parameter name required. Usage: #{method_name}(\"TGT CMD PARAM\") or #{method_name}(\"TGT\", \"CMD\", \"PARAM\")"
410
+ end
411
+ return [target_name, command_name, parameter_name]
412
+ end
413
+
350
414
  def _cmd_implementation(method_name, *args, range_check:, hazardous_check:, raw:, timeout: nil, log_message: nil,
351
415
  scope: $openc3_scope, token: $openc3_token, **kwargs)
352
416
  extract_string_kwargs_to_args(args, kwargs)
@@ -44,9 +44,12 @@ module OpenC3
44
44
  'get_tlm_buffer',
45
45
  'get_tlm_packet',
46
46
  'get_tlm_values',
47
- 'get_all_telemetry',
48
- 'get_all_telemetry_names',
49
- 'get_telemetry',
47
+ 'get_all_tlm',
48
+ 'get_all_telemetry', # DEPRECATED
49
+ 'get_all_tlm_names',
50
+ 'get_all_telemetry_names', # DEPRECATED
51
+ 'get_tlm',
52
+ 'get_telemetry', # DEPRECATED
50
53
  'get_item',
51
54
  'subscribe_packets',
52
55
  'get_packets',
@@ -201,9 +204,8 @@ module OpenC3
201
204
  # @param target_name [String] Name of the target
202
205
  # @param packet_name [String] Name of the packet
203
206
  # @return [Hash] telemetry hash with last telemetry buffer
204
- def get_tlm_buffer(target_name, packet_name, scope: $openc3_scope, token: $openc3_token)
205
- target_name = target_name.upcase
206
- packet_name = packet_name.upcase
207
+ def get_tlm_buffer(*args, scope: $openc3_scope, token: $openc3_token)
208
+ target_name, packet_name = _extract_target_packet_names('get_tlm_buffer', *args)
207
209
  authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
208
210
  TargetModel.packet(target_name, packet_name, scope: scope)
209
211
  topic = "#{scope}__TELEMETRY__{#{target_name}}__#{packet_name}"
@@ -224,9 +226,8 @@ module OpenC3
224
226
  # @return [Array<String, Object, Symbol|nil>] Returns an Array consisting
225
227
  # of [item name, item value, item limits state] where the item limits
226
228
  # state can be one of {OpenC3::Limits::LIMITS_STATES}
227
- def get_tlm_packet(target_name, packet_name, stale_time: 30, type: :CONVERTED, cache_timeout: 0.1, scope: $openc3_scope, token: $openc3_token)
228
- target_name = target_name.upcase
229
- packet_name = packet_name.upcase
229
+ def get_tlm_packet(*args, stale_time: 30, type: :CONVERTED, cache_timeout: 0.1, scope: $openc3_scope, token: $openc3_token)
230
+ target_name, packet_name = _extract_target_packet_names('get_tlm_packet', *args)
230
231
  authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
231
232
  packet = TargetModel.packet(target_name, packet_name, scope: scope)
232
233
  t = _validate_tlm_type(type)
@@ -274,22 +275,24 @@ module OpenC3
274
275
  # @since 5.0.0
275
276
  # @param target_name [String] Name of the target
276
277
  # @return [Array<Hash>] Array of all telemetry packet hashes
277
- def get_all_telemetry(target_name, scope: $openc3_scope, token: $openc3_token)
278
+ def get_all_tlm(target_name, scope: $openc3_scope, token: $openc3_token)
278
279
  target_name = target_name.upcase
279
280
  authorize(permission: 'tlm', target_name: target_name, scope: scope, token: token)
280
281
  TargetModel.packets(target_name, type: :TLM, scope: scope)
281
282
  end
283
+ alias get_all_telemetry get_all_tlm
282
284
 
283
285
  # Returns an array of all the telemetry packet names
284
286
  #
285
287
  # @since 5.0.6
286
288
  # @param target_name [String] Name of the target
287
289
  # @return [Array<String>] Array of all telemetry packet names
288
- def get_all_telemetry_names(target_name, scope: $openc3_scope, token: $openc3_token)
290
+ def get_all_tlm_names(target_name, scope: $openc3_scope, token: $openc3_token)
289
291
  target_name = target_name.upcase
290
292
  authorize(permission: 'cmd_info', target_name: target_name, scope: scope, token: token)
291
293
  TargetModel.packet_names(target_name, type: :TLM, scope: scope)
292
294
  end
295
+ alias get_all_telemetry_names get_all_tlm_names
293
296
 
294
297
  # Returns a telemetry packet hash
295
298
  #
@@ -297,12 +300,12 @@ module OpenC3
297
300
  # @param target_name [String] Name of the target
298
301
  # @param packet_name [String] Name of the packet
299
302
  # @return [Hash] Telemetry packet hash
300
- def get_telemetry(target_name, packet_name, scope: $openc3_scope, token: $openc3_token)
301
- target_name = target_name.upcase
302
- packet_name = packet_name.upcase
303
+ def get_tlm(*args, scope: $openc3_scope, token: $openc3_token)
304
+ target_name, packet_name = _extract_target_packet_names('get_tlm', *args)
303
305
  authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
304
306
  TargetModel.packet(target_name, packet_name, scope: scope)
305
307
  end
308
+ alias get_telemetry get_tlm
306
309
 
307
310
  # Returns a telemetry packet item hash
308
311
  #
@@ -311,10 +314,8 @@ module OpenC3
311
314
  # @param packet_name [String] Name of the packet
312
315
  # @param item_name [String] Name of the packet
313
316
  # @return [Hash] Telemetry packet item hash
314
- def get_item(target_name, packet_name, item_name, scope: $openc3_scope, token: $openc3_token)
315
- target_name = target_name.upcase
316
- packet_name = packet_name.upcase
317
- item_name = item_name.upcase
317
+ def get_item(*args, scope: $openc3_scope, token: $openc3_token)
318
+ target_name, packet_name, item_name = _extract_target_packet_item_names('get_item', *args)
318
319
  authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
319
320
  TargetModel.packet_item(target_name, packet_name, item_name, scope: scope)
320
321
  end
@@ -375,9 +376,8 @@ module OpenC3
375
376
  # @param target_name [String] Name of the target
376
377
  # @param packet_name [String] Name of the packet
377
378
  # @return [Numeric] Receive count for the telemetry packet
378
- def get_tlm_cnt(target_name, packet_name, scope: $openc3_scope, token: $openc3_token)
379
- target_name = target_name.upcase
380
- packet_name = packet_name.upcase
379
+ def get_tlm_cnt(*args, scope: $openc3_scope, token: $openc3_token)
380
+ target_name, packet_name = _extract_target_packet_names('get_tlm_cnt', *args)
381
381
  authorize(permission: 'system', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
382
382
  TargetModel.packet(target_name, packet_name, scope: scope)
383
383
  Topic.get_cnt("#{scope}__TELEMETRY__{#{target_name}}__#{packet_name}")
@@ -403,9 +403,8 @@ module OpenC3
403
403
  # @param target_name [String] Target name
404
404
  # @param packet_name [String] Packet name
405
405
  # @return [Array<String>] All of the ignored telemetry items for a packet.
406
- def get_packet_derived_items(target_name, packet_name, scope: $openc3_scope, token: $openc3_token)
407
- target_name = target_name.upcase
408
- packet_name = packet_name.upcase
406
+ def get_packet_derived_items(*args, scope: $openc3_scope, token: $openc3_token)
407
+ target_name, packet_name = _extract_target_packet_names('get_packet_derived_items', *args)
409
408
  authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
410
409
  packet = TargetModel.packet(target_name, packet_name, scope: scope)
411
410
  return packet['items'].select { |item| item['data_type'] == 'DERIVED' }.map { |item| item['name'] }
@@ -413,6 +412,46 @@ module OpenC3
413
412
 
414
413
  # PRIVATE
415
414
 
415
+ def _extract_target_packet_names(method_name, *args)
416
+ target_name = nil
417
+ packet_name = nil
418
+ case args.length
419
+ when 1
420
+ target_name, packet_name = args[0].upcase.split
421
+ when 2
422
+ target_name = args[0].upcase
423
+ packet_name = args[1].upcase
424
+ else
425
+ # Invalid number of arguments
426
+ raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{method_name}()"
427
+ end
428
+ if target_name.nil? or packet_name.nil?
429
+ raise "ERROR: Both target name and packet name required. Usage: #{method_name}(\"TGT PKT\") or #{method_name}(\"TGT\", \"PKT\")"
430
+ end
431
+ return [target_name, packet_name]
432
+ end
433
+
434
+ def _extract_target_packet_item_names(method_name, *args)
435
+ target_name = nil
436
+ packet_name = nil
437
+ item_name = nil
438
+ case args.length
439
+ when 1
440
+ target_name, packet_name, item_name = args[0].upcase.split
441
+ when 3
442
+ target_name = args[0].upcase
443
+ packet_name = args[1].upcase
444
+ item_name = args[2].upcase
445
+ else
446
+ # Invalid number of arguments
447
+ raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{method_name}()"
448
+ end
449
+ if target_name.nil? or packet_name.nil? or item_name.nil?
450
+ raise "ERROR: Target name, packet name, and item name are required. Usage: #{method_name}(\"TGT PKT ITEM\") or #{method_name}(\"TGT\", \"PKT\", \"ITEM\")"
451
+ end
452
+ return [target_name, packet_name, item_name]
453
+ end
454
+
416
455
  def _validate_tlm_type(type)
417
456
  case type.intern
418
457
  when :RAW
@@ -161,8 +161,8 @@ module OpenC3
161
161
  end
162
162
 
163
163
  def read
164
- topic = @read_topics.shift
165
164
  packet = super()
165
+ topic = @read_topics.shift
166
166
  return nil unless packet
167
167
  identified_packet = @read_packets_by_topic[topic]
168
168
  if identified_packet
@@ -175,15 +175,17 @@ module OpenC3
175
175
  end
176
176
 
177
177
  def write(packet)
178
- topics = packet.meta['TOPIC']
179
- topics = packet.meta['TOPICS'] unless topics
180
- if topics
181
- topics.each do |topic|
182
- @write_topics << topic
183
- super(packet)
178
+ @write_mutex.synchronize do
179
+ topics = packet.meta['TOPIC']
180
+ topics = packet.meta['TOPICS'] unless topics
181
+ if topics
182
+ topics.each do |topic|
183
+ @write_topics << topic
184
+ super(packet)
185
+ end
186
+ else
187
+ raise "Command packet #{packet.target_name} #{packet.packet_name} requires a META TOPIC or TOPICS"
184
188
  end
185
- else
186
- raise "Command packet #{packet.target_name} #{packet.packet_name} requires a META TOPIC or TOPICS"
187
189
  end
188
190
  end
189
191