openc3 5.8.1 → 5.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/ext/openc3/ext/crc/crc.c +1 -1
  3. data/lib/openc3/api/cmd_api.rb +1 -1
  4. data/lib/openc3/microservices/decom_microservice.rb +10 -2
  5. data/lib/openc3/microservices/reaction_microservice.rb +152 -81
  6. data/lib/openc3/microservices/timeline_microservice.rb +1 -1
  7. data/lib/openc3/microservices/trigger_group_microservice.rb +188 -118
  8. data/lib/openc3/migrations/20230615000000_autonomic.rb +86 -0
  9. data/lib/openc3/models/activity_model.rb +2 -4
  10. data/lib/openc3/models/microservice_model.rb +6 -2
  11. data/lib/openc3/models/model.rb +1 -3
  12. data/lib/openc3/models/reaction_model.rb +124 -119
  13. data/lib/openc3/models/scope_model.rb +15 -3
  14. data/lib/openc3/models/timeline_model.rb +1 -3
  15. data/lib/openc3/models/trigger_group_model.rb +16 -50
  16. data/lib/openc3/models/trigger_model.rb +86 -123
  17. data/lib/openc3/packets/json_packet.rb +2 -3
  18. data/lib/openc3/script/commands.rb +10 -0
  19. data/lib/openc3/script/script.rb +1 -0
  20. data/lib/openc3/top_level.rb +0 -12
  21. data/lib/openc3/utilities/authorization.rb +1 -1
  22. data/lib/openc3/utilities/bucket_require.rb +5 -1
  23. data/lib/openc3/utilities/bucket_utilities.rb +4 -1
  24. data/lib/openc3/utilities/cli_generator.rb +56 -4
  25. data/lib/openc3/utilities/ruby_lex_utils.rb +4 -0
  26. data/lib/openc3/version.rb +6 -6
  27. data/templates/plugin/README.md +54 -4
  28. data/templates/plugin/Rakefile +31 -3
  29. data/templates/tool_angular/.editorconfig +16 -0
  30. data/templates/tool_angular/.gitignore +44 -0
  31. data/templates/tool_angular/.vscode/extensions.json +4 -0
  32. data/templates/tool_angular/.vscode/launch.json +20 -0
  33. data/templates/tool_angular/.vscode/tasks.json +42 -0
  34. data/templates/tool_angular/angular.json +111 -0
  35. data/templates/tool_angular/extra-webpack.config.js +8 -0
  36. data/templates/tool_angular/package.json +47 -0
  37. data/templates/tool_angular/src/app/app-routing.module.ts +15 -0
  38. data/templates/tool_angular/src/app/app.component.html +31 -0
  39. data/templates/tool_angular/src/app/app.component.scss +26 -0
  40. data/templates/tool_angular/src/app/app.component.spec.ts +29 -0
  41. data/templates/tool_angular/src/app/app.component.ts +51 -0
  42. data/templates/tool_angular/src/app/app.module.ts +30 -0
  43. data/templates/tool_angular/src/app/custom-overlay-container.ts +17 -0
  44. data/templates/tool_angular/src/app/empty-route/empty-route.component.ts +7 -0
  45. data/templates/tool_angular/src/app/openc3-api.d.ts +1 -0
  46. data/templates/tool_angular/src/assets/.gitkeep +0 -0
  47. data/templates/tool_angular/src/environments/environment.prod.ts +3 -0
  48. data/templates/tool_angular/src/environments/environment.ts +16 -0
  49. data/templates/tool_angular/src/favicon.ico +0 -0
  50. data/templates/tool_angular/src/index.html +13 -0
  51. data/templates/tool_angular/src/main.single-spa.ts +40 -0
  52. data/templates/tool_angular/src/single-spa/asset-url.ts +12 -0
  53. data/templates/tool_angular/src/single-spa/single-spa-props.ts +8 -0
  54. data/templates/tool_angular/src/styles.scss +1 -0
  55. data/templates/tool_angular/tsconfig.app.json +13 -0
  56. data/templates/tool_angular/tsconfig.json +33 -0
  57. data/templates/tool_angular/tsconfig.spec.json +14 -0
  58. data/templates/tool_angular/yarn.lock +8080 -0
  59. data/templates/tool_react/.eslintrc +7 -0
  60. data/templates/tool_react/.gitignore +72 -0
  61. data/templates/tool_react/.prettierignore +8 -0
  62. data/templates/tool_react/babel.config.json +29 -0
  63. data/templates/tool_react/jest.config.js +12 -0
  64. data/templates/tool_react/package.json +53 -0
  65. data/templates/tool_react/src/openc3-tool_name.js +24 -0
  66. data/templates/tool_react/src/root.component.js +88 -0
  67. data/templates/tool_react/src/root.component.test.js +9 -0
  68. data/templates/tool_react/webpack.config.js +27 -0
  69. data/templates/tool_react/yarn.lock +6854 -0
  70. data/templates/tool_svelte/.gitignore +72 -0
  71. data/templates/tool_svelte/.prettierignore +8 -0
  72. data/templates/tool_svelte/babel.config.js +12 -0
  73. data/templates/tool_svelte/build/smui.css +5 -0
  74. data/templates/tool_svelte/jest.config.js +9 -0
  75. data/templates/tool_svelte/package.json +46 -0
  76. data/templates/tool_svelte/rollup.config.js +72 -0
  77. data/templates/tool_svelte/src/App.svelte +42 -0
  78. data/templates/tool_svelte/src/App.test.js +9 -0
  79. data/templates/tool_svelte/src/services/api.js +92 -0
  80. data/templates/tool_svelte/src/services/axios.js +85 -0
  81. data/templates/tool_svelte/src/services/cable.js +65 -0
  82. data/templates/tool_svelte/src/services/config-parser.js +199 -0
  83. data/templates/tool_svelte/src/services/openc3-api.js +647 -0
  84. data/templates/tool_svelte/src/theme/_smui-theme.scss +25 -0
  85. data/templates/tool_svelte/src/tool_name.js +17 -0
  86. data/templates/tool_svelte/yarn.lock +5052 -0
  87. data/templates/tool_vue/.browserslistrc +16 -0
  88. data/templates/tool_vue/.env.standalone +1 -0
  89. data/templates/tool_vue/.eslintrc.js +43 -0
  90. data/templates/tool_vue/.gitignore +2 -0
  91. data/templates/tool_vue/.nycrc +3 -0
  92. data/templates/tool_vue/.prettierrc.js +5 -0
  93. data/templates/tool_vue/babel.config.json +11 -0
  94. data/templates/tool_vue/jsconfig.json +6 -0
  95. data/templates/tool_vue/package.json +52 -0
  96. data/templates/tool_vue/src/App.vue +15 -0
  97. data/templates/tool_vue/src/main.js +38 -0
  98. data/templates/tool_vue/src/router.js +29 -0
  99. data/templates/tool_vue/src/tools/tool_name/tool_name.vue +63 -0
  100. data/templates/tool_vue/vue.config.js +30 -0
  101. data/templates/tool_vue/yarn.lock +9145 -0
  102. data/templates/widget/package.json +9 -9
  103. data/templates/widget/yarn.lock +77 -73
  104. metadata +76 -2
