Line | Branch | Decision | Exec | Source |
---|---|---|---|---|
1 | #include "pch.h" | |||
2 | ||||
3 | #include "alphan_airmass.h" | |||
4 | #include "fuel_math.h" | |||
5 | ||||
6 | 5 | AirmassResult AlphaNAirmass::getAirmass(float rpm, bool postState) { | ||
7 | 5 | auto tps = Sensor::get(SensorType::Tps1); | ||
8 | ||||
9 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 4 times.
|
2/2✓ Decision 'true' taken 1 time.
✓ Decision 'false' taken 4 times.
|
5 | if (!tps.Valid) { |
10 | // We are fully reliant on TPS - if the TPS fails, stop the engine. | |||
11 | 1 | return {}; | ||
12 | } | |||
13 | ||||
14 | // In this case, VE directly describes the cylinder filling relative to the ideal | |||
15 | 4 | float ve = getVe(rpm, tps.Value, postState); | ||
16 | ||||
17 | // optionally use real IAT instead of fixed air temperature | |||
18 | 4 | constexpr float standardIat = STD_IAT; // std atmosphere temperature | ||
19 | 4 | float iat = engineConfiguration->alphaNUseIat | ||
20 |
3/5✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
|
6 | ? Sensor::get(SensorType::Iat).value_or(standardIat) | |
21 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
|
4 | : standardIat; | |
22 | ||||
23 | 4 | float iatK = iat + 273/* todo reuse C_K_OFFSET which would require adjusting unit tests*/; | ||
24 | ||||
25 | // TODO: should this be barometric pressure and/or temperature compensated? | |||
26 | 4 | mass_t airmass = getAirmassImpl( | ||
27 | ve, | |||
28 | STD_ATMOSPHERE, | |||
29 | iatK | |||
30 | ); | |||
31 | ||||
32 | return { | |||
33 | airmass, | |||
34 | 4 | tps.Value | ||
35 | 4 | }; | ||
36 | } | |||
37 |