openc3 5.20.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/bin/openc3cli +12 -120
  3. data/data/config/command_modifiers.yaml +13 -1
  4. data/data/config/interface_modifiers.yaml +21 -4
  5. data/data/config/item_modifiers.yaml +1 -1
  6. data/data/config/microservice.yaml +15 -2
  7. data/data/config/param_item_modifiers.yaml +1 -1
  8. data/data/config/parameter_modifiers.yaml +1 -1
  9. data/data/config/table_manager.yaml +2 -2
  10. data/data/config/target.yaml +11 -0
  11. data/data/config/telemetry_modifiers.yaml +17 -1
  12. data/data/config/tool.yaml +12 -0
  13. data/data/config/widgets.yaml +13 -17
  14. data/lib/openc3/accessors/form_accessor.rb +4 -3
  15. data/lib/openc3/accessors/html_accessor.rb +3 -3
  16. data/lib/openc3/accessors/http_accessor.rb +13 -13
  17. data/lib/openc3/accessors/xml_accessor.rb +16 -4
  18. data/lib/openc3/api/target_api.rb +0 -30
  19. data/lib/openc3/config/config_parser.rb +6 -3
  20. data/lib/openc3/core_ext/array.rb +0 -16
  21. data/lib/openc3/core_ext.rb +0 -1
  22. data/lib/openc3/interfaces/file_interface.rb +198 -0
  23. data/lib/openc3/interfaces/http_client_interface.rb +71 -39
  24. data/lib/openc3/interfaces/http_server_interface.rb +0 -7
  25. data/lib/openc3/interfaces/interface.rb +2 -0
  26. data/lib/openc3/interfaces/mqtt_interface.rb +32 -15
  27. data/lib/openc3/interfaces/mqtt_stream_interface.rb +19 -4
  28. data/lib/openc3/interfaces/protocols/crc_protocol.rb +7 -0
  29. data/lib/openc3/interfaces/serial_interface.rb +1 -0
  30. data/lib/openc3/interfaces.rb +2 -4
  31. data/lib/openc3/microservices/multi_microservice.rb +3 -3
  32. data/lib/openc3/migrations/20241208080000_no_critical_cmd.rb +31 -0
  33. data/lib/openc3/migrations/20241208080001_no_trigger_group.rb +46 -0
  34. data/lib/openc3/models/interface_model.rb +9 -3
  35. data/lib/openc3/models/microservice_model.rb +8 -1
  36. data/lib/openc3/models/plugin_model.rb +6 -1
  37. data/lib/openc3/models/python_package_model.rb +6 -1
  38. data/lib/openc3/models/reaction_model.rb +14 -10
  39. data/lib/openc3/models/scope_model.rb +60 -42
  40. data/lib/openc3/models/target_model.rb +17 -1
  41. data/lib/openc3/models/timeline_model.rb +17 -5
  42. data/lib/openc3/models/tool_model.rb +15 -3
  43. data/lib/openc3/models/trigger_group_model.rb +6 -3
  44. data/lib/openc3/operators/microservice_operator.rb +8 -0
  45. data/lib/openc3/packets/commands.rb +17 -6
  46. data/lib/openc3/packets/limits.rb +0 -12
  47. data/lib/openc3/packets/packet.rb +1 -1
  48. data/lib/openc3/packets/packet_item.rb +30 -36
  49. data/lib/openc3/packets/structure_item.rb +2 -2
  50. data/lib/openc3/script/script.rb +0 -10
  51. data/lib/openc3/script/web_socket_api.rb +2 -2
  52. data/lib/openc3/streams/mqtt_stream.rb +41 -33
  53. data/lib/openc3/streams/serial_stream.rb +27 -27
  54. data/lib/openc3/streams/stream.rb +17 -17
  55. data/lib/openc3/streams/tcpip_client_stream.rb +1 -1
  56. data/lib/openc3/streams/tcpip_socket_stream.rb +19 -19
  57. data/lib/openc3/system/system.rb +1 -1
  58. data/lib/openc3/system.rb +2 -3
  59. data/lib/openc3/tools/table_manager/table.rb +2 -2
  60. data/lib/openc3/tools/table_manager/table_parser.rb +1 -1
  61. data/lib/openc3/top_level.rb +0 -5
  62. data/lib/openc3/topics/command_decom_topic.rb +0 -7
  63. data/lib/openc3/utilities/bucket_utilities.rb +1 -1
  64. data/lib/openc3/utilities/cli_generator.rb +0 -1
  65. data/lib/openc3/version.rb +6 -6
  66. data/templates/plugin/README.md +1 -1
  67. data/templates/target/targets/TARGET/lib/target.rb +1 -1
  68. data/templates/tool_angular/package.json +8 -8
  69. data/templates/tool_angular/src/app/app.component.html +4 -13
  70. data/templates/tool_angular/src/app/app.component.scss +5 -13
  71. data/templates/tool_angular/src/app/app.component.ts +5 -4
  72. data/templates/tool_angular/src/app/custom-overlay-container.ts +2 -2
  73. data/templates/tool_angular/src/app/openc3-api.d.ts +1 -1
  74. data/templates/tool_angular/src/main.single-spa.ts +1 -1
  75. data/templates/tool_react/package.json +1 -0
  76. data/templates/tool_react/src/root.component.js +1 -1
  77. data/templates/tool_svelte/package.json +11 -9
  78. data/templates/tool_svelte/rollup.config.js +2 -0
  79. data/templates/tool_svelte/src/App.svelte +2 -2
  80. data/templates/tool_vue/eslint.config.mjs +68 -0
  81. data/templates/tool_vue/jsconfig.json +1 -1
  82. data/templates/tool_vue/package.json +26 -43
  83. data/templates/tool_vue/src/App.vue +3 -5
  84. data/templates/tool_vue/src/main.js +12 -23
  85. data/templates/tool_vue/src/router.js +19 -18
  86. data/templates/tool_vue/src/tools/tool_name/tool_name.vue +2 -2
  87. data/templates/tool_vue/vite.config.js +52 -0
  88. data/templates/widget/package.json +19 -26
  89. data/templates/widget/src/Widget.vue +13 -15
  90. data/templates/widget/vite.config.js +26 -0
  91. metadata +10 -41
  92. data/lib/openc3/core_ext/hash.rb +0 -40
  93. data/lib/openc3/core_ext/httpclient.rb +0 -11
  94. data/lib/openc3/interfaces/linc_interface.rb +0 -480
  95. data/lib/openc3/interfaces/protocols/override_protocol.rb +0 -4
  96. data/lib/openc3/microservices/critical_cmd_microservice.rb +0 -74
  97. data/lib/openc3/microservices/reaction_microservice.rb +0 -607
  98. data/lib/openc3/microservices/timeline_microservice.rb +0 -398
  99. data/lib/openc3/microservices/trigger_group_microservice.rb +0 -698
  100. data/lib/openc3/migrations/20230615000000_autonomic.rb +0 -86
  101. data/lib/openc3/migrations/20240915000000_activity_uuid.rb +0 -28
  102. data/lib/openc3/migrations/20241016000000_scope_critical_cmd.rb +0 -24
  103. data/lib/openc3/system/system_config.rb +0 -413
  104. data/templates/tool_svelte/src/services/api.js +0 -92
  105. data/templates/tool_svelte/src/services/axios.js +0 -85
  106. data/templates/tool_svelte/src/services/cable.js +0 -65
  107. data/templates/tool_svelte/src/services/config-parser.js +0 -198
  108. data/templates/tool_svelte/src/services/openc3-api.js +0 -606
  109. data/templates/tool_vue/.eslintrc.js +0 -43
  110. data/templates/tool_vue/babel.config.json +0 -11
  111. data/templates/tool_vue/vue.config.js +0 -38
  112. data/templates/widget/.eslintrc.js +0 -43
  113. data/templates/widget/babel.config.json +0 -11
  114. data/templates/widget/vue.config.js +0 -28
  115. /data/templates/tool_vue/{.prettierrc.js → .prettierrc.cjs} +0 -0
  116. /data/templates/widget/{.prettierrc.js → .prettierrc.cjs} +0 -0
