@bitpoolos/edge-bacnet 1.0.9 → 1.1.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/bacnet_client.js +309 -314
- package/bacnet_device.js +41 -15
- package/bacnet_gateway.html +88 -42
- package/bacnet_gateway.js +80 -27
- package/bacnet_read.html +110 -34
- package/bacnet_server.js +321 -0
- package/bacnet_write.html +14 -9
- package/common.js +34 -3
- package/edge-bacnet-datastore.cfg +0 -0
- package/package.json +1 -1
package/common.js
CHANGED
|
@@ -7,7 +7,7 @@ const { randomUUID } = require('crypto');
|
|
|
7
7
|
const os = require('os');
|
|
8
8
|
const { exec } = require("child_process");
|
|
9
9
|
const baEnum = require('./resources/node-bacnet/index.js').enum;
|
|
10
|
-
|
|
10
|
+
const fs = require('fs');
|
|
11
11
|
|
|
12
12
|
const logger = createLogger({
|
|
13
13
|
format: format.combine(
|
|
@@ -79,7 +79,8 @@ class BacnetClientConfig {
|
|
|
79
79
|
deviceId,
|
|
80
80
|
manual_instance_range_enabled,
|
|
81
81
|
manual_instance_range_start,
|
|
82
|
-
manual_instance_range_end
|
|
82
|
+
manual_instance_range_end,
|
|
83
|
+
bacnetServerEnabled
|
|
83
84
|
) {
|
|
84
85
|
this.apduTimeout = apduTimeout;
|
|
85
86
|
this.localIpAdrress = localIpAdrress;
|
|
@@ -96,6 +97,7 @@ class BacnetClientConfig {
|
|
|
96
97
|
this.manual_instance_range_enabled = manual_instance_range_enabled;
|
|
97
98
|
this.manual_instance_range_start = manual_instance_range_start;
|
|
98
99
|
this.manual_instance_range_end = manual_instance_range_end;
|
|
100
|
+
this.bacnetServerEnabled = bacnetServerEnabled;
|
|
99
101
|
}
|
|
100
102
|
};
|
|
101
103
|
|
|
@@ -204,6 +206,33 @@ const doNodeRedRestart = function() {
|
|
|
204
206
|
});
|
|
205
207
|
};
|
|
206
208
|
|
|
209
|
+
// STORE CONFIG FUNCTION ==========================================================
|
|
210
|
+
//
|
|
211
|
+
// ================================================================================
|
|
212
|
+
async function Store_Config(data) {
|
|
213
|
+
await fs.writeFile("edge-bacnet-datastore.cfg", data, (err) => {
|
|
214
|
+
if (err) {
|
|
215
|
+
console.log("Store_Config writeFile error: ", err);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
// READ CONFIG SYNC FUNCTION ======================================================
|
|
221
|
+
//
|
|
222
|
+
// ================================================================================
|
|
223
|
+
function Read_Config_Sync() {
|
|
224
|
+
var data = "{}";
|
|
225
|
+
try {
|
|
226
|
+
data = fs.readFileSync("edge-bacnet-datastore.cfg", {encoding:'utf8', flag:'r'});
|
|
227
|
+
}
|
|
228
|
+
catch(err) {
|
|
229
|
+
console.log("Read_Config_Sync error:", err);
|
|
230
|
+
data = '{}';
|
|
231
|
+
Store_Config(data);
|
|
232
|
+
}
|
|
233
|
+
return data;
|
|
234
|
+
};
|
|
235
|
+
|
|
207
236
|
module.exports = {
|
|
208
237
|
DeviceObjectId,
|
|
209
238
|
DeviceObject,
|
|
@@ -216,5 +245,7 @@ module.exports = {
|
|
|
216
245
|
generateId,
|
|
217
246
|
getIpAddress,
|
|
218
247
|
roundDecimalPlaces,
|
|
219
|
-
doNodeRedRestart
|
|
248
|
+
doNodeRedRestart,
|
|
249
|
+
Store_Config,
|
|
250
|
+
Read_Config_Sync
|
|
220
251
|
};
|
|
File without changes
|