2020-07-23 01:12:38 -07:00
|
|
|
#include "airmass.h"
|
2020-09-06 16:06:32 -07:00
|
|
|
#include "sensor.h"
|
|
|
|
|
|
|
|
EXTERN_ENGINE;
|
2020-07-23 01:12:38 -07:00
|
|
|
|
|
|
|
AirmassModelBase::AirmassModelBase(const ValueProvider3D& veTable) : m_veTable(&veTable) {}
|
|
|
|
|
2020-09-07 07:15:42 -07:00
|
|
|
float AirmassModelBase::getVeLoadAxis(float passedLoad) const {
|
|
|
|
switch(CONFIG(veOverrideMode)) {
|
|
|
|
case VE_None: return passedLoad;
|
2020-12-30 05:43:49 -08:00
|
|
|
case VE_MAP: return Sensor::get(SensorType::Map).value_or(0);
|
2020-09-07 07:15:42 -07:00
|
|
|
case VE_TPS: return Sensor::get(SensorType::Tps1).value_or(0);
|
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-23 01:12:38 -07:00
|
|
|
float AirmassModelBase::getVe(int rpm, float load) const {
|
|
|
|
efiAssert(OBD_PCM_Processor_Fault, m_veTable != nullptr, "VE table null", 0);
|
|
|
|
|
2020-09-07 07:15:42 -07:00
|
|
|
// Override the load value if necessary
|
|
|
|
load = getVeLoadAxis(load);
|
|
|
|
|
2020-09-06 16:06:32 -07:00
|
|
|
float ve = m_veTable->getValue(rpm, load);
|
|
|
|
|
|
|
|
auto tps = Sensor::get(SensorType::Tps1);
|
|
|
|
// get VE from the separate table for Idle
|
|
|
|
if (tps.Valid && CONFIG(useSeparateVeForIdle)) {
|
|
|
|
float idleVe = interpolate2d("idleVe", rpm, config->idleVeBins, config->idleVe);
|
|
|
|
// interpolate between idle table and normal (running) table using TPS threshold
|
|
|
|
ve = interpolateClamped(0.0f, idleVe, CONFIG(idlePidDeactivationTpsThreshold), ve, tps.Value);
|
|
|
|
}
|
|
|
|
|
|
|
|
ENGINE(engineState.currentVe) = ve;
|
2020-09-07 07:15:42 -07:00
|
|
|
ENGINE(engineState.currentVeLoad) = load;
|
2020-09-06 16:06:32 -07:00
|
|
|
return ve * 0.01f;
|
2020-07-23 01:12:38 -07:00
|
|
|
}
|