Skip to content

Commit

Permalink
More reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
FredM67 committed May 1, 2023
1 parent 52f7f98 commit 405e9c3
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 38 deletions.
1 change: 1 addition & 0 deletions Mk2_3phase_RFdatalog_temp/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "debug.h"
#include "types.h"

#include "utils_dualtariff.h"
#include "utils_relay.h"
#include "utils_temp.h"

Expand Down
37 changes: 0 additions & 37 deletions Mk2_3phase_RFdatalog_temp/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
54 changes: 54 additions & 0 deletions Mk2_3phase_RFdatalog_temp/utils_dualtariff.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* @file utils_dualtariff.h
* @author Frédéric Metrich ([email protected])
* @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 <Arduino.h>

/** @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__
3 changes: 2 additions & 1 deletion Mk2_3phase_RFdatalog_temp/utils_temp.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#ifndef _UTILS_TEMP_H
#define _UTILS_TEMP_H

#include "config.h"
#include <Arduino.h>

#include "constants.h"

using ScratchPad = uint8_t[9];
Expand Down

0 comments on commit 405e9c3

Please sign in to comment.