openc3 5.0.6 → 5.0.9

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.

@@ -1,7 +1,7 @@
1
1
  ---
2
2
  VERTICAL:
3
- summary: Places the widgets it encapsulates vertically on
4
- the screen. The screen defaults to a vertical layout, so if no layout widgets
3
+ summary: Places the widgets it encapsulates vertically
4
+ description: The screen defaults to a vertical layout, so if no layout widgets
5
5
  are specified, all widgets will be automatically placed within a VERTICAL
6
6
  layout widget. The VERTICAL widget sizes itself to fit its contents.
7
7
  parameters:
@@ -14,9 +14,9 @@ VERTICAL:
14
14
  description: Pack all widgets vertically (default = true)
15
15
  values: .*
16
16
  VERTICALBOX:
17
- summary: Places the widgets it encapsulates vertically
18
- on the screen inside of a thin border. The VERTICALBOX widget sizes itself
19
- to fit its contents vertically and to fit the screen horizontally.
17
+ summary: Places the widgets it encapsulates vertically inside a thin border
18
+ description: The VERTICALBOX widget sizes itself
19
+ to fit its contents vertically and to fit the screen horizontally
20
20
  parameters:
21
21
  - name: Title
22
22
  required: false
@@ -32,16 +32,15 @@ VERTICALBOX:
32
32
  values: .*
33
33
  HORIZONTAL:
34
34
  summary: Places the widgets it encapsulates horizontally
35
- on the screen. The HORIZONTAL widget sizes itself to fit its contents.
35
+ description: The HORIZONTAL widget sizes itself to fit its contents
36
36
  parameters:
37
37
  - name: Horizontal spacing
38
38
  required: false
39
39
  description: Horizontal spacing between widgets in pixels (default = 1)
40
40
  values: .*
41
41
  HORIZONTALBOX:
42
- summary: Places the widgets it encapsulates horizontally
43
- on the screen inside of a thin border. The HORIZONTALBOX widget sizes itself
44
- to fit its contents.
42
+ summary: Places the widgets it encapsulates horizontally inside a thin border
43
+ description: The HORIZONTALBOX widget sizes itself to fit its contents
45
44
  parameters:
46
45
  - name: Title
47
46
  required: false
@@ -52,8 +51,8 @@ HORIZONTALBOX:
52
51
  description: Horizontal spacing between widgets in pixels (default = 1)
53
52
  values: .*
54
53
  MATRIXBYCOLUMNS:
55
- summary: Places the widgets into a table-like matrix.
56
- The MATRIXBYCOLUMNS widget sizes itself to fit its contents.
54
+ summary: Places the widgets into a table-like matrix
55
+ description: The MATRIXBYCOLUMNS widget sizes itself to fit its contents
57
56
  parameters:
58
57
  - name: Columns
59
58
  required: true
@@ -68,15 +67,15 @@ MATRIXBYCOLUMNS:
68
67
  description: Vertical spacing between matrix items in pixels (default = 0)
69
68
  values: .*
70
69
  SCROLLWINDOW:
71
- summary: Places the widgets inside of it into a scrollable area.
72
- The SCROLLWINDOW widget sizes itself to fit the screen in which it is contained.
70
+ summary: Places the widgets inside of it into a scrollable area
71
+ description: The SCROLLWINDOW widget sizes itself to fit the screen in which it is contained
73
72
  parameters:
74
73
  - name: Height
75
74
  required: false
76
75
  description: Maximum height of the scroll window in pixels (default = 180)
77
76
  values: .*
78
77
  SPACER:
79
- summary: Places a fixed size spacer in between widgets.
78
+ summary: Places a fixed size spacer in between widgets
80
79
  parameters:
81
80
  - name: Width
82
81
  required: false
@@ -87,7 +86,7 @@ SPACER:
87
86
  description: Height of the widget
88
87
  values: .*
89
88
  IFRAME:
90
- summary: Open external tools in an Iframe within OpenC3.
89
+ summary: Open external tools in an Iframe within OpenC3
91
90
  parameters:
92
91
  - name: URL
93
92
  required: true
@@ -130,18 +129,16 @@ IMAGEVIEWER:
130
129
  values: .*
