-
Notifications
You must be signed in to change notification settings - Fork 1
/
decode_car.py
60 lines (48 loc) · 1.79 KB
/
decode_car.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import io
import test.Car
length = 129
inp = io.open('car.bin', 'rb')
buffer = inp.read(length)
# start decoding
car = test.Car.Car()
car.wrapForDecode(buffer, 0, car.sbeBlockLength(), car.sbeSchemaVersion(), length)
# single fixed fields
print('serialNumber: '+str(car.getSerialNumber()))
print('modelYear: '+str(car.getModelYear()))
print('available: '+str(car.getAvailable()))
print('code: '+str(car.getCode()))
# fixed arrays
for i in range(0,car.someNumbersLength()):
print('someNumber'+str(i)+': '+str(car.getSomeNumbers(i)))
for i in range(0,car.vehicleCodeLength()):
print('vehicleCode'+str(i)+': '+str(car.getVehicleCode(i)))
# bitsets
print('cruiseControl: '+str(car.extras().getCruiseControl()))
print('sportsPack: '+str(car.extras().getSportsPack()))
print('sunRoof: '+str(car.extras().getSunRoof()))
# composites
print('capacity: '+str(car.engine().getCapacity()))
print('numCylinders: '+str(car.engine().getNumCylinders()))
print('maxRpm: '+str(car.engine().maxRpm()))
for i in range(0,car.engine().manufacturerCodeLength()):
print('manufacturerCode'+str(i)+': '+str(car.engine().getManufacturerCode(i)))
# groups
figures = car.fuelFigures()
while figures.hasNext():
figures.next()
print('speed: '+str(figures.getSpeed()))
print('mpg: '+str(figures.getMpg()))
figures = car.performanceFigures()
while figures.hasNext():
figures.next()
print('octaneRating: '+str(figures.getOctaneRating()))
acceleration = figures.acceleration()
while acceleration.hasNext():
acceleration.next()
print('mph: '+str(acceleration.getMph()))
print('seconds: '+str(acceleration.getSeconds()))
#variable length
make = car.getMake()
print('make: '+str(make))
model = car.getModel()
print('model: '+str(model))