add control status

This commit is contained in:
2024-12-21 22:02:16 +01:00
parent 9abf64f9dd
commit 4ef6c8bd08
6 changed files with 95 additions and 18 deletions

View File

@ -77,7 +77,7 @@ void checkSensorSanity(void)
for (int i = 0; i < NUMBER_OF_SENSOR_SANITY_CHECKS; i++)
{
// printf("Check sanity of sensor %s:\n", sanityChecks[i].name);
// printf(" Status: %u\n", sanityChecks[i].status);
// printf(" state: %u\n", sanityChecks[i].state);
// printf(" Sensor Limits: Max = %.2f, Min = %.2f\n", sanityChecks[i].sSensorLimit.max, sanityChecks[i].sSensorLimit.min);
// printf(" Last Sensor Temperature: %.2f\n", sanityChecks[i].fSensorTemperatureLast);
@ -86,7 +86,7 @@ void checkSensorSanity(void)
if (sCurrentMeasurement.state == MEASUREMENT_FAULT)
{
ESP_LOGE(TAG, "%s Sensor not found!", sanityChecks[i].name);
sanityChecks[i].status = SENSOR_NOT_FOUND;
sanityChecks[i].state = SENSOR_NOT_FOUND;
sSafetyState = SAFETY_SENSOR_ERROR;
}
else
@ -97,7 +97,7 @@ void checkSensorSanity(void)
if (sanityChecks[i].uUnchangedCounter >= (SENSOR_GRACE_PERIOD / PERIODIC_INTERVAL))
{
ESP_LOGE(TAG, "%s Sensor reported unchanged value! %lf == %lf", sanityChecks[i].name, sCurrentMeasurement.fCurrentValue, sanityChecks[i].fSensorTemperatureLast);
sanityChecks[i].status = SENSOR_UNCHANGED;
sanityChecks[i].state = SENSOR_UNCHANGED;
sSafetyState = SAFETY_SENSOR_ERROR;
}
}
@ -108,23 +108,23 @@ void checkSensorSanity(void)
if (sCurrentMeasurement.fCurrentValue > sanityChecks[i].sSensorLimit.max)
{
ESP_LOGE(TAG, "%s Sensor reported too high value! %lf > %lf", sanityChecks[i].name, sCurrentMeasurement.fCurrentValue, sanityChecks[i].sSensorLimit.max);
sanityChecks[i].status = SENSOR_TOO_HIGH;
sanityChecks[i].state = SENSOR_TOO_HIGH;
sSafetyState = SAFETY_SENSOR_ERROR;
}
else if (sCurrentMeasurement.fCurrentValue < sanityChecks[i].sSensorLimit.min)
{
ESP_LOGE(TAG, "%s Sensor reported too low value! %lf < %lf", sanityChecks[i].name, sCurrentMeasurement.fCurrentValue, sanityChecks[i].sSensorLimit.min);
sanityChecks[i].status = SENSOR_TOO_LOW;
sanityChecks[i].state = SENSOR_TOO_LOW;
sSafetyState = SAFETY_SENSOR_ERROR;
}
else
{
sanityChecks[i].uUnchangedCounter = 0U;
sanityChecks[i].status = SENSOR_NO_ERROR;
sanityChecks[i].state = SENSOR_NO_ERROR;
}
}
}
// printf(" Status: %u\n", sanityChecks[i].status);
// printf(" state: %u\n", sanityChecks[i].state);
}
}
@ -142,7 +142,7 @@ void getSensorSanityStates(sSensorSanityCheck *pSensorSanityChecks)
for (size_t i = 0; i < NUMBER_OF_SENSOR_SANITY_CHECKS; i++)
{
// Copy only the needed attributes
pSensorSanityChecks[i].status = sanityChecks[i].status;
pSensorSanityChecks[i].state = sanityChecks[i].state;
strcpy(pSensorSanityChecks[i].name, sanityChecks[i].name);
}
xSemaphoreGiveRecursive(xMutexAccessSafety);