implement test for `Torque Reduction Ignition Retard(deg)` parameter #5608
This commit is contained in:
parent
5bce202067
commit
9d86da59e1
|
@ -21,6 +21,7 @@ namespace engine_configuration_defaults {
|
|||
constexpr float TORQUE_REDUCTION_ARMING_RPM = 0.0f;
|
||||
constexpr float TORQUE_REDUCTION_ARMING_APP = 0.0f;
|
||||
constexpr int8_t TORQUE_REDUCTION_IGNITION_CUT = 0;
|
||||
constexpr float TORQUE_REDUCTION_IGNITION_RETARD = 0.0f;
|
||||
|
||||
/* Launch Control: */
|
||||
constexpr switch_input_pin_e LAUNCH_ACTIVATE_PIN = Gpio::Unassigned;
|
||||
|
|
|
@ -6,8 +6,11 @@
|
|||
|
||||
#include "flat_shift_condition_test_base.h"
|
||||
|
||||
FlatShiftConditionTestBase::FlatShiftConditionTestBase(const int8_t torqueReductionIgnitionCut)
|
||||
: m_torqueReductionIgnitionCut(torqueReductionIgnitionCut) {
|
||||
FlatShiftConditionTestBase::FlatShiftConditionTestBase(
|
||||
const int8_t torqueReductionIgnitionCut,
|
||||
const float torqueReductionIgnitionRetard
|
||||
) : m_torqueReductionIgnitionCut(torqueReductionIgnitionCut),
|
||||
m_torqueReductionIgnitionRetard(torqueReductionIgnitionRetard) {
|
||||
}
|
||||
|
||||
void FlatShiftConditionTestBase::SetUp() {
|
||||
|
@ -19,6 +22,7 @@ void FlatShiftConditionTestBase::SetUp() {
|
|||
.setTriggerPin(TEST_TORQUE_REDUCTION_BUTTON_PIN)
|
||||
.setLimitTorqueReductionTime(false)
|
||||
.setTorqueReductionIgnitionCut(m_torqueReductionIgnitionCut)
|
||||
.setTorqueReductionIgnitionRetard(m_torqueReductionIgnitionRetard)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ protected:
|
|||
static constexpr switch_input_pin_e TEST_TORQUE_REDUCTION_BUTTON_PIN = Gpio::G10;
|
||||
static constexpr float TEST_TORQUE_REDUCTION_ARMING_APP = 7.89;
|
||||
|
||||
FlatShiftConditionTestBase(int8_t torqueReductionIgnitionCut);
|
||||
FlatShiftConditionTestBase(int8_t torqueReductionIgnitionCut, float m_torqueReductionIgnitionRetard);
|
||||
|
||||
void SetUp() override;
|
||||
|
||||
|
@ -19,4 +19,5 @@ protected:
|
|||
void unsatisfyFlatShiftCondition();
|
||||
private:
|
||||
const int8_t m_torqueReductionIgnitionCut;
|
||||
const float m_torqueReductionIgnitionRetard;
|
||||
};
|
|
@ -69,12 +69,19 @@ ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setTorqueReductio
|
|||
}
|
||||
|
||||
ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setTorqueReductionIgnitionCut(
|
||||
std::optional<int8_t> value
|
||||
const std::optional<int8_t> value
|
||||
) {
|
||||
m_torqueReductionIgnitionCut = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setTorqueReductionIgnitionRetard(
|
||||
const std::optional<float> value
|
||||
) {
|
||||
m_torqueReductionIgnitionRetard = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void ShiftTorqueReductionTestBase::setUpTestConfig(const ShiftTorqueReductionTestConfig& config) {
|
||||
getTestEngineConfiguration().configureTorqueReductionEnabled(config.getTorqueReductionEnabled());
|
||||
getTestEngineConfiguration().configureTorqueReductionActivationMode(config.getTorqueReductionActivationMode());
|
||||
|
@ -87,4 +94,5 @@ void ShiftTorqueReductionTestBase::setUpTestConfig(const ShiftTorqueReductionTes
|
|||
getTestEngineConfiguration().configureTorqueReductionArmingRpm(config.getTorqueReductionArmingRpm());
|
||||
getTestEngineConfiguration().configureTorqueReductionArmingApp(config.getTorqueReductionArmingApp());
|
||||
getTestEngineConfiguration().configureTorqueReductionIgnitionCut(config.getTorqueReductionIgnitionCut());
|
||||
getTestEngineConfiguration().configureTorqueReductionIgnitionRetard(config.getTorqueReductionIgnitionRetard());
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ public:
|
|||
std::optional<float> getTorqueReductionArmingRpm() const { return m_torqueReductionArmingRpm; }
|
||||
std::optional<float> getTorqueReductionArmingApp() const { return m_torqueReductionArmingApp; }
|
||||
std::optional<int8_t> getTorqueReductionIgnitionCut() const { return m_torqueReductionIgnitionCut; }
|
||||
std::optional<float> getTorqueReductionIgnitionRetard() const { return m_torqueReductionIgnitionRetard; }
|
||||
|
||||
// We do not core about performance in tests, but we want to use builder-like style, so setters return new instance
|
||||
// of configuration:
|
||||
|
@ -37,6 +38,7 @@ public:
|
|||
ShiftTorqueReductionTestConfig setTorqueReductionArmingRpm(std::optional<float> value);
|
||||
ShiftTorqueReductionTestConfig setTorqueReductionArmingApp(std::optional<float> value);
|
||||
ShiftTorqueReductionTestConfig setTorqueReductionIgnitionCut(std::optional<int8_t> value);
|
||||
ShiftTorqueReductionTestConfig setTorqueReductionIgnitionRetard(std::optional<float> value);
|
||||
private:
|
||||
std::optional<bool> m_isTorqueReductionEnabled;
|
||||
std::optional<torqueReductionActivationMode_e> m_torqueReductionActivationMode;
|
||||
|
@ -49,6 +51,7 @@ private:
|
|||
std::optional<float> m_torqueReductionArmingRpm;
|
||||
std::optional<float> m_torqueReductionArmingApp;
|
||||
std::optional<int8_t> m_torqueReductionIgnitionCut;
|
||||
std::optional<float> m_torqueReductionIgnitionRetard;
|
||||
};
|
||||
|
||||
class ShiftTorqueReductionTestBase : public TestBase {
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
//
|
||||
// Created by kifir on 11/5/24.
|
||||
//
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
#include "flat_shift_condition_test_base.h"
|
||||
|
||||
constexpr float TEST_IGNITION_RETARD = 17.4;
|
||||
constexpr float TEST_TORQUE_REDUCTION_IGNITION_RETARD = 23.0f;
|
||||
|
||||
namespace {
|
||||
class ShiftTorqueReductionAngleAdvanceTest : public FlatShiftConditionTestBase {
|
||||
protected:
|
||||
ShiftTorqueReductionAngleAdvanceTest();
|
||||
|
||||
void SetUp() override;
|
||||
|
||||
void checkBaseIgnitionAdvance(const char* context, float expectedAdvance);
|
||||
private:
|
||||
void configureTestIgnitionTable();
|
||||
};
|
||||
|
||||
ShiftTorqueReductionAngleAdvanceTest::ShiftTorqueReductionAngleAdvanceTest()
|
||||
: FlatShiftConditionTestBase(0, TEST_TORQUE_REDUCTION_IGNITION_RETARD) {
|
||||
}
|
||||
|
||||
void ShiftTorqueReductionAngleAdvanceTest::SetUp() {
|
||||
FlatShiftConditionTestBase::SetUp();
|
||||
configureTestIgnitionTable();
|
||||
}
|
||||
|
||||
void ShiftTorqueReductionAngleAdvanceTest::checkBaseIgnitionAdvance(
|
||||
const char* const context,
|
||||
const float expectedAdvance
|
||||
) {
|
||||
periodicFastCallback();
|
||||
EXPECT_NEAR(expectedAdvance, engine->ignitionState.baseIgnitionAdvance, EPS5D) << context;
|
||||
}
|
||||
|
||||
void ShiftTorqueReductionAngleAdvanceTest::configureTestIgnitionTable() {
|
||||
IgnitionTable testIgnitionTable;
|
||||
for (IgnitionTable::size_type loadIdx = 0; loadIdx < testIgnitionTable.size(); loadIdx++) {
|
||||
const IgnitionTable::value_type& rpms = testIgnitionTable[loadIdx];
|
||||
for (IgnitionTable::size_type rpmIdx = 0; rpmIdx < rpms.size(); rpmIdx++) {
|
||||
testIgnitionTable[loadIdx][rpmIdx] = TEST_IGNITION_RETARD;
|
||||
}
|
||||
};
|
||||
getTestPersistentConfiguration().setIgnitionTable(testIgnitionTable);
|
||||
}
|
||||
|
||||
TEST_F(ShiftTorqueReductionAngleAdvanceTest, checkAngleAdvance) {
|
||||
checkBaseIgnitionAdvance("Initial state", TEST_IGNITION_RETARD);
|
||||
|
||||
satisfyFlatShiftCondition();
|
||||
checkBaseIgnitionAdvance("Flat Shift condition is satisfied", TEST_TORQUE_REDUCTION_IGNITION_RETARD);
|
||||
|
||||
unsatisfyFlatShiftCondition();
|
||||
checkBaseIgnitionAdvance("Flat Shift condition is not satisfied", TEST_IGNITION_RETARD);
|
||||
}
|
||||
}
|
|
@ -25,7 +25,7 @@ namespace {
|
|||
};
|
||||
|
||||
ShiftTorqueReductionSparkSkipRatioTest::ShiftTorqueReductionSparkSkipRatioTest()
|
||||
: FlatShiftConditionTestBase(TEST_TORQUE_REDUCTION_IGNITION_CUT) {
|
||||
: FlatShiftConditionTestBase(TEST_TORQUE_REDUCTION_IGNITION_CUT, 0.0f) {
|
||||
}
|
||||
|
||||
void ShiftTorqueReductionSparkSkipRatioTest::SetUp() {
|
||||
|
|
|
@ -68,6 +68,7 @@ TESTS_SRC_CPP = \
|
|||
tests/shift_torque_reduction/test_shift_torque_reduction_app_condition.cpp \
|
||||
tests/shift_torque_reduction/test_shift_torque_reduction_flat_shift_condition.cpp \
|
||||
tests/shift_torque_reduction/test_shift_torque_reduction_spark_skip_ratio.cpp \
|
||||
tests/shift_torque_reduction/test_shift_torque_reduction_angle_advance.cpp \
|
||||
tests/test_fft.cpp \
|
||||
tests/lua/test_lua_basic.cpp \
|
||||
tests/lua/test_lookup.cpp \
|
||||
|
|
|
@ -241,6 +241,17 @@ void TestEngineConfiguration::configureTorqueReductionIgnitionCut(const std::opt
|
|||
}
|
||||
}
|
||||
|
||||
void TestEngineConfiguration::configureTorqueReductionIgnitionRetard(const std::optional<int8_t> ignitionRetard) {
|
||||
if (ignitionRetard.has_value()) {
|
||||
engineConfiguration->torqueReductionIgnitionRetard = ignitionRetard.value();
|
||||
} else {
|
||||
ASSERT_EQ(
|
||||
engineConfiguration->torqueReductionIgnitionRetard,
|
||||
engine_configuration_defaults::TORQUE_REDUCTION_IGNITION_RETARD
|
||||
); // check default value
|
||||
}
|
||||
}
|
||||
|
||||
TestEngineConfiguration::TestEngineConfiguration() {
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
void configureTorqueReductionArmingRpm(std::optional<float> armingRpm);
|
||||
void configureTorqueReductionArmingApp(std::optional<float> armingApp);
|
||||
void configureTorqueReductionIgnitionCut(std::optional<int8_t> ignitionCut);
|
||||
void configureTorqueReductionIgnitionRetard(std::optional<int8_t> ignitionRetard);
|
||||
private:
|
||||
TestEngineConfiguration();
|
||||
static TestEngineConfiguration instance;
|
||||
|
|
Loading…
Reference in New Issue