@bitpoolos/edge-bacnet 1.1.5 → 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.html +79 -33
- package/bacnet_gateway.js +25 -5
- package/bacnet_server.js +47 -45
- package/common.js +31 -1
- package/examples/1-Discover-Read.json +1 -1
- package/examples/2-Discover-Write.json +1 -1
- package/examples/3-Discover-Read-Write.json +1 -1
- package/package.json +1 -1
- package/edge-bacnet-datastore.cfg +0 -0
package/bacnet_client.js
CHANGED
package/bacnet_gateway.html
CHANGED
|
@@ -81,6 +81,9 @@
|
|
|
81
81
|
rebuildDataModel() {
|
|
82
82
|
return fetch('/bitpool-bacnet-data/rebuildDataModel').then(res => res.json());
|
|
83
83
|
};
|
|
84
|
+
clearBacnetServerPoints() {
|
|
85
|
+
return fetch('/bitpool-bacnet-data/clearBacnetServerPoints').then(res => res.json());
|
|
86
|
+
};
|
|
84
87
|
};
|
|
85
88
|
RED.nodes.registerType('Bacnet-Gateway', {
|
|
86
89
|
category: 'Bitpool BACnet',
|
|
@@ -186,18 +189,6 @@
|
|
|
186
189
|
|
|
187
190
|
queryAdapters();
|
|
188
191
|
|
|
189
|
-
// function setBroadCastAddress() {
|
|
190
|
-
// let nicSelector = document.getElementById("node-input-local_device_address");
|
|
191
|
-
// nicSelector.onchange = function(e) {
|
|
192
|
-
// if(typeof e.target.value == "string" && e.target.value !== ""){
|
|
193
|
-
// let broadcastAddrPrefill = e.target.value.split(".").slice(0, 3).join(".") + ".255";
|
|
194
|
-
// document.getElementById("node-input-broadCastAddr").value = broadcastAddrPrefill;
|
|
195
|
-
// }
|
|
196
|
-
// };
|
|
197
|
-
// }
|
|
198
|
-
|
|
199
|
-
// setBroadCastAddress();
|
|
200
|
-
|
|
201
192
|
function setDeviceIdRangeState(state) {
|
|
202
193
|
let deviceIdRangeStart = $("#node-input-device_id_range_start");
|
|
203
194
|
let deviceIdRangeEnd = $("#node-input-device_id_range_end");
|
|
@@ -234,6 +225,52 @@
|
|
|
234
225
|
setManualInstanceRangeState(this.checked);
|
|
235
226
|
});
|
|
236
227
|
|
|
228
|
+
if(node.vm == undefined) {
|
|
229
|
+
const confirmDialog = document.createElement('p-confirm-dialog');
|
|
230
|
+
document.getElementById("clearServerContainer").appendChild(confirmDialog);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const {createApp, ref, onMounted} = Vue;
|
|
234
|
+
const ConfirmDialog = primevue.confirmdialog;
|
|
235
|
+
const ConfirmationService = primevue.confirmationservice;
|
|
236
|
+
|
|
237
|
+
//prime vue app
|
|
238
|
+
const App = {
|
|
239
|
+
data() {
|
|
240
|
+
return {
|
|
241
|
+
nodeService: ref(new NodeService())
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
methods: {
|
|
245
|
+
confirm(event) {
|
|
246
|
+
this.$confirm.require({
|
|
247
|
+
message: 'Do you want to clear all the BACnet server points? This action is not reversible',
|
|
248
|
+
header: 'Delete Confirmation',
|
|
249
|
+
icon: 'pi pi-info-circle',
|
|
250
|
+
acceptClass: 'p-button-danger',
|
|
251
|
+
accept: () => {
|
|
252
|
+
//handle accept
|
|
253
|
+
this.nodeService.clearBacnetServerPoints();
|
|
254
|
+
},
|
|
255
|
+
reject: () => {
|
|
256
|
+
//handle reject
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
components: {
|
|
262
|
+
"p-button": primevue.button,
|
|
263
|
+
"p-confirm-dialog": primevue.confirmdialog
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
let vueapp = createApp(App);
|
|
268
|
+
vueapp.use(primevue.config.default);
|
|
269
|
+
vueapp.use(primevue.confirmpopup);
|
|
270
|
+
vueapp.use(primevue.confirmationservice);
|
|
271
|
+
node.vm = vueapp.mount("#clearServerContainer");
|
|
272
|
+
|
|
273
|
+
|
|
237
274
|
},
|
|
238
275
|
oneditsave: function (test) {
|
|
239
276
|
let node = this;
|
|
@@ -283,26 +320,39 @@
|
|
|
283
320
|
align-items: center;
|
|
284
321
|
padding-top: 20px;
|
|
285
322
|
}
|
|
286
|
-
|
|
287
323
|
.point {
|
|
288
324
|
padding-left: 50px
|
|
289
325
|
}
|
|
290
|
-
|
|
291
326
|
.pointButton {
|
|
292
327
|
color: inherit;
|
|
293
328
|
border: none;
|
|
294
329
|
display: flex;
|
|
295
330
|
align-items: center;
|
|
296
331
|
}
|
|
297
|
-
|
|
298
332
|
.networkTreeContent {
|
|
299
333
|
margin-top: 20px;
|
|
300
334
|
margin-left: 50px;
|
|
301
335
|
}
|
|
302
|
-
|
|
336
|
+
.p-confirm-dialog-accept > .p-button-label, .bacnetServerRebuildSchedule_clearButton > .p-button-label {
|
|
337
|
+
color: white;
|
|
338
|
+
}
|
|
303
339
|
.red-ui-editor label {
|
|
304
340
|
font-size: 12px;
|
|
305
341
|
}
|
|
342
|
+
.bacnetServerRebuildSchedule_clearButton {
|
|
343
|
+
box-shadow: 0 0 0 0.2rem #edacac !important;
|
|
344
|
+
width: 200px;
|
|
345
|
+
border-radius: 3px;
|
|
346
|
+
margin-left: 140px !important;
|
|
347
|
+
}
|
|
348
|
+
.clear_server_span {
|
|
349
|
+
width: 0px;
|
|
350
|
+
}
|
|
351
|
+
.read_server_parent_div {
|
|
352
|
+
display: flex;
|
|
353
|
+
align-items: center;
|
|
354
|
+
justify-content: space-around;
|
|
355
|
+
}
|
|
306
356
|
|
|
307
357
|
</style>
|
|
308
358
|
|
|
@@ -419,25 +469,21 @@
|
|
|
419
469
|
|
|
420
470
|
</div>
|
|
421
471
|
<div id='read-server-tab' style='display:none'>
|
|
422
|
-
<div class="
|
|
423
|
-
<
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
472
|
+
<div class="read_server_parent_div">
|
|
473
|
+
<div class="form-row">
|
|
474
|
+
<label for="node-input-serverEnabled">
|
|
475
|
+
Enabled:
|
|
476
|
+
</label>
|
|
477
|
+
<input type="checkbox" id="node-input-serverEnabled" style="width: auto;"/>
|
|
478
|
+
</div>
|
|
479
|
+
|
|
480
|
+
<div class="form-row" id="clearServerContainer" style="align-items: center; display: flex;">
|
|
481
|
+
<label for="node-input-bacnetServerRebuildSchedule_value" class="clear_server_span"><i class="icon-tag"></i> <span data-i18n="bitpool-bacnet.label.bacnetServerRebuildSchedule"></span> </label>
|
|
482
|
+
<p-button class="bacnetServerRebuildSchedule_clearButton p-button-danger" @click="confirm($event)" label="Reinitialize Server" ></p-button>
|
|
483
|
+
|
|
484
|
+
</div>
|
|
427
485
|
</div>
|
|
428
486
|
|
|
429
|
-
<div class="form-row" style="align-items: center; display: flex;">
|
|
430
|
-
<label for="node-input-bacnetServerRebuildSchedule_value"><i class="icon-tag"></i> <span data-i18n="bitpool-bacnet.label.bacnetServerRebuildSchedule"></span>Clear Server Points:</label>
|
|
431
|
-
<p style="margin-right: 5px; margin-bottom: 0px; padding-left: 7px;">Every</p>
|
|
432
|
-
<input type="text" id="node-input-bacnetServerRebuildSchedule" style="display: none;">
|
|
433
|
-
<input type="text" id="node-input-bacnetServerRebuildSchedule_value" placeholder="5" style="width: 70px; margin-right: 5px;">
|
|
434
|
-
<select name="timePeriod" id="node-input-bacnetServerRebuildSchedule_options" style="width: 120px; margin-right: 5px;">
|
|
435
|
-
<option value="Seconds">Seconds</option>
|
|
436
|
-
<option value="Minutes">Minutes</option>
|
|
437
|
-
<option value="Hours">Hours</option>
|
|
438
|
-
<option value="Days">Days</option>
|
|
439
|
-
</select>
|
|
440
|
-
</div>
|
|
441
487
|
</div>
|
|
442
488
|
|
|
443
489
|
</script>
|
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,12 +151,22 @@ 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
|
+
}
|
|
156
|
+
|
|
157
|
+
if(node.nodeName !== "gateway" &&
|
|
158
|
+
node.nodeName !== "" &&
|
|
159
|
+
node.nodeName !== "null" &&
|
|
160
|
+
node.nodeName !== "undefined" &&
|
|
161
|
+
typeof node.nodeName == "string") {
|
|
162
|
+
if(node.bacnetServerEnabled == true && node.bacnetClient) {
|
|
163
|
+
node.bacnetServer.setDeviceName(node.nodeName);
|
|
164
|
+
}
|
|
155
165
|
}
|
|
156
166
|
|
|
157
167
|
node.on('input', function(msg) {
|
|
158
168
|
|
|
159
|
-
if(msg.topic && msg.payload) {
|
|
169
|
+
if(msg.topic && msg.payload !== null) {
|
|
160
170
|
if(node.bacnetServer) {
|
|
161
171
|
node.bacnetServer.addObject(msg.topic, msg.payload);
|
|
162
172
|
}
|
|
@@ -191,7 +201,7 @@ module.exports = function (RED) {
|
|
|
191
201
|
if(!node.bacnetClient) {
|
|
192
202
|
logOut("Issue with the bacnetClient: ", node.bacnetClient);
|
|
193
203
|
//no bacnet client present
|
|
194
|
-
node.status({fill:"red",shape:"dot",text:"Please define client"});
|
|
204
|
+
//node.status({fill:"red",shape:"dot",text:"Please define client"});
|
|
195
205
|
res.send(false);
|
|
196
206
|
} else {
|
|
197
207
|
node.bacnetClient.getNetworkTreeData().then(function(result) {
|
|
@@ -208,7 +218,7 @@ module.exports = function (RED) {
|
|
|
208
218
|
if(!node.bacnetClient) {
|
|
209
219
|
logOut("Issue with the bacnetClient: ", node.bacnetClient);
|
|
210
220
|
//no bacnet client present
|
|
211
|
-
node.status({fill:"red",shape:"dot",text:"Please define client"});
|
|
221
|
+
//node.status({fill:"red",shape:"dot",text:"Please define client"});
|
|
212
222
|
res.send(false);
|
|
213
223
|
} else {
|
|
214
224
|
node.bacnetClient.rebuildDataModel().then(function(result) {
|
|
@@ -220,6 +230,16 @@ module.exports = function (RED) {
|
|
|
220
230
|
}
|
|
221
231
|
});
|
|
222
232
|
|
|
233
|
+
//route handler for the clear Bacnet server points function
|
|
234
|
+
RED.httpAdmin.get('/bitpool-bacnet-data/clearBacnetServerPoints', function(req, res) {
|
|
235
|
+
if(node.bacnetServerEnabled == true && node.bacnetClient) {
|
|
236
|
+
node.bacnetServer.clearServerPoints();
|
|
237
|
+
res.send(true);
|
|
238
|
+
} else {
|
|
239
|
+
res.send(false);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
|
|
223
243
|
//route handler for network data
|
|
224
244
|
RED.httpAdmin.get('/bitpool-bacnet-data/getNetworkInterfaces', function(req, res) {
|
|
225
245
|
getIpAddress().then(function(result) {
|
package/bacnet_server.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
const bacnet = require('./resources/node-bacnet/index.js');
|
|
2
2
|
const baEnum = bacnet.enum;
|
|
3
|
-
const {
|
|
3
|
+
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
|
-
that.rebuildScheduleSeconds = rebuildSchedule;
|
|
11
|
-
that.scheduler = new ToadScheduler();
|
|
12
10
|
that.objectIdNumber = 1;
|
|
13
11
|
that.nodeRedVersion = nodeRedVersion;
|
|
14
12
|
that.deviceId = deviceId;
|
|
@@ -32,6 +30,20 @@ class BacnetServer {
|
|
|
32
30
|
[baEnum.ObjectType.CHARACTERSTRING_VALUE]: []
|
|
33
31
|
};
|
|
34
32
|
|
|
33
|
+
try {
|
|
34
|
+
let cachedData = JSON.parse(Read_Config_Sync_Server());
|
|
35
|
+
if(typeof cachedData == "object") {
|
|
36
|
+
|
|
37
|
+
if(cachedData.objectList) that.objectList = cachedData.objectList;
|
|
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
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} catch (error) {
|
|
44
|
+
//do nothing
|
|
45
|
+
}
|
|
46
|
+
|
|
35
47
|
that.bacnetClient.client.on('whoIs', (device) => {
|
|
36
48
|
that.bacnetClient.client.iAmResponse(that.bacnetClient.broadCastAddr, that.deviceId, baEnum.Segmentation.SEGMENTED_BOTH, 27823);
|
|
37
49
|
});
|
|
@@ -58,6 +70,7 @@ class BacnetServer {
|
|
|
58
70
|
|
|
59
71
|
if(i == requestProps.length - 1) {
|
|
60
72
|
if(responseObject.length > 0) {
|
|
73
|
+
|
|
61
74
|
that.bacnetClient.client.readPropertyMultipleResponse(senderAddress, data.invokeId, responseObject);
|
|
62
75
|
} else {
|
|
63
76
|
that.bacnetClient.client.errorResponse(
|
|
@@ -111,28 +124,21 @@ class BacnetServer {
|
|
|
111
124
|
|
|
112
125
|
//do initial iAm broadcast when BACnet server starts
|
|
113
126
|
that.bacnetClient.client.iAmResponse(that.bacnetClient.broadCastAddr, that.deviceId, baEnum.Segmentation.SEGMENTED_BOTH, 27823);
|
|
127
|
+
}
|
|
114
128
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
const job = new SimpleIntervalJob({ seconds: parseInt(that.rebuildScheduleSeconds), }, task)
|
|
122
|
-
|
|
123
|
-
that.scheduler.addSimpleIntervalJob(job)
|
|
124
|
-
|
|
125
|
-
} catch (error) {
|
|
126
|
-
|
|
129
|
+
setDeviceName(nodeName) {
|
|
130
|
+
let that = this;
|
|
131
|
+
if(typeof nodeName == "string" && nodeName !== "") {
|
|
132
|
+
that.objectStore[baEnum.ObjectType.DEVICE][baEnum.PropertyIdentifier.OBJECT_NAME][0].value = nodeName;
|
|
127
133
|
}
|
|
128
134
|
}
|
|
129
135
|
|
|
130
136
|
addObject(name, value) {
|
|
131
137
|
let that = this;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
let
|
|
135
|
-
|
|
138
|
+
let objectType = that.getBacnetObjectType(value);
|
|
139
|
+
if(name && objectType) {
|
|
140
|
+
let formattedName = name.replaceAll('.', '_');
|
|
141
|
+
formattedName = formattedName.replaceAll('/', '_');
|
|
136
142
|
if(objectType == "number") {
|
|
137
143
|
let foundIndex = that.objectStore[baEnum.ObjectType.ANALOG_VALUE].findIndex(ele => ele[baEnum.PropertyIdentifier.OBJECT_NAME][0].value == formattedName);
|
|
138
144
|
if(foundIndex == -1) {
|
|
@@ -143,22 +149,18 @@ class BacnetServer {
|
|
|
143
149
|
[baEnum.PropertyIdentifier.DESCRIPTION]: [{value: '', type: 7}],
|
|
144
150
|
[baEnum.PropertyIdentifier.OBJECT_IDENTIFIER]: [{value: {type: baEnum.ObjectType.ANALOG_VALUE, instance: objectId}, type: 12}],
|
|
145
151
|
[baEnum.PropertyIdentifier.PRESENT_VALUE]: [{value: value, type: 4}],
|
|
146
|
-
[baEnum.PropertyIdentifier.
|
|
147
|
-
[
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
{value: baEnum.PropertyIdentifier.DESCRIPTION, type: 9 },
|
|
151
|
-
{value: baEnum.PropertyIdentifier.OBJECT_IDENTIFIER, type: 9 },
|
|
152
|
-
{value: baEnum.PropertyIdentifier.PROPERTY_LIST, type: 9 },
|
|
153
|
-
{value: baEnum.PropertyIdentifier.PRESENT_VALUE, type: 9 }
|
|
154
|
-
],
|
|
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}]
|
|
155
156
|
});
|
|
156
157
|
|
|
157
158
|
that.objectList.push({value: {type: baEnum.ObjectType.ANALOG_VALUE, instance: objectId}, type: 12})
|
|
159
|
+
that.objectStore[baEnum.ObjectType.DEVICE][baEnum.PropertyIdentifier.OBJECT_LIST] = that.objectList;
|
|
158
160
|
} else if(foundIndex !== -1) {
|
|
159
|
-
|
|
160
161
|
let foundObject = that.objectStore[baEnum.ObjectType.ANALOG_VALUE][foundIndex];
|
|
161
162
|
foundObject[baEnum.PropertyIdentifier.PRESENT_VALUE][0].value = value;
|
|
163
|
+
that.objectStore[baEnum.ObjectType.DEVICE][baEnum.PropertyIdentifier.OBJECT_LIST] = that.objectList;
|
|
162
164
|
}
|
|
163
165
|
} else if(objectType == "string") {
|
|
164
166
|
let foundIndex = that.objectStore[baEnum.ObjectType.CHARACTERSTRING_VALUE].findIndex(ele => ele[baEnum.PropertyIdentifier.OBJECT_NAME][0].value == formattedName);
|
|
@@ -170,24 +172,22 @@ class BacnetServer {
|
|
|
170
172
|
[baEnum.PropertyIdentifier.DESCRIPTION]: [{value: '', type: 7}],
|
|
171
173
|
[baEnum.PropertyIdentifier.OBJECT_IDENTIFIER]: [{value: {type: baEnum.ObjectType.CHARACTERSTRING_VALUE, instance: objectId}, type: 12}],
|
|
172
174
|
[baEnum.PropertyIdentifier.PRESENT_VALUE]: [{value: value, type: 7}],
|
|
173
|
-
[baEnum.PropertyIdentifier.
|
|
174
|
-
[
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
{value: baEnum.PropertyIdentifier.DESCRIPTION, type: 9 },
|
|
178
|
-
{value: baEnum.PropertyIdentifier.OBJECT_IDENTIFIER, type: 9 },
|
|
179
|
-
{value: baEnum.PropertyIdentifier.PROPERTY_LIST, type: 9 },
|
|
180
|
-
{value: baEnum.PropertyIdentifier.PRESENT_VALUE, type: 9 }
|
|
181
|
-
],
|
|
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}]
|
|
182
179
|
});
|
|
183
180
|
|
|
184
181
|
that.objectList.push({value: {type: baEnum.ObjectType.CHARACTERSTRING_VALUE, instance: objectId}, type: 12})
|
|
182
|
+
that.objectStore[baEnum.ObjectType.DEVICE][baEnum.PropertyIdentifier.OBJECT_LIST] = that.objectList;
|
|
185
183
|
} else if(foundIndex !== -1) {
|
|
186
184
|
let foundObject = that.objectStore[baEnum.ObjectType.CHARACTERSTRING_VALUE][foundIndex];
|
|
187
185
|
foundObject[baEnum.PropertyIdentifier.PRESENT_VALUE][0].value = value;
|
|
186
|
+
that.objectStore[baEnum.ObjectType.DEVICE][baEnum.PropertyIdentifier.OBJECT_LIST] = that.objectList;
|
|
188
187
|
}
|
|
189
188
|
}
|
|
190
189
|
}
|
|
190
|
+
Store_Config_Server(JSON.stringify({objectList: that.objectList, objectStore: that.objectStore}));
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
getObject(objectId, propId, instance) {
|
|
@@ -270,8 +270,8 @@ class BacnetServer {
|
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
} catch(e){
|
|
274
|
-
//
|
|
273
|
+
} catch(e) {
|
|
274
|
+
//do nothing
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
return null;
|
|
@@ -279,15 +279,17 @@ class BacnetServer {
|
|
|
279
279
|
|
|
280
280
|
clearServerPoints() {
|
|
281
281
|
let that = this;
|
|
282
|
-
|
|
283
|
-
that.objectStore[baEnum.ObjectType.ANALOG_VALUE] = [];
|
|
284
|
-
that.objectStore[baEnum.ObjectType.CHARACTERSTRING_VALUE] = [];
|
|
285
|
-
|
|
282
|
+
|
|
286
283
|
that.objectList = [
|
|
287
284
|
{value: {type: baEnum.ObjectType.DEVICE, instance: that.deviceId}, type: 12}
|
|
288
285
|
];
|
|
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] = [];
|
|
289
289
|
|
|
290
290
|
that.objectIdNumber = 1;
|
|
291
|
+
|
|
292
|
+
Store_Config_Server(JSON.stringify({objectList: that.objectList, objectStore: that.objectStore}));
|
|
291
293
|
}
|
|
292
294
|
|
|
293
295
|
getRandomArbitrary(min, max) {
|
package/common.js
CHANGED
|
@@ -233,6 +233,34 @@ function Read_Config_Sync() {
|
|
|
233
233
|
return data;
|
|
234
234
|
};
|
|
235
235
|
|
|
236
|
+
// STORE CONFIG FUNCTION - BACNET SERVER ==========================================
|
|
237
|
+
//
|
|
238
|
+
// ================================================================================
|
|
239
|
+
async function Store_Config_Server(data) {
|
|
240
|
+
await fs.writeFile("edge-bacnet-server-datastore.cfg", data, (err) => {
|
|
241
|
+
if (err) {
|
|
242
|
+
console.log("Store_Config_Server writeFile error: ", err);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
// READ CONFIG SYNC FUNCTION - BACNET SERVER ======================================
|
|
248
|
+
//
|
|
249
|
+
// ================================================================================
|
|
250
|
+
function Read_Config_Sync_Server() {
|
|
251
|
+
var data = "{}";
|
|
252
|
+
try {
|
|
253
|
+
data = fs.readFileSync("edge-bacnet-server-datastore.cfg", {encoding:'utf8', flag:'r'});
|
|
254
|
+
}
|
|
255
|
+
catch(err) {
|
|
256
|
+
console.log("Read_Config_Sync_Server error:", err);
|
|
257
|
+
if(err.errno == -4058) console.log("Edge-BACnet Server: No save file found, creating new file");
|
|
258
|
+
data = '{}';
|
|
259
|
+
Store_Config_Server(data);
|
|
260
|
+
}
|
|
261
|
+
return data;
|
|
262
|
+
};
|
|
263
|
+
|
|
236
264
|
module.exports = {
|
|
237
265
|
DeviceObjectId,
|
|
238
266
|
DeviceObject,
|
|
@@ -247,5 +275,7 @@ module.exports = {
|
|
|
247
275
|
roundDecimalPlaces,
|
|
248
276
|
doNodeRedRestart,
|
|
249
277
|
Store_Config,
|
|
250
|
-
Read_Config_Sync
|
|
278
|
+
Read_Config_Sync,
|
|
279
|
+
Store_Config_Server,
|
|
280
|
+
Read_Config_Sync_Server
|
|
251
281
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"id":"
|
|
1
|
+
[{"id":"697c8ed4b294882c","type":"Bacnet-Gateway","z":"29e22a8fbd476c06","name":"","local_device_address":"","apduTimeout":6000,"roundDecimal":2,"local_device_port":47808,"apduSize":"5","maxSegments":"0x50","broadCastAddr":"255.255.255.255","toLogIam":true,"discover_polling_schedule":"60","discover_polling_schedule_value":"1","discover_polling_schedule_options":"Minutes","device_id_range_enabled":false,"device_id_range_start":"","device_id_range_end":"","deviceId":"817001","manual_instance_range_enabled":false,"manual_instance_range_start":"","manual_instance_range_end":"","logErrorToConsole":false,"serverEnabled":false,"bacnetServerRebuildSchedule":"604800","bacnetServerRebuildSchedule_value":"7","bacnetServerRebuildSchedule_options":"Days","x":640,"y":380,"wires":[["d78c0f4d2fb9befa"]]},{"id":"d129d123e7eedbca","type":"Bitpool-Inject","z":"29e22a8fbd476c06","name":"Discover","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","doPoll":false,"doDiscover":true,"x":460,"y":380,"wires":[["697c8ed4b294882c"]]},{"id":"2dc599ab69789b27","type":"Bitpool-Inject","z":"29e22a8fbd476c06","name":"Poll","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","doPoll":true,"doDiscover":false,"x":290,"y":320,"wires":[["282edf29720defca"]]},{"id":"d78c0f4d2fb9befa","type":"debug","z":"29e22a8fbd476c06","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":820,"y":380,"wires":[]},{"id":"282edf29720defca","type":"Bacnet-Discovery","z":"29e22a8fbd476c06","name":"","events":true,"json":false,"mqtt":true,"hiddenDeployToggle":false,"prevHiddenToggleState":false,"roundDecimal":2,"pointsToRead":{},"readDevices":[],"object_property_simplePayload":true,"object_property_fullObject":false,"x":470,"y":320,"wires":[["697c8ed4b294882c"]]}]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"id":"
|
|
1
|
+
[{"id":"e478e80571442399","type":"Bacnet-Gateway","z":"29e22a8fbd476c06","name":"","local_device_address":"","apduTimeout":6000,"roundDecimal":2,"local_device_port":47808,"apduSize":"5","maxSegments":"0x50","broadCastAddr":"255.255.255.255","toLogIam":true,"discover_polling_schedule":"60","discover_polling_schedule_value":"1","discover_polling_schedule_options":"Minutes","device_id_range_enabled":false,"device_id_range_start":"","device_id_range_end":"","deviceId":"817001","manual_instance_range_enabled":false,"manual_instance_range_start":"","manual_instance_range_end":"","logErrorToConsole":false,"serverEnabled":false,"bacnetServerRebuildSchedule":"604800","bacnetServerRebuildSchedule_value":"7","bacnetServerRebuildSchedule_options":"Days","x":620,"y":320,"wires":[["0313b7ee1cfa6b42"]]},{"id":"c2e012301c4a6af4","type":"Bitpool-Inject","z":"29e22a8fbd476c06","name":"Discover","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","doPoll":false,"doDiscover":true,"x":440,"y":320,"wires":[["e478e80571442399"]]},{"id":"8172620e7be7b505","type":"Bitpool-Inject","z":"29e22a8fbd476c06","name":"Poll","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","doPoll":true,"doDiscover":false,"x":290,"y":400,"wires":[["b3293195b7c5bd9d"]]},{"id":"0313b7ee1cfa6b42","type":"debug","z":"29e22a8fbd476c06","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":800,"y":320,"wires":[]},{"id":"b3293195b7c5bd9d","type":"Bacnet-Write","z":"29e22a8fbd476c06","name":"","applicationTag":"4","priority":"16","pointsToWrite":[],"writeDevices":[],"hiddenDeployToggle":false,"prevHiddenToggleState":false,"x":450,"y":400,"wires":[["e478e80571442399"]]}]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"id":"
|
|
1
|
+
[{"id":"e6ef82c5497d2d12","type":"Bacnet-Gateway","z":"29e22a8fbd476c06","name":"","local_device_address":"","apduTimeout":6000,"roundDecimal":2,"local_device_port":47808,"apduSize":"5","maxSegments":"0x50","broadCastAddr":"255.255.255.255","toLogIam":true,"discover_polling_schedule":"60","discover_polling_schedule_value":"1","discover_polling_schedule_options":"Minutes","device_id_range_enabled":false,"device_id_range_start":"","device_id_range_end":"","deviceId":"817001","manual_instance_range_enabled":false,"manual_instance_range_start":"","manual_instance_range_end":"","logErrorToConsole":false,"serverEnabled":false,"bacnetServerRebuildSchedule":"604800","bacnetServerRebuildSchedule_value":"7","bacnetServerRebuildSchedule_options":"Days","x":660,"y":360,"wires":[["13c868a66ecd17df"]]},{"id":"4df39409775f724e","type":"Bitpool-Inject","z":"29e22a8fbd476c06","name":"Discover","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","doPoll":false,"doDiscover":true,"x":480,"y":360,"wires":[["e6ef82c5497d2d12"]]},{"id":"67e4f714757a028e","type":"Bitpool-Inject","z":"29e22a8fbd476c06","name":"Poll","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","doPoll":true,"doDiscover":false,"x":330,"y":440,"wires":[["b8931cb1a1c69ffb"]]},{"id":"13c868a66ecd17df","type":"debug","z":"29e22a8fbd476c06","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":840,"y":360,"wires":[]},{"id":"b8931cb1a1c69ffb","type":"Bacnet-Write","z":"29e22a8fbd476c06","name":"","applicationTag":"4","priority":"16","pointsToWrite":[],"writeDevices":[],"hiddenDeployToggle":false,"prevHiddenToggleState":false,"x":490,"y":440,"wires":[["e6ef82c5497d2d12"]]},{"id":"a95e261a4cc2662b","type":"Bitpool-Inject","z":"29e22a8fbd476c06","name":"Poll","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","doPoll":true,"doDiscover":false,"x":330,"y":300,"wires":[["08df19608ade8576"]]},{"id":"08df19608ade8576","type":"Bacnet-Discovery","z":"29e22a8fbd476c06","name":"","events":true,"json":false,"mqtt":true,"hiddenDeployToggle":false,"prevHiddenToggleState":false,"roundDecimal":2,"pointsToRead":{},"readDevices":[],"object_property_simplePayload":true,"object_property_fullObject":false,"x":490,"y":300,"wires":[["e6ef82c5497d2d12"]]}]
|
package/package.json
CHANGED
|
File without changes
|