2021-08-03 19:05:01 -07:00
|
|
|
#include "pch.h"
|
|
|
|
|
2021-06-25 10:02:37 -07:00
|
|
|
#include "trigger_simulator.h"
|
|
|
|
#include "trigger_emulator_algo.h"
|
|
|
|
|
|
|
|
TEST(miata, miata_na_tdc) {
|
2023-05-31 22:31:28 -07:00
|
|
|
EngineTestHelper eth(engine_type_e::FRANKENSO_MIATA_NA6_MAP);
|
2022-08-19 12:03:20 -07:00
|
|
|
engineConfiguration->alwaysInstantRpm = true;
|
2021-06-25 10:02:37 -07:00
|
|
|
|
|
|
|
#define TEST_REVOLUTIONS 6
|
|
|
|
|
|
|
|
TriggerWaveform & shape = engine->triggerCentral.triggerShape;
|
|
|
|
|
|
|
|
TriggerEmulatorHelper emulatorHelper;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* let's feed two more cycles to validate shape definition
|
|
|
|
*/
|
|
|
|
for (uint32_t i = 0; i <= TEST_REVOLUTIONS * shape.getSize(); i++) {
|
|
|
|
|
|
|
|
int time = getSimulatedEventTime(shape, i);
|
|
|
|
eth.setTimeAndInvokeEventsUs(time);
|
|
|
|
|
2023-10-26 11:10:51 -07:00
|
|
|
emulatorHelper.handleEmulatorCallback(0,
|
2021-11-21 01:56:07 -08:00
|
|
|
shape.wave,
|
2021-11-16 01:15:29 -08:00
|
|
|
i % shape.getSize());
|
2021-06-25 10:02:37 -07:00
|
|
|
}
|
|
|
|
|
2022-01-20 20:19:48 -08:00
|
|
|
ASSERT_EQ(167, round(Sensor::getOrZero(SensorType::Rpm))) << "miata_na_tdc RPM";
|
2024-05-01 09:10:52 -07:00
|
|
|
ASSERT_EQ(293999, engine->tdcScheduler[0].getMomentUs() % SIMULATION_CYCLE_PERIOD); // let's assert TDC position and sync point
|
|
|
|
ASSERT_EQ(293999, engine->tdcScheduler[1].getMomentUs() % SIMULATION_CYCLE_PERIOD); // let's assert TDC position and sync point
|
2021-06-25 10:02:37 -07:00
|
|
|
}
|