diff --git a/src/specificClass.js b/src/specificClass.js index ef00497..bacb65c 100644 --- a/src/specificClass.js +++ b/src/specificClass.js @@ -264,15 +264,26 @@ class PumpingStation { return; } - if (level > startLevel && direction === 'filling') { - const percControl = this._scaleLevelToFlowPercent(level); - this.logger.debug(`Controllevel based => Level ${level} control applying to pump : ${percControl}`); - await this._applyMachineLevelControl(percControl); - // Also forward to machine groups (e.g. MGC) — the level-based - // control originally only addressed direct-child machines, but in - // a hierarchical topology (PS → MGC → pumps) the machines sit - // under MGC and PS.machines is empty. - await this._applyMachineGroupLevelControl(percControl); + // Continuous proportional control: command pumps whenever level is + // above stopLevel. The percControl ramp gives: + // - 0% at minFlowLevel (= startLevel) → pumps barely running + // - linearly up to 100% at maxFlowLevel → all pumps full + // - Below startLevel but above stopLevel: percControl < 0 → clamp + // to 0 → MGC turns off pumps (graceful ramp-down instead of a + // dead zone where pumps keep running at their last setpoint). + if (level > stopLevel) { + const rawPercControl = this._scaleLevelToFlowPercent(level); + const percControl = Math.max(0, rawPercControl); + this.logger.debug(`Controllevel based => Level ${level} percControl ${percControl}`); + if (percControl > 0) { + await this._applyMachineLevelControl(percControl); + await this._applyMachineGroupLevelControl(percControl); + } else { + // Between stopLevel and startLevel with percControl ≤ 0: + // tell MGC to scale back to 0 rather than leaving pumps + // running at the last commanded setpoint. + await this._applyMachineGroupLevelControl(0); + } } if (level < stopLevel && direction === 'draining') {