3-phase PV router
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
relayOutput Class Reference

Relay diversion config and engine. 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 { 0xff }
 
bool relayIsON { false }
 
const int16_t surplusThreshold { -1000 }
 

Detailed Description

Relay diversion config and engine.

Definition at line 29 of file utils_relay.h.

Constructor & Destructor Documentation

◆ relayOutput() [1/4]

constexpr relayOutput::relayOutput ( )
constexprdelete

◆ relayOutput() [2/4]

constexpr relayOutput::relayOutput ( const uint8_t  _relay_pin)
inlineexplicitconstexpr

Construct a new relay Config object with default parameters.

Parameters
_relay_pinControl pin for the relay

Definition at line 39 of file utils_relay.h.

◆ relayOutput() [3/4]

constexpr relayOutput::relayOutput ( uint8_t  _relay_pin,
int16_t  _surplusThreshold,
int16_t  _importThreshold 
)
inlineconstexpr

Construct a new relay Config object with default/custom parameters.

Parameters
_relay_pinControl pin for the relay
_surplusThresholdSurplus threshold to turn relay ON
_importThresholdImport threshold to turn relay OFF

Definition at line 51 of file utils_relay.h.

◆ relayOutput() [4/4]

constexpr relayOutput::relayOutput ( uint8_t  _relay_pin,
int16_t  _surplusThreshold,
int16_t  _importThreshold,
uint16_t  _minON,
uint16_t  _minOFF 
)
inlineconstexpr

Construct a new relay Config object with custom parameters.

Parameters
_relay_pinControl pin for the relay
_surplusThresholdSurplus threshold to turn relay ON
_importThresholdImport threshold to turn relay OFF
_minONMinimum duration in minutes to leave relay ON
_minOFFMinimum duration in minutes to leave relay OFF

Definition at line 65 of file utils_relay.h.

Member Function Documentation

◆ get_importThreshold()

constexpr auto relayOutput::get_importThreshold ( ) const
inlineconstexpr

Get the import threshold which will turns OFF the relay.

Returns
constexpr auto

Definition at line 95 of file utils_relay.h.

Here is the caller graph for this function:

◆ get_minOFF()

constexpr auto relayOutput::get_minOFF ( ) const
inlineconstexpr

Get the minimum OFF-time in seconds.

Returns
constexpr auto

Definition at line 115 of file utils_relay.h.

Here is the caller graph for this function:

◆ get_minON()

constexpr auto relayOutput::get_minON ( ) const
inlineconstexpr

Get the minimum ON-time in seconds.

Returns
constexpr auto

Definition at line 105 of file utils_relay.h.

Here is the caller graph for this function:

◆ get_pin()

constexpr auto relayOutput::get_pin ( ) const
inlineconstexpr

Get the control pin of the relay.

Returns
constexpr auto

Definition at line 75 of file utils_relay.h.

Here is the caller graph for this function:

◆ get_surplusThreshold()

constexpr auto relayOutput::get_surplusThreshold ( ) const
inlineconstexpr

Get the surplus threshold which will turns ON the relay.

Returns
constexpr auto

Definition at line 85 of file utils_relay.h.

Here is the caller graph for this function:

◆ inc_duration()

void relayOutput::inc_duration ( ) const
inline

Increment the duration of the current state.

This function must be called every second.

Definition at line 135 of file utils_relay.h.

◆ isRelayON()

auto relayOutput::isRelayON ( ) const
inline

Return the state.

Returns
auto

Definition at line 125 of file utils_relay.h.

◆ printRelayConfiguration()

void relayOutput::printRelayConfiguration ( uint8_t  idx) const
inline

Print the configuration of the current relay-diversion.

Definition at line 166 of file utils_relay.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ proceed_relay()

bool relayOutput::proceed_relay ( const int32_t  currentAvgPower) const
inline

Proceed with the relay.

Returns
bool True if state has changed

Definition at line 148 of file utils_relay.h.

Here is the call graph for this function:

◆ try_turnOFF()

bool relayOutput::try_turnOFF ( ) const
inlineprivate

Turn OFF the relay if the 'time' condition is met.

Returns
bool True if state has changed

Definition at line 215 of file utils_relay.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ try_turnON()

bool relayOutput::try_turnON ( ) const
inlineprivate

Turn ON the relay if the 'time' condition is met.

Returns
bool True if state has changed

Definition at line 193 of file utils_relay.h.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ duration

uint16_t relayOutput::duration { 0 }
mutableprivate

Duration of the current state

Definition at line 239 of file utils_relay.h.

◆ importThreshold

const int16_t relayOutput::importThreshold { 200 }
private

Import threshold to turn relay OFF

Definition at line 235 of file utils_relay.h.

◆ minOFF

const uint16_t relayOutput::minOFF { 5 * 60 }
private

Minimum duration in seconds the relay is turned OFF

Definition at line 237 of file utils_relay.h.

◆ minON

const uint16_t relayOutput::minON { 5 * 60 }
private

Minimum duration in seconds the relay is turned ON

Definition at line 236 of file utils_relay.h.

◆ relay_pin

const uint8_t relayOutput::relay_pin { 0xff }
private

Pin associated with the relay

Definition at line 233 of file utils_relay.h.

◆ relayIsON

bool relayOutput::relayIsON { false }
mutableprivate

True if the relay is ON

Definition at line 240 of file utils_relay.h.

◆ surplusThreshold

const int16_t relayOutput::surplusThreshold { -1000 }
private

Surplus threshold to turn relay ON

Definition at line 234 of file utils_relay.h.


The documentation for this class was generated from the following file: