diff --git a/src/specificClass.js b/src/specificClass.js index 3cf0180..f00c018 100644 --- a/src/specificClass.js +++ b/src/specificClass.js @@ -967,10 +967,14 @@ _callMeasurementHandler(measurementType, value, position, context) { return 0; } - const cFlow = this.predictFlow.y(x); + // Clamp: at position ≤ 0 the pump isn't rotating — physical flow is 0. + // Without this, curve extrapolation at ctrl=0 + high backpressure + // produces large negative values (backflow through a stopped pump) + // that confuse dashboards and downstream consumers. + const rawFlow = this.predictFlow.y(x); + const cFlow = (x <= 0) ? 0 : Math.max(0, rawFlow); this.measurements.type("flow").variant("predicted").position("downstream").value(cFlow,Date.now(),this.unitPolicy.canonical.flow); this.measurements.type("flow").variant("predicted").position("atEquipment").value(cFlow,Date.now(),this.unitPolicy.canonical.flow); - //this.logger.debug(`Calculated flow: ${cFlow} for pressure: ${this.getMeasuredPressure()} and position: ${x}`); return cFlow; } @@ -991,10 +995,9 @@ _callMeasurementHandler(measurementType, value, position, context) { return 0; } - //this.predictPower.currentX = x; Decrepated - const cPower = this.predictPower.y(x); + const rawPower = this.predictPower.y(x); + const cPower = (x <= 0) ? 0 : Math.max(0, rawPower); this.measurements.type("power").variant("predicted").position('atEquipment').value(cPower, Date.now(), this.unitPolicy.canonical.power); - //this.logger.debug(`Calculated power: ${cPower} for pressure: ${this.getMeasuredPressure()} and position: ${x}`); return cPower; } // If no curve data is available, log a warning and return 0