tear down Engine god object #4511

just trying different things
This commit is contained in:
Andrey 2022-09-03 11:07:26 -04:00
parent bd7b6e6736
commit 6b4e6c8169
5 changed files with 15 additions and 7 deletions

View File

@ -219,8 +219,6 @@ void Engine::periodicSlowCallback() {
updateBoostControl();
#endif // EFI_BOOST_CONTROL
standardAirCharge = getStandardAirCharge();
#if (BOARD_TLE8888_COUNT > 0)
tle8888startup();
#endif

View File

@ -342,8 +342,6 @@ public:
float stftCorrection[STFT_BANK_COUNT] = {0};
// Standard cylinder air charge - 100% VE at standard temperature, grams per cylinder
float standardAirCharge = 0;
void periodicFastCallback();
void periodicSlowCallback();

View File

@ -1,5 +1,11 @@
#include "pch.h"
#include "engine_configuration.h"
#include "sensor.h"
#include "error_handling.h"
#include "efi_interpolation.h"
#include "table_helper.h"
#include "fuel_math.h"
#include "fuel_computer.h"
mass_t FuelComputerBase::getCycleFuel(mass_t airmass, int rpm, float load) {
@ -59,7 +65,7 @@ float FuelComputer::getTargetLambdaLoadAxis(float defaultLoad) const {
return getLoadOverride(defaultLoad, engineConfiguration->afrOverrideMode);
}
float getLoadOverride(float defaultLoad, load_override_e overrideMode) {
float IFuelComputer::getLoadOverride(float defaultLoad, load_override_e overrideMode) const {
switch(overrideMode) {
case AFR_None: return defaultLoad;
// MAP default to 200kpa - failed MAP goes rich
@ -67,7 +73,7 @@ float getLoadOverride(float defaultLoad, load_override_e overrideMode) {
// TPS/pedal default to 100% - failed TPS goes rich
case AFR_Tps: return Sensor::get(SensorType::Tps1).value_or(100);
case AFR_AccPedal: return Sensor::get(SensorType::AcceleratorPedal).value_or(100);
case AFR_CylFilling: return 100 * engine->fuelComputer->sdAirMassInOneCylinder / engine->standardAirCharge;
case AFR_CylFilling: return 100 * engine->fuelComputer->sdAirMassInOneCylinder / getStandardAirCharge();
default: return 0;
}
}

View File

@ -12,6 +12,7 @@ class ValueProvider3D;
struct IFuelComputer : public fuel_computer_s {
virtual mass_t getCycleFuel(mass_t airmass, int rpm, float load) = 0;
temperature_t getTCharge(int rpm, float tps);
float getLoadOverride(float defaultLoad, load_override_e overrideMode) const;
private:
float getTChargeCoefficient(int rpm, float tps);
};

View File

@ -174,7 +174,7 @@ static float getBaseFuelMass(int rpm) {
// Plop some state for others to read
engine->fuelComputer->sdAirMassInOneCylinder = airmass.CylinderAirmass;
engine->engineState.fuelingLoad = airmass.EngineLoadPercent;
engine->engineState.ignitionLoad = getLoadOverride(airmass.EngineLoadPercent, engineConfiguration->ignOverrideMode);
engine->engineState.ignitionLoad = engine->fuelComputer->getLoadOverride(airmass.EngineLoadPercent, engineConfiguration->ignOverrideMode);
auto gramPerCycle = airmass.CylinderAirmass * engineConfiguration->specs.cylindersCount;
auto gramPerMs = rpm == 0 ? 0 : gramPerCycle / getEngineCycleDuration(rpm);
@ -398,6 +398,11 @@ float getCrankingFuel(float baseFuel) {
return getCrankingFuel3(baseFuel, engine->rpmCalculator.getRevolutionCounterSinceStart());
}
/**
* Standard cylinder air charge - 100% VE at standard temperature, grams per cylinder
*
* Should we bother caching 'getStandardAirCharge' result or can we afford to run the math every time we calculate fuel?
*/
float getStandardAirCharge() {
float totalDisplacement = engineConfiguration->specs.displacement;
float cylDisplacement = totalDisplacement / engineConfiguration->specs.cylindersCount;