Export current entry temperatures as metrics
This commit is contained in:
@ -22,9 +22,8 @@
|
||||
|
||||
static const char *TAG = "smart-oil-heater-control-system-control";
|
||||
static eControlState sControlState = CONTROL_STARTING;
|
||||
|
||||
// Control table for daily schedules
|
||||
static sControlDay aControlTable[] = {
|
||||
static const sControlDay aControlTable[] = {
|
||||
{MONDAY, 2U, {{{4, 45}, RETURN_FLOW_TEMPERATURE_LOWER_LIMIT_DAY, CHAMBER_TEMPERATURE_TARGET}, {{22, 0}, RETURN_FLOW_TEMPERATURE_LOWER_LIMIT_NIGHT, CHAMBER_TEMPERATURE_TARGET}}},
|
||||
{TUESDAY, 2U, {{{4, 45}, RETURN_FLOW_TEMPERATURE_LOWER_LIMIT_DAY, CHAMBER_TEMPERATURE_TARGET}, {{22, 0}, RETURN_FLOW_TEMPERATURE_LOWER_LIMIT_NIGHT, CHAMBER_TEMPERATURE_TARGET}}},
|
||||
{WEDNESDAY, 2U, {{{4, 45}, RETURN_FLOW_TEMPERATURE_LOWER_LIMIT_DAY, CHAMBER_TEMPERATURE_TARGET}, {{22, 0}, RETURN_FLOW_TEMPERATURE_LOWER_LIMIT_NIGHT, CHAMBER_TEMPERATURE_TARGET}}},
|
||||
@ -33,11 +32,11 @@ static sControlDay aControlTable[] = {
|
||||
{SATURDAY, 2U, {{{6, 45}, RETURN_FLOW_TEMPERATURE_LOWER_LIMIT_DAY, CHAMBER_TEMPERATURE_TARGET}, {{23, 30}, RETURN_FLOW_TEMPERATURE_LOWER_LIMIT_NIGHT, CHAMBER_TEMPERATURE_TARGET}}},
|
||||
{SUNDAY, 2U, {{{6, 45}, RETURN_FLOW_TEMPERATURE_LOWER_LIMIT_DAY, CHAMBER_TEMPERATURE_TARGET}, {{22, 30}, RETURN_FLOW_TEMPERATURE_LOWER_LIMIT_NIGHT, CHAMBER_TEMPERATURE_TARGET}}},
|
||||
};
|
||||
static sControlTemperatureEntry currentControlEntry = aControlTable[0].aTemperatureEntries[0];
|
||||
|
||||
// Function prototypes
|
||||
void taskControl(void *pvParameters);
|
||||
eControlWeekday getCurrentWeekday(void);
|
||||
sControlTemperatureEntry getCurrentTemperatureEntry(void);
|
||||
void findControlCurrentTemperatureEntry(void);
|
||||
|
||||
void initControl(void)
|
||||
{
|
||||
@ -101,7 +100,7 @@ void taskControl(void *pvParameters)
|
||||
continue;
|
||||
}
|
||||
|
||||
sControlTemperatureEntry currentControlEntry = getCurrentTemperatureEntry();
|
||||
sControlTemperatureEntry currentControlEntry = getControlCurrentTemperatureEntry();
|
||||
|
||||
if (getOutdoorTemperature().average60s.fValue >= SUMMER_MODE_TEMPERATURE_THRESHOLD_HIGH)
|
||||
{
|
||||
@ -192,7 +191,7 @@ eControlState getControlState(void)
|
||||
return sControlState;
|
||||
}
|
||||
|
||||
eControlWeekday getCurrentWeekday(void)
|
||||
eControlWeekday getControlCurrentWeekday(void)
|
||||
{
|
||||
time_t now;
|
||||
struct tm *timeinfo;
|
||||
@ -204,10 +203,9 @@ eControlWeekday getCurrentWeekday(void)
|
||||
return (eControlWeekday)((day == 0) ? 6 : day - 1);
|
||||
}
|
||||
|
||||
sControlTemperatureEntry getCurrentTemperatureEntry(void)
|
||||
void findControlCurrentTemperatureEntry(void)
|
||||
{
|
||||
sControlTemperatureEntry result = aControlTable[0].aTemperatureEntries[0];
|
||||
eControlWeekday currentDay = getCurrentWeekday();
|
||||
eControlWeekday currentDay = getControlCurrentWeekday();
|
||||
|
||||
time_t now;
|
||||
struct tm timeinfo;
|
||||
@ -225,10 +223,14 @@ sControlTemperatureEntry getCurrentTemperatureEntry(void)
|
||||
(aControlTable[i].day == currentDay && aControlTable[i].aTemperatureEntries[j].timestamp.hour > hour) ||
|
||||
(aControlTable[i].day == currentDay && aControlTable[i].aTemperatureEntries[j].timestamp.hour == hour && aControlTable[i].aTemperatureEntries[j].timestamp.minute >= minute))
|
||||
{
|
||||
return aControlTable[i].aTemperatureEntries[j];
|
||||
currentControlEntry = aControlTable[i].aTemperatureEntries[j];
|
||||
}
|
||||
result = aControlTable[i].aTemperatureEntries[j];
|
||||
currentControlEntry = aControlTable[i].aTemperatureEntries[j];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
sControlTemperatureEntry getControlCurrentTemperatureEntry(void)
|
||||
{
|
||||
return currentControlEntry;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user