mock invalid & current state of ETB error counter
This commit is contained in:
parent
b97745496e
commit
7547edb566
|
@ -11,9 +11,15 @@ public:
|
|||
return m_sensor;
|
||||
}
|
||||
|
||||
void setInvalidMockValue() {
|
||||
m_useMock = true;
|
||||
m_valid = false;
|
||||
}
|
||||
|
||||
void setMockValue(float value, bool mockRedundant) {
|
||||
m_mockValue = value;
|
||||
m_useMock = true;
|
||||
m_valid = true;
|
||||
m_mockRedundant = mockRedundant;
|
||||
}
|
||||
|
||||
|
@ -47,6 +53,9 @@ public:
|
|||
SensorResult get() const {
|
||||
// Check if mock
|
||||
if (m_useMock) {
|
||||
if (!m_valid) {
|
||||
return unexpected;
|
||||
}
|
||||
return m_mockValue;
|
||||
}
|
||||
|
||||
|
@ -111,6 +120,7 @@ public:
|
|||
|
||||
private:
|
||||
bool m_useMock = false;
|
||||
bool m_valid = false;
|
||||
bool m_mockRedundant = false;
|
||||
float m_mockValue;
|
||||
Sensor* m_sensor = nullptr;
|
||||
|
@ -185,6 +195,14 @@ void Sensor::unregister() {
|
|||
return entry ? entry->hasSensor() : false;
|
||||
}
|
||||
|
||||
void Sensor::setInvalidMockValue(SensorType type) {
|
||||
auto entry = getEntryForType(type);
|
||||
|
||||
if (entry) {
|
||||
entry->setInvalidMockValue();
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/ void Sensor::setMockValue(SensorType type, float value, bool mockRedundant) {
|
||||
auto entry = getEntryForType(type);
|
||||
|
||||
|
|
|
@ -113,6 +113,9 @@ public:
|
|||
*/
|
||||
static void setMockValue(SensorType type, float value, bool mockRedundant = false);
|
||||
|
||||
|
||||
static void setInvalidMockValue(SensorType type);
|
||||
|
||||
/*
|
||||
* Mock a value for a particular sensor.
|
||||
*/
|
||||
|
|
|
@ -12,8 +12,6 @@ static EtbController * initEtbIntegratedTest() {
|
|||
engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_3;
|
||||
engineConfiguration->throttlePedalPositionSecondAdcChannel = EFI_ADC_3;
|
||||
|
||||
Sensor::setMockValue(SensorType::AcceleratorPedalPrimary, 40);
|
||||
Sensor::setMockValue(SensorType::AcceleratorPedalSecondary, 40);
|
||||
|
||||
Sensor::setMockValue(SensorType::Tps1, 25.0f, true);
|
||||
|
||||
|
@ -26,6 +24,9 @@ TEST(etb, integrated) {
|
|||
EngineTestHelper eth(TEST_ENGINE); // we have a distractor so cannot move EngineTestHelper into utility method
|
||||
EtbController *etb = initEtbIntegratedTest();
|
||||
|
||||
Sensor::setMockValue(SensorType::AcceleratorPedalPrimary, 40);
|
||||
Sensor::setMockValue(SensorType::AcceleratorPedalSecondary, 40);
|
||||
|
||||
etb->update();
|
||||
|
||||
ASSERT_EQ(engine->outputChannels.etbTarget, 40);
|
||||
|
@ -51,8 +52,18 @@ TEST(etb, integratedTpsJitter) {
|
|||
|
||||
ASSERT_FALSE(isTps1Error());
|
||||
ASSERT_FALSE(isTps2Error());
|
||||
ASSERT_FALSE(isPedalError());
|
||||
ASSERT_TRUE(isPedalError());
|
||||
|
||||
etb->update();
|
||||
|
||||
Sensor::setInvalidMockValue(SensorType::AcceleratorPedal);
|
||||
ASSERT_TRUE(isPedalError());
|
||||
etb->update();
|
||||
|
||||
ASSERT_EQ(1, etb->etbInputErrorCounter);
|
||||
|
||||
Sensor::setInvalidMockValue(SensorType::Tps1);
|
||||
etb->update();
|
||||
|
||||
ASSERT_EQ(1, etb->etbInputErrorCounter);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue