temperature sensor update

This commit is contained in:
Robin Müller 2021-04-20 14:58:35 +02:00
parent c8b2b3a038
commit 64efb8ec7f

View File

@ -69,14 +69,14 @@ public:
* @param outputSet Output dataset for the output temperature to fetch it with read() * @param outputSet Output dataset for the output temperature to fetch it with read()
* @param thermalModule respective thermal module, if it has one * @param thermalModule respective thermal module, if it has one
*/ */
TemperatureSensor(object_id_t setObjectid, TemperatureSensor(object_id_t setObjectid,lp_var_t<limitType>* inputTemperature,
inputType *inputValue, gp_id_t variableGpid, PoolVariableIF* inputVariable, gp_id_t variableGpid, PoolVariableIF* inputVariable,
uint8_t vectorIndex, Parameters parameters = {0, 0, 0, 0, 0, 0}, uint8_t vectorIndex, Parameters parameters = {0, 0, 0, 0, 0, 0},
LocalPoolDataSetBase *outputSet = NULL, ThermalModuleIF *thermalModule = NULL) : LocalPoolDataSetBase *outputSet = nullptr, ThermalModuleIF *thermalModule = nullptr) :
AbstractTemperatureSensor(setObjectid, thermalModule), parameters(parameters), AbstractTemperatureSensor(setObjectid, thermalModule), parameters(parameters),
inputValue(inputValue), poolVariable(inputVariable), inputTemperature(inputTemperature),
outputTemperature(variableGpid, outputSet, PoolVariableIF::VAR_WRITE), outputTemperature(variableGpid, outputSet, PoolVariableIF::VAR_WRITE),
sensorMonitor(setObjectid, DOMAIN_ID_SENSOR, poolVariable, sensorMonitor(setObjectid, DOMAIN_ID_SENSOR, variableGpid,
DEFAULT_CONFIRMATION_COUNT, parameters.lowerLimit, parameters.upperLimit, DEFAULT_CONFIRMATION_COUNT, parameters.lowerLimit, parameters.upperLimit,
TEMP_SENSOR_LOW, TEMP_SENSOR_HIGH), TEMP_SENSOR_LOW, TEMP_SENSOR_HIGH),
oldTemperature(20), uptimeOfOldTemperature({ thermal::INVALID_TEMPERATURE, 0 }) { oldTemperature(20), uptimeOfOldTemperature({ thermal::INVALID_TEMPERATURE, 0 }) {
@ -110,10 +110,7 @@ protected:
UsedParameters parameters; UsedParameters parameters;
inputType* inputValue; lp_var_t<limitType>* inputTemperature;
PoolVariableIF* poolVariable;
lp_var_t<float> outputTemperature; lp_var_t<float> outputTemperature;
LimitMonitor<limitType> sensorMonitor; LimitMonitor<limitType> sensorMonitor;
@ -122,18 +119,18 @@ protected:
timeval uptimeOfOldTemperature; timeval uptimeOfOldTemperature;
void doChildOperation() { void doChildOperation() {
ReturnValue_t result = poolVariable->read(MutexIF::TimeoutType::WAITING, 20); ReturnValue_t result = inputTemperature->read(MutexIF::TimeoutType::WAITING, 20);
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
return; return;
} }
if ((not poolVariable->isValid()) or if ((not inputTemperature->isValid()) or
(not healthHelper.healthTable->isHealthy(getObjectId()))) { (not healthHelper.healthTable->isHealthy(getObjectId()))) {
setInvalid(); setInvalid();
return; return;
} }
outputTemperature = calculateOutputTemperature(*inputValue); outputTemperature = calculateOutputTemperature(inputTemperature->value);
outputTemperature.setValid(PoolVariableIF::VALID); outputTemperature.setValid(PoolVariableIF::VALID);
timeval uptime; timeval uptime;