@@ -31,17 +31,15 @@ require 'openc3/topics/system_events_topic'
31
31
  begin
32
32
  require 'openc3-enterprise/models/cmd_authority_model'
33
33
  require 'openc3-enterprise/models/critical_cmd_model'
34
- rescue LoadError
35
34
  module OpenC3
36
- class CmdAuthorityModel
37
- def self.names(scope:)
38
- []
39
- end
35
+ class ScopeModel < Model
36
+ ENTERPRISE = true
40
37
  end
41
- class CriticalCmdModel
42
- def self.names(scope:)
43
- []
44
- end
38
+ end
39
+ rescue LoadError
40
+ module OpenC3
41
+ class ScopeModel < Model
42
+ ENTERPRISE = false
45
43
  end
46
44
  end
47
45
  end
@@ -58,6 +56,7 @@ module OpenC3
58
56
  attr_accessor :cleanup_poll_time
59
57
  attr_accessor :command_authority
60
58
  attr_accessor :critical_commanding
59
+ attr_accessor :shard
61
60
 
62
61
  # NOTE: The following three class methods are used by the ModelController
63
62
  # and are reimplemented to enable various Model class methods to work
@@ -76,13 +75,13 @@ module OpenC3
76
75
  super(PRIMARY_KEY)
77
76
  end
