mirror of https://github.com/FOME-Tech/fome-fw.git
only check throttle jam while ignition is on #489
This commit is contained in:
parent
877ec23c47
commit
64108b67cf
|
@ -479,6 +479,7 @@ expected<percent_t> EtbController::getClosedLoop(percent_t target, percent_t obs
|
||||||
return getClosedLoopAutotune(target, observation);
|
return getClosedLoopAutotune(target, observation);
|
||||||
} else {
|
} else {
|
||||||
checkJam(target, observation);
|
checkJam(target, observation);
|
||||||
|
|
||||||
// Normal case - use PID to compute closed loop part
|
// Normal case - use PID to compute closed loop part
|
||||||
return m_pid.getOutput(target, observation, etbPeriodSeconds);
|
return m_pid.getOutput(target, observation, etbPeriodSeconds);
|
||||||
}
|
}
|
||||||
|
@ -614,13 +615,12 @@ void EtbController::checkJam(percent_t setpoint, percent_t observation) {
|
||||||
if (jamDetectThreshold != 0) {
|
if (jamDetectThreshold != 0) {
|
||||||
auto nowNt = getTimeNowNt();
|
auto nowNt = getTimeNowNt();
|
||||||
|
|
||||||
if (absError > jamDetectThreshold) {
|
if (absError > jamDetectThreshold && engine->module<IgnitionController>()->getIgnState()) {
|
||||||
if (m_jamDetectTimer.hasElapsedSec(engineConfiguration->etbJamTimeout)) {
|
if (m_jamDetectTimer.hasElapsedSec(engineConfiguration->etbJamTimeout)) {
|
||||||
// ETB is jammed!
|
// ETB is jammed!
|
||||||
jamDetected = true;
|
jamDetected = true;
|
||||||
|
|
||||||
// TODO: do something about it!
|
getLimpManager()->reportEtbProblem();
|
||||||
// getLimpManager()->reportEtbProblem();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_jamDetectTimer.reset(nowNt);
|
m_jamDetectTimer.reset(nowNt);
|
||||||
|
|
|
@ -152,7 +152,7 @@ public:
|
||||||
AlternatorController,
|
AlternatorController,
|
||||||
#endif /* EFI_ALTERNATOR_CONTROL */
|
#endif /* EFI_ALTERNATOR_CONTROL */
|
||||||
MainRelayController,
|
MainRelayController,
|
||||||
IgnitionController,
|
Mockable<IgnitionController>,
|
||||||
Mockable<AcController>,
|
Mockable<AcController>,
|
||||||
PrimeController,
|
PrimeController,
|
||||||
DfcoController,
|
DfcoController,
|
||||||
|
|
|
@ -6,8 +6,14 @@
|
||||||
|
|
||||||
class IgnitionController : public EngineModule {
|
class IgnitionController : public EngineModule {
|
||||||
public:
|
public:
|
||||||
|
using interface_t = IgnitionController;
|
||||||
|
|
||||||
void onSlowCallback() override;
|
void onSlowCallback() override;
|
||||||
|
|
||||||
|
virtual bool getIgnState() const {
|
||||||
|
return m_lastState;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Timer m_timeSinceIgnVoltage;
|
Timer m_timeSinceIgnVoltage;
|
||||||
bool m_lastState = false;
|
bool m_lastState = false;
|
||||||
|
|
|
@ -35,3 +35,9 @@ MockStepperHardware::~MockStepperHardware() { }
|
||||||
|
|
||||||
MockTsChannel::MockTsChannel() : TsChannelBase("mock") { }
|
MockTsChannel::MockTsChannel() : TsChannelBase("mock") { }
|
||||||
MockTsChannel::~MockTsChannel() { }
|
MockTsChannel::~MockTsChannel() { }
|
||||||
|
|
||||||
|
MockIdleController::MockIdleController() { }
|
||||||
|
MockIdleController::~MockIdleController() { }
|
||||||
|
|
||||||
|
MockIgnitionController::MockIgnitionController() { }
|
||||||
|
MockIgnitionController::~MockIgnitionController() { }
|
||||||
|
|
|
@ -122,6 +122,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
class MockIdleController : public IIdleController {
|
class MockIdleController : public IIdleController {
|
||||||
|
public:
|
||||||
|
MockIdleController();
|
||||||
|
virtual ~MockIdleController();
|
||||||
|
|
||||||
MOCK_METHOD(IIdleController::Phase, determinePhase, (int rpm, int targetRpm, SensorResult tps, float vss, float crankingTaperFraction), (override));
|
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(int, getTargetRpm, (float clt), (override));
|
||||||
MOCK_METHOD(float, getCrankingOpenLoop, (float clt), (const, override));
|
MOCK_METHOD(float, getCrankingOpenLoop, (float clt), (const, override));
|
||||||
|
@ -132,3 +136,11 @@ class MockIdleController : public IIdleController {
|
||||||
MOCK_METHOD(bool, isIdlingOrTaper, (), (const, override));
|
MOCK_METHOD(bool, isIdlingOrTaper, (), (const, override));
|
||||||
MOCK_METHOD(float, getIdleTimingAdjustment, (int rpm), (override));
|
MOCK_METHOD(float, getIdleTimingAdjustment, (int rpm), (override));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MockIgnitionController : public IgnitionController {
|
||||||
|
public:
|
||||||
|
MockIgnitionController();
|
||||||
|
virtual ~MockIgnitionController();
|
||||||
|
|
||||||
|
MOCK_METHOD(bool, getIgnState, (), (const, override));
|
||||||
|
};
|
||||||
|
|
|
@ -740,6 +740,13 @@ TEST(etb, closedLoopPid) {
|
||||||
TEST(etb, jamDetection) {
|
TEST(etb, jamDetection) {
|
||||||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
||||||
|
|
||||||
|
MockIgnitionController ignController;
|
||||||
|
|
||||||
|
EXPECT_CALL(ignController, getIgnState).WillRepeatedly(Return(true));
|
||||||
|
|
||||||
|
// This only works when the ignition is on!
|
||||||
|
engine->module<IgnitionController>().set(&ignController);
|
||||||
|
|
||||||
// Must have TPS & PPS initialized for ETB setup
|
// Must have TPS & PPS initialized for ETB setup
|
||||||
Sensor::setMockValue(SensorType::Tps1Primary, 0);
|
Sensor::setMockValue(SensorType::Tps1Primary, 0);
|
||||||
Sensor::setMockValue(SensorType::Tps1, 0.0f, true);
|
Sensor::setMockValue(SensorType::Tps1, 0.0f, true);
|
||||||
|
|
Loading…
Reference in New Issue