rusefi/unit_tests/test-framework/logicdata_csv_reader.h

57 lines
1.2 KiB
C
Raw Normal View History

2021-06-25 21:15:55 -07:00
/*
* @file logicdata_csv_reader.h
*
* @date Jun 26, 2021
* @author Andrey Belomutskiy, (c) 2012-2021
*/
2022-09-24 12:33:01 -07:00
2022-09-24 20:01:42 -07:00
const int NORMAL_ORDER[2] = {0, 1};
const int REVERSE_ORDER[2] = {1, 0};
2022-09-24 12:33:01 -07:00
2022-09-24 21:26:42 -07:00
2021-06-25 21:15:55 -07:00
class CsvReader {
public:
CsvReader(size_t triggerCount, size_t vvtCount) : CsvReader(triggerCount, vvtCount, 0.0) {}
CsvReader(size_t triggerCount, size_t vvtCount, double timestampOffset)
: m_triggerCount(triggerCount)
, m_vvtCount(vvtCount)
, m_timestampOffset(timestampOffset)
{
}
2021-12-01 10:35:44 -08:00
~CsvReader();
2022-09-24 21:26:42 -07:00
bool twoBanksSingleCamMode = true;
2022-09-24 20:07:55 -07:00
void open(const char *fileName, const int* triggerColumnIndeces = NORMAL_ORDER, const int *vvtColumnIndeces = NORMAL_ORDER);
bool haveMore();
void processLine(EngineTestHelper *eth);
void readLine(EngineTestHelper *eth);
2021-12-01 10:35:44 -08:00
double readTimestampAndValues(double *v);
2023-12-06 20:00:13 -08:00
bool flipOnRead = false;
bool flipVvtOnRead = false;
2023-12-06 20:00:13 -08:00
int lineIndex() const {
return m_lineIndex;
}
private:
const size_t m_triggerCount;
const size_t m_vvtCount;
const double m_timestampOffset;
2021-12-01 10:35:44 -08:00
FILE *fp = nullptr;
2021-06-25 21:33:28 -07:00
char buffer[255];
bool currentState[TRIGGER_INPUT_PIN_COUNT] = {0, 0};
bool currentVvtState[CAM_INPUTS_COUNT] = {0, 0};
2021-06-25 21:33:28 -07:00
int m_lineIndex = -1;
2021-06-25 21:33:28 -07:00
2022-09-24 19:55:54 -07:00
const int* triggerColumnIndeces;
2022-09-24 20:01:42 -07:00
const int* vvtColumnIndeces;
2021-06-25 21:15:55 -07:00
};