pause closed loop fuel after cuts

This commit is contained in:
Matthew Kennedy 2023-03-02 11:42:12 -08:00
parent 4e65acba84
commit a861d76da6
3 changed files with 21 additions and 0 deletions

View File

@ -181,6 +181,11 @@ todo AndreiKA this change breaks 22 unit tests?
m_transientAllowInjection = allowFuel;
m_transientAllowIgnition = allowSpark;
if (!m_transientAllowInjection || !m_transientAllowIgnition) {
// Tracks the last time any cut happened
m_lastCutTime.reset(nowNt);
}
}
void LimpManager::onIgnitionStateChanged(bool ignitionOn) {
@ -234,3 +239,7 @@ LimpState LimpManager::allowIgnition() const {
}
return {true, ClearReason::None};
}
float LimpManager::getTimeSinceAnyCut() const {
return m_lastCutTime.getElapsedSeconds();
}

View File

@ -112,6 +112,8 @@ public:
LimpState allowInjection() const;
LimpState allowIgnition() const;
float getTimeSinceAnyCut() const;
bool allowTriggerInput() const;
// Other subsystems call these APIs to indicate a problem has occurred
@ -140,6 +142,9 @@ private:
// Ignition switch state
bool m_ignitionOn = false;
// Tracks how long since a cut (ignition or fuel) was active for any reason
Timer m_lastCutTime;
};
LimpManager * getLimpManager();

View File

@ -93,6 +93,13 @@ bool shouldUpdateCorrection(SensorType sensor) {
return false;
}
// Pause if some other cut was active recently
auto timeSinceFuelCut = engine->module<LimpManager>()->getTimeSinceAnyCut();
// TODO: should duration this be configurable?
if (timeSinceFuelCut < 2) {
return false;
}
return true;
}