openc3 5.0.9 → 5.0.11

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of openc3 might be problematic. Click here for more details.

Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/data/config/_id_items.yaml +2 -1
  3. data/data/config/_id_params.yaml +2 -1
  4. data/data/config/_items.yaml +2 -1
  5. data/data/config/_params.yaml +2 -1
  6. data/data/config/command_modifiers.yaml +30 -0
  7. data/data/config/item_modifiers.yaml +10 -0
  8. data/data/config/microservice.yaml +12 -0
  9. data/data/config/param_item_modifiers.yaml +10 -0
  10. data/data/config/plugins.yaml +0 -9
  11. data/data/config/telemetry_modifiers.yaml +10 -0
  12. data/ext/openc3/ext/packet/packet.c +20 -2
  13. data/ext/openc3/ext/structure/structure.c +12 -17
  14. data/lib/openc3/accessors/accessor.rb +71 -0
  15. data/lib/openc3/accessors/binary_accessor.rb +1226 -0
  16. data/lib/openc3/accessors/cbor_accessor.rb +83 -0
  17. data/lib/openc3/accessors/html_accessor.rb +28 -0
  18. data/lib/openc3/accessors/json_accessor.rb +131 -0
  19. data/lib/openc3/accessors/xml_accessor.rb +67 -0
  20. data/lib/openc3/accessors.rb +23 -0
  21. data/lib/openc3/api/interface_api.rb +10 -3
  22. data/lib/openc3/config/config_parser.rb +10 -4
  23. data/lib/openc3/core_ext/tempfile.rb +20 -0
  24. data/lib/openc3/core_ext.rb +1 -0
  25. data/lib/openc3/interfaces/interface.rb +1 -1
  26. data/lib/openc3/models/auth_model.rb +0 -1
  27. data/lib/openc3/models/cvt_model.rb +1 -10
  28. data/lib/openc3/models/microservice_model.rb +26 -0
  29. data/lib/openc3/models/note_model.rb +5 -5
  30. data/lib/openc3/packets/binary_accessor.rb +2 -1207
  31. data/lib/openc3/packets/packet.rb +106 -6
  32. data/lib/openc3/packets/packet_config.rb +30 -7
  33. data/lib/openc3/packets/parsers/limits_response_parser.rb +1 -3
  34. data/lib/openc3/packets/parsers/processor_parser.rb +1 -2
  35. data/lib/openc3/packets/structure.rb +39 -14
  36. data/lib/openc3/packets/structure_item.rb +15 -1
  37. data/lib/openc3/script/storage.rb +2 -0
  38. data/lib/openc3/utilities/authentication.rb +6 -4
  39. data/lib/openc3/utilities/local_mode.rb +10 -1
  40. data/lib/openc3/utilities/s3.rb +3 -1
  41. data/lib/openc3/utilities/s3_autoload.rb +8 -6
  42. data/lib/openc3/utilities/simulated_target.rb +3 -2
  43. data/lib/openc3/utilities/target_file.rb +45 -6
  44. data/lib/openc3/version.rb +5 -5
  45. data/lib/openc3.rb +1 -0
  46. metadata +38 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce13d20a53c970d01c019afff0088ee574998e393eb0e56be1ea3bc1af2dbc3c
4
- data.tar.gz: '079099f252bf45fcbbcec9f05239de9c84858a166cfb2077806554bcdae76258'
3
+ metadata.gz: 89287db0131e005414e13d5e1ad18916fb85af1fecd415feb234ded2dc7808a4
4
+ data.tar.gz: 18ba67b0e23fb908c256540fe380e863655d7fd8b9368dd42fea34d254820c61
5
5
  SHA512:
6
- metadata.gz: bf8762aa78976151e1c561e55fd08de0593f82055d759a6c1c2ed5db9fd3b0510141077f70592cade4a7dbf1ff957657ea4252b6a7d4839046b6b69f853a5cda
7
- data.tar.gz: 457563612d61588d7f18da69a48df88b0368b0fba3e9840d7a316eabf334d3e88218cfca584327f927f23f119c005aef4dba63e033b011a7d4c8bcdc071df15c
6
+ metadata.gz: c181ccc282a7a97baf9f5bba954822d6e38499ead775bb8261216e70f1ecd4870bc071f2c9a56aa835697f4596e0748df018bde8a18486deb1a9a63360217f66
7
+ data.tar.gz: ea11fef50705c7cfa4c74f239abbf0c0c02b163a10c3cda6db15408eb3fef1fd69501df8be844741d49f274a1ad9edc01af866614f20ccd400c24f5ab73a512d
@@ -20,5 +20,6 @@
20
20
  values: "['\"].*['\"]"
