forked from Harsch-Systems/node-red-contrib-pi-plates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
din.js
22 lines (21 loc) · 738 Bytes
/
din.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module.exports = function (RED) {
function DINNode(config) {
RED.nodes.createNode(this, config);
var node = this;
node.plate = RED.nodes.getNode(config.config_plate).plate;
node.input = parseInt(config.input, 10);
node.state = 0;
node.on('input', function (msg) {
const obj = {cmd: "getDINbit", args: {bit: node.input}};
node.plate.send(obj, (reply) => {
node.state = reply.state
node.status({text: node.state});
node.send({payload: node.state});
});
});
this.on('close', function () {
// cleanup goes here
});
}
RED.nodes.registerType("ppDIN", DINNode);
}