Line | Branch | Decision | Exec | Source |
---|---|---|---|---|
1 | #include "pch.h" | |||
2 | ||||
3 | #include "fan_control.h" | |||
4 | ||||
5 | #include "bench_test.h" | |||
6 | ||||
7 | 2084 | PUBLIC_API_WEAK bool fansDisabledByBoardStatus() { | ||
8 | 2084 | return false; | ||
9 | } | |||
10 | ||||
11 | 2184 | PUBLIC_API_WEAK bool fansEnabledByBoardStatus() { | ||
12 | 2184 | return false; | ||
13 | } | |||
14 | ||||
15 | 2184 | bool FanController::getState(bool acActive, bool lastState) { | ||
16 |
1/1✓ Branch 2 taken 2184 times.
|
2184 | auto clt = Sensor::get(SensorType::Clt); | |
17 |
1/1✓ Branch 1 taken 2184 times.
|
2184 | auto vss = Sensor::get(SensorType::VehicleSpeed); | |
18 | ||||
19 | #if EFI_SHAFT_POSITION_INPUT | |||
20 |
1/1✓ Branch 1 taken 2184 times.
|
2184 | cranking = engine->rpmCalculator.isCranking(); | |
21 |
1/1✓ Branch 1 taken 2184 times.
|
2184 | notRunning = !engine->rpmCalculator.isRunning(); | |
22 | #else | |||
23 | cranking = false; | |||
24 | notRunning = true; | |||
25 | #endif | |||
26 | ||||
27 |
2/8✓ Branch 1 taken 2184 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2184 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
2184 | disabledBySpeed = disableAtSpeed() > 0 && vss.Valid && vss.Value > disableAtSpeed(); | |
28 |
5/5✓ Branch 0 taken 2135 times.
✓ Branch 1 taken 49 times.
✓ Branch 3 taken 2135 times.
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 2134 times.
|
2184 | disabledWhileEngineStopped = notRunning && disableWhenStopped(); | |
29 | 2184 | brokenClt = !clt; | ||
30 |
5/5✓ Branch 1 taken 2184 times.
✓ Branch 3 taken 195 times.
✓ Branch 4 taken 1989 times.
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 194 times.
|
2184 | enabledForAc = enableWithAc() && acActive; | |
31 |
1/1✓ Branch 2 taken 2184 times.
|
2184 | hot = clt.value_or(0) > getFanOnTemp(); | |
32 |
1/1✓ Branch 2 taken 2184 times.
|
2184 | cold = clt.value_or(0) < getFanOffTemp(); | |
33 | ||||
34 |
2/3✓ Branch 1 taken 2184 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2184 times.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 2184 times.
|
2184 | if (fansEnabledByBoardStatus()) { |
35 | ✗ | radiatorFanStatus = (int)RadiatorFanState::BoardForcedOn; | ||
36 | ✗ | return true; | ||
37 |
2/2✓ Branch 0 taken 99 times.
✓ Branch 1 taken 2085 times.
|
2/2✓ Decision 'true' taken 99 times.
✓ Decision 'false' taken 2085 times.
|
2184 | } else if (cranking) { |
38 | // Inhibit while cranking | |||
39 | 99 | radiatorFanStatus = (int)RadiatorFanState::Cranking; | ||
40 | 99 | return false; | ||
41 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2084 times.
|
2/2✓ Decision 'true' taken 1 time.
✓ Decision 'false' taken 2084 times.
|
2085 | } else if (disabledWhileEngineStopped) { |
42 | // Inhibit while not running (if so configured) | |||
43 | 1 | radiatorFanStatus = (int)RadiatorFanState::EngineStopped; | ||
44 | 1 | return false; | ||
45 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2084 times.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 2084 times.
|
2084 | } else if (disabledBySpeed) { |
46 | // Inhibit while driving fast | |||
47 | ✗ | radiatorFanStatus = (int)RadiatorFanState::VehicleIsTooFast; | ||
48 | ✗ | return false; | ||
49 |
2/3✓ Branch 1 taken 2084 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2084 times.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 2084 times.
|
2084 | } else if (fansDisabledByBoardStatus()) { |
50 | ✗ | radiatorFanStatus = (int)RadiatorFanState::BoardStatus; | ||
51 | ✗ | return false; | ||
52 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2073 times.
|
2/2✓ Decision 'true' taken 11 times.
✓ Decision 'false' taken 2073 times.
|
2084 | } else if (brokenClt) { |
53 | // If CLT is broken, turn the fan on | |||
54 | 11 | radiatorFanStatus = (int)RadiatorFanState::CltBroken; | ||
55 | 11 | return true; | ||
56 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2072 times.
|
2/2✓ Decision 'true' taken 1 time.
✓ Decision 'false' taken 2072 times.
|
2073 | } else if (enabledForAc) { |
57 | 1 | radiatorFanStatus = (int)RadiatorFanState::AC; | ||
58 | 1 | return true; | ||
59 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2068 times.
|
2/2✓ Decision 'true' taken 4 times.
✓ Decision 'false' taken 2068 times.
|
2072 | } else if (hot) { |
60 | 4 | radiatorFanStatus = (int)RadiatorFanState::Hot; | ||
61 | 4 | return true; | ||
62 |
2/2✓ Branch 0 taken 2066 times.
✓ Branch 1 taken 2 times.
|
2/2✓ Decision 'true' taken 2066 times.
✓ Decision 'false' taken 2 times.
|
2068 | } else if (cold) { |
63 | 2066 | radiatorFanStatus = (int)RadiatorFanState::Cold; | ||
64 | 2066 | return false; | ||
65 | } else { | |||
66 | 2 | radiatorFanStatus = (int)RadiatorFanState::Previous; | ||
67 | // no condition met, maintain previous state | |||
68 | 2 | return lastState; | ||
69 | } | |||
70 | } | |||
71 | ||||
72 | 2184 | void FanController::onSlowCallback() { | ||
73 | #if EFI_PROD_CODE | |||
74 | if (isRunningBenchTest()) { | |||
75 | radiatorFanStatus = (int)RadiatorFanState::Bench; | |||
76 | return; // let's not mess with bench testing | |||
77 | } | |||
78 | #endif | |||
79 | ||||
80 | 2184 | bool acActive = engine->module<AcController>()->isAcEnabled(); | ||
81 | ||||
82 | 2184 | auto& pin = getPin(); | ||
83 | ||||
84 | 2184 | bool result = getState(acActive, pin.getLogicValue()); | ||
85 | ||||
86 | 2184 | m_state = result; | ||
87 | ||||
88 | 2184 | pin.setValue(result); | ||
89 | 2184 | } | ||
90 | ||||
91 | 1172 | void FanController::setDefaultConfiguration() { | ||
92 | 1172 | engineConfiguration->fanOnTemperature = 92; | ||
93 | 1172 | engineConfiguration->fanOffTemperature = 88; | ||
94 | 1172 | engineConfiguration->fan2OnTemperature = 95; | ||
95 | 1172 | engineConfiguration->fan2OffTemperature = 91; | ||
96 | 1172 | } | ||
97 |