openc3 7.5.1 → 7.6.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 (169) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -0
  3. data/bin/openc3cli +82 -5
  4. data/data/config/_params.yaml +3 -0
  5. data/data/config/command_modifiers.yaml +5 -3
  6. data/data/config/default_plugins.yaml +1 -0
  7. data/data/config/interface_modifiers.yaml +17 -1
  8. data/data/config/item_modifiers.yaml +24 -1
  9. data/data/config/microservice.yaml +15 -1
  10. data/data/config/parameter_modifiers.yaml +4 -4
  11. data/data/config/plugins.yaml +511 -3
  12. data/data/config/settings.yaml +17 -0
  13. data/data/config/target.yaml +53 -0
  14. data/data/config/telemetry.yaml +58 -2
  15. data/data/config/widgets.yaml +30 -0
  16. data/lib/openc3/accessors/accessor.rb +14 -2
  17. data/lib/openc3/accessors/binary_accessor.rb +25 -5
  18. data/lib/openc3/api/CLAUDE.md +1 -0
  19. data/lib/openc3/api/api.rb +1 -0
  20. data/lib/openc3/api/cmd_api.rb +9 -1
  21. data/lib/openc3/api/interface_api.rb +7 -2
  22. data/lib/openc3/api/limits_api.rb +93 -41
  23. data/lib/openc3/api/router_api.rb +7 -2
  24. data/lib/openc3/api/settings_api.rb +4 -1
  25. data/lib/openc3/api/shared_resource_api.rb +107 -0
  26. data/lib/openc3/api/tlm_api.rb +10 -0
  27. data/lib/openc3/interfaces/http_client_interface.rb +84 -27
  28. data/lib/openc3/interfaces/protocols/preidentified_protocol.rb +6 -2
  29. data/lib/openc3/interfaces/tcpip_server_interface.rb +205 -125
  30. data/lib/openc3/io/json_api.rb +2 -10
  31. data/lib/openc3/io/json_api_object.rb +2 -10
  32. data/lib/openc3/logs/packet_log_writer.rb +8 -3
  33. data/lib/openc3/microservices/decom_common.rb +4 -1
  34. data/lib/openc3/microservices/decom_microservice.rb +52 -6
  35. data/lib/openc3/microservices/interface_decom_common.rb +13 -0
  36. data/lib/openc3/microservices/interface_microservice.rb +50 -11
  37. data/lib/openc3/microservices/limits_group_microservice.rb +513 -0
  38. data/lib/openc3/microservices/log_microservice.rb +22 -8
  39. data/lib/openc3/microservices/microservice.rb +8 -2
  40. data/lib/openc3/microservices/multi_microservice.rb +76 -22
  41. data/lib/openc3/microservices/queue_microservice.rb +29 -24
  42. data/lib/openc3/migrations/20260704000000_default_bridge.rb +1 -2
  43. data/lib/openc3/migrations/20261103000001_limits_group_backfill.rb +193 -0
  44. data/lib/openc3/models/bridge_model.rb +3 -3
  45. data/lib/openc3/models/cvt_model.rb +3 -1
  46. data/lib/openc3/models/host_interface_microservice_model.rb +4 -4
  47. data/lib/openc3/models/interface_model.rb +27 -7
  48. data/lib/openc3/models/microservice_group.rb +167 -0
  49. data/lib/openc3/models/microservice_model.rb +88 -2
  50. data/lib/openc3/models/panel_model.rb +109 -0
  51. data/lib/openc3/models/plugin_model.rb +1006 -26
  52. data/lib/openc3/models/plugin_store_model.rb +6 -1
  53. data/lib/openc3/models/protected_storage_model.rb +64 -0
  54. data/lib/openc3/models/queue_model.rb +19 -10
  55. data/lib/openc3/models/scope_model.rb +80 -3
  56. data/lib/openc3/models/setting_model.rb +2 -2
  57. data/lib/openc3/models/shared_resource_model.rb +381 -0
  58. data/lib/openc3/models/target_model.rb +324 -68
  59. data/lib/openc3/operators/microservice_operator.rb +76 -9
  60. data/lib/openc3/operators/operator.rb +29 -0
  61. data/lib/openc3/packets/commands.rb +16 -16
  62. data/lib/openc3/packets/limits.rb +2 -0
  63. data/lib/openc3/packets/packet.rb +75 -4
  64. data/lib/openc3/packets/packet_config.rb +152 -13
  65. data/lib/openc3/packets/packet_item.rb +35 -14
  66. data/lib/openc3/packets/packet_item_limits.rb +67 -6
  67. data/lib/openc3/packets/parsers/limits_parser.rb +69 -2
  68. data/lib/openc3/packets/parsers/packet_item_parser.rb +6 -0
  69. data/lib/openc3/packets/parsers/packet_parser.rb +45 -0
  70. data/lib/openc3/packets/parsers/state_parser.rb +1 -1
  71. data/lib/openc3/script/CLAUDE.md +1 -0
  72. data/lib/openc3/script/api_shared.rb +17 -9
  73. data/lib/openc3/script/calendar.rb +18 -6
  74. data/lib/openc3/script/commands.rb +11 -9
  75. data/lib/openc3/script/critical_cmd.rb +22 -2
  76. data/lib/openc3/script/metadata.rb +30 -4
  77. data/lib/openc3/script/plugins.rb +8 -0
  78. data/lib/openc3/script/script.rb +8 -24
  79. data/lib/openc3/script/web_socket_api.rb +23 -17
  80. data/lib/openc3/system/system.rb +9 -3
  81. data/lib/openc3/top_level.rb +17 -0
  82. data/lib/openc3/topics/command_topic.rb +7 -1
  83. data/lib/openc3/topics/decom_interface_topic.rb +9 -3
  84. data/lib/openc3/topics/discovery_topic.rb +84 -0
  85. data/lib/openc3/topics/limits_event_topic.rb +236 -17
  86. data/lib/openc3/topics/telemetry_decom_topic.rb +12 -3
  87. data/lib/openc3/topics/topic.rb +2 -1
  88. data/lib/openc3/utilities/authentication.rb +67 -16
  89. data/lib/openc3/utilities/cli_generator.rb +117 -25
  90. data/lib/openc3/utilities/client_ip_header_filter.rb +38 -0
  91. data/lib/openc3/utilities/config_overlay.rb +24 -1
  92. data/lib/openc3/utilities/cosmos_rails_formatter.rb +18 -10
  93. data/lib/openc3/utilities/hardware_discovery.rb +279 -0
  94. data/lib/openc3/utilities/limits_rollup.rb +81 -0
  95. data/lib/openc3/utilities/local_mode.rb +48 -5
  96. data/lib/openc3/utilities/questdb_client.rb +130 -22
  97. data/lib/openc3/utilities/reingest_job.rb +12 -3
  98. data/lib/openc3/utilities/running_script.rb +206 -49
  99. data/lib/openc3/utilities/script.rb +24 -12
  100. data/lib/openc3/utilities/script_env.rb +164 -0
  101. data/lib/openc3/utilities/script_message_signing.rb +133 -0
  102. data/lib/openc3/utilities/store_autoload.rb +32 -1
  103. data/lib/openc3/utilities/store_queued.rb +5 -1
  104. data/lib/openc3/version.rb +6 -6
  105. data/templates/command_validator/command_validator.py +9 -9
  106. data/templates/{tool_react/pnpm-workspace.yaml → panel/.prettierrc.cjs} +7 -5
  107. data/templates/panel/Rakefile +24 -0
  108. data/templates/panel/package.json +17 -0
  109. data/templates/{tool_angular → panel}/pnpm-workspace.yaml +5 -0
  110. data/templates/panel/src/Panel.js +52 -0
  111. data/templates/panel/src/Panel.vue +60 -0
  112. data/templates/panel/src/panelSdk.js +24 -0
  113. data/templates/panel/vite-Panel.config.js +43 -0
  114. data/templates/tool_vue/package.json +3 -3
  115. data/templates/widget/package.json +2 -2
  116. metadata +24 -56
  117. data/templates/tool_angular/.editorconfig +0 -16
  118. data/templates/tool_angular/.gitignore +0 -44
  119. data/templates/tool_angular/.vscode/extensions.json +0 -4
  120. data/templates/tool_angular/.vscode/launch.json +0 -20
  121. data/templates/tool_angular/.vscode/tasks.json +0 -42
  122. data/templates/tool_angular/angular.json +0 -111
  123. data/templates/tool_angular/extra-webpack.config.js +0 -8
  124. data/templates/tool_angular/package.json +0 -48
  125. data/templates/tool_angular/src/app/app-routing.module.ts +0 -15
  126. data/templates/tool_angular/src/app/app.component.html +0 -22
  127. data/templates/tool_angular/src/app/app.component.scss +0 -18
  128. data/templates/tool_angular/src/app/app.component.spec.ts +0 -29
  129. data/templates/tool_angular/src/app/app.component.ts +0 -52
  130. data/templates/tool_angular/src/app/app.module.ts +0 -30
  131. data/templates/tool_angular/src/app/custom-overlay-container.ts +0 -17
  132. data/templates/tool_angular/src/app/empty-route/empty-route.component.ts +0 -7
  133. data/templates/tool_angular/src/app/openc3-api.d.ts +0 -1
  134. data/templates/tool_angular/src/assets/.gitkeep +0 -0
  135. data/templates/tool_angular/src/environments/environment.prod.ts +0 -3
  136. data/templates/tool_angular/src/environments/environment.ts +0 -16
  137. data/templates/tool_angular/src/favicon.ico +0 -0
  138. data/templates/tool_angular/src/index.html +0 -13
  139. data/templates/tool_angular/src/main.single-spa.ts +0 -40
  140. data/templates/tool_angular/src/single-spa/asset-url.ts +0 -12
  141. data/templates/tool_angular/src/single-spa/single-spa-props.ts +0 -8
  142. data/templates/tool_angular/src/styles.scss +0 -1
  143. data/templates/tool_angular/tsconfig.app.json +0 -13
  144. data/templates/tool_angular/tsconfig.json +0 -33
  145. data/templates/tool_angular/tsconfig.spec.json +0 -14
  146. data/templates/tool_react/.eslintrc +0 -7
  147. data/templates/tool_react/.gitignore +0 -71
  148. data/templates/tool_react/.prettierignore +0 -8
  149. data/templates/tool_react/babel.config.json +0 -29
  150. data/templates/tool_react/jest.config.js +0 -12
  151. data/templates/tool_react/package.json +0 -51
  152. data/templates/tool_react/src/openc3-tool_name.js +0 -24
  153. data/templates/tool_react/src/root.component.js +0 -88
  154. data/templates/tool_react/src/root.component.test.js +0 -9
  155. data/templates/tool_react/webpack.config.js +0 -27
  156. data/templates/tool_svelte/.gitignore +0 -71
  157. data/templates/tool_svelte/.prettierignore +0 -8
  158. data/templates/tool_svelte/.prettierrc.js +0 -5
  159. data/templates/tool_svelte/babel.config.js +0 -12
  160. data/templates/tool_svelte/build/smui.css +0 -1
  161. data/templates/tool_svelte/jest.config.js +0 -9
  162. data/templates/tool_svelte/package.json +0 -49
  163. data/templates/tool_svelte/pnpm-workspace.yaml +0 -20
  164. data/templates/tool_svelte/rollup.config.js +0 -74
  165. data/templates/tool_svelte/src/App.svelte +0 -42
  166. data/templates/tool_svelte/src/App.test.js +0 -9
  167. data/templates/tool_svelte/src/theme/_smui-theme.scss +0 -25
  168. data/templates/tool_svelte/src/tool_name.js +0 -17
  169. data/templates/widget/LICENSE.md +0 -20
