MAINTENANCE
Suspends automatic control and parks the plant so engineers can work on it.
| Mode string | MAINTENANCE (EMS_OP_MAINTENANCE) |
| Dispatcher | ems_main.py → control_logic_updated.control_step_maintenance |
| Config block | functions.Maintenance |
| Queue action | set_power_kw (value 0.0) |
| Queue source tag | maintenance |
| Status | Implemented |
Purpose
Planned service work. Selecting this mode:
- Discards unapplied automatic power setpoints, so a command queued by a previous mode cannot move the plant while somebody is working on it.
- Holds every active PCS at
0 kW, unlesshold_zero_poweris turned off.
This is the same mechanism as STOP_ALL, but it is a planned state rather than an emergency one, and it is explicit about being configurable.
Difference from STOP_ALL
| STOP_ALL | MAINTENANCE | |
|---|---|---|
| Intent | Emergency stop | Planned service work |
| Zero-power hold | Always | Configurable (hold_zero_power) |
| Manual commands | Preserved | Preserved |
| Config block | None, by design | functions.Maintenance |
Configuration
functions.Maintenance
| Key | Live value | Meaning |
|---|---|---|
hold_zero_power |
true |
Queue an explicit 0 kW for every active PCS. Set false to only stop automatic dispatch and leave the plant at its current setpoint. |
Design note on
hold_zero_power: the default istruebecause a maintenance mode that leaves the plant running is the dangerous interpretation. If your maintenance workflow expects the plant to keep operating while engineers work on unrelated systems, set this tofalse.
Why there is no enabled flag
Selecting the mode is the intent, exactly as with STOP_ALL. A separate enable flag would let an
operator select MAINTENANCE and have nothing happen, which is worse than acting. If you want a
confirmation gate instead, that belongs in the UI/API layer, not in the control step.
Safety
- Preserves manual/operator commands and
mode_pq/mode_vfswitches — the discard step only removes automaticcontrol_logicpower setpoints. The engineer on site keeps control. - Zero commands use their own
maintenancequeue source, so running every cycle replaces rather than stacks them (exactly one pending command per PCS). - Failures are caught per cycle and logged as
[EMS][WARN] MAINTENANCE failed: .... - Reachable only when
ems_control_modeis internal and no diagnostic test is active.
Outputs
discard_pending_automatic_power_commands()queue_diagnostic_zero_power_commands(source="maintenance")— oneset_power_kw= 0.0 per active PCS.- Log line:
[MAINTENANCE] automatic control suspended; discarded N pending setpoint(s); queued 0 kW for M PCS.
Confirmation needed: the
hold_zero_power: truedefault is my interpretation of what maintenance should do. Tell me if instead it should, for example, hold a target SOC, allow unlimited manual discharge, or inhibit specific protections — those are all easy to add.