2021-01-08 09:34:43 +01:00
|
|
|
#ifndef MISSION_CONTROLLER_THERMALCONTROLLER_H_
|
|
|
|
#define MISSION_CONTROLLER_THERMALCONTROLLER_H_
|
|
|
|
|
|
|
|
#include <fsfw/controller/ExtendedControllerBase.h>
|
2023-01-17 15:55:36 +01:00
|
|
|
#include <fsfw/devicehandlers/DeviceHandlerThermalSet.h>
|
2022-06-17 08:31:36 +02:00
|
|
|
#include <fsfw/timemanager/Countdown.h>
|
2022-02-14 13:49:12 +01:00
|
|
|
#include <mission/controller/controllerdefinitions/ThermalControllerDefinitions.h>
|
2022-05-19 23:08:54 +02:00
|
|
|
#include <mission/devices/devicedefinitions/Max31865Definitions.h>
|
2022-05-24 16:52:21 +02:00
|
|
|
#include <mission/devices/devicedefinitions/SusDefinitions.h>
|
2022-05-23 00:37:49 +02:00
|
|
|
#include <mission/devices/devicedefinitions/Tmp1075Definitions.h>
|
2022-02-10 18:29:28 +01:00
|
|
|
|
2022-11-27 16:58:57 +01:00
|
|
|
#include <list>
|
|
|
|
|
2022-11-24 16:40:59 +01:00
|
|
|
#include "../devices/HeaterHandler.h"
|
|
|
|
|
2022-11-24 15:51:24 +01:00
|
|
|
/**
|
|
|
|
* NOP Limit: Hard limit for device, usually from datasheet. Device damage is possible lif NOP limit
|
|
|
|
* is exceeded.
|
2022-11-24 16:40:59 +01:00
|
|
|
* 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
|
2022-11-24 15:51:24 +01:00
|
|
|
*/
|
2022-11-16 17:33:19 +01:00
|
|
|
struct TempLimits {
|
2022-12-13 10:19:28 +01:00
|
|
|
TempLimits(float nopLowerLimit, float opLowerLimit, float cutOffLimit, float opUpperLimit,
|
|
|
|
float nopUpperLimit)
|
2022-11-24 16:40:59 +01:00
|
|
|
: opLowerLimit(opLowerLimit),
|
|
|
|
opUpperLimit(opUpperLimit),
|
2022-12-12 20:07:54 +01:00
|
|
|
cutOffLimit(cutOffLimit),
|
2022-11-24 16:40:59 +01:00
|
|
|
nopLowerLimit(nopLowerLimit),
|
|
|
|
nopUpperLimit(nopUpperLimit) {}
|
2022-11-24 11:35:05 +01:00
|
|
|
float opLowerLimit;
|
|
|
|
float opUpperLimit;
|
2022-12-12 20:07:54 +01:00
|
|
|
float cutOffLimit;
|
2022-11-24 11:35:05 +01:00
|
|
|
float nopLowerLimit;
|
|
|
|
float nopUpperLimit;
|
2022-11-16 17:33:19 +01:00
|
|
|
};
|
|
|
|
|
2022-02-10 18:54:09 +01:00
|
|
|
class ThermalController : public ExtendedControllerBase {
|
2022-01-17 15:58:27 +01:00
|
|
|
public:
|
2022-05-23 00:37:49 +02:00
|
|
|
static const uint16_t INVALID_TEMPERATURE = 999;
|
2022-11-27 16:58:57 +01:00
|
|
|
static const uint8_t NUMBER_OF_SENSORS = 16;
|
2022-05-23 00:37:49 +02:00
|
|
|
|
2022-11-23 19:38:30 +01:00
|
|
|
ThermalController(object_id_t objectId, HeaterHandler& heater);
|
2021-01-08 09:34:43 +01:00
|
|
|
|
2022-02-17 16:29:22 +01:00
|
|
|
ReturnValue_t initialize() override;
|
2022-02-10 18:54:09 +01:00
|
|
|
|
2022-02-14 13:49:12 +01:00
|
|
|
protected:
|
2022-02-10 18:54:09 +01:00
|
|
|
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;
|
2022-02-14 13:49:12 +01:00
|
|
|
|
2022-05-19 23:08:54 +02:00
|
|
|
private:
|
2023-01-17 15:55:36 +01:00
|
|
|
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::TCS_CONTROLLER;
|
|
|
|
static constexpr Event NO_VALID_SENSOR_TEMPERATURE = MAKE_EVENT(0, severity::MEDIUM);
|
|
|
|
static constexpr Event NO_HEALTHY_HEATER_AVAILABLE = MAKE_EVENT(1, severity::MEDIUM);
|
2022-11-28 10:06:49 +01:00
|
|
|
|
2022-06-16 07:00:09 +02:00
|
|
|
static const uint32_t DELAY = 500;
|
2022-11-28 10:06:49 +01:00
|
|
|
|
2022-12-12 21:33:12 +01:00
|
|
|
static const uint32_t TEMP_OFFSET = 5;
|
2022-06-16 07:00:09 +02:00
|
|
|
|
2022-06-17 08:31:36 +02:00
|
|
|
enum class InternalState { STARTUP, INITIAL_DELAY, READY };
|
2022-06-16 07:00:09 +02:00
|
|
|
|
|
|
|
InternalState internalState = InternalState::STARTUP;
|
|
|
|
|
2022-11-24 16:40:59 +01:00
|
|
|
HeaterHandler& heaterHandler;
|
|
|
|
|
2022-02-14 13:49:12 +01:00
|
|
|
thermalControllerDefinitions::SensorTemperatures sensorTemperatures;
|
2022-05-24 16:52:21 +02:00
|
|
|
thermalControllerDefinitions::SusTemperatures susTemperatures;
|
2022-05-23 00:37:49 +02:00
|
|
|
thermalControllerDefinitions::DeviceTemperatures deviceTemperatures;
|
2022-05-19 23:08:54 +02:00
|
|
|
|
2023-01-17 15:45:54 +01:00
|
|
|
DeviceHandlerThermalSet imtqThermalSet;
|
|
|
|
|
2022-05-24 16:52:21 +02:00
|
|
|
// Temperature Sensors
|
2022-11-25 10:13:24 +01:00
|
|
|
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;
|
2023-01-09 11:57:48 +01:00
|
|
|
|
2022-11-14 10:04:41 +01:00
|
|
|
TMP1075::Tmp1075Dataset tmp1075SetTcs0;
|
|
|
|
TMP1075::Tmp1075Dataset tmp1075SetTcs1;
|
|
|
|
TMP1075::Tmp1075Dataset tmp1075SetPlPcdu0;
|
2023-01-09 11:57:48 +01:00
|
|
|
// damaged
|
|
|
|
// TMP1075::Tmp1075Dataset tmp1075SetPlPcdu1;
|
2022-11-14 10:04:41 +01:00
|
|
|
TMP1075::Tmp1075Dataset tmp1075SetIfBoard;
|
2022-05-19 23:08:54 +02:00
|
|
|
|
2022-05-24 16:52:21 +02:00
|
|
|
// 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;
|
2022-05-23 00:37:49 +02:00
|
|
|
|
2022-11-24 16:40:59 +01:00
|
|
|
// TempLimits
|
2022-12-12 20:07:54 +01:00
|
|
|
TempLimits acsBoardLimits = TempLimits(-40.0, -40.0, 80.0, 85.0, 85.0);
|
|
|
|
TempLimits mgtLimits = TempLimits(-40.0, -40.0, 65.0, 70.0, 70.0);
|
|
|
|
TempLimits rwLimits = TempLimits(-40.0, -40.0, 80.0, 85.0, 85.0);
|
|
|
|
TempLimits strLimits = TempLimits(-30.0, -20.0, 65.0, 70.0, 80.0);
|
|
|
|
TempLimits ifBoardLimits = TempLimits(-65.0, -40.0, 80.0, 85.0, 150.0);
|
|
|
|
TempLimits tcsBoardLimits = TempLimits(-60.0, -40.0, 80.0, 85.0, 130.0);
|
|
|
|
TempLimits obcLimits = TempLimits(-40.0, -40.0, 80.0, 85.0, 85.0);
|
|
|
|
TempLimits obcIfBoardLimits = TempLimits(-65.0, -40.0, 80.0, 85.0, 125.0);
|
|
|
|
TempLimits sBandTransceiverLimits = TempLimits(-40.0, -25.0, 35.0, 40.0, 65.0);
|
|
|
|
TempLimits pcduP60BoardLimits = TempLimits(-35.0, -35.0, 80.0, 85.0, 85.0);
|
|
|
|
TempLimits pcduAcuLimits = TempLimits(-35.0, -35.0, 80.0, 85.0, 85.0);
|
|
|
|
TempLimits pcduPduLimits = TempLimits(-35.0, -35.0, 80.0, 85.0, 85.0);
|
|
|
|
TempLimits plPcduBoardLimits = TempLimits(-55.0, -40.0, 80.0, 85.0, 125.0);
|
|
|
|
TempLimits plocMissionBoardLimits = TempLimits(-30.0, -10.0, 40.0, 45.0, 60);
|
|
|
|
TempLimits plocProcessingBoardLimits = TempLimits(-30.0, -10.0, 40.0, 45.0, 60.0);
|
|
|
|
TempLimits dacLimits = TempLimits(-65.0, -40.0, 113.0, 118.0, 150.0);
|
|
|
|
TempLimits cameraLimits = TempLimits(-40.0, -30.0, 60.0, 65.0, 85.0);
|
|
|
|
TempLimits droLimits = TempLimits(-40.0, -30.0, 75.0, 80.0, 90.0);
|
|
|
|
TempLimits x8Limits = TempLimits(-40.0, -30.0, -75.0, 80.0, 90.0);
|
|
|
|
TempLimits hpaLimits = TempLimits(-40.0, -30.0, -75.0, 80.0, 90.0);
|
|
|
|
TempLimits txLimits = TempLimits(-40.0, -30.0, -75.0, 80.0, 90.0);
|
|
|
|
TempLimits mpaLimits = TempLimits(-40.0, -30.0, -75.0, 80.0, 90.0);
|
|
|
|
TempLimits scexBoardLimits = TempLimits(-60.0, -40.0, 80.0, 85.0, 150.0);
|
2022-11-16 17:33:19 +01:00
|
|
|
|
2023-01-17 15:55:36 +01:00
|
|
|
float sensorTemp = 0.0;
|
2022-12-14 11:24:03 +01:00
|
|
|
bool sensorTempAvailable = true;
|
|
|
|
bool heaterAvailable = true;
|
|
|
|
bool redSwitchNrInUse = false;
|
|
|
|
|
2022-06-16 07:00:09 +02:00
|
|
|
// Initial delay to make sure all pool variables have been initialized their owners
|
|
|
|
Countdown initialCountdown = Countdown(DELAY);
|
|
|
|
|
2022-11-14 10:11:44 +01:00
|
|
|
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);
|
|
|
|
|
2022-10-18 14:08:26 +02:00
|
|
|
static constexpr dur_millis_t MUTEX_TIMEOUT = 50;
|
2022-12-14 11:24:03 +01:00
|
|
|
|
2022-05-24 16:52:21 +02:00
|
|
|
void copySensors();
|
|
|
|
void copySus();
|
2022-05-23 00:37:49 +02:00
|
|
|
void copyDevices();
|
2022-11-28 17:40:29 +01:00
|
|
|
|
2023-01-23 22:29:29 +01:00
|
|
|
void ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr,
|
|
|
|
const lp_float_t& sensor1, const lp_float_t& sensor2,
|
|
|
|
const lp_float_t& sensor3, TempLimits* tempLimit);
|
2023-01-05 19:39:51 +01:00
|
|
|
void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, TempLimits* tempLimit);
|
2022-12-14 11:24:03 +01:00
|
|
|
void chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr);
|
2023-01-04 19:03:01 +01:00
|
|
|
void chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1,
|
2023-01-22 20:37:51 +01:00
|
|
|
const lp_float_t& sensor2, const lp_float_t& sensor3);
|
2023-01-23 22:29:29 +01:00
|
|
|
void chooseOf4Sensors(heater::Switchers switchNr, const lp_float_t& sensor1,
|
|
|
|
const lp_float_t& sensor2, const lp_float_t& sensor3,
|
|
|
|
const lp_float_t& sensor4);
|
2023-01-22 20:37:51 +01:00
|
|
|
void chooseOf5Sensors(heater::Switchers switchNr, const lp_float_t& sensor1,
|
2023-01-23 22:29:29 +01:00
|
|
|
const lp_float_t& sensor2, const lp_float_t& sensor3,
|
|
|
|
const lp_float_t& sensor4, const lp_float_t& sensor5);
|
2022-12-13 12:08:53 +01:00
|
|
|
|
|
|
|
void ctrlAcsBoard();
|
|
|
|
void ctrlMgt();
|
|
|
|
void ctrlRw();
|
|
|
|
void ctrlStr();
|
|
|
|
void ctrlIfBoard();
|
|
|
|
void ctrlTcsBoard();
|
|
|
|
void ctrlObc();
|
|
|
|
void ctrlObcIfBoard();
|
|
|
|
void ctrlSBandTransceiver();
|
|
|
|
void ctrlPcduP60Board();
|
|
|
|
void ctrlPcduAcu();
|
|
|
|
void ctrlPcduPdu();
|
|
|
|
void ctrlPlPcduBoard();
|
|
|
|
void ctrlPlocMissionBoard();
|
|
|
|
void ctrlPlocProcessingBoard();
|
|
|
|
void ctrlDac();
|
|
|
|
void ctrlCameraBody();
|
|
|
|
void ctrlDro();
|
|
|
|
void ctrlX8();
|
|
|
|
void ctrlHpa();
|
|
|
|
void ctrlTx();
|
|
|
|
void ctrlMpa();
|
|
|
|
void ctrlScexBoard();
|
2021-01-08 09:34:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */
|