Skip to content

Commit

Permalink
Detect and skip string-type signals
Browse files Browse the repository at this point in the history
This is an intermediate step to allow handling of files with string
signals.  Eventually, support should actually be added for string
signals.
  • Loading branch information
altendky committed Jun 4, 2016
1 parent 49ff649 commit d6d1216
Show file tree
Hide file tree
Showing 10 changed files with 216 additions and 1 deletion.
4 changes: 4 additions & 0 deletions canmatrix/importsym.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ class Mode(object):
is_signed = False
elif tempArray[1] == 'signed':
is_signed = True
elif tempArray[1] == 'string':
# TODO: actually support string variables instead of skipping
print('Variable type \'string\' found and skipped')
continue
else:
raise ValueError('Unknown type \'{}\' found'.format(tempArray[1]))

Expand Down
106 changes: 106 additions & 0 deletions test/reference/from_sym/test.arxml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,26 @@
</I-PDU-TRIGGERING-REFS>
<FRAME-PORT-REFS/>
</CAN-FRAME-TRIGGERING>
<CAN-FRAME-TRIGGERING>
<SHORT-NAME>justString</SHORT-NAME>
<IDENTIFIER>486517952</IDENTIFIER>
<CAN-ADDRESSING-MODE>EXTENDED</CAN-ADDRESSING-MODE>
<FRAME-REF DEST="FRAME">/Frame/FRAME_justString</FRAME-REF>
<I-PDU-TRIGGERING-REFS>
<I-PDU-TRIGGERING-REF DEST="I-PDU-TRIGGERING">/Cluster/CAN/IPDUTRIGG_justString</I-PDU-TRIGGERING-REF>
</I-PDU-TRIGGERING-REFS>
<FRAME-PORT-REFS/>
</CAN-FRAME-TRIGGERING>
<CAN-FRAME-TRIGGERING>
<SHORT-NAME>stringAndOther</SHORT-NAME>
<IDENTIFIER>486517696</IDENTIFIER>
<CAN-ADDRESSING-MODE>EXTENDED</CAN-ADDRESSING-MODE>
<FRAME-REF DEST="FRAME">/Frame/FRAME_stringAndOther</FRAME-REF>
<I-PDU-TRIGGERING-REFS>
<I-PDU-TRIGGERING-REF DEST="I-PDU-TRIGGERING">/Cluster/CAN/IPDUTRIGG_stringAndOther</I-PDU-TRIGGERING-REF>
</I-PDU-TRIGGERING-REFS>
<FRAME-PORT-REFS/>
</CAN-FRAME-TRIGGERING>
<CAN-FRAME-TRIGGERING>
<SHORT-NAME>StatusMeasuredPower</SHORT-NAME>
<IDENTIFIER>218090231</IDENTIFIER>
Expand Down Expand Up @@ -311,6 +331,14 @@
<SHORT-NAME>IPDUTRIGG_MasterMeasuredPowerAPU2</SHORT-NAME>
<I-PDU-REF DEST="SIGNAL-I-PDU">/PDU/PDU_MasterMeasuredPowerAPU2</I-PDU-REF>
</I-PDU-TRIGGERING>
<I-PDU-TRIGGERING>
<SHORT-NAME>IPDUTRIGG_justString</SHORT-NAME>
<I-PDU-REF DEST="SIGNAL-I-PDU">/PDU/PDU_justString</I-PDU-REF>
</I-PDU-TRIGGERING>
<I-PDU-TRIGGERING>
<SHORT-NAME>IPDUTRIGG_stringAndOther</SHORT-NAME>
<I-PDU-REF DEST="SIGNAL-I-PDU">/PDU/PDU_stringAndOther</I-PDU-REF>
</I-PDU-TRIGGERING>
<I-PDU-TRIGGERING>
<SHORT-NAME>IPDUTRIGG_StatusMeasuredPower</SHORT-NAME>
<I-PDU-REF DEST="SIGNAL-I-PDU">/PDU/PDU_StatusMeasuredPower</I-PDU-REF>
Expand Down Expand Up @@ -625,6 +653,10 @@
<SHORT-NAME>RealPower_measured</SHORT-NAME>
<SIGNAL-REF DEST="I-SIGNAL">/ISignal/RealPower_measured</SIGNAL-REF>
</I-SIGNAL-TRIGGERING>
<I-SIGNAL-TRIGGERING>
<SHORT-NAME>RealPower_measured</SHORT-NAME>
<SIGNAL-REF DEST="I-SIGNAL">/ISignal/RealPower_measured</SIGNAL-REF>
</I-SIGNAL-TRIGGERING>
<I-SIGNAL-TRIGGERING>
<SHORT-NAME>ReactivePower_measured</SHORT-NAME>
<SIGNAL-REF DEST="I-SIGNAL">/ISignal/ReactivePower_measured</SIGNAL-REF>
Expand Down Expand Up @@ -1135,6 +1167,30 @@
</PDU-TO-FRAME-MAPPING>
</PDU-TO-FRAME-MAPPINGS>
</FRAME>
<FRAME>
<SHORT-NAME>FRAME_justString</SHORT-NAME>
<FRAME-LENGTH>8</FRAME-LENGTH>
<PDU-TO-FRAME-MAPPINGS>
<PDU-TO-FRAME-MAPPING>
<SHORT-NAME>justString</SHORT-NAME>
<PACKING-BYTE-ORDER>MOST-SIGNIFICANT-BYTE-LAST</PACKING-BYTE-ORDER>
<START-POSITION>0</START-POSITION>
<PDU-REF DEST="SIGNAL-I-PDU">/PDU/PDU_justString</PDU-REF>
</PDU-TO-FRAME-MAPPING>
</PDU-TO-FRAME-MAPPINGS>
</FRAME>
<FRAME>
<SHORT-NAME>FRAME_stringAndOther</SHORT-NAME>
<FRAME-LENGTH>8</FRAME-LENGTH>
<PDU-TO-FRAME-MAPPINGS>
<PDU-TO-FRAME-MAPPING>
<SHORT-NAME>stringAndOther</SHORT-NAME>
<PACKING-BYTE-ORDER>MOST-SIGNIFICANT-BYTE-LAST</PACKING-BYTE-ORDER>
<START-POSITION>0</START-POSITION>
<PDU-REF DEST="SIGNAL-I-PDU">/PDU/PDU_stringAndOther</PDU-REF>
</PDU-TO-FRAME-MAPPING>
</PDU-TO-FRAME-MAPPINGS>
</FRAME>
<FRAME>
<SHORT-NAME>FRAME_StatusMeasuredPower</SHORT-NAME>
<FRAME-LENGTH>8</FRAME-LENGTH>
Expand Down Expand Up @@ -1758,6 +1814,23 @@
</I-SIGNAL-TO-I-PDU-MAPPING>
</SIGNAL-TO-PDU-MAPPINGS>
</SIGNAL-I-PDU>
<SIGNAL-I-PDU>
<SHORT-NAME>PDU_justString</SHORT-NAME>
<LENGTH>64</LENGTH>
<SIGNAL-TO-PDU-MAPPINGS/>
</SIGNAL-I-PDU>
<SIGNAL-I-PDU>
<SHORT-NAME>PDU_stringAndOther</SHORT-NAME>
<LENGTH>64</LENGTH>
<SIGNAL-TO-PDU-MAPPINGS>
<I-SIGNAL-TO-I-PDU-MAPPING>
<SHORT-NAME>RealPower_measured</SHORT-NAME>
<START-POSITION>7</START-POSITION>
<PACKING-BYTE-ORDER>MOST-SIGNIFICANT-BYTE-FIRST</PACKING-BYTE-ORDER>
<SIGNAL-REF DEST="I-SIGNAL">/ISignal/RealPower_measured</SIGNAL-REF>
</I-SIGNAL-TO-I-PDU-MAPPING>
</SIGNAL-TO-PDU-MAPPINGS>
</SIGNAL-I-PDU>
<SIGNAL-I-PDU>
<SHORT-NAME>PDU_StatusMeasuredPower</SHORT-NAME>
<LENGTH>64</LENGTH>
Expand Down Expand Up @@ -2683,6 +2756,10 @@
<SHORT-NAME>RealPower_measured</SHORT-NAME>
<SYSTEM-SIGNAL-REF DEST="SYSTEM-SIGNAL">/Signal/RealPower_measured</SYSTEM-SIGNAL-REF>
</I-SIGNAL>
<I-SIGNAL>
<SHORT-NAME>RealPower_measured</SHORT-NAME>
<SYSTEM-SIGNAL-REF DEST="SYSTEM-SIGNAL">/Signal/RealPower_measured</SYSTEM-SIGNAL-REF>
</I-SIGNAL>
<I-SIGNAL>
<SHORT-NAME>ReactivePower_measured</SHORT-NAME>
<SYSTEM-SIGNAL-REF DEST="SYSTEM-SIGNAL">/Signal/ReactivePower_measured</SYSTEM-SIGNAL-REF>
Expand Down Expand Up @@ -3378,6 +3455,11 @@
<LENGTH>32</LENGTH>
<DATA-TYPE-REF DEST="INTEGER-TYPE">/DataType/RealPower_measured</DATA-TYPE-REF>
</SYSTEM-SIGNAL>
<SYSTEM-SIGNAL>
<SHORT-NAME>RealPower_measured</SHORT-NAME>
<LENGTH>32</LENGTH>
<DATA-TYPE-REF DEST="INTEGER-TYPE">/DataType/RealPower_measured</DATA-TYPE-REF>
</SYSTEM-SIGNAL>
<SYSTEM-SIGNAL>
<SHORT-NAME>ReactivePower_measured</SHORT-NAME>
<LENGTH>32</LENGTH>
Expand Down Expand Up @@ -4230,6 +4312,12 @@
<COMPU-METHOD-REF DEST="COMPU-METHOD">/DataType/Semantics/RealPower_measured</COMPU-METHOD-REF>
</SW-DATA-DEF-PROPS>
</INTEGER-TYPE>
<INTEGER-TYPE>
<SHORT-NAME>RealPower_measured</SHORT-NAME>
<SW-DATA-DEF-PROPS>
<COMPU-METHOD-REF DEST="COMPU-METHOD">/DataType/Semantics/RealPower_measured</COMPU-METHOD-REF>
</SW-DATA-DEF-PROPS>
</INTEGER-TYPE>
<INTEGER-TYPE>
<SHORT-NAME>ReactivePower_measured</SHORT-NAME>
<SW-DATA-DEF-PROPS>
Expand Down Expand Up @@ -7021,6 +7109,24 @@
</COMPU-SCALES>
</COMPU-INTERNAL-TO-PHYS>
</COMPU-METHOD>
<COMPU-METHOD>
<SHORT-NAME>RealPower_measured</SHORT-NAME>
<COMPU-INTERNAL-TO-PHYS>
<COMPU-SCALES>
<COMPU-SCALE>
<COMPU-RATIONAL-COEFFS>
<COMPU-NUMERATOR>
<V>0</V>
<V>1</V>
</COMPU-NUMERATOR>
<COMPU-DENOMINATOR>
<V>1</V>
</COMPU-DENOMINATOR>
</COMPU-RATIONAL-COEFFS>
</COMPU-SCALE>
</COMPU-SCALES>
</COMPU-INTERNAL-TO-PHYS>
</COMPU-METHOD>
<COMPU-METHOD>
<SHORT-NAME>ReactivePower_measured</SHORT-NAME>
<COMPU-INTERNAL-TO-PHYS>
Expand Down
1 change: 1 addition & 0 deletions test/reference/from_sym/test.csv
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ CFFCAF7h,StatusMeasuredPower,100,,,5,0,ReactivePower_measured,Measured reactive
1CFFA9F7h,StatusNVParam,,,,7,0,StatusK1Close,Mode 8:Maximum time required for the K1 contactor to close.,16,,,m,u,,0.0..2000.0,ms
1CFFA9F7h,StatusNVParam,,,,7,0,StatusMX2Open,Mode 7:Maximum time required for the MX2 contactor to open.,16,,,m,u,,0.0..1.0,ms
1CFFA9F7h,StatusNVParam,,,,7,0,V110to120pct,Mode 1:,16,,,m,u,,1.0..30000.0,ms
1CFFABC0h,stringAndOther,,,,1,0,RealPower_measured,Measured real power.,32,,,m,s,,-2147483648.0..2147483647.0,W
1CFFC1F7h,softwareRev,,,,1,0,ControlSwRev,Software revision of the control firmware.,16,,,m,u,,0.0..655.35,0.01
1CFFC1F7h,softwareRev,,,,3,0,InterfaceRev,Software revision of the CAN communication interface.,16,,,m,u,,0.0..655.35,0.01
1CFFC1F7h,softwareRev,,,,5,0,BuildTime,Build timestamp.,32,,,m,u,,0.0..4294967295.0
Expand Down
7 changes: 7 additions & 0 deletions test/reference/from_sym/test.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ BO_ 2365573879 MasterMeasuredPowerAPU2: 8 Vector__XXX
SG_ RealPower_measured : 7|32@0- (1,0) [-2147483648.0|2147483647.0] "W" Vector__XXX
SG_ ReactivePower_measured : 39|32@0- (1,0) [-2147483648.0|2147483647.0] "VA" Vector__XXX

