Exemple #1
0
import io
from baseline.Car import Car
from baseline.BooleanType import BooleanType
from baseline.Model import Model

buffer = bytearray(2048)

# start decoding
car = Car()
car.wrapForEncode(buffer, 0, len(buffer))

car.setSerialNumber(1234)
car.setModelYear(2013)
car.setAvailable(BooleanType.TRUE)
car.setCode(Model.A)

# fixed arrays
for i in range(0, car.someNumbersLength()):
    car.setSomeNumbers(i, i)

code = [x for x in 'abcdef']
for i in range(0, car.vehicleCodeLength()):
    car.setVehicleCode(i, code[i])

car.extras().setCruiseControl(True)
car.extras().setSportsPack(True)
car.extras().setSunRoof(False)

# composites
car.engine().setCapacity(2000)
car.engine().setNumCylinders(4)
import io
from baseline.Car import Car

length = 129
inp = io.open('car.bin', 'rb')
buffer = inp.read(length)

# start decoding
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)))

print('vehicleCode: "'+str(car.getVehicleCode())) + '"'

# 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()))
import io
from baseline.Car import Car
from baseline.BooleanType import BooleanType
from baseline.Model import Model

buffer = bytearray(2048)

# start decoding
car = Car()
car.wrapForEncode(buffer, 0, len(buffer))

car.setSerialNumber(1234)
car.setModelYear(2013)
car.setAvailable(BooleanType.TRUE)
car.setCode(Model.A)

# fixed arrays
for i in range(0, car.someNumbersLength()) :
    car.setSomeNumbers(i, i)

# Note: pad to fixed size if necessary for char arrays:
# car.setVehicleCode('abc'.ljust(6))
#
car.setVehicleCode('abcdef')

car.extras().setCruiseControl(True)
car.extras().setSportsPack(True)
car.extras().setSunRoof(False)

# composites
car.engine().setCapacity(2000)
Exemple #4
0
import io
from baseline.Car import Car

length = 129
inp = io.open('car.bin', 'rb')
buffer = inp.read(length)

# start decoding
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()))