openc3 5.6.1 → 5.7.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.

@@ -72,8 +72,9 @@ module OpenC3
72
72
  def self.handle_config(parser, keyword, parameters, plugin: nil, needs_dependencies: false, scope:)
73
73
  case keyword
74
74
  when 'WIDGET'
75
- parser.verify_num_parameters(1, 1, "WIDGET <Name>")
76
- return self.new(name: parameters[0], plugin: plugin, needs_dependencies: needs_dependencies, scope: scope)
75
+ parser.verify_num_parameters(1, 2, "WIDGET <Name> <Label>")
76
+ # Label is optional and if it doesn't exist nil is fine
77
+ return self.new(name: parameters[0], plugin: plugin, label: parameters[1], needs_dependencies: needs_dependencies, scope: scope)
77
78
  else
78
79
  raise ConfigParser::Error.new(parser, "Unknown keyword and parameters for Widget: #{keyword} #{parameters.join(" ")}")
79
80
  end
@@ -84,6 +85,7 @@ module OpenC3
84
85
  name:,
85
86
  updated_at: nil,
86
87
  plugin: nil,
88
+ label: nil,
87
89
  needs_dependencies: false,
88
90
  scope:
89
91
  )
@@ -91,6 +93,7 @@ module OpenC3
91
93
  @full_name = @name.capitalize + 'Widget'
92
94
  @filename = @full_name + '.umd.min.js'
93
95
  @bucket_key = 'widgets/' + @full_name + '/' + @filename
96
+ @label = label
94
97
  @needs_dependencies = needs_dependencies
95
98
  end
96
99
 
@@ -99,6 +102,7 @@ module OpenC3
99
102
  'name' => @name,
100
103
  'updated_at' => @updated_at,
101
104
  'plugin' => @plugin,
105
+ 'label' => @label,
102
106
  'needs_dependencies' => @needs_dependencies,
103
107
  }
104
108
  end
@@ -337,17 +337,19 @@ module OpenC3
337
337
  end
338
338
  end
339
339
 
340
+ def shutdown
341
+ @shutdown = true
342
+ @mutex.synchronize do
343
+ Logger.info("Shutting down processes...")
344
+ shutdown_processes(@processes)
345
+ Logger.info("Shutting down processes complete")
346
+ @shutdown_complete = true
347
+ end
348
+ end
349
+
340
350
  def run
341
351
  # Use at_exit to shutdown cleanly
342
- at_exit do
343
- @shutdown = true
344
- @mutex.synchronize do
345
- Logger.info("Shutting down processes...")
346
- shutdown_processes(@processes)
347
- Logger.info("Shutting down processes complete")
348
- @shutdown_complete = true
349
- end
350
- end
352
+ at_exit { shutdown() }
351
353
 
352
354
  # Monitor processes and respawn if died
353
355
  Logger.info("#{self.class} Monitoring processes every #{@cycle_time} sec...")
@@ -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 'nokogiri'
@@ -73,7 +73,7 @@ module OpenC3
73
73
  # Fortify complains about Path Manipulation here
74
74
  # We have previously validated the file is a .xtce file in packet_config
75
75
  # The file is opened read-only and then immediately parsed by Nokogiri
76
- doc = File.open(filename) { |f| Nokogiri::XML(f, nil, nil, Nokogiri::XML::ParseOptions::STRICT | Nokogiri::XML::ParseOptions::NOBLANKS) }
76
+ doc = File.open(filename) { |f| Nokogiri::XML(f, nil, nil, Nokogiri::XML::ParseOptions::STRICT | Nokogiri::XML::ParseOptions::NOBLANKS | Nokogiri::XML::ParseOptions::HUGE) }
77
77
  # Determine the @current_target_name
78
78
  xtce_process_element(doc.root)
79
79
  @current_target_name = target_name if target_name
@@ -699,6 +699,8 @@ module OpenC3
699
699
  # Strip quotes from strings
700
700
  if type.initialValue[0] == '"' && type.initialValue[-1] == '"'
701
701
  item.default = type.initialValue[1..-2]
702
+ else
703
+ item.default = type.initialValue
702
704
  end
703
705
  end
704
706
  else
@@ -165,7 +165,7 @@ module OpenC3
165
165
  #
166
166
  # @param args [String|Array<String>] See the description for calling style
167
167
  # @param type [Symbol] Telemetry type, :RAW, :CONVERTED (default), :FORMATTED, or :WITH_UNITS
