@bitpoolos/edge-bacnet 1.1.6 → 1.1.7
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 +1 -1
- package/bacnet_gateway.js +4 -4
- package/bacnet_server.js +21 -42
- package/package.json +1 -1
package/bacnet_client.js
CHANGED
package/bacnet_gateway.js
CHANGED
|
@@ -97,7 +97,7 @@ module.exports = function (RED) {
|
|
|
97
97
|
|
|
98
98
|
if(node.bacnetServerEnabled == true && node.bacnetClient) {
|
|
99
99
|
if(node.bacnetServer == null) {
|
|
100
|
-
node.bacnetServer = new BacnetServer(node.bacnetClient, node.deviceId,
|
|
100
|
+
node.bacnetServer = new BacnetServer(node.bacnetClient, node.deviceId, RED.version());
|
|
101
101
|
nodeContext.set("bacnetServer", node.bacnetServer);
|
|
102
102
|
}
|
|
103
103
|
} else if(node.bacnetServerEnabled == false) {
|
|
@@ -151,7 +151,7 @@ module.exports = function (RED) {
|
|
|
151
151
|
|
|
152
152
|
} else {
|
|
153
153
|
// No client information found
|
|
154
|
-
node.status({fill:"red",shape:"dot",text:"Please define client"})
|
|
154
|
+
//node.status({fill:"red",shape:"dot",text:"Please define client"})
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
if(node.nodeName !== "gateway" &&
|
|
@@ -201,7 +201,7 @@ module.exports = function (RED) {
|
|
|
201
201
|
if(!node.bacnetClient) {
|
|
202
202
|
logOut("Issue with the bacnetClient: ", node.bacnetClient);
|
|
203
203
|
//no bacnet client present
|
|
204
|
-
node.status({fill:"red",shape:"dot",text:"Please define client"});
|
|
204
|
+
//node.status({fill:"red",shape:"dot",text:"Please define client"});
|
|
205
205
|
res.send(false);
|
|
206
206
|
} else {
|
|
207
207
|
node.bacnetClient.getNetworkTreeData().then(function(result) {
|
|
@@ -218,7 +218,7 @@ module.exports = function (RED) {
|
|
|
218
218
|
if(!node.bacnetClient) {
|
|
219
219
|
logOut("Issue with the bacnetClient: ", node.bacnetClient);
|
|
220
220
|
//no bacnet client present
|
|
221
|
-
node.status({fill:"red",shape:"dot",text:"Please define client"});
|
|
221
|
+
//node.status({fill:"red",shape:"dot",text:"Please define client"});
|
|
222
222
|
res.send(false);
|
|
223
223
|
} else {
|
|
224
224
|
node.bacnetClient.rebuildDataModel().then(function(result) {
|
package/bacnet_server.js
CHANGED
|
@@ -4,7 +4,7 @@ const {Store_Config_Server, Read_Config_Sync_Server } = require('./common');
|
|
|
4
4
|
|
|
5
5
|
class BacnetServer {
|
|
6
6
|
|
|
7
|
-
constructor(client, deviceId,
|
|
7
|
+
constructor(client, deviceId, nodeRedVersion) {
|
|
8
8
|
let that = this;
|
|
9
9
|
that.bacnetClient = client;
|
|
10
10
|
that.objectIdNumber = 1;
|
|
@@ -33,15 +33,17 @@ class BacnetServer {
|
|
|
33
33
|
try {
|
|
34
34
|
let cachedData = JSON.parse(Read_Config_Sync_Server());
|
|
35
35
|
if(typeof cachedData == "object") {
|
|
36
|
+
|
|
36
37
|
if(cachedData.objectList) that.objectList = cachedData.objectList;
|
|
37
|
-
if(cachedData.objectStore)
|
|
38
|
+
if(cachedData.objectStore) {
|
|
39
|
+
that.objectStore[baEnum.ObjectType.ANALOG_VALUE] = cachedData.objectStore[baEnum.ObjectType.ANALOG_VALUE];
|
|
40
|
+
that.objectStore[baEnum.ObjectType.CHARACTERSTRING_VALUE] = cachedData.objectStore[baEnum.ObjectType.CHARACTERSTRING_VALUE];
|
|
41
|
+
}
|
|
38
42
|
}
|
|
39
43
|
} catch (error) {
|
|
40
44
|
//do nothing
|
|
41
45
|
}
|
|
42
46
|
|
|
43
|
-
|
|
44
|
-
|
|
45
47
|
that.bacnetClient.client.on('whoIs', (device) => {
|
|
46
48
|
that.bacnetClient.client.iAmResponse(that.bacnetClient.broadCastAddr, that.deviceId, baEnum.Segmentation.SEGMENTED_BOTH, 27823);
|
|
47
49
|
});
|
|
@@ -68,6 +70,7 @@ class BacnetServer {
|
|
|
68
70
|
|
|
69
71
|
if(i == requestProps.length - 1) {
|
|
70
72
|
if(responseObject.length > 0) {
|
|
73
|
+
|
|
71
74
|
that.bacnetClient.client.readPropertyMultipleResponse(senderAddress, data.invokeId, responseObject);
|
|
72
75
|
} else {
|
|
73
76
|
that.bacnetClient.client.errorResponse(
|
|
@@ -134,7 +137,8 @@ class BacnetServer {
|
|
|
134
137
|
let that = this;
|
|
135
138
|
let objectType = that.getBacnetObjectType(value);
|
|
136
139
|
if(name && objectType) {
|
|
137
|
-
let formattedName = name.replaceAll('.', '');
|
|
140
|
+
let formattedName = name.replaceAll('.', '_');
|
|
141
|
+
formattedName = formattedName.replaceAll('/', '_');
|
|
138
142
|
if(objectType == "number") {
|
|
139
143
|
let foundIndex = that.objectStore[baEnum.ObjectType.ANALOG_VALUE].findIndex(ele => ele[baEnum.PropertyIdentifier.OBJECT_NAME][0].value == formattedName);
|
|
140
144
|
if(foundIndex == -1) {
|
|
@@ -145,15 +149,10 @@ class BacnetServer {
|
|
|
145
149
|
[baEnum.PropertyIdentifier.DESCRIPTION]: [{value: '', type: 7}],
|
|
146
150
|
[baEnum.PropertyIdentifier.OBJECT_IDENTIFIER]: [{value: {type: baEnum.ObjectType.ANALOG_VALUE, instance: objectId}, type: 12}],
|
|
147
151
|
[baEnum.PropertyIdentifier.PRESENT_VALUE]: [{value: value, type: 4}],
|
|
148
|
-
[baEnum.PropertyIdentifier.
|
|
149
|
-
[
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
{value: baEnum.PropertyIdentifier.DESCRIPTION, type: 9 },
|
|
153
|
-
{value: baEnum.PropertyIdentifier.OBJECT_IDENTIFIER, type: 9 },
|
|
154
|
-
{value: baEnum.PropertyIdentifier.PROPERTY_LIST, type: 9 },
|
|
155
|
-
{value: baEnum.PropertyIdentifier.PRESENT_VALUE, type: 9 }
|
|
156
|
-
],
|
|
152
|
+
[baEnum.PropertyIdentifier.STATUS_FLAGS]: [{value: 0, type: 8}],
|
|
153
|
+
[baEnum.PropertyIdentifier.EVENT_STATE]: [{value: 0, type: 9}],
|
|
154
|
+
[baEnum.PropertyIdentifier.OUT_OF_SERVICE]: [{value: 0, type: 9}],
|
|
155
|
+
[baEnum.PropertyIdentifier.UNITS]: [{value: 95, type: 9}]
|
|
157
156
|
});
|
|
158
157
|
|
|
159
158
|
that.objectList.push({value: {type: baEnum.ObjectType.ANALOG_VALUE, instance: objectId}, type: 12})
|
|
@@ -173,15 +172,10 @@ class BacnetServer {
|
|
|
173
172
|
[baEnum.PropertyIdentifier.DESCRIPTION]: [{value: '', type: 7}],
|
|
174
173
|
[baEnum.PropertyIdentifier.OBJECT_IDENTIFIER]: [{value: {type: baEnum.ObjectType.CHARACTERSTRING_VALUE, instance: objectId}, type: 12}],
|
|
175
174
|
[baEnum.PropertyIdentifier.PRESENT_VALUE]: [{value: value, type: 7}],
|
|
176
|
-
[baEnum.PropertyIdentifier.
|
|
177
|
-
[
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
{value: baEnum.PropertyIdentifier.DESCRIPTION, type: 9 },
|
|
181
|
-
{value: baEnum.PropertyIdentifier.OBJECT_IDENTIFIER, type: 9 },
|
|
182
|
-
{value: baEnum.PropertyIdentifier.PROPERTY_LIST, type: 9 },
|
|
183
|
-
{value: baEnum.PropertyIdentifier.PRESENT_VALUE, type: 9 }
|
|
184
|
-
],
|
|
175
|
+
[baEnum.PropertyIdentifier.STATUS_FLAGS]: [{value: 0, type: 8}],
|
|
176
|
+
[baEnum.PropertyIdentifier.EVENT_STATE]: [{value: 0, type: 9}],
|
|
177
|
+
[baEnum.PropertyIdentifier.OUT_OF_SERVICE]: [{value: 0, type: 9}],
|
|
178
|
+
[baEnum.PropertyIdentifier.UNITS]: [{value: 95, type: 9}]
|
|
185
179
|
});
|
|
186
180
|
|
|
187
181
|
that.objectList.push({value: {type: baEnum.ObjectType.CHARACTERSTRING_VALUE, instance: objectId}, type: 12})
|
|
@@ -285,28 +279,13 @@ class BacnetServer {
|
|
|
285
279
|
|
|
286
280
|
clearServerPoints() {
|
|
287
281
|
let that = this;
|
|
288
|
-
|
|
289
|
-
let currentDeviceName = that.objectStore[baEnum.ObjectType.DEVICE][baEnum.PropertyIdentifier.OBJECT_NAME][0].value;
|
|
290
|
-
|
|
282
|
+
|
|
291
283
|
that.objectList = [
|
|
292
284
|
{value: {type: baEnum.ObjectType.DEVICE, instance: that.deviceId}, type: 12}
|
|
293
285
|
];
|
|
294
|
-
that.objectStore =
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
[baEnum.PropertyIdentifier.OBJECT_LIST]: that.objectList, // OBJECT_IDENTIFIER
|
|
298
|
-
[baEnum.PropertyIdentifier.OBJECT_NAME]: [{value: currentDeviceName, type: 7}], // OBJECT_NAME
|
|
299
|
-
[baEnum.PropertyIdentifier.OBJECT_TYPE]: [{value: 8, type: 9}], // OBJECT_TYPE
|
|
300
|
-
[baEnum.PropertyIdentifier.DESCRIPTION]: [{value: 'Bitpool Edge BACnet gateway', type: 7}], // DESCRIPTION
|
|
301
|
-
[baEnum.PropertyIdentifier.SYSTEM_STATUS]: [{value: 0, type: 9}], // SYSTEM_STATUS
|
|
302
|
-
[baEnum.PropertyIdentifier.VENDOR_NAME]: [{value: "Bitpool", type: 7}], //VENDOR_NAME
|
|
303
|
-
[baEnum.PropertyIdentifier.VENDOR_IDENTIFIER]: [{value: 1401, type: 7}], //VENDOR_IDENTIFIER
|
|
304
|
-
[baEnum.PropertyIdentifier.MODEL_NAME]: [{value: "bitpool-edge", type: 7}], //MODEL_NAME
|
|
305
|
-
[baEnum.PropertyIdentifier.FIRMWARE_REVISION]: [{value: "Node-Red " + that.nodeRedVersion, type: 7}], //FIRMWARE_REVISION
|
|
306
|
-
},
|
|
307
|
-
[baEnum.ObjectType.ANALOG_VALUE]: [],
|
|
308
|
-
[baEnum.ObjectType.CHARACTERSTRING_VALUE]: []
|
|
309
|
-
};
|
|
286
|
+
that.objectStore[baEnum.ObjectType.DEVICE][baEnum.PropertyIdentifier.OBJECT_LIST] = that.objectList;
|
|
287
|
+
that.objectStore[baEnum.ObjectType.CHARACTERSTRING_VALUE] = [];
|
|
288
|
+
that.objectStore[baEnum.ObjectType.ANALOG_VALUE] = [];
|
|
310
289
|
|
|
311
290
|
that.objectIdNumber = 1;
|
|
312
291
|
|