2022-09-03 04:44:24 -07:00
|
|
|
/**
|
|
|
|
* @file fuel_computer.h
|
|
|
|
*/
|
|
|
|
|
2020-08-10 21:40:19 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
class ValueProvider3D;
|
|
|
|
|
2021-12-26 09:33:32 -08:00
|
|
|
#include "rusefi_types.h"
|
2022-09-01 16:24:19 -07:00
|
|
|
#include "fuel_computer_generated.h"
|
2020-08-10 21:40:19 -07:00
|
|
|
|
2022-09-01 16:24:19 -07:00
|
|
|
struct IFuelComputer : public fuel_computer_s {
|
2022-09-02 10:10:21 -07:00
|
|
|
virtual mass_t getCycleFuel(mass_t airmass, int rpm, float load) = 0;
|
2022-09-03 04:44:24 -07:00
|
|
|
temperature_t getTCharge(int rpm, float tps);
|
2022-09-03 08:07:26 -07:00
|
|
|
float getLoadOverride(float defaultLoad, load_override_e overrideMode) const;
|
2022-09-03 04:44:24 -07:00
|
|
|
private:
|
|
|
|
float getTChargeCoefficient(int rpm, float tps);
|
2020-08-10 21:40:19 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
// This contains the math of the fuel model, but doesn't actually read any configuration
|
2021-11-16 13:52:11 -08:00
|
|
|
class FuelComputerBase : public IFuelComputer {
|
2020-08-10 21:40:19 -07:00
|
|
|
public:
|
2022-09-02 10:10:21 -07:00
|
|
|
mass_t getCycleFuel(mass_t airmass, int rpm, float load) override;
|
2020-08-10 21:40:19 -07:00
|
|
|
|
|
|
|
virtual float getStoichiometricRatio() const = 0;
|
|
|
|
virtual float getTargetLambda(int rpm, float load) const = 0;
|
2020-09-08 14:15:18 -07:00
|
|
|
virtual float getTargetLambdaLoadAxis(float defaultLoad) const = 0;
|
2020-08-10 21:40:19 -07:00
|
|
|
};
|
|
|
|
|
2022-09-03 04:26:49 -07:00
|
|
|
// This class is a usable implementation of a fuel model that reads real configuration
|
2020-08-10 21:40:19 -07:00
|
|
|
class FuelComputer final : public FuelComputerBase {
|
|
|
|
public:
|
|
|
|
float getStoichiometricRatio() const override;
|
|
|
|
float getTargetLambda(int rpm, float load) const override;
|
2020-09-08 14:15:18 -07:00
|
|
|
float getTargetLambdaLoadAxis(float defaultLoad) const override;
|
2020-08-10 21:40:19 -07:00
|
|
|
};
|
2020-10-09 14:16:49 -07:00
|
|
|
|
2021-12-26 11:53:27 -08:00
|
|
|
float getLoadOverride(float defaultLoad, load_override_e overrideMode);
|
2021-11-05 19:29:56 -07:00
|
|
|
constexpr float fuelDensity = 0.72; // g/cc
|