MAP phase sensing #3544

look new unit test!
This commit is contained in:
Andrey 2021-12-07 16:58:10 -05:00
parent 0ed46759f3
commit 6e49d66385
4 changed files with 2991 additions and 0 deletions

View File

@ -49,6 +49,8 @@ struct MapState {
}
bool isPeak(bool lookForLowPeak) {
if (mapBuffer.getCount() < MAP_CAM_BUFFER + 3)
return false;
if (lookForLowPeak) {
return previous < prevPrevious && previous <= current;
} else {

File diff suppressed because it is too large Load Diff

View File

@ -19,6 +19,7 @@ TESTS_SRC_CPP = \
tests/trigger/test_nissan_vq_vvt.cpp \
tests/trigger/test_override_gaps.cpp \
tests/trigger/test_injection_scheduling.cpp \
tests/trigger/test_instant_map.cpp \
tests/ignition_injection/injection_mode_transition.cpp \
tests/ignition_injection/test_startOfCrankingPrimingPulse.cpp \
tests/ignition_injection/test_multispark.cpp \

View File

@ -0,0 +1,53 @@
/*
* test_instant_map.cpp
*
* Created on: Nov 30, 2021
* @author Andrey Belomutskiy, (c) 2012-2021
*/
#include "pch.h"
static char buffer[255];
static FILE *fp;
static int m_lineIndex = -1;
bool haveMore() {
bool result = fgets(buffer, sizeof(buffer), fp) != nullptr;
m_lineIndex++;
if (m_lineIndex == 0) {
// skip header
return haveMore();
}
return result;
}
TEST(trigger, instantMap) {
const char s[2] = ",";
fp = fopen("tests/resources/instant_map.csv", "r");
ASSERT_TRUE(fp != nullptr);
MapState mapState;
EngineTestHelper eth(TEST_ENGINE);
while (haveMore()) {
strtok(buffer, s);
strtok(NULL, s);
char *map = strtok(NULL, s);
if (map == nullptr) {
break;
}
double mapValue = std::stod(map);
printf("map %f\n", mapValue);
if (m_lineIndex != 105 && m_lineIndex != 183 && m_lineIndex < 289) {
ASSERT_FALSE(mapState.isPeak(false)) << m_lineIndex << " " << mapValue;
}
mapState.add(mapValue);
}
ASSERT_TRUE(m_lineIndex > 10);
}