From 399e0a8c018b1261abce77cbeae19eaf92c6b3f2 Mon Sep 17 00:00:00 2001 From: znetsixe Date: Wed, 22 Apr 2026 17:50:50 +0200 Subject: [PATCH] Editor hygiene + remove redundant idle-position clamp in predictions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - rotatingMachine.html: add default name:{value:""} to the editor defaults block (standard Node-RED pattern; was missing). - nodeClass.js: clear node status badge on close — matches the pattern already in other EVOLV node close handlers. - specificClass.js: remove the `(x <= 0) ? 0 : ...` guard in the flow and power prediction methods. The guard was redundant: predictions only run while the FSM is in an active state (operational / starting / warmingup / accelerating / decelerating), none of which produce x=0. Math.max(0, rawFlow) still clamps negative extrapolation. Net: same behaviour in production, less dead code. All 10 basic tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) --- rotatingMachine.html | 1 + src/nodeClass.js | 1 + src/specificClass.js | 5 ++--- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rotatingMachine.html b/rotatingMachine.html index e75d05d..ad3305f 100644 --- a/rotatingMachine.html +++ b/rotatingMachine.html @@ -17,6 +17,7 @@ category: "EVOLV", color: "#86bbdd", defaults: { + name: { value: "" }, // Define specific properties speed: { value: 1, required: true }, diff --git a/src/nodeClass.js b/src/nodeClass.js index c428437..ad4a179 100644 --- a/src/nodeClass.js +++ b/src/nodeClass.js @@ -405,6 +405,7 @@ class nodeClass { clearTimeout(this._startupTimeout); clearInterval(this._tickInterval); clearInterval(this._statusInterval); + this.node.status({}); // clear node status badge // Clean up child measurement listeners const m = this.source; diff --git a/src/specificClass.js b/src/specificClass.js index c4db7cc..bab1fdd 100644 --- a/src/specificClass.js +++ b/src/specificClass.js @@ -968,8 +968,7 @@ _callMeasurementHandler(measurementType, value, position, context) { } const rawFlow = this.predictFlow.y(x); - // Clamp: at position ≤ 0 the pump isn't rotating — physical flow is 0. - const cFlow = (x <= 0) ? 0 : Math.max(0, rawFlow); + const cFlow = 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); return cFlow; @@ -993,7 +992,7 @@ _callMeasurementHandler(measurementType, value, position, context) { } const rawPower = this.predictPower.y(x); - const cPower = (x <= 0) ? 0 : Math.max(0, rawPower); + const cPower = Math.max(0, rawPower); this.measurements.type("power").variant("predicted").position('atEquipment').value(cPower, Date.now(), this.unitPolicy.canonical.power); return cPower; }