eive-obsw/mission/controller/ThermalController.h
Irini Kosmidou 0484daac23
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit
thermal control first draft
2022-11-27 16:58:57 +01:00

150 lines
5.8 KiB
C++

#ifndef MISSION_CONTROLLER_THERMALCONTROLLER_H_
#define MISSION_CONTROLLER_THERMALCONTROLLER_H_
#include <fsfw/controller/ExtendedControllerBase.h>
#include <fsfw/timemanager/Countdown.h>
#include <mission/controller/controllerdefinitions/ThermalControllerDefinitions.h>
#include <mission/devices/devicedefinitions/Max31865Definitions.h>
#include <mission/devices/devicedefinitions/SusDefinitions.h>
#include <mission/devices/devicedefinitions/Tmp1075Definitions.h>
#include <list>
#include "../devices/HeaterHandler.h"
/**
* NOP Limit: Hard limit for device, usually from datasheet. Device damage is possible lif NOP limit
* is exceeded.
* OP Limit: Soft limit. Device should be switched off or TCS controller should take action if the
* limit is exceeded to avoid reaching NOP limit
*/
struct TempLimits {
TempLimits(float nopLowerLimit, float opLowerLimit, float opUpperLimit, float nopUpperLimit)
: opLowerLimit(opLowerLimit),
opUpperLimit(opUpperLimit),
nopLowerLimit(nopLowerLimit),
nopUpperLimit(nopUpperLimit) {}
float opLowerLimit;
float opUpperLimit;
float nopLowerLimit;
float nopUpperLimit;
// TODO define limits
};
class ThermalController : public ExtendedControllerBase {
public:
static const uint16_t INVALID_TEMPERATURE = 999;
static const uint8_t NUMBER_OF_SENSORS = 16;
ThermalController(object_id_t objectId, HeaterHandler& heater);
ReturnValue_t initialize() override;
protected:
virtual ReturnValue_t handleCommandMessage(CommandMessage* message) override;
virtual void performControlOperation() override;
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
// Mode abstract functions
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t* msToReachTheMode) override;
private:
static const uint32_t DELAY = 500;
static const uint32_t OP_TIME = 1000; //TODO to be changed
enum class InternalState { STARTUP, INITIAL_DELAY, READY };
InternalState internalState = InternalState::STARTUP;
HeaterHandler& heaterHandler;
thermalControllerDefinitions::SensorTemperatures sensorTemperatures;
thermalControllerDefinitions::SusTemperatures susTemperatures;
thermalControllerDefinitions::DeviceTemperatures deviceTemperatures;
// Temperature Sensors
MAX31865::PrimarySet max31865Set0;
MAX31865::PrimarySet max31865Set1;
MAX31865::PrimarySet max31865Set2;
MAX31865::PrimarySet max31865Set3;
MAX31865::PrimarySet max31865Set4;
MAX31865::PrimarySet max31865Set5;
MAX31865::PrimarySet max31865Set6;
MAX31865::PrimarySet max31865Set7;
MAX31865::PrimarySet max31865Set8;
MAX31865::PrimarySet max31865Set9;
MAX31865::PrimarySet max31865Set10;
MAX31865::PrimarySet max31865Set11;
MAX31865::PrimarySet max31865Set12;
MAX31865::PrimarySet max31865Set13;
MAX31865::PrimarySet max31865Set14;
MAX31865::PrimarySet max31865Set15;
TMP1075::Tmp1075Dataset tmp1075SetTcs0;
TMP1075::Tmp1075Dataset tmp1075SetTcs1;
TMP1075::Tmp1075Dataset tmp1075SetPlPcdu0;
TMP1075::Tmp1075Dataset tmp1075SetPlPcdu1;
TMP1075::Tmp1075Dataset tmp1075SetIfBoard;
// SUS
SUS::SusDataset susSet0;
SUS::SusDataset susSet1;
SUS::SusDataset susSet2;
SUS::SusDataset susSet3;
SUS::SusDataset susSet4;
SUS::SusDataset susSet5;
SUS::SusDataset susSet6;
SUS::SusDataset susSet7;
SUS::SusDataset susSet8;
SUS::SusDataset susSet9;
SUS::SusDataset susSet10;
SUS::SusDataset susSet11;
// TempLimits
// TempLimits plocHeatspreaderLimits = TempLimits(-20.0, 70.0, -30.0, 80.0);
// TempLimits plocMissionBoardLimits = TempLimits(-20.0, 70.0, -30.0, 80.0);
TempLimits cameraLimits = TempLimits(-40.0, -30.0, 65.0, 85.0);
TempLimits dacHeatspreaderLimits = TempLimits(-65.0, -40.0, 118.0, 150.0);
TempLimits strLimits = TempLimits(-30.0, -20.0, 70.0, 80.0);
TempLimits rw1Limits = TempLimits(-40.0, -40.0, 85.0, 85.0);
// TempLimits droLimits = TempLimits(-20.0, 70.0, -30.0, 80.0);
TempLimits scexLimits = TempLimits(-60.0, -40.0, 85.0, 150.0);
// TempLimits x8Limits = TempLimits(-20.0, 70.0, -30.0, 80.0);
// TempLimits hpaLimits = TempLimits(-20.0, 70.0, -30.0, 80.0);
// TempLimits txModuleLimits = TempLimits(-20.0, 70.0, -30.0, 80.0);
// TempLimits mpaLimits = TempLimits(-20.0, 70.0, -30.0, 80.0);
TempLimits acuLimits = TempLimits(-55.0, -35.0, 85.0, 150.0); // TODO nopLimits
TempLimits plpcduHeatspreaderLimits = TempLimits(-65.0, -40.0, 85.0, 125.0); // TODO check
TempLimits tcsBoardLimits = TempLimits(-60.0, -40.0, 85.0, 130.0);
TempLimits magnettorquerLimits = TempLimits(-40.0, -30.0, 70.0, 80.0); // TODO nopLimits
// Initial delay to make sure all pool variables have been initialized their owners
Countdown initialCountdown = Countdown(DELAY);
// Heater Countdown to make sure heater
Countdown heater0Countdown = Countdown(OP_TIME);
Countdown heater1Countdown = Countdown(OP_TIME);
Countdown heater2Countdown = Countdown(OP_TIME);
Countdown heater3Countdown = Countdown(OP_TIME);
Countdown heater4Countdown = Countdown(OP_TIME);
Countdown heater5Countdown = Countdown(OP_TIME);
Countdown heater6Countdown = Countdown(OP_TIME);
Countdown heater7Countdown = Countdown(OP_TIME);
PoolEntry<float> tmp1075Tcs0 = PoolEntry<float>(10.0);
PoolEntry<float> tmp1075Tcs1 = PoolEntry<float>(10.0);
PoolEntry<float> tmp1075PlPcdu0 = PoolEntry<float>(10.0);
PoolEntry<float> tmp1075PlPcdu1 = PoolEntry<float>(10.0);
PoolEntry<float> tmp1075IfBrd = PoolEntry<float>(10.0);
static constexpr dur_millis_t MUTEX_TIMEOUT = 50;
void copySensors();
void copySus();
void copyDevices();
};
#endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */