-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
779 lines (649 loc) · 27.2 KB
/
index.js
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
//NAME: index.js
//AUTH: Ryan McCartney ([email protected])
//DESC: Main class for the Probel SW-P-08 client
//DATE: 07/03/2022
const Net = require("net");
const { mod, div, chk, matrixLevelByte, multiplier, message, ackMessage, nakMessage } = require("./utils/utils");
const merge = require("./utils/merge");
const EventEmitter = require("events");
const charLengthLookup = [4, 8, 12, 16, 32];
const interrogateMessage = (destinationNumber, levelNumber = 0, matrixNumber = 0, extended = false) => {
let commandNumber = 1;
let array = [];
if (extended) {
commandNumber = 129;
const destNumberDiv = div(destinationNumber, 256);
const destNumberMod = mod(destinationNumber, 256);
const levelByte = Buffer.alloc(1);
levelByte.writeUInt8(levelNumber, 0);
const matrixByte = Buffer.alloc(1);
matrixByte.writeUInt8(matrixNumber, 0);
array = [matrixByte, levelByte, destNumberDiv, destNumberMod];
} else {
const multiplierNumber = multiplier(destinationNumber, 0);
const destNumber = mod(destinationNumber, 128);
array = [matrixLevelByte.encode(matrixNumber, levelNumber), multiplierNumber, destNumber];
}
const data = Buffer.concat(array);
return message(commandNumber, data);
};
const indexOfAll = (buffer, searchItem) => {
let i = buffer.indexOf(searchItem, 0, "hex");
const indexes = [];
while (i !== -1) {
indexes.push(i);
i = i + 2;
i = buffer.indexOf(searchItem, i, "hex");
}
return indexes;
};
const getMessages = (data) => {
const messages = [];
const somIndexes = indexOfAll(data, "1002");
const eomIndexed = indexOfAll(data, "1003");
for (let i in somIndexes) {
//console.log(data.slice(somIndexes[i] + 2, eomIndexed[i]).toString("hex"));
messages.push(data.slice(somIndexes[i] + 2, eomIndexed[i]));
}
return messages;
};
const crosspointMessage = (levelNumber, sourceNumber, destinationNumber, matrixNumber = 0) => {
const commandNumber = 2;
const multiplierNumber = multiplier(destinationNumber, sourceNumber);
const destNumber = mod(destinationNumber, 128);
const srcNumber = mod(sourceNumber, 128);
const array = [matrixLevelByte.encode(matrixNumber, levelNumber), multiplierNumber, destNumber, srcNumber];
const data = Buffer.concat(array);
return message(commandNumber, data);
};
const crosspointMessageExtended = (levelNumber, sourceNumber, destinationNumber, matrixNumber = 0) => {
const commandNumber = 130;
const levelByte = Buffer.alloc(1);
levelByte.writeUInt8(levelNumber, 0);
const matrixByte = Buffer.alloc(1);
matrixByte.writeUInt8(matrixNumber, 0);
const destNumberMod = mod(destinationNumber, 256);
const srcNumberMod = mod(sourceNumber, 256);
const destNumberDiv = div(destinationNumber, 256);
const srcNumberDiv = div(sourceNumber, 256);
const array = [matrixByte, levelByte, destNumberDiv, destNumberMod, srcNumberDiv, srcNumberMod];
const data = Buffer.concat(array);
return message(commandNumber, data, true);
};
const sourceNamesRequest = (extended = false, matrix = 0, level = 0, chars = 12) => {
let commandNumber = 100;
let array = [];
const charLengthByte = Buffer.alloc(1);
charLengthByte.writeUInt8(charLengthLookup.indexOf(chars, 0), 0);
if (extended) {
commandNumber = 228;
const matrixByte = Buffer.alloc(1);
matrixByte.writeUInt8(matrix, 0);
const levelByte = Buffer.alloc(1);
levelByte.writeUInt8(level, 0);
array = [matrixByte, levelByte, charLengthByte];
} else {
array = [charLengthByte];
}
const data = Buffer.concat(array);
return message(commandNumber, data);
};
const bufferClean = (data) => {
let previousByte;
const cleanedData = [];
for (let byte of data.entries()) {
if (byte[1] === 16 && previousByte === 16) {
previousByte = 0;
} else {
cleanedData.push(data.slice(byte[0], byte[0] + 1));
previousByte = byte[1];
}
}
return Buffer.concat(cleanedData);
};
const umdLabelRequest = () => {
const commandNumber = 104;
return message(commandNumber);
};
const destinationNamesRequest = (extended = false, matrix = 0, chars = 8) => {
let commandNumber = 102;
let array = [];
const charLengthByte = Buffer.alloc(1);
charLengthByte.writeUInt8(charLengthLookup.indexOf(chars, 0), 0);
if (extended) {
commandNumber = 230;
const matrixByte = Buffer.alloc(1);
matrixByte.writeUInt8(matrix, 0);
array = [matrixByte, charLengthByte];
} else {
array = [charLengthByte];
}
const data = Buffer.concat(array);
return message(commandNumber, data);
};
const tallyStateRequest = (level = 0, matrix = 0, extended = false) => {
let commandNumber = 21;
let array = [];
if (extended) {
commandNumber = 149;
const matrixByte = Buffer.alloc(1);
matrixByte.writeUInt8(matrix, 0);
const levelByte = Buffer.alloc(1);
levelByte.writeUInt8(level, 0);
array = [matrixByte, levelByte];
} else {
array = [matrixLevelByte.encode(matrix, level)];
}
return message(commandNumber, Buffer.concat(array));
};
const isAck = (response) => {
if (!Buffer.compare(response, ackMessage())) {
return true;
}
if (!Buffer.compare(response, nakMessage())) {
return false;
}
};
module.exports = class Probel {
constructor(host, config) {
this.debug = false;
this.extended = config?.extended || true;
this.connected = false;
this.host = host;
this.port = config.port || 8910;
this.sources = config?.sources || 0;
this.destinations = config?.destinations || 0;
this.levels = config?.levels || 17;
this.matrix = config?.matrix || 1;
this.chars = config?.chars || 8;
this.client;
this.tallies = {};
this.sourceNames = {};
this.destinationNames = {};
this.umdLabels = {};
this.callback = {};
this.events = new EventEmitter();
this.events.setMaxListeners(this.levels + 4);
if (this.levels > 16 || this.sources > 1024 || this.destinations > 1024) {
this.log("Probel: using extended commands");
this.extended = true;
}
this.connect();
// Run get labels commands on the matrix to detect matrix size
if (this.destinations === 0) {
this.getDestinationNames();
}
if (this.sources === 0) {
this.getSourceNames();
}
}
log = (message) => {
if (this.debug) {
console.log(message);
}
};
waitForCommand = (commandNumbers, timeout = 8000) => {
return new Promise((resolve, reject) => {
// Set up the timeout
const timer = setTimeout(() => {
resolve({
status: false,
message: `Command timed out after ${timeout}ms.`,
timeout: timeout,
commandNumber: commandNumbers,
});
}, timeout);
if (typeof commandNumbers === "string") [(commandNumbers = [commandNumbers])];
for (let commandNumber of commandNumbers) {
this.events.on(commandNumber, (data) => {
try {
if (data) {
//this.log(`Command number ${commandNumber} triggered`);
clearTimeout(timer);
resolve(data);
}
} catch (error) {
clearTimeout(timer);
resolve({
status: false,
message: `An error has occured.`,
error: error,
commandNumber: commandNumber,
});
}
});
}
});
};
connect = () => {
const port = this.port;
const host = this.host;
const log = this.log;
this.client = new Net.Socket();
try {
this.client.connect({ port: port, host: host }, () => {
this.log("Connection established with the Probel SW-P-08 server.");
this.connected = true;
this.events.emit("connection", true);
});
this.client.on("data", this.handleData);
this.client.on("end", function () {
this.connected = false;
this.log("Connection closed");
});
this.client.on("error", function () {
this.connected = false;
log(`Unable to connect to matrix at ${host}:${port}`);
});
} catch (error) {
this.events.emit("connection", false);
this.log(`Unable to connect to matrix at ${host}:${port}`);
this.log(error);
}
};
send = async (message) => {
let connected = this.connected;
if (!connected) {
connected = await this.waitForCommand("connection");
}
if (connected) {
this.log(`Tx (${message.length}): ${message.toString("hex")}`);
this.client.write(message);
} else {
this.log("Connection to the matrix timed out.");
}
};
handleData = (reply) => {
// Log bytes recieved from the router when in debug mode
this.log(`Rx (${reply.length}): ${reply.toString("hex")}`);
this.log(reply.toString());
if (isAck(reply)) {
this.events.emit("ack", true);
} else {
const messages = getMessages(reply);
for (let message of messages) {
this.processData(message);
}
this.send(ackMessage());
}
};
parseNames = (data) => {
const matrixInfo = matrixLevelByte.decode(data[0]);
const charLength = charLengthLookup[data[1]];
const startIndex = 256 * data[2] + data[3] + 1;
const nameCount = data[4];
const names = {};
//Some unexplained changing of bit positions based on the number of labels in a message
let startPosition = 6;
if (nameCount < 16 || startIndex === 0) {
startPosition = 5;
}
let namesBytes = data.slice(startPosition, Buffer.byteLength(data));
for (let i = 0; i < nameCount; i++) {
const nameBytes = namesBytes.slice(i * charLength, i * charLength + charLength);
const name = nameBytes.toString().trim();
if (name) {
names[startIndex + i] = name;
}
}
return names;
};
parseNamesExt = (data, sourceNames = false) => {
//Packing for Extended Destinations
let matrixNumber = data[0];
let levelNumber = 0;
let charLength = charLengthLookup[data[1]];
let startIndex = 256 * data[2] + data[3] + 1;
let nameCount = data[4];
let startPosition = 5;
//Packing for Extended Destinations
if (sourceNames) {
levelNumber = data[1];
charLength = charLengthLookup[data[2]];
startIndex = 256 * data[3] + data[4] + 1;
nameCount = data[5];
startPosition = 6;
}
const names = {};
let namesBytes = data.slice(startPosition, Buffer.byteLength(data));
for (let i = 0; i < nameCount; i++) {
const sliceIndex = i * charLength;
const nameBytes = namesBytes.slice(sliceIndex, sliceIndex + charLength);
const name = nameBytes.toString().trim();
if (name) {
names[startIndex + i] = name;
}
}
return names;
};
parseTally = (data) => {
const matrixInfo = matrixLevelByte.decode(data[0]);
const tallyCount = data[1];
const sourceBytes = data[3];
const destinationBytes = data[4];
//Create Object Structure
const tallies = {};
tallies[matrixInfo.matrix] = {};
tallies[matrixInfo.matrix][matrixInfo.level] = {};
const source = div(sourceBytes, 128).readUInt8(0);
const destination = div(destinationBytes, 128).readUInt8(0);
//Populte with tally data
tallies[matrixInfo.matrix][matrixInfo.level][destination] = source;
return tallies;
};
parseTallies = (data) => {
const matrixInfo = matrixLevelByte.decode(data[0]);
const tallyCount = data[1];
const sourceBytes = data.slice(4, Buffer.byteLength(data));
const startDestination = 256 * data[2] + data[3] + 1;
//Create Object Structure
const tallies = {};
tallies[matrixInfo.matrix + 1] = {};
tallies[matrixInfo.matrix + 1][matrixInfo.level + 1] = {};
//Populte with tally data
for (let i = 0; i < tallyCount; i++) {
const tally = sourceBytes.slice(i * 2, i * 2 + 2);
const source = tally[0] * 256 + tally[1];
const destination = startDestination + i;
tallies[matrixInfo.matrix][matrixInfo.level][destination] = source;
}
return tallies;
};
parseTallyExt = (data) => {
const matrixNumber = data[0] + 1;
const levelNumber = data[1] + 1;
//Create Object Structure
const tallies = {};
tallies[matrixNumber] = {};
tallies[matrixNumber][levelNumber] = {};
const destination = data[2] * 256 + data[3];
const source = data[4] * 256 + data[5];
tallies[matrixNumber][levelNumber][destination] = source;
return tallies;
};
parseTalliesExt = (data) => {
const matrixNumber = data[0] + 1;
const levelNumber = data[1] + 1;
const sourceBytes = data.slice(5, Buffer.byteLength(data));
//Create Object Structure
const tallies = {};
tallies[matrixNumber] = {};
tallies[matrixNumber][levelNumber] = {};
const tallyCount = data[2];
const startDestination = 256 * data[3] + data[4] + 1;
//Populte with tally data
for (let i = 0; i < tallyCount; i++) {
const tally = sourceBytes.slice(i * 2, i * 2 + 2);
const source = tally[0] * 256 + tally[1];
const destination = startDestination + i;
tallies[matrixNumber][levelNumber][destination] = source;
}
return tallies;
};
on = (event = "crosspoint", callback) => {
if (callback) {
if (event === "crosspoint") {
this.callback[event] = callback;
}
}
};
processData = (data) => {
if (data.length > 0) {
let response;
data = bufferClean(data);
const commandNumber = data.readUInt8(0);
const dataBytes = data.slice(1, Buffer.byteLength(data) - 2);
const btc = data[Buffer.byteLength(data) - 2];
const chkInt = data[Buffer.byteLength(data) - 1];
const chkCalculated = chk(data.slice(0, Buffer.byteLength(data) - 1));
// if (chkInt !== chkCalculated.readUInt8(0)) {
// this.log("Checksum invalid");
// return false;
// }
// if (btc !== Buffer.byteLength(dataBytes) + 1) {
// this.log("Byte Count doesn't match message contents.");
// return false;
// }
switch (commandNumber) {
case 106:
//Handle source name response (4-32 chars per name)
const newSourceNames = this.parseNames(dataBytes);
//Detect if matrix size needs changed
const newSourceNumbers = Object.keys(newSourceNames);
const maxSourceNumber = parseInt(newSourceNumbers[newSourceNumbers.length - 1]);
if (maxSourceNumber > this.sources) {
this.log(`Matrix source size updated to ${maxSourceNumber}`);
this.sources = maxSourceNumber;
}
//Concatenate source names in message to object
if (newSourceNames) {
response = { ...this.sourceNames, ...newSourceNames };
this.sourceNames = response;
}
//Check if all the source names in the matrix have been received
if (newSourceNumbers < this.sources || this.sources === 0) {
response = false;
} else {
response = this.sourceNames;
}
break;
case 234:
//Handle source names response (4-32 chars per name)
const newSourceNamesExt = this.parseNamesExt(dataBytes, true);
//Detect if matrix size needs changed
const newSourceNumbersExt = Object.keys(newSourceNamesExt);
const maxSourceNumberExt = parseInt(newSourceNumbersExt[newSourceNumbersExt.length - 1]);
if (maxSourceNumberExt > this.sources) {
this.log(`Matrix source size updated to ${maxSourceNumberExt}`);
this.sources = maxSourceNumberExt;
}
//Concatenate source names in message to object
if (newSourceNamesExt) {
response = { ...this.sourceNames, ...newSourceNamesExt };
this.sourceNames = response;
}
//Check if all the source names in the matrix have been received
if (maxSourceNumberExt < this.sources || this.sources === 0) {
response = false;
} else {
response = this.sourceNames;
}
break;
case 108:
case 236:
//Handle source names UMD response (16 chars per name)
const newUmdLabels = this.parseNames(dataBytes);
if (newUmdLabels) {
response = { ...this.umdLabels, ...newUmdLabels };
this.umdLabels = response;
}
break;
case 107:
//Handle destination names response (4-32 chars per name)
const newDestinationNames = this.parseNames(dataBytes);
//Detect if matrix size needs changed
const newDestinationNumbers = Object.keys(newDestinationNames);
const maxDestinationNumber = parseInt(newDestinationNumbers[newDestinationNumbers.length - 1]);
if (maxDestinationNumber > this.destinations) {
this.log(`Matrix destination size updated to ${maxDestinationNumber}`);
this.destinations = maxDestinationNumber;
}
//Concatenate destination names in message to object
if (newDestinationNames) {
response = merge(this.destinationNames, newDestinationNames);
this.destinationNames = response;
}
//Check if all the destination names in the matrix have been received
if (maxDestinationNumber < this.destinations || this.destinations === 0) {
response = false;
} else {
response = this.destinationNames;
}
break;
case 235:
//Handle destination names response (4-32 chars per name)
const newDestinationNamesExt = this.parseNamesExt(dataBytes);
//Detect if matrix size needs changed
const newDestinationNumbersExt = Object.keys(newDestinationNamesExt);
const maxDestinationNumberExt = parseInt(
newDestinationNumbersExt[newDestinationNumbersExt.length - 1]
);
if (maxDestinationNumberExt > this.destinations) {
this.log(`Matrix destination size updated to ${maxDestinationNumberExt}`);
this.destinations = maxDestinationNumberExt;
}
//Concatenate destination names in message to object
if (newDestinationNamesExt) {
response = merge(this.destinationNames, newDestinationNamesExt);
this.destinationNames = response;
}
//Check if all the destination names in the matrix have been received
if (maxDestinationNumberExt < this.destinations || this.destinations === 0) {
response = false;
} else {
response = this.destinationNames;
}
break;
case 22:
case 23:
const newTallies = this.parseTallies(dataBytes);
if (newTallies) {
response = merge(this.tallies, newTallies);
this.tallies = response;
const tallyMatrix = Object.keys(newTallies)[0];
const tallyLevel = Object.keys(newTallies[tallyMatrix])[0];
if (
parseInt(
Object.keys(newTallies[tallyMatrix][tallyLevel])[
Object.keys(newTallies[tallyMatrix][tallyLevel]).length - 1
]
) < this.destinations ||
tallyLevel < this.levels - 1
) {
response = false;
}
}
break;
case 3:
case 4:
//Handle crosspoint update information
const crosspointData = this.parseTallies(dataBytes);
if (crosspointData) {
response = merge(this.tallies, crosspointData);
this.tallies = response;
}
if (crosspointData) {
if (this.callback.crosspoint) {
this.callback.crosspoint(crosspointData);
}
response = true;
}
break;
case 131:
//Handle Tally Information for Single Extended Destination
const newTallyExt = this.parseTallyExt(dataBytes);
if (newTallyExt) {
this.tallies = merge(this.tallies, newTallyExt);
response = newTallyExt;
}
break;
case 151:
//Handle Tally Dump Information Extended
const newTalliesExt = this.parseTalliesExt(dataBytes);
if (newTalliesExt) {
response = merge(this.tallies, newTalliesExt);
this.tallies = response;
const tallyMatrix = Object.keys(newTalliesExt)[0];
const tallyLevel = Object.keys(newTalliesExt[tallyMatrix])[0];
if (
parseInt(
Object.keys(newTalliesExt[tallyMatrix][tallyLevel])[
Object.keys(newTalliesExt[tallyMatrix][tallyLevel]).length - 1
]
) < this.destinations ||
tallyLevel < this.levels
) {
response = false;
}
}
break;
case 132:
//Handle Crosspoint Response
const crosspointDataExt = this.parseTallyExt(dataBytes);
if (crosspointDataExt) {
response = merge(this.tallies, crosspointDataExt);
this.tallies = response;
}
if (crosspointDataExt) {
if (this.callback.crosspoint) {
this.callback.crosspoint(crosspointDataExt);
}
response = true;
}
break;
}
this.events.emit(commandNumber, response);
}
};
//Interrogate a single crosspoint (destinationNumber, levelNumber, matrixNumber)
interrogate = async (destinationNumber, levelNumber, matrixNumber) => {
let buffer;
if (this.extended) {
buffer = interrogateMessage(destinationNumber, levelNumber, matrixNumber, true);
} else {
buffer = interrogateMessage(destinationNumber, levelNumber, matrixNumber);
}
this.send(buffer);
return await this.waitForCommand(["3", "131"]);
};
//Route a source to a destination at a specified level only (1 to 17)
route = async (levelNumber, srcNumber, destNumber) => {
let buffer;
if (this.extended) {
buffer = crosspointMessageExtended(levelNumber - 1, srcNumber - 1, destNumber - 1, this.matrix - 1);
} else {
buffer = crosspointMessage(levelNumber - 1, srcNumber - 1, destNumber - 1, this.matrix - 1);
}
this.send(buffer);
return await this.waitForCommand(["132", "3", "4", "ack"]);
};
//Route all the levels from a given source to a given destination (1 to 17)
routeAllLevels = async (srcNumber, destNumber) => {
let status = true;
for (let level = 1; level <= this.levels; level++) {
status &= await this.route(level, srcNumber, destNumber);
}
return status;
};
getSourceNames = async () => {
const buffer = sourceNamesRequest(this.extended, this.matrix - 1, 0, this.chars);
this.send(buffer);
return await this.waitForCommand(["106", "234"]);
};
getDestinationNames = async () => {
const buffer = destinationNamesRequest(this.extended, this.matrix - 1, this.chars);
this.send(buffer);
return await this.waitForCommand(["107", "235"]);
};
getUmdLabels = async () => {
const buffer = umdLabelRequest();
this.send(buffer);
return await this.waitForCommand(["108", "236"]);
};
getState = async () => {
for (let level = 0; level < this.levels; level++) {
const buffer = tallyStateRequest(level, this.matrix - 1, this.extended);
this.send(buffer);
}
return await this.waitForCommand(["22", "23", "151"]);
};
getSize = async () => {
if (this.destinations === 0) {
await this.getDestinationNames();
}
if (this.sources === 0) {
await this.getSourceNames();
}
return { source: this.sources, destinations: this.destinations, levels: this.levels, extended: this.extended };
};
};