mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-12-27 15:24:28 +01:00
Let rbe node compare to previous input OR output
closes #192 and #193 Also update info and test.
This commit is contained in:
@@ -21,6 +21,7 @@ module.exports = function(RED) {
|
||||
this.func = n.func || "rbe";
|
||||
this.gap = n.gap || "0";
|
||||
this.start = n.start || '';
|
||||
this.inout = n.inout || "out";
|
||||
this.pc = false;
|
||||
if (this.gap.substr(-1) === "%") {
|
||||
this.pc = true;
|
||||
@@ -59,16 +60,17 @@ module.exports = function(RED) {
|
||||
if (!node.previous.hasOwnProperty(t)) { node.previous[t] = n - node.gap; }
|
||||
if (Math.abs(n - node.previous[t]) >= node.gap) {
|
||||
if (this.func === "deadband") {
|
||||
node.previous[t] = n;
|
||||
if (node.inout === "out") { node.previous[t] = n; }
|
||||
node.send(msg);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this.func === "narrowband") {
|
||||
node.previous[t] = n;
|
||||
if (node.inout === "out") { node.previous[t] = n; }
|
||||
node.send(msg);
|
||||
}
|
||||
}
|
||||
if (node.inout === "in") { node.previous[t] = n; }
|
||||
}
|
||||
else {
|
||||
node.warn(RED._("rbe.warn.nonumber"));
|
||||
|
||||
Reference in New Issue
Block a user