implement RPM condition monitoring #5608
This commit is contained in:
parent
639d738390
commit
e657eb3cf0
|
@ -17,6 +17,7 @@ void ShiftTorqueReductionController::update() {
|
|||
if (engineConfiguration->torqueReductionEnabled) {
|
||||
updateTriggerPinState();
|
||||
updateTimeConditionSatisfied();
|
||||
updateRpmConditionSatisfied();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,4 +65,9 @@ void ShiftTorqueReductionController::updateTimeConditionSatisfied() {
|
|||
: false;
|
||||
}
|
||||
|
||||
void ShiftTorqueReductionController::updateRpmConditionSatisfied() {
|
||||
const float currentRpm = Sensor::getOrZero(SensorType::Rpm);
|
||||
isRpmConditionSatisfied = (engineConfiguration->torqueReductionArmingRpm <= currentRpm);
|
||||
}
|
||||
|
||||
#endif // EFI_LAUNCH_CONTROL
|
|
@ -14,6 +14,7 @@ private:
|
|||
void updateTriggerPinState(switch_input_pin_e pin, bool isPinInverted);
|
||||
|
||||
void updateTimeConditionSatisfied();
|
||||
void updateRpmConditionSatisfied();
|
||||
|
||||
Timer m_pinTriggeredTimer;
|
||||
};
|
||||
|
|
|
@ -3,5 +3,6 @@ struct_no_prefix shift_torque_reduction_state_s
|
|||
bit isTorqueReductionTriggerPinValid
|
||||
bit torqueReductionTriggerPinState
|
||||
bit isTimeConditionSatisfied
|
||||
bit isRpmConditionSatisfied
|
||||
|
||||
end_struct
|
||||
|
|
|
@ -54,6 +54,11 @@ ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setTorqueReductio
|
|||
return *this;
|
||||
}
|
||||
|
||||
ShiftTorqueReductionTestConfig ShiftTorqueReductionTestConfig::setTorqueReductionArmingRpm(std::optional<float> value) {
|
||||
m_torqueReductionArmingRpm = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void ShiftTorqueReductionTestBase::setUpTestConfig(const ShiftTorqueReductionTestConfig& config) {
|
||||
configureTorqueReductionEnabled(config.getTorqueReductionEnabled());
|
||||
configureTorqueReductionActivationMode(config.getTorqueReductionActivationMode());
|
||||
|
@ -62,6 +67,7 @@ void ShiftTorqueReductionTestBase::setUpTestConfig(const ShiftTorqueReductionTes
|
|||
configureLaunchActivatePin(config.getLaunchActivatePin());
|
||||
configureLaunchActivateInverted(config.getLaunchActivateInverted());
|
||||
configureTorqueReductionTime(config.getTorqueReductionTime());
|
||||
configureTorqueReductionArmingRpm(config.getTorqueReductionArmingRpm());
|
||||
}
|
||||
|
||||
void ShiftTorqueReductionTestBase::configureTorqueReductionEnabled(const std::optional<bool> torqueReductionEnabled) {
|
||||
|
@ -141,4 +147,15 @@ void ShiftTorqueReductionTestBase::configureTorqueReductionTime(std::optional<fl
|
|||
engine_configuration_defaults::TORQUE_REDUCTION_TIME
|
||||
); // check default value
|
||||
}
|
||||
}
|
||||
|
||||
void ShiftTorqueReductionTestBase::configureTorqueReductionArmingRpm(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
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ public:
|
|||
std::optional<switch_input_pin_e> getLaunchActivatePin() const { return m_launchActivatePin; }
|
||||
std::optional<bool> getLaunchActivateInverted() const { return m_launchActivateInverted; }
|
||||
std::optional<float> getTorqueReductionTime() const { return m_torqueReductionTime; }
|
||||
std::optional<float> getTorqueReductionArmingRpm() const { return m_torqueReductionArmingRpm; }
|
||||
|
||||
// We do not core about performance in tests, but we want to use builder-like style, so setters return new instance
|
||||
// of configuration:
|
||||
|
@ -29,6 +30,7 @@ public:
|
|||
ShiftTorqueReductionTestConfig setLaunchActivatePin(std::optional<switch_input_pin_e> value);
|
||||
ShiftTorqueReductionTestConfig setLaunchActivateInverted(std::optional<bool> value);
|
||||
ShiftTorqueReductionTestConfig setTorqueReductionTime(std::optional<float> value);
|
||||
ShiftTorqueReductionTestConfig setTorqueReductionArmingRpm(std::optional<float> value);
|
||||
private:
|
||||
std::optional<bool> m_isTorqueReductionEnabled;
|
||||
std::optional<torqueReductionActivationMode_e> m_torqueReductionActivationMode;
|
||||
|
@ -37,6 +39,7 @@ private:
|
|||
std::optional<switch_input_pin_e> m_launchActivatePin;
|
||||
std::optional<bool> m_launchActivateInverted;
|
||||
std::optional<float> m_torqueReductionTime;
|
||||
std::optional<float> m_torqueReductionArmingRpm;
|
||||
};
|
||||
|
||||
class ShiftTorqueReductionTestBase : public TestBase {
|
||||
|
@ -50,4 +53,5 @@ private:
|
|||
void configureLaunchActivatePin(std::optional<switch_input_pin_e> pin);
|
||||
void configureLaunchActivateInverted(std::optional<bool> pinInverted);
|
||||
void configureTorqueReductionTime(std::optional<float> timeout);
|
||||
void configureTorqueReductionArmingRpm(std::optional<float> armingRpm);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
//
|
||||
// Created by kifir on 10/3/24.
|
||||
//
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
#include "shift_torque_reduction_test_base.h"
|
||||
|
||||
namespace {
|
||||
constexpr float TEST_TORQUE_REDUCTION_ARMING_RPM = 239.0f;
|
||||
|
||||
class ShiftTorqueReductionRpmConditionTest : public ShiftTorqueReductionTestBase {
|
||||
protected:
|
||||
void checkRpmCondition(float rpm, bool expectedRpmCondition, const char* context);
|
||||
};
|
||||
|
||||
void ShiftTorqueReductionRpmConditionTest::checkRpmCondition(
|
||||
const float rpm,
|
||||
const bool expectedRpmCondition,
|
||||
const char* const context
|
||||
) {
|
||||
updateRpm(rpm);
|
||||
EXPECT_EQ(engine->shiftTorqueReductionController.isRpmConditionSatisfied, expectedRpmCondition) << context;
|
||||
}
|
||||
|
||||
TEST_F(ShiftTorqueReductionRpmConditionTest, checkZeroArmingRpm) {
|
||||
setUpTestConfig(ShiftTorqueReductionTestConfig()
|
||||
.setTorqueReductionEnabled(true)
|
||||
.setTorqueReductionArmingRpm(0.0f)
|
||||
);
|
||||
checkRpmCondition(0.0f, true, "Zero RPM");
|
||||
checkRpmCondition(TEST_TORQUE_REDUCTION_ARMING_RPM, true, "Non-zero RPM");
|
||||
}
|
||||
|
||||
TEST_F(ShiftTorqueReductionRpmConditionTest, checkArmingRpm) {
|
||||
setUpTestConfig(ShiftTorqueReductionTestConfig()
|
||||
.setTorqueReductionEnabled(true)
|
||||
.setTorqueReductionArmingRpm(TEST_TORQUE_REDUCTION_ARMING_RPM)
|
||||
);
|
||||
checkRpmCondition(0.0f, false, "Zero RPM");
|
||||
checkRpmCondition(TEST_TORQUE_REDUCTION_ARMING_RPM - EPS5D, false, "Below arming RPM");
|
||||
checkRpmCondition(TEST_TORQUE_REDUCTION_ARMING_RPM, true, "Exact arming RPM");
|
||||
checkRpmCondition(TEST_TORQUE_REDUCTION_ARMING_RPM + EPS5D, true, "Above arming RPM");
|
||||
}
|
||||
}
|
|
@ -60,6 +60,7 @@ TESTS_SRC_CPP = \
|
|||
tests/shift_torque_reduction/shift_torque_reduction_test_base.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_rpm_condition.cpp \
|
||||
tests/lua/test_lua_basic.cpp \
|
||||
tests/lua/test_lookup.cpp \
|
||||
tests/lua/test_lua_e38.cpp \
|
||||
|
|
Loading…
Reference in New Issue