2018-03-04 13:13:23 -08:00
|
|
|
/*
|
|
|
|
* test_startOfCrankingPrimingPulse.cpp
|
|
|
|
*
|
|
|
|
* Created on: Mar 4, 2018
|
2020-01-13 18:57:43 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2018-03-04 13:13:23 -08:00
|
|
|
*/
|
|
|
|
|
2021-08-03 19:05:01 -07:00
|
|
|
#include "pch.h"
|
2018-03-04 20:32:25 -08:00
|
|
|
|
2019-01-13 19:15:21 -08:00
|
|
|
TEST(engine, testPlainCrankingWithoutAdvancedFeatures) {
|
2021-11-16 13:52:11 -08:00
|
|
|
EngineTestHelper eth(TEST_ENGINE);
|
2018-03-04 13:13:23 -08:00
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
engine->tdcMarkEnabled = false;
|
2020-11-03 11:12:26 -08:00
|
|
|
engineConfiguration->cranking.baseFuel = 12;
|
|
|
|
|
2018-03-04 13:30:03 -08:00
|
|
|
setupSimpleTestEngineWithMafAndTT_ONE_trigger(ð);
|
2019-01-21 18:48:58 -08:00
|
|
|
ASSERT_EQ( 0, GET_RPM()) << "RPM=0";
|
2018-03-04 13:13:23 -08:00
|
|
|
|
2019-01-10 22:18:35 -08:00
|
|
|
eth.fireTriggerEventsWithDuration(/* durationMs */ 200);
|
2018-03-04 15:12:52 -08:00
|
|
|
// still no RPM since need to cycles measure cycle duration
|
2019-01-21 18:48:58 -08:00
|
|
|
ASSERT_EQ( 0, GET_RPM()) << "start-RPM#1";
|
2018-03-04 20:32:25 -08:00
|
|
|
|
2018-07-28 16:51:41 -07:00
|
|
|
|
2019-01-10 22:18:35 -08:00
|
|
|
eth.fireRise(/* delayMs */ 200);
|
2019-01-21 18:48:58 -08:00
|
|
|
ASSERT_EQ( 300, GET_RPM()) << "RPM#2";
|
2018-03-04 20:32:25 -08:00
|
|
|
// two simultaneous injections
|
2019-01-14 15:38:20 -08:00
|
|
|
ASSERT_EQ( 4, engine->executor.size()) << "plain#2";
|
2018-03-04 13:13:23 -08:00
|
|
|
|
2021-06-01 22:21:36 -07:00
|
|
|
eth.assertEvent5("sim start", 0, (void*)startSimultaniousInjection, 100000 - 1625);
|
2020-10-26 04:23:13 -07:00
|
|
|
// -1 because ugh floating point math
|
|
|
|
eth.assertEvent5("sim end", 1, (void*)endSimultaniousInjection, 100000 - 1);
|
2018-03-04 13:13:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-08 13:20:19 -08:00
|
|
|
TEST(priming, startScheduling) {
|
2021-11-16 13:52:11 -08:00
|
|
|
EngineTestHelper eth(TEST_ENGINE);
|
2018-03-04 20:32:25 -08:00
|
|
|
|
2019-01-21 18:48:58 -08:00
|
|
|
ASSERT_EQ( 0, GET_RPM()) << "RPM=0";
|
2018-03-04 20:53:48 -08:00
|
|
|
|
2021-12-08 04:26:49 -08:00
|
|
|
// Turn on the ignition switch!
|
|
|
|
engine->module<PrimeController>()->onIgnitionStateChanged(true);
|
2018-03-04 20:53:48 -08:00
|
|
|
|
2021-12-08 13:20:19 -08:00
|
|
|
ASSERT_EQ(1, engine->executor.size()) << "prime fuel";
|
2018-03-04 13:13:23 -08:00
|
|
|
}
|
|
|
|
|
2021-12-08 13:20:19 -08:00
|
|
|
TEST(priming, duration) {
|
|
|
|
EngineTestHelper eth(TEST_ENGINE);
|
|
|
|
|
|
|
|
MockInjectorModel2 injectorModel;
|
|
|
|
engine->module<InjectorModel>().set(&injectorModel);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < efi::size(engineConfiguration->primeBins); i++) {
|
|
|
|
engineConfiguration->primeBins[i] = i * 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPECT_CALL(injectorModel, getInjectionDuration(0.075f)).WillOnce(Return(20.0f));
|
|
|
|
engineConfiguration->primeValues[5] = 75; // <-- We test this point
|
|
|
|
|
|
|
|
// With coolant temp, we should see value from mock
|
|
|
|
Sensor::setMockValue(SensorType::Clt, 50);
|
|
|
|
EXPECT_EQ(20, engine->module<PrimeController>()->getPrimeDuration());
|
|
|
|
|
|
|
|
// Without coolant temp, no prime
|
|
|
|
Sensor::resetMockValue(SensorType::Clt);
|
|
|
|
EXPECT_EQ(0, engine->module<PrimeController>()->getPrimeDuration());
|
|
|
|
}
|