comments
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Irini Kosmidou 2023-02-22 19:14:35 +01:00
parent 29179bde0c
commit 0fa1bab94d
5 changed files with 29 additions and 10 deletions

View File

@ -1,6 +1,7 @@
#include "ObjectFactory.h" #include "ObjectFactory.h"
#include <fsfw/power/DummyPowerSwitcher.h> #include <fsfw/power/DummyPowerSwitcher.h>
#include "fsfw/power/PowerSwitchIF.h"
#include <fsfw/tmtcservices/CommandingServiceBase.h> #include <fsfw/tmtcservices/CommandingServiceBase.h>
#include <fsfw/tmtcservices/PusServiceBase.h> #include <fsfw/tmtcservices/PusServiceBase.h>
#include <mission/controller/ThermalController.h> #include <mission/controller/ThermalController.h>
@ -62,6 +63,12 @@ void ObjectFactory::produce(void* args) {
auto* dummyGpioIF = new DummyGpioIF(); auto* dummyGpioIF = new DummyGpioIF();
auto* dummySwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0); auto* dummySwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0);
std::vector<ReturnValue_t> switcherList;
auto initVal = PowerSwitchIF::SWITCH_OFF;
for (unsigned i = 0; i < 18; i++) {
switcherList.emplace_back(initVal);
}
dummySwitcher->setInitialSwitcherList(switcherList);
#ifdef PLATFORM_UNIX #ifdef PLATFORM_UNIX
new SerialComIF(objects::UART_COM_IF); new SerialComIF(objects::UART_COM_IF);
#if OBSW_ADD_PLOC_MPSOC == 1 #if OBSW_ADD_PLOC_MPSOC == 1

View File

@ -38,5 +38,6 @@ uint32_t PduDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return
ReturnValue_t PduDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, ReturnValue_t PduDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) { LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(PDU::pool::PDU_TEMPERATURE, new PoolEntry<float>({0})); localDataPoolMap.emplace(PDU::pool::PDU_TEMPERATURE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(PDU::pool::PDU_CURRENTS, new PoolEntry<int16_t>(9));
return returnvalue::OK; return returnvalue::OK;
} }

View File

@ -1373,19 +1373,23 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers
struct TempLimits& tempLimit) { struct TempLimits& tempLimit) {
componentAboveCutOffLimit = false; componentAboveCutOffLimit = false;
// Heater off // Heater off
if (not heaterHandler.checkSwitchState(switchNr)) { if (not heaterHandler.checkSwitchState(switchNr) and not thermalStates[thermalComponent].heating) {
if (sensorTemp < tempLimit.opLowerLimit) { if (sensorTemp < tempLimit.opLowerLimit) {
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON); heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON);
sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " ON" << std::endl; sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " ON" << std::endl;
thermalStates[thermalComponent].heating = true;
//TODO: EVENT //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 // Heater on
} else if (heaterHandler.checkSwitchState(switchNr)) { } else if (heaterHandler.checkSwitchState(switchNr) and thermalStates[thermalComponent].heating) {
if (sensorTemp >= tempLimit.opLowerLimit + TEMP_OFFSET) { if (sensorTemp >= tempLimit.opLowerLimit + TEMP_OFFSET) {
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); 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 (heaterHandler.checkSwitchState(redSwitchNr)) {
if (sensorTemp >= tempLimit.cutOffLimit) { if (sensorTemp >= tempLimit.cutOffLimit) {
componentAboveCutOffLimit = true; componentAboveCutOffLimit = true;
@ -1417,18 +1421,18 @@ bool ThermalController::selectAndReadSensorTemp() {
for (unsigned i = 0; i < numSensors; i++) { for (unsigned i = 0; i < numSensors; i++) {
if (sensors[i].first and sensors[i].second != INVALID_TEMPERATURE) { if (sensors[i].first and sensors[i].second != INVALID_TEMPERATURE) {
sensorTemp = sensors[i].second; sensorTemp = sensors[i].second;
errorCounters[thermalComponent] = 0; thermalStates[thermalComponent].errorCounter = 0;
return true; return true;
} }
} }
errorCounters[thermalComponent] ++; thermalStates[thermalComponent].errorCounter ++;
if(thermalComponent != rw and thermalComponent != acsBoard){ if(thermalComponent != rw and thermalComponent != acsBoard){
if (errorCounters[thermalComponent] <= 3){ if (thermalStates[thermalComponent].errorCounter <= 3){
triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent); triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent);
} }
}else{ }else{
if (errorCounters[thermalComponent] <= 8){ if (thermalStates[thermalComponent].errorCounter <= 8){
triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent); triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent);
} }
} }

View File

@ -36,6 +36,12 @@ struct TempLimits {
float nopUpperLimit; float nopUpperLimit;
}; };
struct ThermalState {
uint8_t errorCounter;
bool heating;
uint32_t heaterStartTime;
};
enum ThermalComponents: uint8_t { enum ThermalComponents: uint8_t {
//TODO: Großbuchstaben //TODO: Großbuchstaben
NONE = 0, NONE = 0,
@ -183,7 +189,8 @@ class ThermalController : public ExtendedControllerBase {
ThermalComponents thermalComponent = NONE; ThermalComponents thermalComponent = NONE;
bool redSwitchNrInUse = false; bool redSwitchNrInUse = false;
bool componentAboveCutOffLimit = false; bool componentAboveCutOffLimit = false;
uint8_t errorCounters[32]; std::array<ThermalState, 30> thermalStates {};
// 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);

View File

@ -298,7 +298,7 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switchers heaterIdx) {
heater.mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); heater.mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs());
heater.waitMainSwitchOn = true; heater.waitMainSwitchOn = true;
} else { } else {
sif::debug << "HeaterHandler::handleSwitchHandling: Failed to get state of" sif::debug << "HeaterHandler::handleSwitchOnCommand: Failed to get state of"
<< " main line switch" << std::endl; << " main line switch" << std::endl;
if (heater.replyQueue != commandQueue->getId()) { if (heater.replyQueue != commandQueue->getId()) {
actionHelper.finish(false, heater.replyQueue, heater.action, mainSwitchState); actionHelper.finish(false, heater.replyQueue, heater.action, mainSwitchState);