@bitpoolos/edge-bacnet 1.4.4 → 1.4.5
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 +8 -0
- package/bacnet_client.js +157 -130
- package/bacnet_gateway.html +141 -135
- package/bacnet_read.html +45 -42
- package/bacnet_write.html +7 -5
- package/bitpool_inject.html +49 -136
- package/package.json +1 -1
- package/resources/style.css +602 -202
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.4.5] - 16-08-2024
|
|
4
|
+
### Summary
|
|
5
|
+
|
|
6
|
+
User interface redesign and restyle. Predominantly colors, buttons, fonts, and placement of UI components.
|
|
7
|
+
|
|
8
|
+
Added timestamp update, and online/offline status update for points when an error has occured during the network request for present value. Use in Simple with status and Full Object payload types.
|
|
9
|
+
|
|
10
|
+
|
|
3
11
|
## [1.4.4] - 08-08-2024
|
|
4
12
|
### Summary
|
|
5
13
|
|
package/bacnet_client.js
CHANGED
|
@@ -90,10 +90,8 @@ class BacnetClient extends EventEmitter {
|
|
|
90
90
|
|
|
91
91
|
//buildNetworkTreeData task
|
|
92
92
|
const buildNetworkTree = new Task("simple task", () => {
|
|
93
|
-
|
|
94
93
|
that.doTreeBuilder();
|
|
95
94
|
that.countDevices();
|
|
96
|
-
|
|
97
95
|
});
|
|
98
96
|
|
|
99
97
|
const buildNetworkTreeJob = new SimpleIntervalJob({ seconds: 5 }, buildNetworkTree);
|
|
@@ -213,28 +211,30 @@ class BacnetClient extends EventEmitter {
|
|
|
213
211
|
if (lastIndex) {
|
|
214
212
|
let formattedName = deviceName.substring(0, lastIndex);
|
|
215
213
|
formattedName = `${formattedName.trim()}_Device_${deviceId}`;
|
|
216
|
-
if (
|
|
217
|
-
|
|
214
|
+
if (
|
|
215
|
+
that.networkTree[deviceKey][formattedName] &&
|
|
216
|
+
Object.keys(that.networkTree[deviceKey][formattedName]).length > 0
|
|
217
|
+
) {
|
|
218
218
|
delete that.networkTree[deviceKey]["device"];
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
} else {
|
|
223
223
|
const json = {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
224
|
+
objectId: {
|
|
225
|
+
type: 8,
|
|
226
|
+
instance: device.getDeviceId(),
|
|
227
|
+
},
|
|
228
228
|
};
|
|
229
229
|
|
|
230
230
|
if (that.networkTree[deviceKey] && that.networkTree[deviceKey]["device"]) {
|
|
231
231
|
that.networkTree[deviceKey]["device"]["meta"] = json;
|
|
232
232
|
} else {
|
|
233
233
|
that.networkTree[deviceKey] = {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
}
|
|
234
|
+
device: {
|
|
235
|
+
meta: json,
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
} catch (e) {
|
|
@@ -262,7 +262,6 @@ class BacnetClient extends EventEmitter {
|
|
|
262
262
|
}
|
|
263
263
|
);
|
|
264
264
|
});
|
|
265
|
-
|
|
266
265
|
}
|
|
267
266
|
|
|
268
267
|
addToParentMstpNetwork(device) {
|
|
@@ -328,12 +327,15 @@ class BacnetClient extends EventEmitter {
|
|
|
328
327
|
await that.updateDeviceName(device);
|
|
329
328
|
|
|
330
329
|
if (device.getIsProtocolServicesSet() == false) {
|
|
331
|
-
that
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
330
|
+
that
|
|
331
|
+
.getProtocolSupported(device)
|
|
332
|
+
.then(function (result) {
|
|
333
|
+
let decodedValues = decodeBitArray(8, result.values[0].originalBitString.value);
|
|
334
|
+
device.setProtocolServicesSupported(decodedValues);
|
|
335
|
+
})
|
|
336
|
+
.catch(function (error) {
|
|
337
|
+
that.logOut("getProtocolSupported error: ", error);
|
|
338
|
+
});
|
|
337
339
|
}
|
|
338
340
|
|
|
339
341
|
that
|
|
@@ -441,7 +443,7 @@ class BacnetClient extends EventEmitter {
|
|
|
441
443
|
for (let key in payload) {
|
|
442
444
|
let device = payload[key];
|
|
443
445
|
for (let pointName in device) {
|
|
444
|
-
let pointObject = device[pointName]
|
|
446
|
+
let pointObject = device[pointName];
|
|
445
447
|
if (that.networkTree[key][pointName]) {
|
|
446
448
|
that.networkTree[key][pointName] = pointObject;
|
|
447
449
|
}
|
|
@@ -472,15 +474,17 @@ class BacnetClient extends EventEmitter {
|
|
|
472
474
|
|
|
473
475
|
if (typeof device == "object") {
|
|
474
476
|
if (device.getIsProtocolServicesSet() == false) {
|
|
475
|
-
that
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
477
|
+
that
|
|
478
|
+
.getProtocolSupported(device)
|
|
479
|
+
.then(function (result) {
|
|
480
|
+
let decodedValues = decodeBitArray(8, result.values[0].originalBitString.value);
|
|
481
|
+
device.setProtocolServicesSupported(decodedValues);
|
|
482
|
+
})
|
|
483
|
+
.catch(function (error) {
|
|
484
|
+
that.logOut("getProtocolSupported error: ", error);
|
|
485
|
+
});
|
|
481
486
|
}
|
|
482
487
|
try {
|
|
483
|
-
|
|
484
488
|
if (device.getSegmentation() !== 3) {
|
|
485
489
|
that.updateDeviceName(device);
|
|
486
490
|
that
|
|
@@ -515,9 +519,7 @@ class BacnetClient extends EventEmitter {
|
|
|
515
519
|
query(index);
|
|
516
520
|
});
|
|
517
521
|
});
|
|
518
|
-
|
|
519
522
|
} else if (device.getSegmentation() == 3) {
|
|
520
|
-
|
|
521
523
|
that.updateDeviceName(device);
|
|
522
524
|
that
|
|
523
525
|
.getDevicePointListWithoutObjectList(device)
|
|
@@ -638,7 +640,7 @@ class BacnetClient extends EventEmitter {
|
|
|
638
640
|
|
|
639
641
|
findDeviceByKey(key) {
|
|
640
642
|
let that = this;
|
|
641
|
-
return that.deviceList.find(ele => `${that.getDeviceAddress(ele)}-${ele.getDeviceId()}` === key);
|
|
643
|
+
return that.deviceList.find((ele) => `${that.getDeviceAddress(ele)}-${ele.getDeviceId()}` === key);
|
|
642
644
|
}
|
|
643
645
|
|
|
644
646
|
getObjectId(pointName, pointConfig, that) {
|
|
@@ -659,7 +661,6 @@ class BacnetClient extends EventEmitter {
|
|
|
659
661
|
}
|
|
660
662
|
}
|
|
661
663
|
|
|
662
|
-
|
|
663
664
|
async doRead(readConfig, outputType, objectPropertyType, readNodeName) {
|
|
664
665
|
const that = this;
|
|
665
666
|
const roundDecimal = readConfig.precision;
|
|
@@ -668,7 +669,6 @@ class BacnetClient extends EventEmitter {
|
|
|
668
669
|
let pendingRequests = 0;
|
|
669
670
|
|
|
670
671
|
try {
|
|
671
|
-
|
|
672
672
|
// Process all devices in sequence
|
|
673
673
|
for (let deviceIndex = 0; deviceIndex < devicesToRead.length; deviceIndex++) {
|
|
674
674
|
const key = devicesToRead[deviceIndex];
|
|
@@ -711,7 +711,7 @@ class BacnetClient extends EventEmitter {
|
|
|
711
711
|
objectId: { type: point.meta.objectId.type, instance: point.meta.objectId.instance },
|
|
712
712
|
properties: [{ id: baEnum.PropertyIdentifier.PRESENT_VALUE }],
|
|
713
713
|
pointRef: point,
|
|
714
|
-
pointName: pointName
|
|
714
|
+
pointName: pointName,
|
|
715
715
|
});
|
|
716
716
|
}
|
|
717
717
|
|
|
@@ -732,9 +732,16 @@ class BacnetClient extends EventEmitter {
|
|
|
732
732
|
if (processedPoints >= totalPoints) {
|
|
733
733
|
pendingRequests++;
|
|
734
734
|
// Emit the `values` event for the current device
|
|
735
|
-
that.emit(
|
|
735
|
+
that.emit(
|
|
736
|
+
"values",
|
|
737
|
+
bacnetResults,
|
|
738
|
+
outputType,
|
|
739
|
+
objectPropertyType,
|
|
740
|
+
readNodeName,
|
|
741
|
+
pendingRequests,
|
|
742
|
+
devicesToRead.length
|
|
743
|
+
);
|
|
736
744
|
delete bacnetResults[deviceName];
|
|
737
|
-
|
|
738
745
|
}
|
|
739
746
|
}
|
|
740
747
|
}
|
|
@@ -751,18 +758,19 @@ class BacnetClient extends EventEmitter {
|
|
|
751
758
|
}
|
|
752
759
|
|
|
753
760
|
let deviceMetaInfo = {
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
761
|
+
address: device.getAddress(),
|
|
762
|
+
isMstp: device.getIsMstpDevice(),
|
|
763
|
+
deviceId: device.getDeviceId(),
|
|
764
|
+
vendorId: device.getVendorId(),
|
|
765
|
+
deviceName: deviceName,
|
|
759
766
|
};
|
|
760
767
|
|
|
761
768
|
// Process the results of the batch
|
|
762
|
-
results.value.values.forEach(pointResult => {
|
|
763
|
-
const cacheRef = requestArray.find(
|
|
764
|
-
ele
|
|
765
|
-
|
|
769
|
+
results.value.values.forEach((pointResult) => {
|
|
770
|
+
const cacheRef = requestArray.find(
|
|
771
|
+
(ele) =>
|
|
772
|
+
ele.pointRef.meta.objectId.type === pointResult.objectId.type &&
|
|
773
|
+
ele.pointRef.meta.objectId.instance === pointResult.objectId.instance
|
|
766
774
|
);
|
|
767
775
|
|
|
768
776
|
if (cacheRef) {
|
|
@@ -772,7 +780,11 @@ class BacnetClient extends EventEmitter {
|
|
|
772
780
|
|
|
773
781
|
if (isNumber(val)) {
|
|
774
782
|
pointRef.presentValue = roundDecimalPlaces(val, roundDecimal);
|
|
775
|
-
if (
|
|
783
|
+
if (
|
|
784
|
+
pointRef.meta.objectId.type == 19 ||
|
|
785
|
+
pointRef.meta.objectId.type == 13 ||
|
|
786
|
+
pointRef.meta.objectId.type == 14
|
|
787
|
+
) {
|
|
776
788
|
if (pointRef.stateTextArray && typeof pointRef.stateTextArray[0].value !== "object") {
|
|
777
789
|
if (val != 0) {
|
|
778
790
|
pointRef.presentValue = pointRef.stateTextArray[val - 1].value;
|
|
@@ -799,31 +811,31 @@ class BacnetClient extends EventEmitter {
|
|
|
799
811
|
that.logOut("Error processing batch:", err);
|
|
800
812
|
|
|
801
813
|
let deviceMetaInfo = {
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
814
|
+
address: device.getAddress(),
|
|
815
|
+
isMstp: device.getIsMstpDevice(),
|
|
816
|
+
deviceId: device.getDeviceId(),
|
|
817
|
+
vendorId: device.getVendorId(),
|
|
818
|
+
deviceName: deviceName,
|
|
807
819
|
};
|
|
808
820
|
|
|
809
|
-
requestArray.forEach(request => {
|
|
821
|
+
requestArray.forEach((request) => {
|
|
810
822
|
let pointRef = request.pointRef;
|
|
811
823
|
pointRef.status = "offline";
|
|
824
|
+
pointRef.timestamp = Date.now();
|
|
812
825
|
pointRef.meta["device"] = deviceMetaInfo;
|
|
813
826
|
|
|
814
827
|
bacnetResults[deviceName][request.pointName] = pointRef;
|
|
815
828
|
});
|
|
816
|
-
|
|
817
829
|
}
|
|
818
830
|
}
|
|
819
831
|
|
|
820
832
|
async processIndividualPoints(device, requestArray, deviceName, bacnetResults, that, roundDecimal) {
|
|
821
833
|
let deviceMetaInfo = {
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
834
|
+
address: device.getAddress(),
|
|
835
|
+
isMstp: device.getIsMstpDevice(),
|
|
836
|
+
deviceId: device.getDeviceId(),
|
|
837
|
+
vendorId: device.getVendorId(),
|
|
838
|
+
deviceName: deviceName,
|
|
827
839
|
};
|
|
828
840
|
|
|
829
841
|
for (const request of requestArray) {
|
|
@@ -839,6 +851,8 @@ class BacnetClient extends EventEmitter {
|
|
|
839
851
|
}
|
|
840
852
|
|
|
841
853
|
pointRef.meta["device"] = deviceMetaInfo;
|
|
854
|
+
pointRef.timestamp = Date.now();
|
|
855
|
+
pointRef.status = "online";
|
|
842
856
|
|
|
843
857
|
// Store the point data in results
|
|
844
858
|
bacnetResults[deviceName][pointName] = pointRef;
|
|
@@ -846,7 +860,7 @@ class BacnetClient extends EventEmitter {
|
|
|
846
860
|
that.logOut(`Error updating point ${pointName}:`, err);
|
|
847
861
|
|
|
848
862
|
pointRef.meta["device"] = deviceMetaInfo;
|
|
849
|
-
|
|
863
|
+
pointRef.timestamp = Date.now();
|
|
850
864
|
pointRef.status = "offline";
|
|
851
865
|
bacnetResults[deviceName][pointName] = pointRef;
|
|
852
866
|
}
|
|
@@ -856,11 +870,14 @@ class BacnetClient extends EventEmitter {
|
|
|
856
870
|
updateManyPoints(device, points) {
|
|
857
871
|
let that = this;
|
|
858
872
|
return new Promise((resolve, reject) => {
|
|
859
|
-
that
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
873
|
+
that
|
|
874
|
+
._readObjectWithRequestArray(device.getAddress(), points, that.readPropertyMultipleOptions)
|
|
875
|
+
.then(function (results) {
|
|
876
|
+
resolve(results);
|
|
877
|
+
})
|
|
878
|
+
.catch(function (err) {
|
|
879
|
+
reject(err);
|
|
880
|
+
});
|
|
864
881
|
});
|
|
865
882
|
}
|
|
866
883
|
|
|
@@ -1128,8 +1145,9 @@ class BacnetClient extends EventEmitter {
|
|
|
1128
1145
|
|
|
1129
1146
|
return new Promise((resolve, reject) => {
|
|
1130
1147
|
// Try to read all properties at once
|
|
1131
|
-
that
|
|
1132
|
-
.
|
|
1148
|
+
that
|
|
1149
|
+
._readObject(deviceAddress, type, instance, [{ id: baEnum.PropertyIdentifier.ALL }], readOptions)
|
|
1150
|
+
.then((result) => {
|
|
1133
1151
|
if (result.value) {
|
|
1134
1152
|
// If the result has value, resolve the promise
|
|
1135
1153
|
resolve(result);
|
|
@@ -1145,30 +1163,33 @@ class BacnetClient extends EventEmitter {
|
|
|
1145
1163
|
|
|
1146
1164
|
// Function to read properties individually
|
|
1147
1165
|
const readPropertiesIndividually = () => {
|
|
1148
|
-
const promises = allProperties.map(
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1166
|
+
const promises = allProperties.map(
|
|
1167
|
+
(property, index) =>
|
|
1168
|
+
new Promise((propertyResolve) => {
|
|
1169
|
+
that.client.readProperty(
|
|
1170
|
+
deviceAddress,
|
|
1171
|
+
{ type: type, instance: instance },
|
|
1172
|
+
property.id,
|
|
1173
|
+
readOptions,
|
|
1174
|
+
(err, value) => {
|
|
1175
|
+
if (err) {
|
|
1176
|
+
propertyResolve(null);
|
|
1177
|
+
} else {
|
|
1178
|
+
propertyResolve({
|
|
1179
|
+
id: property.id,
|
|
1180
|
+
index: value.property.index,
|
|
1181
|
+
value: value.values,
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
);
|
|
1186
|
+
})
|
|
1187
|
+
);
|
|
1167
1188
|
|
|
1168
1189
|
Promise.all(promises)
|
|
1169
|
-
.then(resultArray => {
|
|
1190
|
+
.then((resultArray) => {
|
|
1170
1191
|
// Filter out null results
|
|
1171
|
-
const validResults = resultArray.filter(result => result !== null);
|
|
1192
|
+
const validResults = resultArray.filter((result) => result !== null);
|
|
1172
1193
|
|
|
1173
1194
|
resolve({
|
|
1174
1195
|
error: null,
|
|
@@ -1190,7 +1211,6 @@ class BacnetClient extends EventEmitter {
|
|
|
1190
1211
|
});
|
|
1191
1212
|
}
|
|
1192
1213
|
|
|
1193
|
-
|
|
1194
1214
|
_readObjectLite(device, deviceAddress, type, instance) {
|
|
1195
1215
|
const that = this;
|
|
1196
1216
|
const readOptions = {
|
|
@@ -1199,15 +1219,13 @@ class BacnetClient extends EventEmitter {
|
|
|
1199
1219
|
};
|
|
1200
1220
|
|
|
1201
1221
|
// Define all properties to be read
|
|
1202
|
-
const allProperties = [
|
|
1203
|
-
{ id: baEnum.PropertyIdentifier.PRESENT_VALUE },
|
|
1204
|
-
{ id: baEnum.PropertyIdentifier.OBJECT_NAME },
|
|
1205
|
-
];
|
|
1222
|
+
const allProperties = [{ id: baEnum.PropertyIdentifier.PRESENT_VALUE }, { id: baEnum.PropertyIdentifier.OBJECT_NAME }];
|
|
1206
1223
|
|
|
1207
1224
|
return new Promise((resolve, reject) => {
|
|
1208
1225
|
// Try to read all properties at once
|
|
1209
|
-
that
|
|
1210
|
-
.
|
|
1226
|
+
that
|
|
1227
|
+
._readObject(deviceAddress, type, instance, allProperties, readOptions)
|
|
1228
|
+
.then((result) => {
|
|
1211
1229
|
if (result.value) {
|
|
1212
1230
|
// If the result has value, resolve the promise
|
|
1213
1231
|
resolve(result);
|
|
@@ -1223,30 +1241,33 @@ class BacnetClient extends EventEmitter {
|
|
|
1223
1241
|
|
|
1224
1242
|
// Function to read properties individually
|
|
1225
1243
|
const readPropertiesIndividually = () => {
|
|
1226
|
-
const promises = allProperties.map(
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1244
|
+
const promises = allProperties.map(
|
|
1245
|
+
(property, index) =>
|
|
1246
|
+
new Promise((propertyResolve) => {
|
|
1247
|
+
that.client.readProperty(
|
|
1248
|
+
deviceAddress,
|
|
1249
|
+
{ type: type, instance: instance },
|
|
1250
|
+
property.id,
|
|
1251
|
+
readOptions,
|
|
1252
|
+
(err, value) => {
|
|
1253
|
+
if (err) {
|
|
1254
|
+
propertyResolve(null);
|
|
1255
|
+
} else {
|
|
1256
|
+
propertyResolve({
|
|
1257
|
+
id: property.id,
|
|
1258
|
+
index: value.property.index,
|
|
1259
|
+
value: value.values,
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
);
|
|
1264
|
+
})
|
|
1265
|
+
);
|
|
1245
1266
|
|
|
1246
1267
|
Promise.all(promises)
|
|
1247
|
-
.then(resultArray => {
|
|
1268
|
+
.then((resultArray) => {
|
|
1248
1269
|
// Filter out null results
|
|
1249
|
-
const validResults = resultArray.filter(result => result !== null);
|
|
1270
|
+
const validResults = resultArray.filter((result) => result !== null);
|
|
1250
1271
|
|
|
1251
1272
|
resolve({
|
|
1252
1273
|
error: null,
|
|
@@ -1496,7 +1517,7 @@ class BacnetClient extends EventEmitter {
|
|
|
1496
1517
|
}
|
|
1497
1518
|
|
|
1498
1519
|
addUniqueToArray(device, array) {
|
|
1499
|
-
const foundIndex = array.findIndex(ele => ele.getDeviceId() === device.getDeviceId());
|
|
1520
|
+
const foundIndex = array.findIndex((ele) => ele.getDeviceId() === device.getDeviceId());
|
|
1500
1521
|
if (foundIndex === -1) {
|
|
1501
1522
|
array.push(device);
|
|
1502
1523
|
}
|
|
@@ -1509,16 +1530,16 @@ class BacnetClient extends EventEmitter {
|
|
|
1509
1530
|
const device = that.deviceList[i];
|
|
1510
1531
|
if (!device.getIsMstpDevice()) {
|
|
1511
1532
|
//ip device
|
|
1512
|
-
const foundIndex = that.renderList.findIndex(ele => ele.deviceId == device.getDeviceId());
|
|
1533
|
+
const foundIndex = that.renderList.findIndex((ele) => ele.deviceId == device.getDeviceId());
|
|
1513
1534
|
if (foundIndex == -1) {
|
|
1514
1535
|
that.addUniqueToArray(device, missingDevices);
|
|
1515
1536
|
}
|
|
1516
1537
|
} else {
|
|
1517
1538
|
//mstp device
|
|
1518
|
-
const foundParentIndex = that.renderList.findIndex(ele => ele.deviceId == device.getParentDeviceId());
|
|
1539
|
+
const foundParentIndex = that.renderList.findIndex((ele) => ele.deviceId == device.getParentDeviceId());
|
|
1519
1540
|
if (foundParentIndex == -1) {
|
|
1520
1541
|
//parent not existent in tree
|
|
1521
|
-
const parentDeviceIndex = that.deviceList.findIndex(ele => ele.getDeviceId() === device.getParentDeviceId());
|
|
1542
|
+
const parentDeviceIndex = that.deviceList.findIndex((ele) => ele.getDeviceId() === device.getParentDeviceId());
|
|
1522
1543
|
if (parentDeviceIndex !== -1) {
|
|
1523
1544
|
that.addUniqueToArray(that.deviceList[parentDeviceIndex], missingDevices);
|
|
1524
1545
|
}
|
|
@@ -1526,9 +1547,9 @@ class BacnetClient extends EventEmitter {
|
|
|
1526
1547
|
} else {
|
|
1527
1548
|
const parentTreeDevice = that.renderList[foundParentIndex];
|
|
1528
1549
|
let mstpIndex = -1;
|
|
1529
|
-
parentTreeDevice.children.forEach(child => {
|
|
1550
|
+
parentTreeDevice.children.forEach((child) => {
|
|
1530
1551
|
if (child.label.includes("MSTP")) {
|
|
1531
|
-
const tempIndex = child.children.findIndex(ele => ele.deviceId == device.getDeviceId());
|
|
1552
|
+
const tempIndex = child.children.findIndex((ele) => ele.deviceId == device.getDeviceId());
|
|
1532
1553
|
if (tempIndex !== -1) {
|
|
1533
1554
|
mstpIndex = tempIndex;
|
|
1534
1555
|
}
|
|
@@ -1548,7 +1569,13 @@ class BacnetClient extends EventEmitter {
|
|
|
1548
1569
|
async doTreeBuilder() {
|
|
1549
1570
|
let that = this;
|
|
1550
1571
|
|
|
1551
|
-
const treeWorker = new treeBuilder(
|
|
1572
|
+
const treeWorker = new treeBuilder(
|
|
1573
|
+
that.deviceList,
|
|
1574
|
+
that.networkTree,
|
|
1575
|
+
that.renderList,
|
|
1576
|
+
that.renderListCount,
|
|
1577
|
+
that.initialTreeBuild
|
|
1578
|
+
);
|
|
1552
1579
|
|
|
1553
1580
|
treeWorker.cacheData();
|
|
1554
1581
|
|
|
@@ -1645,9 +1672,6 @@ class BacnetClient extends EventEmitter {
|
|
|
1645
1672
|
});
|
|
1646
1673
|
}
|
|
1647
1674
|
});
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
1675
|
} else {
|
|
1652
1676
|
that
|
|
1653
1677
|
._readObjectFull(device, address, point.value.type, point.value.instance)
|
|
@@ -1727,7 +1751,7 @@ class BacnetClient extends EventEmitter {
|
|
|
1727
1751
|
|
|
1728
1752
|
let objectId;
|
|
1729
1753
|
if (objectName !== null && typeof objectName == "string") {
|
|
1730
|
-
objectName = objectName.replace(reg,
|
|
1754
|
+
objectName = objectName.replace(reg, "");
|
|
1731
1755
|
objectId = objectName + "_" + bac_obj + "_" + pointProperty.objectId.instance;
|
|
1732
1756
|
|
|
1733
1757
|
try {
|
|
@@ -1758,7 +1782,8 @@ class BacnetClient extends EventEmitter {
|
|
|
1758
1782
|
if (object.value[0].value == 0) {
|
|
1759
1783
|
values[objectId].presentValue = values[objectId].stateTextArray[object.value[0].value].value;
|
|
1760
1784
|
} else if (object.value[0].value !== 0) {
|
|
1761
|
-
values[objectId].presentValue =
|
|
1785
|
+
values[objectId].presentValue =
|
|
1786
|
+
values[objectId].stateTextArray[object.value[0].value - 1].value;
|
|
1762
1787
|
}
|
|
1763
1788
|
}
|
|
1764
1789
|
} else if (objectType !== 8) {
|
|
@@ -1776,9 +1801,9 @@ class BacnetClient extends EventEmitter {
|
|
|
1776
1801
|
break;
|
|
1777
1802
|
case baEnum.PropertyIdentifier.OBJECT_NAME:
|
|
1778
1803
|
if (object.value[0] && object.value[0].value) {
|
|
1779
|
-
values[objectId].objectName = object.value[0].value.replace(reg,
|
|
1804
|
+
values[objectId].objectName = object.value[0].value.replace(reg, "");
|
|
1780
1805
|
if (!values[objectId].displayName) {
|
|
1781
|
-
values[objectId].displayName = object.value[0].value.replace(reg,
|
|
1806
|
+
values[objectId].displayName = object.value[0].value.replace(reg, "");
|
|
1782
1807
|
}
|
|
1783
1808
|
}
|
|
1784
1809
|
break;
|
|
@@ -1816,9 +1841,11 @@ class BacnetClient extends EventEmitter {
|
|
|
1816
1841
|
case baEnum.PropertyIdentifier.STATE_TEXT:
|
|
1817
1842
|
if (object.value) {
|
|
1818
1843
|
values[objectId].stateTextArray = object.value;
|
|
1819
|
-
if (
|
|
1844
|
+
if (
|
|
1845
|
+
typeof values[objectId].presentValue == "number" &&
|
|
1820
1846
|
values[objectId].presentValue !== null &&
|
|
1821
|
-
values[objectId].presentValue !== undefined
|
|
1847
|
+
values[objectId].presentValue !== undefined
|
|
1848
|
+
) {
|
|
1822
1849
|
const tempIndex = values[objectId].presentValue;
|
|
1823
1850
|
if (tempIndex == 0) {
|
|
1824
1851
|
values[objectId].presentValue = values[objectId].stateTextArray[tempIndex].value;
|