openc3 5.9.1 → 5.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/lib/openc3/accessors/binary_accessor.rb +5 -2
  4. data/lib/openc3/api/limits_api.rb +3 -3
  5. data/lib/openc3/microservices/decom_microservice.rb +5 -1
  6. data/lib/openc3/microservices/trigger_group_microservice.rb +6 -2
  7. data/lib/openc3/models/interface_model.rb +2 -0
  8. data/lib/openc3/models/microservice_status_model.rb +1 -1
  9. data/lib/openc3/models/plugin_model.rb +2 -0
  10. data/lib/openc3/models/target_model.rb +2 -0
  11. data/lib/openc3/models/tool_model.rb +2 -0
  12. data/lib/openc3/models/widget_model.rb +2 -0
  13. data/lib/openc3/packets/packet.rb +7 -13
  14. data/lib/openc3/packets/structure.rb +2 -2
  15. data/lib/openc3/packets/structure_item.rb +7 -27
  16. data/lib/openc3/script/api_shared.rb +45 -48
  17. data/lib/openc3/script/web_socket_api.rb +2 -2
  18. data/lib/openc3/system/target.rb +3 -3
  19. data/lib/openc3/top_level.rb +1 -1
  20. data/lib/openc3/topics/command_decom_topic.rb +0 -4
  21. data/lib/openc3/topics/telemetry_decom_topic.rb +0 -4
  22. data/lib/openc3/topics/telemetry_reduced_topics.rb +1 -13
  23. data/lib/openc3/topics/topic.rb +0 -8
  24. data/lib/openc3/utilities/authentication.rb +0 -1
  25. data/lib/openc3/utilities/aws_bucket.rb +44 -38
  26. data/lib/openc3/utilities/store_autoload.rb +5 -5
  27. data/lib/openc3/version.rb +5 -5
  28. data/templates/tool_angular/package.json +17 -17
  29. data/templates/tool_angular/yarn.lock +1798 -998
  30. data/templates/tool_react/package.json +20 -20
  31. data/templates/tool_react/yarn.lock +754 -700
  32. data/templates/tool_svelte/package.json +21 -21
  33. data/templates/tool_svelte/yarn.lock +622 -478
  34. data/templates/tool_vue/package.json +7 -7
  35. data/templates/tool_vue/yarn.lock +152 -118
  36. data/templates/widget/package.json +8 -8
  37. data/templates/widget/yarn.lock +157 -66
  38. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c24a28732bfd8c275b65639cd566b4823d78b70b43781bf14a82e114397e7677
4
- data.tar.gz: a8567e57ec8008d505e7f6a30cd3462e435988a46729908fbc17775f2b92e976
3
+ metadata.gz: e462e9d0a5d73e46212ec61b784b432827b0588b64308449309196e1257ad5b0
4
+ data.tar.gz: 4811700be9aeab28edc867d11e26481d7cbf63abe8bb3ca9ef956823d8adb17d
5
5
  SHA512:
6
- metadata.gz: dc287a9895e3ae60c6332389d0b7926bb84aa04d7d65e51c936ba65f66640b179b0baefdcec232d7775a70f2e95d88557faf5e960663c4c28840428e7cb52904
7
- data.tar.gz: 578c1f1fe45512344390492e9aa15d7af851bb81e608fbc874189dcc73bc998c472e62d449c114fb300fc58bb0d9cc269cc3dfbcbb31aaaf76c9003abd63c8e7
6
+ metadata.gz: 0e01b50dc62e075afe78f66101e176ec20118f017122a8f76a1eb3d1b302250e55717897c2302c6bf812cece5bedf0d9e6a0b1fdc2dc43f68998a693d7b04b4d
7
+ data.tar.gz: 5a93a1b914e84e5555cc88e4c74da80a8283ae621c958c6d9535848c1ff384dd7aa3a6ba59dff7e148b91eb3370ef563ec0a8c94f1ecafc517bd65665f8f8e2a
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'
17
+ gem 'mock_redis', '0.36'
@@ -17,7 +17,7 @@
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
19
  #
20
- # This file may also be used under the terms of a commercial license
20
+ # This file may also be used under the terms of a commercial license
21
21
  # if purchased from OpenC3, Inc.
22
22
 
23
23
  # This file contains the implementation of the BinaryAccessor class.
@@ -280,7 +280,10 @@ module OpenC3
280
280
 
281
281
  if upper_bound > lower_bound
282
282
  # Combine bytes into a FixNum
283
- temp_data[1..temp_upper].each_byte { |temp_value| temp = temp << 8; temp = temp + temp_value }
283
+ temp_data[1..temp_upper].each_byte do |temp_value|
284
+ temp = temp << 8
285
+ temp = temp + temp_value
286
+ end
284
287
  end
285
288
 
286
289
  # Shift off unwanted bits at end
