mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
fix rbe edge case of sending when change = 0 in narrowband mode
and add test to close #569
This commit is contained in:
parent
75df218a23
commit
2e5b526c55
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-rbe",
|
"name" : "node-red-node-rbe",
|
||||||
"version" : "0.2.4",
|
"version" : "0.2.5",
|
||||||
"description" : "A Node-RED node that provides report-by-exception (RBE) and deadband capability.",
|
"description" : "A Node-RED node that provides report-by-exception (RBE) and deadband capability.",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
},
|
},
|
||||||
|
@ -56,7 +56,7 @@ module.exports = function(RED) {
|
|||||||
if ((node.previous[t] === undefined) && (node.func === "narrowbandEq")) { node.previous[t] = n; }
|
if ((node.previous[t] === undefined) && (node.func === "narrowbandEq")) { node.previous[t] = n; }
|
||||||
if (node.previous[t] === undefined) { node.previous[t] = n - node.gap; }
|
if (node.previous[t] === undefined) { node.previous[t] = n - node.gap; }
|
||||||
if (Math.abs(n - node.previous[t]) === node.gap) {
|
if (Math.abs(n - node.previous[t]) === node.gap) {
|
||||||
if (this.func === "deadbandEq") {
|
if ((this.func === "deadbandEq")||(this.func === "narrowband")) {
|
||||||
if (node.inout === "out") { node.previous[t] = n; }
|
if (node.inout === "out") { node.previous[t] = n; }
|
||||||
node.send(msg);
|
node.send(msg);
|
||||||
}
|
}
|
||||||
|
@ -392,6 +392,32 @@ describe('rbe node', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should send output if gap is 0 and input doesnt change (narrowband)', function(done) {
|
||||||
|
var flow = [{"id":"n1", "type":"rbe", func:"narrowband", gap:"0", wires:[["n2"]] },
|
||||||
|
{id:"n2", type:"helper"} ];
|
||||||
|
helper.load(testNode, flow, function() {
|
||||||
|
var n1 = helper.getNode("n1");
|
||||||
|
var n2 = helper.getNode("n2");
|
||||||
|
var c = 0;
|
||||||
|
n2.on("input", function(msg) {
|
||||||
|
if (c === 0) {
|
||||||
|
msg.should.have.a.property("payload", 1);
|
||||||
|
}
|
||||||
|
else if (c === 4) {
|
||||||
|
msg.should.have.a.property("payload",1);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
c += 1;
|
||||||
|
});
|
||||||
|
n1.emit("input", {payload:1});
|
||||||
|
n1.emit("input", {payload:1});
|
||||||
|
n1.emit("input", {payload:1});
|
||||||
|
n1.emit("input", {payload:1});
|
||||||
|
n1.emit("input", {payload:0});
|
||||||
|
n1.emit("input", {payload:1});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should not send output if more than x away from original value (narrowband in step mode)', function(done) {
|
it('should not send output if more than x away from original value (narrowband in step mode)', function(done) {
|
||||||
var flow = [{"id":"n1", "type":"rbe", func:"narrowband", gap:"10", inout:"in", start:"500", wires:[["n2"]] },
|
var flow = [{"id":"n1", "type":"rbe", func:"narrowband", gap:"10", inout:"in", start:"500", wires:[["n2"]] },
|
||||||
{id:"n2", type:"helper"} ];
|
{id:"n2", type:"helper"} ];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user