78
77
 
79
- def self.from_json(json)
78
+ def self.from_json(json, scope: nil)
80
79
  json = JSON.parse(json, :allow_nan => true, :create_additions => true) if String === json
81
80
  raise "json data is nil" if json.nil?
82
81
  self.new(**json.transform_keys(&:to_sym))
83
82
  end
84
83
 
85
- def self.get_model(name:)
84
+ def self.get_model(name:, scope: nil)
86
85
  json = get(name: name)
87
86
  if json
88
87
  return from_json(json)
@@ -99,6 +98,7 @@ module OpenC3
99
98
  cleanup_poll_time: 900,
100
99
  command_authority: false,
101
100
  critical_commanding: "OFF",
101
+ shard: 0,
102
102
  updated_at: nil
103
103
  )
104
104
  super(
@@ -120,6 +120,7 @@ module OpenC3
120
120
  if not ["OFF", "NORMAL", "ALL"].include?(@critical_commanding)
121
121
  raise "Invalid value for critical_commanding: #{@critical_commanding}"
122
122
  end
123
+ @shard = shard.to_i # to_i to handle nil
123
124
  @children = []
124
125
  end
125
126
 
@@ -130,21 +131,23 @@ module OpenC3
130
131
  @scope = @name # Ensure @scope matches @name
131
132
  super(update: update, force: force, queued: queued)
132
133
 
133
- # If we're updating the scope and disabling command_authority
134
- # then we clear out all the existing values so it comes up fresh
135
- if update and @command_authority == false
136
- CmdAuthorityModel.names(scope: @name).each do |auth_name|
137
- model = CmdAuthorityModel.get_model(name: auth_name, scope: @name)
138
- model.destroy if model
134
+ if ENTERPRISE
135
+ # If we're updating the scope and disabling command_authority
136
+ # then we clear out all the existing values so it comes up fresh
137
+ if update and @command_authority == false
138
+ CmdAuthorityModel.names(scope: @name).each do |auth_name|
139
+ model = CmdAuthorityModel.get_model(name: auth_name, scope: @name)
140
+ model.destroy if model
141
+ end
139
142
  end
140
- end
141
143
 
142
- # If we're updating the scope and disabling critical_commanding
143
- # then we clear out all the pending critical commands
144
- if update and @critical_commanding == "OFF"
145
- CriticalCmdModel.names(scope: @name).each do |name|
146
- model = CriticalCmdModel.get_model(name: name, scope: @name)
147
- model.destroy if model
144
+ # If we're updating the scope and disabling critical_commanding
145
+ # then we clear out all the pending critical commands
146
+ if update and @critical_commanding == "OFF"
147
+ CriticalCmdModel.names(scope: @name).each do |name|
148
+ model = CriticalCmdModel.get_model(name: name, scope: @name)
149
+ model.destroy if model
150
+ end
148
151
  end
149
152
  end
150
153
 
@@ -174,6 +177,7 @@ module OpenC3
174
177
  'cleanup_poll_time' => @cleanup_poll_time,
175
178
  'command_authority' => @command_authority,
176
179
  'critical_commanding' => @critical_commanding,
180
+ 'shard' => @shard,
177
181
  }
178
182
  end
179
183
 
@@ -194,6 +198,7 @@ module OpenC3
194
198
  ],
195
199
  topics: topics,
196
200
  parent: parent,
201
+ shard: @shard,
197
202
  scope: @scope
198
203
  )
199
204
  microservice.create
@@ -216,6 +221,7 @@ module OpenC3
216
221
  topics: ["#{@scope}__COMMAND__{UNKNOWN}__UNKNOWN"],
217
222
  target_names: [],
218
223
  parent: parent,
224
+ shard: @shard,
219
225
  scope: @scope
220
226
  )
221
227
  microservice.create
@@ -238,6 +244,7 @@ module OpenC3
238
244
  topics: ["#{@scope}__TELEMETRY__{UNKNOWN}__UNKNOWN"],
239
245
  target_names: [],
240
246
  parent: parent,
247
+ shard: @shard,
241
248
  scope: @scope
242
249
  )
243
250
  microservice.create