BO_ 2634001600 justString: 8 Vector__XXX

BO_ 2634001344 stringAndOther: 8 Vector__XXX
SG_ RealPower_measured : 7|32@0- (1,0) [-2147483648.0|2147483647.0] "W" Vector__XXX

BO_ 2365573879 StatusMeasuredPower: 8 Vector__XXX
SG_ RealPower_measured : 7|32@0- (1,0) [-2147483648.0|2147483647.0] "W" Vector__XXX
SG_ ReactivePower_measured : 39|32@0- (1,0) [-2147483648.0|2147483647.0] "VA" Vector__XXX
Expand Down Expand Up @@ -300,6 +305,7 @@ CM_ SG_ 2365562433 Voltage_command "Desired output voltage while in grid forming
CM_ SG_ 2365562433 Frequency_command "Desired output frequency while in grid forming mode.";
CM_ SG_ 2365573879 RealPower_measured "Measured real power of master unit.";
CM_ SG_ 2365573879 ReactivePower_measured "Measured reactive power of master unit.";
CM_ SG_ 2634001344 RealPower_measured "Measured real power.";
CM_ SG_ 2365573879 RealPower_measured "Measured real power.";
CM_ SG_ 2365573879 ReactivePower_measured "Measured reactive power.";
CM_ SG_ 2566898935 RealPower_echo "Echoed real power command.";
Expand Down Expand Up @@ -461,6 +467,7 @@ BA_ "GenSigStartValue" SG_ 2365562433 Voltage_command 2400.0;
BA_ "GenSigStartValue" SG_ 2365562433 Frequency_command 500.0;
BA_ "GenSigStartValue" SG_ 2365573879 RealPower_measured 0.0;
BA_ "GenSigStartValue" SG_ 2365573879 ReactivePower_measured 0.0;
BA_ "GenSigStartValue" SG_ 2634001344 RealPower_measured 0.0;
BA_ "GenSigStartValue" SG_ 2365573879 RealPower_measured 0.0;
BA_ "GenSigStartValue" SG_ 2365573879 ReactivePower_measured 0.0;
BA_ "GenSigStartValue" SG_ 2566898935 RealPower_echo 0.0;
Expand Down
13 changes: 12 additions & 1 deletion test/reference/from_sym/test.dbf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[PROTOCOL] CAN