@@ -172,7 +172,7 @@ module OpenC3
172
172
 
173
173
  TargetModel.set_packet(target_name, packet_name, packet, scope: scope)
174
174
 
175
- message = "Disabling Limits For '#{target_name} #{packet_name} #{item_name}'"
175
+ message = "Disabling Limits for '#{target_name} #{packet_name} #{item_name}'"
176
176
  Logger.info(message, scope: scope)
177
177
 
178
178
  event = { type: :LIMITS_ENABLE_STATE, target_name: target_name, packet_name: packet_name,
@@ -344,11 +344,11 @@ module OpenC3
344
344
  if action == :enable
345
345
  enabled = true
346
346
  item['limits']['enabled'] = true
347
- message = "Enabling Limits For '#{target_name} #{packet_name} #{item_name}'"
347
+ message = "Enabling Limits for '#{target_name} #{packet_name} #{item_name}'"
348
348
  elsif action == :disable
349
349
  enabled = false
350
350
  item['limits'].delete('enabled')
351
- message = "Disabling Limits For '#{target_name} #{packet_name} #{item_name}'"
351
+ message = "Disabling Limits for '#{target_name} #{packet_name} #{item_name}'"
352
352
  end
353
353
  Logger.info(message, scope: scope)
354
354
 
@@ -115,7 +115,11 @@ module OpenC3
115
115
  def limits_change_callback(packet, item, old_limits_state, value, log_change)
116
116
  return if @cancel_thread
117
117
  packet_time = packet.packet_time
118
- message = "#{packet.target_name} #{packet.packet_name} #{item.name} = #{value} is #{item.limits.state}"
118
+ if value
119
+ message = "#{packet.target_name} #{packet.packet_name} #{item.name} = #{value} is #{item.limits.state}"
120
+ else
121
+ message = "#{packet.target_name} #{packet.packet_name} #{item.name} is disabled"
122
+ end
119
123
  message << " (#{packet.packet_time.sys.formatted})" if packet_time
120
124
 
121
125
  time_nsec = packet_time ? packet_time.to_nsec_from_epoch : Time.now.to_nsec_from_epoch
@@ -355,9 +355,13 @@ module OpenC3
355
355
  end
356
356
  # This shouldn't happen because the frontend provides valid items but good to check
357
357
  # The raise is ultimately rescued inside evaluate_trigger when operand_value is called
358
- raise "Packet #{operand[ITEM_TARGET]} #{operand[ITEM_PACKET]} not found" if packet.nil?
358
+ if packet.nil?
359
+ raise "Packet #{operand[ITEM_TARGET]} #{operand[ITEM_PACKET]} not found"
360
+ end
359
361
  value = packet.read(operand[ITEM_TYPE], operand[ITEM_VALUE_TYPE].intern)
360
- raise "Item #{operand[ITEM_TARGET]} #{operand[ITEM_PACKET]} #{operand[ITEM_TYPE]} not found" if value.nil?
362
+ if value.nil?
363
+ raise "Item #{operand[ITEM_TARGET]} #{operand[ITEM_PACKET]} #{operand[ITEM_TYPE]} not found"
364
+ end
361
365
  value
362
366
  end
363
367
 
@@ -389,6 +389,8 @@ module OpenC3
389
389
  status_model = RouterStatusModel.get_model(name: @name, scope: @scope)
390
390
  end
391
391
  status_model.destroy if status_model
392
+ rescue Exception => error
393
+ Logger.error("Error undeploying interface/router model #{@name} in scope #{@scope} due to #{error}")
392
394
  end
393
395
 
394
396
  def unmap_target(target_name, cmd_only: false, tlm_only: false)
@@ -17,7 +17,7 @@
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
19
  #
20
- # This file may also be used under the terms of a commercial license
20
+ # This file may also be used under the terms of a commercial license
21
21
  # if purchased from OpenC3, Inc.
22
22
 
23
23
  require 'openc3/models/model'
@@ -297,6 +297,8 @@ module OpenC3
297
297
  microservices.each do |name, model_instance|
298
298
  model_instance.cleanup
299
299
  end
300
+ rescue Exception => error
301
+ Logger.error("Error undeploying plugin model #{@name} in scope #{@scope} due to #{error}")
300
302
  end
301
303
 
302
304
  # Reinstall
@@ -639,6 +639,8 @@ module OpenC3
639
639
  @@item_map_cache[@name] = nil
640
640
 
641
641
  ConfigTopic.write({ kind: 'deleted', type: 'target', name: @name, plugin: @plugin }, scope: @scope)
642
+ rescue Exception => error
643
+ Logger.error("Error undeploying target model #{@name} in scope #{@scope} due to #{error}")
642
644
  end
643
645
 
644
646
  ##################################################
@@ -247,6 +247,8 @@ module OpenC3
247
247
  ConfigTopic.write({ kind: 'deleted', type: 'tool', name: @folder_name, plugin: @plugin }, scope: @scope)
248
248
  end
249
249
  end
250
+ rescue Exception => error
251
+ Logger.error("Error undeploying tool model #{@name} in scope #{@scope} due to #{error}")
250
252
  end
251
253
 
252
254
  ##################################################
@@ -139,6 +139,8 @@ module OpenC3
139
139
  bucket = Bucket.getClient()
140
140
  bucket.delete_object(bucket: ENV['OPENC3_TOOLS_BUCKET'], key: @bucket_key)
141
141
  bucket.delete_object(bucket: ENV['OPENC3_TOOLS_BUCKET'], key: @bucket_key + '.map')
142
+ rescue Exception => error
143
+ Logger.error("Error undeploying widget model #{@name} in scope #{@scope} due to #{error}")
142
144
  end
143
145
  end
144
146
  end
@@ -540,7 +540,7 @@ module OpenC3
540
540
 
541
541
  # (see Structure#get_item)
542
542
  def get_item(name)
543
- super(name)
543
+ return super(name)
544
544
  rescue ArgumentError
545
545
  raise "Packet item '#{@target_name} #{@packet_name} #{name.upcase}' does not exist"
546
546
  end
@@ -1056,10 +1056,10 @@ module OpenC3
1056
1056
 
1057
1057
  if @processors
1058
1058
  processors = []
1059
- config['processors'] = processors
1060
1059
  @processors.each do |processor_name, processor|
1061
1060
  processors << processor.as_json(*a)
1062
1061
  end
1062
+ config['processors'] = processors
1063
1063
  end
1064
1064
 
1065
1065
  config['meta'] = @meta if @meta
@@ -1144,17 +1144,11 @@ module OpenC3
1144
1144
  # Update to new limits state
1145
1145
  item.limits.state = limits_state
1146
1146
 
1147
- if old_limits_state == nil # Changing from nil
1148
- if limits_state != :GREEN && limits_state != :BLUE # Warnings are needed
1149
- @limits_change_callback.call(self, item, old_limits_state, value, true) if @limits_change_callback
1150
- end
1151
- else # Changing from a state other than nil so always call the callback
1152
- if @limits_change_callback
1153
- if item.limits.state.nil?
1154
- @limits_change_callback.call(self, item, old_limits_state, value, false)
1155
- else
1156
- @limits_change_callback.call(self, item, old_limits_state, value, true)
1157
- end
1147
+ if @limits_change_callback
1148
+ if item.limits.state.nil?
1149
+ @limits_change_callback.call(self, item, old_limits_state, value, false)
1150
+ else
1151
+ @limits_change_callback.call(self, item, old_limits_state, value, true)
1158
1152
  end
1159
1153
  end
1160
1154
  end
@@ -17,7 +17,7 @@
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
19
  #
20
- # This file may also be used under the terms of a commercial license
20
+ # This file may also be used under the terms of a commercial license
21
21
  # if purchased from OpenC3, Inc.
22
22
 
23
23
  require 'openc3/packets/binary_accessor'
@@ -518,7 +518,7 @@ module OpenC3
518
518
  # Take the structure mutex to ensure the buffer does not change while you perform activities
519
519
  def synchronize
520
520
  setup_mutex()
521
- @mutex.synchronize { || yield }
521
+ @mutex.synchronize { || yield } #|
522
522
  end
523
523
 
524
524
  # Take the structure mutex to ensure the buffer does not change while you perform activities
@@ -17,7 +17,7 @@
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
19
  #
20
- # This file may also be used under the terms of a commercial license
20
+ # This file may also be used under the terms of a commercial license
21
21
  # if purchased from OpenC3, Inc.
22
22
 
23
23
  require 'openc3/ext/packet' if RUBY_ENGINE == 'ruby' and !ENV['OPENC3_NO_EXT']
@@ -76,9 +76,6 @@ module OpenC3
76
76
  # @return [Boolean] Whether this structure item can overlap another item in the same packet
77
77
  attr_accessor :overlap
78
78
 
79
- # A large buffer size in bits (1 Megabyte)
80
- LARGE_BUFFER_SIZE_BITS = 1024 * 1024 * 8
81
-
82
79
  # Create a StructureItem by setting all the attributes. It
83
80
  # calls all the setter routines to do the attribute verification and then
84
81
  # verifies the overall integrity.
@@ -135,14 +132,7 @@ module OpenC3
135
132
  end
136
133
 
137
134
  def bit_offset=(bit_offset)
138
- if 0.class == Integer
139
- # Ruby version >= 2.4.0
140
- raise ArgumentError, "#{@name}: bit_offset must be an Integer" unless Integer === bit_offset
141
- else
142
- # Ruby version < 2.4.0
143
- raise ArgumentError, "#{@name}: bit_offset must be a Fixnum" unless Fixnum === bit_offset
144
- end
145
-
135
+ raise ArgumentError, "#{@name}: bit_offset must be an Integer" unless Integer === bit_offset
146
136
  byte_aligned = ((bit_offset % 8) == 0)
147
137
  if (@data_type == :FLOAT or @data_type == :STRING or @data_type == :BLOCK) and !byte_aligned
148
138
  raise ArgumentError, "#{@name}: bit_offset for :FLOAT, :STRING, and :BLOCK items must be byte aligned"
@@ -156,18 +146,14 @@ module OpenC3
156
146
  end
157
147
 
158
148
  def bit_size=(bit_size)
159
- if 0.class == Integer
160
- # Ruby version >= 2.4.0
161
- raise ArgumentError, "#{name}: bit_size must be an Integer" unless Integer === bit_size
162
- else
163
- # Ruby version < 2.4.0
164
- raise ArgumentError, "#{name}: bit_size must be a Fixnum" unless Fixnum === bit_size
165
- end
149
+ raise ArgumentError, "#{@name}: bit_size must be an Integer" unless Integer === bit_size
166
150
  byte_multiple = ((bit_size % 8) == 0)
167
151
  if bit_size <= 0 and (@data_type == :INT or @data_type == :UINT or @data_type == :FLOAT)
168
152
  raise ArgumentError, "#{@name}: bit_size cannot be negative or zero for :INT, :UINT, and :FLOAT items: #{bit_size}"
169
153
  end
170
- raise ArgumentError, "#{@name}: bit_size for STRING and BLOCK items must be byte multiples" if (@data_type == :STRING or @data_type == :BLOCK) and !byte_multiple
154
+ if (@data_type == :STRING or @data_type == :BLOCK) and !byte_multiple
155
+ raise ArgumentError, "#{@name}: bit_size for STRING and BLOCK items must be byte multiples"
156
+ end
171
157
  if @data_type == :FLOAT and bit_size != 32 and bit_size != 64
172
158
  raise ArgumentError, "#{@name}: bit_size for FLOAT items must be 32 or 64. Given: #{bit_size}"
173
159
  end
@@ -195,13 +181,7 @@ module OpenC3
195
181
 
196
182
  def array_size=(array_size)
197
183
  if array_size
198
- if 0.class == Integer
199
- # Ruby version >= 2.4.0
200
- raise ArgumentError, "#{@name}: array_size must be an Integer" unless Integer === array_size
201
- else
202
- # Ruby version < 2.4.0
203
- raise ArgumentError, "#{@name}: array_size must be a Fixnum" unless Fixnum === array_size
204
- end
184
+ raise ArgumentError, "#{@name}: array_size must be an Integer" unless Integer === array_size
205
185
  raise ArgumentError, "#{@name}: array_size must be a multiple of bit_size" unless @bit_size == 0 or (array_size % @bit_size == 0) or array_size < 0
206
186
  raise ArgumentError, "#{@name}: bit_size cannot be negative or zero for array items" if @bit_size <= 0
207
187
  end
@@ -44,17 +44,14 @@ module OpenC3
44
44
  _check(*args, scope: scope) { |tgt, pkt, item| tlm(tgt, pkt, item, type: type, scope: scope, token: token) }
45
45
  end
46
46
 
47
- # @deprecated Use check with type: :RAW
48
47
  def check_raw(*args, scope: $openc3_scope, token: $openc3_token)
49
48
  check(*args, type: :RAW, scope: scope, token: token)
50
49
  end
51
50
 
52
- # @deprecated Use check with type: :FORMATTED
53
51
  def check_formatted(*args, scope: $openc3_scope, token: $openc3_token)
54
52
  check(*args, type: :FORMATTED, scope: scope, token: token)
55
53
  end
56
54
 
57
- # @deprecated Use check with type: :WITH_UNITS
58
55
  def check_with_units(*args, scope: $openc3_scope, token: $openc3_token)
59
56
  check(*args, type: :WITH_UNITS, scope: scope, token: token)
60
57
  end
@@ -90,10 +87,10 @@ module OpenC3
90
87
  raise "Invalid type '#{type}' for check_tolerance" unless %i(RAW CONVERTED).include?(type)
91
88
 
92
89
  target_name, packet_name, item_name, expected_value, tolerance =
93
- _check_tolerance_process_args(args, scope: scope, token: token)
90
+ _check_tolerance_process_args(args)
94
91
  value = tlm(target_name, packet_name, item_name, type: type, scope: scope, token: token)
95
92
  if value.is_a?(Array)
96
- expected_value, tolerance = array_tolerance_process_args(value.size, expected_value, tolerance, 'check_tolerance', scope: scope, token: token)
93
+ expected_value, tolerance = _array_tolerance_process_args(value.size, expected_value, tolerance, 'check_tolerance')
97
94
 
98
95
  message = ""
99
96
  all_checks_ok = true
@@ -166,23 +163,23 @@ module OpenC3
166
163
  # @param args [String|Array<String>] See the description for calling style
167
164
  # @param type [Symbol] Telemetry type, :RAW, :CONVERTED (default), :FORMATTED, or :WITH_UNITS
168
165
  def wait(*args, type: :CONVERTED, quiet: false, scope: $openc3_scope, token: $openc3_token)
169
- time = nil
166
+ time_diff = nil
170
167
 
171
168
  case args.length
172
169
  # wait() # indefinitely until they click Go
173
170
  when 0
174
171
  start_time = Time.now.sys
175
172
  openc3_script_sleep()
176
- time = Time.now.sys - start_time
177
- Logger.info("WAIT: Indefinite for actual time of #{time} seconds") unless quiet
173
+ time_diff = Time.now.sys - start_time
174
+ Logger.info("WAIT: Indefinite for actual time of #{time_diff} seconds") unless quiet
178
175
 
179
176
  # wait(5) # absolute wait time
180
177
  when 1
181
178
  if args[0].kind_of? Numeric
182
179
  start_time = Time.now.sys
183
180
  openc3_script_sleep(args[0])
184
- time = Time.now.sys - start_time
185
- Logger.info("WAIT: #{args[0]} seconds with actual time of #{time} seconds") unless quiet
181
+ time_diff = Time.now.sys - start_time
182
+ Logger.info("WAIT: #{args[0]} seconds with actual time of #{time_diff} seconds") unless quiet
186
183
  else
187
184
  raise "Non-numeric wait time specified"
188
185
  end
@@ -216,7 +213,7 @@ module OpenC3
216
213
  # Invalid number of arguments
217
214
  raise "ERROR: Invalid number of arguments (#{args.length}) passed to wait()"
218
215
  end
219
- time
216
+ time_diff
220
217
  end
221
218
 
222
219
  # @deprecated Use wait with type: :RAW
@@ -235,11 +232,11 @@ module OpenC3
235
232
  def wait_tolerance(*args, type: :CONVERTED, quiet: false, scope: $openc3_scope, token: $openc3_token)
236
233
  raise "Invalid type '#{type}' for wait_tolerance" unless %i(RAW CONVERTED).include?(type)
237
234
 
238
- target_name, packet_name, item_name, expected_value, tolerance, timeout, polling_rate = _wait_tolerance_process_args(args, scope: scope, token: token)
235
+ target_name, packet_name, item_name, expected_value, tolerance, timeout, polling_rate = _wait_tolerance_process_args(args)
239
236
  start_time = Time.now.sys
240
237
  value = tlm(target_name, packet_name, item_name, type: type, scope: scope, token: token)
241
238
  if value.is_a?(Array)
242
- expected_value, tolerance = array_tolerance_process_args(value.size, expected_value, tolerance, 'wait_tolerance', scope: scope, token: token)
239
+ expected_value, tolerance = _array_tolerance_process_args(value.size, expected_value, tolerance, 'wait_tolerance')
243
240
 
244
241
  success, value = openc3_script_wait_implementation_array_tolerance(value.size, target_name, packet_name, item_name, type, expected_value, tolerance, timeout, polling_rate, scope: scope, token: token)
245
242
  time = Time.now.sys - start_time
@@ -285,13 +282,13 @@ module OpenC3
285
282
  def wait_expression(exp_to_eval, timeout, polling_rate = DEFAULT_TLM_POLLING_RATE, context = nil, quiet: false, scope: $openc3_scope, token: $openc3_token)
286
283
  start_time = Time.now.sys
287
284
  success = openc3_script_wait_implementation_expression(exp_to_eval, timeout, polling_rate, context, scope: scope, token: token)
288
- time = Time.now.sys - start_time
285
+ time_diff = Time.now.sys - start_time
289
286
  if success
290
- Logger.info "WAIT: #{exp_to_eval} is TRUE after waiting #{time} seconds" unless quiet
287
+ Logger.info "WAIT: #{exp_to_eval} is TRUE after waiting #{time_diff} seconds" unless quiet
291
288
  else
292
- Logger.warn "WAIT: #{exp_to_eval} is FALSE after waiting #{time} seconds" unless quiet
289
+ Logger.warn "WAIT: #{exp_to_eval} is FALSE after waiting #{time_diff} seconds" unless quiet
293
290
  end
294
- time
291
+ time_diff
295
292
  end
296
293
 
297
294
  # Wait for the converted value of a telmetry item against a condition or for a timeout
@@ -304,13 +301,13 @@ module OpenC3
304
301
  # @param args [String|Array<String>] See the description for calling style
305
302
  # @param type [Symbol] Telemetry type, :RAW, :CONVERTED (default), :FORMATTED, or :WITH_UNITS
306
303
  def wait_check(*args, type: :CONVERTED, scope: $openc3_scope, token: $openc3_token, &block)
307
- target_name, packet_name, item_name, comparison_to_eval, timeout, polling_rate = _wait_check_process_args(args, scope: scope, token: token)
304
+ target_name, packet_name, item_name, comparison_to_eval, timeout, polling_rate = _wait_check_process_args(args)
308
305
  start_time = Time.now.sys
309
306
  success, value = openc3_script_wait_implementation(target_name, packet_name, item_name, type, comparison_to_eval, timeout, polling_rate, scope: scope, token: token, &block)
310
307
  value = "'#{value}'" if value.is_a? String # Show user the check against a quoted string
311
- time = Time.now.sys - start_time
308
+ time_diff = Time.now.sys - start_time
312
309
  check_str = "CHECK: #{_upcase(target_name, packet_name, item_name)} #{comparison_to_eval}"
313
- with_value_str = "with value == #{value} after waiting #{time} seconds"
310
+ with_value_str = "with value == #{value} after waiting #{time_diff} seconds"
314
311
  if success
315
312
  Logger.info "#{check_str} success #{with_value_str}"
316
313
  else
@@ -321,7 +318,7 @@ module OpenC3
321
318
  raise CheckError, message
322
319
  end
323
320
  end
324
- time
321
+ time_diff
325
322
  end
326
323
 
327
324
  # @deprecated use wait_check with type: :RAW
@@ -341,20 +338,20 @@ module OpenC3
341
338
  def wait_check_tolerance(*args, type: :CONVERTED, scope: $openc3_scope, token: $openc3_token, &block)
342
339
  raise "Invalid type '#{type}' for wait_check_tolerance" unless %i(RAW CONVERTED).include?(type)
343
340
 
344
- target_name, packet_name, item_name, expected_value, tolerance, timeout, polling_rate = _wait_tolerance_process_args(args, scope: scope, token: token)
341
+ target_name, packet_name, item_name, expected_value, tolerance, timeout, polling_rate = _wait_tolerance_process_args(args)
345
342
  start_time = Time.now.sys
346
343
  value = tlm(target_name, packet_name, item_name, type: type, scope: scope, token: token)
347
344
  if value.is_a?(Array)
348
- expected_value, tolerance = array_tolerance_process_args(value.size, expected_value, tolerance, 'wait_check_tolerance', scope: scope, token: token)
345
+ expected_value, tolerance = _array_tolerance_process_args(value.size, expected_value, tolerance, 'wait_check_tolerance')
349
346
 
350
347
  success, value = openc3_script_wait_implementation_array_tolerance(value.size, target_name, packet_name, item_name, type, expected_value, tolerance, timeout, polling_rate, scope: scope, token: token, &block)
351
- time = Time.now.sys - start_time
348
+ time_diff = Time.now.sys - start_time
352
349
 
353
350
  message = ""
354
351
  value.size.times do |i|
355
352
  range = (expected_value[i] - tolerance[i]..expected_value[i] + tolerance[i])
356
353
  check_str = "CHECK: #{_upcase(target_name, packet_name, item_name)}[#{i}]"
357
- range_str = "range #{range.first} to #{range.last} with value == #{value[i]} after waiting #{time} seconds"
354
+ range_str = "range #{range.first} to #{range.last} with value == #{value[i]} after waiting #{time_diff} seconds"
358
355
  if range.include?(value[i])
359
356
  message << "#{check_str} was within #{range_str}\n"
360
357
  else
@@ -373,10 +370,10 @@ module OpenC3
373
370
  end
374
371
  else
375
372
  success, value = openc3_script_wait_implementation_tolerance(target_name, packet_name, item_name, type, expected_value, tolerance, timeout, polling_rate, scope: scope, token: token)
376
- time = Time.now.sys - start_time
373
+ time_diff = Time.now.sys - start_time
377
374
  range = (expected_value - tolerance)..(expected_value + tolerance)
378
375
  check_str = "CHECK: #{_upcase(target_name, packet_name, item_name)}"
379
- range_str = "range #{range.first} to #{range.last} with value == #{value} after waiting #{time} seconds"
376
+ range_str = "range #{range.first} to #{range.last} with value == #{value} after waiting #{time_diff} seconds"
380
377
  if success
381
378
  Logger.info "#{check_str} was within #{range_str}"
382
379
  else
@@ -388,7 +385,7 @@ module OpenC3
388
385
  end
389
386
  end
390
387
  end
391
- time
388
+ time_diff
392
389
  end
393
390
 
394
391
  # @deprecated Use wait_check_tolerance with type: :RAW
@@ -407,18 +404,18 @@ module OpenC3
407
404
  timeout,
408
405
  polling_rate,
409
406
  context, scope: scope, token: token, &block)
