From bcc6c63046710d6c1c9ad64f29dd6a875b914e7c Mon Sep 17 00:00:00 2001 From: rusefi Date: Tue, 9 Feb 2021 10:16:49 -0500 Subject: [PATCH] second bank vvt decoder unit test --- unit_tests/tests/trigger/test_quad_cam.cpp | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/unit_tests/tests/trigger/test_quad_cam.cpp b/unit_tests/tests/trigger/test_quad_cam.cpp index d7f0175a09..1a7f2a09d0 100644 --- a/unit_tests/tests/trigger/test_quad_cam.cpp +++ b/unit_tests/tests/trigger/test_quad_cam.cpp @@ -64,4 +64,29 @@ TEST(trigger, testQuadCam) { // actually position based on VVT! ASSERT_EQ(totalRevolutionCountBeforeVvtSync, engine->triggerCentral.triggerState.getTotalRevolutionCounter()); + + int secondCamSecondBank = 3; + int secondBank = 1; + + // this would be ignored since we only consume the other kind of fronts here + hwHandleVvtCamSignal(TV_FALL, getTimeNowNt(), secondCamSecondBank PASS_ENGINE_PARAMETER_SUFFIX); + eth.moveTimeForwardUs(MS2US(20 / d)); + // this would be be first VVT signal - gap duration would be calculated against 'DEEP_IN_THE_PAST_SECONDS' initial value + hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), secondCamSecondBank PASS_ENGINE_PARAMETER_SUFFIX); + + eth.moveTimeForwardUs(MS2US(20 / d)); + // this second important front would give us first real VVT gap duration + hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), secondCamSecondBank PASS_ENGINE_PARAMETER_SUFFIX); + + ASSERT_FLOAT_EQ(0, engine->triggerCentral.getVVTPosition()); + ASSERT_EQ(totalRevolutionCountBeforeVvtSync, engine->triggerCentral.triggerState.getTotalRevolutionCounter()); + + eth.moveTimeForwardUs(MS2US(130 / d)); + // this third important front would give us first comparison between two real gaps + hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), secondCamSecondBank PASS_ENGINE_PARAMETER_SUFFIX); + + ASSERT_NEAR(-2571.4, engine->triggerCentral.vvtPosition[secondBank][secondCam], EPS3D); + // actually position based on VVT! + ASSERT_EQ(totalRevolutionCountBeforeVvtSync, engine->triggerCentral.triggerState.getTotalRevolutionCounter()); + }