2019-10-07 20:12:29 -07:00
|
|
|
/**
|
|
|
|
* @file test_one_cylinder_logic.cpp
|
2020-01-07 21:02:40 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2019-10-07 20:12:29 -07:00
|
|
|
*/
|
|
|
|
|
2021-08-03 19:05:01 -07:00
|
|
|
#include "pch.h"
|
2019-10-07 20:12:29 -07:00
|
|
|
#include "spark_logic.h"
|
2024-02-28 18:05:48 -08:00
|
|
|
#include "GY6_139QMB.h"
|
|
|
|
#include "defaults.h"
|
2019-10-07 20:12:29 -07:00
|
|
|
|
|
|
|
TEST(issues, issueOneCylinderSpecialCase968) {
|
2023-05-31 22:31:28 -07:00
|
|
|
EngineTestHelper eth(engine_type_e::GY6_139QMB);
|
2024-02-28 19:53:44 -08:00
|
|
|
angle_t timing = 4;
|
|
|
|
engineConfiguration->crankingTimingAngle = timing;
|
2022-11-29 20:41:49 -08:00
|
|
|
setTable(config->injectionPhase, -180.0f);
|
2022-04-23 06:51:47 -07:00
|
|
|
engineConfiguration->isFasterEngineSpinUpEnabled = false;
|
2021-11-17 00:54:21 -08:00
|
|
|
engine->tdcMarkEnabled = false;
|
2019-10-07 20:12:29 -07:00
|
|
|
// set injection_mode 1
|
|
|
|
engineConfiguration->injectionMode = IM_SEQUENTIAL;
|
|
|
|
|
2022-04-02 23:21:37 -07:00
|
|
|
setCrankOperationMode();
|
2019-10-07 20:12:29 -07:00
|
|
|
|
2023-08-05 21:46:33 -07:00
|
|
|
eth.setTriggerType(trigger_type_e::TT_HALF_MOON);
|
2019-10-07 20:12:29 -07:00
|
|
|
|
|
|
|
ASSERT_EQ( 0, engine->executor.size()) << "start";
|
|
|
|
|
2021-11-20 22:01:27 -08:00
|
|
|
eth.fireTriggerEvents2(/* count */ 2, 50 /* ms */);
|
2024-02-28 18:05:48 -08:00
|
|
|
eth.assertRpm(0);
|
2019-10-07 20:12:29 -07:00
|
|
|
ASSERT_EQ( 0, engine->executor.size()) << "first revolution(s)";
|
|
|
|
|
|
|
|
eth.fireTriggerEvents2(/* count */ 1, 50 /* ms */);
|
2024-02-28 18:05:48 -08:00
|
|
|
eth.assertRpm(600, "RPM");
|
|
|
|
ASSERT_EQ(engine->triggerCentral.currentEngineDecodedPhase, 90 + Gy6139_globalTriggerAngleOffset);
|
2024-02-28 19:53:44 -08:00
|
|
|
ASSERT_EQ(engine->engineState.timingAdvance[0], timing);
|
|
|
|
|
|
|
|
angle_t expectedAngle = 180 - Gy6139_globalTriggerAngleOffset + timing;
|
|
|
|
int expectedDeltaTimeUs = eth.angleToTimeUs(expectedAngle);
|
2019-10-07 20:12:29 -07:00
|
|
|
|
|
|
|
ASSERT_EQ( 2, engine->executor.size()) << "first revolution(s)";
|
2024-04-09 20:53:26 -07:00
|
|
|
eth.assertEvent5("spark up#0", 0, (void*)turnSparkPinHighStartCharging, -expectedDeltaTimeUs - MS2US(DEFAULT_CRANKING_DWELL_MS));
|
2024-02-28 19:53:44 -08:00
|
|
|
eth.assertEvent5("spark down#0", 1, (void*)fireSparkAndPrepareNextSchedule, -expectedDeltaTimeUs);
|
2019-10-07 20:12:29 -07:00
|
|
|
|
|
|
|
|
|
|
|
eth.fireTriggerEvents2(/* count */ 1, 50 /* ms */);
|
|
|
|
ASSERT_EQ( 4, engine->executor.size()) << "first revolution(s)";
|
|
|
|
}
|