410
- time = Time.now.sys - start_time
407
+ time_diff = Time.now.sys - start_time
411
408
  if success
412
- Logger.info "CHECK: #{exp_to_eval} is TRUE after waiting #{time} seconds"
409
+ Logger.info "CHECK: #{exp_to_eval} is TRUE after waiting #{time_diff} seconds"
413
410
  else
414
- message = "CHECK: #{exp_to_eval} is FALSE after waiting #{time} seconds"
411
+ message = "CHECK: #{exp_to_eval} is FALSE after waiting #{time_diff} seconds"
415
412
  if $disconnect
416
413
  Logger.error message
417
414
  else
418
415
  raise CheckError, message
419
416
  end
420
417
  end
421
- time
418
+ time_diff
422
419
  end
423
420
  alias wait_expression_stop_on_timeout wait_check_expression
424
421
 
@@ -483,7 +480,7 @@ module OpenC3
483
480
  ###########################################################################
484
481
  # Scripts Outside of ScriptRunner Support
485
482
  # ScriptRunner overrides these methods to work in the OpenC3 cluster
486
- # They are only here to allow for scripts to have a change to work
483
+ # They are only here to allow for scripts to have a chance to work
487
484
  # unaltered outside of the cluster
488
485
  ###########################################################################
489
486
 
