openc3 5.19.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -7
  3. data/bin/openc3cli +12 -120
  4. data/bin/pipinstall +5 -3
  5. data/data/config/command_modifiers.yaml +17 -1
  6. data/data/config/interface_modifiers.yaml +21 -4
  7. data/data/config/item_modifiers.yaml +1 -1
  8. data/data/config/microservice.yaml +15 -2
  9. data/data/config/param_item_modifiers.yaml +1 -1
  10. data/data/config/parameter_modifiers.yaml +1 -1
  11. data/data/config/table_manager.yaml +2 -2
  12. data/data/config/target.yaml +11 -0
  13. data/data/config/telemetry_modifiers.yaml +17 -1
  14. data/data/config/tool.yaml +12 -0
  15. data/data/config/widgets.yaml +41 -17
  16. data/ext/openc3/ext/packet/packet.c +3 -0
  17. data/lib/openc3/accessors/form_accessor.rb +4 -3
  18. data/lib/openc3/accessors/html_accessor.rb +3 -3
  19. data/lib/openc3/accessors/http_accessor.rb +13 -13
  20. data/lib/openc3/accessors/xml_accessor.rb +16 -4
  21. data/lib/openc3/api/cmd_api.rb +4 -5
  22. data/lib/openc3/api/limits_api.rb +3 -3
  23. data/lib/openc3/api/target_api.rb +0 -30
  24. data/lib/openc3/api/tlm_api.rb +2 -1
  25. data/lib/openc3/bridge/bridge_config.rb +1 -2
  26. data/lib/openc3/ccsds/ccsds_parser.rb +12 -8
  27. data/lib/openc3/config/config_parser.rb +10 -3
  28. data/lib/openc3/conversions/bit_reverse_conversion.rb +1 -0
  29. data/lib/openc3/conversions/conversion.rb +5 -1
  30. data/lib/openc3/conversions/generic_conversion.rb +3 -8
  31. data/lib/openc3/conversions/object_read_conversion.rb +1 -8
  32. data/lib/openc3/conversions/polynomial_conversion.rb +3 -8
  33. data/lib/openc3/conversions/processor_conversion.rb +13 -11
  34. data/lib/openc3/conversions/segmented_polynomial_conversion.rb +3 -11
  35. data/lib/openc3/conversions/unix_time_conversion.rb +4 -7
  36. data/lib/openc3/conversions/unix_time_formatted_conversion.rb +4 -3
  37. data/lib/openc3/conversions/unix_time_seconds_conversion.rb +4 -3
  38. data/lib/openc3/core_ext/array.rb +0 -16
  39. data/lib/openc3/core_ext.rb +0 -1
  40. data/lib/openc3/interfaces/file_interface.rb +198 -0
  41. data/lib/openc3/interfaces/http_client_interface.rb +71 -39
  42. data/lib/openc3/interfaces/http_server_interface.rb +1 -9
  43. data/lib/openc3/interfaces/interface.rb +3 -2
  44. data/lib/openc3/interfaces/mqtt_interface.rb +32 -15
  45. data/lib/openc3/interfaces/mqtt_stream_interface.rb +19 -4
  46. data/lib/openc3/interfaces/protocols/crc_protocol.rb +7 -0
  47. data/lib/openc3/interfaces/serial_interface.rb +1 -0
  48. data/lib/openc3/interfaces/tcpip_server_interface.rb +1 -2
  49. data/lib/openc3/interfaces/udp_interface.rb +5 -3
  50. data/lib/openc3/interfaces.rb +2 -4
  51. data/lib/openc3/io/json_drb.rb +5 -0
  52. data/lib/openc3/io/json_rpc.rb +10 -9
  53. data/lib/openc3/io/udp_sockets.rb +7 -5
  54. data/lib/openc3/microservices/decom_microservice.rb +24 -7
  55. data/lib/openc3/microservices/interface_microservice.rb +65 -7
  56. data/lib/openc3/microservices/microservice.rb +1 -2
  57. data/lib/openc3/microservices/multi_microservice.rb +3 -3
  58. data/lib/openc3/migrations/20241208080000_no_critical_cmd.rb +31 -0
  59. data/lib/openc3/migrations/20241208080001_no_trigger_group.rb +46 -0
  60. data/lib/openc3/models/activity_model.rb +7 -3
  61. data/lib/openc3/models/cvt_model.rb +7 -1
  62. data/lib/openc3/models/interface_model.rb +9 -3
  63. data/lib/openc3/models/microservice_model.rb +8 -1
  64. data/lib/openc3/models/model.rb +1 -0
  65. data/lib/openc3/models/plugin_model.rb +11 -6
  66. data/lib/openc3/models/python_package_model.rb +10 -3
  67. data/lib/openc3/models/reaction_model.rb +14 -10
  68. data/lib/openc3/models/scope_model.rb +87 -25
  69. data/lib/openc3/models/target_model.rb +17 -1
  70. data/lib/openc3/models/timeline_model.rb +17 -5
  71. data/lib/openc3/models/tool_model.rb +15 -3
  72. data/lib/openc3/models/trigger_group_model.rb +6 -3
  73. data/lib/openc3/operators/microservice_operator.rb +10 -3
  74. data/lib/openc3/packets/commands.rb +17 -6
  75. data/lib/openc3/packets/limits.rb +0 -12
  76. data/lib/openc3/packets/packet.rb +10 -1
  77. data/lib/openc3/packets/packet_config.rb +34 -1
  78. data/lib/openc3/packets/packet_item.rb +30 -32
  79. data/lib/openc3/packets/structure_item.rb +2 -2
  80. data/lib/openc3/script/calendar.rb +1 -6
  81. data/lib/openc3/script/commands.rb +19 -13
  82. data/lib/openc3/script/critical_cmd.rb +91 -0
  83. data/lib/openc3/script/screen.rb +2 -2
  84. data/lib/openc3/script/script.rb +17 -10
  85. data/lib/openc3/script/web_socket_api.rb +5 -5
  86. data/lib/openc3/streams/mqtt_stream.rb +41 -33
  87. data/lib/openc3/streams/serial_stream.rb +27 -27
  88. data/lib/openc3/streams/stream.rb +17 -17
  89. data/lib/openc3/streams/tcpip_client_stream.rb +1 -1
  90. data/lib/openc3/streams/tcpip_socket_stream.rb +19 -19
  91. data/lib/openc3/system/system.rb +1 -1
  92. data/lib/openc3/system.rb +2 -3
  93. data/lib/openc3/tools/table_manager/table.rb +2 -2
  94. data/lib/openc3/tools/table_manager/table_parser.rb +1 -1
  95. data/lib/openc3/top_level.rb +9 -5
  96. data/lib/openc3/topics/command_decom_topic.rb +0 -7
  97. data/lib/openc3/topics/command_topic.rb +16 -0
  98. data/lib/openc3/topics/interface_topic.rb +2 -0
  99. data/lib/openc3/utilities/authentication.rb +7 -3
  100. data/lib/openc3/utilities/bucket_utilities.rb +1 -1
  101. data/lib/openc3/utilities/cli_generator.rb +0 -1
  102. data/lib/openc3/utilities/logger.rb +1 -0
  103. data/lib/openc3/utilities/store_queued.rb +1 -0
  104. data/lib/openc3/version.rb +6 -6
  105. data/templates/conversion/conversion.rb +2 -0
  106. data/templates/plugin/README.md +1 -1
  107. data/templates/target/targets/TARGET/lib/target.rb +1 -1
  108. data/templates/tool_angular/package.json +9 -9
  109. data/templates/tool_angular/src/app/app.component.html +4 -13
  110. data/templates/tool_angular/src/app/app.component.scss +5 -13
  111. data/templates/tool_angular/src/app/app.component.ts +5 -4
  112. data/templates/tool_angular/src/app/custom-overlay-container.ts +2 -2
  113. data/templates/tool_angular/src/app/openc3-api.d.ts +1 -1
  114. data/templates/tool_angular/src/main.single-spa.ts +1 -1
  115. data/templates/tool_react/package.json +1 -0
  116. data/templates/tool_react/src/root.component.js +1 -1
  117. data/templates/tool_svelte/build/smui.css +1 -1
  118. data/templates/tool_svelte/package.json +11 -9
  119. data/templates/tool_svelte/rollup.config.js +2 -0
  120. data/templates/tool_svelte/src/App.svelte +2 -2
  121. data/templates/tool_vue/eslint.config.mjs +68 -0
  122. data/templates/tool_vue/jsconfig.json +1 -1
  123. data/templates/tool_vue/package.json +26 -43
  124. data/templates/tool_vue/src/App.vue +3 -5
  125. data/templates/tool_vue/src/main.js +12 -23
  126. data/templates/tool_vue/src/router.js +19 -18
  127. data/templates/tool_vue/src/tools/tool_name/tool_name.vue +2 -2
  128. data/templates/tool_vue/vite.config.js +52 -0
  129. data/templates/widget/package.json +19 -26
  130. data/templates/widget/src/Widget.vue +13 -15
  131. data/templates/widget/vite.config.js +26 -0
  132. metadata +25 -39
  133. data/lib/openc3/core_ext/hash.rb +0 -40
  134. data/lib/openc3/core_ext/httpclient.rb +0 -11
  135. data/lib/openc3/interfaces/linc_interface.rb +0 -480
  136. data/lib/openc3/interfaces/protocols/override_protocol.rb +0 -4
  137. data/lib/openc3/microservices/reaction_microservice.rb +0 -607
  138. data/lib/openc3/microservices/timeline_microservice.rb +0 -400
  139. data/lib/openc3/microservices/trigger_group_microservice.rb +0 -698
  140. data/lib/openc3/migrations/20230615000000_autonomic.rb +0 -86
  141. data/lib/openc3/migrations/20240915000000_activity_uuid.rb +0 -28
  142. data/lib/openc3/system/system_config.rb +0 -413
  143. data/templates/tool_svelte/src/services/api.js +0 -92
  144. data/templates/tool_svelte/src/services/axios.js +0 -85
  145. data/templates/tool_svelte/src/services/cable.js +0 -65
  146. data/templates/tool_svelte/src/services/config-parser.js +0 -198
  147. data/templates/tool_svelte/src/services/openc3-api.js +0 -606
  148. data/templates/tool_vue/.eslintrc.js +0 -43
  149. data/templates/tool_vue/babel.config.json +0 -11
  150. data/templates/tool_vue/vue.config.js +0 -38
  151. data/templates/widget/.eslintrc.js +0 -43
  152. data/templates/widget/babel.config.json +0 -11
  153. data/templates/widget/vue.config.js +0 -28
  154. /data/templates/tool_vue/{.prettierrc.js → .prettierrc.cjs} +0 -0
  155. /data/templates/widget/{.prettierrc.js → .prettierrc.cjs} +0 -0