@@ -24,10 +24,16 @@ module OpenC3
24
24
 
25
25
  private
26
26
 
27
+ # The metadata methods are deprecated. Define a telemetry packet for metadata
28
+ # and set it with inject_tlm instead. See https://docs.openc3.com/docs/guides/metadata
29
+
30
+ # @deprecated Use Data Extractor or Telemetry Grapher on a metadata packet instead.
31
+ # See https://docs.openc3.com/docs/guides/metadata
27
32
  # Gets all the metadata
28
33
  #
29
34
  # @return The result of the method call.
30
35
  def metadata_all(limit: 100, scope: $openc3_scope)
36
+ OpenC3.deprecation_warning("`metadata_all` is deprecated. Please use Data Extractor or Telemetry Grapher instead.", uplevel: 1)
31
37
  response = $api_server.request('get', "/openc3-api/metadata", query: { limit: limit }, scope: scope)
32
38
  # Non-existent just returns nil
33
39
  return nil if response.nil? || response.status != 200
@@ -35,10 +41,18 @@ module OpenC3
35
41
  end
36
42
  alias all_metadata metadata_all
37
43
 
44
+ # @deprecated Use tlm or get_tlm_packet on a metadata packet instead.
45
+ # See https://docs.openc3.com/docs/guides/metadata
38
46
  # Gets metadata, default is latest if start is nil
