2022-01-18 07:24:08 -08:00
|
|
|
/*
|
|
|
|
* @file test_hpfp_integrated.cpp
|
|
|
|
*
|
|
|
|
* Created on: Jan 18, 2022
|
|
|
|
* More integrated version of HPFP test
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pch.h"
|
2023-10-05 17:20:26 -07:00
|
|
|
using ::testing::_;
|
2022-01-18 07:24:08 -08:00
|
|
|
|
2023-10-05 20:09:45 -07:00
|
|
|
static size_t hpfpTotalToggle = 0;
|
|
|
|
|
2024-05-02 21:57:06 -07:00
|
|
|
static void assertToggleCounterExtra(EngineTestHelper *eth, size_t extra, const char *msg) {
|
2023-10-05 20:09:45 -07:00
|
|
|
eth->smartFireTriggerEvents2(/*count*/4, /*delay*/ 16);
|
2024-05-02 21:57:06 -07:00
|
|
|
ASSERT_EQ(hpfpTotalToggle + extra, enginePins.hpfpValve.pinToggleCounter) << msg;
|
2023-10-05 20:09:45 -07:00
|
|
|
hpfpTotalToggle += extra;
|
|
|
|
}
|
|
|
|
|
2022-01-18 07:24:08 -08:00
|
|
|
TEST(HPFP, IntegratedSchedule) {
|
2023-05-31 22:31:28 -07:00
|
|
|
EngineTestHelper eth(engine_type_e::TEST_ENGINE, [](engine_configuration_s* engineConfiguration) {
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->hpfpValvePin = Gpio::A2; // arbitrary
|
2022-01-18 07:24:08 -08:00
|
|
|
});
|
|
|
|
|
2023-03-27 00:58:18 -07:00
|
|
|
engineConfiguration->cylindersCount = 4;
|
2022-01-18 07:24:08 -08:00
|
|
|
engineConfiguration->hpfpCamLobes = 3;
|
|
|
|
engineConfiguration->hpfpPumpVolume = 0.2; // cc/lobe
|
|
|
|
|
2023-10-05 17:20:26 -07:00
|
|
|
EXPECT_CALL(*eth.mockAirmass, getAirmass(_, _))
|
|
|
|
.WillRepeatedly(Return(AirmassResult{/*airmass*/1, /*load*/50.0f}));
|
2022-01-18 07:24:08 -08:00
|
|
|
|
2023-10-05 16:20:27 -07:00
|
|
|
engineConfiguration->trigger.customTotalToothCount = 4;
|
2022-01-18 07:24:08 -08:00
|
|
|
engineConfiguration->trigger.customSkippedToothCount = 0;
|
2023-05-31 23:01:33 -07:00
|
|
|
eth.setTriggerType(trigger_type_e::TT_TOOTHED_WHEEL);
|
2022-04-02 23:21:37 -07:00
|
|
|
setCamOperationMode();
|
2022-01-18 07:24:08 -08:00
|
|
|
engineConfiguration->isFasterEngineSpinUpEnabled = true;
|
2023-10-05 20:09:45 -07:00
|
|
|
engineConfiguration->hpfpCam = HPFP_CAM_IN1;
|
2022-01-18 07:24:08 -08:00
|
|
|
|
2023-10-05 17:20:26 -07:00
|
|
|
eth.smartFireTriggerEvents2(/*count*/8, /*delay*/ 16);
|
2022-01-20 20:03:45 -08:00
|
|
|
ASSERT_EQ(937, round(Sensor::getOrZero(SensorType::Rpm)));
|
2022-01-18 07:24:08 -08:00
|
|
|
|
2023-10-05 20:09:45 -07:00
|
|
|
|
2024-05-02 21:57:06 -07:00
|
|
|
hpfpTotalToggle = 6;
|
2022-01-18 07:24:08 -08:00
|
|
|
/**
|
|
|
|
* overall this is a pretty lame test but helps to know that the whole on/off/on dance does in fact happen for HPFP
|
|
|
|
*/
|
2023-10-05 20:09:45 -07:00
|
|
|
ASSERT_EQ(hpfpTotalToggle, enginePins.hpfpValve.pinToggleCounter);
|
|
|
|
|
2024-05-02 21:57:06 -07:00
|
|
|
assertToggleCounterExtra(ð, 4, "#1");
|
2023-10-05 20:09:45 -07:00
|
|
|
|
2024-03-17 19:30:50 -07:00
|
|
|
engine->triggerCentral.vvtPosition[0][0] = -100; // Bank 0
|
2023-10-05 20:09:45 -07:00
|
|
|
|
2024-05-02 21:57:06 -07:00
|
|
|
assertToggleCounterExtra(ð, 7, "#2");
|
2023-10-05 20:09:45 -07:00
|
|
|
|
2024-05-02 21:57:06 -07:00
|
|
|
assertToggleCounterExtra(ð, 6, "#3");
|
2023-10-05 20:17:05 -07:00
|
|
|
|
2024-05-02 21:57:06 -07:00
|
|
|
assertToggleCounterExtra(ð, 6, "#4");
|
2023-10-05 20:17:05 -07:00
|
|
|
|
2024-05-02 21:57:06 -07:00
|
|
|
assertToggleCounterExtra(ð, 6, "#5");
|
2022-01-18 07:24:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|