@@ -49,6 +49,7 @@ module OpenC3
49
49
  PRIMARY_KEY = 'openc3_plugins'
50
50
  # Reserved VARIABLE names. See local_mode.rb: update_local_plugin()
51
51
  RESERVED_VARIABLE_NAMES = ['target_name', 'microservice_name', 'scope']
52
+ PLUGIN_TXT = 'plugin.txt'
52
53
 
53
54
  attr_accessor :variables
54
55
  attr_accessor :plugin_txt_lines
@@ -90,14 +91,14 @@ module OpenC3
90
91
  # This is only used in openc3cli load when everything is known
91
92
  plugin_txt_lines = existing_plugin_txt_lines
92
93
  file_data = existing_plugin_txt_lines.join("\n")
93
- tf = Tempfile.new("plugin.txt")
94
+ tf = Tempfile.new(PLUGIN_TXT)
94
95
  tf.write(file_data)
95
96
  tf.close
96
97
  plugin_txt_path = tf.path
97
98
  else
98
99
  # Otherwise we always process the new and return both
99
100
  pkg.extract_files(temp_dir)
100
- plugin_txt_path = File.join(temp_dir, 'plugin.txt')
101
+ plugin_txt_path = File.join(temp_dir, PLUGIN_TXT)
101
102
  plugin_text = File.read(plugin_txt_path)
