implement hysterisis functionality for ignition and fuel cut #5610
This commit is contained in:
parent
8a4f53214b
commit
af6786e237
|
@ -73,21 +73,37 @@ bool LaunchControlBase::isInsideTpsCondition() const {
|
|||
return engineConfiguration->launchTpsThreshold < tps.Value;
|
||||
}
|
||||
|
||||
LaunchCondition LaunchControlBase::calculateRPMLaunchCondition(const int rpm) const {
|
||||
LaunchCondition LaunchControlBase::calculateRPMLaunchCondition(const int rpm) {
|
||||
const int launchRpm = engineConfiguration->launchRpm;
|
||||
if (rpm < launchRpm) {
|
||||
const int preLaunchRpm = launchRpm - engineConfiguration->launchRpmWindow;
|
||||
if (rpm < preLaunchRpm) {
|
||||
return LaunchCondition::NotMet;
|
||||
} else {
|
||||
} else if (launchRpm <= rpm) {
|
||||
return LaunchCondition::Launch;
|
||||
} else {
|
||||
return LaunchCondition::PreLaunch;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Condition is true as soon as we are above LaunchRpm
|
||||
*/
|
||||
bool LaunchControlBase::isInsideRPMCondition(const int rpm) const {
|
||||
bool LaunchControlBase::isInsideRPMCondition(const int rpm) {
|
||||
const LaunchCondition rpmLaunchCondition = calculateRPMLaunchCondition(rpm);
|
||||
return rpmLaunchCondition == LaunchCondition::Launch;
|
||||
bool result = false;
|
||||
switch (rpmLaunchCondition) {
|
||||
case LaunchCondition::NotMet: {
|
||||
m_afterLaunch = false;
|
||||
break;
|
||||
}
|
||||
case LaunchCondition::PreLaunch: {
|
||||
result = m_afterLaunch;
|
||||
break;
|
||||
}
|
||||
case LaunchCondition::Launch: {
|
||||
m_afterLaunch = true;
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool LaunchControlBase::isLaunchConditionMet(const int rpm) {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
void initLaunchControl();
|
||||
|
||||
enum class LaunchCondition {
|
||||
PreLaunch,
|
||||
Launch,
|
||||
NotMet
|
||||
};
|
||||
|
@ -27,8 +28,8 @@ public:
|
|||
bool isInsideSpeedCondition() const;
|
||||
bool isInsideTpsCondition() const;
|
||||
bool isInsideSwitchCondition();
|
||||
LaunchCondition calculateRPMLaunchCondition(int rpm) const;
|
||||
bool isInsideRPMCondition(int rpm) const;
|
||||
LaunchCondition calculateRPMLaunchCondition(int rpm);
|
||||
bool isInsideRPMCondition(int rpm);
|
||||
bool isLaunchConditionMet(int rpm);
|
||||
|
||||
bool isLaunchSparkRpmRetardCondition() const;
|
||||
|
@ -38,6 +39,7 @@ private:
|
|||
bool isLaunchRpmRetardCondition() const;
|
||||
|
||||
Timer m_launchTimer;
|
||||
bool m_afterLaunch = false;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -78,8 +78,13 @@ TEST(LaunchControl, RPMCondition) {
|
|||
|
||||
engineConfiguration->launchRpm = 3000;
|
||||
|
||||
EXPECT_EQ(dut.calculateRPMLaunchCondition(2900), LaunchCondition::NotMet);
|
||||
EXPECT_EQ(engineConfiguration->launchRpmWindow, 500);
|
||||
|
||||
EXPECT_EQ(dut.calculateRPMLaunchCondition(2499), LaunchCondition::NotMet);
|
||||
EXPECT_EQ(dut.calculateRPMLaunchCondition(2500), LaunchCondition::PreLaunch);
|
||||
EXPECT_EQ(dut.calculateRPMLaunchCondition(2900), LaunchCondition::PreLaunch);
|
||||
EXPECT_EQ(dut.calculateRPMLaunchCondition(2999), LaunchCondition::PreLaunch);
|
||||
EXPECT_EQ(dut.calculateRPMLaunchCondition(3000), LaunchCondition::Launch);
|
||||
EXPECT_EQ(dut.calculateRPMLaunchCondition(3100), LaunchCondition::Launch);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue