Skip to content

Commit 097e3dd

Browse files
authored
[WIP] remove import * f (#295)
* refactor/rename * adapt examples to new api * remove import * and refactor modules #236
1 parent 04b9e2a commit 097e3dd

21 files changed

+207
-205
lines changed

examples/BusmasterRestbus.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def genCallbacks(cycle, bId, db):
154154
"""
155155

156156

157-
def tickerBoardUnits(db, dbcname):
157+
def ticker_ecus(db, dbcname):
158158
nodeList = {}
159159
zf = zipfile.ZipFile(dbcname + '_Simulation.zip',
160160
mode='w',
@@ -169,27 +169,27 @@ def tickerBoardUnits(db, dbcname):
169169
else:
170170
continue
171171
bu._cycles = {}
172-
for botsch in db.frames:
173-
if bu.name in botsch.transmitters:
174-
if "GenMsgCycleTime" in botsch.attributes:
175-
data = botsch.attributes["GenMsgStartValue"][1:-2]
172+
for frame in db.frames:
173+
if bu.name in frame.transmitters:
174+
if "GenMsgCycleTime" in frame.attributes and "GenMsgStartValue" in frame.attributes:
175+
data = frame.attributes["GenMsgStartValue"][1:-2]
176176
dlc = (math.floor(len(data) / 2))
177-
cycleTime = int(botsch.attributes["GenMsgCycleTime"])
177+
cycleTime = int(frame.attributes["GenMsgCycleTime"])
178178
if float(cycleTime) > 0:
179179
if cycleTime in bu._cycles:
180-
bu._cycles[cycleTime].append(botsch.id)
180+
bu._cycles[cycleTime].append(frame.id)
181181
else:
182-
bu._cycles[cycleTime] = [botsch.id]
182+
bu._cycles[cycleTime] = [frame.id]
183183
nodeList[bu.name] = bu.name + ".cpp"
184184

185185
timedPrototypes = ""
186186
timedCallbacks = ""
187187
structNames = ""
188188
exports = ""
189189
for cycle in bu._cycles:
190-
for botsch in bu._cycles[cycle]:
190+
for frame in bu._cycles[cycle]:
191191
(tempstructNames, tempPrototypes, tempCallbacks,
192-
tempExports) = genCallbacks(cycle, botsch, db)
192+
tempExports) = genCallbacks(cycle, frame, db)
193193
structNames += tempstructNames
194194
timedPrototypes += tempPrototypes
195195
timedCallbacks += tempCallbacks
@@ -214,6 +214,6 @@ def main():
214214
outfile = os.path.splitext(sys.argv[2])[0]
215215

216216
db = next(iter(canmatrix.formats.loadp(infile).values()))
217-
tickerBoardUnits(db, outfile)
217+
ticker_ecus(db, outfile)
218218

219219
main()

examples/createCMacros.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
def createStoreMacro(signal, prefix="", frame="frame"):
2929
startBit = signal.get_startbit(bit_numbering=1, start_little=1)
3030
byteOrder = signal.is_little_endian
31-
length = signal.signalsize
31+
length = signal.size
3232
startByte = int(startBit / 8)
3333
startBitInByte = startBit % 8
3434
currentTargetLength = (8 - startBitInByte)
@@ -67,7 +67,7 @@ def createDecodeMacro(
6767
startByte = int(startBit / 8)
6868
startBitInByte = startBit % 8
6969

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

examples/createccl.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def main():
9090
sendIndex = 0
9191
txDict = {}
9292
for frame in db.frames:
93-
if ecu in frame.receiver:
93+
if ecu in frame.receivers:
9494
receiveArray.append(frame.id)
9595
receiveDict[frame] = receiveIndex
9696
receiveIndex += 1
@@ -121,7 +121,7 @@ def main():
121121
ccl_h += "extern " + txMailboxStruct + "\n"
122122
for frame in receiveDict:
123123
for signal in frame.signals:
124-
if ecu in signal.receiver:
124+
if ecu in signal.receivers:
125125
ccl_h += createDecodeMacro(signal, "_" +
126126
frame.name +
127127
"__", "", "RxCanMailboxes[%d].data" %

examples/exampleMerge.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
#
3232

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

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

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

4242
#
4343
# -----------------------------------------------------

0 commit comments

Comments
 (0)