From 8bc18db80fc71b743040b2ce7caa887d9cf05698 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Thu, 23 Jul 2020 01:12:38 -0700 Subject: [PATCH] base class --- firmware/controllers/algo/airmass/airmass.cpp | 10 ++++++++++ firmware/controllers/algo/airmass/airmass.h | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 firmware/controllers/algo/airmass/airmass.cpp diff --git a/firmware/controllers/algo/airmass/airmass.cpp b/firmware/controllers/algo/airmass/airmass.cpp new file mode 100644 index 0000000000..3ede8519e1 --- /dev/null +++ b/firmware/controllers/algo/airmass/airmass.cpp @@ -0,0 +1,10 @@ +#include "airmass.h" + +AirmassModelBase::AirmassModelBase(const ValueProvider3D& veTable) : m_veTable(&veTable) {} + +float AirmassModelBase::getVe(int rpm, float load) const { + efiAssert(OBD_PCM_Processor_Fault, m_veTable != nullptr, "VE table null", 0); + + // TODO: allow override of the Y axis value based on a config field + return m_veTable->getValue(rpm, load); +} diff --git a/firmware/controllers/algo/airmass/airmass.h b/firmware/controllers/algo/airmass/airmass.h index a5ad25950c..338741da5f 100644 --- a/firmware/controllers/algo/airmass/airmass.h +++ b/firmware/controllers/algo/airmass/airmass.h @@ -1,6 +1,22 @@ #pragma once +#include "engine.h" + struct AirmassResult { float CylinderAirmass = 0; float EngineLoadPercent = 100; }; + +struct AirmassModelBase { + DECLARE_ENGINE_PTR; + + AirmassModelBase(const ValueProvider3D& veTable); + virtual AirmassResult getAirmass(int rpm) = 0; + +protected: + // Retrieve the user-calibrated volumetric efficiency from the table + float getVe(int rpm, percent_t load) const; + +private: + const ValueProvider3D* const m_veTable; +};