39
47
  #
40
48
  # @return The result of the method call.
41
49
  def metadata_get(start: nil, scope: $openc3_scope)
50
+ OpenC3.deprecation_warning("`metadata_get` is deprecated. Please use `tlm` or `get_tlm_packet` instead.", uplevel: 1)
51
+ return _metadata_get(start: start, scope: scope)
52
+ end
53
+ alias get_metadata metadata_get
54
+
55
+ def _metadata_get(start: nil, scope: $openc3_scope)
42
56
  if start
43
57
  response = $api_server.request('get', "/openc3-api/metadata/#{start}", scope: scope)
44
58
  else
@@ -46,10 +60,14 @@ module OpenC3
46
60
  end
47
61
  # Non-existent just returns nil
48
62
  return nil if response.nil? || response.status != 200
49
- return JSON.parse(response.body, allow_nan: true, create_additions: true)
63
+ result = JSON.parse(response.body, allow_nan: true, create_additions: true)
64
+ # The latest endpoint returns 200 with an error status when there is no metadata
65
+ return nil if result.is_a?(Hash) && result['status'] == 'error'
66
+ return result
50
67
  end
51
- alias get_metadata metadata_get
52
68
 
69
+ # @deprecated Use inject_tlm on a metadata packet instead.
70
+ # See https://docs.openc3.com/docs/guides/metadata
53
71
  # Create a new metadata entry at the given start time or now if no start given
