continue max heater duration
This commit is contained in:
@@ -209,8 +209,12 @@ void ThermalController::performControlOperation() {
|
||||
} else {
|
||||
transitionWhenHeatersOffCycles++;
|
||||
}
|
||||
} else if (mode != MODE_OFF and not tcsBrdShortlyUnavailable) {
|
||||
performThermalModuleCtrl(heaterSwitchStateArray);
|
||||
} else if (mode != MODE_OFF) {
|
||||
if (not tcsBrdShortlyUnavailable) {
|
||||
performThermalModuleCtrl(heaterSwitchStateArray);
|
||||
}
|
||||
heaterTransitionControl(heaterSwitchStateArray);
|
||||
heaterMaxDurationControl(heaterSwitchStateArray);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1586,9 +1590,8 @@ void ThermalController::performThermalModuleCtrl(const HeaterSwitchStates& heate
|
||||
eBandTooHotFlag = false;
|
||||
}
|
||||
}
|
||||
|
||||
heaterTransitionControl(heaterSwitchStates);
|
||||
}
|
||||
|
||||
void ThermalController::ctrlComponentTemperature(HeaterContext& htrCtx) {
|
||||
if (selectAndReadSensorTemp(htrCtx)) {
|
||||
if (chooseHeater(htrCtx.switchNr, htrCtx.redSwitchNr)) {
|
||||
@@ -1613,6 +1616,7 @@ bool ThermalController::selectAndReadSensorTemp(HeaterContext& htrCtx) {
|
||||
sensors[i].second > SANITY_LIMIT_LOWER_TEMP and
|
||||
sensors[i].second < SANITY_LIMIT_UPPER_TEMP) {
|
||||
sensorTemp = sensors[i].second;
|
||||
currentSensorIndex = i;
|
||||
thermalStates[thermalComponent].errorCounter = 0;
|
||||
return true;
|
||||
}
|
||||
@@ -1689,7 +1693,6 @@ void ThermalController::checkLimitsAndCtrlHeater(HeaterContext& htrCtx) {
|
||||
if (sensorTemp < htrCtx.tempLimit.opLowerLimit and heaterCtrlAllowed()) {
|
||||
sif::info << "TCS: Heater " << static_cast<int>(thermalComponent) << " ON" << std::endl;
|
||||
heaterSwitchHelper(htrCtx.switchNr, HeaterHandler::SwitchState::ON, thermalComponent);
|
||||
heaterStates[htrCtx.switchNr].switchTransition = true;
|
||||
heaterStates[htrCtx.switchNr].target = HeaterHandler::SwitchState::ON;
|
||||
} else {
|
||||
// Even if heater control is now allowed, we can update the state.
|
||||
@@ -1754,6 +1757,11 @@ void ThermalController::heaterTransitionControl(const HeaterSwitchStates& curren
|
||||
for (unsigned i = 0; i < 7; i++) {
|
||||
if (heaterStates[i].switchTransition) {
|
||||
if (currentHeaterStates[i] == heaterStates[i].target) {
|
||||
// Required for max heat period control
|
||||
if (currentHeaterStates[i] == HeaterHandler::SwitchState::ON) {
|
||||
heaterStates[i].heaterOnPeriod.setTimeout(MAX_HEATER_ON_DURATIONS[i]);
|
||||
heaterStates[i].heaterOnPeriod.resetTimer();
|
||||
}
|
||||
heaterStates[i].switchTransition = false;
|
||||
continue;
|
||||
}
|
||||
@@ -1765,6 +1773,26 @@ void ThermalController::heaterTransitionControl(const HeaterSwitchStates& curren
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ThermalController::heaterMaxDurationControl(const HeaterSwitchStates& currentHeaterStates) {
|
||||
for (unsigned i = 0; i < heater::Switch::NUMBER_OF_SWITCHES; i++) {
|
||||
if (currentHeaterStates[i] == HeaterHandler::SwitchState::ON and
|
||||
heaterStates[i].heaterOnPeriod.hasTimedOut()) {
|
||||
heaterStates[i].switchTransition = false;
|
||||
heaterStates[i].heaterSwitchControlCycles = 0;
|
||||
heaterHandler.switchHeater(static_cast<heater::Switch>(i), HeaterHandler::SwitchState::OFF);
|
||||
for (unsigned j = 0; j < thermalStates.size(); j++) {
|
||||
if (thermalStates[j].heating and thermalStates[j].heaterSwitch == i) {
|
||||
timeval currentTime;
|
||||
Clock::getClockMonotonic(¤tTime);
|
||||
thermalStates[j].heating = false;
|
||||
thermalStates[j].heaterEndTime = currentTime.tv_sec;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t ThermalController::tempFloatToU32() const {
|
||||
auto sensorTempAsFloat = static_cast<float>(sensorTemp);
|
||||
uint32_t tempRaw = 0;
|
||||
@@ -1799,6 +1827,11 @@ bool ThermalController::heaterCtrlAllowed() const { return submode != SUBMODE_NO
|
||||
void ThermalController::resetThermalStates() {
|
||||
for (auto& thermalState : thermalStates) {
|
||||
thermalState.heating = false;
|
||||
thermalState.errorCounter = 0;
|
||||
thermalState.heaterStartTime = 0;
|
||||
thermalState.heaterEndTime = 0;
|
||||
thermalState.sensorIndex = 0;
|
||||
thermalState.heaterSwitch = heater::Switch::NUMBER_OF_SWITCHES;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1809,6 +1842,9 @@ void ThermalController::heaterSwitchHelper(heater::Switch switchNr,
|
||||
Clock::getClockMonotonic(¤tTime);
|
||||
if (state == HeaterHandler::SwitchState::ON) {
|
||||
heaterHandler.switchHeater(switchNr, state);
|
||||
heaterStates[switchNr].switchTransition = true;
|
||||
thermalStates[componentIdx].sensorIndex = currentSensorIndex;
|
||||
thermalStates[componentIdx].heaterSwitch = switchNr;
|
||||
thermalStates[componentIdx].heating = true;
|
||||
thermalStates[componentIdx].heaterStartTime = currentTime.tv_sec;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user