131
130
  TABBOOK:
132
131
  summary: Creates a tabbed area in which to place TABITEM widgets
133
- to form a tabbed layout.
134
132
  TABITEM:
135
- summary: Creates a tab into which to place widgets. The tab
136
- automatically acts like a VERTICAL widget.
133
+ summary: Creates a VERTICAL layout tab into which to place widgets
137
134
  parameters:
138
135
  - name: Tab text
139
136
  required: true
140
137
  description: Text to diplay in the tab
141
138
  values: .*
142
139
  LABEL:
143
- summary: Displays text on the screen. Generally, label widgets
144
- contain a telemetry mnemonic and are placed next to the telemetry VALUE widget.
140
+ summary: Displays text on the screen
141
+ description: Generally, label widgets contain a telemetry mnemonic and are placed next to the telemetry VALUE widget
145
142
  parameters:
146
143
  - name: Text
147
144
  required: true
@@ -150,16 +147,16 @@ LABEL:
150
147
  # HORIZONTALLINE:
151
148
  # summary: Displays a horizontal line on the screen that can be used as a separator
152
149
  SECTIONHEADER:
153
- summary: Displays a label that is underlined with a
154
- horizontal line. Generally, SECTIONHEADER widgets are the first widget placed
155
- inside of a VERTICALBOX widget.
150
+ summary: Displays a label that is underlined with a horizontal line
151
+ description: Generally, SECTIONHEADER widgets are the first widget placed
152
+ inside of a VERTICALBOX widget
156
153
  parameters:
157
154
  - name: Text
158
155
  required: true
159
156
  description: Text to display above the horizontal line
160
157
  values: .*
161
158
  TITLE:
162
- summary: Displays a large centered title on the screen.
159
+ summary: Displays a large centered title on the screen
163
160
  parameters:
164
161
  - name: Text
165
162
  required: true
@@ -186,8 +183,7 @@ TITLE:
186
183
  # description: The vertical size policy of the spacer. Default is MINIMUM.
187
184
  # values: <%= %w(FIXED MINIMUM MAXIMUM PREFERRED EXPANDING MINIMUMEXPANDING IGNORED) %>
188
185
  ARRAY:
189
- summary: Displays data from an array telemetry item.
190
- Data is organized into rows and by default space separated.
186
+ summary: Displays ARRAY data organized into rows and space separated
191
187
  parameters:
192
188
  - name: Target name
193
189
  required: true
@@ -222,8 +218,7 @@ ARRAY:
222
218
  description: The type of the value to display. Default is CONVERTED.
223
219
  values: <%= %w(RAW CONVERTED FORMATTED WITH_UNITS) %>
224
220
  BLOCK:
225
- summary: Displays data from a block telemetry item.
226
- Data is organized into rows and space separated.
221
+ summary: Displays BLOCK data organized into rows and space separated
227
222
  parameters:
228
223
  - name: Target name
229
224
  required: true
@@ -307,8 +302,8 @@ BLOCK:
307
302
  # description: The font size. (default = 100)
308
303
  # values: .*
309
304
  FORMATVALUE:
310
- summary: Displays a box with a value printed inside that
311
- is formatted by the specified string rather than by a format string given in
305
+ summary: Displays a box with a formatted value
306
+ description: Data is formatted by the specified string rather than by a format string given in
312
307
  the telemetry definition files. The white portion of the box darkens to gray
313
308
  while the value remains stagnant, then brightens to white each time the value
314
309
  changes. Additionally the value is colored based on the items limits state
@@ -339,9 +334,7 @@ FORMATVALUE:
339
334
  description: The number of characters wide to make the value box (default = 12)
340
335
  values: .*
341
336
  LABELLED:
342
- summary:
343
- Displays a Label widget followed by a LED which changes color based on telemetry values.
344
- See the LED widget documentation for more information.
337
+ summary: Displays a LABEL followed by a LED
345
338
  parameters:
346
339
  - name: Target name
347
340
  required: true
@@ -376,8 +369,7 @@ LABELLED:
376
369
  pushes them to the respective side with the space going on the opposite.
377
370
  values: ["SPLIT", "CENTER", "LEFT", "RIGHT"]