@@ -253,6 +260,7 @@ module OpenC3
253
260
  cmd: ["ruby", "periodic_microservice.rb", microservice_name],
254
261
  work_dir: '/openc3/lib/openc3/microservices',
255
262
  parent: parent,
263
+ shard: @shard,
256
264
  scope: @scope
257
265
  )
258
266
  microservice.create
@@ -268,6 +276,7 @@ module OpenC3
268
276
  cmd: ["ruby", "scope_cleanup_microservice.rb", microservice_name],
269
277
  work_dir: '/openc3/lib/openc3/microservices',
270
278
  parent: parent,
279
+ shard: @shard,
271
280
  scope: @scope
272
281
  )
273
282
  microservice.create
@@ -281,8 +290,9 @@ module OpenC3
281
290
  microservice = MicroserviceModel.new(
282
291
  name: microservice_name,
283
292
  cmd: ["ruby", "critical_cmd_microservice.rb", microservice_name],
284
- work_dir: '/openc3/lib/openc3/microservices',
293
+ work_dir: '/openc3-enterprise/lib/openc3-enterprise/microservices',
285
294
  parent: parent,
295
+ shard: @shard,
286
296
  scope: @scope
287
297
  )
288
298
  microservice.create
@@ -298,6 +308,7 @@ module OpenC3
298
308
  cmd: ["ruby", "multi_microservice.rb", *@children],
299
309
  work_dir: '/openc3/lib/openc3/microservices',
300
310
  target_names: [],
311
+ shard: @shard,
301
312
  scope: @scope
302
313
  )
303
314
  microservice.create
@@ -308,16 +319,18 @@ module OpenC3
308
319
  def deploy(gem_path, variables)
309
320
  seed_database()
310
321
 
311
- # Create DEFAULT trigger group model
312
- model = TriggerGroupModel.get(name: 'DEFAULT', scope: @scope)
313
- unless model
314
- model = TriggerGroupModel.new(name: 'DEFAULT', scope: @scope)
315
- model.create()
316
- model.deploy()
322
+ if ENTERPRISE
323
+ # Create DEFAULT trigger group model
324
+ model = TriggerGroupModel.get(name: 'DEFAULT', scope: @scope)
325
+ unless model
326
+ model = TriggerGroupModel.new(name: 'DEFAULT', shard: @shard, scope: @scope)
327
+ model.create()
328
+ model.deploy()
329
+ end
317
330
  end
318
331
 
319
332
  # Create UNKNOWN target for display of unknown data
320
- model = TargetModel.new(name: "UNKNOWN", scope: @scope)
333
+ model = TargetModel.new(name: "UNKNOWN", shard: @shard, scope: @scope)
321
334
  model.create
322
335
 
323
336
  @parent = "#{@scope}__SCOPEMULTI__#{@scope}"
@@ -337,8 +350,10 @@ module OpenC3
337
350
  # Scope Cleanup Microservice
338
351
  deploy_scopecleanup_microservice(gem_path, variables, @parent)
339
352
 
340
- # Critical Cmd Microservice
341
- deploy_critical_cmd_microservice(gem_path, variables, @parent)
353
+ if ENTERPRISE
354
+ # Critical Cmd Microservice
355
+ deploy_critical_cmd_microservice(gem_path, variables, @parent)
356
+ end
342
357
 
343
358
  # Multi Microservice to parent other scope microservices
344
359
  deploy_scopemulti_microservice(gem_path, variables)
@@ -361,27 +376,30 @@ module OpenC3
361
376
  model.destroy if model
362
377
  model = MicroserviceModel.get_model(name: "#{@scope}__PERIODIC__#{@scope}", scope: @scope)
363
378
  model.destroy if model
364
- model = MicroserviceModel.get_model(name: "#{@scope}__TRIGGER_GROUP__DEFAULT", scope: @scope)
365
- model.destroy if model
366
- model = MicroserviceModel.get_model(name: "#{@scope}__CRITICALCMD__#{@scope}", scope: @scope)
367
- model.destroy if model
379
+ if ENTERPRISE
380
+ model = MicroserviceModel.get_model(name: "#{@scope}__TRIGGER_GROUP__DEFAULT", scope: @scope)
381
+ model.destroy if model
382
+ model = MicroserviceModel.get_model(name: "#{@scope}__CRITICALCMD__#{@scope}", scope: @scope)
383
+ model.destroy if model
384
+
385
+ Topic.del("#{@scope}__openc3_autonomic")
386
+ Topic.del("#{@scope}__TRIGGER__GROUP")
387
+ end
368
388
 
369
389
  # Delete the topics we created for the scope
370
390
  Topic.del("#{@scope}__COMMAND__{UNKNOWN}__UNKNOWN")
371
391
  Topic.del("#{@scope}__TELEMETRY__{UNKNOWN}__UNKNOWN")
372
392
  Topic.del("#{@scope}__openc3_targets")
373
393
  Topic.del("#{@scope}__CONFIG")
374
- Topic.del("#{@scope}__openc3_autonomic")
375
- Topic.del("#{@scope}__TRIGGER__GROUP")
376
394
  end
377
395
 
378
396
  def seed_database
379
397
  setting = SettingModel.get(name: 'source_url')
380
398
  SettingModel.set({ name: 'source_url', data: 'https://github.com/OpenC3/cosmos' }, scope: @scope) unless setting
381
399
  setting = SettingModel.get(name: 'rubygems_url')
382
- SettingModel.set({ name: 'rubygems_url', data: 'https://rubygems.org' }, scope: @scope) unless setting
400
+ SettingModel.set({ name: 'rubygems_url', data: ENV['RUBYGEMS_URL'] || 'https://rubygems.org' }, scope: @scope) unless setting
383
401
  setting = SettingModel.get(name: 'pypi_url')
384
- SettingModel.set({ name: 'pypi_url', data: 'https://pypi.org' }, scope: @scope) unless setting
402
+ SettingModel.set({ name: 'pypi_url', data: ENV['PYPI_URL'] || 'https://pypi.org' }, scope: @scope) unless setting
385
403
  end
386
404
  end
387
405
  end
@@ -80,6 +80,7 @@ module OpenC3
80
80
  attr_accessor :target_microservices
81
81
  attr_accessor :children
82
82
  attr_accessor :disable_erb
83
+ attr_accessor :shard
83
84
 
84
85
  # NOTE: The following three class methods are used by the ModelController
85
86
  # and are reimplemented to enable various Model class methods to work
@@ -345,6 +346,7 @@ module OpenC3
345
346
  reducer_disable: false,
346
347
  reducer_max_cpu_utilization: 30.0,
347
348
  disable_erb: nil,
349
+ shard: 0,
348
350
  scope:
349
351
  )
350
352
  super("#{scope}__#{PRIMARY_KEY}", name: name, plugin: plugin, updated_at: updated_at,
@@ -393,6 +395,7 @@ module OpenC3
393
395
  @reducer_disable = reducer_disable
394
396
  @reducer_max_cpu_utilization = reducer_max_cpu_utilization
395
397
  @disable_erb = disable_erb
398
+ @shard = shard.to_i # to_i to handle nil
396
399
  @bucket = Bucket.getClient()
397
400
  @children = []
398
401
  end
@@ -433,7 +436,8 @@ module OpenC3
433
436
  'target_microservices' => @target_microservices.as_json(:allow_nan => true),
434
437
  'reducer_disable' => @reducer_disable,
435
438
  'reducer_max_cpu_utilization' => @reducer_max_cpu_utilization,
436
- 'disable_erb' => @disable_erb
439
+ 'disable_erb' => @disable_erb,
440
+ 'shard' => @shard,
437
441
  }
438
442
  end
439
443
 
@@ -548,6 +552,10 @@ module OpenC3
548
552
  if parameters
549
553
  @disable_erb.concat(parameters)
550
554
  end
555
+ when 'SHARD'
556
+ parser.verify_num_parameters(1, 1, "#{keyword} <Shard Number Starting from 0>")
557
+ @shard = Integer(parameters[0])
558
+
551
559
  else
552
560
  raise ConfigParser::Error.new(parser, "Unknown keyword and parameters for Target: #{keyword} #{parameters.join(" ")}")
553
561
  end
@@ -922,6 +930,7 @@ module OpenC3
922
930
  plugin: @plugin,
923
931
  parent: parent,
924
932
  needs_dependencies: @needs_dependencies,
933
+ shard: @shard,
925
934
  scope: @scope
926
935
  )
927
936
  microservice.create
@@ -948,6 +957,7 @@ module OpenC3
948
957
  plugin: @plugin,
949
958
  parent: parent,
950
959
  needs_dependencies: @needs_dependencies,
960
+ shard: @shard,
951
961
  scope: @scope
952
962
  )
953
963
  microservice.create
@@ -974,6 +984,7 @@ module OpenC3
974
984
  plugin: @plugin,
975
985
  parent: parent,
976
986
  needs_dependencies: @needs_dependencies,
987
+ shard: @shard,
977
988
  scope: @scope
978
989
  )
979
990
  microservice.create
