Line | Branch | Decision | Exec | Source |
---|---|---|---|---|
1 | #include "pch.h" | |||
2 | ||||
3 | #include "init.h" | |||
4 | #include "adc_subscription.h" | |||
5 | #include "function_pointer_sensor.h" | |||
6 | #include "live_data.h" | |||
7 | ||||
8 | struct GetAfrWrapper { | |||
9 | ✗ | float getLambda() { | ||
10 | ✗ | return getAfr(SensorType::Lambda1) / STOICH_RATIO; | ||
11 | }; | |||
12 | ✗ | float getLambda2() { | ||
13 | ✗ | return getAfr(SensorType::Lambda2) / STOICH_RATIO; | ||
14 | } | |||
15 | }; | |||
16 | ||||
17 | static GetAfrWrapper afrWrapper; | |||
18 | ||||
19 | static FunctionPointerSensor lambdaSensor(SensorType::Lambda1, | |||
20 | ✗ | []() { | ||
21 | ✗ | return afrWrapper.getLambda(); | ||
22 | }); | |||
23 | ||||
24 | static FunctionPointerSensor lambdaSensor2(SensorType::Lambda2, | |||
25 | ✗ | []() { | ||
26 | ✗ | return afrWrapper.getLambda2(); | ||
27 | }); | |||
28 | ||||
29 | #include "AemXSeriesLambda.h" | |||
30 | ||||
31 | #if EFI_CAN_SUPPORT | |||
32 | static AemXSeriesWideband aem1(0, SensorType::Lambda1); | |||
33 | static AemXSeriesWideband aem2(1, SensorType::Lambda2); | |||
34 | #endif | |||
35 | ||||
36 | template <> | |||
37 | ✗ | const wideband_state_s* getLiveData(size_t idx) { | ||
38 | #if EFI_CAN_SUPPORT | |||
39 | switch (idx) { | |||
40 | case 0: | |||
41 | aem1.refreshState(); | |||
42 | return &aem1; | |||
43 | case 1: | |||
44 | aem2.refreshState(); | |||
45 | return &aem2; | |||
46 | } | |||
47 | #endif | |||
48 | ||||
49 | ✗ | return nullptr; | ||
50 | } | |||
51 | ||||
52 | 3 | void initLambda() { | ||
53 | // first we register the smoothed sensors for the early return on the can wbo case | |||
54 | 3 | smoothedLambda1Sensor.Register(); | ||
55 | 3 | smoothedLambda2Sensor.Register(); | ||
56 | ||||
57 | #if EFI_CAN_SUPPORT | |||
58 | if (engineConfiguration->enableAemXSeries) { | |||
59 | if (!engineConfiguration->canWriteEnabled || !engineConfiguration->canReadEnabled) { | |||
60 | criticalError("CAN read and write are required to use CAN wideband."); | |||
61 | return; | |||
62 | } | |||
63 | ||||
64 | registerCanSensor(aem1); | |||
65 | registerCanSensor(aem2); | |||
66 | ||||
67 | return; | |||
68 | } | |||
69 | #endif | |||
70 | ||||
71 | #if EFI_UNIT_TEST | |||
72 | 3 | constexpr bool isUnitTest = true; | ||
73 | #else | |||
74 | constexpr bool isUnitTest = false; | |||
75 | #endif | |||
76 | ||||
77 | // CANbus option is handled above, let's handle analog inputs conditionally to give Lua sensors a chance | |||
78 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
1/2✓ Decision 'true' taken 3 times.
✗ Decision 'false' not taken.
|
3 | if (isAdcChannelValid(engineConfiguration->afr.hwChannel) || isUnitTest) { |
79 | 3 | lambdaSensor.Register(); | ||
80 | } | |||
81 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
1/2✓ Decision 'true' taken 3 times.
✗ Decision 'false' not taken.
|
3 | if (isAdcChannelValid(engineConfiguration->afr.hwChannel2) || isUnitTest) { |
82 | 3 | lambdaSensor2.Register(); | ||
83 | } | |||
84 | 3 | } | ||
85 |