54
72
  #
55
73
  # @param metadata [Hash<Symbol, Variable>] A hash of metadata
@@ -57,6 +75,7 @@ module OpenC3
57
75
  # @param color [String] Events color to show on Calendar tool, if nil will be blue
58
76
  # @return The result of the method call.
59
77
  def metadata_set(metadata, start: nil, color: nil, scope: $openc3_scope)
78
+ OpenC3.deprecation_warning("`metadata_set` is deprecated. Please use `inject_tlm` instead.", uplevel: 1)
60
79
  unless metadata.is_a?(Hash)
61
80
  raise "metadata must be a Hash: #{metadata} is a #{metadata.class}"
62
81
  end
@@ -75,6 +94,8 @@ module OpenC3
75
94
  end
76
95
  alias set_metadata metadata_set
77
96
 
97
+ # @deprecated Use inject_tlm with only the changed items instead.
98
+ # See https://docs.openc3.com/docs/guides/metadata
78
99
  # Updates existing metadata. If no start is given, updates latest metadata.
79
100
  #
80
101
  # @param metadata [Hash<Symbol, Variable>] A hash of metadata
@@ -82,11 +103,13 @@ module OpenC3
82
103
  # @param color [String] Events color to show on Calendar tool, if nil will be blue
83
104
  # @return The result of the method call.
84
105
  def metadata_update(metadata, start: nil, color: nil, scope: $openc3_scope)
106
+ OpenC3.deprecation_warning("`metadata_update` is deprecated. Please use `inject_tlm` instead.", uplevel: 1)
85
107
  unless metadata.is_a?(Hash)
86
108
  raise "metadata must be a Hash: #{metadata} is a #{metadata.class}"
87
109
  end
88
110
  if start.nil? # No start so grab latest
89
- existing = get_metadata()
111
+ existing = _metadata_get(scope: scope)
112
+ raise "No metadata to update; use metadata_set" if existing.nil?
90
113
  start = existing['start']
91
114
  color = existing['color'] unless color
92
115
  metadata = existing['metadata'].merge(metadata)
@@ -103,9 +126,12 @@ module OpenC3
103
126
  end
104
127
  alias update_metadata metadata_update
105
128
 
129
+ # @deprecated Use the user input methods followed by inject_tlm instead.
130
+ # See https://docs.openc3.com/docs/guides/metadata
106
131
  # Requests the metadata from the user for a target
107
132
  def metadata_input(*args, **kwargs)
108
- raise StandardError "can only be used in Script Runner"
133
+ OpenC3.deprecation_warning("`metadata_input` is deprecated. Please use the user input methods followed by `inject_tlm` instead.", uplevel: 1)
134
+ raise StandardError, "can only be used in Script Runner"
109
135
  end
110
136
  alias input_metadata metadata_input
111
137
  end
@@ -11,6 +11,14 @@
11
11
  # This file may also be used under the terms of a commercial license
12
12
  # if purchased from OpenC3, Inc.
13
13
 
14
+ # NOTE: plugin_list and plugin_get are intentionally NOT in the Api module
15
+ # (and not in Api::WHITELIST) like most other script methods. The Python api
16
+ # has no PluginModel and no way to read default_plugins.yaml (it lives outside
17
+ # the python package and Python has no yaml dependency), so a shared api
18
+ # implementation can't be mirrored in both languages. Instead these call the
19
+ # PluginsController REST endpoints directly, which also gives the same results
20
+ # in Ruby and Python scripts.
21
+
14
22
  module OpenC3
15
23
  module Script
16
24
  private
@@ -114,12 +114,12 @@ module OpenC3
114
114
  end
115
115
  end
116
116
 
117
- def prompt_for_critical_cmd(uuid, _username, _target_name, _cmd_name, _cmd_params, cmd_string)
117
+ def prompt_for_critical_cmd(uuid, _username, _target_name, _cmd_name, _cmd_params, cmd_string, scope: $openc3_scope)
118
118
  puts "Waiting for critical command approval:"
