GCC Code Coverage Report


Directory: ./
File: firmware/controllers/algo/airmass/airmass.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 91.9% 34 0 37
Functions: 100.0% 3 0 3
Branches: 78.1% 25 0 32
Decisions: 78.6% 11 - 14

Line Branch Decision Exec Source
1 #include "pch.h"
2
3 #include "airmass.h"
4 #include "idle_thread.h"
5
6 594 AirmassVeModelBase::AirmassVeModelBase(const ValueProvider3D& veTable) : m_veTable(&veTable) {}
7
8 1108 float getVeLoadAxis(ve_override_e mode, float passedLoad) {
9
2/4
✓ Branch 0 taken 1107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 3 not taken.
1108 switch(mode) {
10
1/1
✓ Decision 'true' taken 1107 times.
1107 case VE_None: return passedLoad;
11 case VE_MAP: return Sensor::getOrZero(SensorType::Map);
12
1/1
✓ Decision 'true' taken 1 time.
1 case VE_TPS: return Sensor::getOrZero(SensorType::Tps1);
13 default: return 0;
14 }
15 }
16
17 1101 float AirmassVeModelBase::getVe(float rpm, float load, bool postState) const {
18
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1101 times.
✗ Branch 3 not taken.
1101 efiAssert(ObdCode::OBD_PCM_Processor_Fault, m_veTable != nullptr, "VE table null", 0);
19
20 // Override the load value if necessary
21
1/1
✓ Branch 1 taken 1101 times.
1101 load = getVeLoadAxis(engineConfiguration->veOverrideMode, load);
22
23
1/1
✓ Branch 1 taken 1101 times.
1101 percent_t ve = m_veTable->getValue(rpm, load);
24 1101 float idleVeLoad = load;
25
26 #if EFI_IDLE_CONTROL
27
1/1
✓ Branch 2 taken 1101 times.
1101 auto tps = Sensor::get(SensorType::Tps1);
28 // get VE from the separate table for Idle if idling
29
3/4
✓ Branch 1 taken 1101 times.
✓ Branch 5 taken 1101 times.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
2/2
✓ Decision 'true' taken 7 times.
✓ Decision 'false' taken 1101 times.
1108 if (engine->module<IdleController>()->isIdlingOrTaper() &&
30
5/6
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1094 times.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
✓ Branch 6 taken 1094 times.
1108 tps && engineConfiguration->useSeparateVeForIdle) {
31
1/1
✓ Branch 1 taken 7 times.
7 idleVeLoad = getVeLoadAxis(engineConfiguration->idleVeOverrideMode, load);
32
33 14 percent_t idleVe = interpolate3d(
34 7 config->idleVeTable,
35 7 config->idleVeLoadBins, idleVeLoad,
36
1/1
✓ Branch 1 taken 7 times.
7 config->idleVeRpmBins, rpm
37 );
38
39 // interpolate between idle table and normal (running) table using TPS threshold
40 // 0 TPS -> idle table
41 // 1/2 threshold -> idle table
42 // idle threshold -> normal table
43 7 float idleThreshold = engineConfiguration->idlePidDeactivationTpsThreshold;
44
1/1
✓ Branch 1 taken 7 times.
7 ve = interpolateClamped(idleThreshold / 2, idleVe, idleThreshold, ve, tps.Value);
45 }
46 #endif // EFI_IDLE_CONTROL
47
48 // Add any adjustments if configured
49
2/2
✓ Branch 1 taken 4404 times.
✓ Branch 2 taken 1101 times.
2/2
✓ Decision 'true' taken 4404 times.
✓ Decision 'false' taken 1101 times.
5505 for (size_t i = 0; i < efi::size(config->veBlends); i++) {
50
1/1
✓ Branch 2 taken 4404 times.
4404 auto result = calculateBlend(config->veBlends[i], rpm, load);
51
52
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4392 times.
2/2
✓ Decision 'true' taken 12 times.
✓ Decision 'false' taken 4392 times.
4404 if (postState) {
53 12 engine->outputChannels.veBlendParameter[i] = result.BlendParameter;
54 12 engine->outputChannels.veBlendBias[i] = result.Bias;
55 12 engine->outputChannels.veBlendOutput[i] = result.Value;
56 12 engine->outputChannels.veBlendYAxis[i] = result.TableYAxis;
57 }
58
59 // Skip extra floating point math if we can...
60
1/2
✓ Branch 0 taken 4404 times.
✗ Branch 1 not taken.
1/2
✓ Decision 'true' taken 4404 times.
✗ Decision 'false' not taken.
4404 if (result.Value == 0) {
61 4404 continue;
62 }
63
64 // Apply as a multiplier, not as an adder
65 // Value of +5 means add 5%, aka multiply by 1.05
66 ve *= ((100 + result.Value) * 0.01f);
67 }
68
69
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1098 times.
2/2
✓ Decision 'true' taken 3 times.
✓ Decision 'false' taken 1098 times.
1101 if (postState) {
70 3 engine->engineState.currentVe = ve;
71 3 engine->engineState.veTableYAxis = load;
72 3 engine->engineState.veTableIdleYAxis = idleVeLoad;
73 }
74
75 1101 return ve * PERCENT_DIV;
76 }
77