Line | Branch | Decision | Exec | Source |
---|---|---|---|---|
1 | /** | |||
2 | * @file state_sequence.cpp | |||
3 | * | |||
4 | * @date May 18, 2014 | |||
5 | * @author Andrey Belomutskiy, (c) 2012-2020 | |||
6 | */ | |||
7 | ||||
8 | #include "pch.h" | |||
9 | #include "state_sequence.h" | |||
10 | #include "trigger_structure.h" | |||
11 | ||||
12 | 994 | void MultiChannelStateSequence::checkSwitchTimes(const float scale) const { | ||
13 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 994 times.
|
994 | efiAssertVoid(ObdCode::CUSTOM_ERR_WAVE_1, phaseCount > 0, "StateSequence cannot be empty"); | |
14 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 994 times.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 994 times.
|
994 | if (getSwitchTime(phaseCount - 1) != 1) { |
15 | #if EFI_UNIT_TEST | |||
16 | ✗ | for (int index = 0;index < phaseCount;index ++) { | ||
17 | ✗ | printf("switch time index=%d angle=%f\n", index, getSwitchTime(index)); | ||
18 | } | |||
19 | #endif // EFI_UNIT_TEST | |||
20 | ||||
21 | ✗ | firmwareError(ObdCode::CUSTOM_ERR_WAVE_1, "[count=%d] last switch time has to be 1/%f not %.2f/%f", | ||
22 | ✗ | phaseCount, | ||
23 | ✗ | scale, getSwitchTime(phaseCount - 1), | ||
24 | ✗ | scale * getSwitchTime(phaseCount - 1)); | ||
25 | ✗ | return; | ||
26 | } | |||
27 |
2/2✓ Branch 0 taken 13708 times.
✓ Branch 1 taken 994 times.
|
2/2✓ Decision 'true' taken 13708 times.
✓ Decision 'false' taken 994 times.
|
14702 | for (int i = 0; i < phaseCount - 1; i++) { |
28 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 13708 times.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 13708 times.
|
13708 | if (getSwitchTime(i) >= getSwitchTime(i + 1)) { |
29 | ✗ | firmwareError(ObdCode::CUSTOM_ERR_WAVE_2, "invalid switchTimes @%d: %.2f/%.2f", | ||
30 | ✗ | i, getSwitchTime(i), getSwitchTime(i + 1)); | ||
31 | } | |||
32 | } | |||
33 | } | |||
34 | ||||
35 | 13821 | int MultiChannelStateSequence::findInsertionAngle(const float angle) const { | ||
36 |
2/2✓ Branch 0 taken 13839 times.
✓ Branch 1 taken 1 time.
|
2/2✓ Decision 'true' taken 13839 times.
✓ Decision 'false' taken 1 time.
|
13840 | for (int i = phaseCount - 1; i >= 0; i--) { |
37 |
2/2✓ Branch 1 taken 13820 times.
✓ Branch 2 taken 19 times.
|
2/2✓ Decision 'true' taken 13820 times.
✓ Decision 'false' taken 19 times.
|
13839 | if (angle > getSwitchTime(i)) |
38 | 13820 | return i + 1; | ||
39 | } | |||
40 | 1 | return 0; | ||
41 | } | |||
42 | ||||
43 | 13822 | expected<int> MultiChannelStateSequence::findAngleMatch(const float angle) const { | ||
44 |
2/2✓ Branch 1 taken 474148 times.
✓ Branch 2 taken 13820 times.
|
2/2✓ Decision 'true' taken 474148 times.
✓ Decision 'false' taken 13820 times.
|
487968 | for (int i = 0; i < phaseCount; i++) { |
45 |
4/4✓ Branch 1 taken 474148 times.
✓ Branch 4 taken 474148 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 474146 times.
|
2/2✓ Decision 'true' taken 2 times.
✓ Decision 'false' taken 474146 times.
|
474148 | if (isSameF(getSwitchTime(i), angle)) |
46 | 2 | return i; | ||
47 | } | |||
48 | 13820 | return unexpected; | ||
49 | } | |||
50 |