102
103
  plugin_txt_lines = []
103
104
  plugin_text.each_line do |line|
@@ -113,8 +114,7 @@ module OpenC3
113
114
  false,
114
115
  true,
115
116
  false) do |keyword, params|
116
- case keyword
117
- when 'VARIABLE'
117
+ if keyword == 'VARIABLE'
118
118
  usage = "#{keyword} <Variable Name> <Default Value>"
119
119
  parser.verify_num_parameters(2, nil, usage)
120
120
  variable_name = params[0]
@@ -200,7 +200,12 @@ module OpenC3
200
200
  end
201
201
  unless validate_only
202
202
  Logger.info "Installing python packages from requirements.txt with pypi_url=#{pypi_url}"
203
- puts `/openc3/bin/pipinstall --user --no-warn-script-location -i #{pypi_url} -r #{File.join(gem_path, 'requirements.txt')}`
203
+ if ENV['PIP_ENABLE_TRUSTED_HOST'].nil?
204
+ pip_args = "--no-warn-script-location -i #{pypi_url} -r #{File.join(gem_path, 'requirements.txt')}"
205
+ else
206
+ pip_args = "--no-warn-script-location -i #{pypi_url} --trusted-host #{URI.parse(pypi_url).host} -r #{File.join(gem_path, 'requirements.txt')}"
207
+ end
208
+ puts `/openc3/bin/pipinstall #{pip_args}`
204
209
  end
