openc3 5.12.0 → 5.14.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 (80) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -3
  3. data/bin/openc3cli +21 -18
  4. data/data/config/command_modifiers.yaml +53 -1
  5. data/data/config/graph_settings.yaml +1 -1
  6. data/data/config/item_modifiers.yaml +1 -2
  7. data/data/config/parameter_modifiers.yaml +13 -14
  8. data/data/config/screen.yaml +1 -2
  9. data/data/config/target_config.yaml +2 -6
  10. data/lib/openc3/accessors/accessor.rb +42 -29
  11. data/lib/openc3/accessors/binary_accessor.rb +11 -1
  12. data/lib/openc3/accessors/form_accessor.rb +11 -1
  13. data/lib/openc3/accessors/http_accessor.rb +38 -0
  14. data/lib/openc3/accessors/json_accessor.rb +15 -3
  15. data/lib/openc3/accessors/template_accessor.rb +150 -0
  16. data/lib/openc3/accessors/xml_accessor.rb +11 -1
  17. data/lib/openc3/accessors.rb +1 -0
  18. data/lib/openc3/api/cmd_api.rb +99 -35
  19. data/lib/openc3/api/limits_api.rb +3 -3
  20. data/lib/openc3/api/tlm_api.rb +70 -31
  21. data/lib/openc3/interfaces/interface.rb +9 -7
  22. data/lib/openc3/interfaces/mqtt_interface.rb +11 -9
  23. data/lib/openc3/interfaces/mqtt_stream_interface.rb +78 -0
  24. data/lib/openc3/interfaces/protocols/cmd_response_protocol.rb +116 -0
  25. data/lib/openc3/interfaces/tcpip_client_interface.rb +4 -0
  26. data/lib/openc3/interfaces/tcpip_server_interface.rb +5 -0
  27. data/lib/openc3/interfaces.rb +1 -1
  28. data/lib/openc3/logs/packet_log_reader.rb +2 -2
  29. data/lib/openc3/logs/text_log_writer.rb +3 -2
  30. data/lib/openc3/microservices/decom_microservice.rb +1 -0
  31. data/lib/openc3/microservices/interface_microservice.rb +10 -1
  32. data/lib/openc3/microservices/trigger_group_microservice.rb +2 -1
  33. data/lib/openc3/models/cvt_model.rb +16 -12
  34. data/lib/openc3/models/gem_model.rb +20 -3
  35. data/lib/openc3/models/microservice_model.rb +1 -1
  36. data/lib/openc3/models/plugin_model.rb +43 -5
  37. data/lib/openc3/models/target_model.rb +69 -8
  38. data/lib/openc3/packets/json_packet.rb +46 -15
  39. data/lib/openc3/packets/packet.rb +92 -4
  40. data/lib/openc3/packets/packet_config.rb +27 -2
  41. data/lib/openc3/packets/parsers/xtce_parser.rb +5 -1
  42. data/lib/openc3/script/api_shared.rb +42 -31
  43. data/lib/openc3/script/commands.rb +18 -12
  44. data/lib/openc3/script/limits.rb +1 -1
  45. data/lib/openc3/script/script.rb +6 -12
  46. data/lib/openc3/script/storage.rb +4 -4
  47. data/lib/openc3/script/web_socket_api.rb +2 -2
  48. data/lib/openc3/streams/mqtt_stream.rb +109 -0
  49. data/lib/openc3/streams/tcpip_socket_stream.rb +19 -0
  50. data/lib/openc3/system/system.rb +13 -1
  51. data/lib/openc3/utilities/cli_generator.rb +48 -21
  52. data/lib/openc3/utilities/local_mode.rb +3 -3
  53. data/lib/openc3/utilities/logger.rb +17 -16
  54. data/lib/openc3/utilities/process_manager.rb +1 -1
  55. data/lib/openc3/utilities/store_queued.rb +126 -0
  56. data/lib/openc3/version.rb +5 -5
  57. data/templates/conversion/conversion.py +28 -0
  58. data/templates/conversion/conversion.rb +1 -18
  59. data/templates/limits_response/response.py +37 -0
  60. data/templates/limits_response/response.rb +0 -17
  61. data/templates/microservice/microservices/TEMPLATE/microservice.py +54 -0
  62. data/templates/microservice/microservices/TEMPLATE/microservice.rb +0 -7
  63. data/templates/plugin/.gitignore +1 -0
  64. data/templates/plugin/plugin.gemspec +2 -2
  65. data/templates/target/targets/TARGET/lib/target.py +9 -0
  66. data/templates/target/targets/TARGET/procedures/procedure.py +3 -0
  67. data/templates/target/targets/TARGET/public/README.txt +1 -0
  68. data/templates/tool_angular/package.json +21 -20
  69. data/templates/tool_angular/yarn.lock +2287 -3171
  70. data/templates/tool_react/package.json +15 -15
  71. data/templates/tool_react/yarn.lock +716 -789
  72. data/templates/tool_svelte/package.json +16 -15
  73. data/templates/tool_svelte/src/services/openc3-api.js +17 -22
  74. data/templates/tool_svelte/yarn.lock +715 -620
  75. data/templates/tool_vue/package.json +16 -15
  76. data/templates/tool_vue/yarn.lock +149 -69
  77. data/templates/widget/package.json +15 -14
  78. data/templates/widget/yarn.lock +132 -63
  79. metadata +160 -148
  80. data/lib/openc3/io/openc3_snmp.rb +0 -61
