From 6fd10e718093f4b17f9ca3c4dff61dc628e89d2e Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Sun, 22 Jan 2023 20:37:51 +0100 Subject: [PATCH] bug fixed --- dummies/TemperatureSensorInserter.cpp | 4 +- dummies/TemperatureSensorInserter.h | 4 +- dummies/helpers.cpp | 4 +- mission/controller/ThermalController.cpp | 59 ++++++++++++++++-------- mission/controller/ThermalController.h | 7 +-- 5 files changed, 51 insertions(+), 27 deletions(-) diff --git a/dummies/TemperatureSensorInserter.cpp b/dummies/TemperatureSensorInserter.cpp index 4852440f..58748e87 100644 --- a/dummies/TemperatureSensorInserter.cpp +++ b/dummies/TemperatureSensorInserter.cpp @@ -6,8 +6,8 @@ #include TemperatureSensorInserter::TemperatureSensorInserter( - object_id_t objectId, const std::map& tempSensorDummies_, - const std::map& tempTmpSensorDummies_) + object_id_t objectId, const std::map& tempSensorDummies_, + const std::map& tempTmpSensorDummies_) : SystemObject(objects::THERMAL_TEMP_INSERTER) {} ReturnValue_t TemperatureSensorInserter::initialize() { diff --git a/dummies/TemperatureSensorInserter.h b/dummies/TemperatureSensorInserter.h index 1cf49e01..cf858576 100644 --- a/dummies/TemperatureSensorInserter.h +++ b/dummies/TemperatureSensorInserter.h @@ -9,8 +9,8 @@ class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject { public: explicit TemperatureSensorInserter( - object_id_t objectId, const std::map& tempSensorDummies_, - const std::map& tempTmpSensorDummies_); + object_id_t objectId, const std::map& tempSensorDummies_, + const std::map& tempTmpSensorDummies_); ReturnValue_t initialize() override; diff --git a/dummies/helpers.cpp b/dummies/helpers.cpp index db57d5ff..91e61aa4 100644 --- a/dummies/helpers.cpp +++ b/dummies/helpers.cpp @@ -82,7 +82,7 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { } if (cfg.addTempSensorDummies) { - std::map tempSensorDummies; + std::map tempSensorDummies; tempSensorDummies.emplace(objects::RTD_0_IC3_PLOC_HEATSPREADER, new Max31865Dummy(objects::RTD_0_IC3_PLOC_HEATSPREADER, objects::DUMMY_COM_IF, comCookieDummy)); @@ -132,7 +132,7 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { objects::RTD_15_IC18_IMTQ, new Max31865Dummy(objects::RTD_15_IC18_IMTQ, objects::DUMMY_COM_IF, comCookieDummy)); - std::map tempTmpSensorDummies; + std::map tempTmpSensorDummies; tempTmpSensorDummies.emplace( objects::TMP1075_HANDLER_TCS_0, new Tmp1075Dummy(objects::TMP1075_HANDLER_TCS_0, objects::DUMMY_COM_IF, comCookieDummy)); diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 0861c08a..d11eda72 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -984,11 +984,20 @@ void ThermalController::copyDevices() { } void ThermalController::ctrlAcsBoard() { - ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_0_OBC_BRD, - deviceTemperatures.gyro0SideA, deviceTemperatures.mgm0SideA, - deviceTemperatures.gyro1SideA, // mgm1(int), - // sensorTemperatures.sensor_tcs_board, - &acsBoardLimits); // TODO: add red sensors +// TODO: add red sensors, check sensor 4 + heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; + heater::Switchers redSwitchNr = heater::HEATER_0_OBC_BRD; + chooseHeater(switchNr, redSwitchNr); + + if (heaterAvailable) { + /*chooseOf5Sensors(switchNr, deviceTemperatures.gyro0SideA, deviceTemperatures.mgm0SideA, + deviceTemperatures.gyro1SideA, deviceTemperatures.mgt, + sensorTemperatures.sensor_tcs_board);*/ + + if (sensorTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, &acsBoardLimits); + } + } } void ThermalController::ctrlMgt() { @@ -1164,8 +1173,6 @@ void ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switch } else { heaterAvailable = false; triggerEvent(NO_HEALTHY_HEATER_AVAILABLE, switchNr, redSwitchNr); - sif::error << "ThermalController::chooseSensor: Both heater: " << switchNr << " + " - << redSwitchNr << " not healthy" << std::endl; } } else { redSwitchNrInUse = false; @@ -1173,8 +1180,7 @@ void ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switch } void ThermalController::chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1, - const lp_float_t& sensor2, const lp_float_t& sensor3, - bool moreThan3Sensors) { + const lp_float_t& sensor2, const lp_float_t& sensor3) { sensorTempAvailable = true; if (sensor1.isValid()) { @@ -1183,16 +1189,11 @@ void ThermalController::chooseSensor(heater::Switchers switchNr, const lp_float_ sensorTemp = sensor2.value; } else if (sensor3.isValid()) { sensorTemp = sensor3.value; - /*} else if (moreThan3Sensors and sensor4.isValid()) { - sensorTemp = sensor4.value; - } else if (moreThan3Sensors and sensor5.isValid()) { - sensorTemp = sensor5.value; */ } 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; + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); sensorTempAvailable = false; } } @@ -1201,15 +1202,37 @@ 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, - bool moreThan3Sensors) { + const lp_float_t& sensor3, TempLimits* tempLimit) { chooseHeater(switchNr, redSwitchNr); if (heaterAvailable) { - chooseSensor(switchNr, sensor1, sensor2, sensor3, moreThan3Sensors); + chooseSensor(switchNr, sensor1, sensor2, sensor3); if (sensorTempAvailable) { ctrlHeater(switchNr, redSwitchNr, tempLimit); } } } +void ThermalController::chooseOf5Sensors(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) { + sensorTempAvailable = true; + + if (sensor1.isValid()) { + sensorTemp = sensor1.value; + } else if (sensor2.isValid()) { + sensorTemp = sensor2.value; + } else if (sensor3.isValid()) { + sensorTemp = sensor3.value; + } else if (sensor4.isValid()) { + sensorTemp = sensor4.value; + } else if (sensor5.isValid()) { + sensorTemp = sensor5.value; + } else { + if (heaterHandler.checkSwitchState(switchNr)) { + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + } + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); + sensorTempAvailable = false; + } +} diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index c97b3fdc..7f3e8ac7 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -162,12 +162,13 @@ class ThermalController : public ExtendedControllerBase { 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, - bool moreThan3Sensors = false); // TODO sensor 4, 5 = default argument, if not available + const lp_float_t& sensor2, const lp_float_t& sensor3, TempLimits* tempLimit); // TODO sensor 4, 5 = default argument, if not available void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, TempLimits* tempLimit); 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, bool moreThan3Sensors); + const lp_float_t& sensor2, const lp_float_t& sensor3); + void chooseOf5Sensors(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); void ctrlAcsBoard(); void ctrlMgt();