Merge pull request #1622 from mck1117/encapsulate-wwae

put wall wetting inside InjectionEvent
This commit is contained in:
rusefillc 2020-07-20 14:19:57 -04:00 committed by GitHub
commit d85e98d1f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 15 deletions

View File

@ -276,7 +276,7 @@ static const void * getStructAddr(int structId) {
case LDS_ENGINE_STATE_INDEX:
return static_cast<engine_state2_s*>(&engine->engineState);
case LDS_FUEL_TRIM_STATE_INDEX:
return static_cast<wall_fuel_state*>(&engine->wallFuel[0]);
return static_cast<wall_fuel_state*>(&engine->injectionEvents.elements[0].wallFuel);
case LDS_TRIGGER_CENTRAL_STATE_INDEX:
return static_cast<trigger_central_s*>(&engine->triggerCentral);
case LDS_TRIGGER_STATE_STATE_INDEX:

View File

@ -562,11 +562,13 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
// 148
tsOutputChannels->fuelTankLevel = engine->sensors.fuelTankLevel;
// 160
tsOutputChannels->wallFuelAmount = ENGINE(wallFuel[0]).getWallFuel();
const auto& wallFuel = ENGINE(injectionEvents.elements[0].wallFuel);
tsOutputChannels->wallFuelAmount = wallFuel.getWallFuel();
// 168
tsOutputChannels->wallFuelCorrection = wallFuel.wallFuelCorrection;
// 164
tsOutputChannels->iatCorrection = ENGINE(engineState.running.intakeTemperatureCoefficient);
// 168
tsOutputChannels->wallFuelCorrection = ENGINE(wallFuel[0]).wallFuelCorrection;
// 184
tsOutputChannels->cltCorrection = ENGINE(engineState.running.coolantTemperatureCoefficient);
// 188

View File

@ -140,7 +140,6 @@ public:
IgnitionEventList ignitionEvents;
#endif /* EFI_ENGINE_CONTROL */
WallFuel wallFuel[INJECTION_PIN_COUNT];
bool needToStopEngine(efitick_t nowNt) const;
bool etbAutoTune = false;
/**

View File

@ -12,6 +12,7 @@
#include "scheduler.h"
#include "fl_stack.h"
#include "trigger_structure.h"
#include "accel_enrichment.h"
#define MAX_INJECTION_OUTPUT_COUNT INJECTION_PIN_COUNT
#define MAX_WIRES_COUNT 2
@ -42,6 +43,8 @@ public:
* TODO: make watchdog decrement relevant counter
*/
bool isScheduled = false;
WallFuel wallFuel;
};

View File

@ -208,9 +208,9 @@ static void resetAccel(void) {
engine->engineLoadAccelEnrichment.resetAE();
engine->tpsAccelEnrichment.resetAE();
for (unsigned int i = 0; i < sizeof(engine->wallFuel) / sizeof(engine->wallFuel[0]); i++)
for (unsigned int i = 0; i < efi::size(engine->injectionEvents.elements); i++)
{
engine->wallFuel[i].resetWF();
engine->injectionEvents.elements[i].wallFuel.resetWF();
}
}

View File

@ -188,8 +188,7 @@ void handleFuelInjectionEvent(int injEventIndex, InjectionEvent *event,
* x2 or /2?
*/
size_t injectorIndex = event->outputs[0]->injectorIndex;
const floatms_t injectionDuration = ENGINE(wallFuel[injectorIndex]).adjust(ENGINE(injectionDuration) PASS_ENGINE_PARAMETER_SUFFIX);
const floatms_t injectionDuration = event->wallFuel.adjust(ENGINE(injectionDuration) PASS_ENGINE_PARAMETER_SUFFIX);
#if EFI_PRINTF_FUEL_DETAILS
if (printFuelDebug) {
printf("fuel index=%d injectionDuration=%.2fms adjusted=%.2fms\n",

View File

@ -17,9 +17,11 @@ TEST(fuel, testWallWettingEnrichmentMath) {
engine->rpmCalculator.setRpmValue(3000 PASS_ENGINE_PARAMETER_SUFFIX);
WallFuel wallFuel;
// each invocation of 'adjust' changes WallWetting internal state
ASSERT_NEAR(16.6666, ENGINE(wallFuel[0]).adjust(10.0 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
ASSERT_NEAR(16.198, ENGINE(wallFuel[0]).adjust(10.0 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
ASSERT_NEAR(16.6666, wallFuel.adjust(10.0 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
ASSERT_NEAR(16.198, wallFuel.adjust(10.0 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
}
TEST(fuel, testWallWettingEnrichmentScheduling) {
@ -38,11 +40,11 @@ TEST(fuel, testWallWettingEnrichmentScheduling) {
int expectedInvocationCounter = 1;
for (int i = 0; i < 4; i++) {
ASSERT_EQ(expectedInvocationCounter, ENGINE(wallFuel[i]).invocationCounter);
ASSERT_EQ(expectedInvocationCounter, ENGINE(injectionEvents.elements[i]).wallFuel.invocationCounter);
}
// Cylinder 5 doesn't exist - shouldn't have been called!
ASSERT_EQ(0, ENGINE(wallFuel[5]).invocationCounter);
ASSERT_EQ(0, ENGINE(injectionEvents.elements[5]).wallFuel.invocationCounter);
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
@ -50,9 +52,9 @@ TEST(fuel, testWallWettingEnrichmentScheduling) {
// still same 1 per cylinder - wall wetting is NOT invoked from 'periodicFastCallback'
for (int i = 0; i < 4; i++) {
ASSERT_EQ(expectedInvocationCounter, ENGINE(wallFuel[i]).invocationCounter);
ASSERT_EQ(expectedInvocationCounter, ENGINE(injectionEvents.elements[i]).wallFuel.invocationCounter);
}
// Cylinder 5 doesn't exist - shouldn't have been called!
ASSERT_EQ(0, ENGINE(wallFuel[5]).invocationCounter);
ASSERT_EQ(0, ENGINE(injectionEvents.elements[5]).wallFuel.invocationCounter);
}