From 0fa1bab94d2e468f956acd16b7487f0073fd1460 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Wed, 22 Feb 2023 19:14:35 +0100 Subject: [PATCH] comments --- bsp_hosted/ObjectFactory.cpp | 7 +++++++ dummies/PduDummy.cpp | 1 + mission/controller/ThermalController.cpp | 20 ++++++++++++-------- mission/controller/ThermalController.h | 9 ++++++++- mission/devices/HeaterHandler.cpp | 2 +- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index d2c3c3da..287ecd36 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -1,6 +1,7 @@ #include "ObjectFactory.h" #include +#include "fsfw/power/PowerSwitchIF.h" #include #include #include @@ -62,6 +63,12 @@ void ObjectFactory::produce(void* args) { auto* dummyGpioIF = new DummyGpioIF(); auto* dummySwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0); + std::vector switcherList; + auto initVal = PowerSwitchIF::SWITCH_OFF; + for (unsigned i = 0; i < 18; i++) { + switcherList.emplace_back(initVal); + } + dummySwitcher->setInitialSwitcherList(switcherList); #ifdef PLATFORM_UNIX new SerialComIF(objects::UART_COM_IF); #if OBSW_ADD_PLOC_MPSOC == 1 diff --git a/dummies/PduDummy.cpp b/dummies/PduDummy.cpp index 1c26728c..ed0485ce 100644 --- a/dummies/PduDummy.cpp +++ b/dummies/PduDummy.cpp @@ -38,5 +38,6 @@ uint32_t PduDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return ReturnValue_t PduDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(PDU::pool::PDU_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(PDU::pool::PDU_CURRENTS, new PoolEntry(9)); return returnvalue::OK; } diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index cbba6a87..5d929503 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1373,19 +1373,23 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers struct TempLimits& tempLimit) { componentAboveCutOffLimit = false; // Heater off - if (not heaterHandler.checkSwitchState(switchNr)) { + if (not heaterHandler.checkSwitchState(switchNr) and not thermalStates[thermalComponent].heating) { if (sensorTemp < tempLimit.opLowerLimit) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON); sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " ON" << std::endl; + thermalStates[thermalComponent].heating = true; //TODO: EVENT + //TODO: merken wenn an oder ausgeschaltet und erst nach drei zyklen wieder checken? wenn in transition dann paar mal skippen mit transitionboolean; bool switchOnTransition und bool switchOffTasnition, counter 3 zyklen dabei checken ob tansition erfolgreich, bool clearen, falls drei erreicht heaterControlErrorCounter global zählen } // Heater on - } else if (heaterHandler.checkSwitchState(switchNr)) { + } else if (heaterHandler.checkSwitchState(switchNr) and thermalStates[thermalComponent].heating) { if (sensorTemp >= tempLimit.opLowerLimit + TEMP_OFFSET) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " OFF" << std::endl; + sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " OFF" << std::endl; //TODO: array mit struct enthält infos + thermalStates[thermalComponent].heating = false; + } - } else if (not redSwitchNrInUse) { + } else if (redSwitchNrInUse) { if (heaterHandler.checkSwitchState(redSwitchNr)) { if (sensorTemp >= tempLimit.cutOffLimit) { componentAboveCutOffLimit = true; @@ -1417,18 +1421,18 @@ bool ThermalController::selectAndReadSensorTemp() { for (unsigned i = 0; i < numSensors; i++) { if (sensors[i].first and sensors[i].second != INVALID_TEMPERATURE) { sensorTemp = sensors[i].second; - errorCounters[thermalComponent] = 0; + thermalStates[thermalComponent].errorCounter = 0; return true; } } - errorCounters[thermalComponent] ++; + thermalStates[thermalComponent].errorCounter ++; if(thermalComponent != rw and thermalComponent != acsBoard){ - if (errorCounters[thermalComponent] <= 3){ + if (thermalStates[thermalComponent].errorCounter <= 3){ triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent); } }else{ - if (errorCounters[thermalComponent] <= 8){ + if (thermalStates[thermalComponent].errorCounter <= 8){ triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent); } } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 368508ab..590565c5 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -36,6 +36,12 @@ struct TempLimits { float nopUpperLimit; }; +struct ThermalState { + uint8_t errorCounter; + bool heating; + uint32_t heaterStartTime; +}; + enum ThermalComponents: uint8_t { //TODO: Großbuchstaben NONE = 0, @@ -183,7 +189,8 @@ class ThermalController : public ExtendedControllerBase { ThermalComponents thermalComponent = NONE; bool redSwitchNrInUse = false; bool componentAboveCutOffLimit = false; - uint8_t errorCounters[32]; + std::array thermalStates {}; + // Initial delay to make sure all pool variables have been initialized their owners Countdown initialCountdown = Countdown(DELAY); diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index 35287ed7..3b5c865e 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -298,7 +298,7 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switchers heaterIdx) { heater.mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); heater.waitMainSwitchOn = true; } else { - sif::debug << "HeaterHandler::handleSwitchHandling: Failed to get state of" + sif::debug << "HeaterHandler::handleSwitchOnCommand: Failed to get state of" << " main line switch" << std::endl; if (heater.replyQueue != commandQueue->getId()) { actionHelper.finish(false, heater.replyQueue, heater.action, mainSwitchState);