openc3 5.0.8 → 5.0.10
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.
- checksums.yaml +4 -4
- data/bin/openc3cli +128 -95
- data/data/config/_id_items.yaml +2 -1
- data/data/config/_id_params.yaml +2 -1
- data/data/config/_items.yaml +2 -1
- data/data/config/_params.yaml +2 -1
- data/data/config/command_modifiers.yaml +30 -0
- data/data/config/item_modifiers.yaml +10 -0
- data/data/config/microservice.yaml +12 -0
- data/data/config/param_item_modifiers.yaml +10 -0
- data/data/config/plugins.yaml +0 -9
- data/data/config/telemetry_modifiers.yaml +10 -0
- data/data/config/widgets.yaml +49 -73
- data/ext/openc3/ext/packet/packet.c +20 -2
- data/ext/openc3/ext/structure/structure.c +12 -17
- data/lib/openc3/accessors/accessor.rb +71 -0
- data/lib/openc3/accessors/binary_accessor.rb +1226 -0
- data/lib/openc3/accessors/cbor_accessor.rb +83 -0
- data/lib/openc3/accessors/html_accessor.rb +28 -0
- data/lib/openc3/accessors/json_accessor.rb +131 -0
- data/lib/openc3/accessors/xml_accessor.rb +67 -0
- data/lib/openc3/accessors.rb +23 -0
- data/lib/openc3/api/cmd_api.rb +5 -2
- data/lib/openc3/api/interface_api.rb +15 -0
- data/lib/openc3/api/limits_api.rb +3 -3
- data/lib/openc3/config/config_parser.rb +10 -4
- data/lib/openc3/core_ext/file.rb +5 -0
- data/lib/openc3/core_ext/tempfile.rb +20 -0
- data/lib/openc3/io/json_rpc.rb +3 -3
- data/lib/openc3/microservices/cleanup_microservice.rb +7 -5
- data/lib/openc3/models/cvt_model.rb +1 -10
- data/lib/openc3/models/interface_model.rb +41 -0
- data/lib/openc3/models/microservice_model.rb +33 -1
- data/lib/openc3/models/plugin_model.rb +1 -1
- data/lib/openc3/models/target_model.rb +85 -68
- data/lib/openc3/packets/binary_accessor.rb +2 -1207
- data/lib/openc3/packets/packet.rb +106 -6
- data/lib/openc3/packets/packet_config.rb +30 -7
- data/lib/openc3/packets/parsers/limits_response_parser.rb +1 -3
- data/lib/openc3/packets/parsers/processor_parser.rb +1 -2
- data/lib/openc3/packets/parsers/xtce_parser.rb +68 -3
- data/lib/openc3/packets/structure.rb +39 -14
- data/lib/openc3/packets/structure_item.rb +15 -1
- data/lib/openc3/script/storage.rb +19 -1
- data/lib/openc3/utilities/local_mode.rb +521 -0
- data/lib/openc3/utilities/simulated_target.rb +3 -2
- data/lib/openc3/utilities/target_file.rb +146 -0
- data/lib/openc3/version.rb +5 -5
- data/lib/openc3.rb +1 -0
- metadata +45 -7
data/data/config/widgets.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
VERTICAL:
|
3
|
-
summary: Places the widgets it encapsulates vertically
|
4
|
-
|
3
|
+
summary: Places the widgets it encapsulates vertically
|
4
|
+
description: The screen defaults to a vertical layout, so if no layout widgets
|
5
5
|
are specified, all widgets will be automatically placed within a VERTICAL
|
6
6
|
layout widget. The VERTICAL widget sizes itself to fit its contents.
|
7
7
|
parameters:
|
@@ -14,9 +14,9 @@ VERTICAL:
|
|
14
14
|
description: Pack all widgets vertically (default = true)
|
15
15
|
values: .*
|
16
16
|
VERTICALBOX:
|
17
|
-
summary: Places the widgets it encapsulates vertically
|
18
|
-
|
19
|
-
to fit its contents vertically and to fit the screen horizontally
|
17
|
+
summary: Places the widgets it encapsulates vertically inside a thin border
|
18
|
+
description: The VERTICALBOX widget sizes itself
|
19
|
+
to fit its contents vertically and to fit the screen horizontally
|
20
20
|
parameters:
|
21
21
|
- name: Title
|
22
22
|
required: false
|
@@ -32,16 +32,15 @@ VERTICALBOX:
|
|
32
32
|
values: .*
|
33
33
|
HORIZONTAL:
|
34
34
|
summary: Places the widgets it encapsulates horizontally
|
35
|
-
|
35
|
+
description: The HORIZONTAL widget sizes itself to fit its contents
|
36
36
|
parameters:
|
37
37
|
- name: Horizontal spacing
|
38
38
|
required: false
|
39
39
|
description: Horizontal spacing between widgets in pixels (default = 1)
|
40
40
|
values: .*
|
41
41
|
HORIZONTALBOX:
|
42
|
-
summary: Places the widgets it encapsulates horizontally
|
43
|
-
|
44
|
-
to fit its contents.
|
42
|
+
summary: Places the widgets it encapsulates horizontally inside a thin border
|
43
|
+
description: The HORIZONTALBOX widget sizes itself to fit its contents
|
45
44
|
parameters:
|
46
45
|
- name: Title
|
47
46
|
required: false
|
@@ -52,8 +51,8 @@ HORIZONTALBOX:
|
|
52
51
|
description: Horizontal spacing between widgets in pixels (default = 1)
|
53
52
|
values: .*
|
54
53
|
MATRIXBYCOLUMNS:
|
55
|
-
summary: Places the widgets into a table-like matrix
|
56
|
-
|
54
|
+
summary: Places the widgets into a table-like matrix
|
55
|
+
description: The MATRIXBYCOLUMNS widget sizes itself to fit its contents
|
57
56
|
parameters:
|
58
57
|
- name: Columns
|
59
58
|
required: true
|
@@ -68,15 +67,15 @@ MATRIXBYCOLUMNS:
|
|
68
67
|
description: Vertical spacing between matrix items in pixels (default = 0)
|
69
68
|
values: .*
|
70
69
|
SCROLLWINDOW:
|
71
|
-
summary: Places the widgets inside of it into a scrollable area
|
72
|
-
|
70
|
+
summary: Places the widgets inside of it into a scrollable area
|
71
|
+
description: The SCROLLWINDOW widget sizes itself to fit the screen in which it is contained
|
73
72
|
parameters:
|
74
73
|
- name: Height
|
75
74
|
required: false
|
76
75
|
description: Maximum height of the scroll window in pixels (default = 180)
|
77
76
|
values: .*
|
78
77
|
SPACER:
|
79
|
-
summary: Places a fixed size spacer in between widgets
|
78
|
+
summary: Places a fixed size spacer in between widgets
|
80
79
|
parameters:
|
81
80
|
- name: Width
|
82
81
|
required: false
|
@@ -87,7 +86,7 @@ SPACER:
|
|
87
86
|
description: Height of the widget
|
88
87
|
values: .*
|
89
88
|
IFRAME:
|
90
|
-
summary: Open external tools in an Iframe within OpenC3
|
89
|
+
summary: Open external tools in an Iframe within OpenC3
|
91
90
|
parameters:
|
92
91
|
- name: URL
|
93
92
|
required: true
|
@@ -130,18 +129,16 @@ IMAGEVIEWER:
|
|
130
129
|
values: .*
|
131
130
|
TABBOOK:
|
132
131
|
summary: Creates a tabbed area in which to place TABITEM widgets
|
133
|
-
to form a tabbed layout.
|
134
132
|
TABITEM:
|
135
|
-
summary: Creates a tab into which to place widgets
|
136
|
-
automatically acts like a VERTICAL widget.
|
133
|
+
summary: Creates a VERTICAL layout tab into which to place widgets
|
137
134
|
parameters:
|
138
135
|
- name: Tab text
|
139
136
|
required: true
|
140
137
|
description: Text to diplay in the tab
|
141
138
|
values: .*
|
142
139
|
LABEL:
|
143
|
-
summary: Displays text on the screen
|
144
|
-
|
140
|
+
summary: Displays text on the screen
|
141
|
+
description: Generally, label widgets contain a telemetry mnemonic and are placed next to the telemetry VALUE widget
|
145
142
|
parameters:
|
146
143
|
- name: Text
|
147
144
|
required: true
|
@@ -150,16 +147,16 @@ LABEL:
|
|
150
147
|
# HORIZONTALLINE:
|
151
148
|
# summary: Displays a horizontal line on the screen that can be used as a separator
|
152
149
|
SECTIONHEADER:
|
153
|
-
summary: Displays a label that is underlined with a
|
154
|
-
|
155
|
-
inside of a VERTICALBOX widget
|
150
|
+
summary: Displays a label that is underlined with a horizontal line
|
151
|
+
description: Generally, SECTIONHEADER widgets are the first widget placed
|
152
|
+
inside of a VERTICALBOX widget
|
156
153
|
parameters:
|
157
154
|
- name: Text
|
158
155
|
required: true
|
159
156
|
description: Text to display above the horizontal line
|
160
157
|
values: .*
|
161
158
|
TITLE:
|
162
|
-
summary: Displays a large centered title on the screen
|
159
|
+
summary: Displays a large centered title on the screen
|
163
160
|
parameters:
|
164
161
|
- name: Text
|
165
162
|
required: true
|
@@ -186,8 +183,7 @@ TITLE:
|
|
186
183
|
# description: The vertical size policy of the spacer. Default is MINIMUM.
|
187
184
|
# values: <%= %w(FIXED MINIMUM MAXIMUM PREFERRED EXPANDING MINIMUMEXPANDING IGNORED) %>
|
188
185
|
ARRAY:
|
189
|
-
summary: Displays data
|
190
|
-
Data is organized into rows and by default space separated.
|
186
|
+
summary: Displays ARRAY data organized into rows and space separated
|
191
187
|
parameters:
|
192
188
|
- name: Target name
|
193
189
|
required: true
|
@@ -222,8 +218,7 @@ ARRAY:
|
|
222
218
|
description: The type of the value to display. Default is CONVERTED.
|
223
219
|
values: <%= %w(RAW CONVERTED FORMATTED WITH_UNITS) %>
|
224
220
|
BLOCK:
|
225
|
-
summary: Displays data
|
226
|
-
Data is organized into rows and space separated.
|
221
|
+
summary: Displays BLOCK data organized into rows and space separated
|
227
222
|
parameters:
|
228
223
|
- name: Target name
|
229
224
|
required: true
|
@@ -307,8 +302,8 @@ BLOCK:
|
|
307
302
|
# description: The font size. (default = 100)
|
308
303
|
# values: .*
|
309
304
|
FORMATVALUE:
|
310
|
-
summary: Displays a box with a value
|
311
|
-
|
305
|
+
summary: Displays a box with a formatted value
|
306
|
+
description: Data is formatted by the specified string rather than by a format string given in
|
312
307
|
the telemetry definition files. The white portion of the box darkens to gray
|
313
308
|
while the value remains stagnant, then brightens to white each time the value
|
314
309
|
changes. Additionally the value is colored based on the items limits state
|
@@ -339,9 +334,7 @@ FORMATVALUE:
|
|
339
334
|
description: The number of characters wide to make the value box (default = 12)
|
340
335
|
values: .*
|
341
336
|
LABELLED:
|
342
|
-
summary:
|
343
|
-
Displays a Label widget followed by a LED which changes color based on telemetry values.
|
344
|
-
See the LED widget documentation for more information.
|
337
|
+
summary: Displays a LABEL followed by a LED
|
345
338
|
parameters:
|
346
339
|
- name: Target name
|
347
340
|
required: true
|
@@ -376,8 +369,7 @@ LABELLED:
|
|
376
369
|
pushes them to the respective side with the space going on the opposite.
|
377
370
|
values: ["SPLIT", "CENTER", "LEFT", "RIGHT"]
|
378
371
|
LABELPROGRESSBAR:
|
379
|
-
summary: Displays a LABEL
|
380
|
-
name followed by a PROGRESSBAR widget to show the items value.
|
372
|
+
summary: Displays a LABEL with the item name followed by a PROGRESSBAR
|
381
373
|
parameters:
|
382
374
|
- name: Target name
|
383
375
|
required: true
|
@@ -405,8 +397,7 @@ LABELPROGRESSBAR:
|
|
405
397
|
description: The type of the value to display. Default is CONVERTED.
|
406
398
|
values: <%= %w(RAW CONVERTED FORMATTED WITH_UNITS) %>
|
407
399
|
LABELVALUE:
|
408
|
-
summary: Displays a LABEL
|
409
|
-
items name followed by a VALUE widget to display the items value.
|
400
|
+
summary: Displays a LABEL with the item name followed by a VALUE
|
410
401
|
parameters:
|
411
402
|
- name: Target name
|
412
403
|
required: true
|
@@ -437,8 +428,7 @@ LABELVALUE:
|
|
437
428
|
pushes them to the respective side with the space going on the opposite.
|
438
429
|
values: ["SPLIT", "CENTER", "LEFT", "RIGHT"]
|
439
430
|
LABELVALUEDESC:
|
440
|
-
summary: Displays a LABEL
|
441
|
-
items description followed by a VALUE widget to display the items value.
|
431
|
+
summary: Displays a LABEL with the items description followed by a VALUE
|
442
432
|
parameters:
|
443
433
|
- name: Target name
|
444
434
|
required: true
|
@@ -495,8 +485,7 @@ LABELVALUEDESC:
|
|
495
485
|
# description: The number of characters wide to make the value box (default = 12)
|
496
486
|
# values: .*
|
497
487
|
LABELVALUELIMITSBAR:
|
498
|
-
summary: Displays a LABEL
|
499
|
-
followed by a VALUE widget to display the item's value, followed by a LIMITSBAR widget.
|
488
|
+
summary: Displays a LABEL with the item name followed by VALUE and LIMITSBAR widgets
|
500
489
|
parameters:
|
501
490
|
- name: Target name
|
502
491
|
required: true
|
@@ -519,9 +508,7 @@ LABELVALUELIMITSBAR:
|
|
519
508
|
description: The number of characters wide to make the value box (default = 12)
|
520
509
|
values: .*
|
521
510
|
LABELVALUELIMITSCOLUMN:
|
522
|
-
summary: Displays a LABEL
|
523
|
-
the telemetry itemls name, followed by a VALUE widget to display the item's
|
524
|
-
value, followed by a LIMITSCOLUMN widget.
|
511
|
+
summary: Displays a LABEL with the item name followed by VALUE and LIMITSCOLUMN widgets
|
525
512
|
parameters:
|
526
513
|
- name: Target name
|
527
514
|
required: true
|
@@ -544,8 +531,7 @@ LABELVALUELIMITSCOLUMN:
|
|
544
531
|
description: The number of characters wide to make the value box (default = 12)
|
545
532
|
values: .*
|
546
533
|
LABELVALUERANGEBAR:
|
547
|
-
summary: Displays a LABEL
|
548
|
-
followed by a VALUE widget to display the item's value, followed by a RANGEBAR widget.
|
534
|
+
summary: Displays a LABEL with the item name followed by VALUE and RANGEBAR widgets
|
549
535
|
parameters:
|
550
536
|
- name: Target name
|
551
537
|
required: true
|
@@ -628,8 +614,8 @@ LABELVALUERANGEBAR:
|
|
628
614
|
# description: Height of the range bar (default = 25)
|
629
615
|
# values: .*
|
630
616
|
LED:
|
631
|
-
summary: Displays a LED which changes color based on telemetry values
|
632
|
-
|
617
|
+
summary: Displays a LED which changes color based on telemetry values
|
618
|
+
description: By default TRUE is green and FALSE is red and all other values are black.
|
633
619
|
Additional values can be added by using the LED_COLOR setting. For example
|
634
620
|
LED INST PARAMS VALUE3 RAW can be followed by SETTING LED_COLOR 0 GREEN,
|
635
621
|
SETTING LED_COLOR 1 RED, and SETTING LED_COLOR ANY ORANGE.
|
@@ -659,8 +645,7 @@ LED:
|
|
659
645
|
description: Height of the LED circle (default = 15)
|
660
646
|
values: .*
|
661
647
|
LIMITSBAR:
|
662
|
-
summary: Displays
|
663
|
-
item's value falls withing its limits ranges horizontally.
|
648
|
+
summary: Displays an item's current value within its colored limits horizontally
|
664
649
|
parameters:
|
665
650
|
- name: Target name
|
666
651
|
required: true
|
@@ -687,8 +672,7 @@ LIMITSBAR:
|
|
687
672
|
description: Height of the range bar (default = 25)
|
688
673
|
values: .*
|
689
674
|
LIMITSCOLUMN:
|
690
|
-
summary: Displays
|
691
|
-
item's value falls withing its limits ranges vertically.
|
675
|
+
summary: Displays an item's current value within its colored limits vertically
|
692
676
|
parameters:
|
693
677
|
- name: Target name
|
694
678
|
required: true
|
@@ -715,8 +699,7 @@ LIMITSCOLUMN:
|
|
715
699
|
description: Height of the range bar (default = 25)
|
716
700
|
values: .*
|
717
701
|
LIMITSCOLOR:
|
718
|
-
summary: Displays a
|
719
|
-
limits color of an item
|
702
|
+
summary: Displays a circle depicting the limits color of an item
|
720
703
|
parameters:
|
721
704
|
- name: Target name
|
722
705
|
required: true
|
@@ -743,9 +726,7 @@ LIMITSCOLOR:
|
|
743
726
|
description: Show the full item name (default is false)
|
744
727
|
values: .*
|
745
728
|
VALUELIMITSBAR:
|
746
|
-
summary: Displays
|
747
|
-
an items value falls withing its limits ranges horizontally and its value in
|
748
|
-
a VALUE widget.
|
729
|
+
summary: Displays an item VALUE followed by LIMITSBAR
|
749
730
|
parameters:
|
750
731
|
- name: Target name
|
751
732
|
required: true
|
@@ -768,9 +749,7 @@ VALUELIMITSBAR:
|
|
768
749
|
description: The number of characters wide to make the value box (default = 8)
|
769
750
|
values: .*
|
770
751
|
VALUELIMITSCOLUMN:
|
771
|
-
summary: Displays
|
772
|
-
an item's value falls within its limits ranges vertically and its value in a
|
773
|
-
VALUE widget.
|
752
|
+
summary: Displays an item VALUE followed by LIMITSCOLUMN
|
774
753
|
parameters:
|
775
754
|
- name: Target name
|
776
755
|
required: true
|
@@ -793,8 +772,7 @@ VALUELIMITSCOLUMN:
|
|
793
772
|
description: The number of characters wide to make the value box (default = 8)
|
794
773
|
values: .*
|
795
774
|
VALUERANGEBAR:
|
796
|
-
summary: Displays
|
797
|
-
item's value falls within a range horizontally and its value in a VALUE widget.
|
775
|
+
summary: Displays an item VALUE followed by RANGEBAR
|
798
776
|
parameters:
|
799
777
|
- name: Target name
|
800
778
|
required: true
|
@@ -877,8 +855,7 @@ VALUERANGEBAR:
|
|
877
855
|
# description: Height of the range bar (default = 25)
|
878
856
|
# values: .*
|
879
857
|
LINEGRAPH:
|
880
|
-
summary: Displays a line graph of a telemetry
|
881
|
-
verses sample number
|
858
|
+
summary: Displays a line graph of a telemetry item
|
882
859
|
parameters:
|
883
860
|
- name: Target name
|
884
861
|
required: true
|
@@ -925,8 +902,7 @@ SPARKLINE:
|
|
925
902
|
description: The item name
|
926
903
|
values: .+
|
927
904
|
LABELSPARKLINE:
|
928
|
-
summary: Displays a LABEL
|
929
|
-
item name followed by a SPARKLINE widget to graph the item
|
905
|
+
summary: Displays a LABEL with the item name followed by a SPARKLINE
|
930
906
|
parameters:
|
931
907
|
- name: Target name
|
932
908
|
required: true
|
@@ -969,8 +945,7 @@ PROGRESSBAR:
|
|
969
945
|
description: The type of the value to display. Default is CONVERTED.
|
970
946
|
values: <%= %w(RAW CONVERTED FORMATTED WITH_UNITS) %>
|
971
947
|
RANGEBAR:
|
972
|
-
summary: Displays a
|
973
|
-
item's value falls withing a range horizontally.
|
948
|
+
summary: Displays a custom range bar displaying the item value
|
974
949
|
parameters:
|
975
950
|
- name: Target name
|
976
951
|
required: true
|
@@ -1177,9 +1152,8 @@ TEXTBOX:
|
|
1177
1152
|
# description: Height of the limits bar (default = 25)
|
1178
1153
|
# values: .*
|
1179
1154
|
VALUE:
|
1180
|
-
summary:
|
1181
|
-
|
1182
|
-
portion of the box darkens to gray while the value remains stagnant, then
|
1155
|
+
summary: Displays a box with a telemetry item value
|
1156
|
+
description: The white portion of the box darkens to gray while the value remains stagnant, then
|
1183
1157
|
brightens to white each time the value changes. Additionally the value is
|
1184
1158
|
colored based on the items limits state (Red for example if it is out of limits).
|
1185
1159
|
parameters:
|
@@ -1429,7 +1403,8 @@ CANVASLINE:
|
|
1429
1403
|
the line
|
1430
1404
|
values: ["NO_CONNECTOR", "CONNECTOR"]
|
1431
1405
|
CANVASLINEVALUE:
|
1432
|
-
summary: Draws a line onto the canvas
|
1406
|
+
summary: Draws a color changing line onto the canvas
|
1407
|
+
description: The line is represented by one of two colors based on the value
|
1433
1408
|
of the associated telemetry item
|
1434
1409
|
parameters:
|
1435
1410
|
- name: Target name
|
@@ -1484,7 +1459,8 @@ CANVASLINEVALUE:
|
|
1484
1459
|
description: The type of the value to display. Default is RAW
|
1485
1460
|
values: <%= %w(RAW CONVERTED FORMATTED WITH_UNITS) %>
|
1486
1461
|
CANVASDOT:
|
1487
|
-
summary:
|
1462
|
+
summary: Draws a dot onto the canvas
|
1463
|
+
description: The dot can be given a fixed X and Y location or
|
1488
1464
|
programmed to change its position with ruby code
|
1489
1465
|
parameters:
|
1490
1466
|
- name: X Position or Ruby Code
|
@@ -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
|
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
|
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
|
-
|
1318
|
-
|
1319
|
-
|
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
|
-
|
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
|