auto-sync

This commit is contained in:
rusEfi 2016-09-03 01:02:32 -04:00
parent e6dc0ab05a
commit f9d77c4d90
3 changed files with 31 additions and 15 deletions

View File

@ -58,7 +58,7 @@ public:
int eventsCount;
private:
void clear();
void registerInjectionEvent(int injectorIndex, float angle, bool isSimultanious DECLARE_ENGINE_PARAMETER_S);
void registerInjectionEvent(int injectorIndex, float angle, angle_t injectionDuration, bool isSimultanious DECLARE_ENGINE_PARAMETER_S);
};
/**

View File

@ -135,7 +135,7 @@ void initializeIgnitionActions(angle_t advance, angle_t dwellAngle,
}
}
void FuelSchedule::registerInjectionEvent(int injectorIndex, float angle,
void FuelSchedule::registerInjectionEvent(int injectorIndex, float angle, angle_t injectionDuration,
bool isSimultanious DECLARE_ENGINE_PARAMETER_S) {
NamedOutputPin *output = &enginePins.injectors[injectorIndex];
@ -150,7 +150,8 @@ void FuelSchedule::registerInjectionEvent(int injectorIndex, float angle,
// error already reported
return;
}
ev->isOverlapping = angle < 0;
fixAngle(angle);
ev->isOverlapping = angle < 720 && (angle + injectionDuration) > 720;
ev->injectorIndex = injectorIndex;
ev->output = output;
@ -201,8 +202,8 @@ void FuelSchedule::addFuelEvents(injection_mode_e mode DECLARE_ENGINE_PARAMETER_
* todo: since this method is not invoked within trigger event handler and
* engineState.injectionOffset is calculated from the same utility timer should we more that logic here?
*/
angle_t baseAngle = ENGINE(engineState.injectionOffset)
- MS2US(ENGINE(fuelMs)) / ENGINE(rpmCalculator.oneDegreeUs);
angle_t injectionDuration = MS2US(ENGINE(fuelMs)) / ENGINE(rpmCalculator.oneDegreeUs);
angle_t baseAngle = ENGINE(engineState.injectionOffset) - injectionDuration;
switch (mode) {
case IM_SEQUENTIAL:
@ -210,7 +211,7 @@ void FuelSchedule::addFuelEvents(injection_mode_e mode DECLARE_ENGINE_PARAMETER_
int index = getCylinderId(engineConfiguration->specs.firingOrder, i) - 1;
float angle = baseAngle
+ ENGINE(engineCycle) * i / CONFIG(specs.cylindersCount);
registerInjectionEvent(index, angle, false PASS_ENGINE_PARAMETER);
registerInjectionEvent(index, angle, injectionDuration, false PASS_ENGINE_PARAMETER);
}
break;
case IM_SIMULTANEOUS:
@ -222,7 +223,7 @@ void FuelSchedule::addFuelEvents(injection_mode_e mode DECLARE_ENGINE_PARAMETER_
* We do not need injector pin here because we will control all injectors
* simultaneously
*/
registerInjectionEvent(0, angle, true PASS_ENGINE_PARAMETER);
registerInjectionEvent(0, angle, injectionDuration, true PASS_ENGINE_PARAMETER);
}
break;
case IM_BATCH:
@ -230,7 +231,7 @@ void FuelSchedule::addFuelEvents(injection_mode_e mode DECLARE_ENGINE_PARAMETER_
int index = i % (engineConfiguration->specs.cylindersCount / 2);
float angle = baseAngle
+ i * ENGINE(engineCycle) / CONFIG(specs.cylindersCount);
registerInjectionEvent(index, angle, false PASS_ENGINE_PARAMETER);
registerInjectionEvent(index, angle, injectionDuration, false PASS_ENGINE_PARAMETER);
if (CONFIG(twoWireBatchInjection)) {
@ -238,7 +239,7 @@ void FuelSchedule::addFuelEvents(injection_mode_e mode DECLARE_ENGINE_PARAMETER_
* also fire the 2nd half of the injectors so that we can implement a batch mode on individual wires
*/
index = index + (CONFIG(specs.cylindersCount) / 2);
registerInjectionEvent(index, angle, false PASS_ENGINE_PARAMETER);
registerInjectionEvent(index, angle, injectionDuration, false PASS_ENGINE_PARAMETER);
}
}
break;

View File

@ -594,10 +594,11 @@ static void assertInjectorDownEvent(const char *msg, int eventIndex, efitime_t m
assertEvent(msg, eventIndex, (void*)seTurnPinLow, timeNow, momentX, (long)&enginePins.injectors[injectorIndex]);
}
static void assertInjectionEvent(InjectionEvent *ev, int injectorIndex, int eventIndex, angle_t angleOffset) {
static void assertInjectionEvent(InjectionEvent *ev, int injectorIndex, int eventIndex, angle_t angleOffset, bool isOverlapping) {
assertEqualsM("inj index", injectorIndex, ev->injectorIndex);
assertEqualsM("event index", eventIndex, ev->injectionStart.eventIndex);
assertEqualsM("event offset", angleOffset, ev->injectionStart.angleOffset);
assertTrueM("is overlapping", isOverlapping == ev->isOverlapping);
}
void testFuelSchedulerBug299(void) {
@ -608,6 +609,7 @@ void testFuelSchedulerBug299(void) {
engineConfiguration->isIgnitionEnabled = false;
engineConfiguration->specs.cylindersCount = 4;
engineConfiguration->injectionMode = IM_BATCH;
FuelSchedule * t;
timeNow = 0;
schedulingQueue.clear();
@ -655,6 +657,13 @@ void testFuelSchedulerBug299(void) {
assertInjectorDownEvent("@7", 7, MS2US(40), 1);
assertEqualsM("exec#0", 0, schedulingQueue.executeAll(timeNow));
t = ENGINE(engineConfiguration2)->injectionEvents;
assertEqualsM("t.s#0", 4, t->injectionEvents.size);
assertInjectionEvent(&t->injectionEvents.elements[0], 0, 0, 513, false);
assertInjectionEvent(&t->injectionEvents.elements[1], 1, 0, 693, false);
assertInjectionEvent(&t->injectionEvents.elements[2], 0, 0, 153, false);
assertInjectionEvent(&t->injectionEvents.elements[3], 1, 0, 153 + 180, false);
/**
* Trigger down - no new events, executing some
*/
@ -783,12 +792,12 @@ void testFuelSchedulerBug299(void) {
engine->periodicFastCallback(PASS_ENGINE_PARAMETER_F);
FuelSchedule * t = ENGINE(engineConfiguration2)->injectionEvents;
t = ENGINE(engineConfiguration2)->injectionEvents;
assertEqualsM("t.s", 4, t->injectionEvents.size);
assertInjectionEvent(&t->injectionEvents.elements[0], 0, 0, 225);
assertInjectionEvent(&t->injectionEvents.elements[1], 1, 0, 405);
assertInjectionEvent(&t->injectionEvents.elements[2], 0, 0, 585);
assertInjectionEvent(&t->injectionEvents.elements[3], 1, 0, 45);
assertInjectionEvent(&t->injectionEvents.elements[0], 0, 0, 225, false);
assertInjectionEvent(&t->injectionEvents.elements[1], 1, 0, 405, false);
assertInjectionEvent(&t->injectionEvents.elements[2], 0, 0, 585, true);
assertInjectionEvent(&t->injectionEvents.elements[3], 1, 0, 45, false);
timeNow += MS2US(20);
eth.firePrimaryTriggerRise();
@ -828,6 +837,12 @@ void testFuelSchedulerBug299(void) {
eth.firePrimaryTriggerRise();
assertEqualsM("qs#3", 8, schedulingQueue.size());
t = ENGINE(engineConfiguration2)->injectionEvents;
assertEqualsM("t.s", 4, t->injectionEvents.size);
assertInjectionEvent(&t->injectionEvents.elements[0], 0, 0, 225, false);
assertInjectionEvent(&t->injectionEvents.elements[1], 1, 0, 405, false);
assertInjectionEvent(&t->injectionEvents.elements[2], 0, 0, 585, true);
assertInjectionEvent(&t->injectionEvents.elements[3], 1, 0, 45, false);
unitTestValue = 0;