168
- def wait(*args, type: :CONVERTED, scope: $openc3_scope, token: $openc3_token)
168
+ def wait(*args, type: :CONVERTED, quiet: false, scope: $openc3_scope, token: $openc3_token)
169
169
  time = nil
170
170
 
171
171
  case args.length
@@ -174,7 +174,7 @@ module OpenC3
174
174
  start_time = Time.now.sys
175
175
  openc3_script_sleep()
176
176
  time = Time.now.sys - start_time
177
- Logger.info("WAIT: Indefinite for actual time of #{time} seconds")
177
+ Logger.info("WAIT: Indefinite for actual time of #{time} seconds") unless quiet
178
178
 
179
179
  # wait(5) # absolute wait time
180
180
  when 1
@@ -182,7 +182,7 @@ module OpenC3
182
182
  start_time = Time.now.sys
183
183
  openc3_script_sleep(args[0])
184
184
  time = Time.now.sys - start_time
185
- Logger.info("WAIT: #{args[0]} seconds with actual time of #{time} seconds")
185
+ Logger.info("WAIT: #{args[0]} seconds with actual time of #{time} seconds") unless quiet
186
186
  else
187
187
  raise "Non-numeric wait time specified"
188
188
  end
@@ -196,7 +196,7 @@ module OpenC3
196
196
  else
197
197
  polling_rate = DEFAULT_TLM_POLLING_RATE
198
198
  end
199
- _execute_wait(target_name, packet_name, item_name, type, comparison_to_eval, timeout, polling_rate, scope: scope, token: token)
199
+ _execute_wait(target_name, packet_name, item_name, type, comparison_to_eval, timeout, polling_rate, quiet: quiet, scope: scope, token: token)
200
200
 
201
201
  # wait('target_name', 'packet_name', 'item_name', comparison_to_eval, timeout, polling_rate) # polling_rate is optional
202
202
  when 5, 6
@@ -210,7 +210,7 @@ module OpenC3
210
210
  else
211
211
  polling_rate = DEFAULT_TLM_POLLING_RATE
212
212
  end
213
- _execute_wait(target_name, packet_name, item_name, type, comparison_to_eval, timeout, polling_rate, scope: scope, token: token)
213
+ _execute_wait(target_name, packet_name, item_name, type, comparison_to_eval, timeout, polling_rate, quiet: quiet, scope: scope, token: token)
214
214
 
215
215
  else
216
216
  # Invalid number of arguments
@@ -220,8 +220,8 @@ module OpenC3
220
220
  end
221
221
 
222
222
  # @deprecated Use wait with type: :RAW
223
- def wait_raw(*args, scope: $openc3_scope, token: $openc3_token)
224
- wait(*args, type: :RAW, scope: scope, token: token)
223
+ def wait_raw(*args, quiet: false, scope: $openc3_scope, token: $openc3_token)
224
+ wait(*args, type: :RAW, quiet: quiet, scope: scope, token: token)
225
225
  end
226
226
 
227
227
  # Wait on an expression to be true. On a timeout, the script will continue.
@@ -232,7 +232,7 @@ module OpenC3
232
232
  #
233
233
  # @param args [String|Array<String>] See the description for calling style
234
234
  # @param type [Symbol] Telemetry type, :RAW or :CONVERTED (default)
235
- def wait_tolerance(*args, type: :CONVERTED, scope: $openc3_scope, token: $openc3_token)
235
+ def wait_tolerance(*args, type: :CONVERTED, quiet: false, scope: $openc3_scope, token: $openc3_token)
236
236
  raise "Invalid type '#{type}' for wait_tolerance" unless %i(RAW CONVERTED).include?(type)
237
237
 
238
238
  target_name, packet_name, item_name, expected_value, tolerance, timeout, polling_rate = _wait_tolerance_process_args(args, scope: scope, token: token)
@@ -257,9 +257,9 @@ module OpenC3
257
257
  end
258
258
 
259
259
  if success
260
- Logger.info message
260
+ Logger.info message unless quiet
261
261
  else
262
- Logger.warn message
262
+ Logger.warn message unless quiet
263
263
  end
264
264
  else
265
265
  success, value = openc3_script_wait_implementation_tolerance(target_name, packet_name, item_name, type, expected_value, tolerance, timeout, polling_rate, scope: scope, token: token)