21
21
  - name: Endianness
22
22
  required: false
23
- description: Indicates if the item is to be interpreted in Big Endian or Little Endian format
23
+ description: Indicates if the item is to be interpreted in Big Endian or Little Endian format.
24
+ See guide on <a href="https://openc3.com/docs/v5/little-endian-bitfields">Little Endian Bitfields</a>.
24
25
  values: <%= %w(BIG_ENDIAN LITTLE_ENDIAN) %>
@@ -31,7 +31,8 @@
31
31
  values: "['\"].*['\"]"
32
32
  - name: Endianness
33
33
  required: false
34
- description: Indicates if the data in this command is to be sent in Big Endian or Little Endian format
34
+ description: Indicates if the data in this command is to be sent in Big Endian or Little Endian format.
35
+ See guide on <a href="https://openc3.com/docs/v5/little-endian-bitfields">Little Endian Bitfields</a>.
35
36
  values: <%= %w(BIG_ENDIAN LITTLE_ENDIAN) %>
36
37
  UINT:
37
38
  parameters: *params
@@ -16,5 +16,6 @@
16
16
  values: "['\"].*['\"]"
17
17
  - name: Endianness
18
18
  required: false
19
- description: Indicates if the item is to be interpreted in Big Endian or Little Endian format
19
+ description: Indicates if the item is to be interpreted in Big Endian or Little Endian format.
20
+ See guide on <a href="https://openc3.com/docs/v5/little-endian-bitfields">Little Endian Bitfields</a>.
20
21
  values: <%= %w(BIG_ENDIAN LITTLE_ENDIAN) %>
@@ -32,7 +32,8 @@
32
32
  values: '[''"].*[''"]'
33
33
  - name: Endianness
34
34
  required: false
35
- description: Indicates if the data in this command is to be sent in Big Endian or Little Endian format
35
+ description: Indicates if the data in this command is to be sent in Big Endian or Little Endian format.
36
+ See guide on <a href="https://openc3.com/docs/v5/little-endian-bitfields">Little Endian Bitfields</a>.
36
37
  values: <%= %w(BIG_ENDIAN LITTLE_ENDIAN) %>
37
38
  UINT:
38
39
  parameters: *params
@@ -158,3 +158,33 @@ HAZARDOUS:
158
158
  required: false
159
159
  description: Description for why the command is hazardous which must be enclosed with quotes
160
160
  values: "['\"].*['\"]"
161
+ ACCESSOR:
162
+ summary: Defines the class used to read and write raw values from the packet
163
+ description: Defines the class that is used too read raw values from the packet. Defaults to BinaryAccessor.
164
+ Provided accessors also include JsonAccessor, CborAccessor, HtmlAccessor, and XmlAccessor.
165
+ parameters:
166
+ - name: Accessor Class Name
167
+ required: true
168
+ description: The name of the accessor class
169
+ values: .+
170
+ since: 5.0.10
171
+ TEMPLATE:
172
+ summary: Defines a template string used to initialize the command before default values are filled in
173
+ description: Generally the template string is formatted in JSON or HTML and then values are filled in with
174
+ command parameters. Must be UTF-8 encoded.
175
+ parameters:
176
+ - name: Template
177
+ required: true
178
+ description: The template string which should be enclosed in quotes
179
+ values: "['\"].*['\"]"
180
+ since: 5.0.10
181
+ TEMPLATE_FILE:
182
+ summary: Defines a template file used to initialize the command before default values are filled in
183
+ description: Generally the template file is formatted in JSON or HTML and then values are filled in with
184
+ command parameters. Can be binary or UTF-8.
185
+ parameters:
186
+ - name: Template File Path
187
+ required: true
188
+ description: The relative path to the template file. Filename should generally start with an underscore.
189
+ values: .+
190
+ since: 5.0.10
@@ -219,3 +219,13 @@ LIMITS_RESPONSE:
219
219
  description: Variable length number of options that will be passed to the
220
220
  class constructor
221
221
  values: .+
222
+ KEY:
223
+ summary: Defines the key used to access this raw value in the packet.
224
+ description: Keys are often JsonPath or XPath strings
225
+ example: KEY $.book.title
226
+ parameters:
227
+ - name: Key string
228
+ required: true
229
+ description: The key to access this item
230
+ values: .+
231
+ since: 5.0.10
@@ -32,6 +32,18 @@ MICROSERVICE:
32
32
  required: true
33
33
  description: Working directory to run the microservice CMD in. Can be a path relative to the microservice folder in the plugin, or an absolute path in the container the microservice runs in.
34
34
  values: .+
35
+ PORT:
36
+ summary: Open port for the microservice
37
+ description: Kubernetes needs a Service to be applied to open a port so this is required for Kubernetes support
38
+ parameters:
39
+ - name: Number
40
+ required: true
41
+ description: Port number
42
+ values: \d+
43
+ - name: Protocol
44
+ required: false
45
+ description: Port protocol. Default is TCP.
46
+ values: .+
35
47
  TOPIC:
36
48
  summary: Associate a Redis topic
37
49
  description: Redis topic to associate with this microservice. Standard OpenC3 microservices such as decom_microservice use this information to know what packet streams to subscribe to. The TOPIC keyword can be used as many times as necessary to associate all needed topics.
@@ -50,3 +50,13 @@ OVERLAP:
50
50
  If an item's bit offset overlaps another item, OpenC3 issues a warning. This keyword explicitly
51
51
  allows an item to overlap another and supresses the warning message.
52
52
  since: 4.4.1
53
+ KEY:
54
+ summary: Defines the key used to access this raw value in the packet.
55
+ description: Keys are often JsonPath or XPath strings
56
+ example: KEY $.book.title
57
+ parameters:
58
+ - name: Key string
59
+ required: true
60
+ description: The key to access this item
61
+ values: .+
62
+ since: 5.0.10
@@ -38,15 +38,6 @@ INTERFACE:
38
38
  documentation for more details.
39
39
  ROUTER:
40
40
  modifiers:
41
- ROUTE:
42
- summary: Map an interface to a router
43
- description: Once an interface has been mapped to a router, all its received telemetry
44
- will be sent out through the router.
45
- parameters:
46
- - name: Interface
47
- required: true
48
- description: Name of the interface
49
- values: .+
50
41
  <%= MetaConfigParser.load('interface_modifiers.yaml').to_meta_config_yaml(4) %>
51
42
  summary: Create router to receive commands and output telemetry packets from one or more interfaces
52
43
  description: Creates an router which receives command packets from
@@ -157,3 +157,13 @@ HIDDEN:
157
157
  It also hides this telemetry from appearing in the Script Runner popup helper
158
158
  when writing scripts. The telemetry still exists in the system and can received
159
159
  and checked by scripts.
160
+ ACCESSOR:
161
+ summary: Defines the class used to read and write raw values from the packet
162
+ description: Defines the class that is used too read raw values from the packet. Defaults to BinaryAccessor.
163
+ Provided accessors also include JsonAccessor, CborAccessor, HtmlAccessor, and XmlAccessor.
164
+ parameters:
165
+ - name: Accessor Class Name
166
+ required: true
167
+ description: The name of the accessor class
168
+ values: .+
169
+ since: 5.0.10
@@ -57,6 +57,7 @@ static ID id_ivar_packet_name = 0;
57
57
  static ID id_ivar_description = 0;
58
58
  static ID id_ivar_stored = 0;
59
59
  static ID id_ivar_extra = 0;
60
+ static ID id_ivar_template = 0;
60
61
 
61
62
  /* Sets the target name this packet is associated with. Unidentified packets
62
63
  * will have target name set to nil.
@@ -193,6 +194,22 @@ static VALUE packet_initialize(int argc, VALUE *argv, VALUE self)
193
194
 
194
195
  switch (argc)
195
196
  {
197
+ case 0:
198
+ target_name = Qnil;
199
+ packet_name = Qnil;
200
+ default_endianness = symbol_BIG_ENDIAN;
201
+ description = Qnil;
202
+ buffer = Qnil;
203
+ item_class = cPacketItem;
204
+ break;
205
+ case 1:
206
+ target_name = argv[0];
207
+ packet_name = Qnil;
208
+ default_endianness = symbol_BIG_ENDIAN;
209
+ description = Qnil;
210
+ buffer = Qnil;
211
+ item_class = cPacketItem;
212
+ break;
196
213
  case 2:
197
214
  target_name = argv[0];
198
215
  packet_name = argv[1];
@@ -235,7 +252,7 @@ static VALUE packet_initialize(int argc, VALUE *argv, VALUE self)
235
252
  break;
236
253
  default:
237
254
  /* Invalid number of arguments given */
