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 41 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 51 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 |
_importThreshold | Import threshold to turn relay OFF |
Definition at line 63 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 |
_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 77 of file utils_relay.h.
|
inlineconstexpr |
Get the import threshold which will turns OFF the relay.
Definition at line 107 of file utils_relay.h.
|
inlineconstexpr |
Get the minimum OFF-time in seconds.
Definition at line 127 of file utils_relay.h.
|
inlineconstexpr |
Get the minimum ON-time in seconds.
Definition at line 117 of file utils_relay.h.
|
inlineconstexpr |
Get the control pin of the relay.
Definition at line 87 of file utils_relay.h.
|
inlineconstexpr |
Get the surplus threshold which will turns ON the relay.
Definition at line 97 of file utils_relay.h.
|
inline |
Increment the duration of the current state.
This function must be called every second.
Definition at line 147 of file utils_relay.h.
|
inline |
|
inline |
Print the configuration of the current relay-diversion.
Definition at line 178 of file utils_relay.h.
|
inline |
Proceed with the relay.
Definition at line 160 of file utils_relay.h.
|
inlineprivate |
Turn OFF the relay if the 'time' condition is met.
Definition at line 227 of file utils_relay.h.
|
inlineprivate |
Turn ON the relay if the 'time' condition is met.
Definition at line 205 of file utils_relay.h.
|
mutableprivate |
Duration of the current state
Definition at line 251 of file utils_relay.h.
|
private |
Import threshold to turn relay OFF
Definition at line 247 of file utils_relay.h.
|
private |
Minimum duration in seconds the relay is turned OFF
Definition at line 249 of file utils_relay.h.
|
private |
Minimum duration in seconds the relay is turned ON
Definition at line 248 of file utils_relay.h.
|
private |
Pin associated with the relay
Definition at line 245 of file utils_relay.h.
|
mutableprivate |
True if the relay is ON
Definition at line 252 of file utils_relay.h.
|
private |
Surplus threshold to turn relay ON
Definition at line 246 of file utils_relay.h.