From 4bb078c451ddf543e15e27073f5c8edf1642d38e Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 12 Apr 2021 12:40:59 +0200 Subject: [PATCH 1/6] thermal sensor update --- thermal/TemperatureSensor.h | 54 +++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/thermal/TemperatureSensor.h b/thermal/TemperatureSensor.h index 2b1fb1f0..ceb8a861 100644 --- a/thermal/TemperatureSensor.h +++ b/thermal/TemperatureSensor.h @@ -1,11 +1,14 @@ #ifndef TEMPERATURESENSOR_H_ #define TEMPERATURESENSOR_H_ -#include "../thermal/AbstractTemperatureSensor.h" -#include "../datapoolglob/GlobalDataSet.h" -#include "../datapoolglob/GlobalPoolVariable.h" +#include "tcsDefinitions.h" +#include "AbstractTemperatureSensor.h" + +#include "../datapoollocal/LocalPoolDataSetBase.h" +#include "../datapoollocal/LocalPoolVariable.h" #include "../monitoring/LimitMonitor.h" + /** * @brief This building block handles non-linear value conversion and * range checks for analog temperature sensors. @@ -57,27 +60,26 @@ public: /** * Instantiate Temperature Sensor Object. - * @param setObjectid objectId of the sensor object - * @param inputValue Input value which is converted to a temperature - * @param poolVariable Pool Variable to store the temperature value - * @param vectorIndex Vector Index for the sensor monitor - * @param parameters Calculation parameters, temperature limits, gradient limit - * @param datapoolId Datapool ID of the output temperature - * @param outputSet Output dataset for the output temperature to fetch it with read() + * @param setObjectid objectId of the sensor object + * @param inputValue Pointer to input value which is converted to a temperature + * @param variableGpid Global Pool ID of the output value + * @param inputVariable Input variable handle + * @param vectorIndex Vector Index for the sensor monitor + * @param parameters Calculation parameters, temperature limits, gradient limit + * @param outputSet Output dataset for the output temperature to fetch it with read() * @param thermalModule respective thermal module, if it has one */ TemperatureSensor(object_id_t setObjectid, - inputType *inputValue, PoolVariableIF *poolVariable, - uint8_t vectorIndex, uint32_t datapoolId, Parameters parameters = {0, 0, 0, 0, 0, 0}, - GlobDataSet *outputSet = NULL, ThermalModuleIF *thermalModule = NULL) : + inputType *inputValue, gp_id_t variableGpid, PoolVariableIF* inputVariable, + uint8_t vectorIndex, Parameters parameters = {0, 0, 0, 0, 0, 0}, + LocalPoolDataSetBase *outputSet = NULL, ThermalModuleIF *thermalModule = NULL) : AbstractTemperatureSensor(setObjectid, thermalModule), parameters(parameters), - inputValue(inputValue), poolVariable(poolVariable), - outputTemperature(datapoolId, outputSet, PoolVariableIF::VAR_WRITE), - sensorMonitor(setObjectid, DOMAIN_ID_SENSOR, - GlobalDataPool::poolIdAndPositionToPid(poolVariable->getDataPoolId(), vectorIndex), + inputValue(inputValue), poolVariable(inputVariable), + outputTemperature(variableGpid, outputSet, PoolVariableIF::VAR_WRITE), + sensorMonitor(setObjectid, DOMAIN_ID_SENSOR, poolVariable, DEFAULT_CONFIRMATION_COUNT, parameters.lowerLimit, parameters.upperLimit, TEMP_SENSOR_LOW, TEMP_SENSOR_HIGH), - oldTemperature(20), uptimeOfOldTemperature( { INVALID_TEMPERATURE, 0 }) { + oldTemperature(20), uptimeOfOldTemperature({ thermal::INVALID_TEMPERATURE, 0 }) { } @@ -98,7 +100,7 @@ protected: private: void setInvalid() { - outputTemperature = INVALID_TEMPERATURE; + outputTemperature = thermal::INVALID_TEMPERATURE; outputTemperature.setValid(false); uptimeOfOldTemperature.tv_sec = INVALID_UPTIME; sensorMonitor.setToInvalid(); @@ -108,11 +110,11 @@ protected: UsedParameters parameters; - inputType * inputValue; + inputType* inputValue; - PoolVariableIF *poolVariable; + PoolVariableIF* poolVariable; - gp_float_t outputTemperature; + lp_var_t outputTemperature; LimitMonitor sensorMonitor; @@ -120,8 +122,8 @@ protected: timeval uptimeOfOldTemperature; void doChildOperation() { - if (!poolVariable->isValid() - || !healthHelper.healthTable->isHealthy(getObjectId())) { + if ((not poolVariable->isValid()) or + (not healthHelper.healthTable->isHealthy(getObjectId()))) { setInvalid(); return; } @@ -152,13 +154,13 @@ protected: } } - //Check is done against raw limits. SHOULDDO: Why? Using �C would be more easy to handle. + //Check is done against raw limits. SHOULDDO: Why? Using C would be more easy to handle. sensorMonitor.doCheck(outputTemperature.value); if (sensorMonitor.isOutOfLimits()) { uptimeOfOldTemperature.tv_sec = INVALID_UPTIME; outputTemperature.setValid(PoolVariableIF::INVALID); - outputTemperature = INVALID_TEMPERATURE; + outputTemperature = thermal::INVALID_TEMPERATURE; } else { oldTemperature = outputTemperature; uptimeOfOldTemperature = uptime; From 6873d2b8473469290a268149cb939a745e92e67f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 20 Apr 2021 14:46:59 +0200 Subject: [PATCH 2/6] temp sensor update --- thermal/TemperatureSensor.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/thermal/TemperatureSensor.h b/thermal/TemperatureSensor.h index ceb8a861..f1e17c55 100644 --- a/thermal/TemperatureSensor.h +++ b/thermal/TemperatureSensor.h @@ -122,6 +122,11 @@ protected: timeval uptimeOfOldTemperature; void doChildOperation() { + ReturnValue_t result = poolVariable->read(MutexIF::TimeoutType::WAITING, 20); + if(result != HasReturnvaluesIF::RETURN_OK) { + return; + } + if ((not poolVariable->isValid()) or (not healthHelper.healthTable->isHealthy(getObjectId()))) { setInvalid(); From 64efb8ec7f2cd64c188791043289e4a45d79ad87 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 20 Apr 2021 14:58:35 +0200 Subject: [PATCH 3/6] temperature sensor update --- thermal/TemperatureSensor.h | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/thermal/TemperatureSensor.h b/thermal/TemperatureSensor.h index f1e17c55..abe446c0 100644 --- a/thermal/TemperatureSensor.h +++ b/thermal/TemperatureSensor.h @@ -69,14 +69,14 @@ public: * @param outputSet Output dataset for the output temperature to fetch it with read() * @param thermalModule respective thermal module, if it has one */ - TemperatureSensor(object_id_t setObjectid, - inputType *inputValue, gp_id_t variableGpid, PoolVariableIF* inputVariable, + TemperatureSensor(object_id_t setObjectid,lp_var_t* inputTemperature, + gp_id_t variableGpid, PoolVariableIF* inputVariable, 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), - inputValue(inputValue), poolVariable(inputVariable), + inputTemperature(inputTemperature), 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, TEMP_SENSOR_LOW, TEMP_SENSOR_HIGH), oldTemperature(20), uptimeOfOldTemperature({ thermal::INVALID_TEMPERATURE, 0 }) { @@ -110,10 +110,7 @@ protected: UsedParameters parameters; - inputType* inputValue; - - PoolVariableIF* poolVariable; - + lp_var_t* inputTemperature; lp_var_t outputTemperature; LimitMonitor sensorMonitor; @@ -122,18 +119,18 @@ protected: timeval uptimeOfOldTemperature; 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) { return; } - if ((not poolVariable->isValid()) or + if ((not inputTemperature->isValid()) or (not healthHelper.healthTable->isHealthy(getObjectId()))) { setInvalid(); return; } - outputTemperature = calculateOutputTemperature(*inputValue); + outputTemperature = calculateOutputTemperature(inputTemperature->value); outputTemperature.setValid(PoolVariableIF::VALID); timeval uptime; From e6a8371d4a6a54ad4091eb3bf48da6aea96d522e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 20 Apr 2021 15:00:59 +0200 Subject: [PATCH 4/6] temperature sensor update --- thermal/TemperatureSensor.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/thermal/TemperatureSensor.h b/thermal/TemperatureSensor.h index abe446c0..55138cc3 100644 --- a/thermal/TemperatureSensor.h +++ b/thermal/TemperatureSensor.h @@ -137,9 +137,9 @@ protected: Clock::getUptime(&uptime); if (uptimeOfOldTemperature.tv_sec != INVALID_UPTIME) { - //In theory, we could use an AbsValueMonitor to monitor the gradient. - //But this would require storing the maxGradient in DP and quite some overhead. - //The concept of delta limits is a bit strange anyway. + // In theory, we could use an AbsValueMonitor to monitor the gradient. + // But this would require storing the maxGradient in DP and quite some overhead. + // The concept of delta limits is a bit strange anyway. float deltaTime; float deltaTemp; @@ -152,11 +152,10 @@ protected: } if (parameters.gradient < deltaTemp / deltaTime) { triggerEvent(TEMP_SENSOR_GRADIENT); - //Don't set invalid, as we did not recognize it as invalid with full authority, let FDIR handle it + // Don't set invalid, as we did not recognize it as invalid with full authority, let FDIR handle it } } - //Check is done against raw limits. SHOULDDO: Why? Using C would be more easy to handle. sensorMonitor.doCheck(outputTemperature.value); if (sensorMonitor.isOutOfLimits()) { From 524e50a6dd5649b9748c677b72e00bdb9e9a725e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 20 Apr 2021 15:54:44 +0200 Subject: [PATCH 5/6] comment block corrected --- thermal/TemperatureSensor.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/thermal/TemperatureSensor.h b/thermal/TemperatureSensor.h index 55138cc3..b4ea4504 100644 --- a/thermal/TemperatureSensor.h +++ b/thermal/TemperatureSensor.h @@ -60,18 +60,17 @@ public: /** * Instantiate Temperature Sensor Object. - * @param setObjectid objectId of the sensor object - * @param inputValue Pointer to input value which is converted to a temperature - * @param variableGpid Global Pool ID of the output value - * @param inputVariable Input variable handle - * @param vectorIndex Vector Index for the sensor monitor - * @param parameters Calculation parameters, temperature limits, gradient limit - * @param outputSet Output dataset for the output temperature to fetch it with read() - * @param thermalModule respective thermal module, if it has one + * @param setObjectid objectId of the sensor object + * @param inputTemperature Pointer to a raw input value which is converted to an floating + * point C output temperature + * @param variableGpid Global Pool ID of the output value + * @param vectorIndex Vector Index for the sensor monitor + * @param parameters Calculation parameters, temperature limits, gradient limit + * @param outputSet Output dataset for the output temperature to fetch it with read() + * @param thermalModule Respective thermal module, if it has one */ TemperatureSensor(object_id_t setObjectid,lp_var_t* inputTemperature, - gp_id_t variableGpid, PoolVariableIF* inputVariable, - uint8_t vectorIndex, Parameters parameters = {0, 0, 0, 0, 0, 0}, + gp_id_t variableGpid, uint8_t vectorIndex, Parameters parameters = {0, 0, 0, 0, 0, 0}, LocalPoolDataSetBase *outputSet = nullptr, ThermalModuleIF *thermalModule = nullptr) : AbstractTemperatureSensor(setObjectid, thermalModule), parameters(parameters), inputTemperature(inputTemperature), From 0c342ad7fcc715266a2562f65f2cec034d40e919 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 20 Apr 2021 15:57:11 +0200 Subject: [PATCH 6/6] minor changes --- thermal/TemperatureSensor.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/thermal/TemperatureSensor.h b/thermal/TemperatureSensor.h index b4ea4504..69c16c7f 100644 --- a/thermal/TemperatureSensor.h +++ b/thermal/TemperatureSensor.h @@ -1,5 +1,5 @@ -#ifndef TEMPERATURESENSOR_H_ -#define TEMPERATURESENSOR_H_ +#ifndef FSFW_THERMAL_TEMPERATURESENSOR_H_ +#define FSFW_THERMAL_TEMPERATURESENSOR_H_ #include "tcsDefinitions.h" #include "AbstractTemperatureSensor.h" @@ -151,7 +151,8 @@ protected: } if (parameters.gradient < deltaTemp / deltaTime) { triggerEvent(TEMP_SENSOR_GRADIENT); - // Don't set invalid, as we did not recognize it as invalid with full authority, let FDIR handle it + // Don't set invalid, as we did not recognize it as invalid with full authority, + // let FDIR handle it } } @@ -181,7 +182,10 @@ public: static const uint16_t ADDRESS_C = 2; static const uint16_t ADDRESS_GRADIENT = 3; - static const uint16_t DEFAULT_CONFIRMATION_COUNT = 1; //!< Changed due to issue with later temperature checking even tough the sensor monitor was confirming already (Was 10 before with comment = Correlates to a 10s confirmation time. Chosen rather large, should not be so bad for components and helps survive glitches.) + //! Changed due to issue with later temperature checking even tough the sensor monitor was + //! confirming already (Was 10 before with comment = Correlates to a 10s confirmation time. + //! Chosen rather large, should not be so bad for components and helps survive glitches.) + static const uint16_t DEFAULT_CONFIRMATION_COUNT = 1; static const uint8_t DOMAIN_ID_SENSOR = 1; @@ -221,4 +225,4 @@ public: }; -#endif /* TEMPERATURESENSOR_H_ */ +#endif /* FSFW_THERMAL_TEMPERATURESENSOR_H_ */