auto-sync

This commit is contained in:
rusEfi 2016-08-06 01:04:28 -04:00
parent 460bb0e56e
commit 5e42bdb39f
4 changed files with 35 additions and 2 deletions

View File

@ -328,6 +328,13 @@ void Engine::prepareFuelSchedule(DECLARE_ENGINE_PARAMETER_F) {
injection_mode_e mode = isCrankingR(rpm) ? CONFIG(crankingInjectionMode) : CONFIG(injectionMode);
if (ENGINE(engineConfiguration2)->processing->usedAtEngineCycle != 0 &&
ENGINE(engineConfiguration2)->processing->usedAtEngineCycle == ENGINE(rpmCalculator).getRevolutionCounter()) {
// we are here if engine is still using this older fuel schedule, not yet time to override it
// scheduleMsg(&logger, "still need %d", ENGINE(rpmCalculator).getRevolutionCounter());
return;
}
ENGINE(engineConfiguration2)->processing->addFuelEvents(
mode PASS_ENGINE_PARAMETER);
ENGINE(m.injectonSchTime) = GET_TIMESTAMP() - ENGINE(m.beforeInjectonSch);

View File

@ -43,6 +43,8 @@ public:
*/
void addFuelEvents(injection_mode_e mode DECLARE_ENGINE_PARAMETER_S);
uint32_t usedAtEngineCycle;
InjectionEventList injectionEvents;
/**
@ -258,6 +260,14 @@ public:
WallFuel wallFuel;
/**
* we have a background thread preparing new fuel schedule while engine is running using existing
* copy of fuel schedule. This pointer allows us to use the same schedule for the whole duration of an
* engine cycle.
*
*/
FuelSchedule *fuelScheduleForThisEngineCycle;
/**
* That's the list of pending spark firing events
*/

View File

@ -128,12 +128,22 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int eventIndex, bool limitedF
return;
}
// scheduleMsg(logger, "handleFuel totalPerCycle=%f", totalPerCycle);
// scheduleMsg(logger, "handleFuel engineCycleDuration=%f", engineCycleDuration);
if (engine->isCylinderCleanupMode) {
return;
}
floatus_t injectionStartDelayUs = ENGINE(rpmCalculator.oneDegreeUs) * event->injectionStart.angleOffset;
// scheduleMsg(logger, "handleFuel pin=%s eventIndex %d duration=%fms %d", event->output->name,
// eventIndex,
// injectionDuration,
// getRevolutionCounter());
// scheduleMsg(logger, "handleFuel pin=%s delay=%f %d", event->output->name, injectionStartDelayUs,
// getRevolutionCounter());
OutputSignal *signal = &ENGINE(engineConfiguration2)->fuelActuators[eventIndex];
if (event->isSimultanious) {
@ -179,13 +189,15 @@ static ALWAYS_INLINE void handleFuel(bool limitedFuel, uint32_t eventIndex, int
* Ignition events are defined by addFuelEvents() according to selected
* fueling strategy
*/
FuelSchedule *fs = ENGINE(engineConfiguration2)->injectionEvents;
FuelSchedule *fs = engine->fuelScheduleForThisEngineCycle;
InjectionEventList *injectionEvents = &fs->injectionEvents;
if (!fs->hasEvents[eventIndex])
return;
// scheduleMsg(logger, "handleFuel ind=%d %d", eventIndex, getRevolutionCounter());
ENGINE(tpsAccelEnrichment.onNewValue(getTPS(PASS_ENGINE_PARAMETER_F) PASS_ENGINE_PARAMETER));
ENGINE(engineLoadAccelEnrichment.onEngineCycle(PASS_ENGINE_PARAMETER_F));
@ -453,6 +465,10 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex DECL
int revolutionIndex = ENGINE(rpmCalculator).getRevolutionCounter() % 2;
if (eventIndex == 0) {
// these two statements should be atomic, but in reality we should be fine, right?
engine->fuelScheduleForThisEngineCycle = ENGINE(engineConfiguration2)->injectionEvents;
engine->fuelScheduleForThisEngineCycle->usedAtEngineCycle = ENGINE(rpmCalculator).getRevolutionCounter();
if (triggerVersion.isOld()) {
prepareOutputSignals(PASS_ENGINE_PARAMETER_F);
}

View File

@ -296,5 +296,5 @@ int getRusEfiVersion(void) {
return 123; // this is here to make the compiler happy about the unused array
if (UNUSED_CCM_SIZE[0] * 0 != 0)
return 3211; // this is here to make the compiler happy about the unused array
return 20160715;
return 20160805;
}