changes thermal control
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Irini Kosmidou 2022-12-14 11:24:03 +01:00
parent 0b1136ad28
commit 8a9ed28845
2 changed files with 54 additions and 54 deletions

View File

@ -954,80 +954,49 @@ void ThermalController::copyDevices() {
} }
void ThermalController::ctrlMgt() { void ThermalController::ctrlMgt() {
float sensorTemp;
float opLowerLimit = mgtLimits.opLowerLimit; float opLowerLimit = mgtLimits.opLowerLimit;
float cutOffLimit = mgtLimits.cutOffLimit; float cutOffLimit = mgtLimits.cutOffLimit;
heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; heater::Switchers switchNr = heater::HEATER_2_ACS_BRD;
heater::Switchers redSwitchNr = heater::HEATER_3_PCDU_PDU; heater::Switchers redSwitchNr = heater::HEATER_3_PCDU_PDU;
bool cameraTempAvailable = true;
bool heaterAvailable = true;
bool redSwitchNrInUse = false;
// Choose Heater chooseHeater(switchNr, redSwitchNr);
chooseHeater(switchNr, redSwitchNr, redSwitchNrInUse, heaterAvailable);
if (heaterAvailable) { if (heaterAvailable) {
// Choose sensor chooseSensor(switchNr, sensorTemperatures.sensor_magnettorquer.value,
if (sensorTemperatures.sensor_magnettorquer.isValid()) { sensorTemperatures.sensor_magnettorquer.value,
sensorTemp = sensorTemperatures.sensor_magnettorquer.value; sensorTemperatures.sensor_plpcdu_heatspreader.value,
} else if (sensorTemperatures.sensor_magnettorquer.isValid()) { // TODO: int sensor sensorTemperatures.sensor_magnettorquer.isValid(),
sensorTemp = sensorTemperatures.sensor_magnettorquer.value; sensorTemperatures.sensor_magnettorquer.isValid(),
} else if (sensorTemperatures.sensor_plpcdu_heatspreader.isValid()) { sensorTemperatures.sensor_plpcdu_heatspreader.isValid()); // TODO: int sensor
sensorTemp = sensorTemperatures.sensor_plpcdu_heatspreader.value;
} else {
if (heaterHandler.checkSwitchState(switchNr)) {
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF);
}
triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr);
cameraTempAvailable = false;
}
// Thermal Control if (sensorTempAvailable) {
if (cameraTempAvailable) { ctrlHeater(switchNr, redSwitchNr, opLowerLimit, cutOffLimit);
ctrlHeater(switchNr, redSwitchNr, redSwitchNrInUse, sensorTemp, opLowerLimit, cutOffLimit);
} }
} }
} }
void ThermalController::ctrlCameraBody() { void ThermalController::ctrlCameraBody() {
// Camera Body // Camera Body
float sensorTemp;
float opLowerLimit = cameraLimits.opLowerLimit; float opLowerLimit = cameraLimits.opLowerLimit;
float cutOffLimit = cameraLimits.cutOffLimit; float cutOffLimit = cameraLimits.cutOffLimit;
heater::Switchers switchNr = heater::HEATER_4_CAMERA; heater::Switchers switchNr = heater::HEATER_4_CAMERA;
heater::Switchers redSwitchNr = heater::HEATER_6_DRO; heater::Switchers redSwitchNr = heater::HEATER_6_DRO;
bool cameraTempAvailable = true;
bool heaterAvailable = true;
bool redSwitchNrInUse = false;
// Choose Heater chooseHeater(switchNr, redSwitchNr);
chooseHeater(switchNr, redSwitchNr, redSwitchNrInUse, heaterAvailable);
if (heaterAvailable) { if (heaterAvailable) {
// Choose sensor chooseSensor(switchNr, sensorTemperatures.sensor_4k_camera.value,
if (sensorTemperatures.sensor_4k_camera.isValid()) { sensorTemperatures.sensor_dro.value, sensorTemperatures.sensor_mpa.value,
sensorTemp = sensorTemperatures.sensor_4k_camera.value; sensorTemperatures.sensor_4k_camera.isValid(),
} else if (sensorTemperatures.sensor_dro.isValid()) { sensorTemperatures.sensor_dro.isValid(), sensorTemperatures.sensor_mpa.isValid());
sensorTemp = sensorTemperatures.sensor_dro.value;
} else if (sensorTemperatures.sensor_mpa.isValid()) {
sensorTemp = sensorTemperatures.sensor_mpa.value;
} else {
if (heaterHandler.checkSwitchState(switchNr)) {
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF);
}
triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr);
cameraTempAvailable = false;
}
// Thermal Control if (sensorTempAvailable) {
if (cameraTempAvailable) { ctrlHeater(switchNr, redSwitchNr, opLowerLimit, cutOffLimit);
ctrlHeater(switchNr, redSwitchNr, redSwitchNrInUse, sensorTemp, opLowerLimit, cutOffLimit);
} }
} }
} }
void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr,
bool redSwitchNrInUse, float sensorTemp, float opLowerLimit, float opLowerLimit, float cutOffLimit) {
float cutOffLimit) {
// Heater off // Heater off
if (not heaterHandler.checkSwitchState(switchNr)) { if (not heaterHandler.checkSwitchState(switchNr)) {
// TODO: check if OP or NOP // TODO: check if OP or NOP
@ -1048,9 +1017,10 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers
} }
} }
void ThermalController::chooseHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, void ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr) {
bool& redSwitchNrInUse, bool& heaterAvailable) {
// Choose Heater // Choose Heater
heaterAvailable = true;
if (heaterHandler.getHealth(switchNr) != HasHealthIF::HEALTHY) { if (heaterHandler.getHealth(switchNr) != HasHealthIF::HEALTHY) {
if (heaterHandler.getHealth(redSwitchNr) == HasHealthIF::HEALTHY) { if (heaterHandler.getHealth(redSwitchNr) == HasHealthIF::HEALTHY) {
switchNr = redSwitchNr; switchNr = redSwitchNr;
@ -1059,5 +1029,28 @@ void ThermalController::chooseHeater(heater::Switchers switchNr, heater::Switche
heaterAvailable = false; heaterAvailable = false;
// TODO: triggerEvent ? // TODO: triggerEvent ?
} }
} else {
redSwitchNrInUse = false;
}
}
void ThermalController::chooseSensor(heater::Switchers switchNr, float sensorValue1,
float sensorValue2, float sensorValue3, bool sensor1Valid,
bool sensor2Valid, bool sensor3Valid) {
// Choose sensor
sensorTempAvailable = true;
if (sensor1Valid) {
sensorTemp = sensorValue1;
} else if (sensor2Valid) {
sensorTemp = sensorValue2;
} else if (sensor3Valid) {
sensorTemp = sensorValue3;
} else {
if (heaterHandler.checkSwitchState(switchNr)) {
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF);
}
triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr);
sensorTempAvailable = false;
} }
} }

