From 77c55b9f889a4d7568059f16d1aeb3a7eb0c861e Mon Sep 17 00:00:00 2001 From: Andrey Date: Sun, 11 Jun 2023 18:39:03 -0400 Subject: [PATCH] Dashpot for return-to-idle from coasting #5303 third step towards unit test --- firmware/controllers/actuators/idle_thread.cpp | 2 +- unit_tests/tests/test_idle_controller.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/firmware/controllers/actuators/idle_thread.cpp b/firmware/controllers/actuators/idle_thread.cpp index 9f0b208309..b8e68a6b7f 100644 --- a/firmware/controllers/actuators/idle_thread.cpp +++ b/firmware/controllers/actuators/idle_thread.cpp @@ -148,7 +148,7 @@ percent_t IdleController::getOpenLoop(Phase phase, float rpm, float clt, SensorR return interpolate2d(rpm, config->iacCoastingRpmBins, config->iacCoasting); } - percent_t running = getRunningOpenLoop(IIdleController::Phase::Cranking, rpm, clt, tps); + percent_t running = getRunningOpenLoop(phase, rpm, clt, tps); // Interpolate between cranking and running over a short time // This clamps once you fall off the end, so no explicit check for >1 required diff --git a/unit_tests/tests/test_idle_controller.cpp b/unit_tests/tests/test_idle_controller.cpp index 17c01e9b43..3143909745 100644 --- a/unit_tests/tests/test_idle_controller.cpp +++ b/unit_tests/tests/test_idle_controller.cpp @@ -251,7 +251,8 @@ TEST(idle_v2, openLoopRunningTaper) { EngineTestHelper eth(engine_type_e::TEST_ENGINE); StrictMock dut; - EXPECT_CALL(dut, getRunningOpenLoop(IIdleController::Phase::Cranking, 0, 30, SensorResult(0))).WillRepeatedly(Return(25)); + EXPECT_CALL(dut, getRunningOpenLoop(IIdleController::Phase::CrankToIdleTaper, 0, 30, SensorResult(0))).WillRepeatedly(Return(25)); + EXPECT_CALL(dut, getRunningOpenLoop(IIdleController::Phase::Running, 0, 30, SensorResult(0))).WillRepeatedly(Return(25)); EXPECT_CALL(dut, getCrankingOpenLoop(30)).WillRepeatedly(Return(75)); // 0 cycles - no taper yet, pure cranking value