increase metrics task stack to support more metrics

This commit is contained in:
Hendrik Schutter 2024-12-26 18:12:39 +01:00
parent 655d890a0f
commit 29223c0070
2 changed files with 34 additions and 35 deletions

View File

@ -32,7 +32,7 @@ void initMetrics(void)
BaseType_t taskCreated = xTaskCreate( BaseType_t taskCreated = xTaskCreate(
taskMetrics, // Function to implement the task taskMetrics, // Function to implement the task
"taskMetrics", // Task name "taskMetrics", // Task name
16384, // Stack size (in words, not bytes) 32768, // Stack size (in words, not bytes)
NULL, // Parameters to the task function (none in this case) NULL, // Parameters to the task function (none in this case)
5, // Task priority (higher number = higher priority) 5, // Task priority (higher number = higher priority)
NULL // Task handle (optional) NULL // Task handle (optional)
@ -56,13 +56,13 @@ void taskMetrics(void *pvParameters)
u16MetricCounter = 0U; u16MetricCounter = 0U;
/*Burner Error State*/ // Burner Error State
strcpy(aMetrics[u16MetricCounter].caMetricName, "burner_fault_pending"); strcpy(aMetrics[u16MetricCounter].caMetricName, "burner_fault_pending");
aMetrics[u16MetricCounter].type = INTEGER_U8; aMetrics[u16MetricCounter].type = INTEGER_U8;
aMetrics[u16MetricCounter].u8MetricValue = getBurnerError(); aMetrics[u16MetricCounter].u8MetricValue = getBurnerError();
u16MetricCounter++; u16MetricCounter++;
/*Circulation Pump State*/ // Circulation Pump State
if (getCirculationPumpState() == ENABLED) if (getCirculationPumpState() == ENABLED)
{ {
strcpy(aMetrics[u16MetricCounter].caMetricName, "circulation_pump_enabled"); strcpy(aMetrics[u16MetricCounter].caMetricName, "circulation_pump_enabled");
@ -78,7 +78,7 @@ void taskMetrics(void *pvParameters)
u16MetricCounter++; u16MetricCounter++;
} }
/*Burner State*/ // Burner State
if (getBurnerState() == ENABLED) if (getBurnerState() == ENABLED)
{ {
strcpy(aMetrics[u16MetricCounter].caMetricName, "burner_enabled"); strcpy(aMetrics[u16MetricCounter].caMetricName, "burner_enabled");
@ -94,7 +94,7 @@ void taskMetrics(void *pvParameters)
u16MetricCounter++; u16MetricCounter++;
} }
/*Safety Contact State*/ // Safety Contact State
if (getSafetyControlState() == ENABLED) if (getSafetyControlState() == ENABLED)
{ {
strcpy(aMetrics[u16MetricCounter].caMetricName, "safety_contact_enabled"); strcpy(aMetrics[u16MetricCounter].caMetricName, "safety_contact_enabled");
@ -110,19 +110,19 @@ void taskMetrics(void *pvParameters)
u16MetricCounter++; u16MetricCounter++;
} }
/*Chamber Temperature*/ // Chamber Temperature
strcpy(aMetrics[u16MetricCounter].caMetricName, "chamber_temperature"); strcpy(aMetrics[u16MetricCounter].caMetricName, "chamber_temperature");
aMetrics[u16MetricCounter].type = FLOAT; aMetrics[u16MetricCounter].type = FLOAT;
aMetrics[u16MetricCounter].fMetricValue = getChamberTemperature().fCurrentValue; aMetrics[u16MetricCounter].fMetricValue = getChamberTemperature().fCurrentValue;
u16MetricCounter++; u16MetricCounter++;
/*Chamber Temperature Average 10s*/ // Chamber Temperature Average 10s
strcpy(aMetrics[u16MetricCounter].caMetricName, "chamber_temperature_avg10"); strcpy(aMetrics[u16MetricCounter].caMetricName, "chamber_temperature_avg10");
aMetrics[u16MetricCounter].type = FLOAT; aMetrics[u16MetricCounter].type = FLOAT;
aMetrics[u16MetricCounter].fMetricValue = getChamberTemperature().average10s.fValue; aMetrics[u16MetricCounter].fMetricValue = getChamberTemperature().average10s.fValue;
u16MetricCounter++; u16MetricCounter++;
/*Chamber Temperature Average 60s*/ // Chamber Temperature Average 60s
strcpy(aMetrics[u16MetricCounter].caMetricName, "chamber_temperature_avg60"); strcpy(aMetrics[u16MetricCounter].caMetricName, "chamber_temperature_avg60");
aMetrics[u16MetricCounter].type = FLOAT; aMetrics[u16MetricCounter].type = FLOAT;
aMetrics[u16MetricCounter].fMetricValue = getChamberTemperature().average60s.fValue; aMetrics[u16MetricCounter].fMetricValue = getChamberTemperature().average60s.fValue;
@ -133,70 +133,68 @@ void taskMetrics(void *pvParameters)
aMetrics[u16MetricCounter].type = FLOAT; aMetrics[u16MetricCounter].type = FLOAT;
aMetrics[u16MetricCounter].fMetricValue = getChamberTemperature().predict10s.fValue; aMetrics[u16MetricCounter].fMetricValue = getChamberTemperature().predict10s.fValue;
u16MetricCounter++; u16MetricCounter++;
/*
// Chamber Temperature Predict 60s // Chamber Temperature Predict 60s
strcpy(aMetrics[u16MetricCounter].caMetricName, "chamber_temperature_pred90"); strcpy(aMetrics[u16MetricCounter].caMetricName, "chamber_temperature_pred60");
aMetrics[u16MetricCounter].type = FLOAT; aMetrics[u16MetricCounter].type = FLOAT;
aMetrics[u16MetricCounter].fMetricValue = getChamberTemperature().predict60s.fValue; aMetrics[u16MetricCounter].fMetricValue = getChamberTemperature().predict60s.fValue;
u16MetricCounter++; u16MetricCounter++;
*/ // Inlet Flow Temperature
/*Inlet Flow Temperature*/
strcpy(aMetrics[u16MetricCounter].caMetricName, "inlet_flow_temperature"); strcpy(aMetrics[u16MetricCounter].caMetricName, "inlet_flow_temperature");
aMetrics[u16MetricCounter].type = FLOAT; aMetrics[u16MetricCounter].type = FLOAT;
aMetrics[u16MetricCounter].fMetricValue = getInletFlowTemperature().fCurrentValue; aMetrics[u16MetricCounter].fMetricValue = getInletFlowTemperature().fCurrentValue;
u16MetricCounter++; u16MetricCounter++;
/*Inlet Flow Temperature Average 10s*/ // Inlet Flow Temperature Average 10s
strcpy(aMetrics[u16MetricCounter].caMetricName, "inlet_flow_temperature_avg10"); strcpy(aMetrics[u16MetricCounter].caMetricName, "inlet_flow_temperature_avg10");
aMetrics[u16MetricCounter].type = FLOAT; aMetrics[u16MetricCounter].type = FLOAT;
aMetrics[u16MetricCounter].fMetricValue = getInletFlowTemperature().average10s.fValue; aMetrics[u16MetricCounter].fMetricValue = getInletFlowTemperature().average10s.fValue;
u16MetricCounter++; u16MetricCounter++;
/*Inlet Flow Temperature Average 60s*/ // Inlet Flow Temperature Average 60s
strcpy(aMetrics[u16MetricCounter].caMetricName, "inlet_flow_temperature_avg60"); strcpy(aMetrics[u16MetricCounter].caMetricName, "inlet_flow_temperature_avg60");
aMetrics[u16MetricCounter].type = FLOAT; aMetrics[u16MetricCounter].type = FLOAT;
aMetrics[u16MetricCounter].fMetricValue = getInletFlowTemperature().average60s.fValue; aMetrics[u16MetricCounter].fMetricValue = getInletFlowTemperature().average60s.fValue;
u16MetricCounter++; u16MetricCounter++;
/*Outdoor Temperature*/ // Outdoor Temperature
strcpy(aMetrics[u16MetricCounter].caMetricName, "outdoor_temperature"); strcpy(aMetrics[u16MetricCounter].caMetricName, "outdoor_temperature");
aMetrics[u16MetricCounter].type = FLOAT; aMetrics[u16MetricCounter].type = FLOAT;
aMetrics[u16MetricCounter].fMetricValue = getOutdoorTemperature().fCurrentValue; aMetrics[u16MetricCounter].fMetricValue = getOutdoorTemperature().fCurrentValue;
u16MetricCounter++; u16MetricCounter++;
/*Outdoor Temperature Average 10s*/ // Outdoor Temperature Average 10s
strcpy(aMetrics[u16MetricCounter].caMetricName, "outdoor_temperature_avg10"); strcpy(aMetrics[u16MetricCounter].caMetricName, "outdoor_temperature_avg10");
aMetrics[u16MetricCounter].type = FLOAT; aMetrics[u16MetricCounter].type = FLOAT;
aMetrics[u16MetricCounter].fMetricValue = getOutdoorTemperature().average10s.fValue; aMetrics[u16MetricCounter].fMetricValue = getOutdoorTemperature().average10s.fValue;
u16MetricCounter++; u16MetricCounter++;
/*Outdoor Temperature Average 60s*/ // Outdoor Temperature Average 60s
strcpy(aMetrics[u16MetricCounter].caMetricName, "outdoor_temperature_avg60"); strcpy(aMetrics[u16MetricCounter].caMetricName, "outdoor_temperature_avg60");
aMetrics[u16MetricCounter].type = FLOAT; aMetrics[u16MetricCounter].type = FLOAT;
aMetrics[u16MetricCounter].fMetricValue = getOutdoorTemperature().average60s.fValue; aMetrics[u16MetricCounter].fMetricValue = getOutdoorTemperature().average60s.fValue;
u16MetricCounter++; u16MetricCounter++;
/*Return Flow Temperature*/ // Return Flow Temperature
strcpy(aMetrics[u16MetricCounter].caMetricName, "return_flow_temperature"); strcpy(aMetrics[u16MetricCounter].caMetricName, "return_flow_temperature");
aMetrics[u16MetricCounter].type = FLOAT; aMetrics[u16MetricCounter].type = FLOAT;
aMetrics[u16MetricCounter].fMetricValue = getReturnFlowTemperature().fCurrentValue; aMetrics[u16MetricCounter].fMetricValue = getReturnFlowTemperature().fCurrentValue;
u16MetricCounter++; u16MetricCounter++;
/*Return Flow Temperature Average 10s*/ // Return Flow Temperature Average 10s
strcpy(aMetrics[u16MetricCounter].caMetricName, "return_flow_temperature_avg10"); strcpy(aMetrics[u16MetricCounter].caMetricName, "return_flow_temperature_avg10");
aMetrics[u16MetricCounter].type = FLOAT; aMetrics[u16MetricCounter].type = FLOAT;
aMetrics[u16MetricCounter].fMetricValue = getReturnFlowTemperature().average10s.fValue; aMetrics[u16MetricCounter].fMetricValue = getReturnFlowTemperature().average10s.fValue;
u16MetricCounter++; u16MetricCounter++;
/*Return Flow Temperature Average 60s*/ // Return Flow Temperature Average 60s
strcpy(aMetrics[u16MetricCounter].caMetricName, "return_flow_temperature_avg60"); strcpy(aMetrics[u16MetricCounter].caMetricName, "return_flow_temperature_avg60");
aMetrics[u16MetricCounter].type = FLOAT; aMetrics[u16MetricCounter].type = FLOAT;
aMetrics[u16MetricCounter].fMetricValue = getReturnFlowTemperature().average60s.fValue; aMetrics[u16MetricCounter].fMetricValue = getReturnFlowTemperature().average60s.fValue;
u16MetricCounter++; u16MetricCounter++;
/*Sensor State*/ // Sensor State
sSensorSanityCheck aChecks[NUMBER_OF_SENSOR_SANITY_CHECKS]; sSensorSanityCheck aChecks[NUMBER_OF_SENSOR_SANITY_CHECKS];
getSensorSanityStates(aChecks); getSensorSanityStates(aChecks);
for (size_t i = 0; i < NUMBER_OF_SENSOR_SANITY_CHECKS; i++) for (size_t i = 0; i < NUMBER_OF_SENSOR_SANITY_CHECKS; i++)
@ -208,25 +206,25 @@ void taskMetrics(void *pvParameters)
u16MetricCounter++; u16MetricCounter++;
} }
/*Safety State*/ // Safety State
strcpy(aMetrics[u16MetricCounter].caMetricName, "safety_state"); strcpy(aMetrics[u16MetricCounter].caMetricName, "safety_state");
aMetrics[u16MetricCounter].type = INTEGER_U8; aMetrics[u16MetricCounter].type = INTEGER_U8;
aMetrics[u16MetricCounter].u8MetricValue = getSafetyState(); aMetrics[u16MetricCounter].u8MetricValue = getSafetyState();
u16MetricCounter++; u16MetricCounter++;
/*Control State*/ // Control State
strcpy(aMetrics[u16MetricCounter].caMetricName, "control_state"); strcpy(aMetrics[u16MetricCounter].caMetricName, "control_state");
aMetrics[u16MetricCounter].type = INTEGER_U8; aMetrics[u16MetricCounter].type = INTEGER_U8;
aMetrics[u16MetricCounter].u8MetricValue = getControlState(); aMetrics[u16MetricCounter].u8MetricValue = getControlState();
u16MetricCounter++; u16MetricCounter++;
/*SNTP State*/ // SNTP State
strcpy(aMetrics[u16MetricCounter].caMetricName, "sntp_state"); strcpy(aMetrics[u16MetricCounter].caMetricName, "sntp_state");
aMetrics[u16MetricCounter].type = INTEGER_U8; aMetrics[u16MetricCounter].type = INTEGER_U8;
aMetrics[u16MetricCounter].u8MetricValue = getSntpState(); aMetrics[u16MetricCounter].u8MetricValue = getSntpState();
u16MetricCounter++; u16MetricCounter++;
/*System Time*/ // System Time
time_t now; time_t now;
time(&now); time(&now);
strcpy(aMetrics[u16MetricCounter].caMetricName, "system_unixtime"); strcpy(aMetrics[u16MetricCounter].caMetricName, "system_unixtime");
@ -234,13 +232,13 @@ void taskMetrics(void *pvParameters)
aMetrics[u16MetricCounter].i64MetricValue = now; aMetrics[u16MetricCounter].i64MetricValue = now;
u16MetricCounter++; u16MetricCounter++;
/*Uptime*/ // Uptime
strcpy(aMetrics[u16MetricCounter].caMetricName, "uptime_seconds"); strcpy(aMetrics[u16MetricCounter].caMetricName, "uptime_seconds");
aMetrics[u16MetricCounter].type = INTEGER_64; aMetrics[u16MetricCounter].type = INTEGER_64;
aMetrics[u16MetricCounter].i64MetricValue = (esp_timer_get_time() / 1000000U); aMetrics[u16MetricCounter].i64MetricValue = (esp_timer_get_time() / 1000000U);
u16MetricCounter++; u16MetricCounter++;
/*Wifi RSSI*/ // Wifi RSSI
wifi_ap_record_t ap; wifi_ap_record_t ap;
esp_wifi_sta_get_ap_info(&ap); esp_wifi_sta_get_ap_info(&ap);
strcpy(aMetrics[u16MetricCounter].caMetricName, "wifi_rssi"); strcpy(aMetrics[u16MetricCounter].caMetricName, "wifi_rssi");
@ -257,7 +255,7 @@ void vSetMetrics(sMetric *paMetrics, uint16_t u16Size)
if (xSemaphoreTakeRecursive(xMutexAccessMetricResponse, pdMS_TO_TICKS(5000)) == pdTRUE) if (xSemaphoreTakeRecursive(xMutexAccessMetricResponse, pdMS_TO_TICKS(5000)) == pdTRUE)
{ {
memset(caHtmlResponse, 0, strlen(caHtmlResponse)); memset(caHtmlResponse, 0U, strlen(caHtmlResponse));
for (uint16_t u16Index = 0U; u16Index < u16Size; u16Index++) for (uint16_t u16Index = 0U; u16Index < u16Size; u16Index++)
{ {
char caValueBuffer[64]; char caValueBuffer[64];
@ -277,6 +275,7 @@ void vSetMetrics(sMetric *paMetrics, uint16_t u16Size)
break; break;
} }
// printf("%s\n", paMetrics[u16Index].caMetricName);
// printf("%s\n", caValueBuffer); // printf("%s\n", caValueBuffer);
strcat(caHtmlResponse, paMetrics[u16Index].caMetricName); strcat(caHtmlResponse, paMetrics[u16Index].caMetricName);
strcat(caHtmlResponse, caValueBuffer); strcat(caHtmlResponse, caValueBuffer);

View File

@ -2,9 +2,9 @@
#include <esp_http_server.h> #include <esp_http_server.h>
#define HTML_RESPONSE_SIZE 1024U #define HTML_RESPONSE_SIZE 4096U
#define METRIC_NAME_MAX_SIZE 256U #define METRIC_NAME_MAX_SIZE 64U
#define METRIC_MAX_COUNT 64U #define METRIC_MAX_COUNT 32U
typedef enum _MetricValueType typedef enum _MetricValueType
{ {