View File

@ -134,6 +134,11 @@ class ThermalController : public ExtendedControllerBase {
TempLimits mpaLimits = 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); TempLimits scexBoardLimits = TempLimits(-60.0, -40.0, 80.0, 85.0, 150.0);
float sensorTemp;
bool sensorTempAvailable = true;
bool heaterAvailable = true;
bool redSwitchNrInUse = false;
// Initial delay to make sure all pool variables have been initialized their owners // Initial delay to make sure all pool variables have been initialized their owners
Countdown initialCountdown = Countdown(DELAY); Countdown initialCountdown = Countdown(DELAY);
@ -144,14 +149,16 @@ class ThermalController : public ExtendedControllerBase {
PoolEntry<float> tmp1075IfBrd = PoolEntry<float>(10.0); PoolEntry<float> tmp1075IfBrd = PoolEntry<float>(10.0);
static constexpr dur_millis_t MUTEX_TIMEOUT = 50; static constexpr dur_millis_t MUTEX_TIMEOUT = 50;
void copySensors(); void copySensors();
void copySus(); void copySus();
void copyDevices(); void copyDevices();
void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, bool redSwitchNrInUse, void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, float opLowerLimit,
float sensorTemp, float opLowerLimit, float cutOffLimit); float cutOffLimit);
void chooseHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, void chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr);
bool& redSwitchNrInUse, bool& heaterAvailable); void chooseSensor(heater::Switchers switchNr, float sensorValue1, float sensorValue2,
float sensorValue3, bool sensor1Valid, bool sensor2Valid, bool sensor3Valid);
void ctrlAcsBoard(); void ctrlAcsBoard();
void ctrlMgt(); void ctrlMgt();