@@ -0,0 +1,150 @@
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2024 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/accessors/accessor'
20
+
21
+ module OpenC3
22
+ class TemplateAccessor < Accessor
23
+ def initialize(packet, left_char = '<', right_char = '>')
24
+ super(packet)
25
+ @left_char = left_char
26
+ @right_char = right_char
27
+ @configured = false
28
+ end
29
+
30
+ def configure
31
+ return if @configured
32
+
33
+ escaped_left_char = @left_char
34
+ escaped_left_char = "\\#{@left_char}" if @left_char == '('
35
+ escaped_right_char = @right_char
36
+ escaped_right_char = "\\#{@right_char}" if @right_char == ')'
37
+
38
+ # Convert the template into a Regexp for reading each item
39
+ template = @packet.template.dup
40
+ template_items = template.scan(Regexp.new("#{escaped_left_char}.*?#{escaped_right_char}"))
41
+ escaped_read_template = template
42
+ if @left_char != '('
43
+ escaped_read_template = escaped_read_template.gsub('(', '\(')
44
+ end
45
+ if @right_char != ')'
46
+ escaped_read_template = escaped_read_template.gsub(')', '\)')
47
+ end
48
+
49
+ @item_keys = []
50
+ template_items.each do |item|
51
+ @item_keys << item[1..-2]
52
+ escaped_read_template.gsub!(item, "(.*)")
53
+ end
54
+ @read_regexp = Regexp.new(escaped_read_template)
55
+
56
+ @configured = true
57
+ end
58
+
59
+ def read_item(item, buffer)
60
+ return nil if item.data_type == :DERIVED
61
+ configure()
62
+
63
+ # Scan the response for all the variables in brackets <VARIABLE>
64
+ values = buffer.scan(@read_regexp)[0]
65
+ if !values || (values.length != @item_keys.length)
66
+ raise "Unexpected number of items found in buffer: #{values ? values.length : 0}, Expected: #{@item_keys.length}"
67
+ else
68
+ values.each_with_index do |value, i|
69
+ item_key = @item_keys[i]
70
+ if item_key == item.key
71
+ return Accessor.convert_to_type(value, item)
72
+ end
73
+ end
74
+ end
75
+
76
+ raise "Response does not include key #{item.key}: #{buffer}"
77
+ end
78
+
79
+ def read_items(items, buffer)
80
+ result = {}
81
+ configure()
82
+
83
+ # Scan the response for all the variables in brackets <VARIABLE>
84
+ values = buffer.scan(@read_regexp)[0]
85
+ if !values || (values.length != @item_keys.length)
86
+ raise "Unexpected number of items found in buffer: #{values ? values.length : 0}, Expected: #{@item_keys.length}"
87
+ else
88
+ items.each do |item|
89
+ if item.data_type == :DERIVED
90
+ result[item.name] = nil
91
+ next
92
+ end
93
+ index = @item_keys.index(item.key)
94
+ if index
95
+ result[item.name] = Accessor.convert_to_type(values[index], item)
96
+ else
97
+ raise "Unknown item with key #{item.key} requested"
98
+ end
99
+ end
100
+ end
101
+
102
+ return result
103
+ end
104
+
105
+ def write_item(item, value, buffer)
106
+ return nil if item.data_type == :DERIVED
107
+ configure()
108
+
109
+ success = buffer.gsub!("#{@left_char}#{item.key}#{@right_char}", value.to_s)
110
+ raise "Key #{item.key} not found in template" unless success
111
+ return value
112
+ end
113
+
114
+ def write_items(items, values, buffer)
115
+ configure()
116
+ items.each_with_index do |item, index|
117
+ next if item.data_type == :DERIVED
118
+ success = buffer.gsub!("#{@left_char}#{item.key}#{@right_char}", values[index].to_s)
119
+ raise "Key #{item.key} not found in template" unless success
120
+ end
121
+ return values
122
+ end
123
+
124
+ # If this is set it will enforce that buffer data is encoded
125
+ # in a specific encoding
126
+ def enforce_encoding
127
+ return nil
128
+ end
129
+
130
+ # This affects whether the Packet class enforces the buffer
131
+ # length at all. Set to false to remove any correlation between
132
+ # buffer length and defined sizes of items in COSMOS
133
+ def enforce_length
134
+ return false
135
+ end
136
+
137
+ # This sets the short_buffer_allowed flag in the Packet class
138
+ # which allows packets that have a buffer shorter than the defined size.
139
+ # Note that the buffer is still resized to the defined length
140
+ def enforce_short_buffer_allowed
141
+ return true
142
+ end
143
+
144
+ # If this is true it will enfore that COSMOS DERIVED items must have a
145
+ # write_conversion to be written
146
+ def enforce_derived_write_conversion(_item)
147
+ return true
148
+ end
149
+ end
150
+ end
@@ -68,19 +68,29 @@ module OpenC3
68
68
  doc.to_xml
