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;
|
||||
}
|
||||
|
||||
@ -54,3 +54,5 @@ typedef struct _ControlDay
|
||||
|
||||
void initControl(void);
|
||||
eControlState getControlState(void);
|
||||
eControlWeekday getControlCurrentWeekday(void);
|
||||
sControlTemperatureEntry getControlCurrentTemperatureEntry(void);
|
||||
|
||||
@ -254,6 +254,31 @@ void taskMetrics(void *pvParameters)
|
||||
aMetrics[u16MetricCounter].u8MetricValue = getControlState();
|
||||
u16MetricCounter++;
|
||||
|
||||
// Control Current Weekday
|
||||
strcpy(aMetrics[u16MetricCounter].caMetricName, "control_current_weekday");
|
||||
aMetrics[u16MetricCounter].type = INTEGER_U8;
|
||||
aMetrics[u16MetricCounter].u8MetricValue = getControlCurrentWeekday();
|
||||
u16MetricCounter++;
|
||||
|
||||
// Control Current Entry Time
|
||||
strcpy(aMetrics[u16MetricCounter].caMetricName, "control_current_entry_time");
|
||||
aMetrics[u16MetricCounter].type = INTEGER_64;
|
||||
int64_t i64SecondsSinceMidnight = (getControlCurrentTemperatureEntry().timestamp.hour * 60U * 60U) + (getControlCurrentTemperatureEntry().timestamp.minute * 60U);
|
||||
aMetrics[u16MetricCounter].i64MetricValue = i64SecondsSinceMidnight;
|
||||
u16MetricCounter++;
|
||||
|
||||
// Control Current Entry Chamber Temperature
|
||||
strcpy(aMetrics[u16MetricCounter].caMetricName, "control_current_entry_chamber_temperature");
|
||||
aMetrics[u16MetricCounter].type = FLOAT;
|
||||
aMetrics[u16MetricCounter].fMetricValue = getControlCurrentTemperatureEntry().fChamberTemperature;
|
||||
u16MetricCounter++;
|
||||
|
||||
// Control Current Entry Return Flow Temperature
|
||||
strcpy(aMetrics[u16MetricCounter].caMetricName, "control_current_entry_return_flow_temperature");
|
||||
aMetrics[u16MetricCounter].type = FLOAT;
|
||||
aMetrics[u16MetricCounter].fMetricValue = getControlCurrentTemperatureEntry().fReturnFlowTemperature;
|
||||
u16MetricCounter++;
|
||||
|
||||
// SNTP State
|
||||
strcpy(aMetrics[u16MetricCounter].caMetricName, "sntp_state");
|
||||
aMetrics[u16MetricCounter].type = INTEGER_U8;
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
#define HTML_RESPONSE_SIZE 4096U
|
||||
#define METRIC_NAME_MAX_SIZE 64U
|
||||
#define METRIC_MAX_COUNT 34U
|
||||
#define METRIC_MAX_COUNT 38U
|
||||
|
||||
typedef enum _MetricValueType
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user