fsfw/thermal/ThermalModule.h

101 lines
2.3 KiB
C
Raw Normal View History

2020-12-03 18:32:32 +01:00
#ifndef FSFW_THERMAL_THERMALMODULE_H_
#define FSFW_THERMAL_THERMALMODULE_H_
#include "ThermalModuleIF.h"
#include "tcsDefinitions.h"
#include "RedundantHeater.h"
2020-12-03 18:32:32 +01:00
#include "../datapoollocal/LocalPoolDataSetBase.h"
#include "../datapoollocal/LocalPoolVariable.h"
#include "../devicehandlers/HealthDevice.h"
#include "../events/EventReportingProxyIF.h"
#include <list>
class PowerSwitchIF;
2020-12-03 18:32:32 +01:00
/**
* @brief Allows creation of different thermal control domains within a system.
*/
class ThermalModule: public ThermalModuleIF {
friend class ThermalController;
public:
struct Parameters {
float heaterOn;
float hysteresis;
};
2020-12-03 18:32:32 +01:00
ThermalModule(gp_id_t moduleTemperaturePoolId, gp_id_t currentStatePoolId,
gp_id_t targetStatePoolId, LocalPoolDataSetBase *dataSet,
Parameters parameters, RedundantHeater::Parameters heaterParameters);
2020-12-03 18:32:32 +01:00
ThermalModule(gp_id_t moduleTemperaturePoolId,
LocalPoolDataSetBase *dataSet);
virtual ~ThermalModule();
void performOperation(uint8_t opCode);
void performMode(Strategy strategy);
float getTemperature();
void registerSensor(AbstractTemperatureSensor *sensor);
void registerComponent(ThermalComponentIF *component,
ThermalComponentIF::Priority priority);
ThermalComponentIF *findComponent(object_id_t objectId);
void initialize(PowerSwitchIF* powerSwitch);
void setHeating(bool on);
virtual void setOutputInvalid();
protected:
enum Informee {
ALL, SAFE, NONE
};
struct ComponentData {
ThermalComponentIF *component;
ThermalComponentIF::Priority priority;
ThermalComponentIF::HeaterRequest request;
};
Strategy oldStrategy;
2020-12-03 18:32:32 +01:00
float survivalTargetTemp = 0.0;
2020-12-03 18:32:32 +01:00
float targetTemp = 0.0;
2020-12-03 18:32:32 +01:00
bool heating = false;
Parameters parameters;
2020-12-03 18:32:32 +01:00
lp_var_t<float> moduleTemperature;
2020-12-03 18:32:32 +01:00
RedundantHeater *heater = nullptr;
2020-12-03 18:32:32 +01:00
lp_var_t<int8_t> currentState;
lp_var_t<int8_t> targetState;
std::list<AbstractTemperatureSensor *> sensors;
std::list<ComponentData> components;
void calculateTemperature();
ThermalComponentIF::HeaterRequest letComponentsPerformAndDeciceIfWeNeedToHeat(bool safeOnly);
void informComponentsAboutHeaterState(bool heaterIsOn,
Informee whomToInform);
bool calculateModuleHeaterRequestAndSetModuleStatus(Strategy strategy);
void updateTargetTemperatures(ThermalComponentIF *component, bool isSafe);
};
2020-12-03 18:32:32 +01:00
#endif /* FSFW_THERMAL_THERMALMODULE_H_ */