2018-03-04 13:13:23 -08:00
|
|
|
/*
|
|
|
|
* test_startOfCrankingPrimingPulse.cpp
|
|
|
|
*
|
|
|
|
* Created on: Mar 4, 2018
|
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2018
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "test_startOfCrankingPrimingPulse.h"
|
|
|
|
#include "test_trigger_decoder.h"
|
2018-03-04 20:32:25 -08:00
|
|
|
#include "event_queue.h"
|
|
|
|
#include "unit_test_framework.h"
|
|
|
|
|
|
|
|
extern EventQueue schedulingQueue;
|
|
|
|
extern int timeNowUs;
|
|
|
|
extern EnginePins enginePins;
|
2018-03-04 13:13:23 -08:00
|
|
|
|
|
|
|
void testPlainCrankingWithoutAdvancedFeatures() {
|
|
|
|
// this is just a reference unit test implementation
|
|
|
|
printf("*************************************************** testPlainCrankingWithoutAdvancedFeatures\r\n");
|
|
|
|
|
|
|
|
EngineTestHelper eth(TEST_ENGINE);
|
|
|
|
EXPAND_EngineTestHelper
|
|
|
|
|
2018-03-04 13:30:03 -08:00
|
|
|
setupSimpleTestEngineWithMafAndTT_ONE_trigger(ð);
|
2018-03-04 13:13:23 -08:00
|
|
|
assertEqualsM("RPM=0", 0, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
|
|
|
|
|
2018-07-28 16:37:10 -07:00
|
|
|
eth.fireTriggerEventsWithDuration(200);
|
2018-03-04 15:12:52 -08:00
|
|
|
// still no RPM since need to cycles measure cycle duration
|
|
|
|
assertEqualsM("RPM#1", 0, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
|
2018-03-04 20:32:25 -08:00
|
|
|
|
2018-07-28 16:51:41 -07:00
|
|
|
|
|
|
|
eth.fireRise(200);
|
2018-03-04 15:12:52 -08:00
|
|
|
assertEqualsM("RPM#2", 300, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
|
2018-03-04 20:32:25 -08:00
|
|
|
// two simultaneous injections
|
|
|
|
assertEqualsM("plain#2", 4, schedulingQueue.size());
|
2018-03-04 13:13:23 -08:00
|
|
|
|
2018-03-04 20:53:48 -08:00
|
|
|
assertEvent5("sim start", 0, (void*)startSimultaniousInjection, timeNowUs, 97975);
|
|
|
|
assertEvent5("sim end", 1, (void*)endSimultaniousInjection, timeNowUs, 100000);
|
2018-03-04 13:13:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void testStartOfCrankingPrimingPulse() {
|
2018-03-04 20:32:25 -08:00
|
|
|
printf("*************************************************** testStartOfCrankingPrimingPulse\r\n");
|
2018-03-04 13:13:23 -08:00
|
|
|
|
2018-03-04 20:32:25 -08:00
|
|
|
EngineTestHelper eth(TEST_ENGINE);
|
|
|
|
EXPAND_EngineTestHelper
|
|
|
|
|
|
|
|
engineConfiguration->startOfCrankingPrimingPulse = 4;
|
|
|
|
|
|
|
|
setupSimpleTestEngineWithMafAndTT_ONE_trigger(ð);
|
|
|
|
assertEqualsM("RPM=0", 0, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
|
2018-03-04 20:53:48 -08:00
|
|
|
|
2018-03-05 05:25:20 -08:00
|
|
|
// this -70 value comes from CLT error handling code
|
|
|
|
assertEqualsM("CLT#1", 70, engine->sensors.clt);
|
|
|
|
|
|
|
|
// we need below freezing temperature to get prime fuel
|
|
|
|
// todo: less cruel CLT value assignment which would survive 'updateSlowSensors'
|
|
|
|
engine->sensors.clt = -10;
|
|
|
|
// this is needed to update injectorLag
|
|
|
|
// engine->updateSlowSensors(PASS_ENGINE_PARAMETER_SIGNATURE);
|
|
|
|
// assertEqualsM("CLT#2", -10, engine->sensors.clt);
|
|
|
|
|
|
|
|
|
2018-03-04 20:53:48 -08:00
|
|
|
// prod code invokes this on ECU start, here we have to mimic this behavior
|
|
|
|
startPrimeInjectionPulse(PASS_ENGINE_PARAMETER_SIGNATURE);
|
|
|
|
|
|
|
|
|
2018-03-05 05:25:20 -08:00
|
|
|
assertEqualsM("prime fuel", 1, schedulingQueue.size());
|
2018-03-04 13:13:23 -08:00
|
|
|
}
|
|
|
|
|