Merge branch 'development' into mueller/linuxtcpip-printout-fix

This commit is contained in:
Steffen Gaisser 2021-04-20 17:43:44 +02:00
commit b38e9ede0c
4 changed files with 404 additions and 393 deletions

View File

@ -16,9 +16,9 @@ ReturnValue_t HealthDevice::performOperation(uint8_t opCode) {
CommandMessage command; CommandMessage command;
ReturnValue_t result = commandQueue->receiveMessage(&command); ReturnValue_t result = commandQueue->receiveMessage(&command);
if (result == HasReturnvaluesIF::RETURN_OK) { if (result == HasReturnvaluesIF::RETURN_OK) {
healthHelper.handleHealthCommand(&command); result = healthHelper.handleHealthCommand(&command);
} }
return HasReturnvaluesIF::RETURN_OK; return result;
} }
ReturnValue_t HealthDevice::initialize() { ReturnValue_t HealthDevice::initialize() {

View File

@ -1,15 +1,13 @@
#include "../devicehandlers/DeviceHandlerFailureIsolation.h"
#include "Heater.h" #include "Heater.h"
#include "../devicehandlers/DeviceHandlerFailureIsolation.h"
#include "../power/Fuse.h" #include "../power/Fuse.h"
#include "../ipc/QueueFactory.h" #include "../ipc/QueueFactory.h"
Heater::Heater(uint32_t objectId, uint8_t switch0, uint8_t switch1) : Heater::Heater(uint32_t objectId, uint8_t switch0, uint8_t switch1) :
HealthDevice(objectId, 0), internalState(STATE_OFF), powerSwitcher( HealthDevice(objectId, 0), internalState(STATE_OFF), switch0(switch0), switch1(switch1),
NULL), pcduQueueId(0), switch0(switch0), switch1(switch1), wasOn( heaterOnCountdown(10800000)/*about two orbits*/,
false), timedOut(false), reactedToBeingFaulty(false), passive( parameterHelper(this) {
false), eventQueue(NULL), heaterOnCountdown(10800000)/*about two orbits*/, parameterHelper(
this), lastAction(CLEAR) {
eventQueue = QueueFactory::instance()->createMessageQueue(); eventQueue = QueueFactory::instance()->createMessageQueue();
} }
@ -226,7 +224,6 @@ void Heater::setSwitch(uint8_t number, ReturnValue_t state,
triggerEvent(HEATER_STAYED_ON); triggerEvent(HEATER_STAYED_ON);
} }
} }
//SHOULDDO MiniOps during switch timeout leads to a faulty switch
} }
} }
} }
@ -286,7 +283,10 @@ void Heater::handleQueue() {
if (result == HasReturnvaluesIF::RETURN_OK) { if (result == HasReturnvaluesIF::RETURN_OK) {
return; return;
} }
parameterHelper.handleParameterMessage(&command); result = parameterHelper.handleParameterMessage(&command);
if (result == HasReturnvaluesIF::RETURN_OK) {
return;
}
} }
} }
@ -316,7 +316,9 @@ void Heater::handleEventQueue() {
switch (event.getEvent()) { switch (event.getEvent()) {
case Fuse::FUSE_WENT_OFF: case Fuse::FUSE_WENT_OFF:
case HEATER_STAYED_OFF: case HEATER_STAYED_OFF:
case HEATER_STAYED_ON://Setting it faulty does not help, but we need to reach a stable state and can check for being faulty before throwing this event again. // HEATER_STAYED_ON is a setting if faulty does not help, but we need to reach a stable state and can check
// for being faulty before throwing this event again.
case HEATER_STAYED_ON:
if (healthHelper.healthTable->isCommandable(getObjectId())) { if (healthHelper.healthTable->isCommandable(getObjectId())) {
healthHelper.setHealth(HasHealthIF::FAULTY); healthHelper.setHealth(HasHealthIF::FAULTY);
internalState = STATE_FAULTY; internalState = STATE_FAULTY;

View File

@ -1,13 +1,13 @@
#ifndef FRAMEWORK_THERMAL_HEATER_H_ #ifndef FSFW_THERMAL_HEATER_H_
#define FRAMEWORK_THERMAL_HEATER_H_ #define FSFW_THERMAL_HEATER_H_
#include "../devicehandlers/HealthDevice.h" #include "../devicehandlers/HealthDevice.h"
#include "../parameters/ParameterHelper.h" #include "../parameters/ParameterHelper.h"
#include "../power/PowerSwitchIF.h" #include "../power/PowerSwitchIF.h"
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
#include "../timemanager/Countdown.h" #include "../timemanager/Countdown.h"
#include <stdint.h> #include <cstdint>
//class RedundantHeater;
class Heater: public HealthDevice, public ReceivesParameterMessagesIF { class Heater: public HealthDevice, public ReceivesParameterMessagesIF {
friend class RedundantHeater; friend class RedundantHeater;
@ -47,35 +47,38 @@ protected:
STATE_PASSIVE, STATE_PASSIVE,
STATE_WAIT_FOR_SWITCHES_ON, STATE_WAIT_FOR_SWITCHES_ON,
STATE_WAIT_FOR_SWITCHES_OFF, STATE_WAIT_FOR_SWITCHES_OFF,
STATE_WAIT_FOR_FDIR, //used to avoid doing anything until fdir decided what to do STATE_WAIT_FOR_FDIR, // Used to avoid doing anything until fdir decided what to do
STATE_FAULTY, STATE_FAULTY,
STATE_WAIT, //used when waiting for system to recover from miniops STATE_WAIT, // Used when waiting for system to recover from miniops
STATE_EXTERNAL_CONTROL //entered when under external control and a fdir reaction would be triggered. This is useful when leaving external control into an unknown state // Entered when under external control and a fdir reaction would be triggered.
//if no fdir reaction is triggered under external control the state is still ok and no need for any special treatment is needed // This is useful when leaving external control into an unknown state
STATE_EXTERNAL_CONTROL
// If no fdir reaction is triggered under external control the state is still ok and
// no need for any special treatment is needed
} internalState; } internalState;
PowerSwitchIF *powerSwitcher; PowerSwitchIF *powerSwitcher = nullptr;
MessageQueueId_t pcduQueueId; MessageQueueId_t pcduQueueId = MessageQueueIF::NO_QUEUE;
uint8_t switch0; uint8_t switch0;
uint8_t switch1; uint8_t switch1;
bool wasOn; bool wasOn = false;
bool timedOut; bool timedOut = false;
bool reactedToBeingFaulty; bool reactedToBeingFaulty = false;
bool passive; bool passive = false;
MessageQueueIF* eventQueue; MessageQueueIF* eventQueue = nullptr;
Countdown heaterOnCountdown; Countdown heaterOnCountdown;
Countdown switchCountdown; Countdown switchCountdown;
ParameterHelper parameterHelper; ParameterHelper parameterHelper;
enum Action { enum Action {
SET, CLEAR SET, CLEAR
} lastAction; } lastAction = CLEAR;
void doAction(Action action); void doAction(Action action);
@ -87,4 +90,4 @@ protected:
void handleEventQueue(); void handleEventQueue();
}; };
#endif /* FRAMEWORK_THERMAL_HEATER_H_ */ #endif /* FSFW_THERMAL_HEATER_H_ */

View File

@ -1,11 +1,14 @@
#ifndef TEMPERATURESENSOR_H_ #ifndef FSFW_THERMAL_TEMPERATURESENSOR_H_
#define TEMPERATURESENSOR_H_ #define FSFW_THERMAL_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.
@ -58,26 +61,24 @@ 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 inputTemperature Pointer to a raw input value which is converted to an floating
* @param poolVariable Pool Variable to store the temperature value * point C output temperature
* @param outputGpid Global Pool ID of the output value
* @param vectorIndex Vector Index for the sensor monitor * @param vectorIndex Vector Index for the sensor monitor
* @param parameters Calculation parameters, temperature limits, gradient limit * @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 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, PoolVariableIF *poolVariable, gp_id_t outputGpid, uint8_t vectorIndex, Parameters parameters = {0, 0, 0, 0, 0, 0},
uint8_t vectorIndex, uint32_t datapoolId, Parameters parameters = {0, 0, 0, 0, 0, 0}, LocalPoolDataSetBase *outputSet = nullptr, ThermalModuleIF *thermalModule = nullptr) :
GlobDataSet *outputSet = NULL, ThermalModuleIF *thermalModule = NULL) :
AbstractTemperatureSensor(setObjectid, thermalModule), parameters(parameters), AbstractTemperatureSensor(setObjectid, thermalModule), parameters(parameters),
inputValue(inputValue), poolVariable(poolVariable), inputTemperature(inputTemperature),
outputTemperature(datapoolId, outputSet, PoolVariableIF::VAR_WRITE), outputTemperature(outputGpid, outputSet, PoolVariableIF::VAR_WRITE),
sensorMonitor(setObjectid, DOMAIN_ID_SENSOR, sensorMonitor(setObjectid, DOMAIN_ID_SENSOR, outputGpid,
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 +99,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 +109,8 @@ protected:
UsedParameters parameters; UsedParameters parameters;
inputType * inputValue; lp_var_t<limitType>* inputTemperature;
lp_var_t<float> outputTemperature;
PoolVariableIF *poolVariable;
gp_float_t outputTemperature;
LimitMonitor<limitType> sensorMonitor; LimitMonitor<limitType> sensorMonitor;
@ -120,13 +118,18 @@ protected:
timeval uptimeOfOldTemperature; timeval uptimeOfOldTemperature;
void doChildOperation() { void doChildOperation() {
if (!poolVariable->isValid() ReturnValue_t result = inputTemperature->read(MutexIF::TimeoutType::WAITING, 20);
|| !healthHelper.healthTable->isHealthy(getObjectId())) { if(result != HasReturnvaluesIF::RETURN_OK) {
return;
}
if ((not inputTemperature->isValid()) or
(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;
@ -148,17 +151,17 @@ protected:
} }
if (parameters.gradient < deltaTemp / deltaTime) { if (parameters.gradient < deltaTemp / deltaTime) {
triggerEvent(TEMP_SENSOR_GRADIENT); 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 <20>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;
@ -179,7 +182,10 @@ public:
static const uint16_t ADDRESS_C = 2; static const uint16_t ADDRESS_C = 2;
static const uint16_t ADDRESS_GRADIENT = 3; 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; static const uint8_t DOMAIN_ID_SENSOR = 1;
@ -219,4 +225,4 @@ public:
}; };
#endif /* TEMPERATURESENSOR_H_ */ #endif /* FSFW_THERMAL_TEMPERATURESENSOR_H_ */