Trigger: warning code on normal engine start up #669
This commit is contained in:
parent
1c48a61339
commit
6ca965d246
|
@ -8,8 +8,10 @@
|
||||||
#include "engine_test_helper.h"
|
#include "engine_test_helper.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
static constexpr trigger_event_e riseEvents[] = { SHAFT_PRIMARY_RISING, SHAFT_SECONDARY_RISING, SHAFT_3RD_RISING };
|
static constexpr trigger_event_e riseEvents[] = { SHAFT_PRIMARY_RISING,
|
||||||
static constexpr trigger_event_e fallEvents[] = { SHAFT_PRIMARY_FALLING, SHAFT_SECONDARY_FALLING, SHAFT_3RD_FALLING };
|
SHAFT_SECONDARY_RISING, SHAFT_3RD_RISING };
|
||||||
|
static constexpr trigger_event_e fallEvents[] = { SHAFT_PRIMARY_FALLING,
|
||||||
|
SHAFT_SECONDARY_FALLING, SHAFT_3RD_FALLING };
|
||||||
|
|
||||||
static char* trim(char *str) {
|
static char* trim(char *str) {
|
||||||
while (str != nullptr && str[0] == ' ') {
|
while (str != nullptr && str[0] == ' ') {
|
||||||
|
@ -18,25 +20,35 @@ static char* trim(char*str) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(cranking, realCrankingFromFile) {
|
class CsvReader {
|
||||||
FILE *fp = fopen("tests/trigger/recourses/cranking_na_3.csv", "r");
|
public:
|
||||||
ASSERT_TRUE(fp != nullptr);
|
FILE *fp;
|
||||||
|
|
||||||
WITH_ENGINE_TEST_HELPER(MIATA_NA6_MAP);
|
|
||||||
|
|
||||||
ssize_t read;
|
|
||||||
|
|
||||||
char buffer[255];
|
char buffer[255];
|
||||||
|
|
||||||
bool currentState[2];
|
bool currentState[2];
|
||||||
|
|
||||||
int index = -1;
|
int lineIndex = -1;
|
||||||
while (fgets(buffer, sizeof(buffer), fp)) {
|
|
||||||
index++;
|
void open(char *fileName) {
|
||||||
if (index == 0) {
|
fp = fopen(fileName, "r");
|
||||||
// skip header
|
ASSERT_TRUE(fp != nullptr);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool haveMore() {
|
||||||
|
bool result = fgets(buffer, sizeof(buffer), fp) != nullptr;
|
||||||
|
lineIndex++;
|
||||||
|
if (lineIndex == 0) {
|
||||||
|
// skip header
|
||||||
|
return haveMore();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void processLine(EngineTestHelper *eth) {
|
||||||
|
Engine *engine = ð->engine;
|
||||||
|
EXPAND_Engine
|
||||||
|
|
||||||
const char s[2] = ",";
|
const char s[2] = ",";
|
||||||
char *line = buffer;
|
char *line = buffer;
|
||||||
|
|
||||||
|
@ -47,19 +59,54 @@ TEST(cranking, realCrankingFromFile) {
|
||||||
|
|
||||||
double timeStamp = std::stod(timeStampstr);
|
double timeStamp = std::stod(timeStampstr);
|
||||||
|
|
||||||
eth.setTimeAndInvokeEventsUs(1'000'000 * timeStamp);
|
eth->setTimeAndInvokeEventsUs(1'000'000 * timeStamp);
|
||||||
for (int index = 0; index < 2; index++) {
|
for (int index = 0; index < 2; index++) {
|
||||||
if (currentState[index] == newState[index]) {
|
if (currentState[index] == newState[index]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
trigger_event_e event = (newState[index] ? riseEvents : fallEvents)[index];
|
trigger_event_e event =
|
||||||
|
(newState[index] ? riseEvents : fallEvents)[index];
|
||||||
efitick_t nowNt = getTimeNowNt();
|
efitick_t nowNt = getTimeNowNt();
|
||||||
engine->triggerCentral.handleShaftSignal(event, nowNt PASS_ENGINE_PARAMETER_SUFFIX);
|
engine->triggerCentral.handleShaftSignal(event, nowNt PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
currentState[index] = newState[index];
|
currentState[index] = newState[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void readLine(EngineTestHelper *eth) {
|
||||||
|
if (!haveMore())
|
||||||
|
return;
|
||||||
|
processLine(eth);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST(cranking, realCrankingFromFile) {
|
||||||
|
CsvReader reader;
|
||||||
|
reader.open("tests/trigger/recourses/cranking_na_3.csv");
|
||||||
|
|
||||||
|
WITH_ENGINE_TEST_HELPER (MIATA_NA6_MAP);
|
||||||
|
|
||||||
|
ssize_t read;
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
reader.readLine(ð);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT_EQ( 0, GET_RPM())<< reader.lineIndex;
|
||||||
|
ASSERT_EQ( 0, eth.recentWarnings()->getCount())<< "warningCounter#got synch";
|
||||||
|
|
||||||
|
reader.readLine(ð);
|
||||||
|
ASSERT_EQ( 94, GET_RPM())<< reader.lineIndex;
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
reader.readLine(ð);
|
||||||
|
}
|
||||||
|
ASSERT_EQ( 1, eth.recentWarnings()->getCount())<< "warningCounter#with synch";
|
||||||
|
|
||||||
|
while (reader.haveMore()) {
|
||||||
|
reader.processLine(ð);
|
||||||
|
}
|
||||||
|
ASSERT_EQ( 3, eth.recentWarnings()->getCount())<< "warningCounter#realCranking";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue