From f4eae9613ffd0a0d9427e2fa4a589460096432c7 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Mon, 29 Aug 2016 22:02:57 -0400 Subject: [PATCH] auto-sync --- firmware/controllers/algo/engine.h | 1 + firmware/controllers/algo/event_registry.h | 6 ++++- firmware/controllers/math/engine_math.cpp | 2 +- unit_tests/test_trigger_decoder.cpp | 28 +++++++++++++++++++--- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index ffd63f626a..127ffc3e7a 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -88,6 +88,7 @@ public: #endif OutputSignal fuelActuators[MAX_INJECTION_OUTPUT_COUNT]; + OutputSignal overlappingFuelActuator[MAX_NUMBER_OF_CYLINDERS]; float fsioLastValue[LE_COMMAND_COUNT]; diff --git a/firmware/controllers/algo/event_registry.h b/firmware/controllers/algo/event_registry.h index add6f4577f..77bda7ae3b 100644 --- a/firmware/controllers/algo/event_registry.h +++ b/firmware/controllers/algo/event_registry.h @@ -57,7 +57,11 @@ public: char *name; }; -#define MAX_INJECTION_OUTPUT_COUNT 45 +#define MAX_NUMBER_OF_CYLINDERS 12 +/** + * two wire batch mode would generate twice the number of cylinders events, that's the max + */ +#define MAX_INJECTION_OUTPUT_COUNT 2 * MAX_NUMBER_OF_CYLINDERS #define MAX_IGNITION_EVENT_COUNT 80 typedef ArrayList InjectionEventList; diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index d0c1c3d05a..2da7e77174 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -147,7 +147,7 @@ void FuelSchedule::registerInjectionEvent(int injectorIndex, float angle, // error already reported return; } - //ev-> + ev->isOverlapping = angle < 0; ev->injectorIndex = injectorIndex; ev->output = output; diff --git a/unit_tests/test_trigger_decoder.cpp b/unit_tests/test_trigger_decoder.cpp index 9bb03ff380..dd70eae435 100644 --- a/unit_tests/test_trigger_decoder.cpp +++ b/unit_tests/test_trigger_decoder.cpp @@ -758,8 +758,8 @@ void testFuelSchedulerBug299(void) { 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 |........|.......#|########|##.....#|########|##......|........| + // inj #0 |........|..######|########|..######|########|........|........| + // inj #1 |..######|########|..######|########|........|........|........| assertInjectorUpEvent("5@0", 0, MS2US(-17.5), 1); assertInjectorUpEvent("5@1", 1, MS2US(-7.5), 0); assertInjectorDownEvent("5@2", 2, MS2US(0), 1); @@ -781,11 +781,19 @@ void testFuelSchedulerBug299(void) { eth.firePrimaryTriggerRise(); assertEqualsM("qs#2", 8, schedulingQueue.size()); assertEqualsM("rev cnt6", 6, engine->rpmCalculator.getRevolutionCounter()); + // time...|-20.....|-10.....|0.......|10......|20......|30......|40......| + // inj #0 |########|..######|########|..######|........|........|........| + // inj #1 |..######|########|..######|########|........|........|........| assertInjectorUpEvent("6@0", 0, MS2US(-17.5), 1); assertInjectorDownEvent("6@1", 1, MS2US(-10.0), 0); assertInjectorUpEvent("6@2", 2, MS2US(-7.5), 0); + assertInjectorUpEvent("6@3", 3, MS2US(0), 1); + assertInjectorUpEvent("6@4", 4, MS2US(2.5), 1); + assertInjectorDownEvent("6@5", 5, MS2US(10.0), 0); + assertInjectorUpEvent("6@6", 6, MS2US(12.5), 0); + assertInjectorDownEvent("6@7", 7, MS2US(20.0), 1); - assertEqualsM("exec#6", 4, schedulingQueue.executeAll(timeNow)); + assertEqualsM("exec#7", 4, schedulingQueue.executeAll(timeNow)); timeNow += MS2US(20); @@ -793,6 +801,20 @@ void testFuelSchedulerBug299(void) { assertEqualsM("qs#3", 4, schedulingQueue.size()); assertEqualsM("rev cnt6", 6, engine->rpmCalculator.getRevolutionCounter()); + // time...|-20.....|-10.....|0.......|10......|20......|30......|40......| + // inj #0 |........|##......|........|........|........|........|........| + // inj #1 |..######|########|........|........|........|........|........| + assertInjectorUpEvent("7@0", 0, MS2US(-17.5), 1); + assertInjectorUpEvent("7@1", 1, MS2US(-10.0), 0); + assertInjectorDownEvent("7@2", 2, MS2US(-7.5), 0); + assertInjectorUpEvent("7@3", 3, MS2US(0), 1); + assertEqualsM("exec#6", 4, schedulingQueue.executeAll(timeNow)); + + + timeNow += MS2US(20); + eth.firePrimaryTriggerRise(); + assertEqualsM("qs#3", 8, schedulingQueue.size()); + unitTestValue = 0;