119
119
  puts " #{cmd_string}"
120
120
  puts " UUID: #{uuid}"
121
121
  loop do
122
- status = critical_cmd_status(uuid)
122
+ status = critical_cmd_status(uuid, scope: scope)
123
123
  if status == 'APPROVED'
124
124
  return
125
125
  elsif status == 'REJECTED'
@@ -240,14 +240,14 @@ module OpenC3
240
240
  # initialize_offline_access()
241
241
  # script_run("INST/procedures/collect.rb")
242
242
  #
243
- def initialize_offline_access
243
+ def initialize_offline_access(scope: $openc3_scope)
244
244
  keycloak_url = ENV.fetch('OPENC3_KEYCLOAK_URL', nil)
245
245
  if keycloak_url.nil? or keycloak_url.empty?
246
246
  raise "initialize_offline_access only valid in COSMOS Enterprise. OPENC3_KEYCLOAK_URL environment variable must be set."
247
247
  end
248
248
  auth = OpenC3KeycloakAuthentication.new(keycloak_url)
249
249
  auth.token(include_bearer: true, openid_scope: 'openid offline_access')
250
- set_offline_access(auth.refresh_token)
250
+ set_offline_access(auth.refresh_token, scope: scope)
251
251
  end
252
252
 
253
253
  ###########################################################################
@@ -272,17 +272,9 @@ module OpenC3
272
272
  return timeout.to_f
273
273
  end
274
274
 
275
- # generate the auth object
275
+ # Generate the authentication object from the standard environment variables.
276
276
  def generate_auth
277
- if ENV['OPENC3_API_TOKEN'].nil? and ENV['OPENC3_API_USER'].nil?
278
- if ENV['OPENC3_API_PASSWORD']
279
- return OpenC3Authentication.new()
280
- else
281
- return nil
282
- end
283
- else
284
- return OpenC3KeycloakAuthentication.new(ENV['OPENC3_KEYCLOAK_URL'])
285
- end
277
+ OpenC3.authentication_from_environment
286
278
  end
287
279
 
288
280
  # Create a JsonDRbObject connection to the API server
@@ -342,17 +334,9 @@ module OpenC3
342
334
  return timeout.to_f
343
335
  end
344
336
 
345
- # generate the auth object
337
+ # Generate the authentication object from the standard environment variables.
346
338
  def generate_auth
347
- if ENV['OPENC3_API_TOKEN'].nil? and ENV['OPENC3_API_USER'].nil?
348
- if ENV['OPENC3_API_PASSWORD']
349
- return OpenC3Authentication.new()
350
- else
351
- return nil
352
- end
353
- else
354
- return OpenC3KeycloakAuthentication.new(ENV['OPENC3_KEYCLOAK_URL'])
355
- end
339
+ OpenC3.authentication_from_environment
356
340
  end
357
341
 
358
342
  # Create a JsonDRbObject connection to the API server
@@ -172,7 +172,8 @@ module OpenC3
172
172
  @stream.write(data)
173
173
  end
174
174
 
175
- # Connect to the websocket with authorization in query params
175
+ # Connect to the websocket. The token is sent in the subscription identifier
176
+ # (see #subscribe), never in the URL.
176
177
  def connect
177
178
  disconnect()
178
179
  final_url = @url + "?scope=#{@scope}"
@@ -244,17 +245,12 @@ module OpenC3
244
245
  end
245
246
  end
246
247
 
247
- # Generate the appropriate token for OpenC3
248
+ # Generate the appropriate token for OpenC3.
248
249
  def generate_auth
249
- if ENV['OPENC3_API_TOKEN'].nil? and ENV['OPENC3_API_USER'].nil?
250
- if ENV['OPENC3_API_PASSWORD']
251
- return OpenC3Authentication.new()
252
- else
253
- raise "Environment Variables Not Set for Authentication"
254
- end
255
- else
256
- return OpenC3KeycloakAuthentication.new(ENV['OPENC3_KEYCLOAK_URL'])
257
- end
250
+ authentication = OpenC3.authentication_from_environment
251
+ raise "Environment Variables Not Set for Authentication" unless authentication
252
+
253
+ authentication
258
254
  end
259
255
  end
260
256
 
@@ -440,6 +436,9 @@ module OpenC3
440
436
  # scope: scope name
441
437
  # start_time: 64-bit nanoseconds from unix epoch - If not present then realtime
442
438
  # end_time: 64-bit nanoseconds from unix epoch - If not present stream forever
