@bitpoolos/edge-bacnet 1.4.7 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +106 -77
- package/bacnet_client.js +172 -97
- package/bacnet_device.js +18 -3
- package/bacnet_gateway.html +160 -40
- package/bacnet_gateway.js +4 -5
- package/bacnet_read.html +1032 -1008
- package/common.js +41 -1
- package/package.json +2 -2
- package/resources/node-bacstack-ts/dist/lib/client.js +161 -82
- package/resources/node-bacstack-ts/dist/lib/transport.js +57 -25
- package/resources/style.css +6 -6
package/common.js
CHANGED
|
@@ -65,7 +65,8 @@ class BacnetClientConfig {
|
|
|
65
65
|
device_read_schedule,
|
|
66
66
|
retries,
|
|
67
67
|
cacheFileEnabled,
|
|
68
|
-
sanitise_device_schedule
|
|
68
|
+
sanitise_device_schedule,
|
|
69
|
+
portRangeMatrix
|
|
69
70
|
) {
|
|
70
71
|
this.apduTimeout = apduTimeout;
|
|
71
72
|
this.localIpAdrress = localIpAdrress;
|
|
@@ -83,9 +84,26 @@ class BacnetClientConfig {
|
|
|
83
84
|
this.retries = retries;
|
|
84
85
|
this.cacheFileEnabled = cacheFileEnabled;
|
|
85
86
|
this.sanitise_device_schedule = sanitise_device_schedule;
|
|
87
|
+
this.portRangeMatrix = this.generatePortRangeArray(portRangeMatrix);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
generatePortRangeArray(rangeMatrix) {
|
|
91
|
+
let portArray = [];
|
|
92
|
+
for (let x = 0; x < rangeMatrix.length; x++) {
|
|
93
|
+
let rangeEntry = rangeMatrix[x];
|
|
94
|
+
let start = parseInt(rangeEntry.start);
|
|
95
|
+
let end = parseInt(rangeEntry.end);
|
|
96
|
+
for (let i = start; i <= end; i++) {
|
|
97
|
+
portArray.push(i);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return portArray;
|
|
86
102
|
}
|
|
87
103
|
}
|
|
88
104
|
|
|
105
|
+
|
|
106
|
+
|
|
89
107
|
class ReadCommandConfig {
|
|
90
108
|
constructor(pointsToRead, objectProperties, decimalPrecision) {
|
|
91
109
|
this.pointsToRead = pointsToRead;
|
|
@@ -273,6 +291,26 @@ function decodeBitArray(size, bits) {
|
|
|
273
291
|
};
|
|
274
292
|
}
|
|
275
293
|
|
|
294
|
+
function getBacnetErrorString(classInt, codeInt) {
|
|
295
|
+
const classString = Object.keys(baEnum.ErrorClass).find(key => baEnum.ErrorClass[key] === classInt);
|
|
296
|
+
const codeString = Object.keys(baEnum.ErrorCode).find(key => baEnum.ErrorCode[key] === codeInt);
|
|
297
|
+
return `BacnetError - Class:${classString} - Code:${codeString}`;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function parseBacnetError(error) {
|
|
301
|
+
let err = error.message;
|
|
302
|
+
if (err.includes("Class") && err.includes("Code")) {
|
|
303
|
+
const match = err.match(/Class:(\d+) - Code:(\d+)/);
|
|
304
|
+
if (match) {
|
|
305
|
+
err = getBacnetErrorString(parseInt(match[1], 10), parseInt(match[2], 10));
|
|
306
|
+
}
|
|
307
|
+
} else if (err.includes("ERR_TIMEOUT")) {
|
|
308
|
+
err = "Request TIMEOUT";
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return err;
|
|
312
|
+
};
|
|
313
|
+
|
|
276
314
|
module.exports = {
|
|
277
315
|
BacnetConfig,
|
|
278
316
|
BacnetClientConfig,
|
|
@@ -289,4 +327,6 @@ module.exports = {
|
|
|
289
327
|
Read_Config_Sync_Server,
|
|
290
328
|
isNumber,
|
|
291
329
|
decodeBitArray,
|
|
330
|
+
parseBacnetError,
|
|
331
|
+
getBacnetErrorString,
|
|
292
332
|
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitpoolos/edge-bacnet",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "A bacnet gateway for node-red",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@plus4nodered/ts-node-bacnet": "^1.0.0-beta.2",
|
|
7
7
|
"async-mutex": "^0.4.0",
|
|
8
8
|
"cronosjs": "^1.7.1",
|
|
9
9
|
"debug": "^4.1.1",
|
|
10
|
-
"iconv-lite": "^0.
|
|
10
|
+
"iconv-lite": "^0.6.3",
|
|
11
11
|
"toad-scheduler": "^1.6.0",
|
|
12
12
|
"underscore": "^1.10.2",
|
|
13
13
|
"winston": "^3.2.1"
|