378
371
  LABELPROGRESSBAR:
379
- summary: Displays a LABEL widget showing the items
380
- name followed by a PROGRESSBAR widget to show the items value.
372
+ summary: Displays a LABEL with the item name followed by a PROGRESSBAR
381
373
  parameters:
382
374
  - name: Target name
383
375
  required: true
@@ -405,8 +397,7 @@ LABELPROGRESSBAR:
405
397
  description: The type of the value to display. Default is CONVERTED.
406
398
  values: <%= %w(RAW CONVERTED FORMATTED WITH_UNITS) %>
407
399
  LABELVALUE:
408
- summary: Displays a LABEL widget to show the telemetry
409
- items name followed by a VALUE widget to display the items value.
400
+ summary: Displays a LABEL with the item name followed by a VALUE
410
401
  parameters:
411
402
  - name: Target name
412
403
  required: true
@@ -437,8 +428,7 @@ LABELVALUE:
437
428
  pushes them to the respective side with the space going on the opposite.
438
429
  values: ["SPLIT", "CENTER", "LEFT", "RIGHT"]
439
430
  LABELVALUEDESC:
440
- summary: Displays a LABEL widget to show the telemetry
441
- items description followed by a VALUE widget to display the items value.
431
+ summary: Displays a LABEL with the items description followed by a VALUE
442
432
  parameters:
443
433
  - name: Target name
444
434
  required: true
@@ -495,8 +485,7 @@ LABELVALUEDESC:
495
485
  # description: The number of characters wide to make the value box (default = 12)
496
486
  # values: .*
497
487
  LABELVALUELIMITSBAR:
498
- summary: Displays a LABEL widget to show the telemetry item's name,
499
- followed by a VALUE widget to display the item's value, followed by a LIMITSBAR widget.
488
+ summary: Displays a LABEL with the item name followed by VALUE and LIMITSBAR widgets
500
489
  parameters:
501
490
  - name: Target name
502
491
  required: true
@@ -519,9 +508,7 @@ LABELVALUELIMITSBAR:
519
508
  description: The number of characters wide to make the value box (default = 12)
520
509
  values: .*
521
510
  LABELVALUELIMITSCOLUMN:
522
- summary: Displays a LABEL widget to shows
523
- the telemetry itemls name, followed by a VALUE widget to display the item's
524
- value, followed by a LIMITSCOLUMN widget.
511
+ summary: Displays a LABEL with the item name followed by VALUE and LIMITSCOLUMN widgets
525
512
  parameters:
526
513
  - name: Target name
527
514
  required: true
@@ -544,8 +531,7 @@ LABELVALUELIMITSCOLUMN:
544
531
  description: The number of characters wide to make the value box (default = 12)
545
532
  values: .*
546
533
  LABELVALUERANGEBAR:
547
- summary: Displays a LABEL widget to show the telemetry item's name,
548
- followed by a VALUE widget to display the item's value, followed by a RANGEBAR widget.
534
+ summary: Displays a LABEL with the item name followed by VALUE and RANGEBAR widgets
549
535
  parameters:
550
536
  - name: Target name
551
537
  required: true
@@ -628,8 +614,8 @@ LABELVALUERANGEBAR:
628
614
  # description: Height of the range bar (default = 25)
629
615
  # values: .*
630
616
  LED:
631
- summary: Displays a LED which changes color based on telemetry values.
632
- By default TRUE is green and FALSE is red and all other values are black.
617
+ summary: Displays a LED which changes color based on telemetry values
618
+ description: By default TRUE is green and FALSE is red and all other values are black.
633
619
  Additional values can be added by using the LED_COLOR setting. For example
634
620
  LED INST PARAMS VALUE3 RAW can be followed by SETTING LED_COLOR 0 GREEN,
635
621
  SETTING LED_COLOR 1 RED, and SETTING LED_COLOR ANY ORANGE.
@@ -659,8 +645,7 @@ LED:
659
645
  description: Height of the LED circle (default = 15)
660
646
  values: .*
661
647
  LIMITSBAR:
662
- summary: Displays a graphical representation of where an
663
- item's value falls withing its limits ranges horizontally.
648
+ summary: Displays an item's current value within its colored limits horizontally
664
649
  parameters:
