template<typename R, uint8_t N, uint8_t D>
class RelayLogic::Engine< R, N, D >
A collection of relays, switched one at a time from a sliding average.
- Template Parameters
-
| R | The relay type: a Relay<>, or a type derived from one. |
| N | The number of relays to be managed. |
| D | The duration in minutes for the sliding average. |
- Relay Management: Handles the state of multiple relays, turning them ON or OFF based on surplus and import thresholds.
- Sliding Average: Uses an Exponentially Weighted Moving Average (EWMA) to calculate the average power over a configurable duration.
- State Transitions: Ensures stable operation by enforcing minimum ON/OFF durations and a delay between state changes.
Definition at line 314 of file relay_engine.h.
template<typename R, uint8_t N, uint8_t D>
Increment the duration's state of each relay.
This method updates the duration of the current state for each relay and decreases the delay (settle_change) until the next state change is allowed.
Definition at line 458 of file relay_engine.h.
template<typename R, uint8_t N, uint8_t D>
| void RelayLogic::Engine< R, N, D >::proceed_relays |
( |
const uint16_t | overrideBitmask, |
|
|
const bool | diversionEnabled = true ) const |
|
inline |
Proceed all relays: OFF in decreasing order, ON in increasing order.
- Parameters
-
| overrideBitmask | Override bitmask (local pins): a relay is forced ON while its bit is set |
| diversionEnabled | Whether diversion is enabled - if false, only the forced relays are ON |
This method adjusts the state of the relays based on the current average power. If surplus power is available, it tries to turn ON relays in increasing order. If power is being imported, it tries to turn OFF relays in decreasing order. On a surplus too, a relay in battery mode (negative import threshold) that goes OFF does so in decreasing order, before any relay comes in. When diversion is disabled, the relays that are not forced are turned OFF. The minimum ON and OFF times, and the settle time after any change, always apply.
Definition at line 394 of file relay_engine.h.