205
210
  needs_dependencies = true
206
211
  end
@@ -229,7 +234,7 @@ module OpenC3
229
234
 
230
235
  # Process plugin.txt file
231
236
  file_data = plugin_hash['plugin_txt_lines'].join("\n")
232
- tf = Tempfile.new("plugin.txt")
237
+ tf = Tempfile.new(PLUGIN_TXT)
233
238
  tf.write(file_data)
234
239
  tf.close
235
240
  plugin_txt_path = tf.path
@@ -29,11 +29,13 @@ module OpenC3
29
29
  class PythonPackageModel
30
30
  extend Api
31
31
 
32
+ DIST_INFO = '.dist-info'
33
+
32
34
  def self.names
33
35
  paths = Dir.glob("#{ENV['PYTHONUSERBASE']}/lib/*")
34
36
  results = []
35
37
  paths.each do |path|
36
- results.concat(Pathname.new(File.join(path, 'site-packages')).children.select { |c| c.directory? and File.extname(c) == '.dist-info' }.collect { |p| File.basename(p, '.dist-info') })
38
+ results.concat(Pathname.new(File.join(path, 'site-packages')).children.select { |c| c.directory? and File.extname(c) == DIST_INFO }.collect { |p| File.basename(p, DIST_INFO) })
37
39
  end
38
40
  return results.sort
39
41
  end
@@ -90,7 +92,12 @@ module OpenC3
90
92
  end
91
93
  end
92
94
  Logger.info "Installing python package: #{name_or_path}"
93
- result = OpenC3::ProcessManager.instance.spawn(["/openc3/bin/pipinstall", "--user", "--no-warn-script-location", "-i", pypi_url, package_file_path], "package_install", package_filename, Time.now + 3600.0, scope: scope)
95
+ if ENV['PIP_ENABLE_TRUSTED_HOST'].nil?
96
+ pip_args = ["--no-warn-script-location", "-i", pypi_url, package_file_path]
97
+ else
98
+ pip_args = ["--no-warn-script-location", "-i", pypi_url, "--trusted-host", URI.parse(pypi_url).host, package_file_path]
99
+ end
100
+ result = OpenC3::ProcessManager.instance.spawn(["/openc3/bin/pipinstall"] + pip_args, "package_install", package_filename, Time.now + 3600.0, scope: scope)
94
101
  return result.name
95
102
  end
96
103
 
@@ -105,7 +112,7 @@ module OpenC3
105
112
  split_name = name.split('-')
106
113
  if split_name.length > 1
107
114
  package_name = split_name[0..-2].join('-')
108
- version = File.basename(split_name[-1], '.dist-info')
115
+ version = File.basename(split_name[-1], DIST_INFO)
109
116
  else
110
117
  package_name = name
111
118
  version = "Unknown"
@@ -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
@@ -81,8 +81,8 @@ module OpenC3
81
81
  model.undeploy()
82
82
  end
83
83
 
84
- attr_reader :name, :scope, :snooze, :triggers, :actions, :enabled, :triggerLevel, :snoozed_until
85
- attr_accessor :username
84
+ attr_reader :name, :scope, :snooze, :triggers, :actions, :enabled, :trigger_level, :snoozed_until
85
+ attr_accessor :username, :shard
86
86
 
