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:
Matthew Kennedy 2020-12-26 18:47:27 -08:00 committed by GitHub
parent 898b7a82e0
commit 64d9b4b71a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 2 deletions

View File

@ -458,11 +458,14 @@ void EtbController::setOutput(expected<percent_t> outputValue) {
if (!m_motor) return; if (!m_motor) return;
// If output is valid and we aren't paused, output to motor. // If ETB is allowed, output is valid, and we aren't paused, output to motor.
if (outputValue && !engineConfiguration->pauseEtbControl) { if (ENGINE(limpManager).allowElectronicThrottle()
&& outputValue
&& !engineConfiguration->pauseEtbControl) {
m_motor->enable(); m_motor->enable();
m_motor->set(ETB_PERCENT_TO_DUTY(outputValue.Value)); m_motor->set(ETB_PERCENT_TO_DUTY(outputValue.Value));
} else { } else {
// Otherwise disable the motor.
m_motor->disable(); m_motor->disable();
} }
} }

View File

@ -529,6 +529,26 @@ TEST(etb, setOutputPauseControl) {
etb.setOutput(25.0f); 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) { TEST(etb, closedLoopPid) {
pid_s pid = {}; pid_s pid = {};
pid.pFactor = 5; pid.pFactor = 5;