@@ -268,28 +268,28 @@ module OpenC3
268
268
  wait_str = "WAIT: #{_upcase(target_name, packet_name, item_name)}"
269
269
  range_str = "range #{range.first} to #{range.last} with value == #{value} after waiting #{time} seconds"
270
270
  if success
271
- Logger.info "#{wait_str} was within #{range_str}"
271
+ Logger.info "#{wait_str} was within #{range_str}" unless quiet
272
272
  else
273
- Logger.warn "#{wait_str} failed to be within #{range_str}"
273
+ Logger.warn "#{wait_str} failed to be within #{range_str}" unless quiet
274
274
  end
275
275
  end
276
276
  time
277
277
  end
278
278
 
279
279
  # @deprecated Use wait_tolerance with type: :RAW
280
- def wait_tolerance_raw(*args, scope: $openc3_scope, token: $openc3_token)
281
- wait_tolerance(*args, type: :RAW, scope: scope, token: token)
280
+ def wait_tolerance_raw(*args, quiet: false, scope: $openc3_scope, token: $openc3_token)
281
+ wait_tolerance(*args, type: :RAW, quiet: quiet, scope: scope, token: token)
282
282
  end
283
283
 
284
284
  # Wait on a custom expression to be true
285
- def wait_expression(exp_to_eval, timeout, polling_rate = DEFAULT_TLM_POLLING_RATE, context = nil, scope: $openc3_scope, token: $openc3_token)
285
+ def wait_expression(exp_to_eval, timeout, polling_rate = DEFAULT_TLM_POLLING_RATE, context = nil, quiet: false, scope: $openc3_scope, token: $openc3_token)
286
286
  start_time = Time.now.sys
287
287
  success = openc3_script_wait_implementation_expression(exp_to_eval, timeout, polling_rate, context, scope: scope, token: token)
288
288
  time = Time.now.sys - start_time
289
289
  if success
290
- Logger.info "WAIT: #{exp_to_eval} is TRUE after waiting #{time} seconds"
290
+ Logger.info "WAIT: #{exp_to_eval} is TRUE after waiting #{time} seconds" unless quiet
291
291
  else
292
- Logger.warn "WAIT: #{exp_to_eval} is FALSE after waiting #{time} seconds"
292
+ Logger.warn "WAIT: #{exp_to_eval} is FALSE after waiting #{time} seconds" unless quiet
293
293
  end
294
294
  time
295
295
  end
@@ -427,8 +427,9 @@ module OpenC3
427
427
  num_packets,
428
428
  timeout,
429
429
  polling_rate = DEFAULT_TLM_POLLING_RATE,
430
+ quiet: false,
430
431
  scope: $openc3_scope, token: $openc3_token)
431
- _wait_packet(false, target_name, packet_name, num_packets, timeout, polling_rate, scope: scope, token: token)
432
+ _wait_packet(false, target_name, packet_name, num_packets, timeout, polling_rate, quiet: quiet, scope: scope, token: token)
432
433
  end
433
434
 
434
435
  # Wait for a telemetry packet to be received a certain number of times or timeout and raise an error
@@ -437,8 +438,9 @@ module OpenC3
437
438
  num_packets,
438
439
  timeout,
439
440
  polling_rate = DEFAULT_TLM_POLLING_RATE,
441
+ quiet: false,
440
442
  scope: $openc3_scope, token: $openc3_token)
441
- _wait_packet(true, target_name, packet_name, num_packets, timeout, polling_rate, scope: scope, token: token)
443
+ _wait_packet(true, target_name, packet_name, num_packets, timeout, polling_rate, quiet: quiet, scope: scope, token: token)
442
444
  end
443
445
 
444
446
  def disable_instrumentation
@@ -592,6 +594,7 @@ module OpenC3
592
594
  num_packets,
593
595
  timeout,
594
596
  polling_rate = DEFAULT_TLM_POLLING_RATE,
597
+ quiet: false,
595
598
  scope: $openc3_scope, token: $openc3_token)
596
599
  type = (check ? 'CHECK' : 'WAIT')
597
600
  initial_count = tlm(target_name, packet_name, 'RECEIVED_COUNT', scope: scope, token: token)
@@ -611,7 +614,7 @@ module OpenC3
611
614
  value = 0 unless value
612
615
  time = Time.now.sys - start_time
613
616
  if success
