|
3-phase PV router
|
The state of one relay, and its decisions. More...
#include <relay_engine.h>

Public Member Functions | |
| constexpr | Relay ()=delete |
| constexpr | Relay (const uint8_t _relay_pin) |
| Construct a new relay Config object with default parameters. | |
| constexpr | Relay (uint8_t _relay_pin, int16_t _surplusThreshold, int16_t _importThreshold) |
| Construct a new relay Config object with default/custom parameters. | |
| constexpr | Relay (uint8_t _relay_pin, int16_t _surplusThreshold, int16_t _importThreshold, uint16_t _minON, uint16_t _minOFF) |
| Construct a new relay Config object with custom parameters. | |
| constexpr auto | get_importThreshold () const |
| Get the import threshold which will turns OFF the relay. | |
| constexpr auto | get_minOFF () const |
| Get the minimum OFF-time in seconds. | |
| constexpr auto | get_minON () const |
| Get the minimum ON-time in seconds. | |
| constexpr auto | get_pin () const |
| Get the control pin of the relay. | |
| constexpr auto | get_surplusThreshold () const |
| Get the surplus threshold which will turns ON the relay. | |
| constexpr bool | hasValidMinimumTimes () const |
| Whether both minimum times fit in 16 bits of seconds (1092 minutes at most). | |
| void | inc_duration () const |
| Increment the duration of the current state. | |
| auto | isRelayON () const |
| Return the state. | |
| bool | proceed_forced_only (const uint16_t overrideBitmask) const |
| Proceed with the relay while diversion is disabled: ON only while forced. | |
| bool | proceed_relay (const int32_t currentAvgPower, const uint16_t overrideBitmask, const bool onAllowed=true) const |
| Proceed with the relay. | |
Private Member Functions | |
| bool | isForced (const uint16_t overrideBitmask) const |
| bool | try_switch (const bool on) const |
| Turn the relay ON or OFF if the 'time' condition is met. | |
Static Private Member Functions | |
| static constexpr int16_t | negativeOf (const int16_t value) |
| -abs(value), without the abs() macro of Arduino.h. | |
| static constexpr uint16_t | toSeconds (const uint16_t minutes) |
| Minutes to seconds, in 16 bits. | |
Private Attributes | |
| uint16_t | duration { 0 } |
| const int16_t | importThreshold { 200 } |
| const uint16_t | minOFF { 5 * 60 } |
| const uint16_t | minON { 5 * 60 } |
| const uint8_t | relay_pin { 0xff } |
| bool | relayIsON { false } |
| const int16_t | surplusThreshold { -1000 } |
The state of one relay, and its decisions.
On each change, Output::switched(pin, on) drives the pin (relayOutput, utils_relay.h); then the state changes, and the methods return true.
| Output | A type with a static switched(uint8_t pin, bool on), called on each change. |
Definition at line 70 of file relay_engine.h.
|
constexprdelete |
|
inlineexplicitconstexpr |
Construct a new relay Config object with default parameters.
| _relay_pin | Control pin for the relay |
Definition at line 80 of file relay_engine.h.
|
inlineconstexpr |
Construct a new relay Config object with default/custom parameters.
| _relay_pin | Control pin for the relay |
| _surplusThreshold | Surplus threshold to turn relay ON (positive value, e.g., 1000) |
| _importThreshold | Import threshold to turn relay OFF
|
Definition at line 95 of file relay_engine.h.

|
inlineconstexpr |
Construct a new relay Config object with custom parameters.
| _relay_pin | Control pin for the relay |
| _surplusThreshold | Surplus threshold to turn relay ON (positive value, e.g., 1000) |
| _importThreshold | Import threshold to turn relay OFF
|
| _minON | Minimum duration in minutes to leave relay ON |
| _minOFF | Minimum duration in minutes to leave relay OFF |
Definition at line 112 of file relay_engine.h.

|
inlineconstexpr |
Get the import threshold which will turns OFF the relay.
Definition at line 142 of file relay_engine.h.

|
inlineconstexpr |
Get the minimum OFF-time in seconds.
Definition at line 162 of file relay_engine.h.
|
inlineconstexpr |
Get the minimum ON-time in seconds.
Definition at line 152 of file relay_engine.h.
|
inlineconstexpr |
Get the control pin of the relay.
Definition at line 122 of file relay_engine.h.

|
inlineconstexpr |
Get the surplus threshold which will turns ON the relay.
Definition at line 132 of file relay_engine.h.

|
inlineconstexpr |
Whether both minimum times fit in 16 bits of seconds (1092 minutes at most).
validation.h refuses a relay for which it is false.
Definition at line 172 of file relay_engine.h.
|
inline |
Increment the duration of the current state.
This function must be called every second.
Definition at line 192 of file relay_engine.h.
|
inlineprivate |
Definition at line 260 of file relay_engine.h.


|
inline |
|
inlinestaticconstexprprivate |
-abs(value), without the abs() macro of Arduino.h.
Definition at line 255 of file relay_engine.h.

|
inline |
Proceed with the relay while diversion is disabled: ON only while forced.
| overrideBitmask | Override bitmask (local pins) |
The minimum ON and OFF times still apply.
Definition at line 236 of file relay_engine.h.

|
inline |
Proceed with the relay.
| currentAvgPower | Current average power |
| overrideBitmask | Override bitmask (local pins): the relay is forced ON while its bit is set |
| onAllowed | False to turn the relay OFF only (a forced relay is never turned OFF) |
Definition at line 208 of file relay_engine.h.

|
inlinestaticconstexprprivate |
Minutes to seconds, in 16 bits.
minutes * 60 would wrap silently (1093 minutes gave 44 seconds). Definition at line 249 of file relay_engine.h.

|
inlineprivate |
Turn the relay ON or OFF if the 'time' condition is met.
| on | True to turn the relay ON, false to turn it OFF |
Definition at line 271 of file relay_engine.h.

|
mutableprivate |
Duration of the current state
Definition at line 293 of file relay_engine.h.
|
private |
Import threshold to turn relay OFF (positive = import mode, negative = surplus mode)
Definition at line 289 of file relay_engine.h.
|
private |
Minimum duration in seconds the relay is turned OFF
Definition at line 291 of file relay_engine.h.
|
private |
Minimum duration in seconds the relay is turned ON
Definition at line 290 of file relay_engine.h.
|
private |
Pin associated with the relay (unused_pin)
Definition at line 287 of file relay_engine.h.
|
mutableprivate |
True if the relay is ON
Definition at line 294 of file relay_engine.h.
|
private |
Surplus threshold to turn relay ON
Definition at line 288 of file relay_engine.h.