Add settling basin node, fixed issue with object assignment
This commit is contained in:
@@ -26,11 +26,11 @@
|
|||||||
},
|
},
|
||||||
oneditsave: function() {
|
oneditsave: function() {
|
||||||
let debit = parseFloat($("#node-input-F2").typedInput("value"));
|
let debit = parseFloat($("#node-input-F2").typedInput("value"));
|
||||||
if (isNaN(volume) || debit < 0) {
|
if (isNaN(debit) || debit < 0) {
|
||||||
RED.notify("Debit is not set correctly", {type: "error"});
|
RED.notify("Debit is not set correctly", {type: "error"});
|
||||||
}
|
}
|
||||||
let inlet = parseInt($("#node-input-n_inlets").typedInput("value"));
|
let inlet = parseInt($("#node-input-n_inlets").typedInput("value"));
|
||||||
if (isNaN(inlet) || inlet < 1) {
|
if (inlet < 1) {
|
||||||
RED.notify("Number of inlets not set correctly", {type: "error"});
|
RED.notify("Number of inlets not set correctly", {type: "error"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ module.exports = function(RED) {
|
|||||||
let F_diff = Math.max(F1 - F2, 0);
|
let F_diff = Math.max(F1 - F2, 0);
|
||||||
let F2_corr = F1 < F2 ? F1 : F2;
|
let F2_corr = F1 < F2 ? F1 : F2;
|
||||||
|
|
||||||
let msg_F1 = {...msg};
|
let msg_F1 = structuredClone(msg);
|
||||||
msg_F1.payload.F = F_diff;
|
msg_F1.payload.F = F_diff;
|
||||||
|
|
||||||
let msg_F2 = structuredClone(msg);
|
let msg_F2 = {...msg};
|
||||||
msg_F2.payload.F = F2_corr;
|
msg_F2.payload.F = F2_corr;
|
||||||
msg_F2.payload.inlet = inlet_F2;
|
msg_F2.payload.inlet = inlet_F2;
|
||||||
|
|
||||||
|
|||||||
57
additional_nodes/settling-basin.html
Normal file
57
additional_nodes/settling-basin.html
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<script type="text/javascript">
|
||||||
|
RED.nodes.registerType("settling-basin", {
|
||||||
|
category: "WWTP",
|
||||||
|
color: "#e4a363",
|
||||||
|
defaults: {
|
||||||
|
name: { value: "" },
|
||||||
|
SVI: { value: 0.1, required: true },
|
||||||
|
inlet: { value: 1, required: true }
|
||||||
|
},
|
||||||
|
inputs: 1,
|
||||||
|
outputs: 2,
|
||||||
|
outputLabels: ["Main effluent", "Sludge effluent"],
|
||||||
|
icon: "font-awesome/fa-random",
|
||||||
|
label: function() {
|
||||||
|
return this.name || "Settling basin";
|
||||||
|
},
|
||||||
|
oneditprepare: function() {
|
||||||
|
$("#node-input-SVI").typedInput({
|
||||||
|
type:"num",
|
||||||
|
types:["num"]
|
||||||
|
});
|
||||||
|
$("#node-input-inlet").typedInput({
|
||||||
|
type:"num",
|
||||||
|
types:["num"]
|
||||||
|
});
|
||||||
|
},
|
||||||
|
oneditsave: function() {
|
||||||
|
let SVI = parseFloat($("#node-input-SVI").typedInput("value"));
|
||||||
|
if (isNaN(SVI) || SVI < 0) {
|
||||||
|
RED.notify("SVI is not set correctly", {type: "error"});
|
||||||
|
}
|
||||||
|
let inlet = parseInt($("#node-input-n_inlets").typedInput("value"));
|
||||||
|
if (inlet < 1) {
|
||||||
|
RED.notify("Number of inlets not set correctly", {type: "error"});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" data-template-name="settling-basin">
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
||||||
|
<input type="text" id="node-input-name" placeholder="Name">
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-SVI"><i class="fa fa-tag"></i> SVI (alternate)</label>
|
||||||
|
<input type="text" id="node-input-SVI" placeholder="">
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-inlet"><i class="fa fa-tag"></i> Assigned inlet return line</label>
|
||||||
|
<input type="text" id="node-input-inlet" placeholder="#">
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" data-help-name="settling-basin">
|
||||||
|
<p>Settling tank</p>
|
||||||
|
</script>
|
||||||
53
additional_nodes/settling-basin.js
Normal file
53
additional_nodes/settling-basin.js
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
module.exports = function(RED) {
|
||||||
|
function settler(config) {
|
||||||
|
RED.nodes.createNode(this, config);
|
||||||
|
var node = this;
|
||||||
|
|
||||||
|
let name = config.name;
|
||||||
|
let SVI = parseFloat(config.SVI);
|
||||||
|
const inlet_sludge = parseInt(config.inlet);
|
||||||
|
|
||||||
|
node.on('input', function(msg, send, done) {
|
||||||
|
switch (msg.topic) {
|
||||||
|
case "Fluent":
|
||||||
|
// conserve volume flow debit
|
||||||
|
let F_in = msg.payload.F;
|
||||||
|
let C_in = msg.payload.C;
|
||||||
|
let X_in = (C_in[7] + C_in[8] + C_in[9] + C_in[10] + C_in[11] + C_in[12]);
|
||||||
|
let F2 = (F_in * X_in) / (SVI*1000*1000);
|
||||||
|
|
||||||
|
let msg_F1 = structuredClone(msg);
|
||||||
|
msg_F1.payload.F = F_in - F2;
|
||||||
|
msg_F1.payload.C[7] = 0;
|
||||||
|
msg_F1.payload.C[8] = 0;
|
||||||
|
msg_F1.payload.C[9] = 0;
|
||||||
|
msg_F1.payload.C[10] = 0;
|
||||||
|
msg_F1.payload.C[11] = 0;
|
||||||
|
msg_F1.payload.C[12] = 0;
|
||||||
|
|
||||||
|
let msg_F2 = {...msg};
|
||||||
|
msg_F2.payload.F = F2;
|
||||||
|
if (F2 != 0) {
|
||||||
|
msg_F2.payload.C[7] = F_in * C_in[7] / F2;
|
||||||
|
msg_F2.payload.C[8] = F_in * C_in[8] / F2;
|
||||||
|
msg_F2.payload.C[9] = F_in * C_in[9] / F2;
|
||||||
|
msg_F2.payload.C[10] = F_in * C_in[10] / F2;
|
||||||
|
msg_F2.payload.C[11] = F_in * C_in[11] / F2;
|
||||||
|
msg_F2.payload.C[12] = F_in * C_in[12] / F2;
|
||||||
|
}
|
||||||
|
msg_F2.payload.inlet = inlet_sludge;
|
||||||
|
|
||||||
|
send([msg_F1, msg_F2]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.log("Unknown topic: " + msg.topic);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (done) {
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
RED.nodes.registerType("settling-basin", settler);
|
||||||
|
};
|
||||||
@@ -22,7 +22,8 @@
|
|||||||
"node-red": {
|
"node-red": {
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"advanced-reactor": "advanced-reactor.js",
|
"advanced-reactor": "advanced-reactor.js",
|
||||||
"recirculation-pump": "additional_nodes/recirculation-pump.js"
|
"recirculation-pump": "additional_nodes/recirculation-pump.js",
|
||||||
|
"settling-basin": "additional_nodes/settling-basin.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
Reference in New Issue
Block a user