238
- rb_raise(rb_eArgError, "wrong number of arguments (%d for 2..6)", argc);
255
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..6)", argc);
239
256
  break;
240
257
  };
241
258
 
@@ -264,7 +281,7 @@ static VALUE packet_initialize(int argc, VALUE *argv, VALUE self)
264
281
  rb_ivar_set(self, id_ivar_disabled, Qfalse);
265
282
  rb_ivar_set(self, id_ivar_stored, Qfalse);
266
283
  rb_ivar_set(self, id_ivar_extra, Qnil);
267
-
284
+ rb_ivar_set(self, id_ivar_template, Qnil);
268
285
  return self;
269
286
  }
270
287
 
@@ -305,6 +322,7 @@ void Init_packet(void)
305
322
  id_ivar_description = rb_intern("@description");
306
323
  id_ivar_stored = rb_intern("@stored");
307
324
  id_ivar_extra = rb_intern("@extra");
325
+ id_ivar_template = rb_intern("@template");
308
326
 
309
327
  cPacket = rb_define_class_under(mOpenC3, "Packet", cStructure);
310
328
  rb_define_method(cPacket, "initialize", packet_initialize, -1);
@@ -44,6 +44,7 @@ static VALUE MAX_INT64 = Qnil;
44
44
  static VALUE MAX_UINT64 = Qnil;
45
45
 
46
46
  static VALUE mOpenC3 = Qnil;
47
+ static VALUE cAccessor = Qnil;
47
48
  static VALUE cBinaryAccessor = Qnil;
48
49
  static VALUE cStructure = Qnil;
49
50
  static VALUE cStructureItem = Qnil;
@@ -51,6 +52,7 @@ static VALUE cStructureItem = Qnil;
51
52
  static ID id_method_to_s = 0;
52
53
  static ID id_method_raise_buffer_error = 0;
53
54
  static ID id_method_read_array = 0;
55
+ static ID id_method_read_item = 0;
54
56
  static ID id_method_force_encoding = 0;
55
57
  static ID id_method_freeze = 0;
56
58
  static ID id_method_slice = 0;
@@ -78,6 +80,7 @@ static ID id_ivar_fixed_size = 0;
78
80
  static ID id_ivar_short_buffer_allowed = 0;
79
81
  static ID id_ivar_mutex = 0;
80
82
  static ID id_ivar_create_index = 0;
83
+ static ID id_ivar_accessor = 0;
81
84
 
82
85
  static ID id_const_ASCII_8BIT_STRING = 0;
83
86
  static ID id_const_ZERO_STRING = 0;
@@ -1298,11 +1301,8 @@ static VALUE structure_length(VALUE self)
1298
1301
 
1299
1302
  static VALUE read_item_internal(VALUE self, VALUE item, VALUE buffer)
1300
1303
  {
1301
- volatile VALUE bit_offset = Qnil;
1302
- volatile VALUE bit_size = Qnil;
1303
1304
  volatile VALUE data_type = Qnil;
1304
- volatile VALUE array_size = Qnil;
1305
- volatile VALUE endianness = Qnil;
1305
+ volatile VALUE accessor = Qnil;
1306
1306
 
1307
1307
  data_type = rb_ivar_get(item, id_ivar_data_type);
1308
1308
  if (data_type == symbol_DERIVED)
@@ -1314,18 +1314,9 @@ static VALUE read_item_internal(VALUE self, VALUE item, VALUE buffer)
1314
1314
  {
1315
1315
  buffer = rb_funcall(self, id_method_allocate_buffer_if_needed, 0);
1316
1316
  }
1317
- bit_offset = rb_ivar_get(item, id_ivar_bit_offset);
1318
- bit_size = rb_ivar_get(item, id_ivar_bit_size);
1319
- array_size = rb_ivar_get(item, id_ivar_array_size);
1320
- endianness = rb_ivar_get(item, id_ivar_endianness);
1321
- if (RTEST(array_size))
1322
- {
1323
- return rb_funcall(cBinaryAccessor, id_method_read_array, 6, bit_offset, bit_size, data_type, array_size, buffer, endianness);
1324
- }
1325
- else
1326
- {
1327
- return binary_accessor_read(cBinaryAccessor, bit_offset, bit_size, data_type, buffer, endianness);
1328
- }
1317
+
1318
+ accessor = rb_ivar_get(self, id_ivar_accessor);
1319
+ return rb_funcall(accessor, id_method_read_item, 2, item, buffer);
1329
1320
  }