439
+ # time_type: 'PACKET' or 'RECEIVED' - Whether start_time and end_time select data by packet
440
+ # time or received time (also returned as __time). Defaults to PACKET on the server.
441
+ # include_times: true to also return __packet_time and __received_time in each result
443
442
  # items: [ [ MODE__CMDORTLM__TARGET__PACKET__ITEM__VALUETYPE__REDUCEDTYPE, item_key] ]
444
443
  # MODE - RAW, DECOM, REDUCED_MINUTE, REDUCED_HOUR, or REDUCED_DAY
445
444
  # CMDORTLM - CMD or TLM
@@ -456,10 +455,12 @@ module OpenC3
456
455
  # PACKET - Packet name
457
456
  # VALUETYPE - RAW, CONVERTED, FORMATTED, or PURE (pure means all types as stored in log)
458
457
  #
459
- def add(items: nil, packets: nil, start_time: nil, end_time: nil, scope: nil)
458
+ def add(items: nil, packets: nil, start_time: nil, end_time: nil, scope: nil, time_type: nil, include_times: false)
460
459
  times = {}
461
460
  times['start_time'] = to_nsec(start_time) if start_time
462
461
  times['end_time'] = to_nsec(end_time) if end_time
462
+ times['time_type'] = time_type.to_s.upcase if time_type
463
+ times['include_times'] = true if include_times
463
464
  stream_action('add', items: items, packets: packets, scope: scope, extra: times)
464
465
  end
465
466
 
@@ -481,20 +482,25 @@ module OpenC3
481
482
  # TARGET - Target name
482
483
  # PACKET - Packet name
483
484
  # VALUETYPE - RAW, CONVERTED, FORMATTED, or PURE (pure means all types as stored in log)
485
+ # time_type: PACKET or RECEIVED to remove only the subscriptions added with that time_type.
486
+ # Removes both when not given.
484
487
  #
485
- def remove(items: nil, packets: nil, scope: nil)
486
- stream_action('remove', items: items, packets: packets, scope: scope)
488
+ def remove(items: nil, packets: nil, scope: nil, time_type: nil)
489
+ extra = {}
490
+ extra['time_type'] = time_type.to_s.upcase if time_type
491
+ stream_action('remove', items: items, packets: packets, scope: scope, extra: extra)
487
492
  end
488
493
 
489
494
  # Convenience method to read all data until end marker is received.
490
495
  # Omitting end_time streams realtime and endlessly: no end marker is ever
491
496
  # sent, so a timeout is the only way the collection ends on its own.
492
497
  # Warning: DATA IS STORED IN RAM. Do not use this with large queries
493
- def self.read_all(items: nil, packets: nil, start_time: nil, end_time: nil, scope: nil, timeout: nil)
498
+ def self.read_all(items: nil, packets: nil, start_time: nil, end_time: nil, scope: nil, timeout: nil, time_type: nil, include_times: false)
494
499
  read_all_start_time = Time.now
495
500
  data = []
496
- self.new do |api|
497
- api.add(items: items, packets: packets, start_time: start_time, end_time: end_time, scope: scope)
501
+ # Connect with the requested scope, not just add the items with it
502
+ self.new(scope: scope || $openc3_scope) do |api|
503
+ api.add(items: items, packets: packets, start_time: start_time, end_time: end_time, scope: scope, time_type: time_type, include_times: include_times)
498
504
  while true
499
505
  batch = api.read
500
506
  if batch.nil?
@@ -80,12 +80,13 @@ module OpenC3
80
80
  # target_version can also be the actual hash used in the target_archives folder
81
81
  # @param descriptions [Boolean] Whether to keep packet and item descriptions
82
82
  def self.setup_targets(target_names, base_dir, target_version: 'current', scope:, descriptions: true)
83
- # Nothing to do if there are no targets
84
- return if target_names.nil? or target_names.length == 0
83
+ # With no targets this builds an empty System, which microservices without
84
+ # targets (such as an interface without MAP_TARGET) still use, e.g. for UNKNOWN
85
+ target_names ||= []
85
86
  if @@instance.nil?
86
87
  targets_path = "#{base_dir}/_targets"
87
88
  FileUtils.mkdir_p(targets_path)
88
- bucket = Bucket.getClient()
89
+ bucket = Bucket.getClient() unless target_names.empty?
89
90
  target_names.each do |target_name|
90
91
  # Remove any prior extraction so re-running setup_targets (e.g. after
91
92
  # reset_instance! during reingest) starts from a clean slate. Without
@@ -197,6 +198,11 @@ module OpenC3
197
198
  rescue Exception => e
198
199
  errors << "Error processing #{cmd_tlm_file}:\n#{e.message}"
199
200
  end
