openc3 5.4.0 → 5.4.2

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c51fd2722cde933052c2bf5941c3a111a14ae995de868bb6371faf9f32f708e
4
- data.tar.gz: 0a1684b608df0335f485e59b29e55e66a1307cb62c7ab76586989a4566096946
3
+ metadata.gz: '08e9c285070449047388f035c8c56522154ed54cd9e075dc3b52e87f17a7ff0e'
4
+ data.tar.gz: d52d4c20ffd7f7ea1593d19df3be807d7dc4cc787e30390d11f8c1b90103c186
5
5
  SHA512:
6
- metadata.gz: c36db608db41b6f0c1edc8ae6b83293d71eb37984e115d86a9ca9ff1e6aa4f124c3e0d645b1ac01b329d3fd490ef6a3b281ddc2754344bbdc1c78a702258522c
7
- data.tar.gz: 754bc2ce9f0fd0066e47731bc5b50279ac5ce166f20752bb5be42d2ce4ab09698212ee82abcfd1ab353aa1e85029f47e5b766b4bfdba60823682c23148754837
6
+ metadata.gz: 5e242af794c1263642f951c46867ce5fa543ccef505c60c0d6a4015c91503acf8d62b3b7b8dd40b91ec4c252013b4a40eec21d0bb3055bc5f6ae11e370c48fbe
7
+ data.tar.gz: 06b2ad289fcd4bfbfa23a896469b1d9d4b55b017e4535eb060a101147b4b757535f071dd622121f78923a2d0e1923795e109b94d3c6917933e0ce74e11c586cd
@@ -37,6 +37,7 @@ module OpenC3
37
37
  'set_tlm',
38
38
  'inject_tlm',
39
39
  'override_tlm',
40
+ 'get_overrides',
40
41
  'normalize_tlm',
41
42
  'get_tlm_buffer',
42
43
  'get_tlm_packet',
@@ -169,6 +170,12 @@ module OpenC3
169
170
  CvtModel.override(target_name, packet_name, item_name, value, type: type.intern, scope: scope)
170
171
  end
171
172
 
173
+ # Get the list of CVT overrides
174
+ def get_overrides(scope: $openc3_scope, token: $openc3_token)
175
+ authorize(permission: 'tlm', scope: scope, token: token)
176
+ CvtModel.overrides(scope: scope)
177
+ end
178
+
172
179
  # Normalize a telemetry item in a packet to its default behavior. Called
173
180
  # after override_tlm to restore standard processing.
174
181
  #
@@ -394,7 +401,7 @@ module OpenC3
394
401
  return nil
395
402
  end
396
403
 
397
- def tlm_process_args(args, function_name, scope: $openc3_scope, token: $openc3_token)
404
+ def tlm_process_args(args, method_name, scope: $openc3_scope, token: $openc3_token)
398
405
  case args.length
399
406
  when 1
400
407
  target_name, packet_name, item_name = extract_fields_from_tlm_text(args[0])
@@ -404,7 +411,7 @@ module OpenC3
404
411
  item_name = args[2]
405
412
  else
406
413
  # Invalid number of arguments
407
- raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
414
+ raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{method_name}()"
408
415
  end
409
416
  if packet_name == 'LATEST'
410
417
  latest = -1
@@ -429,7 +436,7 @@ module OpenC3
429
436
  return [target_name, packet_name, item_name]
430
437
  end
431
438
 
432
- def set_tlm_process_args(args, function_name, scope: $openc3_scope, token: $openc3_token)
439
+ def set_tlm_process_args(args, method_name, scope: $openc3_scope, token: $openc3_token)
433
440
  case args.length
434
441
  when 1
435
442
  target_name, packet_name, item_name, value = extract_fields_from_set_tlm_text(args[0])
@@ -440,7 +447,7 @@ module OpenC3
440
447
  value = args[3]
441
448
  else
442
449
  # Invalid number of arguments
443
- raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
450
+ raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{method_name}()"
444
451
  end
445
452
  # Determine if this item exists, it will raise appropriate errors if not
