@bitpoolos/edge-bacnet 1.2.3 → 1.2.4
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/bacnet_client.js +12 -10
- package/bacnet_gateway.js +5 -15
- package/bacnet_read.html +4 -4
- package/bacnet_read.js +5 -7
- package/package.json +1 -1
package/bacnet_client.js
CHANGED
|
@@ -319,7 +319,6 @@ class BacnetClient extends EventEmitter {
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
} else {
|
|
322
|
-
that.logOut("queryPriorityDevices: invalid device found: ", device);
|
|
323
322
|
query(index);
|
|
324
323
|
}
|
|
325
324
|
} else if(index == priorityDevices.length) {
|
|
@@ -359,12 +358,12 @@ class BacnetClient extends EventEmitter {
|
|
|
359
358
|
sanitizeDeviceList() {
|
|
360
359
|
let that = this;
|
|
361
360
|
|
|
362
|
-
//
|
|
363
|
-
let timeoutThreshold = parseInt(that.discover_polling_schedule);
|
|
361
|
+
//Discover frequencey x 2
|
|
362
|
+
let timeoutThreshold = parseInt(that.discover_polling_schedule) * 2;
|
|
364
363
|
|
|
365
364
|
that.deviceList.forEach(function(device, index) {
|
|
366
|
-
if(((Date.now() - device.getLastSeen()) / 1000) >
|
|
367
|
-
//render device hasnt responded to whoIs for
|
|
365
|
+
if(((Date.now() - device.getLastSeen()) / 1000) > timeoutThreshold && device.getPriorityQueueIsActive() == false) {
|
|
366
|
+
//render device hasnt responded to whoIs for disover frequency x 2
|
|
368
367
|
|
|
369
368
|
let renderListIndex = that.renderList.findIndex(ele => ele.deviceId == device.getDeviceId());
|
|
370
369
|
|
|
@@ -988,16 +987,18 @@ class BacnetClient extends EventEmitter {
|
|
|
988
987
|
});
|
|
989
988
|
}
|
|
990
989
|
|
|
991
|
-
updatePriorityQueue(
|
|
990
|
+
updatePriorityQueue(priorityDevices) {
|
|
992
991
|
let that = this;
|
|
993
992
|
return new Promise(async function(resolve, reject) {
|
|
994
993
|
try {
|
|
995
|
-
let keys = Object.keys(
|
|
994
|
+
let keys = Object.keys(priorityDevices);
|
|
996
995
|
if(keys.length > 0) {
|
|
997
996
|
keys.forEach(function(key) {
|
|
998
997
|
let device = that.deviceList.find(ele => `${that.getDeviceAddress(ele)}-${ele.getDeviceId()}` == key);
|
|
999
|
-
let points =
|
|
1000
|
-
device
|
|
998
|
+
let points = priorityDevices[key];
|
|
999
|
+
if(device) {
|
|
1000
|
+
device.setPriorityQueue(points);
|
|
1001
|
+
}
|
|
1001
1002
|
});
|
|
1002
1003
|
} else if(keys.length == 0) {
|
|
1003
1004
|
that.clearPriorityQueues();
|
|
@@ -1309,7 +1310,8 @@ class BacnetClient extends EventEmitter {
|
|
|
1309
1310
|
}
|
|
1310
1311
|
}
|
|
1311
1312
|
}
|
|
1312
|
-
|
|
1313
|
+
that.networkTree[deviceKey] = values;
|
|
1314
|
+
resolve(that.networkTree);
|
|
1313
1315
|
});
|
|
1314
1316
|
}
|
|
1315
1317
|
|
package/bacnet_gateway.js
CHANGED
|
@@ -177,6 +177,11 @@ module.exports = function (RED) {
|
|
|
177
177
|
} else if (msg.payload == "BindEvents") {
|
|
178
178
|
node.bacnetClient.removeAllListeners();
|
|
179
179
|
bindEventListeners();
|
|
180
|
+
} else if (msg.doUpdatePriorityDevices == true && msg.priorityDevices !== null) {
|
|
181
|
+
node.bacnetClient.updatePriorityQueue(msg.priorityDevices).then(function (result) {
|
|
182
|
+
}).catch(function (error) {
|
|
183
|
+
logOut("Error updating priorityQueue: ", error);
|
|
184
|
+
});
|
|
180
185
|
}
|
|
181
186
|
|
|
182
187
|
});
|
|
@@ -264,21 +269,6 @@ module.exports = function (RED) {
|
|
|
264
269
|
}
|
|
265
270
|
});
|
|
266
271
|
|
|
267
|
-
//route handler for priority queue
|
|
268
|
-
RED.httpAdmin.post('/bitpool-bacnet-data/priorityQueue', function (req, res) {
|
|
269
|
-
if (!node.bacnetClient) {
|
|
270
|
-
logOut("Issue with the bacnetClient while getting device list: ", node.bacnetClient);
|
|
271
|
-
res.send(false);
|
|
272
|
-
} else {
|
|
273
|
-
node.bacnetClient.updatePriorityQueue(req).then(function (result) {
|
|
274
|
-
res.send(result);
|
|
275
|
-
}).catch(function (error) {
|
|
276
|
-
res.send(error);
|
|
277
|
-
logOut("Error updating priorityQueue: ", error);
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
|
|
282
272
|
node.on('close', function () {
|
|
283
273
|
//do nothing
|
|
284
274
|
});
|
package/bacnet_read.html
CHANGED
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
this.$forceUpdate()
|
|
160
160
|
|
|
161
161
|
//update node-red data structure to forward to gateway
|
|
162
|
-
let device = this.deviceList.find(ele => ele.
|
|
162
|
+
let device = this.deviceList.find(ele => ele.address == slotProps.node.ipAddr && ele.deviceId == slotProps.node.deviceId);
|
|
163
163
|
let deviceAddress = app.getDeviceAddress(device.address);
|
|
164
164
|
let key = `${deviceAddress}-${device.deviceId}`;
|
|
165
165
|
let points = this.pointList[key];
|
|
@@ -208,7 +208,7 @@
|
|
|
208
208
|
this.$forceUpdate();
|
|
209
209
|
|
|
210
210
|
//update node-red data structure
|
|
211
|
-
let device = this.deviceList.find(ele => ele.
|
|
211
|
+
let device = this.deviceList.find(ele => ele.address == slotProps.node.ipAddr && ele.deviceId == slotProps.node.deviceId);
|
|
212
212
|
let deviceAddress = app.getDeviceAddress(device.address);
|
|
213
213
|
let key = `${deviceAddress}-${device.deviceId}`;
|
|
214
214
|
if (this.pointsToRead[key]) {
|
|
@@ -254,7 +254,7 @@
|
|
|
254
254
|
this.$forceUpdate();
|
|
255
255
|
|
|
256
256
|
//update node-red data structure
|
|
257
|
-
let device = this.deviceList.find(ele => ele.
|
|
257
|
+
let device = this.deviceList.find(ele => ele.address == parentDevice.ipAddr && ele.deviceId == parentDevice.deviceId);
|
|
258
258
|
let deviceAddress = app.getDeviceAddress(device.address);
|
|
259
259
|
let key = `${deviceAddress}-${device.deviceId}`;
|
|
260
260
|
|
|
@@ -292,7 +292,7 @@
|
|
|
292
292
|
this.$forceUpdate();
|
|
293
293
|
|
|
294
294
|
//update node-red data stucture
|
|
295
|
-
let device = this.deviceList.find(ele => ele.
|
|
295
|
+
let device = this.deviceList.find(ele => ele.address == parentDevice.ipAddr && ele.deviceId == parentDevice.deviceId);
|
|
296
296
|
let deviceAddress = app.getDeviceAddress(device.address);
|
|
297
297
|
let key = `${deviceAddress}-${device.deviceId}`;
|
|
298
298
|
let point = this.pointList[key][slotProps.node.pointName];
|
package/bacnet_read.js
CHANGED
|
@@ -60,14 +60,12 @@ module.exports = function (RED) {
|
|
|
60
60
|
rejectUnauthorized: false
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
//do nothing
|
|
68
|
-
});
|
|
63
|
+
let priorityDevicesMsg = {
|
|
64
|
+
doUpdatePriorityDevices: true,
|
|
65
|
+
priorityDevices: node.pointsToRead
|
|
66
|
+
};
|
|
69
67
|
|
|
70
|
-
|
|
68
|
+
node.send(priorityDevicesMsg);
|
|
71
69
|
|
|
72
70
|
node.on('input', function(msg) {
|
|
73
71
|
|