-
Notifications
You must be signed in to change notification settings - Fork 2
/
GW_GROUP_INFORMATION_CHANGED_NTF.ts
65 lines (56 loc) · 1.85 KB
/
GW_GROUP_INFORMATION_CHANGED_NTF.ts
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
61
62
63
64
65
"use strict";
import { bitArrayToArray } from "../utils/BitArray";
import { GroupType } from "./GW_GROUPS";
import { NodeVariation, Velocity } from "./GW_SYSTEMTABLE_DATA";
import { GW_FRAME_NTF, readZString } from "./common";
export enum ChangeType {
Deleted = 0,
Modified = 1,
}
export interface GW_GROUP_INFORMATION_CHANGED_NTF_Deleted {
readonly ChangeType: ChangeType.Deleted;
readonly GroupID: number;
}
export interface GW_GROUP_INFORMATION_CHANGED_NTF_Modified {
readonly ChangeType: ChangeType.Modified;
readonly GroupID: number;
readonly Order: number;
readonly Placement: number;
readonly Name: string;
readonly Velocity: Velocity;
readonly NodeVariation: NodeVariation;
readonly GroupType: GroupType;
readonly Nodes: number[];
readonly Revision: number;
}
export class GW_GROUP_INFORMATION_CHANGED_NTF extends GW_FRAME_NTF {
public readonly GroupID: number;
public readonly ChangeType: ChangeType;
public readonly Order?: number;
public readonly Placement?: number;
public readonly Name?: string;
public readonly Velocity?: Velocity;
public readonly NodeVariation?: NodeVariation;
public readonly GroupType?: GroupType;
public readonly Nodes?: number[];
public readonly Revision?: number;
constructor(Data: Buffer) {
super(Data);
this.ChangeType = this.Data.readUInt8(0);
this.GroupID = this.Data.readUInt8(1);
if (this.ChangeType === ChangeType.Modified) {
this.Order = this.Data.readUInt16BE(2);
this.Placement = this.Data.readUInt8(4);
this.Name = readZString(this.Data.subarray(5, 69));
this.Velocity = this.Data.readUInt8(69);
this.NodeVariation = this.Data.readUInt8(70);
this.GroupType = this.Data.readUInt8(71);
this.Revision = this.Data.readUInt16BE(98);
if (this.GroupType === GroupType.UserGroup) {
this.Nodes = bitArrayToArray(this.Data.subarray(73, 98));
} else {
this.Nodes = [];
}
}
}
}