fome-fw/unit_tests/tests/trigger/test_real_nb2_cranking.cpp

59 lines
2.0 KiB
C++
Raw Normal View History

/*
* @file test_real_nb2_cranking.cpp
*
* @date July 13, 2019
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#include "pch.h"
#include "logicdata_csv_reader.h"
2021-07-21 14:48:37 -07:00
TEST(realCrankingNB2, normalCranking) {
CsvReader reader(1, /* vvtCount */ 1);
2022-09-24 12:33:01 -07:00
reader.open("tests/trigger/resources/nb2-cranking-good.csv", SINGLE_TRIGGER_FIRST);
EngineTestHelper eth (HELLEN_NB2);
engineConfiguration->alwaysInstantRpm = true;
2021-07-21 14:48:37 -07:00
while (reader.haveMore()) {
reader.processLine(&eth);
}
2021-07-21 14:48:37 -07:00
// VVT position nearly zero!
EXPECT_NEAR(engine->triggerCentral.getVVTPosition(0, 0), 4.2627f, 1e-4);
2021-07-21 14:48:37 -07:00
// Check the number of times VVT information was used to adjust crank phase
// This should happen exactly once: once we sync, we shouldn't lose it.
2022-08-09 17:32:39 -07:00
EXPECT_EQ(engine->triggerCentral.triggerState.camResyncCounter, 2);
ASSERT_EQ(876, round(Sensor::getOrZero(SensorType::Rpm)));
2021-07-21 14:48:37 -07:00
EXPECT_EQ(3, eth.recentWarnings()->getCount());
EXPECT_EQ(CUSTOM_OUT_OF_ORDER_COIL, eth.recentWarnings()->get(0).Code);
EXPECT_EQ(CUSTOM_CAM_TOO_MANY_TEETH, eth.recentWarnings()->get(1).Code);
EXPECT_EQ(CUSTOM_PRIMARY_NOT_ENOUGH_TEETH, eth.recentWarnings()->get(2).Code);
2021-07-21 14:48:37 -07:00
}
TEST(realCrankingNB2, crankingMissingInjector) {
CsvReader reader(1, /* vvtCount */ 1);
2022-09-24 12:33:01 -07:00
reader.open("tests/trigger/resources/nb2-cranking-good-missing-injector-1.csv", SINGLE_TRIGGER_FIRST);
EngineTestHelper eth (HELLEN_NB2);
engineConfiguration->alwaysInstantRpm = true;
2021-07-21 14:48:37 -07:00
while (reader.haveMore()) {
reader.processLine(&eth);
}
2021-07-21 14:48:37 -07:00
// VVT position nearly zero!
EXPECT_NEAR(engine->triggerCentral.getVVTPosition(0, 0), -2.5231f, 1e-4);
ASSERT_EQ(316, round(Sensor::getOrZero(SensorType::Rpm)));
EXPECT_EQ(4, eth.recentWarnings()->getCount());
EXPECT_EQ(CUSTOM_OUT_OF_ORDER_COIL, eth.recentWarnings()->get(0).Code);
EXPECT_EQ(CUSTOM_CAM_TOO_MANY_TEETH, eth.recentWarnings()->get(1).Code);
EXPECT_EQ(CUSTOM_PRIMARY_NOT_ENOUGH_TEETH, eth.recentWarnings()->get(2).Code);
EXPECT_EQ(CUSTOM_PRIMARY_TOO_MANY_TEETH, eth.recentWarnings()->get(3).Code);
}