forked from bitpool/edge-bacnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bacnet_write.js
46 lines (37 loc) · 1.12 KB
/
bacnet_write.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
MIT License Copyright 2021, 2022 - Bitpool Pty Ltd
*/
module.exports = function (RED) {
function BitpoolBacnetWriteDevice (config) {
RED.nodes.createNode(this, config);
var node = this;
node.priority = config.priority;
node.appTag = config.applicationTag;
node.pointsToWrite = config.pointsToWrite;
node.writeDevices = config.writeDevices;
this.id = config.id;
node.on('input', function(msg) {
let value = msg.payload == "null" ? null : msg.payload;
let priority = node.priority == "null" ? null : parseInt(node.priority);
let output = {
type: "Write",
id: node.id,
options: {
priority: priority,
appTag: parseInt(node.appTag),
pointsToWrite: node.pointsToWrite
},
value: value,
outputType: {
json: node.json,
mqtt: node.mqtt
}
};
node.send(output);
});
node.on('close', function() {
//do nothing
});
};
RED.nodes.registerType('Bacnet-Write', BitpoolBacnetWriteDevice);
};