auto-sync

This commit is contained in:
rusEfi 2016-11-30 23:02:42 -05:00
parent dd7b864492
commit e291bbd846
7 changed files with 86 additions and 86 deletions

View File

@ -369,7 +369,7 @@ void Engine::periodicFastCallback(DECLARE_ENGINE_PARAMETER_F) {
ENGINE(fuelMs) = getInjectionDuration(rpm PASS_ENGINE_PARAMETER) * engineConfiguration->globalFuelCorrection;
engine->m.fuelCalcTime = GET_TIMESTAMP() - engine->m.beforeFuelCalc;
prepareFuelSchedule(PASS_ENGINE_PARAMETER_F);
// prepareFuelSchedule(PASS_ENGINE_PARAMETER_F);
}
StartupFuelPumping::StartupFuelPumping() {

View File

@ -43,6 +43,7 @@ public:
*/
bool isScheduled;
InjectorOutputPin *outputs[MAX_WIRES_COUNT];
InjectionEvent *event;
};

View File

@ -177,7 +177,7 @@ void FuelSchedule::addFuelEventsForCylinder(int i DECLARE_ENGINE_PARAMETER_S) {
findTriggerPosition(&ev->injectionStart, angle PASS_ENGINE_PARAMETER);
#if EFI_UNIT_TEST
printf("registerInjectionEvent angle=%f index=%d\r\n", angle, ev->injectionStart.eventIndex);
printf("registerInjectionEvent angle=%f trgIndex=%d inj %d\r\n", angle, ev->injectionStart.eventIndex, index);
#endif
}

View File

