3-phase PV router
Loading...
Searching...
No Matches
relayOutput Class Reference

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 }
 

Detailed Description

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.

  • Relay Control: The relay is turned ON when the surplus threshold is exceeded and turned OFF when the import threshold is crossed.
  • Time Constraints: Minimum ON and OFF durations ensure stable operation.
  • State Management: The class tracks the relay's current state and the duration of its current state.

Definition at line 41 of file utils_relay.h.

Constructor & Destructor Documentation

◆ relayOutput() [1/4]

relayOutput::relayOutput ( )
constexprdelete

◆ relayOutput() [2/4]

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 51 of file utils_relay.h.

◆ relayOutput() [3/4]

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 63 of file utils_relay.h.

◆ relayOutput() [4/4]

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 77 of file utils_relay.h.

Member Function Documentation

◆ get_importThreshold()

auto relayOutput::get_importThreshold ( ) const
inlineconstexpr

Get the import threshold which will turns OFF the relay.

Returns
constexpr auto

Definition at line 107 of file utils_relay.h.

Here is the caller graph for this function:

◆ get_minOFF()

auto relayOutput::get_minOFF ( ) const
inlineconstexpr

Get the minimum OFF-time in seconds.

Returns
constexpr auto

Definition at line 127 of file utils_relay.h.

Here is the caller graph for this function:

◆ get_minON()

auto relayOutput::get_minON ( ) const
inlineconstexpr

Get the minimum ON-time in seconds.

Returns
constexpr auto

Definition at line 117 of file utils_relay.h.

Here is the caller graph for this function:

◆ get_pin()

auto relayOutput::get_pin ( ) const
inlineconstexpr

Get the control pin of the relay.

Returns
constexpr auto

Definition at line 87 of file utils_relay.h.

Here is the caller graph for this function:

◆ get_surplusThreshold()

auto relayOutput::get_surplusThreshold ( ) const
inlineconstexpr

Get the surplus threshold which will turns ON the relay.

Returns
constexpr auto

Definition at line 97 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 147 of file utils_relay.h.

◆ isRelayON()

auto relayOutput::isRelayON ( ) const
inline

Return the state.

Returns
auto

Definition at line 137 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 178 of file utils_relay.h.

Here is the call 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 160 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 227 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 205 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 251 of file utils_relay.h.

◆ importThreshold

const int16_t relayOutput::importThreshold { 200 }
private

Import threshold to turn relay OFF

Definition at line 247 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 249 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 248 of file utils_relay.h.

◆ relay_pin

const uint8_t relayOutput::relay_pin { unused_pin }
private

Pin associated with the relay

Definition at line 245 of file utils_relay.h.

◆ relayIsON

bool relayOutput::relayIsON { false }
mutableprivate

True if the relay is ON

Definition at line 252 of file utils_relay.h.

◆ surplusThreshold

const int16_t relayOutput::surplusThreshold { -1000 }
private

Surplus threshold to turn relay ON

Definition at line 246 of file utils_relay.h.


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