Let rbe node compare to previous input OR output

closes #192 and #193
Also update info and test.
This commit is contained in:
Dave Conway-Jones
2016-03-21 00:01:50 +00:00
parent 2ed8e5a306
commit c3a8a4088d
6 changed files with 52 additions and 8 deletions

View File

@@ -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"));