665
650
  - name: Target name
666
651
  required: true
@@ -687,8 +672,7 @@ LIMITSBAR:
687
672
  description: Height of the range bar (default = 25)
688
673
  values: .*
689
674
  LIMITSCOLUMN:
690
- summary: Displays a graphical representation of where an
691
- item's value falls withing its limits ranges vertically.
675
+ summary: Displays an item's current value within its colored limits vertically
692
676
  parameters:
693
677
  - name: Target name
694
678
  required: true
@@ -715,8 +699,7 @@ LIMITSCOLUMN:
715
699
  description: Height of the range bar (default = 25)
716
700
  values: .*
717
701
  LIMITSCOLOR:
718
- summary: Displays a stoplight-like circle depicting the
719
- limits color of an item
702
+ summary: Displays a circle depicting the limits color of an item
720
703
  parameters:
721
704
  - name: Target name
722
705
  required: true
@@ -743,9 +726,7 @@ LIMITSCOLOR:
743
726
  description: Show the full item name (default is false)
744
727
  values: .*
745
728
  VALUELIMITSBAR:
746
- summary: Displays a graphical representation of where
747
- an items value falls withing its limits ranges horizontally and its value in
748
- a VALUE widget.
729
+ summary: Displays an item VALUE followed by LIMITSBAR
749
730
  parameters:
750
731
  - name: Target name
751
732
  required: true
@@ -768,9 +749,7 @@ VALUELIMITSBAR:
768
749
  description: The number of characters wide to make the value box (default = 8)
769
750
  values: .*
770
751
  VALUELIMITSCOLUMN:
771
- summary: Displays a graphical representation of where
772
- an item's value falls within its limits ranges vertically and its value in a
773
- VALUE widget.
752
+ summary: Displays an item VALUE followed by LIMITSCOLUMN
774
753
  parameters:
775
754
  - name: Target name
776
755
  required: true
@@ -793,8 +772,7 @@ VALUELIMITSCOLUMN:
793
772
  description: The number of characters wide to make the value box (default = 8)
794
773
  values: .*
795
774
  VALUERANGEBAR:
796
- summary: Displays a graphical representation of where an
797
- item's value falls within a range horizontally and its value in a VALUE widget.
775
+ summary: Displays an item VALUE followed by RANGEBAR
798
776
  parameters:
799
777
  - name: Target name
800
778
  required: true
@@ -877,8 +855,7 @@ VALUERANGEBAR:
877
855
  # description: Height of the range bar (default = 25)
878
856
  # values: .*
879
857
  LINEGRAPH:
880
- summary: Displays a line graph of a telemetry items value
881
- verses sample number
858
+ summary: Displays a line graph of a telemetry item
882
859
  parameters:
883
860
  - name: Target name
884
861
  required: true
@@ -909,6 +886,36 @@ LINEGRAPH:
909
886
  # required: false
910
887
  # description: The type of the value to display. Default is CONVERTED.
911
888
  # values: <%= %w(RAW CONVERTED FORMATTED WITH_UNITS) %>
889
+ SPARKLINE:
890
+ summary: Displays a sparkline graph (no cursor, scale or legend) of a telemetry item
891
+ parameters:
892
+ - name: Target name
893
+ required: true
894
+ description: The target name
895
+ values: .+
896
+ - name: Packet name
897
+ required: true
898
+ description: The packet name
899
+ values: .+
900
+ - name: Item name
901
+ required: true
902
+ description: The item name
903
+ values: .+
904
+ LABELSPARKLINE:
905
+ summary: Displays a LABEL with the item name followed by a SPARKLINE
906
+ parameters:
907
+ - name: Target name
908
+ required: true
909
+ description: The target name
910
+ values: .+
911
+ - name: Packet name
912
+ required: true
913
+ description: The packet name
914
+ values: .+
915
+ - name: Item name
916
+ required: true
917
+ description: The item name
918
+ values: .+
912
919
  PROGRESSBAR:
913
920
  summary: Displays a progress bar that is useful for displaying percentages
914
921
  parmeters:
@@ -938,8 +945,7 @@ PROGRESSBAR:
938
945
  description: The type of the value to display. Default is CONVERTED.