@@ -1000,6 +1011,7 @@ module OpenC3
1000
1011
  plugin: @plugin,
1001
1012
  parent: parent,
1002
1013
  needs_dependencies: @needs_dependencies,
1014
+ shard: @shard,
1003
1015
  scope: @scope
1004
1016
  )
1005
1017
  microservice.create
@@ -1028,6 +1040,7 @@ module OpenC3
1028
1040
  plugin: @plugin,
1029
1041
  parent: parent,
1030
1042
  needs_dependencies: @needs_dependencies,
1043
+ shard: @shard,
1031
1044
  scope: @scope
1032
1045
  )
1033
1046
  microservice.create
@@ -1051,6 +1064,7 @@ module OpenC3
1051
1064
  plugin: @plugin,
1052
1065
  parent: parent,
1053
1066
  needs_dependencies: @needs_dependencies,
1067
+ shard: @shard,
1054
1068
  scope: @scope
1055
1069
  )
1056
1070
  microservice.create
@@ -1067,6 +1081,7 @@ module OpenC3
1067
1081
  work_dir: '/openc3/lib/openc3/microservices',
1068
1082
  plugin: @plugin,
1069
1083
  parent: parent,
1084
+ shard: @shard,
1070
1085
  scope: @scope
1071
1086
  )
1072
1087
  microservice.create
@@ -1084,6 +1099,7 @@ module OpenC3
1084
1099
  work_dir: '/openc3/lib/openc3/microservices',
1085
1100
  plugin: @plugin,
1086
1101
  needs_dependencies: @needs_dependencies,
1102
+ shard: @shard,
1087
1103
  scope: @scope
1088
1104
  )
1089
1105
  microservice.create
@@ -14,7 +14,7 @@
14
14
  # GNU Affero General Public License for more details.
15
15
 
16
16
  # Modified by OpenC3, Inc.
17
- # All changes Copyright 2022, OpenC3, Inc.
17
+ # All changes Copyright 2024, OpenC3, Inc.
18
18
  # All Rights Reserved
19
19
  #
20
20
  # This file may also be used under the terms of a commercial license
@@ -24,6 +24,7 @@ require 'openc3/models/model'
24
24
  require 'openc3/models/activity_model'
25
25
  require 'openc3/models/microservice_model'
26
26
  require 'openc3/topics/timeline_topic'
27
+ require 'openc3/config/config_parser'
27
28
 
28
29
  module OpenC3
29
30
  class TimelineError < StandardError; end
@@ -31,6 +32,8 @@ module OpenC3
31
32
  class TimelineInputError < TimelineError; end
32
33
 
33
34
  class TimelineModel < Model
35
+ attr_reader :execute
36
+
34
37
  PRIMARY_KEY = 'openc3_timelines'.freeze # MUST be equal to ActivityModel::PRIMARY_KEY without leading __
35
38
  KEY = '__TIMELINE__'.freeze
36
39
 
@@ -74,7 +77,7 @@ module OpenC3
74
77
  self.new(**json.transform_keys(&:to_sym), name: name, scope: scope)
75
78
  end
76
79
 
77
- def initialize(name:, scope:, updated_at: nil, color: nil)
80
+ def initialize(name:, scope:, updated_at: nil, color: nil, shard: 0, execute: true)
78
81
  if name.nil? || scope.nil?
79
82
  raise TimelineInputError.new "name or scope must not be nil"
80
83
  end
@@ -82,10 +85,12 @@ module OpenC3
82
85
  super(PRIMARY_KEY, name: "#{scope}#{KEY}#{name}", scope: scope)
83
86
  @updated_at = updated_at
84
87
  @timeline_name = name
85
- update_color(color: color)
88
+ @shard = shard.to_i # to_i to handle nil
89
+ self.color = color
90
+ self.execute = execute
86
91
  end
87
92
 
88
- def update_color(color: nil)
93
+ def color=(color)
89
94
  if color.nil?
90
95
  color = '#%06x' % (rand * 0xffffff)
91
96
  end
@@ -99,11 +104,17 @@ module OpenC3
99
104
  @color = color
100
105
  end
101
106
 
107
+ def execute=(value)
108
+ @execute = ConfigParser.handle_true_false(value)
109
+ end
110
+
102
111
  # @return [Hash] generated from the TimelineModel
103
112
  def as_json(*a)
104
113
  {
105
114
  'name' => @timeline_name,
106
115
  'color' => @color,
116
+ 'execute' => @execute,
117
+ 'shard' => @shard,
107
118
  'scope' => @scope,
108
119
  'updated_at' => @updated_at
109
120
  }