[BUSMASTER_VERSION] [1.7.2]
[NUMBER_OF_MESSAGES] 26
[NUMBER_OF_MESSAGES] 28
[START_MSG] CommandModeControl,16755521,8,11,1,X,Vector__XXX
[START_SIGNALS] Enable_command,2,1,0,U,1.0,0.0,0,0.0,1.0,,,
[VALUE_DESCRIPTION] "Disable",0
Expand Down Expand Up @@ -207,6 +207,13 @@
[START_SIGNALS] ReactivePower_measured,32,8,0,S,2147483647.0,-2147483648.0,0,0.0,1.0,VA,,
[END_MSG]

[START_MSG] justString,486517952,8,0,1,X,Vector__XXX
[END_MSG]

[START_MSG] stringAndOther,486517696,8,1,1,X,Vector__XXX
[START_SIGNALS] RealPower_measured,32,4,0,S,2147483647.0,-2147483648.0,0,0.0,1.0,W,,
[END_MSG]

[START_MSG] StatusMeasuredPower,218090231,8,2,1,X,Vector__XXX
[START_SIGNALS] RealPower_measured,32,4,0,S,2147483647.0,-2147483648.0,0,0.0,1.0,W,,
[START_SIGNALS] ReactivePower_measured,32,8,0,S,2147483647.0,-2147483648.0,0,0.0,1.0,VA,,
Expand Down Expand Up @@ -559,6 +566,8 @@
218078273 S "Sets the desired real (P) and reactive (Q) power levels for the module to follow while in the GRID FOLLOWING mode.";
218078785 S "Sets the desired voltage and frequency for the module to produce while in the GRID FORMING mode. In addition, while in the READY and GRID FOLLOWING modes, this message is used to set the nominal voltage levels for detection of acceptable AC line voltage.";
218090231 S "Returns the actual measured power.";
486517952 S "";
486517696 S "";
218090231 S "Returns the actual measured power.";
419415287 S "Echoes the commanded power (P&Q) as received in CommandPQ.";
218088439 S "Bits representing the status of the power module.";
Expand Down Expand Up @@ -640,6 +649,7 @@
218078785 S Frequency_command "Desired output frequency while in grid forming mode.";
218090231 S RealPower_measured "Measured real power of master unit.";
218090231 S ReactivePower_measured "Measured reactive power of master unit.";
486517696 S RealPower_measured "Measured real power.";
218090231 S RealPower_measured "Measured real power.";
218090231 S ReactivePower_measured "Measured reactive power.";
419415287 S RealPower_echo "Echoed real power command.";
Expand Down Expand Up @@ -826,6 +836,7 @@
218078785,S,Frequency_command,"GenSigStartValue","500.0"
218090231,S,RealPower_measured,"GenSigStartValue","0.0"
218090231,S,ReactivePower_measured,"GenSigStartValue","0.0"
486517696,S,RealPower_measured,"GenSigStartValue","0.0"
218090231,S,RealPower_measured,"GenSigStartValue","0.0"
218090231,S,ReactivePower_measured,"GenSigStartValue","0.0"
419415287,S,RealPower_echo,"GenSigStartValue","0.0"
Expand Down
22 changes: 22 additions & 0 deletions test/reference/from_sym/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,28 @@
}
]
},
{
"id": 486517952,
"is_extended_frame": true,
"name": "justString",
"signals": []
},
{
"id": 486517696,
"is_extended_frame": true,
"name": "stringAndOther",
"signals": [
{
"bit_length": 32,
"factor": 1.0,
"is_big_endian": true,
"is_signed": true,
"name": "RealPower_measured",
"offset": 0.0,
"start_bit": 24
}
]
},
{
"id": 218090231,
"is_extended_frame": true,
Expand Down
13 changes: 13 additions & 0 deletions test/reference/from_sym/test.kcd
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,19 @@
<LabelSet/>
</Signal>
</Message>
<Message id="0x1CFFACC0" length="8" name="justString" format="extended">
<Producer/>
<Notes></Notes>
</Message>
<Message id="0x1CFFABC0" length="8" name="stringAndOther" format="extended">
<Producer/>
<Notes></Notes>
<Signal name="RealPower_measured" offset="24" length="32" endianess="little">
<Notes>Measured real power.</Notes>
<Value type="signed" min="-2147483648.0" max="2147483647.0" unit="W"/>
<LabelSet/>
</Signal>
</Message>
<Message id="0xCFFCAF7" length="8" name="StatusMeasuredPower" format="extended" triggered="true" interval="100">
<Producer/>
<Notes>Returns the actual measured power.</Notes>
Expand Down
Binary file modified test/reference/from_sym/test.xls
Binary file not shown.
38 changes: 38 additions & 0 deletions test/reference/from_sym/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,44 @@ _fl: !!python/object:canmatrix.canmatrix.FrameList
_startbit: 56
_unit: VA
_values: {}
- !!python/object:canmatrix.canmatrix.Frame
_Id: 486517952
_SignalGroups: []
_Size: 8
_Transmitter: []
_attributes: {}
_comment: ''
_extended: 1
_name: justString
_receiver: []
_signals: []
- !!python/object:canmatrix.canmatrix.Frame
_Id: 486517696
_SignalGroups: []
_Size: 8
_Transmitter: []
_attributes: {}
_comment: ''
_extended: 1
_name: stringAndOther
_receiver: []
_signals:
- !!python/object:canmatrix.canmatrix.Signal
_attributes: {GenSigStartValue: '0.0'}
_comment: Measured real power.
_factor: 1.0
_is_little_endian: 0
_is_signed: true
_max: 2147483647.0
_min: -2147483648.0
_multiplex: null
_name: RealPower_measured
_offset: 0.0
_receiver: []
_signalsize: 32
_startbit: 24
_unit: W
_values: {}
- !!python/object:canmatrix.canmatrix.Frame
_Id: 218090231
_SignalGroups: []
Expand Down
13 changes: 13 additions & 0 deletions test/test.sym
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,19 @@ Var=ReactivePower_measured signed 32,32 -m /u:VA // Measured reactive power of m

{SENDRECEIVE}

[justString]
ID=1CFFACC0h
Type=Extended
DLC=8
Var=rev string 0,64 -m /d:"ICUx-03i"

[stringAndOther]
ID=1CFFABC0h
Type=Extended
DLC=8
Var=rev string 0,64 -m /d:"ICUx-03i"
Var=RealPower_measured signed 0,32 -m /u:W // Measured real power.

[StatusMeasuredPower]
ID=0CFFCAF7h // Returns the actual measured power.
Type=Extended
Expand Down

0 comments on commit d6d1216

Please sign in to comment.