614
- Logger.info "#{type}: #{target_name.upcase} #{packet_name.upcase} received #{value - initial_count} times after waiting #{time} seconds"
617
+ Logger.info "#{type}: #{target_name.upcase} #{packet_name.upcase} received #{value - initial_count} times after waiting #{time} seconds" unless quiet
615
618
  else
616
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
620
  if check
@@ -621,13 +624,13 @@ module OpenC3
621
624
  raise CheckError, message
622
625
  end
623
626
  else
624
- Logger.warn message
627
+ Logger.warn message unless quiet
625
628
  end
626
629
  end
627
630
  time
628
631
  end
629
632
 
630
- def _execute_wait(target_name, packet_name, item_name, value_type, comparison_to_eval, timeout, polling_rate, scope: $openc3_scope, token: $openc3_token)
633
+ 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)
631
634
  start_time = Time.now.sys
632
635
  success, value = openc3_script_wait_implementation(target_name, packet_name, item_name, value_type, comparison_to_eval, timeout, polling_rate, scope: scope, token: token)
633
636
  value = "'#{value}'" if value.is_a? String # Show user the check against a quoted string
@@ -635,9 +638,9 @@ module OpenC3
635
638
  wait_str = "WAIT: #{_upcase(target_name, packet_name, item_name)} #{comparison_to_eval}"
636
639
  value_str = "with value == #{value} after waiting #{time} seconds"
637
640
  if success
638
- Logger.info "#{wait_str} success #{value_str}"
641
+ Logger.info "#{wait_str} success #{value_str}" unless quiet
639
642
  else
640
- Logger.warn "#{wait_str} failed #{value_str}"
643
+ Logger.warn "#{wait_str} failed #{value_str}" unless quiet
641
644
  end
642
645
  end
643
646
 
@@ -106,6 +106,7 @@ module OpenC3
106
106
  if local_file
107
107
  OpenC3::Logger.info "Reading local #{scope}/#{path}"
108
108
  file = Tempfile.new('target', binmode: true)
109
+ file.filename = path
109
110
  file.write(local_file.read)
110
111
  local_file.close
111
112
  file.rewind
@@ -126,11 +127,14 @@ module OpenC3
126
127
  end
127
128
  end
128
129
 
130
+ # download_file(path_or_file) is implemented by running_script to download a file
131
+
129
132
  # These are helper methods ... should not be used directly
130
133
 
131
134
  def _get_storage_file(path, scope: $openc3_scope)
132
135
  # Create Tempfile to store data
133
136
  file = Tempfile.new('target', binmode: true)
137
+ file.filename = path
134
138
 
135
139
  endpoint = "/openc3-api/storage/download/#{scope}/#{path}"
136
140
  result = _get_presigned_request(endpoint, scope: scope)
@@ -129,7 +129,9 @@ module OpenC3
129
129
  binary
130
130
  end
131
131
 
132
- def self.build_json(binary, definition_filename)
132
+ # We build the json hash without converting to a json string to allow modifying the hash
133
+ # app/models/table.rb uses this ability to add the real definition filename
134
+ def self.build_json_hash(binary, definition_filename)
133
135
  config = TableConfig.process_file(definition_filename)
134
136
  tables = []
135
137
  json = { tables: tables }
@@ -189,7 +191,7 @@ module OpenC3
189
191
  end
190
192
  end
191
193
  end
192
- json.as_json(:allow_nan => true).to_json(:allow_nan => true)
194
+ json.as_json(:allow_nan => true)
193
195
  end
194
196
 
195
197
  def self.load_binary(config, data)
@@ -226,11 +226,11 @@ class RubyLexUtils
226
226
  previous_indent = 0
227
227
 
228
228
  while lexed = lex.lex
229
- #puts "lexed = #{lexed.chomp}, indent = #{lex.indent}, continue = #{lex.continue}"
229
+ #puts "lexed = #{lexed.chomp}, indent = #{lex.indent}, continue = #{lex.continue}, ltype = #{lex.ltype.inspect}, code_block_open = #{lex.code_block_open}"
230
230
  lex.line_no += lexed.count("\n")
231
231
  lex.line.concat lexed
232
232
  line.concat lexed
233
- if lex.continue
233
+ if lex.continue or lex.ltype
234
234
  if not continue_block?(lexed)
235
235
  unless continue_indent
236
236
  if (lex.indent - previous_indent) > 1
@@ -292,32 +292,9 @@ class RubyLexUtils
292
292
  end
