parent
eed7521035
commit
5a735c9059
|
@ -108,6 +108,13 @@ static SensorType functionToPositionSensor(dc_function_e func) {
|
|||
}
|
||||
}
|
||||
|
||||
static SensorType functionToTpsSensor(dc_function_e func) {
|
||||
switch(func) {
|
||||
case DC_Throttle1: return SensorType::Tps1;
|
||||
default: return SensorType::Tps2;
|
||||
}
|
||||
}
|
||||
|
||||
static SensorType functionToTpsSensorPrimary(dc_function_e func) {
|
||||
switch(func) {
|
||||
case DC_Throttle1: return SensorType::Tps1Primary;
|
||||
|
@ -177,7 +184,7 @@ bool EtbController::init(dc_function_e function, DcMotor *motor, pid_s *pidParam
|
|||
}
|
||||
|
||||
// If no sensor is configured for this throttle, skip initialization.
|
||||
if (!Sensor::hasSensor(functionToTpsSensorPrimary(function))) {
|
||||
if (!Sensor::hasSensor(functionToTpsSensor(function))) {
|
||||
etbErrorCode = (int8_t)TpsState::TpsError;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ TEST(etb, initializationNotRedundantPedal) {
|
|||
EXPECT_FATAL_ERROR(dut.init(DC_Throttle1, nullptr, nullptr, nullptr, true));
|
||||
}
|
||||
|
||||
TEST(etb, initializationNoPrimarySensor) {
|
||||
TEST(etb, initializationNoSensor) {
|
||||
Sensor::resetAllMocks();
|
||||
|
||||
EtbController dut;
|
||||
|
@ -218,13 +218,10 @@ TEST(etb, initializationNoPrimarySensor) {
|
|||
// Needs pedal for init
|
||||
Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true);
|
||||
|
||||
// Redundant, but no primary configured
|
||||
Sensor::setMockValue(SensorType::Tps1, /*value*/0, /*mockRedundant*/true);
|
||||
|
||||
EXPECT_FALSE(dut.init(DC_Throttle1, nullptr, nullptr, nullptr, true));
|
||||
|
||||
// Now configure primary TPS
|
||||
Sensor::setMockValue(SensorType::Tps1Primary, 0);
|
||||
// Redundant
|
||||
Sensor::setMockValue(SensorType::Tps1, /*value*/0, /*mockRedundant*/true);
|
||||
|
||||
// With primary TPS, should return true (ie, throttle was configured)
|
||||
EXPECT_TRUE(dut.init(DC_Throttle1, nullptr, nullptr, nullptr, true));
|
||||
|
|
Loading…
Reference in New Issue