auto-sync
This commit is contained in:
parent
e6dc0ab05a
commit
f9d77c4d90
|
@ -58,7 +58,7 @@ public:
|
||||||
int eventsCount;
|
int eventsCount;
|
||||||
private:
|
private:
|
||||||
void clear();
|
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);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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) {
|
bool isSimultanious DECLARE_ENGINE_PARAMETER_S) {
|
||||||
|
|
||||||
NamedOutputPin *output = &enginePins.injectors[injectorIndex];
|
NamedOutputPin *output = &enginePins.injectors[injectorIndex];
|
||||||
|
@ -150,7 +150,8 @@ void FuelSchedule::registerInjectionEvent(int injectorIndex, float angle,
|
||||||
// error already reported
|
// error already reported
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ev->isOverlapping = angle < 0;
|
fixAngle(angle);
|
||||||
|
ev->isOverlapping = angle < 720 && (angle + injectionDuration) > 720;
|
||||||
|
|
||||||
ev->injectorIndex = injectorIndex;
|
ev->injectorIndex = injectorIndex;
|
||||||
ev->output = output;
|
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
|
* 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?
|
* engineState.injectionOffset is calculated from the same utility timer should we more that logic here?
|
||||||
*/
|
*/
|
||||||
angle_t baseAngle = ENGINE(engineState.injectionOffset)
|
angle_t injectionDuration = MS2US(ENGINE(fuelMs)) / ENGINE(rpmCalculator.oneDegreeUs);
|
||||||
- MS2US(ENGINE(fuelMs)) / ENGINE(rpmCalculator.oneDegreeUs);
|
angle_t baseAngle = ENGINE(engineState.injectionOffset) - injectionDuration;
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case IM_SEQUENTIAL:
|
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;
|
int index = getCylinderId(engineConfiguration->specs.firingOrder, i) - 1;
|
||||||
float angle = baseAngle
|
float angle = baseAngle
|
||||||
+ ENGINE(engineCycle) * i / CONFIG(specs.cylindersCount);
|
+ ENGINE(engineCycle) * i / CONFIG(specs.cylindersCount);
|
||||||
registerInjectionEvent(index, angle, false PASS_ENGINE_PARAMETER);
|
registerInjectionEvent(index, angle, injectionDuration, false PASS_ENGINE_PARAMETER);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IM_SIMULTANEOUS:
|
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
|
* We do not need injector pin here because we will control all injectors
|
||||||
* simultaneously
|
* simultaneously
|
||||||
*/
|
*/
|
||||||
registerInjectionEvent(0, angle, true PASS_ENGINE_PARAMETER);
|
registerInjectionEvent(0, angle, injectionDuration, true PASS_ENGINE_PARAMETER);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IM_BATCH:
|
case IM_BATCH:
|
||||||
|
@ -230,7 +231,7 @@ void FuelSchedule::addFuelEvents(injection_mode_e mode DECLARE_ENGINE_PARAMETER_
|
||||||
int index = i % (engineConfiguration->specs.cylindersCount / 2);
|
int index = i % (engineConfiguration->specs.cylindersCount / 2);
|
||||||
float angle = baseAngle
|
float angle = baseAngle
|
||||||
+ i * ENGINE(engineCycle) / CONFIG(specs.cylindersCount);
|
+ i * ENGINE(engineCycle) / CONFIG(specs.cylindersCount);
|
||||||
registerInjectionEvent(index, angle, false PASS_ENGINE_PARAMETER);
|
registerInjectionEvent(index, angle, injectionDuration, false PASS_ENGINE_PARAMETER);
|
||||||
|
|
||||||
if (CONFIG(twoWireBatchInjection)) {
|
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
|
* 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);
|
index = index + (CONFIG(specs.cylindersCount) / 2);
|
||||||
registerInjectionEvent(index, angle, false PASS_ENGINE_PARAMETER);
|
registerInjectionEvent(index, angle, injectionDuration, false PASS_ENGINE_PARAMETER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -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]);
|
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("inj index", injectorIndex, ev->injectorIndex);
|
||||||
assertEqualsM("event index", eventIndex, ev->injectionStart.eventIndex);
|
assertEqualsM("event index", eventIndex, ev->injectionStart.eventIndex);
|
||||||
assertEqualsM("event offset", angleOffset, ev->injectionStart.angleOffset);
|
assertEqualsM("event offset", angleOffset, ev->injectionStart.angleOffset);
|
||||||
|
assertTrueM("is overlapping", isOverlapping == ev->isOverlapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testFuelSchedulerBug299(void) {
|
void testFuelSchedulerBug299(void) {
|
||||||
|
@ -608,6 +609,7 @@ void testFuelSchedulerBug299(void) {
|
||||||
engineConfiguration->isIgnitionEnabled = false;
|
engineConfiguration->isIgnitionEnabled = false;
|
||||||
engineConfiguration->specs.cylindersCount = 4;
|
engineConfiguration->specs.cylindersCount = 4;
|
||||||
engineConfiguration->injectionMode = IM_BATCH;
|
engineConfiguration->injectionMode = IM_BATCH;
|
||||||
|
FuelSchedule * t;
|
||||||
|
|
||||||
timeNow = 0;
|
timeNow = 0;
|
||||||
schedulingQueue.clear();
|
schedulingQueue.clear();
|
||||||
|
@ -655,6 +657,13 @@ void testFuelSchedulerBug299(void) {
|
||||||
assertInjectorDownEvent("@7", 7, MS2US(40), 1);
|
assertInjectorDownEvent("@7", 7, MS2US(40), 1);
|
||||||
assertEqualsM("exec#0", 0, schedulingQueue.executeAll(timeNow));
|
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
|
* Trigger down - no new events, executing some
|
||||||
*/
|
*/
|
||||||
|
@ -783,12 +792,12 @@ void testFuelSchedulerBug299(void) {
|
||||||
engine->periodicFastCallback(PASS_ENGINE_PARAMETER_F);
|
engine->periodicFastCallback(PASS_ENGINE_PARAMETER_F);
|
||||||
|
|
||||||
|
|
||||||
FuelSchedule * t = ENGINE(engineConfiguration2)->injectionEvents;
|
t = ENGINE(engineConfiguration2)->injectionEvents;
|
||||||
assertEqualsM("t.s", 4, t->injectionEvents.size);
|
assertEqualsM("t.s", 4, t->injectionEvents.size);
|
||||||
assertInjectionEvent(&t->injectionEvents.elements[0], 0, 0, 225);
|
assertInjectionEvent(&t->injectionEvents.elements[0], 0, 0, 225, false);
|
||||||
assertInjectionEvent(&t->injectionEvents.elements[1], 1, 0, 405);
|
assertInjectionEvent(&t->injectionEvents.elements[1], 1, 0, 405, false);
|
||||||
assertInjectionEvent(&t->injectionEvents.elements[2], 0, 0, 585);
|
assertInjectionEvent(&t->injectionEvents.elements[2], 0, 0, 585, true);
|
||||||
assertInjectionEvent(&t->injectionEvents.elements[3], 1, 0, 45);
|
assertInjectionEvent(&t->injectionEvents.elements[3], 1, 0, 45, false);
|
||||||
|
|
||||||
timeNow += MS2US(20);
|
timeNow += MS2US(20);
|
||||||
eth.firePrimaryTriggerRise();
|
eth.firePrimaryTriggerRise();
|
||||||
|
@ -828,6 +837,12 @@ void testFuelSchedulerBug299(void) {
|
||||||
eth.firePrimaryTriggerRise();
|
eth.firePrimaryTriggerRise();
|
||||||
assertEqualsM("qs#3", 8, schedulingQueue.size());
|
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;
|
unitTestValue = 0;
|
||||||
|
|
Loading…
Reference in New Issue