fome-fw/firmware/controllers/algo/fuel/fuel_computer.h

44 lines
1.3 KiB
C
Raw Normal View History

/**
* @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"
#include "fuel_computer_generated.h"
2020-08-10 21:40:19 -07:00
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);
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
class FuelComputerBase : public IFuelComputer {
2020-08-10 21:40:19 -07:00
public:
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;
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:
FuelComputer(const ValueProvider3D& lambdaTable);
2020-08-10 21:40:19 -07:00
float getStoichiometricRatio() const override;
float getTargetLambda(int rpm, float load) const override;
float getTargetLambdaLoadAxis(float defaultLoad) const override;
2020-08-10 21:40:19 -07:00
private:
const ValueProvider3D* const m_lambdaTable;
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);
constexpr float fuelDensity = 0.72; // g/cc