mirror of https://github.com/rusefi/rusefi.git
without ValueProvider3D interface how do we mock? (#4829)
Co-authored-by: rusefillc <sdfsdfqsf2334234234>
This commit is contained in:
parent
2645f97cab
commit
23698be5f8
|
@ -23,8 +23,6 @@ mass_t FuelComputerBase::getCycleFuel(mass_t airmass, int rpm, float load) {
|
||||||
return airmass / afr;
|
return airmass / afr;
|
||||||
}
|
}
|
||||||
|
|
||||||
FuelComputer::FuelComputer(const ValueProvider3D& lambdaTable) : m_lambdaTable(&lambdaTable) {}
|
|
||||||
|
|
||||||
float FuelComputer::getStoichiometricRatio() const {
|
float FuelComputer::getStoichiometricRatio() const {
|
||||||
float primary = engineConfiguration->stoichRatioPrimary;
|
float primary = engineConfiguration->stoichRatioPrimary;
|
||||||
|
|
||||||
|
@ -57,10 +55,13 @@ float FuelComputer::getStoichiometricRatio() const {
|
||||||
return interpolateClamped(0, primary, 100, secondary, flex.Value);
|
return interpolateClamped(0, primary, 100, secondary, flex.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
float FuelComputer::getTargetLambda(int rpm, float load) const {
|
|
||||||
efiAssert(OBD_PCM_Processor_Fault, m_lambdaTable != nullptr, "AFR table null", 0);
|
|
||||||
|
|
||||||
return m_lambdaTable->getValue(rpm, load);
|
float FuelComputer::getTargetLambda(int rpm, float load) const {
|
||||||
|
return interpolate3d(
|
||||||
|
config->lambdaTable,
|
||||||
|
config->lambdaLoadBins, load,
|
||||||
|
config->lambdaRpmBins, rpm
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
float FuelComputer::getTargetLambdaLoadAxis(float defaultLoad) const {
|
float FuelComputer::getTargetLambdaLoadAxis(float defaultLoad) const {
|
||||||
|
|
|
@ -30,14 +30,9 @@ public:
|
||||||
// This class is a usable implementation of a fuel model that reads real configuration
|
// This class is a usable implementation of a fuel model that reads real configuration
|
||||||
class FuelComputer final : public FuelComputerBase {
|
class FuelComputer final : public FuelComputerBase {
|
||||||
public:
|
public:
|
||||||
FuelComputer(const ValueProvider3D& lambdaTable);
|
|
||||||
|
|
||||||
float getStoichiometricRatio() const override;
|
float getStoichiometricRatio() const override;
|
||||||
float getTargetLambda(int rpm, float load) const override;
|
float getTargetLambda(int rpm, float load) const override;
|
||||||
float getTargetLambdaLoadAxis(float defaultLoad) const override;
|
float getTargetLambdaLoadAxis(float defaultLoad) const override;
|
||||||
|
|
||||||
private:
|
|
||||||
const ValueProvider3D* const m_lambdaTable;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
float getLoadOverride(float defaultLoad, load_override_e overrideMode);
|
float getLoadOverride(float defaultLoad, load_override_e overrideMode);
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
#include "lua_hooks.h"
|
#include "lua_hooks.h"
|
||||||
|
|
||||||
extern fuel_Map3D_t veMap;
|
extern fuel_Map3D_t veMap;
|
||||||
extern lambda_Map3D_t lambdaMap;
|
|
||||||
static mapEstimate_Map3D_t mapEstimationTable;
|
static mapEstimate_Map3D_t mapEstimationTable;
|
||||||
|
|
||||||
#if EFI_ENGINE_CONTROL
|
#if EFI_ENGINE_CONTROL
|
||||||
|
@ -331,7 +330,7 @@ float getInjectionMass(int rpm) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static FuelComputer fuelComputer(lambdaMap);
|
static FuelComputer fuelComputer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialize fuel map data structure
|
* @brief Initialize fuel map data structure
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#define rpmMax 8000
|
#define rpmMax 8000
|
||||||
|
|
||||||
fuel_Map3D_t veMap;
|
fuel_Map3D_t veMap;
|
||||||
lambda_Map3D_t lambdaMap;
|
|
||||||
|
|
||||||
#define tpMin 0
|
#define tpMin 0
|
||||||
#define tpMax 100
|
#define tpMax 100
|
||||||
|
@ -119,6 +118,4 @@ temperature_t IFuelComputer::getTCharge(int rpm, float tps) {
|
||||||
|
|
||||||
void initSpeedDensity() {
|
void initSpeedDensity() {
|
||||||
veMap.init(config->veTable, config->veLoadBins, config->veRpmBins);
|
veMap.init(config->veTable, config->veLoadBins, config->veRpmBins);
|
||||||
// ve2Map.init(engineConfiguration->ve2Table, engineConfiguration->ve2LoadBins, engineConfiguration->ve2RpmBins);
|
|
||||||
lambdaMap.init(config->lambdaTable, config->lambdaLoadBins, config->lambdaRpmBins);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,21 +29,10 @@ TEST(FuelComputer, getCycleFuel) {
|
||||||
EXPECT_FLOAT_EQ(result, 7.0f / (5 * 3));
|
EXPECT_FLOAT_EQ(result, 7.0f / (5 * 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(FuelComputer, LambdaLookup) {
|
|
||||||
MockVp3d lambdaTable;
|
|
||||||
FuelComputer dut(lambdaTable);
|
|
||||||
|
|
||||||
EXPECT_CALL(lambdaTable, getValue(1500, FloatEq(0.7f)))
|
|
||||||
.WillOnce(Return(0.85f));
|
|
||||||
|
|
||||||
EXPECT_FLOAT_EQ(dut.getTargetLambda(1500, 0.7f), 0.85f);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(FuelComputer, FlexFuel) {
|
TEST(FuelComputer, FlexFuel) {
|
||||||
EngineTestHelper eth(TEST_ENGINE);
|
EngineTestHelper eth(TEST_ENGINE);
|
||||||
|
|
||||||
MockVp3d lambdaTable;
|
FuelComputer dut;
|
||||||
FuelComputer dut(lambdaTable);
|
|
||||||
|
|
||||||
// easier values for testing
|
// easier values for testing
|
||||||
engineConfiguration->stoichRatioPrimary = 15;
|
engineConfiguration->stoichRatioPrimary = 15;
|
||||||
|
|
Loading…
Reference in New Issue