add greater and greater or equal modes to RBE bandgap mode

This commit is contained in:
Dave Conway-Jones
2017-04-14 21:38:42 +01:00
parent fc249b6792
commit 774bc50589
5 changed files with 122 additions and 34 deletions

View File

@@ -42,15 +42,23 @@ module.exports = function(RED) {
else { node.previous[t] = node.start; }
}
if (node.pc) { node.gap = (node.previous[t] * node.g / 100) || 0; }
if (!node.previous.hasOwnProperty(t)) { node.previous[t] = n - node.gap; }
if (Math.abs(n - node.previous[t]) >= node.gap) {
else { node.gap = Number(node.gap); }
if ((node.previous[t] === undefined) && (node.func === "narrowbandEq")) { node.previous[t] = n; }
if (node.previous[t] === undefined) { node.previous[t] = n - node.gap; }
if (Math.abs(n - node.previous[t]) === node.gap) {
if (this.func === "deadbandEq") {
if (node.inout === "out") { node.previous[t] = n; }
node.send(msg);
}
}
else if (Math.abs(n - node.previous[t]) > node.gap) {
if (this.func === "deadband") {
if (node.inout === "out") { node.previous[t] = n; }
node.send(msg);
}
}
else {
if (this.func === "narrowband") {
else if (Math.abs(n - node.previous[t]) < node.gap) {
if ((this.func === "narrowband")||(this.func === "narrowbandEq")) {
if (node.inout === "out") { node.previous[t] = n; }
node.send(msg);
}