3-phase PV router
|
Represents a single relay configuration and its behavior. More...
#include <utils_relay.h>
Public Member Functions | |
constexpr | relayOutput ()=delete |
constexpr | relayOutput (const uint8_t _relay_pin) |
Construct a new relay Config object with default parameters. | |
constexpr | relayOutput (uint8_t _relay_pin, int16_t _surplusThreshold, int16_t _importThreshold) |
Construct a new relay Config object with default/custom parameters. | |
constexpr | relayOutput (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. | |
void | inc_duration () const |
Increment the duration of the current state. | |
auto | isRelayON () const |
Return the state. | |
void | printRelayConfiguration (uint8_t idx) const |
Print the configuration of the current relay-diversion. | |
bool | proceed_relay (const int32_t currentAvgPower) const |
Proceed with the relay. | |
Private Member Functions | |
bool | try_turnOFF () const |
Turn OFF the relay if the 'time' condition is met. | |
bool | try_turnON () const |
Turn ON the relay if the 'time' condition is met. | |
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 { unused_pin } |
bool | relayIsON { false } |
const int16_t | surplusThreshold { -1000 } |
Represents a single relay configuration and its behavior.
The relayOutput
class encapsulates the configuration and state management of a single relay. It provides methods to control the relay based on surplus and import thresholds, as well as minimum ON/OFF durations.
Definition at line 40 of file utils_relay.h.
|
constexprdelete |
|
inlineexplicitconstexpr |
Construct a new relay Config object with default parameters.
_relay_pin | Control pin for the relay |
Definition at line 50 of file utils_relay.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 65 of file utils_relay.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 82 of file utils_relay.h.
|
inlineconstexpr |
Get the import threshold which will turns OFF the relay.
Definition at line 112 of file utils_relay.h.
|
inlineconstexpr |
Get the minimum OFF-time in seconds.
Definition at line 132 of file utils_relay.h.
|
inlineconstexpr |
Get the minimum ON-time in seconds.
Definition at line 122 of file utils_relay.h.
|
inlineconstexpr |
Get the control pin of the relay.
Definition at line 92 of file utils_relay.h.
|
inlineconstexpr |
Get the surplus threshold which will turns ON the relay.
Definition at line 102 of file utils_relay.h.
|
inline |
Increment the duration of the current state.
This function must be called every second.
Definition at line 152 of file utils_relay.h.
|
inline |
|
inline |
Print the configuration of the current relay-diversion.
Definition at line 198 of file utils_relay.h.
|
inline |
Proceed with the relay.
Definition at line 165 of file utils_relay.h.
|
inlineprivate |
Turn OFF the relay if the 'time' condition is met.
Definition at line 257 of file utils_relay.h.
|
inlineprivate |
Turn ON the relay if the 'time' condition is met.
Definition at line 235 of file utils_relay.h.
|
mutableprivate |
Duration of the current state
Definition at line 281 of file utils_relay.h.
|
private |
Import threshold to turn relay OFF (positive = import mode, negative = surplus mode)
Definition at line 277 of file utils_relay.h.
|
private |
Minimum duration in seconds the relay is turned OFF
Definition at line 279 of file utils_relay.h.
|
private |
Minimum duration in seconds the relay is turned ON
Definition at line 278 of file utils_relay.h.
|
private |
Pin associated with the relay
Definition at line 275 of file utils_relay.h.
|
mutableprivate |
True if the relay is ON
Definition at line 282 of file utils_relay.h.
|
private |
Surplus threshold to turn relay ON
Definition at line 276 of file utils_relay.h.