939
946
  values: <%= %w(RAW CONVERTED FORMATTED WITH_UNITS) %>
940
947
  RANGEBAR:
941
- summary: Displays a graphical representation of where an
942
- item's value falls withing a range horizontally.
948
+ summary: Displays a custom range bar displaying the item value
943
949
  parameters:
944
950
  - name: Target name
945
951
  required: true
@@ -1146,9 +1152,8 @@ TEXTBOX:
1146
1152
  # description: Height of the limits bar (default = 25)
1147
1153
  # values: .*
1148
1154
  VALUE:
1149
- summary:
1150
- The VALUE widget displays a box with a value printed inside. The white
1151
- portion of the box darkens to gray while the value remains stagnant, then
1155
+ summary: Displays a box with a telemetry item value
1156
+ description: The white portion of the box darkens to gray while the value remains stagnant, then
1152
1157
  brightens to white each time the value changes. Additionally the value is
1153
1158
  colored based on the items limits state (Red for example if it is out of limits).
1154
1159
  parameters:
@@ -1398,7 +1403,8 @@ CANVASLINE:
1398
1403
  the line
1399
1404
  values: ["NO_CONNECTOR", "CONNECTOR"]
1400
1405
  CANVASLINEVALUE:
1401
- summary: Draws a line onto the canvas in one of two colors based on the value
1406
+ summary: Draws a color changing line onto the canvas
1407
+ description: The line is represented by one of two colors based on the value
1402
1408
  of the associated telemetry item
1403
1409
  parameters:
1404
1410
  - name: Target name
@@ -1453,7 +1459,8 @@ CANVASLINEVALUE:
1453
1459
  description: The type of the value to display. Default is RAW
1454
1460
  values: <%= %w(RAW CONVERTED FORMATTED WITH_UNITS) %>
1455
1461
  CANVASDOT:
1456
- summary: The CANVASDOT widget draws a dot onto the canvas, and it can be
1462
+ summary: Draws a dot onto the canvas
1463
+ description: The dot can be given a fixed X and Y location or
1457
1464
  programmed to change its position with ruby code
1458
1465
  parameters:
1459
1466
  - name: X Position or Ruby Code
@@ -281,9 +281,12 @@ module OpenC3
281
281
 
282
282
  # States are an array of the name followed by a hash of 'value' and sometimes 'hazardous'
283
283
  item['states'].each do |name, hash|
284
+ param_name = params[item['name']]
285
+ # Remove quotes from string parameters
286
+ param_name = param_name.gsub('"', '').gsub("'", '') if param_name.is_a?(String)
284
287
  # To be hazardous the state must be marked hazardous
285
288
  # Check if either the state name or value matches the param passed
286
- if hash['hazardous'] && (name == params[item['name']] || hash['value'].to_f == params[item['name']].to_f)
289
+ if hash['hazardous'] && (name == param_name || hash['value'] == param_name)
287
290
  return true
288
291
  end
289
292
  end
@@ -396,7 +399,7 @@ module OpenC3
396
399
  'hazardous_check' => hazardous_check,
397
400
  'raw' => raw
398
401
  }
399
- Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params, packet, raw) if !packet["messages_disabled"]
402
+ Logger.info(build_cmd_output_string(target_name, cmd_name, cmd_params, packet, raw), scope: scope) if !packet["messages_disabled"]
400
403
  CommandTopic.send_command(command, scope: scope)
401
404
  end
402
405
 
@@ -32,6 +32,7 @@ module OpenC3
32
32
  'start_raw_logging_interface',
33
33
  'stop_raw_logging_interface',
34
34
  'get_all_interface_info',
35
+ 'map_target_to_interface',
35
36
  ])
36
37
 
37
38
  # Get information about an interface
@@ -113,5 +114,19 @@ module OpenC3
113
114
  info.sort! { |a, b| a[0] <=> b[0] }
114
115
  info
115
116
  end
