Heater Handling #325

Merged
muellerr merged 78 commits from heater_handling into develop 2023-02-08 21:35:05 +01:00
2 changed files with 57 additions and 110 deletions
Showing only changes of commit a81e7c5057 - Show all commits

View File

@ -105,7 +105,7 @@ void ThermalController::performControlOperation() {
} }
// TODO: Heater control // TODO: Heater control
ctrlCameraBody(); //ctrlCameraBody();
/*ctrlAcsBoard(); /*ctrlAcsBoard();
ctrlMgt(); ctrlMgt();
ctrlRw(); ctrlRw();
@ -978,7 +978,10 @@ void ThermalController::copyDevices() {
/* /*
void ThermalController::ctrlAcsBoard() { void ThermalController::ctrlAcsBoard() {
ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_0_OBC_BRD, &acsBoardLimits); ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_0_OBC_BRD,
deviceTemperatures.gyro0SideA, deviceTemperatures.mgm0SideA,
deviceTemperatures.gyro1SideA,
&acsBoardLimits); // TODO: add red sensors
} }
void ThermalController::ctrlMgt() { void ThermalController::ctrlMgt() {
@ -988,11 +991,11 @@ void ThermalController::ctrlMgt() {
chooseHeater(switchNr, redSwitchNr); chooseHeater(switchNr, redSwitchNr);
if (heaterAvailable) { if (heaterAvailable) {
chooseSensorOldVersion(switchNr, sensorTemperatures.sensor_magnettorquer.value, chooseSensorOldVersion(
deviceTemperatures.mgt.value, sensorTemperatures.sensor_plpcdu_heatspreader.value, switchNr, sensorTemperatures.sensor_magnettorquer.value, deviceTemperatures.mgt.value,
sensorTemperatures.sensor_magnettorquer.isValid(), sensorTemperatures.sensor_plpcdu_heatspreader.value,
deviceTemperatures.mgt.isValid(), sensorTemperatures.sensor_magnettorquer.isValid(), deviceTemperatures.mgt.isValid(),
sensorTemperatures.sensor_plpcdu_heatspreader.isValid()); sensorTemperatures.sensor_plpcdu_heatspreader.isValid());
if (sensorTempAvailable) { if (sensorTempAvailable) {
ctrlHeater(switchNr, redSwitchNr, &mgtLimits); ctrlHeater(switchNr, redSwitchNr, &mgtLimits);
@ -1001,44 +1004,20 @@ void ThermalController::ctrlMgt() {
} }
void ThermalController::ctrlRw() { void ThermalController::ctrlRw() {
ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, &rwLimits); // ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO,
// sensorTemperatures.sensor_rw1, deviceTemperatures.rw1, deviceTemperatures.rw3, &rwLimits);
} }
void ThermalController::ctrlStr() { void ThermalController::ctrlStr() {
heater::Switchers switchNr = heater::HEATER_5_STR; ctrlComponentTemperature(heater::HEATER_5_STR, heater::HEATER_6_DRO,
heater::Switchers redSwitchNr = heater::HEATER_6_DRO; sensorTemperatures.sensor_startracker, deviceTemperatures.startracker,
sensorTemperatures.sensor_dro, &strLimits);
chooseHeater(switchNr, redSwitchNr);
if (heaterAvailable) {
chooseSensorOldVersion(switchNr, sensorTemperatures.sensor_startracker.value,
deviceTemperatures.startracker.value, sensorTemperatures.sensor_dro.value,
sensorTemperatures.sensor_startracker.isValid(),
deviceTemperatures.startracker.isValid(), sensorTemperatures.sensor_dro.isValid());
if (sensorTempAvailable) {
ctrlHeater(switchNr, redSwitchNr, &strLimits);
}
}
} }
void ThermalController::ctrlIfBoard() { void ThermalController::ctrlIfBoard() {
heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_3_PCDU_PDU,
heater::Switchers redSwitchNr = heater::HEATER_3_PCDU_PDU; sensorTemperatures.tmp1075IfBrd, sensorTemperatures.sensor_magnettorquer,
deviceTemperatures.mgm2SideB, &ifBoardLimits);
chooseHeater(switchNr, redSwitchNr);
if (heaterAvailable) {
chooseSensorOldVersion(switchNr, sensorTemperatures.tmp1075IfBrd.value,
sensorTemperatures.sensor_magnettorquer.value, deviceTemperatures.mgm2SideB.value,
sensorTemperatures.tmp1075IfBrd.isValid(),
sensorTemperatures.sensor_magnettorquer.isValid(),
deviceTemperatures.mgm2SideB.isValid());
if (sensorTempAvailable) {
ctrlHeater(switchNr, redSwitchNr, &ifBoardLimits);
}
}
} }
void ThermalController::ctrlTcsBoard() { void ThermalController::ctrlTcsBoard() {
@ -1080,49 +1059,25 @@ void ThermalController::ctrlPlocMissionBoard() {
} }
void ThermalController::ctrlPlocProcessingBoard() { void ThermalController::ctrlPlocProcessingBoard() {
heater::Switchers switchNr = heater::HEATER_1_PLOC_PROC_BRD; ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD,
heater::Switchers redSwitchNr = heater::HEATER_0_OBC_BRD; sensorTemperatures.sensor_ploc_missionboard,
sensorTemperatures.sensor_ploc_heatspreader,
chooseHeater(switchNr, redSwitchNr); sensorTemperatures.sensor_dac_heatspreader, &plocProcessingBoardLimits);
if (heaterAvailable) {
chooseSensorOldVersion(switchNr, sensorTemperatures.sensor_ploc_missionboard.value,
sensorTemperatures.sensor_ploc_heatspreader.value,
sensorTemperatures.sensor_dac_heatspreader.value,
sensorTemperatures.sensor_ploc_missionboard.isValid(),
sensorTemperatures.sensor_ploc_heatspreader.isValid(),
sensorTemperatures.sensor_dac_heatspreader.isValid());
if (sensorTempAvailable) {
ctrlHeater(switchNr, redSwitchNr, &plocProcessingBoardLimits);
}
}
} }
void ThermalController::ctrlDac() { void ThermalController::ctrlDac() {
heater::Switchers switchNr = heater::HEATER_1_PLOC_PROC_BRD; ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD,
heater::Switchers redSwitchNr = heater::HEATER_0_OBC_BRD; sensorTemperatures.sensor_dac_heatspreader,
sensorTemperatures.sensor_ploc_missionboard,
chooseHeater(switchNr, redSwitchNr); sensorTemperatures.sensor_ploc_heatspreader, &dacLimits);
if (heaterAvailable) {
chooseSensorOldVersion(switchNr, sensorTemperatures.sensor_dac_heatspreader.value,
sensorTemperatures.sensor_ploc_missionboard.value,
sensorTemperatures.sensor_ploc_heatspreader.value,
sensorTemperatures.sensor_dac_heatspreader.isValid(),
sensorTemperatures.sensor_ploc_missionboard.isValid(),
sensorTemperatures.sensor_ploc_heatspreader.isValid());
if (sensorTempAvailable) {
ctrlHeater(switchNr, redSwitchNr, &dacLimits);
}
}
} }
*/
void ThermalController::ctrlCameraBody() { void ThermalController::ctrlCameraBody() {
ctrlComponentTemperature(heater::HEATER_4_CAMERA, heater::HEATER_6_DRO, sensorTemperatures.sensor_4k_camera, sensorTemperatures.sensor_dro, sensorTemperatures.sensor_mpa, &cameraLimits); ctrlComponentTemperature(heater::HEATER_4_CAMERA, heater::HEATER_6_DRO,
sensorTemperatures.sensor_4k_camera, sensorTemperatures.sensor_dro,
sensorTemperatures.sensor_mpa, &cameraLimits);
} }
/*
void ThermalController::ctrlDro() { void ThermalController::ctrlDro() {
ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, &droLimits); ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, &droLimits);
} }
@ -1178,15 +1133,19 @@ void ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switch
redSwitchNrInUse = true; redSwitchNrInUse = true;
} else { } else {
heaterAvailable = false; heaterAvailable = false;
//TODO: triggerEvent(NO_HEALTHY_HEATER_AVAILABLE, switchNr, redSwitchNr); // TODO: triggerEvent(NO_HEALTHY_HEATER_AVAILABLE, switchNr, redSwitchNr);
sif::error << "ThermalController::chooseSensor: Both heater: "<< switchNr << " + " << redSwitchNr << " not healthy" << std::endl; sif::error << "ThermalController::chooseSensor: Both heater: " << switchNr << " + "
<< redSwitchNr << " not healthy" << std::endl;
} }
} else { } else {
redSwitchNrInUse = false; redSwitchNrInUse = false;
} }
} }
void ThermalController::chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, const lp_float_t& sensor3) { void ThermalController::chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1,
const lp_float_t& sensor2, const lp_float_t& sensor3,
const lp_float_t& sensor4, const lp_float_t& sensor5,
bool moreThan3Sensors) {
sensorTempAvailable = true; sensorTempAvailable = true;
if (sensor1.isValid()) { if (sensor1.isValid()) {
@ -1195,44 +1154,29 @@ void ThermalController::chooseSensor(heater::Switchers switchNr, const lp_float_
sensorTemp = sensor2.value; sensorTemp = sensor2.value;
} else if (sensor3.isValid()) { } else if (sensor3.isValid()) {
sensorTemp = sensor3.value; sensorTemp = sensor3.value;
} else if (moreThan3Sensors and sensor4.isValid()) {
sensorTemp = sensor4.value;
} else if (moreThan3Sensors and sensor5.isValid()) {
sensorTemp = sensor5.value;
} else { } else {
if (heaterHandler.checkSwitchState(switchNr)) { if (heaterHandler.checkSwitchState(switchNr)) {
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF);
} }
//TODO: triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); // TODO: triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr);
sif::error << "ThermalController::chooseSensor: No valid Sensor found"<< std::endl; sif::error << "ThermalController::chooseSensor: No valid Sensor found" << std::endl;
sensorTempAvailable = false; sensorTempAvailable = false;
} }
} }
void ThermalController::chooseSensorOldVersion(heater::Switchers switchNr, float sensorValue1,
float sensorValue2, float sensorValue3, bool sensor1Valid,
bool sensor2Valid, bool sensor3Valid) {
sensorTempAvailable = true;
if (sensor1Valid) { void ThermalController::ctrlComponentTemperature(
sensorTemp = sensorValue1; heater::Switchers switchNr, heater::Switchers redSwitchNr, const lp_float_t& sensor1,
} else if (sensor2Valid) { const lp_float_t& sensor2, const lp_float_t& sensor3, const lp_float_t& sensor4,
sensorTemp = sensorValue2; const lp_float_t& sensor5, TempLimits* tempLimit, bool moreThan3Sensors) {
} else if (sensor3Valid) {
sensorTemp = sensorValue3;
} else {
if (heaterHandler.checkSwitchState(switchNr)) {
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF);
}
//TODO: triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr);
sif::error << "ThermalController::chooseSensor: No valid Sensor found"<< std::endl;
sensorTempAvailable = false;
}
}
void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr,
heater::Switchers redSwitchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, const lp_float_t& sensor3,
TempLimits* tempLimit) {
chooseHeater(switchNr, redSwitchNr); chooseHeater(switchNr, redSwitchNr);
if (heaterAvailable) { if (heaterAvailable) {
chooseSensor(switchNr, sensor1, sensor2, sensor3); chooseSensor(switchNr, sensor1, sensor2, sensor3, sensor4, sensor5, moreThan3Sensors);
if (sensorTempAvailable) { if (sensorTempAvailable) {
ctrlHeater(switchNr, redSwitchNr, tempLimit); ctrlHeater(switchNr, redSwitchNr, tempLimit);

View File

@ -155,14 +155,17 @@ class ThermalController : public ExtendedControllerBase {
void copySus(); void copySus();
void copyDevices(); void copyDevices();
void ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, const lp_float_t& sensor3, void ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr,
TempLimits* tempLimit); const lp_float_t& sensor1, const lp_float_t& sensor2,
const lp_float_t& sensor3, const lp_float_t& sensor4,
const lp_float_t& sensor5, TempLimits* tempLimit,
bool moreThan3Sensors = false);
void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr,
struct TempLimits* tempLimit); struct TempLimits* tempLimit);
void chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr); void chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr);
void chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, const lp_float_t& sensor3); void chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1,
void chooseSensorOldVersion(heater::Switchers switchNr, float sensorValue1, float sensorValue2, const lp_float_t& sensor2, const lp_float_t& sensor3, const lp_float_t& sensor4,
float sensorValue3, bool sensor1Valid, bool sensor2Valid, bool sensor3Valid); const lp_float_t& sensor5, bool moreThan3Sensors);
void ctrlAcsBoard(); void ctrlAcsBoard();
void ctrlMgt(); void ctrlMgt();