87
87
  def initialize(
88
88
  name:,
@@ -90,27 +90,29 @@ module OpenC3
90
90
  snooze:,
91
91
  actions:,
92
92
  triggers:,
93
- triggerLevel:,
93
+ trigger_level:,
94
94
  enabled: true,
95
95
  snoozed_until: nil,
96
96
  username: nil,
97
+ shard: 0,
97
98
  updated_at: nil
98
99
  )
99
100
  super("#{scope}#{PRIMARY_KEY}", name: name, scope: scope)
100
101
  @microservice_name = "#{scope}__OPENC3__REACTION"
101
102
  @enabled = enabled
102
103
  @snoozed_until = snoozed_until
103
- @triggerLevel = validate_level(triggerLevel)
104
+ @trigger_level = validate_level(trigger_level)
104
105
  @snooze = validate_snooze(snooze)
105
106
  @actions = validate_actions(actions)
106
107
  @triggers = validate_triggers(triggers)
107
108
  @username = username
109
+ @shard = shard.to_i # to_i to handle nil
108
110
  @updated_at = updated_at
109
111
  end
110
112
 
111
113
  # Modifiers for the reaction_controller update action
112
- def triggerLevel=(triggerLevel)
113
- @triggerLevel = validate_level(triggerLevel)
114
+ def trigger_level=(trigger_level)
115
+ @trigger_level = validate_level(trigger_level)
114
116
  end
115
117
  def snooze=(snooze)
116
118
  @snooze = validate_snooze(snooze)
@@ -127,7 +129,7 @@ module OpenC3
127
129
  when 'EDGE', 'LEVEL'
128
130
  return level
129
131
  else
130
- raise ReactionInputError.new "invalid triggerLevel, must be EDGE or LEVEL: #{level}"
132
+ raise ReactionInputError.new "invalid trigger level, must be EDGE or LEVEL: #{level}"
131
133
  end
132
134
  end
133
135
 
@@ -257,12 +259,13 @@ module OpenC3
257
259
  'name' => @name,
258
260
  'scope' => @scope,
259
261
  'enabled' => @enabled,
260
- 'triggerLevel' => @triggerLevel,
262
+ 'trigger_level' => @trigger_level,
261
263
  'snooze' => @snooze,
262
264
  'snoozed_until' => @snoozed_until,
263
265
  'triggers' => @triggers,
264
266
  'actions' => @actions,
265
267
  'username' => @username,
268
+ 'shard' => @shard,
266
269
  'updated_at' => @updated_at
267
270
  }
268
271
  end
@@ -290,11 +293,12 @@ module OpenC3
290
293
  name: @microservice_name,
291
294
  folder_name: nil,
292
295
  cmd: ['ruby', 'reaction_microservice.rb', @microservice_name],
293
- work_dir: '/openc3/lib/openc3/microservices',
296
+ work_dir: '/openc3-enterprise/lib/openc3-enterprise/microservices',
294
297
  options: [],
295
298
  topics: topics,
296
299
  target_names: [],
297
300
  plugin: nil,
301
+ shard: @shard,
298
302
  scope: @scope
299
303
  )
300
304
  microservice.create
@@ -30,11 +30,16 @@ require 'openc3/topics/system_events_topic'
30
30
 
31
31
  begin
32
32
  require 'openc3-enterprise/models/cmd_authority_model'
33
+ require 'openc3-enterprise/models/critical_cmd_model'
34
+ module OpenC3
35
+ class ScopeModel < Model
36
+ ENTERPRISE = true
37
+ end
38
+ end
33
39
  rescue LoadError
34
- # Stub out the Enterprise CmdAuthorityModel to do nothing
35
- class CmdAuthorityModel
36
- def self.names(scope:)
37
- []
40
+ module OpenC3
41
+ class ScopeModel < Model
42
+ ENTERPRISE = false
38
43
  end
39
44
  end
40
45
  end
@@ -50,6 +55,8 @@ module OpenC3
50
55
  attr_accessor :tool_log_retain_time
51
56
  attr_accessor :cleanup_poll_time
