Skip to content

Commit 3d97e59

Browse files
committed
xls reader now supports additinal attributes.
(#165, #115)
1 parent 679042f commit 3d97e59

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

canmatrix/xls.py

+21
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ def load(file, **options):
330330
else:
331331
motorolaBitFormat = "msbreverse"
332332

333+
additionalInputs = dict()
333334
wb = xlrd.open_workbook(file_contents=file.read())
334335
sh = wb.sheet_by_index(0)
335336
db = CanMatrix()
@@ -382,6 +383,9 @@ def load(file, **options):
382383
index['function'] = i
383384
elif "Byteorder" in value:
384385
index['byteorder'] = i
386+
else:
387+
if 'Value' in index and i > index['Value']:
388+
additionalInputs[i] = value
385389

386390
if "byteorder" in index:
387391
index['BUstart'] = index['byteorder'] + 1
@@ -437,6 +441,13 @@ def load(file, **options):
437441
cycleTime = 0
438442
newBo.addAttribute("GenMsgCycleTime", str(int(cycleTime)))
439443

444+
for additionalIndex in additionalInputs:
445+
if "frame" in additionalInputs[additionalIndex]:
446+
commandStr = additionalInputs[additionalIndex].replace("frame", "newBo")
447+
commandStr += "="
448+
commandStr += str(sh.cell(rownum, additionalIndex).value)
449+
exec(commandStr)
450+
440451
# new signal detected
441452
if sh.cell(rownum, index['signalName']).value != signalName and len(sh.cell(rownum, index['signalName']).value)>0:
442453
# new Signal
@@ -497,9 +508,19 @@ def load(file, **options):
497508
(startbyte - 1) * 8 + startbit,
498509
bitNumbering=1,
499510
startLittle=True)
511+
512+
for additionalIndex in additionalInputs:
513+
if "signal" in additionalInputs[additionalIndex]:
514+
commandStr = additionalInputs[additionalIndex].replace("signal", "newSig")
515+
commandStr += "="
516+
commandStr += str(sh.cell(rownum, additionalIndex).value)
517+
exec (commandStr)
518+
500519
newBo.addSignal(newSig)
501520
newSig.addComment(signalComment)
502521
function = sh.cell(rownum, index['function']).value
522+
523+
503524
value = str(sh.cell(rownum, index['Value']).value)
504525
valueName = sh.cell(rownum, index['ValueName']).value
505526

0 commit comments

Comments
 (0)