* only:refactoring: extract part of functionality into `TestEngineConfiguration` class * only:refactoring: rename file * only:refactoring: Now we reuse `TestBase` class functionality * only:refactoring: extract part of functionality into `TestEngineState` class * only:refactoring: extract part of functionality into `TestEngineConfiguration` class * implement test for `Torque Reduction Ignition Cut` setting #5608
This commit is contained in:
parent
17ea5ab16b
commit
6361b9ef31
|
@ -20,6 +20,7 @@ namespace engine_configuration_defaults {
|
||||||
constexpr bool LIMIT_TORQUE_REDUCTION_TIME = false;
|
constexpr bool LIMIT_TORQUE_REDUCTION_TIME = false;
|
||||||
constexpr float TORQUE_REDUCTION_ARMING_RPM = 0.0f;
|
constexpr float TORQUE_REDUCTION_ARMING_RPM = 0.0f;
|
||||||
constexpr float TORQUE_REDUCTION_ARMING_APP = 0.0f;
|
constexpr float TORQUE_REDUCTION_ARMING_APP = 0.0f;
|
||||||
|
constexpr int8_t TORQUE_REDUCTION_IGNITION_CUT = 0;
|
||||||
|
|
||||||
/* Launch Control: */
|
/* Launch Control: */
|
||||||
constexpr switch_input_pin_e LAUNCH_ACTIVATE_PIN = Gpio::Unassigned;
|
constexpr switch_input_pin_e LAUNCH_ACTIVATE_PIN = Gpio::Unassigned;
|
||||||
|
|
|
@ -7,107 +7,25 @@
|
||||||
#include "launch_test_base.h"
|
#include "launch_test_base.h"
|
||||||
|
|
||||||
void LaunchTestBase::setUpTestConfig(const LaunchTestConfig& config) {
|
void LaunchTestBase::setUpTestConfig(const LaunchTestConfig& config) {
|
||||||
configureLaunchControlEnabled(config.getLaunchControlEnabled());
|
getTestEngineConfiguration().configureLaunchControlEnabled(config.getLaunchControlEnabled());
|
||||||
|
|
||||||
configureLaunchRpm(config.getLaunchRpm());
|
getTestEngineConfiguration().configureLaunchRpm(config.getLaunchRpm());
|
||||||
configureLaunchRpmWindow(config.getLaunchRpmWindow());
|
getTestEngineConfiguration().configureLaunchRpmWindow(config.getLaunchRpmWindow());
|
||||||
configureLaunchCorrectionsEndRpm(config.getLaunchCorrectionsEndRpm());
|
getTestEngineConfiguration().configureLaunchCorrectionsEndRpm(config.getLaunchCorrectionsEndRpm());
|
||||||
|
|
||||||
configureIgnitionRetardEnable(config.getIgnitionRetardEnable());
|
getTestEngineConfiguration().configureIgnitionRetardEnable(config.getIgnitionRetardEnable());
|
||||||
configureIgnitionRetard(config.getIgnitionRetard());
|
getTestEngineConfiguration().configureIgnitionRetard(config.getIgnitionRetard());
|
||||||
configureSmoothRetardMode(config.getSmoothRetardMode());
|
getTestEngineConfiguration().configureSmoothRetardMode(config.getSmoothRetardMode());
|
||||||
|
|
||||||
configureEnableIgnitionCut(config.getEnableIgnitionCut());
|
getTestEngineConfiguration().configureEnableIgnitionCut(config.getEnableIgnitionCut());
|
||||||
configureInitialIgnitionCutPercent(config.getInitialIgnitionCut());
|
getTestEngineConfiguration().configureInitialIgnitionCutPercent(config.getInitialIgnitionCut());
|
||||||
configureFinalIgnitionCutPercentBeforeLaunch(config.getFinalIgnitionCutBeforeLaunch());
|
getTestEngineConfiguration().configureFinalIgnitionCutPercentBeforeLaunch(config.getFinalIgnitionCutBeforeLaunch());
|
||||||
|
|
||||||
if (config.getSatisfyActivationSwithSpeedAndTpsConditions()) {
|
if (config.getSatisfyActivationSwithSpeedAndTpsConditions()) {
|
||||||
configureSatisfiedActivationSwithSpeedAndTpsConditions();
|
configureSatisfiedActivationSwithSpeedAndTpsConditions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LaunchTestBase::configureLaunchControlEnabled(const std::optional<bool> launchControlEnabled) {
|
|
||||||
if (launchControlEnabled.has_value()) {
|
|
||||||
engineConfiguration->launchControlEnabled = launchControlEnabled.value();
|
|
||||||
} else {
|
|
||||||
ASSERT_FALSE(engineConfiguration->launchControlEnabled); // check default value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LaunchTestBase::configureLaunchRpm(const std::optional<int> launchRpm) {
|
|
||||||
if (launchRpm.has_value()) {
|
|
||||||
engineConfiguration->launchRpm = launchRpm.value();
|
|
||||||
} else {
|
|
||||||
ASSERT_EQ(engineConfiguration->launchRpm, 0); // check default value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LaunchTestBase::configureLaunchRpmWindow(const std::optional<int> launchRpmWindow) {
|
|
||||||
if (launchRpmWindow.has_value()) {
|
|
||||||
engineConfiguration->launchRpmWindow = launchRpmWindow.value();
|
|
||||||
} else {
|
|
||||||
ASSERT_EQ(engineConfiguration->launchRpmWindow, 0); // check default value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LaunchTestBase::configureLaunchCorrectionsEndRpm(const std::optional<int> launchCorrectionsEndRpm) {
|
|
||||||
if (launchCorrectionsEndRpm.has_value()) {
|
|
||||||
engineConfiguration->launchCorrectionsEndRpm = launchCorrectionsEndRpm.value();
|
|
||||||
} else {
|
|
||||||
ASSERT_EQ(engineConfiguration->launchCorrectionsEndRpm, 0); // check default value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LaunchTestBase::configureIgnitionRetardEnable(std::optional<bool> ignitionRetardEnable) {
|
|
||||||
if (ignitionRetardEnable.has_value()) {
|
|
||||||
engineConfiguration->enableLaunchRetard = ignitionRetardEnable.value();
|
|
||||||
} else {
|
|
||||||
ASSERT_FALSE(engineConfiguration->enableLaunchRetard); // check default value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LaunchTestBase::configureIgnitionRetard(std::optional<float> ignitionRetard) {
|
|
||||||
if (ignitionRetard.has_value()) {
|
|
||||||
engineConfiguration->launchTimingRetard = ignitionRetard.value();
|
|
||||||
} else {
|
|
||||||
ASSERT_EQ(engineConfiguration->launchTimingRetard, 0); // check default value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LaunchTestBase::configureSmoothRetardMode(std::optional<bool> smoothRetardMode) {
|
|
||||||
if (smoothRetardMode.has_value()) {
|
|
||||||
engineConfiguration->launchSmoothRetard = smoothRetardMode.value();
|
|
||||||
} else {
|
|
||||||
ASSERT_FALSE(engineConfiguration->launchSmoothRetard); // check default value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LaunchTestBase::configureEnableIgnitionCut(const std::optional<bool> enableIgnitionCut) {
|
|
||||||
if (enableIgnitionCut.has_value()) {
|
|
||||||
engineConfiguration->launchSparkCutEnable = enableIgnitionCut.value();
|
|
||||||
} else {
|
|
||||||
ASSERT_FALSE(engineConfiguration->launchSparkCutEnable); // check default value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LaunchTestBase::configureInitialIgnitionCutPercent(const std::optional<int> initialIgnitionCutPercent) {
|
|
||||||
if (initialIgnitionCutPercent.has_value()) {
|
|
||||||
engineConfiguration->initialIgnitionCutPercent = initialIgnitionCutPercent.value();
|
|
||||||
} else {
|
|
||||||
ASSERT_EQ(engineConfiguration->initialIgnitionCutPercent, 0); // check default value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LaunchTestBase::configureFinalIgnitionCutPercentBeforeLaunch(
|
|
||||||
const std::optional<int> finalIgnitionCutPercentBeforeLaunch
|
|
||||||
) {
|
|
||||||
if (finalIgnitionCutPercentBeforeLaunch.has_value()) {
|
|
||||||
engineConfiguration->finalIgnitionCutPercentBeforeLaunch = finalIgnitionCutPercentBeforeLaunch.value();
|
|
||||||
} else {
|
|
||||||
ASSERT_EQ(engineConfiguration->finalIgnitionCutPercentBeforeLaunch, 0); // check default value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LaunchTestBase::configureSatisfiedActivationSwithSpeedAndTpsConditions() {
|
void LaunchTestBase::configureSatisfiedActivationSwithSpeedAndTpsConditions() {
|
||||||
engineConfiguration->launchActivationMode = ALWAYS_ACTIVE_LAUNCH; // to satisfy activateSwitchCondition
|
engineConfiguration->launchActivationMode = ALWAYS_ACTIVE_LAUNCH; // to satisfy activateSwitchCondition
|
||||||
engineConfiguration->launchSpeedThreshold = 0; // to satisfy speedCondition
|
engineConfiguration->launchSpeedThreshold = 0; // to satisfy speedCondition
|
||||||
|
|
|
@ -66,19 +66,5 @@ protected:
|
||||||
void setUpTestConfig(const LaunchTestConfig& config);
|
void setUpTestConfig(const LaunchTestConfig& config);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void configureLaunchControlEnabled(std::optional<bool> launchControlEnabled);
|
|
||||||
|
|
||||||
void configureLaunchRpm(std::optional<int> launchRpm);
|
|
||||||
void configureLaunchRpmWindow(std::optional<int> launchRpmWindow);
|
|
||||||
void configureLaunchCorrectionsEndRpm(std::optional<int> launchCorrectionsEndRpm);
|
|
||||||
|
|
||||||
void configureIgnitionRetardEnable(std::optional<bool> ignitionRetardEnable);
|
|
||||||
void configureIgnitionRetard(std::optional<float> ignitionRetard);
|
|
||||||
void configureSmoothRetardMode(std::optional<bool> smoothRetardMode);
|
|
||||||
|
|
||||||
void configureEnableIgnitionCut(std::optional<bool> enableIgnitionCut);
|
|
||||||
void configureInitialIgnitionCutPercent(std::optional<int> initialIgnitionCut);
|
|
||||||
void configureFinalIgnitionCutPercentBeforeLaunch(std::optional<int> finalIgnitionCutBeforeLaunch);
|
|
||||||
|
|
||||||
void configureSatisfiedActivationSwithSpeedAndTpsConditions();
|
void configureSatisfiedActivationSwithSpeedAndTpsConditions();
|
||||||
};
|
};
|
|
@ -0,0 +1,45 @@
|
||||||
|
//
|
||||||
|
// Created by kifir on 5/17/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
|
|
||||||
|
#include "util/test_base.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
constexpr float TEST_TRACTION_CONTROL_IGNITION_SKIP = 17.0f;
|
||||||
|
constexpr float TEST_LUA_SOFT_SPARK_SKIP = 239.0f;
|
||||||
|
constexpr float TEST_LUA_HARD_SPARK_SKIP = 174.0f;
|
||||||
|
|
||||||
|
class LaunchTargetSkipRatioTest : public TestBase {
|
||||||
|
protected:
|
||||||
|
void SetUp() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
void LaunchTargetSkipRatioTest::SetUp() {
|
||||||
|
TestBase::SetUp();
|
||||||
|
std::fill_n(
|
||||||
|
&engineConfiguration->tractionControlIgnitionSkip[0][0],
|
||||||
|
TRACTION_CONTROL_ETB_DROP_SIZE * TRACTION_CONTROL_ETB_DROP_SIZE,
|
||||||
|
static_cast<int8_t>(TEST_TRACTION_CONTROL_IGNITION_SKIP)
|
||||||
|
);
|
||||||
|
getTestEngineState().setLuaSoftSparkSkip(TEST_LUA_SOFT_SPARK_SKIP);
|
||||||
|
getTestEngineState().setLuaHardSparkSkip(TEST_LUA_HARD_SPARK_SKIP);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(LaunchTargetSkipRatioTest, doNotUseSkipInTraction) {
|
||||||
|
EXPECT_FALSE(engineConfiguration->useHardSkipInTraction);
|
||||||
|
|
||||||
|
periodicFastCallback();
|
||||||
|
EXPECT_EQ(engine->softSparkLimiter.getTargetSkipRatio(), TEST_LUA_SOFT_SPARK_SKIP + TEST_TRACTION_CONTROL_IGNITION_SKIP);
|
||||||
|
EXPECT_EQ(engine->hardSparkLimiter.getTargetSkipRatio(), TEST_LUA_HARD_SPARK_SKIP);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(LaunchTargetSkipRatioTest, useSkipInTraction) {
|
||||||
|
engineConfiguration->useHardSkipInTraction = true;
|
||||||
|
|
||||||
|
periodicFastCallback();
|
||||||
|
EXPECT_EQ(engine->softSparkLimiter.getTargetSkipRatio(), TEST_LUA_SOFT_SPARK_SKIP);
|
||||||
|
EXPECT_EQ(engine->hardSparkLimiter.getTargetSkipRatio(), TEST_LUA_HARD_SPARK_SKIP + TEST_TRACTION_CONTROL_IGNITION_SKIP);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,41 +0,0 @@
|
||||||
//
|
|
||||||
// Created by kifir on 5/17/24.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "pch.h"
|
|
||||||
|
|
||||||
constexpr float TEST_TRACTION_CONTROL_IGNITION_SKIP = 17.0f;
|
|
||||||
constexpr float TEST_LUA_SOFT_SPARK_SKIP = 239.0f;
|
|
||||||
constexpr float TEST_LUA_HARD_SPARK_SKIP = 174.0f;
|
|
||||||
|
|
||||||
static void setUpTestParameters() {
|
|
||||||
std::fill_n(
|
|
||||||
&engineConfiguration->tractionControlIgnitionSkip[0][0],
|
|
||||||
TRACTION_CONTROL_ETB_DROP_SIZE * TRACTION_CONTROL_ETB_DROP_SIZE,
|
|
||||||
static_cast<int8_t>(TEST_TRACTION_CONTROL_IGNITION_SKIP)
|
|
||||||
);
|
|
||||||
engine->engineState.luaSoftSparkSkip = TEST_LUA_SOFT_SPARK_SKIP;
|
|
||||||
engine->engineState.luaHardSparkSkip = TEST_LUA_HARD_SPARK_SKIP;
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(targetSkipRatio, doNotUseSkipInTraction) {
|
|
||||||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
|
||||||
|
|
||||||
setUpTestParameters();
|
|
||||||
EXPECT_FALSE(engineConfiguration->useHardSkipInTraction);
|
|
||||||
|
|
||||||
eth.engine.periodicFastCallback();
|
|
||||||
EXPECT_EQ(engine->softSparkLimiter.getTargetSkipRatio(), TEST_LUA_SOFT_SPARK_SKIP + TEST_TRACTION_CONTROL_IGNITION_SKIP);
|
|
||||||
EXPECT_EQ(engine->hardSparkLimiter.getTargetSkipRatio(), TEST_LUA_HARD_SPARK_SKIP);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(targetSkipRatio, useSkipInTraction) {
|
|
||||||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
|
||||||
|
|
||||||
setUpTestParameters();
|
|
||||||
engineConfiguration->useHardSkipInTraction = true;
|
|
||||||
|
|
||||||
eth.engine.periodicFastCallback();
|
|
||||||
EXPECT_EQ(engine->softSparkLimiter.getTargetSkipRatio(), TEST_LUA_SOFT_SPARK_SKIP);
|
|
||||||
EXPECT_EQ(engine->hardSparkLimiter.getTargetSkipRatio(), TEST_LUA_HARD_SPARK_SKIP + TEST_TRACTION_CONTROL_IGNITION_SKIP);
|
|
||||||
}
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
//
|
||||||
|
// Created by kifir on 11/4/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
|
|
||||||
|
#include "flat_shift_condition_test_base.h"
|
||||||
|
|
||||||
|
FlatShiftConditionTestBase::FlatShiftConditionTestBase(const int8_t torqueReductionIgnitionCut)
|
||||||
|
: m_torqueReductionIgnitionCut(torqueReductionIgnitionCut) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlatShiftConditionTestBase::SetUp() {
|
||||||
|
ShiftTorqueReductionTestBase::SetUp();
|
||||||
|
|
||||||
|
setUpTestConfig(ShiftTorqueReductionTestConfig()
|
||||||
|
.setTorqueReductionEnabled(true)
|
||||||
|
.setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON)
|
||||||
|
.setTriggerPin(TEST_TORQUE_REDUCTION_BUTTON_PIN)
|
||||||
|
.setLimitTorqueReductionTime(false)
|
||||||
|
.setTorqueReductionIgnitionCut(m_torqueReductionIgnitionCut)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlatShiftConditionTestBase::satisfyFlatShiftCondition() {
|
||||||
|
setMockState(TEST_TORQUE_REDUCTION_BUTTON_PIN, true);
|
||||||
|
updateApp(TEST_TORQUE_REDUCTION_ARMING_APP);
|
||||||
|
|
||||||
|
periodicFastCallback();
|
||||||
|
|
||||||
|
EXPECT_TRUE(engine->shiftTorqueReductionController.isFlatShiftConditionSatisfied);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlatShiftConditionTestBase::unsatisfyFlatShiftCondition() {
|
||||||
|
setMockState(TEST_TORQUE_REDUCTION_BUTTON_PIN, false);
|
||||||
|
|
||||||
|
periodicFastCallback();
|
||||||
|
|
||||||
|
EXPECT_FALSE(engine->shiftTorqueReductionController.isFlatShiftConditionSatisfied);
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
//
|
||||||
|
// Created by kifir on 11/4/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "shift_torque_reduction_test_base.h"
|
||||||
|
|
||||||
|
class FlatShiftConditionTestBase : public ShiftTorqueReductionTestBase {
|
||||||
|
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);
|
||||||
|
|
||||||
|
void SetUp() override;
|
||||||
|
|
||||||
|
void satisfyFlatShiftCondition();
|
||||||
|
void unsatisfyFlatShiftCondition();
|
||||||
|
private:
|
||||||
|
const int8_t m_torqueReductionIgnitionCut;
|
||||||
|
};
|
|
@ -5,7 +5,6 @@
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
|
|
||||||
#include "shift_torque_reduction_test_base.h"
|
#include "shift_torque_reduction_test_base.h"
|
||||||
#include "engine_configuration_defaults.h"
|
|
||||||
|
|
||||||
ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setTorqueReductionEnabled(
|
ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setTorqueReductionEnabled(
|
||||||
const std::optional<bool> value
|
const std::optional<bool> value
|
||||||
|
@ -69,127 +68,23 @@ ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setTorqueReductio
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShiftTorqueReductionTestBase::setUpTestConfig(const ShiftTorqueReductionTestConfig& config) {
|
ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setTorqueReductionIgnitionCut(
|
||||||
configureTorqueReductionEnabled(config.getTorqueReductionEnabled());
|
std::optional<int8_t> value
|
||||||
configureTorqueReductionActivationMode(config.getTorqueReductionActivationMode());
|
|
||||||
configureTorqueReductionButton(config.getTriggerPin());
|
|
||||||
configureTorqueReductionButtonInverted(config.getPinInverted());
|
|
||||||
configureLaunchActivatePin(config.getLaunchActivatePin());
|
|
||||||
configureLaunchActivateInverted(config.getLaunchActivateInverted());
|
|
||||||
configureLimitTorqueReductionTime(config.getLimitTorqueReductionTime());
|
|
||||||
configureTorqueReductionTime(config.getTorqueReductionTime());
|
|
||||||
configureTorqueReductionArmingRpm(config.getTorqueReductionArmingRpm());
|
|
||||||
configureTorqueReductionArmingApp(config.getTorqueReductionArmingApp());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShiftTorqueReductionTestBase::configureTorqueReductionEnabled(const std::optional<bool> torqueReductionEnabled) {
|
|
||||||
if (torqueReductionEnabled.has_value()) {
|
|
||||||
engineConfiguration->torqueReductionEnabled = torqueReductionEnabled.value();
|
|
||||||
} else {
|
|
||||||
ASSERT_EQ(
|
|
||||||
engineConfiguration->torqueReductionEnabled,
|
|
||||||
engine_configuration_defaults::ENABLE_SHIFT_TORQUE_REDUCTION
|
|
||||||
); // check default value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShiftTorqueReductionTestBase::configureTorqueReductionActivationMode(
|
|
||||||
const std::optional<torqueReductionActivationMode_e> activationMode
|
|
||||||
) {
|
) {
|
||||||
if (activationMode.has_value()) {
|
m_torqueReductionIgnitionCut = value;
|
||||||
engineConfiguration->torqueReductionActivationMode = activationMode.value();
|
return *this;
|
||||||
} else {
|
|
||||||
ASSERT_EQ(
|
|
||||||
engineConfiguration->torqueReductionActivationMode,
|
|
||||||
engine_configuration_defaults::TORQUE_REDUCTION_ACTIVATION_MODE
|
|
||||||
); // check default value
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShiftTorqueReductionTestBase::configureTorqueReductionButton(const std::optional<switch_input_pin_e> pin) {
|
void ShiftTorqueReductionTestBase::setUpTestConfig(const ShiftTorqueReductionTestConfig& config) {
|
||||||
if (pin.has_value()) {
|
getTestEngineConfiguration().configureTorqueReductionEnabled(config.getTorqueReductionEnabled());
|
||||||
engineConfiguration->torqueReductionTriggerPin = pin.value();
|
getTestEngineConfiguration().configureTorqueReductionActivationMode(config.getTorqueReductionActivationMode());
|
||||||
} else {
|
getTestEngineConfiguration().configureTorqueReductionButton(config.getTriggerPin());
|
||||||
ASSERT_EQ(
|
getTestEngineConfiguration().configureTorqueReductionButtonInverted(config.getPinInverted());
|
||||||
engineConfiguration->torqueReductionTriggerPin,
|
getTestEngineConfiguration().configureLaunchActivatePin(config.getLaunchActivatePin());
|
||||||
engine_configuration_defaults::TORQUE_REDUCTION_TRIGGER_PIN
|
getTestEngineConfiguration().configureLaunchActivateInverted(config.getLaunchActivateInverted());
|
||||||
); // check default value
|
getTestEngineConfiguration().configureLimitTorqueReductionTime(config.getLimitTorqueReductionTime());
|
||||||
}
|
getTestEngineConfiguration().configureTorqueReductionTime(config.getTorqueReductionTime());
|
||||||
}
|
getTestEngineConfiguration().configureTorqueReductionArmingRpm(config.getTorqueReductionArmingRpm());
|
||||||
|
getTestEngineConfiguration().configureTorqueReductionArmingApp(config.getTorqueReductionArmingApp());
|
||||||
void ShiftTorqueReductionTestBase::configureTorqueReductionButtonInverted(const std::optional<bool> pinInverted) {
|
getTestEngineConfiguration().configureTorqueReductionIgnitionCut(config.getTorqueReductionIgnitionCut());
|
||||||
if (pinInverted.has_value()) {
|
|
||||||
engineConfiguration->torqueReductionTriggerPinInverted = pinInverted.value();
|
|
||||||
} else {
|
|
||||||
ASSERT_EQ(
|
|
||||||
engineConfiguration->torqueReductionTriggerPinInverted,
|
|
||||||
engine_configuration_defaults::TORQUE_REDUCTION_TRIGGER_PIN_INVERTED
|
|
||||||
); // check default value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShiftTorqueReductionTestBase::configureLaunchActivatePin(const std::optional<switch_input_pin_e> pin) {
|
|
||||||
if (pin.has_value()) {
|
|
||||||
engineConfiguration->launchActivatePin = pin.value();
|
|
||||||
} else {
|
|
||||||
ASSERT_EQ(
|
|
||||||
engineConfiguration->launchActivatePin,
|
|
||||||
engine_configuration_defaults::LAUNCH_ACTIVATE_PIN
|
|
||||||
); // check default value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShiftTorqueReductionTestBase::configureLaunchActivateInverted(const std::optional<bool> pinInverted) {
|
|
||||||
if (pinInverted.has_value()) {
|
|
||||||
engineConfiguration->launchActivateInverted = pinInverted.value();
|
|
||||||
} else {
|
|
||||||
ASSERT_EQ(
|
|
||||||
engineConfiguration->launchActivateInverted,
|
|
||||||
engine_configuration_defaults::LAUNCH_ACTIVATE_PIN_INVERTED
|
|
||||||
); // check default value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShiftTorqueReductionTestBase::configureLimitTorqueReductionTime(std::optional<bool> limitTorqueReductionTime) {
|
|
||||||
if (limitTorqueReductionTime.has_value()) {
|
|
||||||
engineConfiguration->limitTorqueReductionTime = limitTorqueReductionTime.value();
|
|
||||||
} else {
|
|
||||||
ASSERT_EQ(
|
|
||||||
engineConfiguration->limitTorqueReductionTime,
|
|
||||||
engine_configuration_defaults::LIMIT_TORQUE_REDUCTION_TIME
|
|
||||||
); // check default value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShiftTorqueReductionTestBase::configureTorqueReductionTime(std::optional<float> timeout) {
|
|
||||||
if (timeout.has_value()) {
|
|
||||||
engineConfiguration->torqueReductionTime = timeout.value();
|
|
||||||
} else {
|
|
||||||
ASSERT_EQ(
|
|
||||||
engineConfiguration->torqueReductionTime,
|
|
||||||
engine_configuration_defaults::TORQUE_REDUCTION_TIME
|
|
||||||
); // check default value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShiftTorqueReductionTestBase::configureTorqueReductionArmingRpm(const std::optional<float> armingRpm) {
|
|
||||||
if (armingRpm.has_value()) {
|
|
||||||
engineConfiguration->torqueReductionArmingRpm = armingRpm.value();
|
|
||||||
} else {
|
|
||||||
ASSERT_EQ(
|
|
||||||
engineConfiguration->torqueReductionArmingRpm,
|
|
||||||
engine_configuration_defaults::TORQUE_REDUCTION_ARMING_RPM
|
|
||||||
); // check default value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShiftTorqueReductionTestBase::configureTorqueReductionArmingApp(const std::optional<float> armingApp) {
|
|
||||||
if (armingApp.has_value()) {
|
|
||||||
engineConfiguration->torqueReductionArmingApp = armingApp.value();
|
|
||||||
} else {
|
|
||||||
ASSERT_EQ(
|
|
||||||
engineConfiguration->torqueReductionArmingApp,
|
|
||||||
engine_configuration_defaults::TORQUE_REDUCTION_ARMING_APP
|
|
||||||
); // check default value
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -20,6 +20,7 @@ public:
|
||||||
std::optional<float> getTorqueReductionTime() const { return m_torqueReductionTime; }
|
std::optional<float> getTorqueReductionTime() const { return m_torqueReductionTime; }
|
||||||
std::optional<float> getTorqueReductionArmingRpm() const { return m_torqueReductionArmingRpm; }
|
std::optional<float> getTorqueReductionArmingRpm() const { return m_torqueReductionArmingRpm; }
|
||||||
std::optional<float> getTorqueReductionArmingApp() const { return m_torqueReductionArmingApp; }
|
std::optional<float> getTorqueReductionArmingApp() const { return m_torqueReductionArmingApp; }
|
||||||
|
std::optional<int8_t> getTorqueReductionIgnitionCut() const { return m_torqueReductionIgnitionCut; }
|
||||||
|
|
||||||
// We do not core about performance in tests, but we want to use builder-like style, so setters return new instance
|
// We do not core about performance in tests, but we want to use builder-like style, so setters return new instance
|
||||||
// of configuration:
|
// of configuration:
|
||||||
|
@ -35,6 +36,7 @@ public:
|
||||||
ShiftTorqueReductionTestConfig setTorqueReductionTime(std::optional<float> value);
|
ShiftTorqueReductionTestConfig setTorqueReductionTime(std::optional<float> value);
|
||||||
ShiftTorqueReductionTestConfig setTorqueReductionArmingRpm(std::optional<float> value);
|
ShiftTorqueReductionTestConfig setTorqueReductionArmingRpm(std::optional<float> value);
|
||||||
ShiftTorqueReductionTestConfig setTorqueReductionArmingApp(std::optional<float> value);
|
ShiftTorqueReductionTestConfig setTorqueReductionArmingApp(std::optional<float> value);
|
||||||
|
ShiftTorqueReductionTestConfig setTorqueReductionIgnitionCut(std::optional<int8_t> value);
|
||||||
private:
|
private:
|
||||||
std::optional<bool> m_isTorqueReductionEnabled;
|
std::optional<bool> m_isTorqueReductionEnabled;
|
||||||
std::optional<torqueReductionActivationMode_e> m_torqueReductionActivationMode;
|
std::optional<torqueReductionActivationMode_e> m_torqueReductionActivationMode;
|
||||||
|
@ -46,20 +48,10 @@ private:
|
||||||
std::optional<float> m_torqueReductionTime;
|
std::optional<float> m_torqueReductionTime;
|
||||||
std::optional<float> m_torqueReductionArmingRpm;
|
std::optional<float> m_torqueReductionArmingRpm;
|
||||||
std::optional<float> m_torqueReductionArmingApp;
|
std::optional<float> m_torqueReductionArmingApp;
|
||||||
|
std::optional<int8_t> m_torqueReductionIgnitionCut;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ShiftTorqueReductionTestBase : public TestBase {
|
class ShiftTorqueReductionTestBase : public TestBase {
|
||||||
protected:
|
protected:
|
||||||
void setUpTestConfig(const ShiftTorqueReductionTestConfig& config);
|
void setUpTestConfig(const ShiftTorqueReductionTestConfig& config);
|
||||||
private:
|
|
||||||
void configureTorqueReductionEnabled(std::optional<bool> isTorqueReductionEnabled);
|
|
||||||
void configureTorqueReductionActivationMode(std::optional<torqueReductionActivationMode_e> activationMode);
|
|
||||||
void configureTorqueReductionButton(std::optional<switch_input_pin_e> pin);
|
|
||||||
void configureTorqueReductionButtonInverted(std::optional<bool> pinInverted);
|
|
||||||
void configureLaunchActivatePin(std::optional<switch_input_pin_e> pin);
|
|
||||||
void configureLaunchActivateInverted(std::optional<bool> pinInverted);
|
|
||||||
void configureLimitTorqueReductionTime(std::optional<bool> limitTorqueReductionTime);
|
|
||||||
void configureTorqueReductionTime(std::optional<float> timeout);
|
|
||||||
void configureTorqueReductionArmingRpm(std::optional<float> armingRpm);
|
|
||||||
void configureTorqueReductionArmingApp(std::optional<float> armingApp);
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
//
|
||||||
|
// Created by kifir on 11/4/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
|
|
||||||
|
#include "flat_shift_condition_test_base.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
constexpr float TEST_LUA_SOFT_SPARK_SKIP = 1.23f;
|
||||||
|
constexpr float TEST_LUA_HARD_SPARK_SKIP = 4.56f;
|
||||||
|
|
||||||
|
constexpr int8_t TEST_TORQUE_REDUCTION_IGNITION_CUT = 17;
|
||||||
|
|
||||||
|
class ShiftTorqueReductionSparkSkipRatioTest : public FlatShiftConditionTestBase {
|
||||||
|
protected:
|
||||||
|
ShiftTorqueReductionSparkSkipRatioTest();
|
||||||
|
|
||||||
|
void SetUp() override;
|
||||||
|
|
||||||
|
void checkTargetSkipRatios(
|
||||||
|
const char* context,
|
||||||
|
float expectedHardSparkLimiterTargetSkipRatio = TEST_LUA_HARD_SPARK_SKIP
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
ShiftTorqueReductionSparkSkipRatioTest::ShiftTorqueReductionSparkSkipRatioTest()
|
||||||
|
: FlatShiftConditionTestBase(TEST_TORQUE_REDUCTION_IGNITION_CUT) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShiftTorqueReductionSparkSkipRatioTest::SetUp() {
|
||||||
|
FlatShiftConditionTestBase::SetUp();
|
||||||
|
|
||||||
|
getTestEngineState().setLuaSoftSparkSkip(TEST_LUA_SOFT_SPARK_SKIP);
|
||||||
|
getTestEngineState().setLuaHardSparkSkip(TEST_LUA_HARD_SPARK_SKIP);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShiftTorqueReductionSparkSkipRatioTest::checkTargetSkipRatios(
|
||||||
|
const char* const context,
|
||||||
|
const float expectedHardSparkLimiterTargetSkipRatio
|
||||||
|
) {
|
||||||
|
periodicFastCallback();
|
||||||
|
EXPECT_EQ(engine->softSparkLimiter.getTargetSkipRatio(), TEST_LUA_SOFT_SPARK_SKIP) << context;
|
||||||
|
EXPECT_EQ(engine->hardSparkLimiter.getTargetSkipRatio(), expectedHardSparkLimiterTargetSkipRatio) << context;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ShiftTorqueReductionSparkSkipRatioTest, checkHardSparkLimiterTargetSkipRatio) {
|
||||||
|
checkTargetSkipRatios("Initial state");
|
||||||
|
|
||||||
|
satisfyFlatShiftCondition();
|
||||||
|
checkTargetSkipRatios(
|
||||||
|
"Flat Shift condition is satisfied",
|
||||||
|
TEST_LUA_HARD_SPARK_SKIP + TEST_TORQUE_REDUCTION_IGNITION_CUT / 100.0f
|
||||||
|
);
|
||||||
|
|
||||||
|
unsatisfyFlatShiftCondition();
|
||||||
|
checkTargetSkipRatios("Flat Shift condition is not satisfied");
|
||||||
|
}
|
||||||
|
}
|
|
@ -49,20 +49,24 @@ TESTS_SRC_CPP = \
|
||||||
tests/ignition_injection/test_odd_firing_engine.cpp \
|
tests/ignition_injection/test_odd_firing_engine.cpp \
|
||||||
tests/ignition_injection/test_three_cylinder.cpp \
|
tests/ignition_injection/test_three_cylinder.cpp \
|
||||||
tests/util/test_base.cpp \
|
tests/util/test_base.cpp \
|
||||||
|
tests/util/test_engine_configuration.cpp \
|
||||||
|
tests/util/test_engine_state.cpp \
|
||||||
tests/ac/ac_test_base.cpp \
|
tests/ac/ac_test_base.cpp \
|
||||||
tests/ac/ac_pressure_test.cpp \
|
tests/ac/ac_pressure_test.cpp \
|
||||||
tests/launch/launch_test_base.cpp \
|
tests/launch/launch_test_base.cpp \
|
||||||
tests/launch/test_target_skip_ratio.cpp \
|
tests/launch/test_launch_target_skip_ratio.cpp \
|
||||||
tests/launch/test_rpm_condition.cpp \
|
tests/launch/test_rpm_condition.cpp \
|
||||||
tests/launch/test_retard_threshold_rpm.cpp \
|
tests/launch/test_retard_threshold_rpm.cpp \
|
||||||
tests/launch/test_ignition_angle_advance.cpp \
|
tests/launch/test_ignition_angle_advance.cpp \
|
||||||
tests/launch/test_spark_skip_ratio.cpp \
|
tests/launch/test_spark_skip_ratio.cpp \
|
||||||
tests/shift_torque_reduction/shift_torque_reduction_test_base.cpp \
|
tests/shift_torque_reduction/shift_torque_reduction_test_base.cpp \
|
||||||
|
tests/shift_torque_reduction/flat_shift_condition_test_base.cpp \
|
||||||
tests/shift_torque_reduction/test_shift_torque_reduction_trigger_pin_state.cpp \
|
tests/shift_torque_reduction/test_shift_torque_reduction_trigger_pin_state.cpp \
|
||||||
tests/shift_torque_reduction/test_shift_torque_reduction_time_condition.cpp \
|
tests/shift_torque_reduction/test_shift_torque_reduction_time_condition.cpp \
|
||||||
tests/shift_torque_reduction/test_shift_torque_reduction_rpm_condition.cpp \
|
tests/shift_torque_reduction/test_shift_torque_reduction_rpm_condition.cpp \
|
||||||
tests/shift_torque_reduction/test_shift_torque_reduction_app_condition.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_flat_shift_condition.cpp \
|
||||||
|
tests/shift_torque_reduction/test_shift_torque_reduction_spark_skip_ratio.cpp \
|
||||||
tests/test_fft.cpp \
|
tests/test_fft.cpp \
|
||||||
tests/lua/test_lua_basic.cpp \
|
tests/lua/test_lua_basic.cpp \
|
||||||
tests/lua/test_lookup.cpp \
|
tests/lua/test_lookup.cpp \
|
||||||
|
|
|
@ -14,6 +14,14 @@ void TestBase::TearDown() {
|
||||||
eth.reset();
|
eth.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TestEngineConfiguration& TestBase::getTestEngineConfiguration() {
|
||||||
|
return TestEngineConfiguration::getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
TestEngineState& TestBase::getTestEngineState() {
|
||||||
|
return TestEngineState::getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
void TestBase::periodicFastCallback() {
|
void TestBase::periodicFastCallback() {
|
||||||
// run the ignition math
|
// run the ignition math
|
||||||
engine->periodicFastCallback();
|
engine->periodicFastCallback();
|
||||||
|
|
|
@ -4,12 +4,17 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "test_engine_configuration.h"
|
||||||
|
#include "test_engine_state.h"
|
||||||
|
|
||||||
class TestBase : public testing::Test {
|
class TestBase : public testing::Test {
|
||||||
protected:
|
protected:
|
||||||
void SetUp() override;
|
void SetUp() override;
|
||||||
void TearDown() override;
|
void TearDown() override;
|
||||||
|
|
||||||
|
TestEngineConfiguration& getTestEngineConfiguration();
|
||||||
|
TestEngineState& getTestEngineState();
|
||||||
|
|
||||||
void periodicFastCallback();
|
void periodicFastCallback();
|
||||||
void periodicSlowCallback();
|
void periodicSlowCallback();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,223 @@
|
||||||
|
//
|
||||||
|
// Created by kifir on 11/4/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
|
|
||||||
|
#include "test_engine_configuration.h"
|
||||||
|
|
||||||
|
#include "engine_configuration_defaults.h"
|
||||||
|
|
||||||
|
TestEngineConfiguration& TestEngineConfiguration::getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureLaunchControlEnabled(const std::optional<bool> launchControlEnabled) {
|
||||||
|
if (launchControlEnabled.has_value()) {
|
||||||
|
engineConfiguration->launchControlEnabled = launchControlEnabled.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_FALSE(engineConfiguration->launchControlEnabled); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureLaunchRpm(const std::optional<int> launchRpm) {
|
||||||
|
if (launchRpm.has_value()) {
|
||||||
|
engineConfiguration->launchRpm = launchRpm.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_EQ(engineConfiguration->launchRpm, 0); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureLaunchRpmWindow(const std::optional<int> launchRpmWindow) {
|
||||||
|
if (launchRpmWindow.has_value()) {
|
||||||
|
engineConfiguration->launchRpmWindow = launchRpmWindow.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_EQ(engineConfiguration->launchRpmWindow, 0); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureLaunchCorrectionsEndRpm(const std::optional<int> launchCorrectionsEndRpm) {
|
||||||
|
if (launchCorrectionsEndRpm.has_value()) {
|
||||||
|
engineConfiguration->launchCorrectionsEndRpm = launchCorrectionsEndRpm.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_EQ(engineConfiguration->launchCorrectionsEndRpm, 0); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureIgnitionRetardEnable(std::optional<bool> ignitionRetardEnable) {
|
||||||
|
if (ignitionRetardEnable.has_value()) {
|
||||||
|
engineConfiguration->enableLaunchRetard = ignitionRetardEnable.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_FALSE(engineConfiguration->enableLaunchRetard); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureIgnitionRetard(std::optional<float> ignitionRetard) {
|
||||||
|
if (ignitionRetard.has_value()) {
|
||||||
|
engineConfiguration->launchTimingRetard = ignitionRetard.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_EQ(engineConfiguration->launchTimingRetard, 0); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureSmoothRetardMode(std::optional<bool> smoothRetardMode) {
|
||||||
|
if (smoothRetardMode.has_value()) {
|
||||||
|
engineConfiguration->launchSmoothRetard = smoothRetardMode.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_FALSE(engineConfiguration->launchSmoothRetard); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureEnableIgnitionCut(const std::optional<bool> enableIgnitionCut) {
|
||||||
|
if (enableIgnitionCut.has_value()) {
|
||||||
|
engineConfiguration->launchSparkCutEnable = enableIgnitionCut.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_FALSE(engineConfiguration->launchSparkCutEnable); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureInitialIgnitionCutPercent(const std::optional<int> initialIgnitionCutPercent) {
|
||||||
|
if (initialIgnitionCutPercent.has_value()) {
|
||||||
|
engineConfiguration->initialIgnitionCutPercent = initialIgnitionCutPercent.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_EQ(engineConfiguration->initialIgnitionCutPercent, 0); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureFinalIgnitionCutPercentBeforeLaunch(
|
||||||
|
const std::optional<int> finalIgnitionCutPercentBeforeLaunch
|
||||||
|
) {
|
||||||
|
if (finalIgnitionCutPercentBeforeLaunch.has_value()) {
|
||||||
|
engineConfiguration->finalIgnitionCutPercentBeforeLaunch = finalIgnitionCutPercentBeforeLaunch.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_EQ(engineConfiguration->finalIgnitionCutPercentBeforeLaunch, 0); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureTorqueReductionEnabled(const std::optional<bool> torqueReductionEnabled) {
|
||||||
|
if (torqueReductionEnabled.has_value()) {
|
||||||
|
engineConfiguration->torqueReductionEnabled = torqueReductionEnabled.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_EQ(
|
||||||
|
engineConfiguration->torqueReductionEnabled,
|
||||||
|
engine_configuration_defaults::ENABLE_SHIFT_TORQUE_REDUCTION
|
||||||
|
); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureTorqueReductionActivationMode(
|
||||||
|
const std::optional<torqueReductionActivationMode_e> activationMode
|
||||||
|
) {
|
||||||
|
if (activationMode.has_value()) {
|
||||||
|
engineConfiguration->torqueReductionActivationMode = activationMode.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_EQ(
|
||||||
|
engineConfiguration->torqueReductionActivationMode,
|
||||||
|
engine_configuration_defaults::TORQUE_REDUCTION_ACTIVATION_MODE
|
||||||
|
); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureTorqueReductionButton(const std::optional<switch_input_pin_e> pin) {
|
||||||
|
if (pin.has_value()) {
|
||||||
|
engineConfiguration->torqueReductionTriggerPin = pin.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_EQ(
|
||||||
|
engineConfiguration->torqueReductionTriggerPin,
|
||||||
|
engine_configuration_defaults::TORQUE_REDUCTION_TRIGGER_PIN
|
||||||
|
); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureTorqueReductionButtonInverted(const std::optional<bool> pinInverted) {
|
||||||
|
if (pinInverted.has_value()) {
|
||||||
|
engineConfiguration->torqueReductionTriggerPinInverted = pinInverted.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_EQ(
|
||||||
|
engineConfiguration->torqueReductionTriggerPinInverted,
|
||||||
|
engine_configuration_defaults::TORQUE_REDUCTION_TRIGGER_PIN_INVERTED
|
||||||
|
); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureLaunchActivatePin(const std::optional<switch_input_pin_e> pin) {
|
||||||
|
if (pin.has_value()) {
|
||||||
|
engineConfiguration->launchActivatePin = pin.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_EQ(
|
||||||
|
engineConfiguration->launchActivatePin,
|
||||||
|
engine_configuration_defaults::LAUNCH_ACTIVATE_PIN
|
||||||
|
); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureLaunchActivateInverted(const std::optional<bool> pinInverted) {
|
||||||
|
if (pinInverted.has_value()) {
|
||||||
|
engineConfiguration->launchActivateInverted = pinInverted.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_EQ(
|
||||||
|
engineConfiguration->launchActivateInverted,
|
||||||
|
engine_configuration_defaults::LAUNCH_ACTIVATE_PIN_INVERTED
|
||||||
|
); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureLimitTorqueReductionTime(std::optional<bool> limitTorqueReductionTime) {
|
||||||
|
if (limitTorqueReductionTime.has_value()) {
|
||||||
|
engineConfiguration->limitTorqueReductionTime = limitTorqueReductionTime.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_EQ(
|
||||||
|
engineConfiguration->limitTorqueReductionTime,
|
||||||
|
engine_configuration_defaults::LIMIT_TORQUE_REDUCTION_TIME
|
||||||
|
); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureTorqueReductionTime(std::optional<float> timeout) {
|
||||||
|
if (timeout.has_value()) {
|
||||||
|
engineConfiguration->torqueReductionTime = timeout.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_EQ(
|
||||||
|
engineConfiguration->torqueReductionTime,
|
||||||
|
engine_configuration_defaults::TORQUE_REDUCTION_TIME
|
||||||
|
); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureTorqueReductionArmingRpm(const std::optional<float> armingRpm) {
|
||||||
|
if (armingRpm.has_value()) {
|
||||||
|
engineConfiguration->torqueReductionArmingRpm = armingRpm.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_EQ(
|
||||||
|
engineConfiguration->torqueReductionArmingRpm,
|
||||||
|
engine_configuration_defaults::TORQUE_REDUCTION_ARMING_RPM
|
||||||
|
); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureTorqueReductionArmingApp(const std::optional<float> armingApp) {
|
||||||
|
if (armingApp.has_value()) {
|
||||||
|
engineConfiguration->torqueReductionArmingApp = armingApp.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_EQ(
|
||||||
|
engineConfiguration->torqueReductionArmingApp,
|
||||||
|
engine_configuration_defaults::TORQUE_REDUCTION_ARMING_APP
|
||||||
|
); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineConfiguration::configureTorqueReductionIgnitionCut(const std::optional<int8_t> ignitionCut) {
|
||||||
|
if (ignitionCut.has_value()) {
|
||||||
|
engineConfiguration->torqueReductionIgnitionCut = ignitionCut.value();
|
||||||
|
} else {
|
||||||
|
ASSERT_EQ(
|
||||||
|
engineConfiguration->torqueReductionIgnitionCut,
|
||||||
|
engine_configuration_defaults::TORQUE_REDUCTION_IGNITION_CUT
|
||||||
|
); // check default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TestEngineConfiguration::TestEngineConfiguration() {
|
||||||
|
}
|
||||||
|
|
||||||
|
TestEngineConfiguration TestEngineConfiguration::instance;
|
|
@ -0,0 +1,43 @@
|
||||||
|
//
|
||||||
|
// Created by kifir on 11/4/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
|
|
||||||
|
class TestEngineConfiguration {
|
||||||
|
public:
|
||||||
|
static TestEngineConfiguration& getInstance();
|
||||||
|
|
||||||
|
// Launch Control Settings
|
||||||
|
void configureLaunchControlEnabled(std::optional<bool> launchControlEnabled);
|
||||||
|
|
||||||
|
void configureLaunchRpm(std::optional<int> launchRpm);
|
||||||
|
void configureLaunchRpmWindow(std::optional<int> launchRpmWindow);
|
||||||
|
void configureLaunchCorrectionsEndRpm(std::optional<int> launchCorrectionsEndRpm);
|
||||||
|
|
||||||
|
void configureIgnitionRetardEnable(std::optional<bool> ignitionRetardEnable);
|
||||||
|
void configureIgnitionRetard(std::optional<float> ignitionRetard);
|
||||||
|
void configureSmoothRetardMode(std::optional<bool> smoothRetardMode);
|
||||||
|
|
||||||
|
void configureEnableIgnitionCut(std::optional<bool> enableIgnitionCut);
|
||||||
|
void configureInitialIgnitionCutPercent(std::optional<int> initialIgnitionCut);
|
||||||
|
void configureFinalIgnitionCutPercentBeforeLaunch(std::optional<int> finalIgnitionCutBeforeLaunch);
|
||||||
|
|
||||||
|
// Shift Torque Reduction (Flat Shift)
|
||||||
|
void configureTorqueReductionEnabled(std::optional<bool> isTorqueReductionEnabled);
|
||||||
|
void configureTorqueReductionActivationMode(std::optional<torqueReductionActivationMode_e> activationMode);
|
||||||
|
void configureTorqueReductionButton(std::optional<switch_input_pin_e> pin);
|
||||||
|
void configureTorqueReductionButtonInverted(std::optional<bool> pinInverted);
|
||||||
|
void configureLaunchActivatePin(std::optional<switch_input_pin_e> pin);
|
||||||
|
void configureLaunchActivateInverted(std::optional<bool> pinInverted);
|
||||||
|
void configureLimitTorqueReductionTime(std::optional<bool> limitTorqueReductionTime);
|
||||||
|
void configureTorqueReductionTime(std::optional<float> timeout);
|
||||||
|
void configureTorqueReductionArmingRpm(std::optional<float> armingRpm);
|
||||||
|
void configureTorqueReductionArmingApp(std::optional<float> armingApp);
|
||||||
|
void configureTorqueReductionIgnitionCut(std::optional<int8_t> ignitionCut);
|
||||||
|
private:
|
||||||
|
TestEngineConfiguration();
|
||||||
|
static TestEngineConfiguration instance;
|
||||||
|
};
|
|
@ -0,0 +1,24 @@
|
||||||
|
//
|
||||||
|
// Created by kifir on 11/4/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
|
|
||||||
|
#include "test_engine_state.h"
|
||||||
|
|
||||||
|
TestEngineState& TestEngineState::getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineState::setLuaSoftSparkSkip(const float value) {
|
||||||
|
engine->engineState.luaSoftSparkSkip = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEngineState::setLuaHardSparkSkip(const float value) {
|
||||||
|
engine->engineState.luaHardSparkSkip = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
TestEngineState::TestEngineState() {
|
||||||
|
}
|
||||||
|
|
||||||
|
TestEngineState TestEngineState::instance;
|
|
@ -0,0 +1,16 @@
|
||||||
|
//
|
||||||
|
// Created by kifir on 11/4/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class TestEngineState {
|
||||||
|
public:
|
||||||
|
static TestEngineState& getInstance();
|
||||||
|
|
||||||
|
void setLuaSoftSparkSkip(float value);
|
||||||
|
void setLuaHardSparkSkip(float value);
|
||||||
|
private:
|
||||||
|
TestEngineState();
|
||||||
|
static TestEngineState instance;
|
||||||
|
};
|
Loading…
Reference in New Issue