52
57
  attr_accessor :command_authority
58
+ attr_accessor :critical_commanding
59
+ attr_accessor :shard
53
60
 
54
61
  # NOTE: The following three class methods are used by the ModelController
55
62
  # and are reimplemented to enable various Model class methods to work
@@ -68,13 +75,13 @@ module OpenC3
68
75
  super(PRIMARY_KEY)
69
76
  end
70
77
 
71
- def self.from_json(json)
78
+ def self.from_json(json, scope: nil)
72
79
  json = JSON.parse(json, :allow_nan => true, :create_additions => true) if String === json
73
80
  raise "json data is nil" if json.nil?
74
81
  self.new(**json.transform_keys(&:to_sym))
75
82
  end
76
83
 
77
- def self.get_model(name:)
84
+ def self.get_model(name:, scope: nil)
78
85
  json = get(name: name)
79
86
  if json
80
87
  return from_json(json)
@@ -90,6 +97,8 @@ module OpenC3
90
97
  tool_log_retain_time: nil,
91
98
  cleanup_poll_time: 900,
92
99
  command_authority: false,
100
+ critical_commanding: "OFF",
101
+ shard: 0,
93
102
  updated_at: nil
94
103
  )
95
104
  super(
@@ -106,6 +115,12 @@ module OpenC3
106
115
  @tool_log_retain_time = tool_log_retain_time
107
116
  @cleanup_poll_time = cleanup_poll_time
108
117
  @command_authority = command_authority
118
+ @critical_commanding = critical_commanding.to_s.upcase
119
+ @critical_commanding = "OFF" if @critical_commanding.length == 0
120
+ if not ["OFF", "NORMAL", "ALL"].include?(@critical_commanding)
121
+ raise "Invalid value for critical_commanding: #{@critical_commanding}"
122
+ end
123
+ @shard = shard.to_i # to_i to handle nil
109
124
  @children = []
110
125
  end
111
126
 
@@ -116,12 +131,23 @@ module OpenC3
116
131
  @scope = @name # Ensure @scope matches @name
117
132
  super(update: update, force: force, queued: queued)
118
133
 
119
- # If we're updating the scope and disabling command_authority
120
- # then we clear out all the existing values so it comes up fresh
121
- if update and @command_authority == false
122
- CmdAuthorityModel.names(scope: @name).each do |auth_name|
123
- model = CmdAuthorityModel.get_model(name: auth_name, scope: @name)
124
- 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
142
+ end
143
+
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
125
151
  end
126
152
  end
127
153
 
@@ -150,6 +176,8 @@ module OpenC3
150
176
  'tool_log_retain_time' => @tool_log_retain_time,
151
177
  'cleanup_poll_time' => @cleanup_poll_time,
152
178
  'command_authority' => @command_authority,
179
+ 'critical_commanding' => @critical_commanding,
180
+ 'shard' => @shard,
153
181
  }
154
182
  end
155
183
 
@@ -170,6 +198,7 @@ module OpenC3
170
198
  ],
171
199
  topics: topics,
172
200
  parent: parent,
201
+ shard: @shard,
173
202
  scope: @scope
174
203
  )
175
204
  microservice.create
@@ -192,6 +221,7 @@ module OpenC3
192
221
  topics: ["#{@scope}__COMMAND__{UNKNOWN}__UNKNOWN"],
193
222
  target_names: [],
194
223
  parent: parent,
224
+ shard: @shard,
195
225
  scope: @scope
196
226
  )
197
227
  microservice.create
@@ -214,6 +244,7 @@ module OpenC3
214
244
  topics: ["#{@scope}__TELEMETRY__{UNKNOWN}__UNKNOWN"],
215
245
  target_names: [],
216
246
  parent: parent,
247
+ shard: @shard,
217
248
  scope: @scope
218
249
  )
219
250
  microservice.create
@@ -229,6 +260,7 @@ module OpenC3
229
260
  cmd: ["ruby", "periodic_microservice.rb", microservice_name],
230
261
  work_dir: '/openc3/lib/openc3/microservices',
231
262
  parent: parent,
263
+ shard: @shard,
232
264
  scope: @scope
233
265
  )
234
266
  microservice.create
