2022-01-23 16:44:41 -08:00
|
|
|
#include "pch.h"
|
|
|
|
|
|
|
|
bool DfcoController::getState() const {
|
|
|
|
if (!engineConfiguration->coastingFuelCutEnabled) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto rpm = Sensor::getOrZero(SensorType::Rpm);
|
2022-01-24 11:26:39 -08:00
|
|
|
const auto [tpsValid, tpsPos] = Sensor::get(SensorType::DriverThrottleIntent);
|
2022-01-23 16:44:41 -08:00
|
|
|
const auto [cltValid, clt] = Sensor::get(SensorType::Clt);
|
|
|
|
const auto [mapValid, map] = Sensor::get(SensorType::Map);
|
|
|
|
|
|
|
|
// If some sensor is broken, inhibit DFCO
|
|
|
|
if (!tpsValid || !cltValid || !mapValid) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool mapActivate = map < engineConfiguration->coastingFuelCutMap;
|
|
|
|
bool tpsActivate = tpsPos < engineConfiguration->coastingFuelCutTps;
|
|
|
|
bool cltActivate = clt > engineConfiguration->coastingFuelCutClt;
|
|
|
|
// True if throttle, MAP, and CLT are all acceptable for DFCO to occur
|
|
|
|
bool dfcoAllowed = mapActivate && tpsActivate && cltActivate;
|
|
|
|
|
|
|
|
bool rpmActivate = (rpm > engineConfiguration->coastingFuelCutRpmHigh);
|
|
|
|
bool rpmDeactivate = (rpm < engineConfiguration->coastingFuelCutRpmLow);
|
|
|
|
|
|
|
|
// RPM is high enough, and DFCO allowed
|
|
|
|
if (dfcoAllowed && rpmActivate) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// RPM too low, or DFCO not allowed
|
|
|
|
if (!dfcoAllowed || rpmDeactivate) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// No conditions hit, no change to state (provides hysteresis)
|
|
|
|
return m_isDfco;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DfcoController::update() {
|
|
|
|
// Run state machine
|
|
|
|
m_isDfco = getState();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DfcoController::cutFuel() const {
|
|
|
|
return m_isDfco;
|
|
|
|
}
|