2021-07-13 11:24:47 -07:00
|
|
|
/*
|
|
|
|
* @file test_real_nb2_cranking.cpp
|
|
|
|
*
|
|
|
|
* @date July 13, 2019
|
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
|
|
|
*/
|
|
|
|
|
2021-08-03 19:05:01 -07:00
|
|
|
#include "pch.h"
|
2021-07-13 11:24:47 -07:00
|
|
|
#include "logicdata_csv_reader.h"
|
|
|
|
|
2021-07-21 14:48:37 -07:00
|
|
|
TEST(realCrankingNB2, normalCranking) {
|
2021-07-13 11:39:21 -07:00
|
|
|
CsvReader reader(1, /* vvtCount */ 1);
|
|
|
|
|
2022-09-24 20:01:42 -07:00
|
|
|
reader.open("tests/trigger/resources/nb2-cranking-good.csv");
|
2024-03-05 19:29:49 -08:00
|
|
|
EngineTestHelper eth (engine_type_e::MAZDA_MIATA_NB2);
|
2022-08-19 12:03:20 -07:00
|
|
|
engineConfiguration->alwaysInstantRpm = true;
|
2021-07-13 11:39:21 -07:00
|
|
|
|
2021-07-21 14:48:37 -07:00
|
|
|
while (reader.haveMore()) {
|
|
|
|
reader.processLine(ð);
|
2021-07-13 11:39:21 -07:00
|
|
|
}
|
2021-07-13 15:15:22 -07:00
|
|
|
|
2021-07-21 14:48:37 -07:00
|
|
|
// VVT position nearly zero!
|
2022-08-19 12:03:20 -07:00
|
|
|
EXPECT_NEAR(engine->triggerCentral.getVVTPosition(0, 0), 4.2627f, 1e-4);
|
2021-07-21 14:48:37 -07:00
|
|
|
|
2021-12-30 08:39:04 -08:00
|
|
|
// Check the number of times VVT information was used to adjust crank phase
|
2021-12-31 12:47:25 -08:00
|
|
|
// 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);
|
2021-12-30 08:39:04 -08:00
|
|
|
|
2022-08-19 12:03:20 -07:00
|
|
|
ASSERT_EQ(876, round(Sensor::getOrZero(SensorType::Rpm)));
|
2021-07-21 14:48:37 -07:00
|
|
|
|
2023-01-10 16:07:44 -08:00
|
|
|
EXPECT_EQ(2, eth.recentWarnings()->getCount());
|
2023-04-11 17:01:34 -07:00
|
|
|
EXPECT_EQ(ObdCode::CUSTOM_PRIMARY_NOT_ENOUGH_TEETH, eth.recentWarnings()->get(0).Code);
|
|
|
|
EXPECT_EQ(ObdCode::CUSTOM_CAM_TOO_MANY_TEETH, eth.recentWarnings()->get(1).Code);
|
2021-07-21 14:48:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(realCrankingNB2, crankingMissingInjector) {
|
|
|
|
CsvReader reader(1, /* vvtCount */ 1);
|
|
|
|
|
2022-09-24 20:01:42 -07:00
|
|
|
reader.open("tests/trigger/resources/nb2-cranking-good-missing-injector-1.csv");
|
2024-03-05 19:29:49 -08:00
|
|
|
EngineTestHelper eth (engine_type_e::MAZDA_MIATA_NB2);
|
2022-08-19 12:03:20 -07:00
|
|
|
engineConfiguration->alwaysInstantRpm = true;
|
2021-07-21 14:48:37 -07:00
|
|
|
|
2021-07-13 15:15:22 -07:00
|
|
|
while (reader.haveMore()) {
|
|
|
|
reader.processLine(ð);
|
|
|
|
}
|
|
|
|
|
2021-07-21 14:48:37 -07:00
|
|
|
// VVT position nearly zero!
|
2022-08-19 12:03:20 -07:00
|
|
|
EXPECT_NEAR(engine->triggerCentral.getVVTPosition(0, 0), -2.5231f, 1e-4);
|
2021-07-13 11:24:47 -07:00
|
|
|
|
2022-08-19 12:03:20 -07:00
|
|
|
ASSERT_EQ(316, round(Sensor::getOrZero(SensorType::Rpm)));
|
2021-07-13 11:24:47 -07:00
|
|
|
|
2023-01-10 16:07:44 -08:00
|
|
|
EXPECT_EQ(3, eth.recentWarnings()->getCount());
|
2023-04-11 17:01:34 -07:00
|
|
|
EXPECT_EQ(ObdCode::CUSTOM_PRIMARY_NOT_ENOUGH_TEETH, eth.recentWarnings()->get(0).Code);
|
|
|
|
EXPECT_EQ(ObdCode::CUSTOM_CAM_TOO_MANY_TEETH, eth.recentWarnings()->get(1).Code);
|
|
|
|
EXPECT_EQ(ObdCode::CUSTOM_PRIMARY_TOO_MANY_TEETH, eth.recentWarnings()->get(2).Code);
|
2021-07-13 11:24:47 -07:00
|
|
|
}
|