From 405e9c3cf5ddddbd059d4bc4bdd735bc2072eb5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Metrich?= <45318189+FredM67@users.noreply.github.com> Date: Mon, 1 May 2023 20:14:44 +0200 Subject: [PATCH] More reorganization --- Mk2_3phase_RFdatalog_temp/config.h | 1 + Mk2_3phase_RFdatalog_temp/types.h | 37 -------------- Mk2_3phase_RFdatalog_temp/utils_dualtariff.h | 54 ++++++++++++++++++++ Mk2_3phase_RFdatalog_temp/utils_temp.h | 3 +- 4 files changed, 57 insertions(+), 38 deletions(-) create mode 100644 Mk2_3phase_RFdatalog_temp/utils_dualtariff.h diff --git a/Mk2_3phase_RFdatalog_temp/config.h b/Mk2_3phase_RFdatalog_temp/config.h index 4adb915c..8e3348e4 100644 --- a/Mk2_3phase_RFdatalog_temp/config.h +++ b/Mk2_3phase_RFdatalog_temp/config.h @@ -27,6 +27,7 @@ #include "debug.h" #include "types.h" +#include "utils_dualtariff.h" #include "utils_relay.h" #include "utils_temp.h" diff --git a/Mk2_3phase_RFdatalog_temp/types.h b/Mk2_3phase_RFdatalog_temp/types.h index f9a232d5..2787ac6b 100644 --- a/Mk2_3phase_RFdatalog_temp/types.h +++ b/Mk2_3phase_RFdatalog_temp/types.h @@ -67,43 +67,6 @@ template< uint8_t N = 3, uint8_t S = 0 > class PayloadTx_struct int16_t temperature_x100[S]; /**< temperature in 100th of °C */ }; -/** @brief Config parameters for overriding a load - * @details This class allows the user to define when and how long a load will be forced at - * full power during off-peak period. - * - * For each load, the user defines a pair of values: pairForceLoad => { offset, duration }. - * The load will be started with full power at ('start_offpeak' + 'offset') for a duration of 'duration' - * - all values are in hours (if between -24 and 24) or in minutes. - * - if the offset is negative, it's calculated from the end of the off-peak period (ie -3 means 3 hours back from the end). - * - to leave the load at full power till the end of the off-peak period, set the duration to 'UINT16_MAX' (somehow infinite time) - */ -class pairForceLoad -{ -public: - constexpr pairForceLoad() = default; - explicit constexpr pairForceLoad(int16_t _iStartOffset) - : iStartOffset(_iStartOffset), uiDuration(UINT16_MAX) - { - } - constexpr pairForceLoad(int16_t _iStartOffset, uint16_t _uiDuration) - : iStartOffset(_iStartOffset), uiDuration(_uiDuration) - { - } - - constexpr int16_t getStartOffset() const - { - return iStartOffset; - } - constexpr uint16_t getDuration() const - { - return uiDuration; - } - -private: - int16_t iStartOffset{ 0 }; /**< the start offset from the off-peak begin in hours or minutes */ - uint16_t uiDuration{ UINT16_MAX }; /**< the duration for overriding the load in hours or minutes */ -}; - /** * @brief Helper function to retrieve the dimension of a C-array * diff --git a/Mk2_3phase_RFdatalog_temp/utils_dualtariff.h b/Mk2_3phase_RFdatalog_temp/utils_dualtariff.h new file mode 100644 index 00000000..9c3b8371 --- /dev/null +++ b/Mk2_3phase_RFdatalog_temp/utils_dualtariff.h @@ -0,0 +1,54 @@ +/** + * @file utils_dualtariff.h + * @author Frédéric Metrich (frederic.metrich@live.fr) + * @brief Some utility functions for dual tariff feature + * @version 0.1 + * @date 2023-05-01 + * + * @copyright Copyright (c) 2023 + * + */ + +#ifndef __UTILS_DUALTARIFF_H__ +#define __UTILS_DUALTARIFF_H__ + +#include + +/** @brief Config parameters for overriding a load + * @details This class allows the user to define when and how long a load will be forced at + * full power during off-peak period. + * + * For each load, the user defines a pair of values: pairForceLoad => { offset, duration }. + * The load will be started with full power at ('start_offpeak' + 'offset') for a duration of 'duration' + * - all values are in hours (if between -24 and 24) or in minutes. + * - if the offset is negative, it's calculated from the end of the off-peak period (ie -3 means 3 hours back from the end). + * - to leave the load at full power till the end of the off-peak period, set the duration to 'UINT16_MAX' (somehow infinite time) + */ +class pairForceLoad +{ +public: + constexpr pairForceLoad() = default; + explicit constexpr pairForceLoad(int16_t _iStartOffset) + : iStartOffset(_iStartOffset), uiDuration(UINT16_MAX) + { + } + constexpr pairForceLoad(int16_t _iStartOffset, uint16_t _uiDuration) + : iStartOffset(_iStartOffset), uiDuration(_uiDuration) + { + } + + constexpr int16_t getStartOffset() const + { + return iStartOffset; + } + constexpr uint16_t getDuration() const + { + return uiDuration; + } + +private: + int16_t iStartOffset{ 0 }; /**< the start offset from the off-peak begin in hours or minutes */ + uint16_t uiDuration{ UINT16_MAX }; /**< the duration for overriding the load in hours or minutes */ +}; + +#endif // __UTILS_DUALTARIFF_H__ diff --git a/Mk2_3phase_RFdatalog_temp/utils_temp.h b/Mk2_3phase_RFdatalog_temp/utils_temp.h index 7750aa5b..9ab61950 100644 --- a/Mk2_3phase_RFdatalog_temp/utils_temp.h +++ b/Mk2_3phase_RFdatalog_temp/utils_temp.h @@ -12,7 +12,8 @@ #ifndef _UTILS_TEMP_H #define _UTILS_TEMP_H -#include "config.h" +#include + #include "constants.h" using ScratchPad = uint8_t[9];