69
69
  end
70
70
 
71
+ # If this is set it will enforce that buffer data is encoded
72
+ # in a specific encoding
71
73
  def enforce_encoding
72
74
  return nil
73
75
  end
74
76
 
77
+ # This affects whether the Packet class enforces the buffer
78
+ # length at all. Set to false to remove any correlation between
79
+ # buffer length and defined sizes of items in COSMOS
75
80
  def enforce_length
76
81
  return false
77
82
  end
78
83
 
84
+ # This sets the short_buffer_allowed flag in the Packet class
85
+ # which allows packets that have a buffer shorter than the defined size.
86
+ # Note that the buffer is still resized to the defined length
79
87
  def enforce_short_buffer_allowed
80
88
  return true
81
89
  end
82
90
 
83
- def enforce_derived_write_conversion(item)
91
+ # If this is true it will enfore that COSMOS DERIVED items must have a
92
+ # write_conversion to be written
93
+ def enforce_derived_write_conversion(_item)
84
94
  return true
85
95
  end
86
96
  end
@@ -25,4 +25,5 @@ module OpenC3
25
25
  autoload(:HttpAccessor, 'openc3/accessors/http_accessor.rb')
26
26
  autoload(:JsonAccessor, 'openc3/accessors/json_accessor.rb')
27
27
  autoload(:XmlAccessor, 'openc3/accessors/xml_accessor.rb')
28
+ autoload(:TemplateAccessor, 'openc3/accessors/template_accessor.rb')
28
29
  end
@@ -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)
@@ -190,10 +190,10 @@ module OpenC3
190
190
  # 'TVAC' => [-25, -10, 50, 55] }
191
191
  #
192
192
  # @return [Hash{String => Array<Number, Number, Number, Number, Number, Number>}]
193
- def get_limits(target_name, packet_name, item_name, scope: $openc3_scope, token: $openc3_token)
193
+ def get_limits(target_name, packet_name, item_name, cache_timeout: nil, scope: $openc3_scope, token: $openc3_token)
194
194
  authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
195
195
  limits = {}
196
- item = _get_item(target_name, packet_name, item_name, scope: scope)
196
+ item = _get_item(target_name, packet_name, item_name, cache_timeout: cache_timeout, scope: scope)
197
197
  item['limits'].each do |key, vals|
198
198
  next unless vals.is_a?(Hash)
199
199
 
@@ -374,7 +374,7 @@ module OpenC3
374
374
  # @param item_name [String] item name
375
375
  # @param scope [String] scope
376
376
  # @return Hash The requested item based on the packet name
