Selectable AFR axis override (#1771)
* add config fields * config options * new output channels * dump out state to ts * s * implement override * enums * this test is no longer used * test new behavior * old * comments * impl * unhide option * fix * tests
This commit is contained in:
parent
4ce758db88
commit
6d1acb40f8
|
@ -1,13 +1,15 @@
|
||||||
#include "fuel_computer.h"
|
#include "fuel_computer.h"
|
||||||
|
#include "map.h"
|
||||||
|
|
||||||
EXTERN_ENGINE;
|
EXTERN_ENGINE;
|
||||||
|
|
||||||
mass_t FuelComputerBase::getCycleFuel(mass_t airmass, int rpm, float load) const {
|
mass_t FuelComputerBase::getCycleFuel(mass_t airmass, int rpm, float load) const {
|
||||||
|
load = getTargetLambdaLoadAxis(load);
|
||||||
|
|
||||||
float stoich = getStoichiometricRatio();
|
float stoich = getStoichiometricRatio();
|
||||||
float lambda = getTargetLambda(rpm, load);
|
float lambda = getTargetLambda(rpm, load);
|
||||||
float afr = stoich * lambda;
|
float afr = stoich * lambda;
|
||||||
|
|
||||||
// TODO: override target AFR load axis value
|
|
||||||
ENGINE(engineState.currentAfrLoad) = load;
|
ENGINE(engineState.currentAfrLoad) = load;
|
||||||
ENGINE(engineState.targetAFR) = afr;
|
ENGINE(engineState.targetAFR) = afr;
|
||||||
|
|
||||||
|
@ -33,4 +35,16 @@ float FuelComputer::getTargetLambda(int rpm, float load) const {
|
||||||
|
|
||||||
// TODO: set the table value in lambda instead of afr
|
// TODO: set the table value in lambda instead of afr
|
||||||
return m_afrTable->getValue(rpm, load) / 14.7f;
|
return m_afrTable->getValue(rpm, load) / 14.7f;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
float FuelComputer::getTargetLambdaLoadAxis(float defaultLoad) const {
|
||||||
|
switch(CONFIG(afrOverrideMode)) {
|
||||||
|
case AFR_None: return defaultLoad;
|
||||||
|
case AFR_MAP: return getMap(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
// 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(engineState.sd.airMassInOneCylinder) / ENGINE(standardAirCharge);
|
||||||
|
default: return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual float getStoichiometricRatio() const = 0;
|
virtual float getStoichiometricRatio() const = 0;
|
||||||
virtual float getTargetLambda(int rpm, float load) const = 0;
|
virtual float getTargetLambda(int rpm, float load) const = 0;
|
||||||
|
virtual float getTargetLambdaLoadAxis(float defaultLoad) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This class is a usable implemenation of a fuel model that reads real configuration
|
// This class is a usable implemenation of a fuel model that reads real configuration
|
||||||
|
@ -30,6 +31,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
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;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const ValueProvider3D* const m_afrTable;
|
const ValueProvider3D* const m_afrTable;
|
||||||
|
|
|
@ -1592,8 +1592,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
|
||||||
field = "#Batch injection with individual wiring"
|
field = "#Batch injection with individual wiring"
|
||||||
field = "Two wire batch emulation", twoWireBatchInjection, {isInjectionEnabled == 1 && injectionMode == 2}
|
field = "Two wire batch emulation", twoWireBatchInjection, {isInjectionEnabled == 1 && injectionMode == 2}
|
||||||
field = "Override VE table load axis", veOverrideMode, { isInjectionEnabled }
|
field = "Override VE table load axis", veOverrideMode, { isInjectionEnabled }
|
||||||
;field = "Override AFR table load axis", afrOverrideMode, { isInjectionEnabled }
|
field = "Override AFR table load axis", afrOverrideMode, { isInjectionEnabled }
|
||||||
; ^^^ Not yet implemented, hidden for now! ^^^
|
|
||||||
|
|
||||||
dialog = ignitionOutputs, "Ignition Outputs"
|
dialog = ignitionOutputs, "Ignition Outputs"
|
||||||
field = "Ignition Pin Mode", ignitionPinMode, {isIgnitionEnabled == 1}
|
field = "Ignition Pin Mode", ignitionPinMode, {isIgnitionEnabled == 1}
|
||||||
|
|
|
@ -13,6 +13,7 @@ class MockFuelComputer : public FuelComputerBase {
|
||||||
public:
|
public:
|
||||||
MOCK_METHOD(float, getStoichiometricRatio, (), (const, override));
|
MOCK_METHOD(float, getStoichiometricRatio, (), (const, override));
|
||||||
MOCK_METHOD(float, getTargetLambda, (int rpm, float load), (const, override));
|
MOCK_METHOD(float, getTargetLambda, (int rpm, float load), (const, override));
|
||||||
|
MOCK_METHOD(float, getTargetLambdaLoadAxis, (float defaultLoad), (const, override));
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST(FuelComputer, getCycleFuel) {
|
TEST(FuelComputer, getCycleFuel) {
|
||||||
|
@ -21,6 +22,8 @@ TEST(FuelComputer, getCycleFuel) {
|
||||||
MockFuelComputer dut;
|
MockFuelComputer dut;
|
||||||
INJECT_ENGINE_REFERENCE(&dut);
|
INJECT_ENGINE_REFERENCE(&dut);
|
||||||
|
|
||||||
|
EXPECT_CALL(dut, getTargetLambdaLoadAxis(FloatEq(0.8f)))
|
||||||
|
.WillOnce(Return(0.8f));
|
||||||
EXPECT_CALL(dut, getStoichiometricRatio())
|
EXPECT_CALL(dut, getStoichiometricRatio())
|
||||||
.WillOnce(Return(3.0f));
|
.WillOnce(Return(3.0f));
|
||||||
EXPECT_CALL(dut, getTargetLambda(1000, FloatEq(0.8f)))
|
EXPECT_CALL(dut, getTargetLambda(1000, FloatEq(0.8f)))
|
||||||
|
|
Loading…
Reference in New Issue