From 545490b3e9b298315468e8301f310f46cbae6ab4 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Fri, 26 Aug 2016 20:03:06 -0400 Subject: [PATCH] auto-sync --- unit_tests/engine_test_helper.cpp | 10 ++++++++-- unit_tests/engine_test_helper.h | 5 ++++- unit_tests/test_speed_density.cpp | 2 +- unit_tests/test_trigger_decoder.cpp | 22 +++++++++++++--------- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/unit_tests/engine_test_helper.cpp b/unit_tests/engine_test_helper.cpp index 503dea33a0..f7238ab466 100644 --- a/unit_tests/engine_test_helper.cpp +++ b/unit_tests/engine_test_helper.cpp @@ -54,6 +54,13 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persiste // this is needed to have valid CLT and IAT. engine->updateSlowSensors(PASS_ENGINE_PARAMETER_F); prepareTimingMap(PASS_ENGINE_PARAMETER_F); + + triggerCallbackInstance.init(engine); + + engine_configuration_s *engineConfiguration = engine->engineConfiguration; + + engine->triggerShape.initializeTriggerShape(NULL PASS_ENGINE_PARAMETER); + engine->triggerCentral.addEventListener(rpmShaftPositionCallback, "rpm reporter", engine); } void EngineTestHelper::fireTriggerEvents2(int count, int duration) { @@ -70,7 +77,7 @@ void EngineTestHelper::fireTriggerEvents(int count) { fireTriggerEvents2(count, 5000); // 5ms } -void EngineTestHelper::initTriggerShapeAndRpmCalculator() { +void EngineTestHelper::applyTriggerShape() { Engine *engine = &this->engine; engine_configuration_s *engineConfiguration = engine->engineConfiguration; persistent_config_s *config = engine->config; @@ -80,6 +87,5 @@ void EngineTestHelper::initTriggerShapeAndRpmCalculator() { incrementGlobalConfigurationVersion(); - engine->triggerCentral.addEventListener(rpmShaftPositionCallback, "rpm reporter", engine); } diff --git a/unit_tests/engine_test_helper.h b/unit_tests/engine_test_helper.h index ea44b716ac..d7f99f282d 100644 --- a/unit_tests/engine_test_helper.h +++ b/unit_tests/engine_test_helper.h @@ -10,11 +10,12 @@ #include "engine.h" #include "trigger_central.h" #include "rpm_calculator.h" +#include "main_trigger_callback.h" class EngineTestHelper { public: EngineTestHelper(engine_type_e engineType); - void initTriggerShapeAndRpmCalculator(); + void applyTriggerShape(); void fireTriggerEvents(int count); void fireTriggerEvents2(int count, int duration); @@ -22,6 +23,8 @@ public: engine_configuration2_s ec2; Engine engine; + MainTriggerCallback triggerCallbackInstance; + engine_configuration_s *ec; engine_configuration_s *engineConfiguration; diff --git a/unit_tests/test_speed_density.cpp b/unit_tests/test_speed_density.cpp index ce59170876..7ded6b2ec1 100644 --- a/unit_tests/test_speed_density.cpp +++ b/unit_tests/test_speed_density.cpp @@ -16,7 +16,7 @@ void testSpeedDensity(void) { EXPAND_EngineTestHelper; eth.ec->trigger.customTotalToothCount = 8; - eth.initTriggerShapeAndRpmCalculator(); + eth.applyTriggerShape(); eth.fireTriggerEvents(36); assertEqualsM("RPM", 1500, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_F)); diff --git a/unit_tests/test_trigger_decoder.cpp b/unit_tests/test_trigger_decoder.cpp index 253fe8491e..7df112f3ea 100644 --- a/unit_tests/test_trigger_decoder.cpp +++ b/unit_tests/test_trigger_decoder.cpp @@ -139,7 +139,7 @@ void test1995FordInline6TriggerDecoder(void) { findTriggerPosition(&position, 360 PASS_ENGINE_PARAMETER); assertTriggerPosition(&position, 6, 0); - eth.initTriggerShapeAndRpmCalculator(); + eth.applyTriggerShape(); eth.engine.triggerCentral.addEventListener(mainTriggerCallback, "main loop", ð.engine); eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_F); @@ -291,7 +291,6 @@ extern engine_pins_s enginePins; void testRpmCalculator(void) { printf("*************************************************** testRpmCalculator\r\n"); timeNow = 0; - schedulingQueue.clear(); EngineTestHelper eth(FORD_INLINE_6_1995); EXPAND_EngineTestHelper; @@ -304,7 +303,7 @@ void testRpmCalculator(void) { engineConfiguration->trigger.customTotalToothCount = 8; engineConfiguration->globalFuelCorrection = 3; - eth.initTriggerShapeAndRpmCalculator(); + eth.applyTriggerShape(); setInjectorLag(0 PASS_ENGINE_PARAMETER); @@ -320,10 +319,9 @@ void testRpmCalculator(void) { assertEqualsM("RPM", 1500, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_F)); assertEqualsM("index #1", 15, eth.engine.triggerCentral.triggerState.getCurrentIndex()); - static MainTriggerCallback triggerCallbackInstance; - triggerCallbackInstance.init(ð.engine); eth.engine.triggerCentral.addEventListener(mainTriggerCallback, "main loop", ð.engine); + schedulingQueue.clear(); assertEqualsM("queue size/0", 0, schedulingQueue.size()); debugSignalExecutor = true; @@ -584,6 +582,7 @@ void testFuelSchedulerBug299(void) { printf("*************************************************** testFuelSchedulerBug299\r\n"); EngineTestHelper eth(TEST_ENGINE); EXPAND_EngineTestHelper; + assertEquals(LM_PLAIN_MAF, engineConfiguration->algorithm); timeNow = 0; schedulingQueue.clear(); @@ -598,13 +597,20 @@ void testFuelSchedulerBug299(void) { engineConfiguration->trigger.type = TT_ONE; incrementGlobalConfigurationVersion(); - eth.initTriggerShapeAndRpmCalculator(); + eth.applyTriggerShape(); assertEqualsM("RPM=0", 0, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_F)); eth.fireTriggerEvents2(2, MS2US(20)); - assertEquals(LM_PLAIN_MAF, engineConfiguration->algorithm); + schedulingQueue.clear(); + eth.fireTriggerEvents2(2, MS2US(20)); + +// assertEqualsM("queue size 3", 6, schedulingQueue.size()); + +// assertEqualsM("ev 3", st + 13333 - 1515, schedulingQueue.getForUnitText(0)->momentX); +// assertEqualsM("ev 4", st + 13333 - 1515, schedulingQueue.getForUnitText(1)->momentX); +// assertEqualsM2("ev 5", st + 14277, schedulingQueue.getForUnitText(2)->momentX, 2); testMafValue = 0; assertEqualsM("maf", 0, getMaf(PASS_ENGINE_PARAMETER_F)); @@ -632,8 +638,6 @@ void testFuelSchedulerBug299(void) { assertEqualsM("fuel#2", 35, engine->fuelMs); assertEqualsM("duty for maf=3", 87.5, getInjectorDutyCycle(eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_F) PASS_ENGINE_PARAMETER)); - - unitTestValue = 0; testMafValue = 0; }