Add recirculation pump node with input handling and flow management
This commit is contained in:
38
additional_nodes/recirculation-pump.js
Normal file
38
additional_nodes/recirculation-pump.js
Normal 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);
|
||||
};
|
||||
Reference in New Issue
Block a user