2017-11-26 01:14:02 +00:00
|
|
|
// This file has been automatically generated by writeMessageClasses.js
|
|
|
|
|
|
2020-01-06 12:10:40 +00:00
|
|
|
import { UUID } from '../UUID';
|
|
|
|
|
import { MessageFlags } from '../../enums/MessageFlags';
|
|
|
|
|
import { MessageBase } from '../MessageBase';
|
|
|
|
|
import { Message } from '../../enums/Message';
|
2017-11-26 01:14:02 +00:00
|
|
|
|
|
|
|
|
export class SystemMessageMessage implements MessageBase
|
|
|
|
|
{
|
|
|
|
|
name = 'SystemMessage';
|
|
|
|
|
messageFlags = MessageFlags.Trusted | MessageFlags.Zerocoded | MessageFlags.FrequencyLow;
|
|
|
|
|
id = Message.SystemMessage;
|
|
|
|
|
|
|
|
|
|
MethodData: {
|
2017-11-26 19:47:41 +00:00
|
|
|
Method: Buffer;
|
2017-11-26 01:14:02 +00:00
|
|
|
Invoice: UUID;
|
|
|
|
|
Digest: Buffer;
|
|
|
|
|
};
|
|
|
|
|
ParamList: {
|
2017-11-26 19:47:41 +00:00
|
|
|
Parameter: Buffer;
|
2017-11-26 01:14:02 +00:00
|
|
|
}[];
|
|
|
|
|
|
|
|
|
|
getSize(): number
|
|
|
|
|
{
|
2017-12-20 17:07:10 +00:00
|
|
|
return (this.MethodData['Method'].length + 1) + this.calculateVarVarSize(this.ParamList, 'Parameter', 1) + 49;
|
2017-11-26 01:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
calculateVarVarSize(block: object[], paramName: string, extraPerVar: number): number
|
|
|
|
|
{
|
|
|
|
|
let size = 0;
|
|
|
|
|
block.forEach((bl: any) =>
|
|
|
|
|
{
|
|
|
|
|
size += bl[paramName].length + extraPerVar;
|
|
|
|
|
});
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
writeToBuffer(buf: Buffer, pos: number): number
|
|
|
|
|
{
|
|
|
|
|
const startPos = pos;
|
|
|
|
|
buf.writeUInt8(this.MethodData['Method'].length, pos++);
|
2017-11-26 19:47:41 +00:00
|
|
|
this.MethodData['Method'].copy(buf, pos);
|
2017-11-26 01:14:02 +00:00
|
|
|
pos += this.MethodData['Method'].length;
|
|
|
|
|
this.MethodData['Invoice'].writeToBuffer(buf, pos);
|
|
|
|
|
pos += 16;
|
|
|
|
|
this.MethodData['Digest'].copy(buf, pos);
|
|
|
|
|
pos += 32;
|
|
|
|
|
const count = this.ParamList.length;
|
|
|
|
|
buf.writeUInt8(this.ParamList.length, pos++);
|
|
|
|
|
for (let i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
buf.writeUInt8(this.ParamList[i]['Parameter'].length, pos++);
|
2017-11-26 19:47:41 +00:00
|
|
|
this.ParamList[i]['Parameter'].copy(buf, pos);
|
2017-11-26 01:14:02 +00:00
|
|
|
pos += this.ParamList[i]['Parameter'].length;
|
|
|
|
|
}
|
|
|
|
|
return pos - startPos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
readFromBuffer(buf: Buffer, pos: number): number
|
|
|
|
|
{
|
|
|
|
|
const startPos = pos;
|
|
|
|
|
let varLength = 0;
|
|
|
|
|
const newObjMethodData: {
|
2017-11-26 19:47:41 +00:00
|
|
|
Method: Buffer,
|
2017-11-26 01:14:02 +00:00
|
|
|
Invoice: UUID,
|
|
|
|
|
Digest: Buffer
|
|
|
|
|
} = {
|
2017-11-26 19:47:41 +00:00
|
|
|
Method: Buffer.allocUnsafe(0),
|
2017-11-26 01:14:02 +00:00
|
|
|
Invoice: UUID.zero(),
|
|
|
|
|
Digest: Buffer.allocUnsafe(0)
|
|
|
|
|
};
|
|
|
|
|
varLength = buf.readUInt8(pos++);
|
2017-11-30 04:11:59 +00:00
|
|
|
newObjMethodData['Method'] = buf.slice(pos, pos + varLength);
|
2017-11-26 01:14:02 +00:00
|
|
|
pos += varLength;
|
|
|
|
|
newObjMethodData['Invoice'] = new UUID(buf, pos);
|
|
|
|
|
pos += 16;
|
|
|
|
|
newObjMethodData['Digest'] = buf.slice(pos, pos + 32);
|
|
|
|
|
pos += 32;
|
|
|
|
|
this.MethodData = newObjMethodData;
|
2020-01-06 12:10:40 +00:00
|
|
|
if (pos >= buf.length)
|
|
|
|
|
{
|
|
|
|
|
return pos - startPos;
|
|
|
|
|
}
|
2017-11-26 01:14:02 +00:00
|
|
|
const count = buf.readUInt8(pos++);
|
|
|
|
|
this.ParamList = [];
|
|
|
|
|
for (let i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
const newObjParamList: {
|
2017-11-26 19:47:41 +00:00
|
|
|
Parameter: Buffer
|
2017-11-26 01:14:02 +00:00
|
|
|
} = {
|
2017-11-26 19:47:41 +00:00
|
|
|
Parameter: Buffer.allocUnsafe(0)
|
2017-11-26 01:14:02 +00:00
|
|
|
};
|
|
|
|
|
varLength = buf.readUInt8(pos++);
|
2017-11-30 04:11:59 +00:00
|
|
|
newObjParamList['Parameter'] = buf.slice(pos, pos + varLength);
|
2017-11-26 01:14:02 +00:00
|
|
|
pos += varLength;
|
|
|
|
|
this.ParamList.push(newObjParamList);
|
|
|
|
|
}
|
|
|
|
|
return pos - startPos;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|