117
+
118
+ # Associates a target and all its commands and telemetry with a particular
119
+ # interface. All the commands will go out over and telemetry be received
120
+ # from that interface.
121
+ #
122
+ # @param target_name [String] The name of the target
123
+ # @param interface_name (see #connect_interface)
124
+ def map_target_to_interface(target_name, interface_name, scope: $openc3_scope, token: $openc3_token)
125
+ authorize(permission: 'system_set', interface_name: interface_name, scope: scope, token: token)
126
+ new_interface = InterfaceModel.get_model(name: interface_name, scope: scope)
127
+ new_interface.map_target(target_name)
128
+ Logger.info("Target #{target_name} mapped to Interface #{interface_name}", scope: scope)
129
+ nil
130
+ end
116
131
  end
117
132
  end
@@ -260,7 +260,7 @@ module OpenC3
260
260
  message = "Setting '#{target_name} #{packet_name} #{item_name}' limits to #{red_low} #{yellow_low} #{yellow_high} #{red_high}"
261
261
  message << " #{green_low} #{green_high}" if green_low && green_high
262
262
  message << " in set #{limits_set} with persistence #{persistence} as enabled #{enabled}"
263
- Logger.info(message)
263
+ Logger.info(message, scope: scope)
264
264
 
265
265
  TargetModel.set_packet(target_name, packet_name, packet, scope: scope)
266
266
 
@@ -307,7 +307,7 @@ module OpenC3
307
307
  def set_limits_set(limits_set, scope: $openc3_scope, token: $openc3_token)
308
308
  authorize(permission: 'tlm_set', scope: scope, token: token)
309
309
  message = "Setting Limits Set: #{limits_set}"
310
- Logger.info(message)
310
+ Logger.info(message, scope: scope)
311
311
  LimitsEventTopic.write({ type: :LIMITS_SET, set: limits_set.to_s,
312
312
  time_nsec: Time.now.to_nsec_from_epoch, message: message }, scope: scope)
313
313
  end
@@ -343,7 +343,7 @@ module OpenC3
343
343
  group = get_limits_groups()[group_name]
344
344
  raise "LIMITS_GROUP #{group_name} undefined. Ensure your telemetry definition contains the line: LIMITS_GROUP #{group_name}" unless group
345
345
 
346
- Logger.info("Disabling Limits Group: #{group_name}")
346
+ Logger.info("Disabling Limits Group: #{group_name}", scope: scope)
347
347
  last_target_name = nil
348
348
  last_packet_name = nil
349
349
  packet = nil
@@ -80,4 +80,9 @@ class File
80
80
  end
81
81
  return nil
82
82
  end
83
+
84
+ def delete
85
+ self.close
86
+ File.delete(self.path)
87
+ end
83
88
  end
@@ -80,9 +80,9 @@ class Float
80
80
  end
81
81
 
82
82
  def as_json(options = nil)
83
- return { "json_class" => Float, "raw" => "Infinity" } if self.infinite? == 1
84
- return { "json_class" => Float, "raw" => "-Infinity" } if self.infinite? == -1
85
- return { "json_class" => Float, "raw" => "NaN" } if self.nan?
83
+ return { "json_class" => "Float", "raw" => "Infinity" } if self.infinite? == 1
84
+ return { "json_class" => "Float", "raw" => "-Infinity" } if self.infinite? == -1
85
+ return { "json_class" => "Float", "raw" => "NaN" } if self.nan?
86
86
 
87
87
  return self
88
88
  end
@@ -35,9 +35,9 @@ module OpenC3
35
35
  @state = 'GETTING_OBJECTS'
36
36
  start_time = Time.now