377
- def _get_item(target_name, packet_name, item_name, cache_timeout: 0.1, scope:)
377
+ def _get_item(target_name, packet_name, item_name, cache_timeout: nil, scope:)
378
378
  # Determine if this item exists, it will raise appropriate errors if not
379
379
  packet_name = CvtModel.determine_latest_packet_for_item(target_name, item_name, cache_timeout: cache_timeout, scope: $openc3_scope) if packet_name == 'LATEST'
380
380
  return TargetModel.packet_item(target_name, packet_name, item_name, scope: scope)
@@ -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',
@@ -66,26 +69,26 @@ module OpenC3
66
69
  # @param args [String|Array<String>] See the description for calling style
67
70
  # @param type [Symbol] Telemetry type, :RAW, :CONVERTED (default), :FORMATTED, or :WITH_UNITS
68
71
  # @return [Object] The telemetry value formatted as requested
69
- def tlm(*args, type: :CONVERTED, cache_timeout: 0.1, scope: $openc3_scope, token: $openc3_token)
72
+ def tlm(*args, type: :CONVERTED, cache_timeout: nil, scope: $openc3_scope, token: $openc3_token)
70
73
  target_name, packet_name, item_name = _tlm_process_args(args, 'tlm', cache_timeout: cache_timeout, scope: scope)
71
74
  authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
72
75
  CvtModel.get_item(target_name, packet_name, item_name, type: type.intern, cache_timeout: cache_timeout, scope: scope)
73
76
  end
74
77
 
75
- def tlm_raw(*args, cache_timeout: 0.1, scope: $openc3_scope, token: $openc3_token)
78
+ def tlm_raw(*args, cache_timeout: nil, scope: $openc3_scope, token: $openc3_token)
76
79
  tlm(*args, type: :RAW, cache_timeout: cache_timeout, scope: scope, token: token)
77
80
  end
78
81
 
79
- def tlm_formatted(*args, cache_timeout: 0.1, scope: $openc3_scope, token: $openc3_token)
82
+ def tlm_formatted(*args, cache_timeout: nil, scope: $openc3_scope, token: $openc3_token)
80
83
  tlm(*args, type: :FORMATTED, cache_timeout: cache_timeout, scope: scope, token: token)
81
84
  end
82
85
 
83
- def tlm_with_units(*args, cache_timeout: 0.1, scope: $openc3_scope, token: $openc3_token)
86
+ def tlm_with_units(*args, cache_timeout: nil, scope: $openc3_scope, token: $openc3_token)
84
87
  tlm(*args, type: :WITH_UNITS, cache_timeout: cache_timeout, scope: scope, token: token)
85
88
  end
86
89
 
87
90
  # @deprecated Use tlm with type:
88
- def tlm_variable(*args, cache_timeout: 0.1, scope: $openc3_scope, token: $openc3_token)
91
+ def tlm_variable(*args, cache_timeout: nil, scope: $openc3_scope, token: $openc3_token)
89
92
  tlm(*args[0..-2], type: args[-1].intern, cache_timeout: cache_timeout, scope: scope, token: token)
90
93
  end
91
94
 
@@ -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: nil, 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)
@@ -247,7 +248,7 @@ module OpenC3
247
248
  # @return [Array<Object, Symbol>]
248
249
  # Array consisting of the item value and limits state
249
250
  # given as symbols such as :RED, :YELLOW, :STALE
250
- def get_tlm_values(items, stale_time: 30, cache_timeout: 0.1, scope: $openc3_scope, token: $openc3_token)
251
+ def get_tlm_values(items, stale_time: 30, cache_timeout: nil, scope: $openc3_scope, token: $openc3_token)
251
252
  if !items.is_a?(Array) || !items[0].is_a?(String)
252
253
  raise ArgumentError, "items must be array of strings: ['TGT__PKT__ITEM__TYPE', ...]"
253
254
  end
@@ -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
@@ -427,7 +466,7 @@ module OpenC3
427
466
  return nil
428
467
  end
429
468
 
430
- def _tlm_process_args(args, method_name, cache_timeout: 0.1, scope: $openc3_scope, token: $openc3_token)
469
+ def _tlm_process_args(args, method_name, cache_timeout: nil, scope: $openc3_scope, token: $openc3_token)
431
470
  case args.length
432
471
  when 1
433
472
  target_name, packet_name, item_name = extract_fields_from_tlm_text(args[0])