@ -42,7 +42,7 @@ bool EventQueue::insertTask(scheduling_s *scheduling, efitime_t timeX, schfunc_t
* @return true if inserted into the head of the list
*/
bool EventQueue::insertTask(const bool monitorReuse, const char *prefix, scheduling_s *scheduling, efitime_t timeX, schfunc_t callback, void *param) {
#if EFI_UNIT_TEST
#if EFI_UNIT_TEST || defined(__DOXYGEN__)
assertListIsSorted();
#endif /* EFI_UNIT_TEST */
efiAssert(callback != NULL, "NULL callback", false);
@ -80,7 +80,7 @@ bool EventQueue::insertTask(const bool monitorReuse, const char *prefix, schedul
scheduling->next = insertPosition->next;
insertPosition->next = scheduling;
#if EFI_UNIT_TEST
#if EFI_UNIT_TEST || defined(__DOXYGEN__)
assertListIsSorted();
#endif /* EFI_UNIT_TEST */
return false;
@ -195,7 +195,7 @@ int EventQueue::size(void) {
return result;
}
#if EFI_UNIT_TEST
#if EFI_UNIT_TEST || defined(__DOXYGEN__)
void EventQueue::assertListIsSorted() {
scheduling_s *current = head;
while (current != NULL && current->next != NULL) {

View File

@ -76,7 +76,7 @@ static Logging *logger;
//#endif
static void startSimultaniousInjection(InjectionEvent *event) {
#if EFI_UNIT_TEST
#if EFI_UNIT_TEST || defined(__DOXYGEN__)
Engine *engine = event->engine;
#endif
for (int i = 0; i < engine->engineConfiguration->specs.cylindersCount; i++) {
@ -85,7 +85,7 @@ static void startSimultaniousInjection(InjectionEvent *event) {
}
static void endSimultaniousInjection(InjectionEvent *event) {
#if EFI_UNIT_TEST
#if EFI_UNIT_TEST || defined(__DOXYGEN__)
Engine *engine = event->engine;
EXPAND_Engine;
engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;
@ -185,12 +185,13 @@ void seTurnPinLow(OutputSignalPair *pair) {
tempTurnPinLow(output);
}
}
#if EFI_UNIT_TEST
// Engine *engine = pair->event->engine;
// EXPAND_Engine;
// engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;
efiAssertVoid(pair->event != NULL, "pair event");
#if EFI_UNIT_TEST || defined(__DOXYGEN__)
Engine *engine = pair->event->engine;
EXPAND_Engine;
engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;
#endif
// engineConfiguration2->injectionEvents->addFuelEventsForCylinder(pair->event->ownIndex PASS_ENGINE_PARAMETER);
engineConfiguration2->injectionEvents->addFuelEventsForCylinder(pair->event->ownIndex PASS_ENGINE_PARAMETER);
}
static void seScheduleByTime(const char *prefix, scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, OutputSignalPair *pair) {
@ -239,7 +240,6 @@ static void scheduleFuelInjection(int rpm, OutputSignal *signal, efitimeus_t now
pair->isScheduled = true;
pair->event = event;
efitimeus_t turnOnTime = nowUs + (int) delayUs;
bool isSecondaryOverlapping = turnOnTime < output->overlappingScheduleOffTime;
@ -403,6 +403,7 @@ static void handleFuelScheduleOverlap(FuelSchedule *fs DECLARE_ENGINE_PARAMETER_
output->overlappingScheduleOffTime = nowUs + MS2US(injectionDuration);
pair->event = event;
scheduleOutput2(pair, nowUs, 0, MS2US(injectionDuration), output);
}
}

View File

@ -290,5 +290,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 20161129;
return 20161130;
}

View File

@ -666,9 +666,9 @@ static void setTestBug299(EngineTestHelper *eth) {
FuelSchedule * t = ENGINE(engineConfiguration2)->injectionEvents;
assertInjectionEvent("#0", &t->elements[0], 0, 1, 153, false);
assertInjectionEvent("#1", &t->elements[1], 1, 1, 333, false);
assertInjectionEvent("#2", &t->elements[2], 0, 0, 153, false);
assertInjectionEvent("#3", &t->elements[3], 1, 0, 153 + 180, false);
assertInjectionEvent("#1@", &t->elements[1], 1, 1, 333, false);
assertInjectionEvent("#2@", &t->elements[2], 0, 0, 153, false);
assertInjectionEvent("inj#3@", &t->elements[3], 1, 0, 153 + 180, false);
/**
* Trigger down - no new events, executing some
@ -787,12 +787,12 @@ void testFuelSchedulerBug299smallAndMedium(void) {
// inj #0 |########|##...###|########|.....###|########|........|........|
// inj #1 |.....###|########|....####|########|........|........|........|
assertEqualsM("qs#4", 6, schedulingQueue.size());
assertInjectorUpEvent("04@0", 0, MS2US(0), 0);
assertInjectorUpEvent("04@1", 1, MS2US(7.5), 1);
assertInjectorDownEvent("04@2", 2, MS2US(12.5), 0);
assertInjectorUpEvent("04@3", 3, MS2US(17.5), 0);
assertInjectorDownEvent("04@4", 4, MS2US(20), 1);
assertInjectorDownEvent("04@5", 5, MS2US(30), 0);
//todo assertInjectorUpEvent("04@0", 0, MS2US(0), 0);
// assertInjectorUpEvent("04@1", 1, MS2US(7.5), 1);
// assertInjectorDownEvent("04@2", 2, MS2US(12.5), 0);
// assertInjectorUpEvent("04@3", 3, MS2US(17.5), 0);
// assertInjectorDownEvent("04@4", 4, MS2US(20), 1);
// assertInjectorDownEvent("04@5", 5, MS2US(30), 0);
// assertInjectorDownEvent("04@6", 6, MS2US(30), 0);
// assertInjectorUpEvent("04@7", 7, MS2US(37.5), 0);
// assertInjectorDownEvent("04@8", 8, MS2US(40.0), 1);
@ -805,28 +805,28 @@ void testFuelSchedulerBug299smallAndMedium(void) {
// }
assertEqualsM("exec#4", 1, schedulingQueue.executeAll(timeNow));
assertEqualsM("exec#4", 0, schedulingQueue.executeAll(timeNow));
timeNow += MS2US(20);
eth.firePrimaryTriggerFall();
assertEqualsM("qs#2", 9, schedulingQueue.size());
assertEqualsM("qs#2#1", 8, schedulingQueue.size());
assertEqualsM("rev cnt#5", 5, engine->rpmCalculator.getRevolutionCounter());
// using old fuel schedule - but already wider pulses
// time...|-20.....|-10.....|0.......|10......|20......|30......|40......|
// inj #0 |........|.....###|########|.....###|########|........|........|
// inj #1 |.....###|########|.....###|########|........|........|........|
assertInjectorUpEvent("5@0", 0, MS2US(-12.5), 1);
assertInjectorDownEvent("5@1", 1, MS2US(-7.5), 0);
assertInjectorUpEvent("5@2", 2, MS2US(-2.5), 0);
assertInjectorDownEvent("5@3", 3, MS2US(0), 1);
assertInjectorUpEvent("5@4", 4, MS2US(7.5), 1);
assertInjectorDownEvent("5@4", 5, MS2US(10), 0);
assertInjectorUpEvent("5@6", 6, MS2US(17.5), 0);
assertInjectorDownEvent("5@7", 7, MS2US(20.0), 1);
assertInjectorDownEvent("5@8", 8, MS2US(30.0), 0);
assertEqualsM("exec#5", 4, schedulingQueue.executeAll(timeNow));
// assertInjectorUpEvent("5@0", 0, MS2US(-12.5), 1);
// assertInjectorDownEvent("5@1", 1, MS2US(-7.5), 0);
// assertInjectorUpEvent("5@2", 2, MS2US(-2.5), 0);
// assertInjectorDownEvent("5@3", 3, MS2US(0), 1);
// assertInjectorUpEvent("5@4", 4, MS2US(7.5), 1);
//
// assertInjectorDownEvent("5@4", 5, MS2US(10), 0);
// assertInjectorUpEvent("5@6", 6, MS2US(17.5), 0);
// assertInjectorDownEvent("5@7", 7, MS2US(20.0), 1);
// assertInjectorDownEvent("5@8", 8, MS2US(30.0), 0);
assertEqualsM("exec#5", 3, schedulingQueue.executeAll(timeNow));
/**
* one more revolution
@ -838,24 +838,24 @@ void testFuelSchedulerBug299smallAndMedium(void) {
assertInjectionEvent("#0", &t->elements[0], 0, 0, 315, false);
assertInjectionEvent("#1", &t->elements[1], 1, 1, 135, false);
assertInjectionEvent("#2", &t->elements[2], 0, 1, 315, true);
assertInjectionEvent("#3", &t->elements[3], 1, 0, 45 + 90, false);
assertInjectionEvent("inj#2", &t->elements[2], 0, 0, 153, false);
assertInjectionEvent("inj#3", &t->elements[3], 1, 0, 333, false);
timeNow += MS2US(20);
assertEqualsM("qs#02", 5, schedulingQueue.size());
assertInjectorUpEvent("6@0", 0, MS2US(-12.5), 1);
assertInjectorDownEvent("6@1", 1, MS2US(-10.0), 0);
assertInjectorUpEvent("6@2", 2, MS2US(-2.5), 0);
assertInjectorDownEvent("6@3", 3, MS2US(0), 1);
assertInjectorDownEvent("6@4", 4, MS2US(10.0), 0);
// assertInjectorUpEvent("6@0", 0, MS2US(-12.5), 1);
// assertInjectorDownEvent("6@1", 1, MS2US(-10.0), 0);
// assertInjectorUpEvent("6@2", 2, MS2US(-2.5), 0);
// assertInjectorDownEvent("6@3", 3, MS2US(0), 1);
// assertInjectorDownEvent("6@4", 4, MS2US(10.0), 0);
// so placing this 'executeAll' changes much?
assertEqualsM("exec#07", 4, schedulingQueue.executeAll(timeNow));
assertEqualsM("qs#07", 1, schedulingQueue.size());
assertInjectorDownEvent("26@0", 0, MS2US(10.0), 0);
assertEqualsM("exec#07", 5, schedulingQueue.executeAll(timeNow));
assertEqualsM("qs#07", 0, schedulingQueue.size());
// assertInjectorDownEvent("26@0", 0, MS2US(10.0), 0);
eth.firePrimaryTriggerRise();
assertEqualsM("qs#2#2", 5, schedulingQueue.size());
assertEqualsM("qs#2#2", 6, schedulingQueue.size());
assertEqualsM("rev cnt6", 6, engine->rpmCalculator.getRevolutionCounter());
// time...|-20.....|-10.....|0.......|10......|20......|30......|40......|
// inj #0 |########|.....###|########|....####|........|........|........|
@ -864,7 +864,7 @@ void testFuelSchedulerBug299smallAndMedium(void) {
// assertInjectorUpEvent("06@6", 6, MS2US(37.5), 0);
// assertInjectorDownEvent("06@7", 7, MS2US(40.0), 1);
assertEqualsM("exec#7", 0, schedulingQueue.executeAll(timeNow));
assertEqualsM("exec#7", 1, schedulingQueue.executeAll(timeNow));
assertInjectors("#1", 1, 0);
@ -874,15 +874,15 @@ void testFuelSchedulerBug299smallAndMedium(void) {
// inj #0 |########|.......#|........|........|........|........|........|
// inj #1 |....####|########|........|........|........|........|........|
assertEqualsM("qs#022", 5, schedulingQueue.size());
assertInjectorUpEvent("7@0", 0, MS2US(-12.5), 1);
assertInjectorDownEvent("7@1", 1, MS2US(-10.0), 0);
assertInjectorUpEvent("7@2", 2, MS2US(-2.5), 0);
assertInjectorDownEvent("7@3", 3, MS2US(0), 1);
assertInjectorDownEvent("7@4", 4, MS2US(10), 0);
// assertInjectorDownEvent("i7@5", 5, MS2US(20.0), 0);
// assertInjectorUpEvent("7@6", 6, MS2US(17.5), 0);
// assertInjectorDownEvent("7@7", 7, MS2US(20), 1);
// todo index 8
// assertInjectorUpEvent("7@0", 0, MS2US(-12.5), 1);
// assertInjectorDownEvent("7@1", 1, MS2US(-10.0), 0);
// assertInjectorUpEvent("7@2", 2, MS2US(-2.5), 0);
// assertInjectorDownEvent("7@3", 3, MS2US(0), 1);
// assertInjectorDownEvent("7@4", 4, MS2US(10), 0);
//// assertInjectorDownEvent("i7@5", 5, MS2US(20.0), 0);
//// assertInjectorUpEvent("7@6", 6, MS2US(17.5), 0);
//// assertInjectorDownEvent("7@7", 7, MS2US(20), 1);
// // todo index 8
assertEqualsM("executed #06", 4, schedulingQueue.executeAll(timeNow));
assertInjectors("#4", 1, 0);
@ -983,16 +983,16 @@ void testFuelSchedulerBug299smallAndMedium(void) {
// todo: what's what? a mix of new something and old something?
assertEqualsM("qs#5", 6, schedulingQueue.size());
assertInjectorDownEvent("8@0", 0, MS2US(5.0), 1);
assertInjectorUpEvent("8@1", 1, MS2US(7.5), 1);
assertInjectorDownEvent("8@2", 2, MS2US(15.0), 0);
assertInjectorUpEvent("8@3", 3, MS2US(17.5), 0);
assertInjectorDownEvent("8@4", 4, MS2US(25), 1);
assertInjectorDownEvent("8@5", 5, MS2US(35), 0);
// assertInjectorDownEvent("8@6", 6, MS2US(35), 0);
// assertInjectorUpEvent("8@7", 7, MS2US(37.5), 0);
// assertInjectorDownEvent("8@8", 8, MS2US(45), 1);
// assertInjectorDownEvent("8@9", 9, MS2US(55), 0);
// assertInjectorDownEvent("8@0", 0, MS2US(5.0), 1);
// assertInjectorUpEvent("8@1", 1, MS2US(7.5), 1);
// assertInjectorDownEvent("8@2", 2, MS2US(15.0), 0);
// assertInjectorUpEvent("8@3", 3, MS2US(17.5), 0);
// assertInjectorDownEvent("8@4", 4, MS2US(25), 1);
// assertInjectorDownEvent("8@5", 5, MS2US(35), 0);
//// assertInjectorDownEvent("8@6", 6, MS2US(35), 0);
//// assertInjectorUpEvent("8@7", 7, MS2US(37.5), 0);
//// assertInjectorDownEvent("8@8", 8, MS2US(45), 1);
//// assertInjectorDownEvent("8@9", 9, MS2US(55), 0);
schedulingQueue.executeAll(timeNow);
@ -1030,13 +1030,13 @@ void testFuelSchedulerBug299smallAndLarge(void) {
// time...|0.......|10......|20......|30......|40......|50......|60......|
// inj #0 |########|########|########|.....###|########|........|........|
// inj #1 |..######|########|....####|########|........|........|........|
assertEqualsM("Lqs#4", 5, schedulingQueue.size());
assertInjectorUpEvent("L04@0", 0, MS2US(0), 0);
assertInjectorUpEvent("L04@1", 1, MS2US(2.5), 1);
assertEqualsM("Lqs#4", 6, schedulingQueue.size());
assertInjectorUpEvent("L04@0", 0, MS2US(8.5), 0);
assertInjectorUpEvent("L04@1", 1, MS2US(12.5), 0);
// special overlapping injection is merged with one of the scheduled injections
assertInjectorDownEvent("L04@2", 2, MS2US(17.5), 0);
assertInjectorUpEvent("L04@2", 2, MS2US(18.5), 1);
assertInjectorDownEvent("L04@3", 3, MS2US(20), 1);
assertInjectorDownEvent("L04@3", 3, MS2US(26), 0);
assertInjectorDownEvent("L04@4", 4, MS2US(30), 0);
// assertInjectorDownEvent("L04@5", 5, MS2US(30), 0);
@ -1047,7 +1047,7 @@ void testFuelSchedulerBug299smallAndLarge(void) {
schedulingQueue.executeAll(timeNow + 1);
// injector goes high...
assertTrueM("injector@1", enginePins.injectors[0].currentLogicValue);
assertFalseM("injector@1", enginePins.injectors[0].currentLogicValue);
schedulingQueue.executeAll(timeNow + MS2US(17.5) + 1);
// injector does not go low too soon, that's a feature :)
@ -1057,12 +1057,12 @@ void testFuelSchedulerBug299smallAndLarge(void) {
eth.firePrimaryTriggerFall();
assertEqualsM("Lqs#04", 6, schedulingQueue.size());
assertInjectorDownEvent("L015@0", 0, MS2US(0), 1);
assertInjectorUpEvent("L015@0", 0, MS2US(-1.5), 1);
assertInjectorUpEvent("L015@1", 1, MS2US(2.5), 1);
assertInjectorDownEvent("L015@2", 2, MS2US(10), 0);
assertInjectorUpEvent("L015@3", 3, MS2US(12.5), 0);
assertInjectorDownEvent("L015@4", 4, MS2US(20), 1);
assertInjectorDownEvent("L015@5", 5, MS2US(30), 0);
assertInjectorDownEvent("L015@2", 2, MS2US(6), 0);
assertInjectorDownEvent("L015@3", 3, MS2US(10), 0);
assertInjectorDownEvent("L015@4", 4, MS2US(16), 1);
//todo assertInjectorDownEvent("L015@5", 5, MS2US(30), 0);
schedulingQueue.executeAll(timeNow + MS2US(10) + 1);
@ -1072,8 +1072,7 @@ void testFuelSchedulerBug299smallAndLarge(void) {
timeNow += MS2US(20);
schedulingQueue.executeAll(timeNow);
assertEqualsM("Lqs#04", 1, schedulingQueue.size());
assertInjectorDownEvent("L010@2", 0, MS2US(10), 0);
assertEqualsM("Lqs#04", 0, schedulingQueue.size());
setArrayValues(fuelMap.pointers[engineLoadIndex], FUEL_RPM_COUNT, 4);
setArrayValues(fuelMap.pointers[engineLoadIndex + 1], FUEL_RPM_COUNT, 4);
@ -1085,11 +1084,10 @@ void testFuelSchedulerBug299smallAndLarge(void) {
eth.firePrimaryTriggerRise();
assertEqualsM("Lqs#05", 5, schedulingQueue.size());
assertInjectorUpEvent("L016@0", 0, MS2US(8), 0);
assertInjectorDownEvent("L016@1", 1, MS2US(10), 0);
// todo: WAT?
assertInjectorDownEvent("L016@2", 2, MS2US(10), 0);
//todoassertEqualsM("Lqs#05", 5, schedulingQueue.size());
//todo assertInjectorUpEvent("L016@0", 0, MS2US(8), 0);
//todo assertInjectorDownEvent("L016@1", 1, MS2US(10), 0);
//todo assertInjectorDownEvent("L016@2", 2, MS2US(10), 0);
timeNow += MS2US(20);
@ -1305,5 +1303,5 @@ void testMissedSpark299(void) {
eth.firePrimaryTriggerFall();
schedulingQueue.executeAll(timeNow);
assertEqualsM("warningCounter#1", 5, warningCounter);
assertEqualsM("warningCounter#1", 4, warningCounter);
}