parent
8e7596acc4
commit
2ae85de636
|
@ -93,7 +93,7 @@ float IdleController::getCrankingOpenLoop(float clt) const {
|
|||
return engineConfiguration->crankingIACposition * mult;
|
||||
}
|
||||
|
||||
percent_t IdleController::getRunningOpenLoop(float rpm, float clt, SensorResult tps) {
|
||||
percent_t IdleController::getRunningOpenLoop(int phaseXXX, float rpm, float clt, SensorResult tps) {
|
||||
float running =
|
||||
engineConfiguration->manIdlePosition // Base idle position (slider)
|
||||
* interpolate2d(clt, config->cltIdleCorrBins, config->cltIdleCorr);
|
||||
|
@ -148,7 +148,7 @@ percent_t IdleController::getOpenLoop(Phase phase, float rpm, float clt, SensorR
|
|||
return interpolate2d(rpm, config->iacCoastingRpmBins, config->iacCoasting);
|
||||
}
|
||||
|
||||
percent_t running = getRunningOpenLoop(rpm, clt, tps);
|
||||
percent_t running = getRunningOpenLoop(/*phase*/0, rpm, clt, tps);
|
||||
|
||||
// Interpolate between cranking and running over a short time
|
||||
// This clamps once you fall off the end, so no explicit check for >1 required
|
||||
|
|
|
@ -27,7 +27,7 @@ struct IIdleController {
|
|||
virtual Phase determinePhase(int rpm, int targetRpm, SensorResult tps, float vss, float crankingTaperFraction) = 0;
|
||||
virtual int getTargetRpm(float clt) = 0;
|
||||
virtual float getCrankingOpenLoop(float clt) const = 0;
|
||||
virtual float getRunningOpenLoop(float rpm, float clt, SensorResult tps) = 0;
|
||||
virtual float getRunningOpenLoop(int phaseXXX, float rpm, float clt, SensorResult tps) = 0;
|
||||
virtual float getOpenLoop(Phase phase, float rpm, float clt, SensorResult tps, float crankingTaperFraction) = 0;
|
||||
virtual float getClosedLoop(Phase phase, float tps, int rpm, int target) = 0;
|
||||
virtual float getCrankingTaperFraction() const = 0;
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
|
||||
// OPEN LOOP CORRECTIONS
|
||||
percent_t getCrankingOpenLoop(float clt) const override;
|
||||
percent_t getRunningOpenLoop(float rpm, float clt, SensorResult tps) override;
|
||||
percent_t getRunningOpenLoop(int phaseXXX, float rpm, float clt, SensorResult tps) override;
|
||||
percent_t getOpenLoop(Phase phase, float rpm, float clt, SensorResult tps, float crankingTaperFraction) override;
|
||||
|
||||
float getIdleTimingAdjustment(int rpm) override;
|
||||
|
|
|
@ -127,7 +127,7 @@ class MockIdleController : public IIdleController {
|
|||
MOCK_METHOD(IIdleController::Phase, determinePhase, (int rpm, int targetRpm, SensorResult tps, float vss, float crankingTaperFraction), (override));
|
||||
MOCK_METHOD(int, getTargetRpm, (float clt), (override));
|
||||
MOCK_METHOD(float, getCrankingOpenLoop, (float clt), (const, override));
|
||||
MOCK_METHOD(float, getRunningOpenLoop, (float rpm, float clt, SensorResult tps), (override));
|
||||
MOCK_METHOD(float, getRunningOpenLoop, (int phaseXXX, float rpm, float clt, SensorResult tps), (override));
|
||||
MOCK_METHOD(float, getOpenLoop, (IIdleController::Phase phase, float rpm, float clt, SensorResult tps, float crankingTaperFraction), (override));
|
||||
MOCK_METHOD(float, getClosedLoop, (IIdleController::Phase phase, float tps, int rpm, int target), (override));
|
||||
MOCK_METHOD(float, getCrankingTaperFraction, (), (const, override));
|
||||
|
|
|
@ -143,8 +143,8 @@ TEST(idle_v2, runningOpenLoopBasic) {
|
|||
config->cltIdleCorr[i] = i * 0.1f;
|
||||
}
|
||||
|
||||
EXPECT_FLOAT_EQ(5, dut.getRunningOpenLoop(0, 10, 0));
|
||||
EXPECT_FLOAT_EQ(25, dut.getRunningOpenLoop(0, 50, 0));
|
||||
EXPECT_FLOAT_EQ(5, dut.getRunningOpenLoop(/*phase*/0, 0, 10, 0));
|
||||
EXPECT_FLOAT_EQ(25, dut.getRunningOpenLoop(/*phase*/0, 0, 50, 0));
|
||||
}
|
||||
|
||||
TEST(idle_v2, runningFanAcBump) {
|
||||
|
@ -162,27 +162,27 @@ TEST(idle_v2, runningFanAcBump) {
|
|||
enginePins.fanRelay.setValue(0);
|
||||
|
||||
// Should be base position
|
||||
EXPECT_FLOAT_EQ(50, dut.getRunningOpenLoop(0, 10, 0));
|
||||
EXPECT_FLOAT_EQ(50, dut.getRunningOpenLoop(/*phase*/0, 0, 10, 0));
|
||||
|
||||
// Turn on AC!
|
||||
engine->module<AcController>()->acButtonState = true;
|
||||
EXPECT_FLOAT_EQ(50 + 9, dut.getRunningOpenLoop(0, 10, 0));
|
||||
EXPECT_FLOAT_EQ(50 + 9, dut.getRunningOpenLoop(/*phase*/0, 0, 10, 0));
|
||||
engine->module<AcController>()->acButtonState = false;
|
||||
|
||||
// Turn the fan on!
|
||||
enginePins.fanRelay.setValue(1);
|
||||
EXPECT_FLOAT_EQ(50 + 7, dut.getRunningOpenLoop(0, 10, 0));
|
||||
EXPECT_FLOAT_EQ(50 + 7, dut.getRunningOpenLoop(/*phase*/0, 0, 10, 0));
|
||||
enginePins.fanRelay.setValue(0);
|
||||
|
||||
// Turn on the other fan!
|
||||
enginePins.fanRelay2.setValue(1);
|
||||
EXPECT_FLOAT_EQ(50 + 3, dut.getRunningOpenLoop(0, 10, 0));
|
||||
EXPECT_FLOAT_EQ(50 + 3, dut.getRunningOpenLoop(/*phase*/0, 0, 10, 0));
|
||||
|
||||
// Turn on everything!
|
||||
engine->module<AcController>()->acButtonState = true;
|
||||
enginePins.fanRelay.setValue(1);
|
||||
enginePins.fanRelay2.setValue(1);
|
||||
EXPECT_FLOAT_EQ(50 + 9 + 7 + 3, dut.getRunningOpenLoop(0, 10, 0));
|
||||
EXPECT_FLOAT_EQ(50 + 9 + 7 + 3, dut.getRunningOpenLoop(/*phase*/0, 0, 10, 0));
|
||||
}
|
||||
|
||||
TEST(idle_v2, runningOpenLoopTpsTaper) {
|
||||
|
@ -198,13 +198,13 @@ TEST(idle_v2, runningOpenLoopTpsTaper) {
|
|||
engineConfiguration->idlePidDeactivationTpsThreshold = 10;
|
||||
|
||||
// Check in-bounds points
|
||||
EXPECT_FLOAT_EQ(0, dut.getRunningOpenLoop(0, 0, 0));
|
||||
EXPECT_FLOAT_EQ(25, dut.getRunningOpenLoop(0, 0, 5));
|
||||
EXPECT_FLOAT_EQ(50, dut.getRunningOpenLoop(0, 0, 10));
|
||||
EXPECT_FLOAT_EQ(0, dut.getRunningOpenLoop(/*phase*/0, 0, 0, 0));
|
||||
EXPECT_FLOAT_EQ(25, dut.getRunningOpenLoop(/*phase*/0, 0, 0, 5));
|
||||
EXPECT_FLOAT_EQ(50, dut.getRunningOpenLoop(/*phase*/0, 0, 0, 10));
|
||||
|
||||
// Check out of bounds - shouldn't leave the interval [0, 10]
|
||||
EXPECT_FLOAT_EQ(0, dut.getRunningOpenLoop(0, 0, -5));
|
||||
EXPECT_FLOAT_EQ(50, dut.getRunningOpenLoop(0, 0, 20));
|
||||
EXPECT_FLOAT_EQ(0, dut.getRunningOpenLoop(/*phase*/0, 0, 0, -5));
|
||||
EXPECT_FLOAT_EQ(50, dut.getRunningOpenLoop(/*phase*/0, 0, 0, 20));
|
||||
}
|
||||
|
||||
TEST(idle_v2, runningOpenLoopRpmTaper) {
|
||||
|
@ -221,18 +221,18 @@ TEST(idle_v2, runningOpenLoopRpmTaper) {
|
|||
engineConfiguration->idlePidRpmUpperLimit = 1500;
|
||||
|
||||
// Check in-bounds points
|
||||
EXPECT_FLOAT_EQ(0, dut.getRunningOpenLoop(1500, 0, 0));
|
||||
EXPECT_FLOAT_EQ(25, dut.getRunningOpenLoop(1750, 0, 0));
|
||||
EXPECT_FLOAT_EQ(50, dut.getRunningOpenLoop(2000, 0, 0));
|
||||
EXPECT_FLOAT_EQ(0, dut.getRunningOpenLoop(/*phase*/0, 1500, 0, 0));
|
||||
EXPECT_FLOAT_EQ(25, dut.getRunningOpenLoop(/*phase*/0, 1750, 0, 0));
|
||||
EXPECT_FLOAT_EQ(50, dut.getRunningOpenLoop(/*phase*/0, 2000, 0, 0));
|
||||
|
||||
// Check out of bounds - shouldn't leave the interval [1500, 2000]
|
||||
EXPECT_FLOAT_EQ(0, dut.getRunningOpenLoop(200, 0, 0));
|
||||
EXPECT_FLOAT_EQ(50, dut.getRunningOpenLoop(3000, 0, 0));
|
||||
EXPECT_FLOAT_EQ(0, dut.getRunningOpenLoop(/*phase*/0, 200, 0, 0));
|
||||
EXPECT_FLOAT_EQ(50, dut.getRunningOpenLoop(/*phase*/0, 3000, 0, 0));
|
||||
}
|
||||
|
||||
struct MockOpenLoopIdler : public IdleController {
|
||||
MOCK_METHOD(float, getCrankingOpenLoop, (float clt), (const, override));
|
||||
MOCK_METHOD(float, getRunningOpenLoop, (float rpm, float clt, SensorResult tps), (override));
|
||||
MOCK_METHOD(float, getRunningOpenLoop, (int phaseXXX, float rpm, float clt, SensorResult tps), (override));
|
||||
};
|
||||
|
||||
TEST(idle_v2, testOpenLoopCranking) {
|
||||
|
@ -251,7 +251,7 @@ TEST(idle_v2, openLoopRunningTaper) {
|
|||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
||||
StrictMock<MockOpenLoopIdler> dut;
|
||||
|
||||
EXPECT_CALL(dut, getRunningOpenLoop(0, 30, SensorResult(0))).WillRepeatedly(Return(25));
|
||||
EXPECT_CALL(dut, getRunningOpenLoop(/*phase*/0, 0, 30, SensorResult(0))).WillRepeatedly(Return(25));
|
||||
EXPECT_CALL(dut, getCrankingOpenLoop(30)).WillRepeatedly(Return(75));
|
||||
|
||||
// 0 cycles - no taper yet, pure cranking value
|
||||
|
|
Loading…
Reference in New Issue