@@ -244,6 +276,23 @@ module OpenC3
244
276
  cmd: ["ruby", "scope_cleanup_microservice.rb", microservice_name],
245
277
  work_dir: '/openc3/lib/openc3/microservices',
246
278
  parent: parent,
279
+ shard: @shard,
280
+ scope: @scope
281
+ )
282
+ microservice.create
283
+ microservice.deploy(gem_path, variables)
284
+ @children << microservice_name if parent
285
+ Logger.info "Configured microservice #{microservice_name}"
286
+ end
287
+
288
+ def deploy_critical_cmd_microservice(gem_path, variables, parent)
289
+ microservice_name = "#{@scope}__CRITICALCMD__#{@scope}"
290
+ microservice = MicroserviceModel.new(
291
+ name: microservice_name,
292
+ cmd: ["ruby", "critical_cmd_microservice.rb", microservice_name],
293
+ work_dir: '/openc3-enterprise/lib/openc3-enterprise/microservices',
294
+ parent: parent,
295
+ shard: @shard,
247
296
  scope: @scope
248
297
  )
249
298
  microservice.create
@@ -259,6 +308,7 @@ module OpenC3
259
308
  cmd: ["ruby", "multi_microservice.rb", *@children],
260
309
  work_dir: '/openc3/lib/openc3/microservices',
261
310
  target_names: [],
311
+ shard: @shard,
262
312
  scope: @scope
263
313
  )
264
314
  microservice.create
@@ -269,16 +319,18 @@ module OpenC3
269
319
  def deploy(gem_path, variables)
270
320
  seed_database()
271
321
 
272
- # Create DEFAULT trigger group model
273
- model = TriggerGroupModel.get(name: 'DEFAULT', scope: @scope)
274
- unless model
275
- model = TriggerGroupModel.new(name: 'DEFAULT', scope: @scope)
276
- model.create()
277
- 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
278
330
  end
279
331
 
280
332
  # Create UNKNOWN target for display of unknown data
281
- model = TargetModel.new(name: "UNKNOWN", scope: @scope)
333
+ model = TargetModel.new(name: "UNKNOWN", shard: @shard, scope: @scope)
282
334
  model.create
283
335
 
284
336
  @parent = "#{@scope}__SCOPEMULTI__#{@scope}"
@@ -298,6 +350,11 @@ module OpenC3
298
350
  # Scope Cleanup Microservice
299
351
  deploy_scopecleanup_microservice(gem_path, variables, @parent)
300
352
 
353
+ if ENTERPRISE
354
+ # Critical Cmd Microservice
355
+ deploy_critical_cmd_microservice(gem_path, variables, @parent)
356
+ end
357
+
301
358
  # Multi Microservice to parent other scope microservices
302
359
  deploy_scopemulti_microservice(gem_path, variables)
303
360
  end
@@ -319,25 +376,30 @@ module OpenC3
319
376
  model.destroy if model
320
377
  model = MicroserviceModel.get_model(name: "#{@scope}__PERIODIC__#{@scope}", scope: @scope)
321
378
  model.destroy if model
322
- model = MicroserviceModel.get_model(name: "#{@scope}__TRIGGER_GROUP__DEFAULT", scope: @scope)
323
- 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
324
388
 
325
389
  # Delete the topics we created for the scope
326
390
  Topic.del("#{@scope}__COMMAND__{UNKNOWN}__UNKNOWN")
327
391
  Topic.del("#{@scope}__TELEMETRY__{UNKNOWN}__UNKNOWN")
328
392
  Topic.del("#{@scope}__openc3_targets")
329
393
  Topic.del("#{@scope}__CONFIG")
330
- Topic.del("#{@scope}__openc3_autonomic")
331
- Topic.del("#{@scope}__TRIGGER__GROUP")
332
394
  end
333
395
 
334
396
  def seed_database
335
397
  setting = SettingModel.get(name: 'source_url')
336
398
  SettingModel.set({ name: 'source_url', data: 'https://github.com/OpenC3/cosmos' }, scope: @scope) unless setting
337
399
  setting = SettingModel.get(name: 'rubygems_url')
338
- 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
339
401
  setting = SettingModel.get(name: 'pypi_url')
340
- 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
341
403
  end
342
404
  end
343
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