@@ -1029,7 +1029,11 @@ def getSignals(signalarray, Bo, xmlRoot, ns, multiplexId, float_factory):
1029
1029
Bo .name ,arGetChild (signal ,"SHORT-NAME" ,xmlRoot ,ns ).text )
1030
1030
1031
1031
baseType = arGetChild (isignal ,"BASE-TYPE" , xmlRoot , ns )
1032
-
1032
+ sig_long_name = arGetChild (isignal , "LONG-NAME" , xmlRoot , ns )
1033
+ if sig_long_name is not None :
1034
+ sig_long_name = arGetChild (sig_long_name , "L-4" , xmlRoot , ns )
1035
+ if sig_long_name is not None :
1036
+ sig_long_name = sig_long_name .text
1033
1037
syssignal = arGetChild (isignal , "SYSTEM-SIGNAL" , xmlRoot , ns )
1034
1038
if syssignal is None :
1035
1039
logger .debug ('Frame %s, signal %s has no systemsignal' ,isignal .tag ,Bo .name )
@@ -1200,19 +1204,31 @@ def getSignals(signalarray, Bo, xmlRoot, ns, multiplexId, float_factory):
1200
1204
newSig .addValues (1 , "TRUE" )
1201
1205
newSig .addValues (0 , "FALSE" )
1202
1206
1207
+ def guess_value (textValue ):
1208
+ """
1209
+ returns a string value for common strings.
1210
+ method is far from complete but helping with odd arxmls
1211
+ :param textValue: value in text like "true"
1212
+ :return: string for value like "1"
1213
+ """
1214
+ textValue = textValue .casefold ()
1215
+ if textValue in ["false" , "off" ]:
1216
+ return "0"
1217
+ elif textValue in ["true" , "on" ]:
1218
+ return "1"
1219
+ return textValue
1203
1220
1204
1221
if initvalue is not None and initvalue .text is not None :
1205
- if initvalue .text == "false" :
1206
- initvalue .text = "0"
1207
- elif initvalue .text == "true" :
1208
- initvalue .text = "1"
1222
+ initvalue .text = guess_value (initvalue .text )
1209
1223
newSig ._initValue = int (initvalue .text )
1210
1224
newSig .addAttribute ("GenSigStartValue" , str (newSig ._initValue ))
1211
1225
else :
1212
1226
newSig ._initValue = 0
1213
1227
1214
1228
for key , value in list (values .items ()):
1215
1229
newSig .addValues (key , value )
1230
+ if sig_long_name is not None :
1231
+ newSig .addAttribute ("LongName" , sig_long_name )
1216
1232
Bo .addSignal (newSig )
1217
1233
1218
1234
@@ -1395,7 +1411,6 @@ def getDesc(element, arDict, ns):
1395
1411
else :
1396
1412
return ""
1397
1413
1398
-
1399
1414
def processEcu (ecu , db , arDict , multiplexTranslation , ns ):
1400
1415
global pduFrameMapping
1401
1416
connectors = arGetChild (ecu , "CONNECTORS" , arDict , ns )
@@ -1557,6 +1572,7 @@ def load(file, **options):
1557
1572
# Defines not jet imported...
1558
1573
db .addBUDefines ("NWM-Stationsadresse" , 'HEX 0 63' )
1559
1574
db .addBUDefines ("NWM-Knoten" , 'ENUM "nein","ja"' )
1575
+ db .addSignalDefines ("LongName" , 'STRING' )
1560
1576
db .addFrameDefines ("GenMsgCycleTime" , 'INT 0 65535' )
1561
1577
db .addFrameDefines ("GenMsgDelayTime" , 'INT 0 65535' )
1562
1578
db .addFrameDefines ("GenMsgNrOfRepetitions" , 'INT 0 65535' )
@@ -1646,19 +1662,11 @@ def load(file, **options):
1646
1662
1647
1663
db .addEcu (bu )
1648
1664
1649
- for bo in db .frames :
1650
- frame = 0
1651
- for sig in bo .signals :
1652
- if sig ._initValue != 0 :
1653
- stbit = sig .getStartbit (bitNumbering = 1 , startLittle = True )
1654
- frame |= computeSignalValueInFrame (
1655
- sig .getStartbit (
1656
- bitNumbering = 1 ,
1657
- startLittle = True ),
1658
- sig .size ,
1659
- sig .is_little_endian ,
1660
- sig ._initValue )
1661
- fmt = "%0" + "%d" % bo .size + "X"
1662
- bo .addAttribute ("GenMsgStartValue" , fmt % frame )
1665
+ for frame in db .frames :
1666
+ sig_value_hash = dict ()
1667
+ for sig in frame .signals :
1668
+ sig_value_hash [sig .name ] = sig ._initValue
1669
+ frameData = frame .encode (sig_value_hash )
1670
+ frame .addAttribute ("GenMsgStartValue" , "" .join (["%02x" % x for x in frameData ]))
1663
1671
result [busname ] = db
1664
1672
return result
0 commit comments