| 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 | 999 | void MultiChannelStateSequence::checkSwitchTimes(const float scale) const { | ||
| 13 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 999 times.
|
999 | efiAssertVoid(ObdCode::CUSTOM_ERR_WAVE_1, phaseCount > 0, "StateSequence cannot be empty"); | |
| 14 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 999 times.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 999 times.
|
999 | 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 13747 times.
✓ Branch 1 taken 999 times.
|
2/2✓ Decision 'true' taken 13747 times.
✓ Decision 'false' taken 999 times.
|
14746 | for (int i = 0; i < phaseCount - 1; i++) { |
| 28 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 13747 times.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 13747 times.
|
13747 | 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 | 13860 | int MultiChannelStateSequence::findInsertionAngle(const float angle) const { | ||
| 36 |
2/2✓ Branch 0 taken 13878 times.
✓ Branch 1 taken 1 time.
|
2/2✓ Decision 'true' taken 13878 times.
✓ Decision 'false' taken 1 time.
|
13879 | for (int i = phaseCount - 1; i >= 0; i--) { |
| 37 |
2/2✓ Branch 1 taken 13859 times.
✓ Branch 2 taken 19 times.
|
2/2✓ Decision 'true' taken 13859 times.
✓ Decision 'false' taken 19 times.
|
13878 | if (angle > getSwitchTime(i)) |
| 38 | 13859 | return i + 1; | ||
| 39 | } | |||
| 40 | 1 | return 0; | ||
| 41 | } | |||
| 42 | ||||
| 43 | 13861 | expected<int> MultiChannelStateSequence::findAngleMatch(const float angle) const { | ||
| 44 |
2/2✓ Branch 1 taken 474366 times.
✓ Branch 2 taken 13859 times.
|
2/2✓ Decision 'true' taken 474366 times.
✓ Decision 'false' taken 13859 times.
|
488225 | for (int i = 0; i < phaseCount; i++) { |
| 45 |
4/4✓ Branch 1 taken 474366 times.
✓ Branch 4 taken 474366 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 474364 times.
|
2/2✓ Decision 'true' taken 2 times.
✓ Decision 'false' taken 474364 times.
|
474366 | if (isSameF(getSwitchTime(i), angle)) |
| 46 | 2 | return i; | ||
| 47 | } | |||
| 48 | 13859 | return unexpected; | ||
| 49 | } | |||
| 50 |