fixed temperature sensor object
This commit is contained in:
parent
9f8a345e35
commit
43ddb44573
@ -1,11 +1,14 @@
|
|||||||
#ifndef TEMPERATURESENSOR_H_
|
#ifndef TEMPERATURESENSOR_H_
|
||||||
#define TEMPERATURESENSOR_H_
|
#define TEMPERATURESENSOR_H_
|
||||||
|
|
||||||
#include "../thermal/AbstractTemperatureSensor.h"
|
#include "tcsDefinitions.h"
|
||||||
#include "../datapoolglob/GlobalDataSet.h"
|
#include "AbstractTemperatureSensor.h"
|
||||||
#include "../datapoolglob/GlobalPoolVariable.h"
|
|
||||||
|
#include "../datapoollocal/LocalPoolDataSetBase.h"
|
||||||
|
#include "../datapoollocal/LocalPoolVariable.h"
|
||||||
#include "../monitoring/LimitMonitor.h"
|
#include "../monitoring/LimitMonitor.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This building block handles non-linear value conversion and
|
* @brief This building block handles non-linear value conversion and
|
||||||
* range checks for analog temperature sensors.
|
* range checks for analog temperature sensors.
|
||||||
@ -57,27 +60,26 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiate Temperature Sensor Object.
|
* Instantiate Temperature Sensor Object.
|
||||||
* @param setObjectid objectId of the sensor object
|
* @param setObjectid objectId of the sensor object
|
||||||
* @param inputValue Input value which is converted to a temperature
|
* @param inputValue Pointer to input value which is converted to a temperature
|
||||||
* @param poolVariable Pool Variable to store the temperature value
|
* @param variableGpid Global Pool ID of the output value
|
||||||
* @param vectorIndex Vector Index for the sensor monitor
|
* @param inputVariable Input variable handle
|
||||||
* @param parameters Calculation parameters, temperature limits, gradient limit
|
* @param vectorIndex Vector Index for the sensor monitor
|
||||||
* @param datapoolId Datapool ID of the output temperature
|
* @param parameters Calculation parameters, temperature limits, gradient limit
|
||||||
* @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,
|
||||||
inputType *inputValue, PoolVariableIF *poolVariable,
|
inputType *inputValue, gp_id_t variableGpid, PoolVariableIF* inputVariable,
|
||||||
uint8_t vectorIndex, uint32_t datapoolId, Parameters parameters = {0, 0, 0, 0, 0, 0},
|
uint8_t vectorIndex, Parameters parameters = {0, 0, 0, 0, 0, 0},
|
||||||
GlobDataSet *outputSet = NULL, ThermalModuleIF *thermalModule = NULL) :
|
LocalPoolDataSetBase *outputSet = NULL, ThermalModuleIF *thermalModule = NULL) :
|
||||||
AbstractTemperatureSensor(setObjectid, thermalModule), parameters(parameters),
|
AbstractTemperatureSensor(setObjectid, thermalModule), parameters(parameters),
|
||||||
inputValue(inputValue), poolVariable(poolVariable),
|
inputValue(inputValue), poolVariable(inputVariable),
|
||||||
outputTemperature(datapoolId, outputSet, PoolVariableIF::VAR_WRITE),
|
outputTemperature(variableGpid, outputSet, PoolVariableIF::VAR_WRITE),
|
||||||
sensorMonitor(setObjectid, DOMAIN_ID_SENSOR,
|
sensorMonitor(setObjectid, DOMAIN_ID_SENSOR, poolVariable,
|
||||||
GlobalDataPool::poolIdAndPositionToPid(poolVariable->getDataPoolId(), vectorIndex),
|
|
||||||
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( { INVALID_TEMPERATURE, 0 }) {
|
oldTemperature(20), uptimeOfOldTemperature({ thermal::INVALID_TEMPERATURE, 0 }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -98,7 +100,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void setInvalid() {
|
void setInvalid() {
|
||||||
outputTemperature = INVALID_TEMPERATURE;
|
outputTemperature = thermal::INVALID_TEMPERATURE;
|
||||||
outputTemperature.setValid(false);
|
outputTemperature.setValid(false);
|
||||||
uptimeOfOldTemperature.tv_sec = INVALID_UPTIME;
|
uptimeOfOldTemperature.tv_sec = INVALID_UPTIME;
|
||||||
sensorMonitor.setToInvalid();
|
sensorMonitor.setToInvalid();
|
||||||
@ -108,11 +110,11 @@ protected:
|
|||||||
|
|
||||||
UsedParameters parameters;
|
UsedParameters parameters;
|
||||||
|
|
||||||
inputType * inputValue;
|
inputType* inputValue;
|
||||||
|
|
||||||
PoolVariableIF *poolVariable;
|
PoolVariableIF* poolVariable;
|
||||||
|
|
||||||
gp_float_t outputTemperature;
|
lp_var_t<float> outputTemperature;
|
||||||
|
|
||||||
LimitMonitor<limitType> sensorMonitor;
|
LimitMonitor<limitType> sensorMonitor;
|
||||||
|
|
||||||
@ -120,8 +122,8 @@ protected:
|
|||||||
timeval uptimeOfOldTemperature;
|
timeval uptimeOfOldTemperature;
|
||||||
|
|
||||||
void doChildOperation() {
|
void doChildOperation() {
|
||||||
if (!poolVariable->isValid()
|
if ((not poolVariable->isValid()) or
|
||||||
|| !healthHelper.healthTable->isHealthy(getObjectId())) {
|
(not healthHelper.healthTable->isHealthy(getObjectId()))) {
|
||||||
setInvalid();
|
setInvalid();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -152,13 +154,13 @@ protected:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check is done against raw limits. SHOULDDO: Why? Using <EFBFBD>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);
|
sensorMonitor.doCheck(outputTemperature.value);
|
||||||
|
|
||||||
if (sensorMonitor.isOutOfLimits()) {
|
if (sensorMonitor.isOutOfLimits()) {
|
||||||
uptimeOfOldTemperature.tv_sec = INVALID_UPTIME;
|
uptimeOfOldTemperature.tv_sec = INVALID_UPTIME;
|
||||||
outputTemperature.setValid(PoolVariableIF::INVALID);
|
outputTemperature.setValid(PoolVariableIF::INVALID);
|
||||||
outputTemperature = INVALID_TEMPERATURE;
|
outputTemperature = thermal::INVALID_TEMPERATURE;
|
||||||
} else {
|
} else {
|
||||||
oldTemperature = outputTemperature;
|
oldTemperature = outputTemperature;
|
||||||
uptimeOfOldTemperature = uptime;
|
uptimeOfOldTemperature = uptime;
|
||||||
|
Loading…
Reference in New Issue
Block a user