Skip to content

Commit

Permalink
[WIP] remove import * f (#295)
Browse files Browse the repository at this point in the history
* refactor/rename
* adapt examples to new api
* remove  import * and refactor modules
#236
  • Loading branch information
ebroecker authored Feb 23, 2019
1 parent 04b9e2a commit 097e3dd
Show file tree
Hide file tree
Showing 21 changed files with 207 additions and 205 deletions.
22 changes: 11 additions & 11 deletions examples/BusmasterRestbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def genCallbacks(cycle, bId, db):
"""


def tickerBoardUnits(db, dbcname):
def ticker_ecus(db, dbcname):
nodeList = {}
zf = zipfile.ZipFile(dbcname + '_Simulation.zip',
mode='w',
Expand All @@ -169,27 +169,27 @@ def tickerBoardUnits(db, dbcname):
else:
continue
bu._cycles = {}
for botsch in db.frames:
if bu.name in botsch.transmitters:
if "GenMsgCycleTime" in botsch.attributes:
data = botsch.attributes["GenMsgStartValue"][1:-2]
for frame in db.frames:
if bu.name in frame.transmitters:
if "GenMsgCycleTime" in frame.attributes and "GenMsgStartValue" in frame.attributes:
data = frame.attributes["GenMsgStartValue"][1:-2]
dlc = (math.floor(len(data) / 2))
cycleTime = int(botsch.attributes["GenMsgCycleTime"])
cycleTime = int(frame.attributes["GenMsgCycleTime"])
if float(cycleTime) > 0:
if cycleTime in bu._cycles:
bu._cycles[cycleTime].append(botsch.id)
bu._cycles[cycleTime].append(frame.id)
else:
bu._cycles[cycleTime] = [botsch.id]
bu._cycles[cycleTime] = [frame.id]
nodeList[bu.name] = bu.name + ".cpp"

timedPrototypes = ""
timedCallbacks = ""
structNames = ""
exports = ""
for cycle in bu._cycles:
for botsch in bu._cycles[cycle]:
for frame in bu._cycles[cycle]:
(tempstructNames, tempPrototypes, tempCallbacks,
tempExports) = genCallbacks(cycle, botsch, db)
tempExports) = genCallbacks(cycle, frame, db)
structNames += tempstructNames
timedPrototypes += tempPrototypes
timedCallbacks += tempCallbacks
Expand All @@ -214,6 +214,6 @@ def main():
outfile = os.path.splitext(sys.argv[2])[0]

db = next(iter(canmatrix.formats.loadp(infile).values()))
tickerBoardUnits(db, outfile)
ticker_ecus(db, outfile)

main()
4 changes: 2 additions & 2 deletions examples/createCMacros.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
def createStoreMacro(signal, prefix="", frame="frame"):
startBit = signal.get_startbit(bit_numbering=1, start_little=1)
byteOrder = signal.is_little_endian
length = signal.signalsize
length = signal.size
startByte = int(startBit / 8)
startBitInByte = startBit % 8
currentTargetLength = (8 - startBitInByte)
Expand Down Expand Up @@ -67,7 +67,7 @@ def createDecodeMacro(
startByte = int(startBit / 8)
startBitInByte = startBit % 8

code = "#define getSignal%s%s(%s) ((((%s[%d])>>%d" % (
code = "#define get_signal%s%s(%s) ((((%s[%d])>>%d" % (
prefix, signal.name, macrosource, source, startByte, startBitInByte)
currentTargetLength = (8 - startBitInByte)

Expand Down
4 changes: 2 additions & 2 deletions examples/createccl.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def main():
sendIndex = 0
txDict = {}
for frame in db.frames:
if ecu in frame.receiver:
if ecu in frame.receivers:
receiveArray.append(frame.id)
receiveDict[frame] = receiveIndex
receiveIndex += 1
Expand Down Expand Up @@ -121,7 +121,7 @@ def main():
ccl_h += "extern " + txMailboxStruct + "\n"
for frame in receiveDict:
for signal in frame.signals:
if ecu in signal.receiver:
if ecu in signal.receivers:
ccl_h += createDecodeMacro(signal, "_" +
frame.name +
"__", "", "RxCanMailboxes[%d].data" %
Expand Down
6 changes: 3 additions & 3 deletions examples/exampleMerge.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
#

# Copy Can-ID 1234 from second CAN-Matrix to target-Matrix
canmatrix.copy.copyFrame(1234, db2, db3)
canmatrix.copy.copy_frame(1234, db2, db3)

# Copy frame "Engine_123" from first CAN-Matrix to target-Matrix
canmatrix.copy.copyFrame("Engine_123", db1, db3)
canmatrix.copy.copy_frame("Engine_123", db1, db3)

# Copy ECU (with all Frames) "Gateway" from first CAN-Matrix to target-Matrix
canmatrix.copy.copyBUwithFrames("Gateway", db1, db3)
canmatrix.copy.copy_ecu_with_frames("Gateway", db1, db3)

#
# -----------------------------------------------------
Expand Down
Loading

0 comments on commit 097e3dd

Please sign in to comment.