2025-06-16 16:53:07 +02:00
|
|
|
module.exports = function(RED) {
|
|
|
|
|
function recirculation(config) {
|
|
|
|
|
RED.nodes.createNode(this, config);
|
|
|
|
|
var node = this;
|
|
|
|
|
|
|
|
|
|
let name = config.name;
|
|
|
|
|
let F2 = parseFloat(config.F2);
|
2025-06-16 17:52:31 +02:00
|
|
|
const inlet_F2 = parseInt(config.inlet);
|
2025-06-16 16:53:07 +02:00
|
|
|
|
|
|
|
|
node.on('input', function(msg, send, done) {
|
|
|
|
|
switch (msg.topic) {
|
2026-03-11 13:39:57 +01:00
|
|
|
case "Fluent": {
|
2025-06-16 16:53:07 +02:00
|
|
|
// conserve volume flow debit
|
2025-06-18 10:25:40 +02:00
|
|
|
let F_in = msg.payload.F;
|
|
|
|
|
let F1 = Math.max(F_in - F2, 0);
|
|
|
|
|
let F2_corr = F_in < F2 ? F_in : F2;
|
2025-06-16 16:53:07 +02:00
|
|
|
|
2025-06-17 13:00:18 +02:00
|
|
|
let msg_F1 = structuredClone(msg);
|
2025-06-18 10:25:40 +02:00
|
|
|
msg_F1.payload.F = F1;
|
2025-06-16 16:53:07 +02:00
|
|
|
|
2025-06-17 13:00:18 +02:00
|
|
|
let msg_F2 = {...msg};
|
2025-06-16 16:53:07 +02:00
|
|
|
msg_F2.payload.F = F2_corr;
|
2025-06-16 17:52:31 +02:00
|
|
|
msg_F2.payload.inlet = inlet_F2;
|
2025-06-16 16:53:07 +02:00
|
|
|
|
|
|
|
|
send([msg_F1, msg_F2]);
|
|
|
|
|
break;
|
2026-03-11 13:39:57 +01:00
|
|
|
}
|
2025-07-16 16:54:30 +02:00
|
|
|
case "clock":
|
|
|
|
|
break;
|
2025-06-16 16:53:07 +02:00
|
|
|
default:
|
|
|
|
|
console.log("Unknown topic: " + msg.topic);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (done) {
|
|
|
|
|
done();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
RED.nodes.registerType("recirculation-pump", recirculation);
|
|
|
|
|
};
|