switch
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

Transition
This commit is contained in:
Irini Kosmidou 2023-03-05 13:05:32 +01:00
parent 88db78fed9
commit 37b540fd48
2 changed files with 16 additions and 30 deletions

View File

@ -1385,6 +1385,7 @@ void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr,
} }
} }
} }
heaterTransitionControl();
resetSensorsArray(); resetSensorsArray();
} }
bool ThermalController::selectAndReadSensorTemp() { bool ThermalController::selectAndReadSensorTemp() {
@ -1429,21 +1430,17 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers
struct TempLimits& tempLimit) { struct TempLimits& tempLimit) {
componentAboveCutOffLimit = false; componentAboveCutOffLimit = false;
// if Heater off // if Heater off
if (not heaterStates[switchNr].switchOnTransition and if (not heaterStates[switchNr].switchTransition) {
not heaterStates[switchNr].switchOffTransition) { 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);
heaterStates[switchNr].switchOnTransition = true;
sif::info << "ThermalController::ctrlHeater: Heater " << thermalComponent << " ON" sif::info << "ThermalController::ctrlHeater: Heater " << thermalComponent << " ON"
<< std::endl; << std::endl;
heaterStates[switchNr].switchTransition = true;
thermalStates[thermalComponent].heating = true; thermalStates[thermalComponent].heating = true;
// TODO: EVENT; aber heaterHandler erstellt schon event // TODO: EVENT; aber heaterHandler erstellt schon event
// TODO: merken wenn an oder ausgeschaltet und erst nach drei zyklen wieder checken? wenn in }else{
// transition dann paar mal skippen; bool switchOnTransition und bool thermalStates[thermalComponent].heating = false;
// switchOffTasnition, counter 3 zyklen dabei checken ob tansition erfolgreich, bool
// clearen, falls drei erreicht heaterControlErrorCounter global zählen
} }
// if Heater on // if Heater on
@ -1453,7 +1450,7 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF);
sif::info << "ThermalController::ctrlHeater: Heater " << thermalComponent << " OFF" sif::info << "ThermalController::ctrlHeater: Heater " << thermalComponent << " OFF"
<< std::endl; << std::endl;
heaterStates[switchNr].switchOffTransition = true; heaterStates[switchNr].switchTransition = true;
thermalStates[thermalComponent].heating = false; thermalStates[thermalComponent].heating = false;
} }
} else { } else {
@ -1462,12 +1459,12 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF);
sif::info << "ThermalController::ctrlHeater: Reached CutOffLimit: Heater " sif::info << "ThermalController::ctrlHeater: Reached CutOffLimit: Heater "
<< thermalComponent << " OFF" << std::endl; << thermalComponent << " OFF" << std::endl;
heaterStates[switchNr].switchOffTransition = true; heaterStates[switchNr].switchTransition = true;
if (heaterHandler.checkSwitchState(redSwitchNr)) { if (heaterHandler.checkSwitchState(redSwitchNr)) {
heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF); heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF);
sif::info << "ThermalController::ctrlHeater: Reached CutOffLimit: RedundantHeater " sif::info << "ThermalController::ctrlHeater: Reached CutOffLimit: RedundantHeater "
<< thermalComponent << " OFF" << std::endl; << thermalComponent << " OFF" << std::endl;
heaterStates[redSwitchNr].switchOffTransition = true; heaterStates[redSwitchNr].switchTransition = true;
} }
} }
} }
@ -1483,20 +1480,12 @@ void ThermalController::resetSensorsArray() {
} }
void ThermalController::heaterTransitionControl() { void ThermalController::heaterTransitionControl() {
for (unsigned i = 0; i < 7; i++) { for (unsigned i = 0; i < 7; i++) {
if (heaterStates[i].switchOffTransition) { if (heaterStates[i].switchTransition) {
if (heaterStates[i].heaterSwitchOffControlErrorCounter > 3) { if (heaterStates[i].heaterSwitchControlErrorCounter > 3) {
heaterStates[i].switchOffTransition = false; heaterStates[i].switchTransition = false;
heaterStates[i].heaterSwitchOffControlErrorCounter = 0; heaterStates[i].heaterSwitchControlErrorCounter = 0;
} }
heaterStates[i].heaterSwitchOffControlErrorCounter++; heaterStates[i].heaterSwitchControlErrorCounter++;
}
if (heaterStates[i].switchOnTransition) {
if (heaterStates[i].heaterSwitchOnControlErrorCounter > 3) {
heaterStates[i].switchOnTransition = false;
heaterStates[i].heaterSwitchOnControlErrorCounter = 0;
}
heaterStates[i].heaterSwitchOnControlErrorCounter++;
} }
} }
} }

View File

@ -43,14 +43,11 @@ struct ThermalState {
}; };
struct HeaterState { struct HeaterState {
bool switchOnTransition; bool switchTransition;
bool switchOffTransition; uint8_t heaterSwitchControlErrorCounter;
uint8_t heaterSwitchOnControlErrorCounter;
uint8_t heaterSwitchOffControlErrorCounter;
}; };
enum ThermalComponents : uint8_t { enum ThermalComponents : uint8_t {
// TODO: Großbuchstaben
NONE = 0, NONE = 0,
ACS_BOARD = 1, ACS_BOARD = 1,
MGT = 2, MGT = 2,