446
453
  TargetModel.packet_item(target_name, packet_name, item_name, scope: scope)
@@ -362,14 +362,18 @@ module OpenC3
362
362
  @interface.tlm_target_names.each do |target_name|
363
363
  # Initialize the target's packet counters based on the Topic stream
364
364
  # Prevents packet count resetting to 0 when interface restarts
365
- System.telemetry.packets(target_name).each do |packet_name, packet|
366
- topic = "#{@scope}__TELEMETRY__{#{target_name}}__#{packet_name}"
367
- msg_id, msg_hash = Topic.get_newest_message(topic)
368
- if msg_id
369
- packet.received_count = msg_hash['received_count'].to_i
370
- else
371
- packet.received_count = 0
365
+ begin
366
+ System.telemetry.packets(target_name).each do |packet_name, packet|
367
+ topic = "#{@scope}__TELEMETRY__{#{target_name}}__#{packet_name}"
368
+ msg_id, msg_hash = Topic.get_newest_message(topic)
369
+ if msg_id
370
+ packet.received_count = msg_hash['received_count'].to_i
371
+ else
372
+ packet.received_count = 0
373
+ end
372
374
  end
375
+ rescue
376
+ # Handle targets without telemetry
373
377
  end
374
378
  end
375
379
  if @interface.connect_on_startup
@@ -649,15 +653,17 @@ module OpenC3
649
653
  # Need to make sure that @cancel_thread is set and the interface disconnected within
650
654
  # mutex to ensure that connect() is not called when we want to stop()
651
655
  @cancel_thread = true
652
- @handler_thread.stop
653
- @interface_thread_sleeper.cancel
654
- @interface.disconnect
655
- if @interface_or_router == 'INTERFACE'
656
- valid_interface = InterfaceStatusModel.get_model(name: @interface.name, scope: @scope)
657
- else
658
- valid_interface = RouterStatusModel.get_model(name: @interface.name, scope: @scope)
656
+ @handler_thread.stop if @handler_thread
657
+ @interface_thread_sleeper.cancel if @interface_thread_sleeper
658
+ if @interface
659
+ @interface.disconnect
660
+ if @interface_or_router == 'INTERFACE'
661
+ valid_interface = InterfaceStatusModel.get_model(name: @interface.name, scope: @scope)
662
+ else
663
+ valid_interface = RouterStatusModel.get_model(name: @interface.name, scope: @scope)
664
+ end
665
+ valid_interface.destroy if valid_interface
659
666
  end
660
- valid_interface.destroy if valid_interface
661
667
  end
662
668
  end
663
669
 
@@ -21,6 +21,7 @@
21
21
  # if purchased from OpenC3, Inc.
22
22
 
23
23
  require 'openc3/utilities/store'
24
+ require 'openc3/models/target_model'
24
25
 
25
26
  module OpenC3
26
27
  class CvtModel
@@ -144,6 +145,38 @@ module OpenC3
144
145
  results
145
146
  end
146
147
 
148
+ # Return all the overrides
149
+ def self.overrides(scope: $openc3_scope)
150
+ overrides = []
151
+ TargetModel.names(scope: scope).each do |target_name|
152
+ all = Store.hgetall("#{scope}__override__#{target_name}")
153
+ next if all.nil? or all.empty?
154
+ all.each do |packet_name, hash|
155
+ items = JSON.parse(hash, :allow_nan => true, :create_additions => true)
156
+ items.each do |key, value|
157
+ item = {}
158
+ item['target_name'] = target_name
159
+ item['packet_name'] = packet_name
160
+ item_name, value_type_key = key.split('__')
161
+ item['item_name'] = item_name
162
+ case value_type_key
163
+ when 'U'
164
+ item['value_type'] = 'WITH_UNITS'
165
+ when 'F'
166
+ item['value_type'] = 'FORMATTED'
167
+ when 'C'
168
+ item['value_type'] = 'CONVERTED'
169
+ else
170
+ item['value_type'] = 'RAW'
171
+ end
172
+ item['value'] = value
173
+ overrides << item
174
+ end
175
+ end
176
+ end
177
+ overrides
178
+ end
179
+
147
180
  # Override a current value table item such that it always returns the same value