@@ -534,17 +531,17 @@ module OpenC3
534
531
  # caller to allow the return of the value through various telemetry calls.
535
532
  # This method should not be called directly by application code.
536
533
  def _check(*args, scope: $openc3_scope, token: $openc3_token)
537
- target_name, packet_name, item_name, comparison_to_eval = _check_process_args(args, 'check', scope: scope, token: token)
534
+ target_name, packet_name, item_name, comparison_to_eval = _check_process_args(args, 'check')
538
535
 
539
536
  value = yield(target_name, packet_name, item_name)
540
537
  if comparison_to_eval
541
- check_eval(target_name, packet_name, item_name, comparison_to_eval, value, scope: scope)
538
+ _check_eval(target_name, packet_name, item_name, comparison_to_eval, value)
542
539
  else
543
540
  Logger.info "CHECK: #{_upcase(target_name, packet_name, item_name)} == #{value}"
544
541
  end
545
542
  end
546
543
 
547
- def _check_process_args(args, method_name, scope: $openc3_scope, token: $openc3_token)
544
+ def _check_process_args(args, method_name)
548
545
  case args.length
549
546
  when 1
550
547
  target_name, packet_name, item_name, comparison_to_eval = extract_fields_from_check_text(args[0])
@@ -557,10 +554,11 @@ module OpenC3
557
554
  # Invalid number of arguments