201
+ begin
202
+ @packet_config.build_limits_group_packet(target.name)
203
+ rescue => e
204
+ errors << e.message
205
+ end
200
206
  unless errors.empty?
201
207
  raise parser.error(errors.join("\n"))
202
208
  end
@@ -88,6 +88,23 @@ module OpenC3
88
88
  $VERBOSE = saved_verbose
89
89
  end
90
90
 
91
+ # Writes a "[DEPRECATION] message" line to $stderr. Use this rather than
92
+ # Kernel#warn for deprecation notices: Script Runner evaluates scripts inside
93
+ # disable_warnings ($VERBOSE = nil), which turns Kernel#warn into a no-op.
94
+ # Warning.warn ignores $VERBOSE but still goes through any Warning.warn override.
95
+ #
96
+ # @param message [String] What is deprecated and what to use instead
97
+ # @param uplevel [Integer|nil] Like Kernel#warn, prefix the location this many
98
+ # frames above the caller (1 = whoever called the deprecated method)
99
+ def self.deprecation_warning(message, uplevel: nil)
100
+ location = ''
101
+ if uplevel
102
+ frame = caller_locations(uplevel + 1, 1)&.first
103
+ location = "#{frame.path}:#{frame.lineno}: " if frame
104
+ end
105
+ Warning.warn("#{location}[DEPRECATION] #{message}\n")
106
+ end
107
+
91
108
  # Adds a path to the global Ruby search path
92
109
  #
93
110
  # @param path [String] Directory path
@@ -46,6 +46,8 @@ module OpenC3
46
46
  # Save the existing cmd_params Hash and JSON generate before writing to the topic
47
47
  cmd_params = command['cmd_params']
48
48
  command['cmd_params'] = JSON.generate(command['cmd_params'].as_json, allow_nan: true)
49
+ extra = command['extra']
50
+ command['extra'] = JSON.generate(extra.as_json, allow_nan: true) if extra
49
51
  OpenC3.inject_context(command)
50
52
 
51
53
  db_shard = Store.db_shard_for_target(command['target_name'], scope: scope)
@@ -54,6 +56,7 @@ module OpenC3
54
56
  if timeout <= 0
55
57
  Topic.write_topic("{#{scope}__CMD}TARGET__#{command['target_name']}", command, '*', 100, db_shard: db_shard)
56
58
  command["cmd_params"] = cmd_params # Restore the original cmd_params Hash
59
+ command['extra'] = extra if extra
57
60
  return command
58
61
  end
59
62
 
@@ -61,6 +64,7 @@ module OpenC3
61
64
  Topic.update_topic_offsets([ack_topic], db_shard: db_shard)
62
65
  cmd_id = Topic.write_topic("{#{scope}__CMD}TARGET__#{command['target_name']}", command, '*', 100, db_shard: db_shard)
63
66
  command["cmd_params"] = cmd_params # Restore the original cmd_params Hash
67
+ command['extra'] = extra if extra
64
68
  time = Time.now
65
69
  while (Time.now - time) < timeout
66
70
  Topic.read_topics([ack_topic], db_shard: db_shard) do |_topic, _msg_id, msg_hash, _redis|
@@ -73,7 +77,9 @@ module OpenC3
73
77
  elsif msg_hash["result"].include?("CriticalCmdError")
74
78
  raise_critical_cmd_error(msg_hash, command)
75
79
  else
76
- raise msg_hash["result"]
80
+ # The interface microservice already logged the error so don't
81
+ # add a backtrace which only shows this ack loop
82
+ raise RuntimeError, msg_hash["result"], []
77
83
  end
78
84
  end
79
85
  end
@@ -38,7 +38,9 @@ module OpenC3
38
38
  if msg_hash["result"] == "SUCCESS"
39
39
  return msg_hash
40
40
  else
41
- raise msg_hash["result"]
41
+ # The error happened in the decom microservice so don't add a
42
+ # backtrace which only shows this ack loop
43
+ raise RuntimeError, msg_hash["result"], []
42
44
  end
43
45
  end
44
46
  end
@@ -67,7 +69,9 @@ module OpenC3
67
69
  if msg_hash["result"] == "SUCCESS"
68
70
  return
69
71
  else
70
- raise msg_hash["result"]
72
+ # The error happened in the decom microservice so don't add a
73
+ # backtrace which only shows this ack loop
74
+ raise RuntimeError, msg_hash["result"], []
71
75
  end
72
76
  end
73
77
  end
@@ -98,7 +102,9 @@ module OpenC3
98
102
  end
99
103
  return msg_hash
100
104
  else
101
- raise msg_hash["result"]
105
+ # The error happened in the decom microservice so don't add a
106
+ # backtrace which only shows this ack loop
107
+ raise RuntimeError, msg_hash["result"], []
102
108
  end