@@ -131,11 +142,12 @@ module OpenC3
131
142
  name: @name,
132
143
  folder_name: nil,
133
144
  cmd: ['ruby', 'timeline_microservice.rb', @name],
134
- work_dir: '/openc3/lib/openc3/microservices',
145
+ work_dir: '/openc3-enterprise/lib/openc3-enterprise/microservices',
135
146
  options: [],
136
147
  topics: topics,
137
148
  target_names: [],
138
149
  plugin: nil,
150
+ shard: @shard,
139
151
  scope: @scope
140
152
  )
141
153
  microservice.create
@@ -40,6 +40,7 @@ module OpenC3
40
40
  attr_accessor :position
41
41
  attr_accessor :needs_dependencies
42
42
  attr_accessor :disable_erb
43
+ attr_accessor :import_map_items
43
44
 
44
45
  # NOTE: The following three class methods are used by the ModelController
45
46
  # and are reimplemented to enable various Model class methods to work
@@ -126,7 +127,7 @@ module OpenC3
126
127
  def initialize(
127
128
  name:,
128
129
  folder_name: nil,
129
- icon: '$astro-caution',
130
+ icon: 'astro:warning',
130
131
  url: nil,
131
132
  inline_url: nil,
132
133
  window: 'INLINE',
@@ -137,6 +138,7 @@ module OpenC3
137
138
  plugin: nil,
138
139
  needs_dependencies: false,
139
140
  disable_erb: nil,
141
+ import_map_items: nil,
140
142
  scope:
141
143
  )
142
144
  super("#{scope}__#{PRIMARY_KEY}", name: name, plugin: plugin, updated_at: updated_at, scope: scope)
@@ -150,11 +152,12 @@ module OpenC3
150
152
  @position = position
151
153
 
152
154
  if @shown and @window == 'INLINE'
153
- @inline_url = 'js/app.js' unless @inline_url
155
+ @inline_url = 'main.js' unless @inline_url
154
156
  @url = "/tools/#{folder_name}" unless @url
155
157
  end
156
158
  @needs_dependencies = needs_dependencies
157
159
  @disable_erb = disable_erb
160
+ @import_map_items = import_map_items
158
161
  end
159
162
 
160
163
  def create(update: false, force: false, queued: false)
@@ -181,6 +184,10 @@ module OpenC3
181
184
  end
182
185
  end
183
186
 
187
+ if @url and !@url.start_with?('/') and !@url.start_with?('http')
188
+ raise "URL must be a full URL (http://domain.com/path) or a relative path (/path)"
189
+ end
190
+
184
191
  super(update: update, force: force, queued: queued)
185
192
  end
186
193
 
@@ -198,7 +205,8 @@ module OpenC3
198
205
  'updated_at' => @updated_at,
199
206
  'plugin' => @plugin,
200
207
  'needs_dependencies' => @needs_dependencies,
201
- 'disable_erb' => @disable_erb
208
+ 'disable_erb' => @disable_erb,
209
+ 'import_map_items' => @import_map_items,
202
210
  }
203
211
  end
204
212
 
@@ -232,6 +240,10 @@ module OpenC3
232
240
  if parameters
233
241
  @disable_erb.concat(parameters)
234
242
  end
243
+ when 'IMPORT_MAP_ITEM'
244
+ parser.verify_num_parameters(2, 2, "IMPORT_MAP_ITEM <key> <value>")
245
+ @import_map_items ||= []
246
+ @import_map_items << [parameters[0], parameters[1]]
235
247
  else
236
248
  raise ConfigParser::Error.new(parser, "Unknown keyword and parameters for Tool: #{keyword} #{parameters.join(" ")}")
237
249
  end
@@ -64,9 +64,9 @@ module OpenC3
64
64
  end
65
65
  end
66
66
 
67
- attr_reader :name, :scope, :updated_at
67
+ attr_reader :name, :scope, :shard, :updated_at
68
68
 
69
- def initialize(name:, scope:, updated_at: nil)
69
+ def initialize(name:, scope:, shard: 0, updated_at: nil)
70
70
  unless name.is_a?(String)
71
71
  raise TriggerGroupInputError.new "invalid group name: '#{name}'"
72
72
  end
@@ -75,6 +75,7 @@ module OpenC3
75
75
  end
76
76
  super("#{scope}#{PRIMARY_KEY}", name: name, scope: scope)
77
77
  @microservice_name = "#{scope}__TRIGGER_GROUP__#{name}"
78
+ @shard = shard.to_i # to_i to handle nil
78
79
  @updated_at = updated_at