558
555
  raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{method_name}()"
559
556
  end
557
+ raise "Invalid comparison to non-ascii value" unless comparison_to_eval.is_printable?
560
558
  return [target_name, packet_name, item_name, comparison_to_eval]
561
559
  end
562
560
 
563
- def _check_tolerance_process_args(args, scope: $openc3_scope, token: $openc3_token)
561
+ def _check_tolerance_process_args(args)
564
562
  case args.length
565
563
  when 3
566
564
  target_name, packet_name, item_name = extract_fields_from_tlm_text(args[0])
@@ -612,11 +610,11 @@ module OpenC3
612
610
  token: token)
613
611
  # If the packet has not been received the value could be nil
614
612
  value = 0 unless value
615
- time = Time.now.sys - start_time
613
+ time_diff = Time.now.sys - start_time
616
614
  if success
617
- Logger.info "#{type}: #{target_name.upcase} #{packet_name.upcase} received #{value - initial_count} times after waiting #{time} seconds" unless quiet
615
+ Logger.info "#{type}: #{target_name.upcase} #{packet_name.upcase} received #{value - initial_count} times after waiting #{time_diff} seconds" unless quiet
618
616
  else
619
- message = "#{type}: #{target_name.upcase} #{packet_name.upcase} expected to be received #{num_packets} times but only received #{value - initial_count} times after waiting #{time} seconds"
617
+ message = "#{type}: #{target_name.upcase} #{packet_name.upcase} expected to be received #{num_packets} times but only received #{value - initial_count} times after waiting #{time_diff} seconds"
620
618
  if check
