Fix ESLint errors and bugs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Rene De Ren
2026-03-11 13:39:57 +01:00
parent 6287708c1e
commit aaa88a7792
2 changed files with 112 additions and 110 deletions

View File

@@ -145,8 +145,8 @@ class nodeClass {
const v = this.source; const v = this.source;
try { try {
const mode = v.currentMode; // modus is bijv. auto, manual, etc. const mode = v.currentMode;
const state = v.state.getCurrentState(); //is bijv. operational, idle, off, etc. const state = v.state.getCurrentState();
const fluidCompatibility = typeof v.getFluidCompatibility === "function" const fluidCompatibility = typeof v.getFluidCompatibility === "function"
? v.getFluidCompatibility() ? v.getFluidCompatibility()
: null; : null;
@@ -158,13 +158,12 @@ class nodeClass {
: ""; : "";
const flowUnit = v?.unitPolicy?.output?.flow || this.config.general.unit || "m3/h"; const flowUnit = v?.unitPolicy?.output?.flow || this.config.general.unit || "m3/h";
const pressureUnit = v?.unitPolicy?.output?.pressure || "mbar"; const pressureUnit = v?.unitPolicy?.output?.pressure || "mbar";
// check if measured flow is available otherwise use predicted flow
const flow = Math.round(v.measurements.type("flow").variant("predicted").position("downstream").getCurrentValue(flowUnit)); const flow = Math.round(v.measurements.type("flow").variant("predicted").position("downstream").getCurrentValue(flowUnit));
let deltaP = v.measurements.type("pressure").variant("predicted").position("delta").getCurrentValue(pressureUnit); let deltaP = v.measurements.type("pressure").variant("predicted").position("delta").getCurrentValue(pressureUnit);
if (deltaP !== null) { if (deltaP !== null) {
deltaP = parseFloat(deltaP.toFixed(0)); deltaP = parseFloat(deltaP.toFixed(0));
} //afronden op 4 decimalen indien geen "null" }
if(isNaN(deltaP)) { if(isNaN(deltaP)) {
deltaP = "∞"; deltaP = "∞";
} }
@@ -200,7 +199,6 @@ class nodeClass {
break; break;
} }
let status; let status;
switch (state) { switch (state) {
case "off": case "off":
@@ -210,16 +208,16 @@ class nodeClass {
status = { fill: "blue", shape: "dot", text: `${mode}: ${symbolState}` }; status = { fill: "blue", shape: "dot", text: `${mode}: ${symbolState}` };
break; break;
case "operational": case "operational":
status = { fill: "green", shape: "dot", text: `${mode}: ${symbolState} | ${roundedPosition}% | 💨${flow}${flowUnit} | ΔP${deltaP} ${pressureUnit}`}; //deltaP toegevoegd status = { fill: "green", shape: "dot", text: `${mode}: ${symbolState} | ${roundedPosition}% | 💨${flow}${flowUnit} | ΔP${deltaP} ${pressureUnit}`};
break; break;
case "starting": case "starting":
status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState}` }; status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState}` };
break; break;
case "warmingup": case "warmingup":
status = { fill: "green", shape: "dot", text: `${mode}: ${symbolState} | ${roundedPosition}% | 💨${flow}${flowUnit} | ΔP${deltaP} ${pressureUnit}`}; //deltaP toegevoegd status = { fill: "green", shape: "dot", text: `${mode}: ${symbolState} | ${roundedPosition}% | 💨${flow}${flowUnit} | ΔP${deltaP} ${pressureUnit}`};
break; break;
case "accelerating": case "accelerating":
status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState} | ${roundedPosition}% | 💨${flow}${flowUnit} | ΔP${deltaP} ${pressureUnit}` }; //deltaP toegevoegd status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState} | ${roundedPosition}% | 💨${flow}${flowUnit} | ΔP${deltaP} ${pressureUnit}` };
break; break;
case "stopping": case "stopping":
status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState}` }; status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState}` };
@@ -228,7 +226,7 @@ class nodeClass {
status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState}` }; status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState}` };
break; break;
case "decelerating": case "decelerating":
status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState} - ${roundedPosition}% | 💨${flow}${flowUnit} | ΔP${deltaP} ${pressureUnit}`}; //deltaP toegevoegd status = { fill: "yellow", shape: "dot", text: `${mode}: ${symbolState} - ${roundedPosition}% | 💨${flow}${flowUnit} | ΔP${deltaP} ${pressureUnit}`};
break; break;
default: default:
status = { fill: "grey", shape: "dot", text: `${mode}: ${symbolState}` }; status = { fill: "grey", shape: "dot", text: `${mode}: ${symbolState}` };

View File

@@ -703,7 +703,7 @@ class Valve {
this.logger.debug(`Updating pressure: variant=${variant}, value=${value}, position=${position}`); this.logger.debug(`Updating pressure: variant=${variant}, value=${value}, position=${position}`);
switch (variant) { switch (variant) {
case ("measured"): case ("measured"): {
// put value in measurements container // put value in measurements container
this._writeMeasurement("pressure", "measured", position, Number(value), unit); this._writeMeasurement("pressure", "measured", position, Number(value), unit);
// get latest downstream pressure measurement // get latest downstream pressure measurement
@@ -712,18 +712,20 @@ class Valve {
const predictedFlow = this._readMeasurement("flow", "predicted", "downstream", FORMULA_UNITS.flow); const predictedFlow = this._readMeasurement("flow", "predicted", "downstream", FORMULA_UNITS.flow);
const activeFlow = Number.isFinite(predictedFlow) ? predictedFlow : measuredFlow; const activeFlow = Number.isFinite(predictedFlow) ? predictedFlow : measuredFlow;
// update predicted flow measurement // update predicted flow measurement
this.updateDeltaPKlep(activeFlow,this.kv,measuredDownStreamP,this.rho,this.T); //update deltaP based on new flow this.updateDeltaPKlep(activeFlow,this.kv,measuredDownStreamP,this.rho,this.T);
break; break;
}
case ("predicted"): case ("predicted"): {
// put value in measurements container // put value in measurements container
this._writeMeasurement("pressure", "predicted", position, Number(value), unit); this._writeMeasurement("pressure", "predicted", position, Number(value), unit);
const predictedDownStreamP = this._readMeasurement("pressure", "predicted", "downstream", FORMULA_UNITS.pressure); const predictedDownStreamP = this._readMeasurement("pressure", "predicted", "downstream", FORMULA_UNITS.pressure);
const measuredFlowFromPred = this._readMeasurement("flow", "measured", "downstream", FORMULA_UNITS.flow); const measuredFlowFromPred = this._readMeasurement("flow", "measured", "downstream", FORMULA_UNITS.flow);
const predictedFlowFromPred = this._readMeasurement("flow", "predicted", "downstream", FORMULA_UNITS.flow); const predictedFlowFromPred = this._readMeasurement("flow", "predicted", "downstream", FORMULA_UNITS.flow);
const activeFlowFromPred = Number.isFinite(predictedFlowFromPred) ? predictedFlowFromPred : measuredFlowFromPred; const activeFlowFromPred = Number.isFinite(predictedFlowFromPred) ? predictedFlowFromPred : measuredFlowFromPred;
this.updateDeltaPKlep(activeFlowFromPred,this.kv,predictedDownStreamP,this.rho,this.T); //update deltaP based on new flow this.updateDeltaPKlep(activeFlowFromPred,this.kv,predictedDownStreamP,this.rho,this.T);
break; break;
}
default: default:
this.logger.warn(`Unrecognized variant '${variant}' for flow update.`); this.logger.warn(`Unrecognized variant '${variant}' for flow update.`);
@@ -784,23 +786,25 @@ class Valve {
this.logger.debug(`Updating flow: variant=${variant}, value=${value}, position=${position}`); this.logger.debug(`Updating flow: variant=${variant}, value=${value}, position=${position}`);
switch (variant) { switch (variant) {
case ("measured"): case ("measured"): {
// put value in measurements container // put value in measurements container
this._writeMeasurement("flow", "measured", position, Number(value), unit); this._writeMeasurement("flow", "measured", position, Number(value), unit);
// get latest downstream pressure measurement // get latest downstream pressure measurement
const measuredDownStreamP = this._readMeasurement("pressure", "measured", "downstream", FORMULA_UNITS.pressure); const measuredDownStreamP = this._readMeasurement("pressure", "measured", "downstream", FORMULA_UNITS.pressure);
const measuredFlow = this._readMeasurement("flow", "measured", position, FORMULA_UNITS.flow); const measuredFlow = this._readMeasurement("flow", "measured", position, FORMULA_UNITS.flow);
// update predicted flow measurement // update predicted flow measurement
this.updateDeltaPKlep(measuredFlow,this.kv,measuredDownStreamP,this.rho,this.T); //update deltaP based on new flow this.updateDeltaPKlep(measuredFlow,this.kv,measuredDownStreamP,this.rho,this.T);
break; break;
}
case ("predicted"): case ("predicted"): {
// put value in measurements container // put value in measurements container
this._writeMeasurement("flow", "predicted", position, Number(value), unit); this._writeMeasurement("flow", "predicted", position, Number(value), unit);
const predictedDownStreamP = this._readMeasurement("pressure", "measured", "downstream", FORMULA_UNITS.pressure); const predictedDownStreamP = this._readMeasurement("pressure", "measured", "downstream", FORMULA_UNITS.pressure);
const predictedFlow = this._readMeasurement("flow", "predicted", position, FORMULA_UNITS.flow); const predictedFlow = this._readMeasurement("flow", "predicted", position, FORMULA_UNITS.flow);
this.updateDeltaPKlep(predictedFlow,this.kv,predictedDownStreamP,this.rho,this.T); //update deltaP based on new flow this.updateDeltaPKlep(predictedFlow,this.kv,predictedDownStreamP,this.rho,this.T);
break; break;
}
default: default:
this.logger.warn(`Unrecognized variant '${variant}' for flow update.`); this.logger.warn(`Unrecognized variant '${variant}' for flow update.`);