limp manager can disable etb (#2143)
* move rev limit to limp manager * call fatal error * include order * fix bug * tests * limp can disable etb Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
parent
5e7dc71365
commit
5f84cf2a07
|
@ -458,11 +458,14 @@ void EtbController::setOutput(expected<percent_t> outputValue) {
|
|||
|
||||
if (!m_motor) return;
|
||||
|
||||
// If output is valid and we aren't paused, output to motor.
|
||||
if (outputValue && !engineConfiguration->pauseEtbControl) {
|
||||
// If ETB is allowed, output is valid, and we aren't paused, output to motor.
|
||||
if (ENGINE(limpManager).allowElectronicThrottle()
|
||||
&& outputValue
|
||||
&& !engineConfiguration->pauseEtbControl) {
|
||||
m_motor->enable();
|
||||
m_motor->set(ETB_PERCENT_TO_DUTY(outputValue.Value));
|
||||
} else {
|
||||
// Otherwise disable the motor.
|
||||
m_motor->disable();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -529,6 +529,26 @@ TEST(etb, setOutputPauseControl) {
|
|||
etb.setOutput(25.0f);
|
||||
}
|
||||
|
||||
TEST(etb, setOutputLimpHome) {
|
||||
WITH_ENGINE_TEST_HELPER(TEST_ENGINE);
|
||||
StrictMock<MockMotor> motor;
|
||||
|
||||
// Must have TPS initialized for ETB setup
|
||||
Sensor::setMockValue(SensorType::Tps1, 0.0f, true);
|
||||
|
||||
EtbController etb;
|
||||
INJECT_ENGINE_REFERENCE(&etb);
|
||||
etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true);
|
||||
|
||||
// Should be disabled when in ETB limp mode
|
||||
EXPECT_CALL(motor, disable());
|
||||
|
||||
// Trip a fatal error
|
||||
ENGINE(limpManager).fatalError();
|
||||
|
||||
etb.setOutput(25.0f);
|
||||
}
|
||||
|
||||
TEST(etb, closedLoopPid) {
|
||||
pid_s pid = {};
|
||||
pid.pFactor = 5;
|
||||
|
|
Loading…
Reference in New Issue