621
619
  if $disconnect
622
620
  Logger.error message
@@ -627,16 +625,16 @@ module OpenC3
627
625
  Logger.warn message unless quiet
628
626
  end
629
627
  end
630
- time
628
+ time_diff
631
629
  end
632
630
 
633
631
  def _execute_wait(target_name, packet_name, item_name, value_type, comparison_to_eval, timeout, polling_rate, quiet: false, scope: $openc3_scope, token: $openc3_token)
634
632
  start_time = Time.now.sys
635
633
  success, value = openc3_script_wait_implementation(target_name, packet_name, item_name, value_type, comparison_to_eval, timeout, polling_rate, scope: scope, token: token)
636
634
  value = "'#{value}'" if value.is_a? String # Show user the check against a quoted string
637
- time = Time.now.sys - start_time
635
+ time_diff = Time.now.sys - start_time
638
636
  wait_str = "WAIT: #{_upcase(target_name, packet_name, item_name)} #{comparison_to_eval}"
639
- value_str = "with value == #{value} after waiting #{time} seconds"
637
+ value_str = "with value == #{value} after waiting #{time_diff} seconds"
640
638
  if success
641
639
  Logger.info "#{wait_str} success #{value_str}" unless quiet
642
640
  else
@@ -644,7 +642,7 @@ module OpenC3
644
642
  end
