3-phase PV router
Loading...
Searching...
No Matches
LoadPriorities::Switching< N > Struct Template Reference

The switching decision, once per mains cycle, and its state. More...

#include <load_priorities.h>

Public Member Functions

void onHighEnergy (uint8_t(&priorities)[N], const int32_t &energy, const int32_t capacity)
 The energy level is high: may switch the next load ON.
 
void onLowEnergy (uint8_t(&priorities)[N], const int32_t &energy)
 The energy level is low: may switch the last load ON to OFF.
 
void onNewCycle (uint8_t(&priorities)[N], const int32_t &energy, const Bucket &bucket)
 The decision of one mains cycle: may switch one load ON or OFF.
 

Public Attributes

uint8_t activeLoad { N }
 
int32_t lowerThreshold { 0 }
 
uint8_t postTransitionCount { 0 }
 
bool recentTransition { false }
 
int32_t upperThreshold { 0 }
 

Static Public Attributes

static constexpr uint8_t POST_TRANSITION_MAX_COUNT { 3 }
 

Detailed Description

template<uint8_t N>
struct LoadPriorities::Switching< N >

The switching decision, once per mains cycle, and its state.

Template Parameters
Nnumber of loads

Definition at line 152 of file load_priorities.h.

Member Function Documentation

◆ onHighEnergy()

template<uint8_t N>
void LoadPriorities::Switching< N >::onHighEnergy ( uint8_t(&) priorities[N],
const int32_t & energy,
const int32_t capacity )
inline

The energy level is high: may switch the next load ON.

During a post-transition period, the upper threshold follows any increase of the energy level, and only the load switched last may switch.

Definition at line 209 of file load_priorities.h.

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

◆ onLowEnergy()

template<uint8_t N>
void LoadPriorities::Switching< N >::onLowEnergy ( uint8_t(&) priorities[N],
const int32_t & energy )
inline

The energy level is low: may switch the last load ON to OFF.

During a post-transition period, the lower threshold follows any decrease of the energy level, and only the load switched last may switch.

Definition at line 251 of file load_priorities.h.

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

◆ onNewCycle()

template<uint8_t N>
void LoadPriorities::Switching< N >::onNewCycle ( uint8_t(&) priorities[N],
const int32_t & energy,
const Bucket & bucket )
inline

The decision of one mains cycle: may switch one load ON or OFF.

Not inlined on purpose, as updatePhysicalLoadStates() in processing.h: inlined, it grew the ISR by 76 bytes, with 4 more registers to save and a stack frame on every call. Called once per mains cycle, it costs a call and a return there. Grid simulator: average 0.1 cycle less, one-off max 2 to 8 cycles more; with remote loads, 32 cycles less on average and 77 less at most.

Parameters
energythe level of the energy bucket

Definition at line 173 of file load_priorities.h.

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

Member Data Documentation

◆ activeLoad

template<uint8_t N>
uint8_t LoadPriorities::Switching< N >::activeLoad { N }

the logical load switched last

Definition at line 160 of file load_priorities.h.

◆ lowerThreshold

template<uint8_t N>
int32_t LoadPriorities::Switching< N >::lowerThreshold { 0 }

dynamic lower threshold

Definition at line 156 of file load_priorities.h.

◆ POST_TRANSITION_MAX_COUNT

template<uint8_t N>
uint8_t LoadPriorities::Switching< N >::POST_TRANSITION_MAX_COUNT { 3 }
staticconstexpr

allows each transition to take effect

Definition at line 154 of file load_priorities.h.

◆ postTransitionCount

template<uint8_t N>
uint8_t LoadPriorities::Switching< N >::postTransitionCount { 0 }

counts the number of cycles since the last transition

Definition at line 159 of file load_priorities.h.

◆ recentTransition

template<uint8_t N>
bool LoadPriorities::Switching< N >::recentTransition { false }

a load state has been recently toggled

Definition at line 158 of file load_priorities.h.

◆ upperThreshold

template<uint8_t N>
int32_t LoadPriorities::Switching< N >::upperThreshold { 0 }

dynamic upper threshold

Definition at line 157 of file load_priorities.h.


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