disable compressor on out-of-bounds A/C pressure #6570

This commit is contained in:
kifir 2024-06-18 13:14:31 +03:00 committed by rusefillc
parent 01d2e9dbd5
commit 8b63e9e9e9
2 changed files with 20 additions and 0 deletions

View File

@ -7,6 +7,8 @@
static Deadband<200> maxRpmDeadband;
static Deadband<5> maxCltDeadband;
static Deadband<5> maxTpsDeadband;
static Deadband<5> minPressureDeadband;
static Deadband<5> maxPressureDeadband;
bool AcController::getAcState() {
latest_usage_ac_control = getTimeNowS();
@ -45,6 +47,22 @@ bool AcController::getAcState() {
if (tpsTooHigh) {
return false;
}
const auto acPressure= Sensor::get(SensorType::AcPressure);
if (acPressure.Valid) {
const auto minAcPressure = static_cast<float>(engineConfiguration->minAcPressure);
acPressureTooLow = minPressureDeadband.lt(acPressure.Value, minAcPressure);
if (acPressureTooLow) {
return false;
}
const auto maxAcPressure = static_cast<float>(engineConfiguration->maxAcPressure);
acPressureTooHigh = maxPressureDeadband.gt(acPressure.Value, maxAcPressure);
if (acPressureTooHigh) {
return false;
}
}
if (isDisabledByLua) {
return false;
}

View File

@ -12,6 +12,8 @@ bit engineTooHot;AC engine too hot
bit tpsTooHigh;AC tps too high
bit isDisabledByLua;AC disabled by Lua
bit acCompressorState;AC compressor on
bit acPressureTooLow;AC pressure too low
bit acPressureTooHigh;AC pressure too high
int latest_usage_ac_control;AC latest activity
! todo: extract some helper which would contain boolean state and most recent toggle time?