79
80
  end
80
81
 
@@ -93,6 +94,7 @@ module OpenC3
93
94
  return {
94
95
  'name' => @name,
95
96
  'scope' => @scope,
97
+ 'shard' => @shard,
96
98
  'updated_at' => @updated_at,
97
99
  }
98
100
  end
@@ -122,11 +124,12 @@ module OpenC3
122
124
  name: @microservice_name,
123
125
  folder_name: nil,
124
126
  cmd: ['ruby', "trigger_group_microservice.rb", @microservice_name],
125
- work_dir: '/openc3/lib/openc3/microservices',
127
+ work_dir: '/openc3-enterprise/lib/openc3-enterprise/microservices',
126
128
  options: [],
127
129
  topics: topics,
128
130
  target_names: [],
129
131
  plugin: nil,
132
+ shard: @shard,
130
133
  scope: @scope
131
134
  )
132
135
  microservice.create
@@ -42,6 +42,8 @@ module OpenC3
42
42
  @new_microservices = {}
43
43
  @changed_microservices = {}
44
44
  @removed_microservices = {}
45
+ @shard = ENV['OPENC3_SHARD'] || 0
46
+ @shard = @shard.to_i
45
47
  end
46
48
 
47
49
  def convert_microservice_to_process_definition(microservice_name, microservice_config)
@@ -87,6 +89,12 @@ module OpenC3
87
89
  # Get all the microservice configuration
88
90
  @microservices = MicroserviceModel.all
89
91
 
92
+ # Filter to just this shard
93
+ @microservices = @microservices.select do |microservice_name, microservice_config|
94
+ microservice_shard = microservice_config['shard'] || 0
95
+ microservice_shard == @shard
96
+ end
97
+
90
98
  # Detect new and changed microservices
91
99
  @new_microservices = {}
92
100
  @changed_microservices = {}
@@ -14,7 +14,7 @@
14
14
  # GNU Affero General Public License for more details.
15
15
 
16
16
  # Modified by OpenC3, Inc.
17
- # All changes Copyright 2022, OpenC3, Inc.
17
+ # All changes Copyright 2024, OpenC3, Inc.
18
18
  # All Rights Reserved
19
19
  #
20
20
  # This file may also be used under the terms of a commercial license
@@ -308,12 +308,23 @@ module OpenC3
308
308
  item = command.get_item(item_upcase)
309
309
  range_check_value = value
310
310
 
311
- # Convert from state to value if possible
312
- if item.states and item.states[value.to_s.upcase]
313
- range_check_value = item.states[value.to_s.upcase]
314
- end
315
-
316
311
  if range_checking
312
+ if item.states
313
+ if item.states[value.to_s.upcase]
314
+ range_check_value = item.states[value.to_s.upcase]
315
+ else
316
+ unless item.states.values.include?(value)
317
+ if command.raw
318
+ # Raw commands report missing value maps
319
+ raise "Command parameter '#{command.target_name} #{command.packet_name} #{item_upcase}' = #{value.to_s.upcase} not one of #{item.states.values.join(', ')}"
320
+ else
321
+ # Normal commands report missing state maps
322
+ raise "Command parameter '#{command.target_name} #{command.packet_name} #{item_upcase}' = #{value.to_s.upcase} not one of #{item.states.keys.join(', ')}"
323
+ end
324
+ end
325
+ end
326
+ end
327
+
317
328
  range = item.range
318
329
  if range
319
330
  # Perform Range Check on command parameter
@@ -50,18 +50,6 @@ module OpenC3
50
50
  return @config.limits_sets
51
51
  end
52
52
 
53
- # (see OpenC3::Packet#out_of_limits)
54
- def out_of_limits
55
- items = []
56
- @config.telemetry.each do |target_name, target_packets|
57
- target_packets.each do |packet_name, packet|
58
- new_items = packet.out_of_limits
59
- items.concat(new_items)
60
- end
61
- end
62
- return items
63
- end
64
-
65
53
  # @return [Hash(String, Array)] The defined limits groups
66
54
  def groups
67
55
  return @config.limits_groups
@@ -756,7 +756,7 @@ module OpenC3
756
756
  super(item, value, :RAW, buffer)
757
757
  rescue ArgumentError => e
758
758
  if item.states and String === value and e.message =~ /invalid value for/
759
- raise "Unknown state #{value} for #{item.name}"
759
+ raise "Unknown state #{value} for #{item.name}, must be one of #{item.states.keys.join(', ')}"
760
760
  else
761
761
  raise e
762
762
  end