71 lines
2.1 KiB
C++
71 lines
2.1 KiB
C++
#include "pch.h"
|
|
|
|
#include "fan_control.h"
|
|
|
|
TEST(Actuators, Fan) {
|
|
EngineTestHelper eth(TEST_ENGINE);
|
|
|
|
engineConfiguration->fanOnTemperature = 90;
|
|
engineConfiguration->fanOffTemperature = 80;
|
|
engineConfiguration->enableFan1WithAc = false;
|
|
|
|
// Cold, fan should be off
|
|
Sensor::setMockValue(SensorType::Clt, 75);
|
|
updateFans(false);
|
|
EXPECT_EQ(false, enginePins.fanRelay.getLogicValue());
|
|
|
|
// Between thresholds, should still be off
|
|
Sensor::setMockValue(SensorType::Clt, 85);
|
|
updateFans(false);
|
|
EXPECT_EQ(false, enginePins.fanRelay.getLogicValue());
|
|
|
|
// Hot, fan should turn on
|
|
Sensor::setMockValue(SensorType::Clt, 95);
|
|
updateFans(false);
|
|
EXPECT_EQ(true, enginePins.fanRelay.getLogicValue());
|
|
|
|
// Between thresholds, should stay on
|
|
Sensor::setMockValue(SensorType::Clt, 85);
|
|
updateFans(false);
|
|
EXPECT_EQ(true, enginePins.fanRelay.getLogicValue());
|
|
|
|
// Below threshold, should turn off
|
|
Sensor::setMockValue(SensorType::Clt, 75);
|
|
updateFans(false);
|
|
EXPECT_EQ(false, enginePins.fanRelay.getLogicValue());
|
|
|
|
engineConfiguration->enableFan1WithAc = true;
|
|
// Now AC is on, fan should turn on!
|
|
updateFans(true);
|
|
EXPECT_EQ(true, enginePins.fanRelay.getLogicValue());
|
|
|
|
// Turn off AC, fan should turn off too.
|
|
updateFans(false);
|
|
EXPECT_EQ(false, enginePins.fanRelay.getLogicValue());
|
|
|
|
// Back to hot, fan should turn on
|
|
Sensor::setMockValue(SensorType::Clt, 95);
|
|
updateFans(false);
|
|
EXPECT_EQ(true, enginePins.fanRelay.getLogicValue());
|
|
|
|
// Engine starts cranking, fan should turn off
|
|
engine->rpmCalculator.setRpmValue(100);
|
|
updateFans(false);
|
|
EXPECT_EQ(false, enginePins.fanRelay.getLogicValue());
|
|
|
|
// Engine running, fan should turn back on
|
|
engine->rpmCalculator.setRpmValue(1000);
|
|
updateFans(false);
|
|
EXPECT_EQ(true, enginePins.fanRelay.getLogicValue());
|
|
|
|
// Stop the engine, fan should stay on
|
|
engine->rpmCalculator.setRpmValue(0);
|
|
updateFans(false);
|
|
EXPECT_EQ(true, enginePins.fanRelay.getLogicValue());
|
|
|
|
// Set configuration to inhibit fan while engine is stopped, fan should stop
|
|
engineConfiguration->disableFan1WhenStopped = true;
|
|
updateFans(false);
|
|
EXPECT_EQ(false, enginePins.fanRelay.getLogicValue());
|
|
}
|