Add recirculation pump node with input handling and flow management

This commit is contained in:
2025-06-16 16:53:07 +02:00
parent d0f8ada144
commit 5281696a21
6 changed files with 105 additions and 7 deletions

View File

@@ -0,0 +1,38 @@
module.exports = function(RED) {
function recirculation(config) {
RED.nodes.createNode(this, config);
var node = this;
let name = config.name;
let F2 = parseFloat(config.F2);
let inlet = parseInt(config.inlet);
node.on('input', function(msg, send, done) {
switch (msg.topic) {
case "Fluent":
// conserve volume flow debit
let F1 = msg.payload.F;
let F_diff = Math.max(F1 - F2, 0);
let F2_corr = F1 < F2 ? F1 : F2;
let msg_F1 = structuredClone(msg);
msg_F1.payload.F = F_diff;
let msg_F2 = structuredClone(msg);
msg_F2.payload.F = F2_corr;
msg_F2.payload.inlet = inlet;
send([msg_F1, msg_F2]);
break;
default:
console.log("Unknown topic: " + msg.topic);
}
if (done) {
done();
}
});
}
RED.nodes.registerType("recirculation-pump", recirculation);
};