better corner case logging, also refactoring
This commit is contained in:
parent
e76c6e251b
commit
a3b13364da
|
@ -523,7 +523,7 @@ static void showFuelInfo2(float rpm, float engineLoad) {
|
|||
scheduleMsg(&logger2, "iatCorrection=%f cltCorrection=%f injectorLag=%f", iatCorrection, cltCorrection,
|
||||
injectorLag);
|
||||
|
||||
float value = getRunningFuel(baseFuelMs, (int) rpm PASS_ENGINE_PARAMETER);
|
||||
float value = getRunningFuel(baseFuelMs PASS_ENGINE_PARAMETER);
|
||||
scheduleMsg(&logger2, "injection pulse width: %f", value);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -127,16 +127,18 @@ percent_t getInjectorDutyCycle(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
|||
*/
|
||||
floatms_t getInjectionDuration(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
||||
float theoreticalInjectionLength;
|
||||
if (isCrankingR(rpm)) {
|
||||
int numberOfCylinders = getNumberOfInjections(engineConfiguration->crankingInjectionMode PASS_ENGINE_PARAMETER);
|
||||
efiAssert(numberOfCylinders > 0, "cranking numberOfCylinders", 0);
|
||||
theoreticalInjectionLength = getCrankingFuel(PASS_ENGINE_PARAMETER_F)
|
||||
/ numberOfCylinders;
|
||||
bool isCranking = isCrankingR(rpm);
|
||||
int numberOfCylinders = getNumberOfInjections(isCranking ?
|
||||
engineConfiguration->crankingInjectionMode :
|
||||
engineConfiguration->injectionMode PASS_ENGINE_PARAMETER);
|
||||
if (numberOfCylinders == 0) {
|
||||
return 0; // we can end up here during configuration reset
|
||||
}
|
||||
if (isCranking) {
|
||||
theoreticalInjectionLength = getCrankingFuel(PASS_ENGINE_PARAMETER_F) / numberOfCylinders;
|
||||
} else {
|
||||
floatms_t baseFuel = getBaseFuel(rpm PASS_ENGINE_PARAMETER);
|
||||
floatms_t fuelPerCycle = getRunningFuel(baseFuel, rpm PASS_ENGINE_PARAMETER);
|
||||
int numberOfCylinders = getNumberOfInjections(engineConfiguration->injectionMode PASS_ENGINE_PARAMETER);
|
||||
efiAssert(numberOfCylinders > 0, "running numberOfCylinders", 0);
|
||||
floatms_t fuelPerCycle = getRunningFuel(baseFuel PASS_ENGINE_PARAMETER);
|
||||
theoreticalInjectionLength = fuelPerCycle / numberOfCylinders;
|
||||
#if EFI_PRINTF_FUEL_DETAILS || defined(__DOXYGEN__)
|
||||
printf("baseFuel=%f fuelPerCycle=%f theoreticalInjectionLength=%f\t\n",
|
||||
|
@ -146,7 +148,7 @@ floatms_t getInjectionDuration(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
|||
return theoreticalInjectionLength + ENGINE(engineState.injectorLag);
|
||||
}
|
||||
|
||||
floatms_t getRunningFuel(floatms_t baseFuel, int rpm DECLARE_ENGINE_PARAMETER_S) {
|
||||
floatms_t getRunningFuel(floatms_t baseFuel DECLARE_ENGINE_PARAMETER_S) {
|
||||
float iatCorrection = ENGINE(engineState.iatFuelCorrection);
|
||||
float cltCorrection = ENGINE(engineState.cltFuelCorrection);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ floatms_t getBaseFuel(int rpm DECLARE_ENGINE_PARAMETER_S);
|
|||
/**
|
||||
* @return baseFuel with CLT and IAT corrections
|
||||
*/
|
||||
floatms_t getRunningFuel(floatms_t baseFuel, int rpm DECLARE_ENGINE_PARAMETER_S);
|
||||
floatms_t getRunningFuel(floatms_t baseFuel DECLARE_ENGINE_PARAMETER_S);
|
||||
|
||||
floatms_t getRealMafFuel(float airMass, int rpm DECLARE_ENGINE_PARAMETER_S);
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ void testFuelMap(void) {
|
|||
printf("*************************************************** getRunningFuel 1\r\n");
|
||||
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_F);
|
||||
float baseFuel = getBaseTableFuel(eth.engine.engineConfiguration, 5, getEngineLoadT(PASS_ENGINE_PARAMETER_F));
|
||||
assertEqualsM("base fuel", 5.05, getRunningFuel(baseFuel, 5 PASS_ENGINE_PARAMETER));
|
||||
assertEqualsM("base fuel", 5.05, getRunningFuel(baseFuel PASS_ENGINE_PARAMETER));
|
||||
|
||||
printf("*************************************************** setting IAT table\r\n");
|
||||
for (int i = 0; i < IAT_CURVE_SIZE; i++) {
|
||||
|
@ -103,7 +103,7 @@ void testFuelMap(void) {
|
|||
printf("*************************************************** getRunningFuel 2\r\n");
|
||||
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_F);
|
||||
baseFuel = getBaseTableFuel(eth.engine.engineConfiguration, 5, getEngineLoadT(PASS_ENGINE_PARAMETER_F));
|
||||
assertEqualsM("v1", 30150, getRunningFuel(baseFuel, 5 PASS_ENGINE_PARAMETER));
|
||||
assertEqualsM("v1", 30150, getRunningFuel(baseFuel PASS_ENGINE_PARAMETER));
|
||||
|
||||
testMafValue = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue