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 { MessageFlags } from '../../enums/MessageFlags';
|
|
|
|
|
import { MessageBase } from '../MessageBase';
|
|
|
|
|
import { Message } from '../../enums/Message';
|
2017-11-26 01:14:02 +00:00
|
|
|
|
|
|
|
|
export class AlertMessageMessage implements MessageBase
|
|
|
|
|
{
|
|
|
|
|
name = 'AlertMessage';
|
|
|
|
|
messageFlags = MessageFlags.Trusted | MessageFlags.FrequencyLow;
|
|
|
|
|
id = Message.AlertMessage;
|
|
|
|
|
|
|
|
|
|
AlertData: {
|
2017-11-26 19:47:41 +00:00
|
|
|
Message: Buffer;
|
2017-11-26 01:14:02 +00:00
|
|
|
};
|
|
|
|
|
AlertInfo: {
|
2017-11-26 19:47:41 +00:00
|
|
|
Message: Buffer;
|
|
|
|
|
ExtraParams: Buffer;
|
2017-11-26 01:14:02 +00:00
|
|
|
}[];
|
|
|
|
|
|
|
|
|
|
getSize(): number
|
|
|
|
|
{
|
2023-11-09 18:00:35 +00:00
|
|
|
return (this.AlertData['Message'].length + 1) + this.calculateVarVarSize(this.AlertInfo, 'Message', 1) + this.calculateVarVarSize(this.AlertInfo, 'ExtraParams', 1) + 1;
|
2017-11-26 01:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
2021-09-23 17:21:36 +01:00
|
|
|
calculateVarVarSize(block: { [key: string]: any }[], paramName: string, extraPerVar: number): number
|
2017-11-26 01:14:02 +00:00
|
|
|
{
|
|
|
|
|
let size = 0;
|
2020-11-19 16:27:29 +00:00
|
|
|
for (const bl of block)
|
2017-11-26 01:14:02 +00:00
|
|
|
{
|
|
|
|
|
size += bl[paramName].length + extraPerVar;
|
2020-11-19 16:27:29 +00:00
|
|
|
}
|
2017-11-26 01:14:02 +00:00
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-03 13:55:02 +00:00
|
|
|
// @ts-ignore
|
2017-11-26 01:14:02 +00:00
|
|
|
writeToBuffer(buf: Buffer, pos: number): number
|
|
|
|
|
{
|
|
|
|
|
const startPos = pos;
|
|
|
|
|
buf.writeUInt8(this.AlertData['Message'].length, pos++);
|
2017-11-26 19:47:41 +00:00
|
|
|
this.AlertData['Message'].copy(buf, pos);
|
2017-11-26 01:14:02 +00:00
|
|
|
pos += this.AlertData['Message'].length;
|
2023-11-09 18:00:35 +00:00
|
|
|
const count = this.AlertInfo.length;
|
2017-11-26 01:14:02 +00:00
|
|
|
buf.writeUInt8(this.AlertInfo.length, pos++);
|
|
|
|
|
for (let i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
buf.writeUInt8(this.AlertInfo[i]['Message'].length, pos++);
|
2017-11-26 19:47:41 +00:00
|
|
|
this.AlertInfo[i]['Message'].copy(buf, pos);
|
2017-11-26 01:14:02 +00:00
|
|
|
pos += this.AlertInfo[i]['Message'].length;
|
|
|
|
|
buf.writeUInt8(this.AlertInfo[i]['ExtraParams'].length, pos++);
|
2017-11-26 19:47:41 +00:00
|
|
|
this.AlertInfo[i]['ExtraParams'].copy(buf, pos);
|
2017-11-26 01:14:02 +00:00
|
|
|
pos += this.AlertInfo[i]['ExtraParams'].length;
|
|
|
|
|
}
|
|
|
|
|
return pos - startPos;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-03 13:55:02 +00:00
|
|
|
// @ts-ignore
|
2017-11-26 01:14:02 +00:00
|
|
|
readFromBuffer(buf: Buffer, pos: number): number
|
|
|
|
|
{
|
|
|
|
|
const startPos = pos;
|
|
|
|
|
let varLength = 0;
|
|
|
|
|
const newObjAlertData: {
|
2017-11-26 19:47:41 +00:00
|
|
|
Message: Buffer
|
2017-11-26 01:14:02 +00:00
|
|
|
} = {
|
2017-11-26 19:47:41 +00:00
|
|
|
Message: Buffer.allocUnsafe(0)
|
2017-11-26 01:14:02 +00:00
|
|
|
};
|
|
|
|
|
varLength = buf.readUInt8(pos++);
|
2017-11-30 04:11:59 +00:00
|
|
|
newObjAlertData['Message'] = buf.slice(pos, pos + varLength);
|
2017-11-26 01:14:02 +00:00
|
|
|
pos += varLength;
|
|
|
|
|
this.AlertData = newObjAlertData;
|
2020-01-06 12:10:40 +00:00
|
|
|
if (pos >= buf.length)
|
|
|
|
|
{
|
|
|
|
|
return pos - startPos;
|
|
|
|
|
}
|
2023-11-09 18:00:35 +00:00
|
|
|
const count = buf.readUInt8(pos++);
|
2017-11-26 01:14:02 +00:00
|
|
|
this.AlertInfo = [];
|
|
|
|
|
for (let i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
const newObjAlertInfo: {
|
2017-11-26 19:47:41 +00:00
|
|
|
Message: Buffer,
|
|
|
|
|
ExtraParams: Buffer
|
2017-11-26 01:14:02 +00:00
|
|
|
} = {
|
2017-11-26 19:47:41 +00:00
|
|
|
Message: Buffer.allocUnsafe(0),
|
|
|
|
|
ExtraParams: Buffer.allocUnsafe(0)
|
2017-11-26 01:14:02 +00:00
|
|
|
};
|
|
|
|
|
varLength = buf.readUInt8(pos++);
|
2017-11-30 04:11:59 +00:00
|
|
|
newObjAlertInfo['Message'] = buf.slice(pos, pos + varLength);
|
2017-11-26 01:14:02 +00:00
|
|
|
pos += varLength;
|
|
|
|
|
varLength = buf.readUInt8(pos++);
|
2017-11-30 04:11:59 +00:00
|
|
|
newObjAlertInfo['ExtraParams'] = buf.slice(pos, pos + varLength);
|
2017-11-26 01:14:02 +00:00
|
|
|
pos += varLength;
|
|
|
|
|
this.AlertInfo.push(newObjAlertInfo);
|
|
|
|
|
}
|
|
|
|
|
return pos - startPos;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|