Rixed multiplying message bug.

This commit is contained in:
2025-06-16 17:52:31 +02:00
parent 3ba98d2362
commit c8c588600c
2 changed files with 13 additions and 5 deletions

View File

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

View File

@@ -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);
}
if (toggleUpdate) {
reactor.updateState(msg.timestamp);
send(reactor.getEffluent);
}
if (done) {
done();