2019-01-13 19:52:22 -08:00
|
|
|
/*
|
|
|
|
* test_cam_vtt_input.cpp
|
|
|
|
*
|
|
|
|
* Created on: Jan 13, 2019
|
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2019
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "engine_test_helper.h"
|
2019-05-10 19:55:08 -07:00
|
|
|
extern WarningCodeState unitTestWarningCodeState;
|
|
|
|
|
|
|
|
TEST(sensors, testNoStartUpWarningsNoSyncronizationTrigger) {
|
|
|
|
WITH_ENGINE_TEST_HELPER(TEST_ENGINE);
|
|
|
|
// one tooth does not need synchronization it just counts tooth
|
|
|
|
eth.setTriggerType(TT_ONE PASS_ENGINE_PARAMETER_SUFFIX);
|
|
|
|
ASSERT_EQ( 0, GET_RPM()) << "testNoStartUpWarnings RPM";
|
|
|
|
|
|
|
|
eth.fireTriggerEvents2(/*count*/10, /*duration*/50);
|
|
|
|
ASSERT_EQ(1200, GET_RPM()) << "testNoStartUpWarnings RPM";
|
|
|
|
ASSERT_EQ( 0, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#testNoStartUpWarningsNoSyncronizationTrigger";
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(sensors, testNoStartUpWarnings) {
|
|
|
|
WITH_ENGINE_TEST_HELPER(TEST_ENGINE);
|
|
|
|
eth.setTriggerType(TT_ONE PASS_ENGINE_PARAMETER_SUFFIX);
|
|
|
|
ASSERT_EQ( 0, GET_RPM()) << "testNoStartUpWarnings RPM";
|
|
|
|
|
|
|
|
// for this test we need a trigger with isSynchronizationNeeded=true
|
|
|
|
|
|
|
|
eth.fireTriggerEvents2(/*count*/10, /*duration*/50);
|
|
|
|
ASSERT_EQ(1200, GET_RPM()) << "testNoStartUpWarnings RPM";
|
|
|
|
ASSERT_EQ( 0, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#testNoStartUpWarnings";
|
|
|
|
// now let's post invalid shape
|
|
|
|
eth.fireRise(50);
|
|
|
|
eth.fireRise(50);
|
|
|
|
eth.fireRise(50);
|
|
|
|
eth.fireRise(50);
|
|
|
|
ASSERT_EQ( 0, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#testNoStartUpWarnings CUSTOM_SYNC_COUNT_MISMATCH expected";
|
|
|
|
// ASSERT_EQ(CUSTOM_SYNC_COUNT_MISMATCH, unitTestWarningCodeState.recentWarnings.get(0));
|
|
|
|
}
|
|
|
|
|
2019-01-13 19:52:22 -08:00
|
|
|
|
|
|
|
TEST(sensors, testCamInput) {
|
2019-05-10 18:56:33 -07:00
|
|
|
// setting some weird engine
|
|
|
|
WITH_ENGINE_TEST_HELPER(FORD_ESCORT_GT);
|
2019-01-13 19:52:22 -08:00
|
|
|
|
2019-05-10 18:56:33 -07:00
|
|
|
// and now changing to ONE trigger on CRANK with CAM/VVT
|
2019-01-13 19:52:22 -08:00
|
|
|
|
2019-05-10 18:56:33 -07:00
|
|
|
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);
|
|
|
|
eth.setTriggerType(TT_ONE PASS_ENGINE_PARAMETER_SUFFIX);
|
|
|
|
engineConfiguration->useOnlyRisingEdgeForTrigger = true;
|
|
|
|
engineConfiguration->camInput = GPIOA_10;
|
|
|
|
|
|
|
|
ASSERT_EQ( 0, GET_RPM()) << "testCamInput RPM";
|
|
|
|
|
|
|
|
eth.firePrimaryTriggerRise();
|
2019-05-10 19:55:08 -07:00
|
|
|
eth.firePrimaryTriggerFall();
|
2019-05-10 18:56:33 -07:00
|
|
|
eth.firePrimaryTriggerRise();
|
2019-05-10 19:55:08 -07:00
|
|
|
eth.firePrimaryTriggerFall();
|
2019-05-10 18:56:33 -07:00
|
|
|
eth.firePrimaryTriggerRise();
|
2019-05-10 19:55:08 -07:00
|
|
|
eth.firePrimaryTriggerFall();
|
2019-05-10 18:56:33 -07:00
|
|
|
eth.firePrimaryTriggerRise();
|
2019-05-10 19:55:08 -07:00
|
|
|
eth.firePrimaryTriggerFall();
|
|
|
|
// error condition since events happened too quick while time does not move
|
2019-05-10 18:56:33 -07:00
|
|
|
ASSERT_EQ(NOISY_RPM, GET_RPM()) << "testCamInput RPM should be noisy";
|
|
|
|
|
2019-05-10 19:55:08 -07:00
|
|
|
// todo: open question what are these warnings about?
|
|
|
|
ASSERT_EQ( 2, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#testCamInput";
|
|
|
|
unitTestWarningCodeState.recentWarnings.clear();
|
2019-05-10 18:56:33 -07:00
|
|
|
|
|
|
|
eth.fireRise(50);
|
|
|
|
eth.fireRise(50);
|
|
|
|
eth.fireRise(50);
|
|
|
|
eth.fireRise(50);
|
|
|
|
eth.fireRise(50);
|
|
|
|
ASSERT_EQ(1200, GET_RPM()) << "testCamInput RPM";
|
2019-05-10 19:55:08 -07:00
|
|
|
ASSERT_EQ(2, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#testCamInput";
|
|
|
|
|
|
|
|
for (int i = 0; i < 100;i++)
|
|
|
|
eth.fireRise(50);
|
|
|
|
|
2019-01-13 19:52:22 -08:00
|
|
|
}
|