293
293
 
294
294
  if contains_keyword?(line)
295
- if contains_block_beginning?(line)
296
- section = ''
297
- line.each_line do |lexed_part|
298
- section << lexed_part
299
- if contains_block_beginning?(section)
300
- yield section, false, inside_begin, lex.exp_line_no
301
- break
302
- end
303
- lex.exp_line_no += 1
304
- end
305
- lex.exp_line_no += 1
306
- remainder = line[(section.length)..-1]
307
- line = remainder
308
- next unless remainder.empty?
309
- else
310
- yield line, false, inside_begin, lex.exp_line_no
311
- end
295
+ yield line, false, inside_begin, lex.exp_line_no
312
296
  elsif !line.empty?
313
- num_left_brackets = line.count('{')
314
- num_right_brackets = line.count('}')
315
- if num_left_brackets != num_right_brackets
316
- # Don't instrument lines with unequal numbers of { and } brackets
317
- yield line, false, inside_begin, lex.exp_line_no
318
- else
319
- yield line, true, inside_begin, lex.exp_line_no
320
- end
297
+ yield line, true, inside_begin, lex.exp_line_no
321
298
  end
322
299
  line = ''
323
300
  lex.exp_line_no = lex.line_no
@@ -159,6 +159,7 @@ module OpenC3
159
159
 
160
160
  unless $openc3_redis_cluster
161
161
  def read_topics(topics, offsets = nil, timeout_ms = 1000, count = nil)
162
+ return {} if topics.empty?
162
163
  Thread.current[:topic_offsets] ||= {}
163
164
  topic_offsets = Thread.current[:topic_offsets]
164
165
  begin
@@ -1,14 +1,14 @@
1
1
  # encoding: ascii-8bit
2
2
 
3
- OPENC3_VERSION = '5.6.1'
3
+ OPENC3_VERSION = '5.7.0'
4
4
  module OpenC3
5
5
  module Version
6
6
  MAJOR = '5'
7
- MINOR = '6'
8
- PATCH = '1'
7
+ MINOR = '7'
8
+ PATCH = '0'
9
9
  OTHER = ''
10
- BUILD = '86a8498603e3f90548f20613cb5b596c906f2a9e'
10
+ BUILD = 'ad11dde957c7d04de9c45d6fb8d6226a812ced9c'
11
11
  end
12
- VERSION = '5.6.1'
13
- GEM_VERSION = '5.6.1'
12
+ VERSION = '5.7.0'
13
+ GEM_VERSION = '5.7.0'
14
14
  end
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "widget",
3
- "version": "5.6.1",
3
+ "version": "5.7.0",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "build": "vue-cli-service build --target lib --dest tools/widgets/<%= widget_name %> --formats umd-min <%= widget_path %> --name <%= widget_name %>"
7
7
  },
8
8
  "dependencies": {
9
- "@openc3/tool-common": "5.6.1",
9
+ "@openc3/tool-common": "5.7.0",
10
10
  "vue": "2.7.14",
11
11
  "vuetify": "2.6.14"
12
12
  },
13
13
  "devDependencies": {
14
- "@babel/eslint-parser": "7.21.3",
14
+ "@babel/eslint-parser": "7.21.8",
15
15
  "@rushstack/eslint-patch": "1.2.0",
16
16
  "@vue/babel-preset-app": "5.0.8",
17
17
  "@vue/cli": "5.0.8",
@@ -21,15 +21,15 @@
21
21
  "@vue/eslint-config-prettier": "7.1.0",
22
22
  "babel-loader": "9.1.2",
23
23
  "babel-plugin-istanbul": "6.1.1",
24
- "eslint": "8.38.0",
24
+ "eslint": "8.40.0",
25
25
  "eslint-config-prettier": "8.8.0",
26
26
  "eslint-plugin-prettier": "4.2.1",
27
- "eslint-plugin-vue": "9.11.0",
28
- "prettier": "2.8.7",
29
- "sass": "1.62.0",
27
+ "eslint-plugin-vue": "9.11.1",
28
+ "prettier": "2.8.8",
29
+ "sass": "1.62.1",
30
30
  "sass-loader": "13.2.2",
31
31
  "vue-cli-plugin-vuetify": "2.5.8",
32
32
  "vue-template-compiler": "2.7.14",
33
- "webpack": "5.79.0"
33
+ "webpack": "5.82.0"
34
34
  }
35
35
  }