103
109
  end
104
110
  end
@@ -0,0 +1,84 @@
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2026 OpenC3, Inc.
4
+ # All Rights Reserved.
5
+ #
6
+ # This program is distributed in the hope that it will be useful,
7
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
8
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9
+ # See LICENSE.md for more details.
10
+ #
11
+ # This file may also be used under the terms of a commercial license
12
+ # if purchased from OpenC3, Inc.
13
+
14
+ require 'securerandom'
15
+ require 'openc3/topics/topic'
16
+
17
+ module OpenC3
18
+ # Discovery requests are published to a bridge hub (bridge_microservice) which
19
+ # hands them to openc3-cosmos-app. openc3-cosmos-app runs the Python Discovery class on the
20
+ # host and the hub publishes the result back on the result topic.
21
+ # See openc3/python/openc3/topics/discovery_topic.py
22
+ class DiscoveryTopic < Topic
23
+ DISCOVERY_TIMEOUT_S = 30
24
+
25
+ def self.request_topic(bridge_name, scope:)
26
+ "#{scope}__DISCOVERY__#{bridge_name}"
27
+ end
28
+
29
+ def self.result_topic(bridge_name, scope:)
30
+ "#{scope}__DISCOVERY_RESULT__#{bridge_name}"
31
+ end
32
+
33
+ # Run a discovery on the host connected to the given bridge
34
+ #
35
+ # @param bridge_name [String] Name of the bridge (e.g. DEFAULT)
36
+ # @param discovery [Array<String>] Discovery class filename followed by its parameters
37
+ # @param timeout [Numeric] Seconds to wait for the host to respond
38
+ # @return [Array<Hash>] Discovered values as { 'value' => ..., 'text' => ... }
39
+ def self.discover(bridge_name, discovery, timeout: nil, scope:)
40
+ result = request(bridge_name, { 'discovery' => JSON.generate(discovery) }, timeout: timeout, scope: scope)
41
+ result['results'] || []
42
+ end
43
+
44
+ # Scan the host connected to the given bridge for hardware and check it
45
+ # against discovery matchers (see openc3/python/openc3/discovery/discovery_scan.py)
46
+ #
47
+ # @param bridge_name [String] Name of the bridge (e.g. DEFAULT)
48
+ # @param scan [Hash] { 'matchers' => [{ 'id', 'class', 'params' }], 'classes' => [...] }
49
+ # @param timeout [Numeric] Seconds to wait for the host to respond
50
+ # @return [Hash] { 'devices' => [...], 'errors' => {...}, 'skipped' => {...} }
51
+ def self.scan(bridge_name, scan, timeout: nil, scope:)
52
+ # An empty discovery makes an openc3-cosmos-app without scan support answer with an error
53
+ fields = { 'discovery' => '[]', 'scan' => JSON.generate(scan) }
54
+ result = request(bridge_name, fields, timeout: timeout, scope: scope)
55
+ return result['scan'] if result['scan']
56
+ raise "openc3-cosmos-app on the host for bridge '#{bridge_name}' does not support hardware discovery. Update openc3-cosmos-app."
57
+ rescue RuntimeError => error
58
+ raise "openc3-cosmos-app on the host for bridge '#{bridge_name}' does not support hardware discovery. Update openc3-cosmos-app." if error.message == 'no discovery class given'
59
+ raise
60
+ end
61
+
62
+ # Publish a request for the bridge's host and wait for its result
63
+ def self.request(bridge_name, fields, timeout:, scope:)
64
+ timeout = DISCOVERY_TIMEOUT_S unless timeout
65
+ result_topic = result_topic(bridge_name, scope: scope)
66
+ Topic.update_topic_offsets([result_topic])
67
+
68
+ id = SecureRandom.uuid
69
+ request = { 'id' => id }.merge(fields).merge('expires_at' => (Time.now.to_f + timeout).to_s)
70
+ Topic.write_topic(request_topic(bridge_name, scope: scope), request, '*', 100)
71
+ time = Time.now
72
+ while (Time.now - time) < timeout
73
+ Topic.read_topics([result_topic]) do |_topic, _msg_id, msg_hash, _redis|
74
+ next unless msg_hash['id'] == id
75
+ result = JSON.parse(msg_hash['result'])
76
+ raise result['error'] if result['error']
77
+ return result
78
+ end
79
+ end
80
+ raise "Timeout of #{timeout}s waiting for discovery on bridge '#{bridge_name}'. Is openc3-cosmos-app running and paired with COSMOS?"
81
+ end
82
+ private_class_method :request
83
+ end
84
+ end