fix: continuous proportional control — eliminate dead zone between start/stop levels
Previously PS only sent demand to MGC when level > startLevel AND
direction === 'filling'. Between startLevel and stopLevel (the 'dead
zone'), pumps kept running at their last commanded setpoint with no
updates. Basin drained uncontrolled until hitting stopLevel.
Fix: send percControl on every tick when level > stopLevel. The
_scaleLevelToFlowPercent math naturally gives:
- Positive % above startLevel (pumps ramp up)
- 0% at exactly startLevel (pumps at minimum)
- Negative % below startLevel → clamped to 0 → MGC scales to 0
→ pumps ramp down gracefully
This creates smooth visible ramp-up and ramp-down as the basin fills
and drains, instead of a sudden jump at startLevel and stuck ctrl in
the dead zone.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -264,15 +264,26 @@ class PumpingStation {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (level > startLevel && direction === 'filling') {
|
// Continuous proportional control: command pumps whenever level is
|
||||||
const percControl = this._scaleLevelToFlowPercent(level);
|
// above stopLevel. The percControl ramp gives:
|
||||||
this.logger.debug(`Controllevel based => Level ${level} control applying to pump : ${percControl}`);
|
// - 0% at minFlowLevel (= startLevel) → pumps barely running
|
||||||
await this._applyMachineLevelControl(percControl);
|
// - linearly up to 100% at maxFlowLevel → all pumps full
|
||||||
// Also forward to machine groups (e.g. MGC) — the level-based
|
// - Below startLevel but above stopLevel: percControl < 0 → clamp
|
||||||
// control originally only addressed direct-child machines, but in
|
// to 0 → MGC turns off pumps (graceful ramp-down instead of a
|
||||||
// a hierarchical topology (PS → MGC → pumps) the machines sit
|
// dead zone where pumps keep running at their last setpoint).
|
||||||
// under MGC and PS.machines is empty.
|
if (level > stopLevel) {
|
||||||
await this._applyMachineGroupLevelControl(percControl);
|
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') {
|
if (level < stopLevel && direction === 'draining') {
|
||||||
|
|||||||
Reference in New Issue
Block a user