diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 42d79a2a..c31ff3f8 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -17,7 +17,7 @@ #include // Enabling this should trigger a special event which in turn should trigger a system reaction. -#define LOWER_SYRLINKS_UPPER_LIMITS 1 +#define LOWER_SYRLINKS_UPPER_LIMITS 0 ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater) : ExtendedControllerBase(objectId), @@ -67,11 +67,6 @@ ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater susSet11(objects::SUS_11_R_LOC_XBYMZB_PT_ZB) { resetSensorsArray(); -#if LOWER_SYRLINKS_UPPER_LIMITS == 1 - sBandTransceiverLimits.cutOffLimit = 0; - sBandTransceiverLimits.opUpperLimit = 0; - sBandTransceiverLimits.nopUpperLimit = 0; -#endif } ReturnValue_t ThermalController::initialize() { @@ -91,6 +86,7 @@ void ThermalController::performControlOperation() { #if OBSW_THREAD_TRACING == 1 trace::threadTrace(opCounter, "TCS Task"); #endif + switch (internalState) { case InternalState::STARTUP: { initialCountdown.resetTimer(); @@ -99,6 +95,7 @@ void ThermalController::performControlOperation() { } case InternalState::INITIAL_DELAY: { if (initialCountdown.hasTimedOut()) { + sif::info << "Starting thermal control operations" << std::endl; internalState = InternalState::READY; } return; @@ -110,6 +107,14 @@ void ThermalController::performControlOperation() { break; } + if(cycles == 50) { +#if LOWER_SYRLINKS_UPPER_LIMITS == 1 + sBandTransceiverLimits.cutOffLimit = 0; + sBandTransceiverLimits.opUpperLimit = 0; + sBandTransceiverLimits.nopUpperLimit = 0; +#endif + } + { PoolReadGuard pg(&sensorTemperatures); if (pg.getReadResult() == returnvalue::OK) { @@ -143,6 +148,7 @@ void ThermalController::performControlOperation() { } performThermalModuleCtrl(); + cycles++; } ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, @@ -1217,7 +1223,7 @@ void ThermalController::ctrlSBandTransceiver() { triggerEvent(tcsCtrl::SYRLINKS_OVERHEATING, tempFloatToU32()); syrlinksTooHotFlag = true; } else if (not componentAboveUpperLimit) { - syrlinksTooHotFlag = true; + syrlinksTooHotFlag = false; } } void ThermalController::ctrlPcduP60Board() { @@ -1541,8 +1547,8 @@ void ThermalController::checkLimitsAndCtrlHeater(heater::Switchers switchNr, componentAboveUpperLimit = false; auto tempTooHighHandler = [&](const char* whatLimit, bool heaterIsOn) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::checkLimitsAndCtrlHeater: Reached " << whatLimit << ": Heater " - << static_cast(thermalComponent) << " OFF" << std::endl; + sif::info << "ThermalController::checkLimitsAndCtrlHeater: Exceeded " << whatLimit << ": " + "Heater for component " << static_cast(thermalComponent) << std::endl; heaterStates[switchNr].switchTransition = true; if (heaterIsOn) { heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF); diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 1102f033..9e9ca309 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -97,7 +97,7 @@ class ThermalController : public ExtendedControllerBase { uint32_t* msToReachTheMode) override; private: - static const uint32_t DELAY = 500; + static const uint32_t INIT_DELAY = 3000; static const uint32_t TEMP_OFFSET = 5; @@ -196,11 +196,13 @@ class ThermalController : public ExtendedControllerBase { bool obcTooHotFlag = false; bool strTooHotFlag = false; bool rwTooHotFlag = false; + uint32_t cycles = 0; std::array thermalStates{}; std::array heaterStates{}; - // Initial delay to make sure all pool variables have been initialized their owners - Countdown initialCountdown = Countdown(DELAY); + // Initial delay to make sure all pool variables have been initialized their owners. + // Also, wait for system initialization to complete. + Countdown initialCountdown = Countdown(INIT_DELAY); #if OBSW_THREAD_TRACING == 1 uint32_t opCounter = 0;