1330
1321
 
1331
1322
  /*
@@ -1562,6 +1553,7 @@ static VALUE structure_initialize(int argc, VALUE *argv, VALUE self)
1562
1553
  rb_ivar_set(self, id_ivar_fixed_size, Qtrue);
1563
1554
  rb_ivar_set(self, id_ivar_short_buffer_allowed, Qfalse);
1564
1555
  rb_ivar_set(self, id_ivar_mutex, Qnil);
1556
+ rb_ivar_set(self, id_ivar_accessor, cBinaryAccessor);
1565
1557
  }
1566
1558
  else
1567
1559
  {
@@ -1607,11 +1599,13 @@ void Init_structure(void)
1607
1599
  volatile VALUE ascii_8bit_string = Qnil;
1608
1600
 
1609
1601
  mOpenC3 = rb_define_module("OpenC3");
1610
- cBinaryAccessor = rb_define_class_under(mOpenC3, "BinaryAccessor", rb_cObject);
1602
+ cAccessor = rb_define_class_under(mOpenC3, "Accessor", rb_cObject);
1603
+ cBinaryAccessor = rb_define_class_under(mOpenC3, "BinaryAccessor", cAccessor);
1611
1604
 
1612
1605
  id_method_to_s = rb_intern("to_s");
1613
1606
  id_method_raise_buffer_error = rb_intern("raise_buffer_error");
1614
1607
  id_method_read_array = rb_intern("read_array");
1608
+ id_method_read_item = rb_intern("read_item");
1615
1609
  id_method_force_encoding = rb_intern("force_encoding");
1616
1610
  id_method_freeze = rb_intern("freeze");
1617
1611
  id_method_slice = rb_intern("slice");
@@ -1670,6 +1664,7 @@ void Init_structure(void)
1670
1664
  id_ivar_short_buffer_allowed = rb_intern("@short_buffer_allowed");
1671
1665
  id_ivar_mutex = rb_intern("@mutex");
1672
1666
  id_ivar_create_index = rb_intern("@create_index");
1667
+ id_ivar_accessor = rb_intern("@accessor");
1673
1668
 
1674
1669
  symbol_LITTLE_ENDIAN = ID2SYM(rb_intern("LITTLE_ENDIAN"));
1675
1670
  symbol_BIG_ENDIAN = ID2SYM(rb_intern("BIG_ENDIAN"));
@@ -0,0 +1,71 @@
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2022 OpenC3, Inc.
4
+ # All Rights Reserved.
5
+ #
6
+ # This program is free software; you can modify and/or redistribute it
7
+ # under the terms of the GNU Affero General Public License
8
+ # as published by the Free Software Foundation; version 3 with
9
+ # attribution addendums as found in the LICENSE.txt
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Affero General Public License for more details.
15
+
16
+ module OpenC3
17
+ class Accessor
18
+ def read_item(item, buffer)
19
+ raise "Must be defined by subclass"
20
+ end
21
+
22
+ def write_item(item, value, buffer)
23
+ raise "Must be defined by subclass"
24
+ end
25
+
26
+ def self.read_items(items, buffer)
27
+ result = {}
28
+ items.each do |item|
29
+ result[item.name] = read_item(item, buffer)
30
+ end
31
+ return result
32
+ end
33
+
34
+ def self.write_items(items, values, buffer)
35
+ items.each_with_index do |item, index|
36
+ write_item(item, values[index], buffer)
37
+ end
38
+ return buffer
39
+ end
40
+
41
+ def self.convert_to_type(value, item)
42
+ data_type = item.data_type
43
+ if (data_type == :STRING) || (data_type == :BLOCK)
44
+ #######################################
45
+ # Handle :STRING and :BLOCK data types
46
+ #######################################
47
+ value = value.to_s
48
+
49
+ elsif (data_type == :INT) || (data_type == :UINT)
50
+ ###################################
51
+ # Handle :INT data type
52
+ ###################################
53
+ value = Integer(value)
54
+
55
+ elsif data_type == :FLOAT
56
+ ##########################
57
+ # Handle :FLOAT data type
58
+ ##########################
59
+ value = Float(value)
60
+
61
+ else
62
+ ############################
63
+ # Handle Unknown data types
64
+ ############################
65
+
66
+ raise(ArgumentError, "data_type #{data_type} is not recognized")
67
+ end
68
+ return value
69
+ end
70
+ end
71
+ end