@@ -0,0 +1,647 @@
1
+ /*
2
+ # Copyright 2022 Ball Aerospace & Technologies Corp.
3
+ # All Rights Reserved.
4
+ #
5
+ # This program is free software; you can modify and/or redistribute it
6
+ # under the terms of the GNU Affero General Public License
7
+ # as published by the Free Software Foundation; version 3 with
8
+ # attribution addendums as found in the LICENSE.txt
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+
15
+ # Modified by OpenC3, Inc.
16
+ # All changes Copyright 2022, OpenC3, Inc.
17
+ # All Rights Reserved
18
+ #
19
+ # This file may also be used under the terms of a commercial license
20
+ # if purchased from OpenC3, Inc.
21
+ */
22
+
23
+ import axios from './axios.js'
24
+
25
+ export class OpenC3Api {
26
+ id = 1
27
+
28
+ constructor() {}
29
+
30
+ async exec(method, params, kwparams = {}, headerOptions = {}) {
31
+ try {
32
+ let refreshed = await OpenC3Auth.updateToken(
33
+ OpenC3Auth.defaultMinValidity
34
+ )
35
+ if (refreshed) {
36
+ OpenC3Auth.setTokens()
37
+ }
38
+ } catch (error) {
39
+ OpenC3Auth.login()
40
+ }
41
+ this.id = this.id + 1
42
+ try {
43
+ kwparams['scope'] = window.openc3Scope
44
+ const response = await axios.post(
45
+ '/openc3-api/api',
46
+ {
47
+ jsonrpc: '2.0',
48
+ method: method,
49
+ params: params,
50
+ id: this.id,
51
+ keyword_params: kwparams,
52
+ },
53
+ {
54
+ headers: {
55
+ Authorization: localStorage.openc3Token,
56
+ 'Content-Type': 'application/json-rpc',
57
+ ...headerOptions,
58
+ },
59
+ }
60
+ )
61
+ // var data = response.data
62
+ // if (data.error) {
63
+ // var err = new Error()
64
+ // err.name = data.error.data.class
65
+ // err.message = data.error.data.message
66
+ // console.log(data.error.data.backtrace.join('\n'))
67
+ // throw err
68
+ // }
69
+ return response.data.result
70
+ } catch (error) {
71
+ var err = new Error()
72
+ if (error.response) {
73
+ // The request was made and the server responded with a
74
+ // status code that falls out of the range of 2xx
75
+ err.name = error.response.data.error.data.class
76
+ err.message = error.response.data.error.data.message
77
+ } else if (error.request) {
78
+ // The request was made but no response was received, `error.request`
79
+ // is an instance of XMLHttpRequest in the browser and an instance
80
+ // of http.ClientRequest in Node.js
81
+ err.name = 'Request error'
82
+ err.message = 'Request error, no response received'
83
+ } else {
84
+ // Something happened in setting up the request and triggered an Error
85
+ err.name = 'Unknown error'
86
+ }
87
+ // console.log(error)
88
+ throw err
89
+ }
90
+ }
91
+
92
+ decode_openc3_type(val) {
93
+ if (val !== null && typeof val === 'object') {
94
+ if (val.json_class == 'Float' && val.raw) {
95
+ if (val.raw == 'NaN') {
96
+ return NaN
97
+ } else if (val.raw == 'Infinity') {
98
+ return Infinity
99
+ } else if (val.raw == '-Infinity') {
100
+ return -Infinity
101
+ }
102
+ }
103
+ }
104
+ return null
105
+ }
106
+
107
+ encode_openc3_type(val) {
108
+ if (Number.isNaN(val)) {
109
+ return { json_class: 'Float', raw: 'NaN' }
110
+ } else if (val == Number.POSITIVE_INFINITY) {
111
+ return { json_class: 'Float', raw: 'Infinity' }
112
+ } else if (val == Number.NEGATIVE_INFINITY) {
113
+ return { json_class: 'Float', raw: '-Infinity' }
114
+ }
115
+ return null
116
+ }
117
+
118
+ ensure_offline_access() {
119
+ this.offline_access_needed().then((needed) => {
120
+ if (needed) {
121
+ if (localStorage.openc3OfflineToken) {
122
+ this.set_offline_access(localStorage.openc3OfflineToken).then(() => {
123
+ delete localStorage.openc3OfflineToken
124
+ })
125
+ } else {
126
+ OpenC3Auth.getOfflineAccess()
127
+ }
128
+ }
129
+ })
130
+ }
131
+
132
+ // ***********************************************
133
+ // The following APIs are used by the CmdTlmServer
134
+ // ***********************************************
135
+
136
+ offline_access_needed() {
137
+ return this.exec('offline_access_needed', [])
138
+ }
139
+
140
+ set_offline_access(offline_access_token) {
141
+ return this.exec('set_offline_access', [offline_access_token])
142
+ }
143
+
144
+ get_all_interface_info() {
145
+ return this.exec('get_all_interface_info', [])
146
+ }
147
+
148
+ map_target_to_interface(target_name, interface_name) {
149
+ return this.exec('map_target_to_interface', [target_name, interface_name])
150
+ }
151
+
152
+ connect_interface(interface_name, ...interface_params) {
153
+ if (interface_params.length > 0) {
154
+ return this.exec('connect_interface', [
155
+ interface_name,
156
+ ...interface_params,
157
+ ])
158
+ } else {
159
+ return this.exec('connect_interface', [interface_name])
160
+ }
161
+ }
162
+
163
+ disconnect_interface(interface_name) {
164
+ return this.exec('disconnect_interface', [interface_name])
165
+ }
166
+
167
+ get_all_router_info() {
168
+ return this.exec('get_all_router_info', [])
169
+ }
170
+
171
+ connect_router(router_name) {
172
+ return this.exec('connect_router', [router_name])
173
+ }
174
+
175
+ disconnect_router(router_name) {
176
+ return this.exec('disconnect_router', [router_name])
177
+ }
178
+
179
+ get_target_interfaces() {
180
+ return this.exec('get_target_interfaces', [])
181
+ }
182
+
183
+ // DEPRECATED
184
+ get_all_target_info() {
185
+ return this.exec('get_all_target_info', [])
186
+ }
187
+
188
+ get_tlm_cnts(target_commands) {
189
+ return this.exec('get_tlm_cnts', [target_commands])
190
+ }
191
+
192
+ get_item(target, packet, item) {
193
+ return this.exec('get_item', [target, packet, item])
194
+ }
195
+
196
+ get_parameter(target, packet, item) {
197
+ return this.exec('get_parameter', [target, packet, item])
198
+ }
199
+
200
+ get_all_packet_logger_info() {
201
+ return this.exec('get_all_packet_logger_info', [])
202
+ }
203
+
204
+ start_logging() {
205
+ return this.exec('start_logging', [])
206
+ }
207
+
208
+ stop_logging() {
209
+ return this.exec('stop_logging', [])
210
+ }
211
+
212
+ start_cmd_log(log_writer_name) {
213
+ return this.exec('start_cmd_log', [log_writer_name])
214
+ }
215
+
216
+ start_tlm_log(log_writer_name) {
217
+ return this.exec('start_tlm_log', [log_writer_name])
218
+ }
219
+
220
+ stop_cmd_log(log_writer_name) {
221
+ return this.exec('stop_cmd_log', [log_writer_name])
222
+ }
223
+
224
+ stop_tlm_log(log_writer_name) {
225
+ return this.exec('stop_tlm_log', [log_writer_name])
226
+ }
227
+
228
+ get_server_status() {
229
+ return this.exec('get_server_status', [])
230
+ }
231
+
232
+ get_limits_sets() {
233
+ return this.exec('get_limits_sets', [])
234
+ }
235
+
236
+ get_limits_set() {
237
+ return this.exec('get_limits_set', [])
238
+ }
239
+
240
+ set_limits_set(limits_set) {
241
+ return this.exec('set_limits_set', [limits_set])
242
+ }
243
+
244
+ get_background_tasks() {
245
+ return this.exec('get_background_tasks', [])
246
+ }
247
+
248
+ start_background_task(name) {
249
+ return this.exec('start_background_task', [name])
250
+ }
251
+
252
+ stop_background_task(name) {
253
+ return this.exec('stop_background_task', [name])
254
+ }
255
+
256
+ // ***********************************************
257
+ // End CmdTlmServer APIs
258
+ // ***********************************************
259
+
260
+ get_target(target_name) {
261
+ return this.exec('get_target', [target_name])
262
+ }
263
+
264
+ get_target_list() {
265
+ return this.exec('get_target_list', [])
266
+ }
267
+
268
+ get_telemetry(target_name, packet_name) {
269
+ return this.exec('get_telemetry', [target_name, packet_name])
270
+ }
271
+
272
+ get_all_telemetry(target_name) {
273
+ return this.exec('get_all_telemetry', [target_name])
274
+ }
275
+
276
+ get_all_telemetry_names(target_name) {
277
+ return this.exec('get_all_telemetry_names', [target_name])
278
+ }
279
+
280
+ async get_tlm_packet(target_name, packet_name, value_type, stale_time = 30) {
281
+ const data = await this.exec('get_tlm_packet', [target_name, packet_name], {
282
+ type: value_type,
283
+ stale_time: stale_time,
284
+ })
285
+ // Make sure data isn't null or undefined. Note this is the only valid use of == or !=
286
+ if (data != null) {
287
+ var len = data.length
288
+ var converted = null
289
+ for (var i = 0; i < len; i++) {
290
+ converted = this.decode_openc3_type(data[i][1])
291
+ if (converted !== null) {
292
+ data[i][1] = converted
293
+ }
294
+ }
295
+ }
296
+ return data
297
+ }
298
+
299
+ get_packet_derived_items(target_name, packet_name) {
300
+ return this.exec('get_packet_derived_items', [target_name, packet_name])
301
+ }
302
+
303
+ get_tlm_buffer(target_name, packet_name) {
304
+ return this.exec('get_tlm_buffer', [target_name, packet_name])
305
+ }
306
+
307
+ async get_tlm_values(items, stale_time = 30) {
308
+ const data = await this.exec('get_tlm_values', [items], {
309
+ stale_time: stale_time,
310
+ })
311
+ var len = data[0].length
312
+ var converted = null
313
+ for (var i = 0; i < len; i++) {
314
+ converted = this.decode_openc3_type(data[0][i])
315
+ if (converted !== null) {
316
+ data[0][i] = converted
317
+ }
318
+ }
319
+ return data
320
+ }
321
+
322
+ get_limits(target_name, packet_name, item_name) {
323
+ return this.exec('get_limits', [target_name, packet_name, item_name])
324
+ }
325
+
326
+ async tlm(target_name, packet_name, item_name, value_type = 'CONVERTED') {
327
+ let data = null
328
+ // Check for the single string syntax: tlm("TGT PKT ITEM")
329
+ if (packet_name === undefined) {
330
+ data = await this.exec('tlm', [target_name])
331
+ // Check for the single string syntax with type: tlm("TGT PKT ITEM", "RAW")
332
+ } else if (item_name === undefined) {
333
+ if (
334
+ ['RAW', 'CONVERTED', 'FORMATTED', 'WITH_UNITS'].includes(packet_name)
335
+ ) {
336
+ data = await this.exec('tlm', [target_name], { type: packet_name })
337
+ } else {
338
+ var err = new Error()
339
+ err.name = 'TypeError'
340
+ err.message = `Invalid data type ${packet_name}. Valid options are RAW, CONVERTED, FORMATTED, and WITH_UNITS.`
341
+ throw err
342
+ }
343
+ } else {
344
+ data = await this.exec('tlm', [target_name, packet_name, item_name], {
345
+ type: value_type,
346
+ })
347
+ }
348
+ var converted = this.decode_openc3_type(data)
349
+ if (converted !== null) {
350
+ data = converted
351
+ }
352
+ return data
353
+ }
354
+
355
+ async inject_tlm(
356
+ target_name,
357
+ packet_name,
358
+ item_hash = null,
359
+ value_type = 'CONVERTED'
360
+ ) {
361
+ data = await this.exec(
362
+ 'inject_tlm',
363
+ [target_name, packet_name, item_hash],
364
+ {
365
+ type: value_type,
366
+ }
367
+ )
368
+ }
369
+
370
+ set_tlm(target_name, packet_name, item_name, value_type) {
371
+ return this.exec('set_tlm', [target_name, packet_name, item_name], {
372
+ type: value_type,
373
+ })
374
+ }
375
+
376
+ override_tlm(target_name, packet_name, item_name, value_type) {
377
+ return this.exec('override_tlm', [target_name, packet_name, item_name], {
378
+ type: value_type,
379
+ })
380
+ }
381
+
382
+ get_overrides() {
383
+ return this.exec('get_overrides')
384
+ }
385
+
386
+ normalize_tlm(target_name, packet_name, item_name, value_type) {
387
+ return this.exec('normalize_tlm', [target_name, packet_name, item_name], {
388
+ type: value_type,
389
+ })
390
+ }
391
+
392
+ get_all_commands(target_name) {
393
+ return this.exec('get_all_commands', [target_name])
394
+ }
395
+
396
+ get_all_command_names(target_name) {
397
+ return this.exec('get_all_command_names', [target_name])
398
+ }
399
+
400
+ get_command(target_name, command_name) {
401
+ return this.exec('get_command', [target_name, command_name])
402
+ }
403
+
404
+ get_cmd_cnts(target_commands) {
405
+ return this.exec('get_cmd_cnts', [target_commands])
406
+ }
407
+
408
+ get_cmd_value(
409
+ target_name,
410
+ packet_name,
411
+ parameter_name,
412
+ value_type = 'CONVERTED'
413
+ ) {
414
+ return this.exec('get_cmd_value', [
415
+ target_name,
416
+ packet_name,
417
+ parameter_name,
418
+ value_type,
419
+ ])
420
+ }
421
+
422
+ get_cmd_buffer(target_name, packet_name) {
423
+ return this.exec('get_cmd_buffer', [target_name, packet_name])
424
+ }
425
+
426
+ // Implementation of functionality shared by cmd methods with param_lists.
427
+ _cmd(method, target_name, command_name, param_list, headerOptions) {
428
+ var converted = null
429
+ for (var key in param_list) {
430
+ if (Object.prototype.hasOwnProperty.call(param_list, key)) {
431
+ converted = this.encode_openc3_type(param_list[key])
432
+ if (converted !== null) {
433
+ param_list[key] = converted
434
+ }
435
+ }
436
+ }
437
+ return this.exec(
438
+ method,
439
+ [target_name, command_name, param_list],
440
+ {},
441
+ headerOptions
442
+ )
443
+ }
444
+
445
+ get_cmd_hazardous(target_name, command_name, param_list) {
446
+ if (command_name === undefined) {
447
+ return this.exec('get_cmd_hazardous', target_name)
448
+ } else {
449
+ return this._cmd(
450
+ 'get_cmd_hazardous',
451
+ target_name,
452
+ command_name,
453
+ param_list
454
+ )
455
+ }
456
+ }
457
+
458
+ cmd(target_name, command_name, param_list, headerOptions = {}) {
459
+ if (command_name === undefined) {
460
+ return this.exec('cmd', target_name, {}, headerOptions)
461
+ } else {
462
+ return this._cmd(
463
+ 'cmd',
464
+ target_name,
465
+ command_name,
466
+ param_list,
467
+ headerOptions
468
+ )
469
+ }
470
+ }
471
+
472
+ cmd_no_range_check(target_name, command_name, param_list) {
473
+ if (command_name === undefined) {
474
+ return this.exec('cmd_no_range_check', target_name)
475
+ } else {
476
+ return this._cmd(
477
+ 'cmd_no_range_check',
478
+ target_name,
479
+ command_name,
480
+ param_list
481
+ )
482
+ }
483
+ }
484
+
485
+ cmd_raw(target_name, command_name, param_list) {
486
+ if (command_name === undefined) {
487
+ return this.exec('cmd_raw', target_name)
488
+ } else {
489
+ return this._cmd('cmd_raw', target_name, command_name, param_list)
490
+ }
491
+ }
492
+
493
+ cmd_raw_no_range_check(target_name, command_name, param_list) {
494
+ if (command_name === undefined) {
495
+ return this.exec('cmd_raw_no_range_check', target_name)
496
+ } else {
497
+ return this._cmd(
498
+ 'cmd_raw_no_range_check',
499
+ target_name,
500
+ command_name,
501
+ param_list
502
+ )
503
+ }
504
+ }
505
+
506
+ cmd_no_hazardous_check(target_name, command_name, param_list) {
507
+ if (command_name === undefined) {
508
+ return this.exec('cmd_no_hazardous_check', target_name)
509
+ } else {
510
+ return this._cmd(
511
+ 'cmd_no_hazardous_check',
512
+ target_name,
513
+ command_name,
514
+ param_list
515
+ )
516
+ }
517
+ }
518
+
519
+ cmd_no_checks(target_name, command_name, param_list) {
520
+ if (command_name === undefined) {
521
+ return this.exec('cmd_no_checks', target_name)
522
+ } else {
523
+ return this._cmd('cmd_no_checks', target_name, command_name, param_list)
524
+ }
525
+ }
526
+
527
+ cmd_raw_no_hazardous_check(target_name, command_name, param_list) {
528
+ if (command_name === undefined) {
529
+ return this.exec('cmd_raw_no_hazardous_check', target_name)
530
+ } else {
531
+ return this._cmd(
532
+ 'cmd_raw_no_hazardous_check',
533
+ target_name,
534
+ command_name,
535
+ param_list
536
+ )
537
+ }
538
+ }
539
+
540
+ cmd_raw_no_checks(target_name, command_name, param_list) {
541
+ if (command_name === undefined) {
542
+ return this.exec('cmd_raw_no_checks', target_name)
543
+ } else {
544
+ return this._cmd(
545
+ 'cmd_raw_no_checks',
546
+ target_name,
547
+ command_name,
548
+ param_list
549
+ )
550
+ }
551
+ }
552
+
553
+ build_command(target_name, command_name, param_list) {
554
+ if (command_name === undefined) {
555
+ return this.exec('build_command', target_name)
556
+ } else {
557
+ return this._cmd('build_command', target_name, command_name, param_list)
558
+ }
559
+ }
560
+
561
+ get_interface_names() {
562
+ return this.exec('get_interface_names', [])
563
+ }
564
+
565
+ send_raw(interface_name, data) {
566
+ return this.exec('send_raw', [interface_name, data])
567
+ }
568
+
569
+ list_configs(tool) {
570
+ return this.exec('list_configs', [tool])
571
+ }
572
+
573
+ load_config(tool, name) {
574
+ return this.exec('load_config', [tool, name])
575
+ }
576
+
577
+ save_config(tool, name, data) {
578
+ return this.exec('save_config', [tool, name, data])
579
+ }
580
+
581
+ delete_config(tool, name) {
582
+ return this.exec('delete_config', [tool, name])
583
+ }
584
+
585
+ enable_limits(target, packet, item) {
586
+ return this.exec('enable_limits', [target, packet, item])
587
+ }
588
+
589
+ disable_limits(target, packet, item) {
590
+ return this.exec('disable_limits', [target, packet, item])
591
+ }
592
+
593
+ get_out_of_limits() {
594
+ return this.exec('get_out_of_limits', [])
595
+ }
596
+
597
+ get_overall_limits_state(ignored) {
598
+ return this.exec('get_overall_limits_state', [ignored])
599
+ }
600
+
601
+ list_settings() {
602
+ return this.exec('list_settings', [])
603
+ }
604
+
605
+ get_all_settings() {
606
+ return this.exec('get_all_settings', [])
607
+ }
608
+
609
+ get_setting(name) {
610
+ return this.exec('get_setting', [name])
611
+ }
612
+
613
+ get_settings(array) {
614
+ return this.exec('get_settings', array)
615
+ }
616
+
617
+ save_setting(name, data) {
618
+ return this.exec('save_setting', [name, data])
619
+ }
620
+
621
+ get_metrics() {
622
+ return this.exec('get_metrics', [])
623
+ }
624
+
625
+ // TODO: Currently unused but seemed like a useful function
626
+ async hashString(string) {
627
+ if (window.isSecureContext) {
628
+ // Encode the string as an arrayBuffer which the subtle crypto API uses
629
+ const arrayBuffer = new TextEncoder().encode(string)
630
+ // Use the subtle crypto API to perform a SHA256 Sum of the array buffer
631
+ // The resulting hash is stored in an array buffer
632
+ const hashAsArrayBuffer = await crypto.subtle.digest(
633
+ 'SHA-256',
634
+ arrayBuffer
635
+ )
636
+ // To create a string we will get the hexadecimal value of each byte of the array buffer
637
+ // This gets us an array where each byte of the array buffer becomes one item in the array
638
+ const uint8ViewOfHash = new Uint8Array(hashAsArrayBuffer)
639
+ // We then convert it to a regular array so we can convert each item to hexadecimal strings
640
+ // Where to characters of 0-9 or a-f represent a number between 0 and 16, containing 4 bits of information, so 2 of them is 8 bits (1 byte).
641
+ return Array.from(uint8ViewOfHash)
642
+ .map((b) => b.toString(16).padStart(2, '0'))
643
+ .join('')
644
+ }
645
+ // else ?
646
+ }
647
+ }
@@ -0,0 +1,25 @@
1
+ @use 'sass:color';
2
+
3
+ @use '@material/theme/color-palette';
4
+
5
+ // Svelte Colors!
6
+ @use '@material/theme/index' as theme with (
7
+ $primary: #fff,
8
+ $secondary: #4dacff,
9
+ $surface: #005a8f,
10
+ $background: #005a8f,
11
+ $error: color-palette.$red-900
12
+ );
13
+
14
+ html,
15
+ body {
16
+ background-color: theme.$surface;
17
+ color: theme.$on-surface;
18
+ }
19
+
20
+ a {
21
+ color: #40b3ff;
22
+ }
23
+ a:visited {
24
+ color: color.scale(#40b3ff, $lightness: -35%);
25
+ }
@@ -0,0 +1,17 @@
1
+ import singleSpaSvelte from "single-spa-svelte";
2
+ import App from "./App.svelte";
3
+ import "../build/smui.css";
4
+
5
+ const svelteLifecycles = singleSpaSvelte({
6
+ component: App,
7
+ domElementGetter: function () {
8
+ let elem = document.getElementById("openc3-tool");
9
+ if (elem) {
10
+ return elem;
11
+ } else {
12
+ return new HTMLElement();
13
+ }
14
+ },
15
+ });
16
+
17
+ export const { bootstrap, mount, unmount } = svelteLifecycles;