deserializePayload method
int
deserializePayload(
- PlanControlBuilder builder,
- ByteData byteData,
- Endian endianness,
- int offset,
override
Call to deserialize only the payload, no header. The Builder is to allow passing the message to build into. returns a int with a serialized size
Implementation
@override
int deserializePayload(imc.PlanControlBuilder builder, ByteData byteData,
Endian endianness, int offset) {
var byteOffset = offset;
// field type
builder.type = imc.PlanControlEnumType(byteData.getUint8(byteOffset));
byteOffset += 1;
// field op
builder.op = imc.PlanControlEnumOp(byteData.getUint8(byteOffset));
byteOffset += 1;
// field requestId
builder.requestId = byteData.getUint16(byteOffset, endianness);
byteOffset += 2;
// field planId
var planIdSSize = byteData.getUint16(byteOffset, endianness);
byteOffset += 2;
var planIdDData = List.filled(planIdSSize, 0);
for (var i = 0; i < planIdSSize; i++) {
planIdDData[i] = byteData.getUint8(byteOffset++);
}
var planIdDecoded = utf8.decode(planIdDData);
builder.planId = planIdDecoded;
// field flags
builder.flags = imc.PlanControlBitfieldFlags(
byteData.getUint16(byteOffset, endianness));
byteOffset += 2;
// field arg
var argSId = byteData.getUint16(byteOffset, endianness);
byteOffset += 2;
if (argSId == imc.ImcId.nullId) {
builder.arg = null;
} else {
var pMsgBuilder = imc.messagesBuilders[
imc.idsToMessages[argSId] ?? imc.ImcId.nullId.toString()]
?.call()
.newInstance(builder);
var pMsgSerializer = imc.messagesSerializers[
imc.idsToMessages[argSId] ?? imc.ImcId.nullId.toString()]
?.call();
if (pMsgBuilder != null && pMsgSerializer != null) {
var mPSize = pMsgSerializer.deserializePayload(
pMsgBuilder, byteData, endianness, byteOffset);
byteOffset += mPSize;
builder.arg = pMsgBuilder.build() as imc.ImcMessage?;
}
}
// field info
var infoSSize = byteData.getUint16(byteOffset, endianness);
byteOffset += 2;
var infoDData = List.filled(infoSSize, 0);
for (var i = 0; i < infoSSize; i++) {
infoDData[i] = byteData.getUint8(byteOffset++);
}
var infoDecoded = utf8.decode(infoDData);
builder.info = infoDecoded;
return byteOffset - offset;
}