645
643
  end
646
644
 
647
- def _wait_tolerance_process_args(args, scope: $openc3_scope, token: $openc3_token)
645
+ def _wait_tolerance_process_args(args)
648
646
  case args.length
649
647
  when 4, 5
650
648
  target_name, packet_name, item_name = extract_fields_from_tlm_text(args[0])
@@ -686,7 +684,7 @@ module OpenC3
686
684
  # When testing an array with a tolerance, the expected value and tolerance
687
685
  # can both be supplied as either an array or a single value. If a single
688
686
  # value is passed in, that value will be used for all array elements.
689
- def array_tolerance_process_args(array_size, expected_value, tolerance, method_name, scope: $openc3_scope, token: $openc3_token)
687
+ def _array_tolerance_process_args(array_size, expected_value, tolerance, method_name)
690
688
  if expected_value.is_a?(Array)
691
689
  if array_size != expected_value.size
692
690
  raise "ERROR: Invalid array size for expected_value passed to #{method_name}()"
@@ -704,7 +702,7 @@ module OpenC3
704
702
  return [expected_value, tolerance]
705
703
  end
706
704
 
707
- def _wait_check_process_args(args, scope: $openc3_scope, token: $openc3_token)
705
+ def _wait_check_process_args(args)
708
706
  case args.length
