fome-fw/unit_tests/tests/actuators/test_antilag.cpp

37 lines
1.4 KiB
C++
Raw Normal View History

2022-12-30 09:11:57 -08:00
#include "pch.h"
#include "fuel_math.h"
2022-12-30 09:11:57 -08:00
TEST(Actuators, AntiLag) {
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
2022-12-30 09:11:57 -08:00
engineConfiguration->antiLagEnabled = true;
setTable(config->ALSFuelAdjustment, 50 /* percent */);
2022-12-30 09:11:57 -08:00
Sensor::setMockValue(SensorType::Clt, 70);
Sensor::setMockValue(SensorType::Rpm, 1000);
Sensor::setMockValue(SensorType::Tps1, 1);
Sensor::setMockValue(SensorType::AcceleratorPedal, 1);
2022-12-30 09:11:57 -08:00
2022-12-30 09:17:53 -08:00
engineConfiguration->antiLagActivationMode = SWITCH_INPUT_ANTILAG;
2022-12-30 09:11:57 -08:00
engine->periodicFastCallback();
float fuelWithCorrections = 1.01;
ASSERT_NEAR(fuelWithCorrections, getRunningFuel(1), EPS4D);
// in unit tests we pretend that physical swiych is always OFF
ASSERT_EQ(0, engine->antilagController.ALSSwitchCondition);
ASSERT_EQ(0.0, engine->antilagController.fuelALSCorrection);
2022-12-30 09:17:53 -08:00
engineConfiguration->antiLagActivationMode = ALWAYS_ON_ANTILAG;
engine->periodicFastCallback();
ASSERT_EQ(1, engine->antilagController.ALSSwitchCondition);
ASSERT_NEAR(50, engine->antilagController.fuelALSCorrection, EPS4D);
2022-12-30 09:17:53 -08:00
ASSERT_EQ(1, engine->antilagController.ALSMinRPMCondition);
ASSERT_EQ(1, engine->antilagController.ALSMaxRPMCondition);
2022-12-30 09:11:57 -08:00
ASSERT_EQ(1, engine->antilagController.ALSMinCLTCondition);
ASSERT_EQ(1, engine->antilagController.ALSMaxCLTCondition);
ASSERT_EQ(1, engine->antilagController.ALSMaxThrottleIntentCondition);
2022-12-30 09:11:57 -08:00
ASSERT_EQ(1, engine->antilagController.isAntilagCondition);
ASSERT_NEAR(1.5 * fuelWithCorrections, getRunningFuel(1), EPS4D);
2022-12-30 09:11:57 -08:00
}