37
37
  [
38
- ["#{@scope}/raw_logs/cmd/#{target_name}/", target.cmd_log_retain_time],
39
- ["#{@scope}/decom_logs/cmd/#{target_name}/", target.cmd_decom_log_retain_time],
40
- ["#{@scope}/raw_logs/tlm/#{target_name}/", target.tlm_log_retain_time],
38
+ ["#{@scope}/raw_logs/cmd/#{target_name}/", target.cmd_log_retain_time],
39
+ ["#{@scope}/decom_logs/cmd/#{target_name}/", target.cmd_decom_log_retain_time],
40
+ ["#{@scope}/raw_logs/tlm/#{target_name}/", target.tlm_log_retain_time],
41
41
  ["#{@scope}/decom_logs/tlm/#{target_name}/", target.tlm_decom_log_retain_time],
42
42
  ["#{@scope}/reduced_minute_logs/tlm/#{target_name}/", target.reduced_minute_log_retain_time],
43
43
  ["#{@scope}/reduced_hour_logs/tlm/#{target_name}/", target.reduced_hour_log_retain_time],
@@ -52,8 +52,10 @@ module OpenC3
52
52
  end
53
53
  if delete_items.length > 0
54
54
  @state = 'DELETING_OBJECTS'
55
- rubys3_client.delete_objects({ bucket: 'logs', delete: { objects: delete_items } })
56
- Logger.info("Deleted #{delete_items.length} #{target_name} log files")
55
+ delete_items.each_slice(1000) do |delete_slice|
56
+ rubys3_client.delete_objects({ bucket: 'logs', delete: { objects: delete_slice } })
57
+ Logger.info("Deleted #{delete_slice.length} #{target_name} log files")
58
+ end
57
59
  end
58
60
  end
59
61
 
@@ -40,12 +40,12 @@ module OpenC3
40
40
 
41
41
  # Delete the current value table for a target
42
42
  def self.del(target_name:, packet_name:, scope:)
43
- EphemeralStore.hdel("#{scope}__tlm__#{target_name}", packet_name)
43
+ Store.hdel("#{scope}__tlm__#{target_name}", packet_name)
44
44
  end
45
45
 
46
46
  # Set the current value table for a target, packet
47
47
  def self.set(hash, target_name:, packet_name:, scope:)
48
- EphemeralStore.hset("#{scope}__tlm__#{target_name}", packet_name, JSON.generate(hash.as_json(:allow_nan => true)))
48
+ Store.hset("#{scope}__tlm__#{target_name}", packet_name, JSON.generate(hash.as_json(:allow_nan => true)))
49
49
  end
50
50
 
51
51
  # Set an item in the current value table
@@ -62,9 +62,9 @@ module OpenC3
62
62
  else
63
63
  raise "Unknown type '#{type}' for #{target_name} #{packet_name} #{item_name}"
64
64
  end
65
- hash = JSON.parse(EphemeralStore.hget("#{scope}__tlm__#{target_name}", packet_name), :allow_nan => true, :create_additions => true)
65
+ hash = JSON.parse(Store.hget("#{scope}__tlm__#{target_name}", packet_name), :allow_nan => true, :create_additions => true)
66
66
  hash[field] = value
67
- EphemeralStore.hset("#{scope}__tlm__#{target_name}", packet_name, JSON.generate(hash.as_json(:allow_nan => true)))
67
+ Store.hset("#{scope}__tlm__#{target_name}", packet_name, JSON.generate(hash.as_json(:allow_nan => true)))
68
68
  end
69
69
 
70
70
  # Get an item from the current value table
@@ -86,7 +86,7 @@ module OpenC3
86
86
  else
87
87
  raise "Unknown type '#{type}' for #{target_name} #{packet_name} #{item_name}"
88
88
  end
89
- hash = JSON.parse(EphemeralStore.hget("#{scope}__tlm__#{target_name}", packet_name), :allow_nan => true, :create_additions => true)
89
+ hash = JSON.parse(Store.hget("#{scope}__tlm__#{target_name}", packet_name), :allow_nan => true, :create_additions => true)
90
90
  hash.values_at(*types).each do |result|
91
91
  return result if result
92
92
  end
@@ -106,7 +106,7 @@ module OpenC3
106
106
 
107
107
  lookups.each do |target_packet_key, target_name, packet_name, packet_values|
108
108
  unless packet_lookup[target_packet_key]
109
- packet = EphemeralStore.hget("#{scope}__tlm__#{target_name}", packet_name)
109
+ packet = Store.hget("#{scope}__tlm__#{target_name}", packet_name)
110
110
  raise "Packet '#{target_name} #{packet_name}' does not exist" unless packet
111
111
  packet_lookup[target_packet_key] = JSON.parse(packet, :allow_nan => true, :create_additions => true)
112
112
  end
@@ -277,5 +277,46 @@ module OpenC3
277
277
  end
278
278
  status_model.destroy if status_model
279
279
  end
280
+
281
+ def unmap_target(target_name)
282
+ target_name = target_name.to_s.upcase
283
+
284
+ # Remove from this interface
285
+ @target_names.delete(target_name)
286
+ update()
287
+
288
+ # Respawn the microservice
289
+ type = self.class._get_type
290
+ microservice_name = "#{@scope}__#{type}__#{@name}"
291
+ microservice = MicroserviceModel.get_model(name: microservice_name, scope: scope)
292
+ microservice.target_names.delete(target_name)
293
+ microservice.update
294
+ end
295
+
296
+ def map_target(target_name)
297
+ target_name = target_name.to_s.upcase
298
+
299
+ # Remove from old interface
300
+ all_interfaces = InterfaceModel.all(scope: scope)
301
+ old_interface = nil
302
+ all_interfaces.each do |old_interface_name, old_interface_details|
303
+ if old_interface_details['target_names'].include?(target_name)
304
+ old_interface = InterfaceModel.from_json(old_interface_details, scope: scope)
305
+ break
306
+ end
307
+ end
308
+ old_interface.unmap_target(target_name) if old_interface
309
+
310
+ # Add to this interface
311
+ @target_names << target_name unless @target_names.include?(target_name)
312
+ update()
313
+
314
+ # Respawn the microservice
315
+ type = self.class._get_type
316
+ microservice_name = "#{@scope}__#{type}__#{@name}"
317
+ microservice = MicroserviceModel.get_model(name: microservice_name, scope: scope)
318
+ microservice.target_names << target_name unless microservice.target_names.include?(target_name)
319
+ microservice.update
320
+ end
280
321
  end
281
322
  end
@@ -26,8 +26,14 @@ module OpenC3
26
26
  PRIMARY_KEY = 'openc3_microservices'
27
27
 
28
28
  attr_accessor :cmd
29
- attr_accessor :options
29
+ attr_accessor :container
30
+ attr_accessor :env
31
+ attr_accessor :folder_name
30
32
  attr_accessor :needs_dependencies
33
+ attr_accessor :options
34
+ attr_accessor :target_names
35
+ attr_accessor :topics
36
+ attr_accessor :work_dir
31
37
 
32
38
  # NOTE: The following three class methods are used by the ModelController
33
39
  # and are reimplemented to enable various Model class methods to work
@@ -251,7 +251,7 @@ module OpenC3
251
251
  end
252
252
 
253
253
  def create(update: false, force: false)
254
- @name = @name + "__#{Time.now.utc.strftime("%Y%m%d%H%M%S")}" unless update
254
+ @name = @name + "__#{Time.now.utc.strftime("%Y%m%d%H%M%S")}" if not update and not @name.index("__")
255
255
  super(update: update, force: force)
256
256
  end
257
257
 
@@ -267,11 +267,13 @@ module OpenC3
267
267
 
268
268
  # Undeploy all models associated with this plugin
269
269
  def undeploy
270
+ microservice_count = 0
270
271
  MicroserviceModel.find_all_by_plugin(plugin: @name, scope: @scope).each do |name, model_instance|
271
272
  model_instance.destroy
273
+ microservice_count += 1
272
274
  end
273
275
  # Wait for the operator to wake up and remove the microservice processes
274
- sleep 12 # Cycle time 5s times 2 plus 2s wait for soft stop and then hard stop
276
+ sleep 12 if microservice_count > 0 # Cycle time 5s times 2 plus 2s wait for soft stop and then hard stop
275
277
  # Remove all the other models now that the processes have stopped
276
278
  # Save TargetModel for last as it has the most to cleanup
277
279
  [InterfaceModel, RouterModel, ToolModel, WidgetModel, TargetModel].each do |model|
@@ -40,7 +40,9 @@ module OpenC3
40
40
  end
41
41
 
42
42
  def self.all(scope:)
43
- super("#{scope}__#{PRIMARY_KEY}")
43
+ all = super("#{scope}__#{PRIMARY_KEY}")
44
+ # Sort by the time and reverse to put newest (latest timestamp) on top
45
+ all.sort_by { |key, value| value['updated_at'] }.reverse
44
46
  end
45
47
  # END NOTE
46
48