Rixed multiplying message bug.
This commit is contained in:
@@ -5,7 +5,7 @@ module.exports = function(RED) {
|
||||
|
||||
let name = config.name;
|
||||
let F2 = parseFloat(config.F2);
|
||||
let inlet = parseInt(config.inlet);
|
||||
const inlet_F2 = parseInt(config.inlet);
|
||||
|
||||
node.on('input', function(msg, send, done) {
|
||||
switch (msg.topic) {
|
||||
@@ -15,12 +15,12 @@ module.exports = function(RED) {
|
||||
let F_diff = Math.max(F1 - F2, 0);
|
||||
let F2_corr = F1 < F2 ? F1 : F2;
|
||||
|
||||
let msg_F1 = structuredClone(msg);
|
||||
let msg_F1 = {...msg};
|
||||
msg_F1.payload.F = F_diff;
|
||||
|
||||
let msg_F2 = structuredClone(msg);
|
||||
msg_F2.payload.F = F2_corr;
|
||||
msg_F2.payload.inlet = inlet;
|
||||
msg_F2.payload.inlet = inlet_F2;
|
||||
|
||||
send([msg_F1, msg_F2]);
|
||||
break;
|
||||
|
||||
@@ -28,12 +28,17 @@ module.exports = function(RED) {
|
||||
);
|
||||
|
||||
node.on('input', function(msg, send, done) {
|
||||
let toggleUpdate = false;
|
||||
|
||||
switch (msg.topic) {
|
||||
case "clock":
|
||||
reactor.updateState(msg.timestamp);
|
||||
toggleUpdate = true;
|
||||
break;
|
||||
case "Fluent":
|
||||
reactor.setInfluent = msg;
|
||||
if (msg.payload.inlet == 0) {
|
||||
toggleUpdate = true;
|
||||
}
|
||||
break;
|
||||
case "OTR":
|
||||
reactor.setOTR = msg;
|
||||
@@ -42,7 +47,10 @@ module.exports = function(RED) {
|
||||
console.log("Unknown topic: " + msg.topic);
|
||||
}
|
||||
|
||||
send(reactor.getEffluent);
|
||||
if (toggleUpdate) {
|
||||
reactor.updateState(msg.timestamp);
|
||||
send(reactor.getEffluent);
|
||||
}
|
||||
|
||||
if (done) {
|
||||
done();
|
||||
|
||||
Reference in New Issue
Block a user