709
707
  when 2, 3
710
708
  target_name, packet_name, item_name, comparison_to_eval = extract_fields_from_check_text(args[0])
@@ -849,8 +847,7 @@ module OpenC3
849
847
  end
850
848
  end
851
849
 
852
- def check_eval(target_name, packet_name, item_name, comparison_to_eval, value, scope: $openc3_scope, token: $openc3_token)
853
- raise "Invalid comparison to non-ascii value" unless comparison_to_eval.is_printable?
850
+ def _check_eval(target_name, packet_name, item_name, comparison_to_eval, value)
854
851
  string = "value " + comparison_to_eval
855
852
  check_str = "CHECK: #{_upcase(target_name, packet_name, item_name)} #{comparison_to_eval}"
856
853
  # Show user the check against a quoted string
@@ -405,9 +405,9 @@ end
405
405
  # # Environment variables are already set inside of our containers
406
406
  # # START OUTSIDE OF DOCKER ONLY
407
407
  # $openc3_scope = 'DEFAULT'
408
- # ENV['OPENC3_API_HOSTNAME'] = 'localhost'
408
+ # ENV['OPENC3_API_HOSTNAME'] = '127.0.0.1'
409
409
  # ENV['OPENC3_API_PORT'] = '2900'
410
- # ENV['OPENC3_SCRIPT_API_HOSTNAME'] = 'localhost'
410
+ # ENV['OPENC3_SCRIPT_API_HOSTNAME'] = '127.0.0.1'
411
411
  # ENV['OPENC3_SCRIPT_API_PORT'] = '2900'
412
412
  # ENV['OPENC3_API_PASSWORD'] = 'password'
413
413
  # # END OUTSIDE OF DOCKER ONLY
@@ -17,7 +17,7 @@
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
19
  #
20
- # This file may also be used under the terms of a commercial license
20
+ # This file may also be used under the terms of a commercial license
21
21
  # if purchased from OpenC3, Inc.
22
22
 
23
23
  require 'openc3/config/config_parser'
@@ -226,8 +226,8 @@ module OpenC3
226
226
  # Process the target's configuration file if it exists
227
227
  def process_target_config_file
228
228
  @filename = File.join(@dir, 'target.txt')
229
- if File.exist?(filename)
230
- process_file(filename)
229
+ if File.exist?(@filename)
230
+ process_file(@filename)
231
231
  else
232
232
  @filename = nil
233
233
  end
@@ -43,7 +43,7 @@ class HazardousError < StandardError
43
43
  attr_accessor :formatted # formatted command for use in resending original
44
44
 
45
45
  def to_s
46
- string = "#{target_name} #{cmd_name} with #{cmd_params} is Hazardous"
46
+ string = "#{target_name} #{cmd_name} with #{cmd_params} is Hazardous "
47
47
  string << "due to '#{hazardous_description}'" if hazardous_description
48
48
  # Pass along the original formatted command so it can be resent
49
49
  string << ".\n#{formatted}"