3-phase PV router
Loading...
Searching...
No Matches
utils_dualtariff.h File Reference

Some utility functions for dual tariff feature. More...

#include <stdint.h>
#include "config_types.h"
Include dependency graph for utils_dualtariff.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  DualTariff::Boost
 A boost resolved for a given off-peak duration: its window in ms and its target masks. More...
 
class  BoostSchedule< N, MaxPins >
 The scheduled boosts: a window and the bitmasks of its targets, for each entry. More...
 
class  BoostSchedule< 0, MaxPins >
 No boost at all. More...
 
struct  BoostSchedule< N, MaxPins >::Entry
 

Namespaces

namespace  DualTariff
 The windows of the scheduled boosts, in milliseconds from the start of the off-peak period.
 

Functions

 BoostSchedule () -> BoostSchedule< 0 >
 Deduction guide: no argument, no boost.
 
template<uint8_t MaxPins, uint8_t N>
 BoostSchedule (const BoostEntry< MaxPins >(&)[N]) -> BoostSchedule< N, MaxPins >
 Deduction guide, as for OverrideTable.
 
template<uint8_t N, uint8_t MaxPins, typename Map>
 BoostSchedule (const ScheduledBoosts< N, MaxPins > &, const Map &) -> BoostSchedule< N, MaxPins >
 Deduction guide: from the boosts of config.h.
 
constexpr bool DualTariff::endsWithinOffPeak (const BoostWindow &window, const uint8_t offPeakHours)
 Whether a window with FOR() ends within the off-peak period (its end may be the end of the period): a longer one is a mistake, since the meter would cut it short.
 
constexpr bool DualTariff::hasLength (const BoostWindow &window)
 Whether the boost lasts at all: a length of 0 is no boost.
 
constexpr bool DualTariff::inWindow (const uint32_t elapsed, const uint32_t start, const uint32_t end)
 Whether the boost is in its window.
 
template<uint8_t N, uint8_t MaxPins>
constexpr Boost DualTariff::resolve (const BoostSchedule< N, MaxPins > &boosts, const uint8_t i, const uint8_t offPeakHours)
 Boost i of boosts, for an off-peak period of offPeakHours.
 
constexpr int32_t DualTariff::startInMinutes (const BoostWindow &window, const uint8_t offPeakHours)
 The start of the window, in minutes from the start of the off-peak period: negative if before it.
 
constexpr bool DualTariff::startsWithinOffPeak (const BoostWindow &window, const uint8_t offPeakHours)
 Whether the window starts within the off-peak period: otherwise, it would never open.
 
constexpr uint32_t DualTariff::windowEnd (const BoostWindow &window, const uint8_t offPeakHours)
 The end of the boost window (excluded), in ms from the start of the off-peak period.
 
constexpr uint32_t DualTariff::windowStart (const BoostWindow &window, const uint8_t offPeakHours)
 The start of the boost window, in ms from the start of the off-peak period.
 

Detailed Description

Some utility functions for dual tariff feature.

Author
Frédéric Metrich (frede.nosp@m.ric..nosp@m.metri.nosp@m.ch@l.nosp@m.ive.f.nosp@m.r)
Version
0.2
Date
2026-11-21
Note
This header has no Arduino dependency, so it can be exercised by the native test suite (test/native/test_dual_tariff).

Definition in file utils_dualtariff.h.

Function Documentation

◆ BoostSchedule() [1/3]

BoostSchedule ( ) -> BoostSchedule< 0 >

Deduction guide: no argument, no boost.

◆ BoostSchedule() [2/3]

template<uint8_t MaxPins, uint8_t N>
BoostSchedule ( const BoostEntry< MaxPins > (&)[N]) -> BoostSchedule< N, MaxPins >

Deduction guide, as for OverrideTable.

◆ BoostSchedule() [3/3]

template<uint8_t N, uint8_t MaxPins, typename Map>
BoostSchedule ( const ScheduledBoosts< N, MaxPins > & ,
const Map &  ) -> BoostSchedule< N, MaxPins >

Deduction guide: from the boosts of config.h.