148
181
  # for the given type
149
182
  def self.override(target_name, packet_name, item_name, value, type: :ALL, scope: $openc3_scope)
@@ -538,7 +538,7 @@ module OpenC3
538
538
  end
539
539
  end
540
540
 
541
- def _check_process_args(args, function_name, scope: $openc3_scope, token: $openc3_token)
541
+ def _check_process_args(args, method_name, scope: $openc3_scope, token: $openc3_token)
542
542
  case args.length
543
543
  when 1
544
544
  target_name, packet_name, item_name, comparison_to_eval = extract_fields_from_check_text(args[0])
@@ -549,7 +549,7 @@ module OpenC3
549
549
  comparison_to_eval = args[3]
550
550
  else
551
551
  # Invalid number of arguments
552
- raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
552
+ raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{method_name}()"
553
553
  end
554
554
  return [target_name, packet_name, item_name, comparison_to_eval]
555
555
  end
@@ -679,17 +679,17 @@ module OpenC3
679
679
  # When testing an array with a tolerance, the expected value and tolerance
680
680
  # can both be supplied as either an array or a single value. If a single
681
681
  # value is passed in, that value will be used for all array elements.
682
- def array_tolerance_process_args(array_size, expected_value, tolerance, function_name, scope: $openc3_scope, token: $openc3_token)
682
+ def array_tolerance_process_args(array_size, expected_value, tolerance, method_name, scope: $openc3_scope, token: $openc3_token)
683
683
  if expected_value.is_a?(Array)
684
684
  if array_size != expected_value.size
685
- raise "ERROR: Invalid array size for expected_value passed to #{function_name}()"
685
+ raise "ERROR: Invalid array size for expected_value passed to #{method_name}()"
686
686
  end
687
687
  else
688
688
  expected_value = Array.new(array_size, expected_value)
689
689
  end
690
690
  if tolerance.is_a?(Array)
691
691
  if array_size != tolerance.size
692
- raise "ERROR: Invalid array size for tolerance passed to #{function_name}()"
692
+ raise "ERROR: Invalid array size for tolerance passed to #{method_name}()"
693
693
  end
694
694
  else
695
695
  tolerance = Array.new(array_size, tolerance)
@@ -30,8 +30,13 @@ module OpenC3
30
30
  # and can implement setup and teardown methods. Script groups are added via add_group(Group)
31
31
  # and individual scripts added via add_script(Group, script_method).
32
32
  class Suite
33
- attr_reader :scripts
34
- attr_reader :plans
33
+ def scripts
34
+ @scripts ||= {}
35
+ end
36
+
37
+ def plans
38
+ @plans ||= []
39
+ end
35
40
 
36
41
  ###########################################################################
37
42
  # START PUBLIC API
@@ -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/script/suite'
@@ -122,7 +122,6 @@ module OpenC3
122
122
  # Build list of Suites and Groups
123
123
  def self.build_suites
124
124
  @@suites = []
125
- # @@suites = @@suites.select { |my_suite| my_suite.name == 'CustomSuite' }
126
125
  suites = {}
127
126
  groups = []
128
127
  ObjectSpace.each_object(Class) do |object|
@@ -144,7 +143,6 @@ module OpenC3
144
143
  if object.methods(false).include?(:name)
145
144
  raise FatalError.new("#{object} redefined the 'self.name' method. Delete the 'self.name' method and try again.")
146
145
  end
147
-
148
146
  groups << object
149
147
  end
150
148
  end
@@ -153,15 +151,18 @@ module OpenC3
153
151
  return "No Suite or no Group classes found"
154
152
  end
155
153
 
156
- # Create Suite for unassigned Groups
154
+ # Remove assigned Groups from the array of groups
157
155
  @@suites.each do |suite|
156
+ next if suite.class == UnassignedSuite
158
157
  groups_to_delete = []
159
158
  groups.each { |group| groups_to_delete << group if suite.scripts[group] }
160
159
  groups_to_delete.each { |group| groups.delete(group) }
161
160
  end
162
161
  if groups.empty?
162
+ # If there are no unassigned group we simply remove the UnassignedSuite
163
163
  @@suites = @@suites.select { |suite| suite.class != UnassignedSuite }
164
164
  else
165
+ # unassigned groups should be added to the UnassignedSuite
165
166
  unassigned_suite = @@suites.select { |suite| suite.class == UnassignedSuite }[0]
166
167
  groups.each { |group| unassigned_suite.add_group(group) }
167
168
  end
@@ -16,6 +16,8 @@
16
16
  # This file may also be used under the terms of a commercial license
17
17
  # if purchased from OpenC3, Inc.
18
18
 
19
+ require 'openc3/script/extract'
20
+
19
21
  module OpenC3
20
22
  module Script
21
23
  private
@@ -39,5 +41,40 @@ module OpenC3
39
41
  end
40
42
  return id, packets
41
43
  end
44
+
45
+ # inject_tlm, set_tlm, override_tlm, and normalize_tlm are implemented here simply to add a puts
46
+ # these methods modify the telemetry so the user should be notified in the Script Runner log messages
47
+
48
+ def inject_tlm(target_name, packet_name, item_hash = nil, type: :CONVERTED, scope: $openc3_scope, token: $openc3_token)
49
+ puts "inject_tlm(\"#{target_name}\", \"#{packet_name}\", #{item_hash}, type: #{type})"
50
+ $api_server.method_missing(:inject_tlm, target_name, packet_name, item_hash, type: type, scope: scope, token: token)
51
+ end
52
+
53
+ def set_tlm(*args, type: :ALL, scope: $openc3_scope, token: $openc3_token)
54
+ if args.length == 1
55
+ puts "set_tlm(\"#{args.join('')}\", type: #{type})"
56
+ else
57
+ puts "set_tlm(\"#{args.join('", "')}\", type: #{type})"
58
+ end
59
+ $api_server.method_missing(:set_tlm, *args, type: type, scope: scope, token: token)
60
+ end
61
+
62
+ def override_tlm(*args, type: :ALL, scope: $openc3_scope, token: $openc3_token)
63
+ if args.length == 1
64
+ puts "override_tlm(\"#{args.join('')}\", type: #{type})"
65
+ else
66
+ puts "override_tlm(\"#{args.join('", "')}\", type: #{type})"
67
+ end
68
+ $api_server.method_missing(:override_tlm, *args, type: type, scope: scope, token: token)
69
+ end
70
+
71
+ def normalize_tlm(*args, type: :ALL, scope: $openc3_scope, token: $openc3_token)
72
+ if args.length == 1
73
+ puts "normalize_tlm(\"#{args.join('')}\", type: #{type})"
74
+ else
75
+ puts "normalize_tlm(\"#{args.join('", "')}\", type: #{type})"
76
+ end
77
+ $api_server.method_missing(:normalize_tlm, *args, type: type, scope: scope, token: token)
78
+ end
42
79
  end
43
80
  end
@@ -1,14 +1,14 @@
1
1
  # encoding: ascii-8bit
2
2
 
3
- OPENC3_VERSION = '5.4.0'
3
+ OPENC3_VERSION = '5.4.2'
4
4
  module OpenC3
5
5
  module Version
6
6
  MAJOR = '5'
7
7
  MINOR = '4'
8
- PATCH = '0'
8
+ PATCH = '2'
9
9
  OTHER = ''
10
- BUILD = 'f10d7e7ecbe3c6917e4f87eeac1f5eb0ddcf3d67'
10
+ BUILD = '6a7f2b4ff8e1255aa4d9768b539211b175cb9ec7'
11
11
  end
12
- VERSION = '5.4.0'
13
- GEM_VERSION = '5.4.0'
12
+ VERSION = '5.4.2'
13
+ GEM_VERSION = '5.4.2'
14
14
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openc3
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.0
4
+ version: 5.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Melton
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-02-02 00:00:00.000000000 Z
12
+ date: 2023-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler