| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | /** | |||
| 2 | * @file tcu.cpp | |||
| 3 | * @brief Base classes for gear selection and transmission control | |||
| 4 | * | |||
| 5 | * @date Aug 31, 2020 | |||
| 6 | * @author David Holdeman, (c) 2020 | |||
| 7 | */ | |||
| 8 | ||||
| 9 | #include "pch.h" | |||
| 10 | ||||
| 11 | #include "tcu.h" | |||
| 12 | ||||
| 13 | #if EFI_TCU | |||
| 14 | ✗ | void TransmissionControllerBase::init() { | ||
| 15 | ✗ | } | ||
| 16 | ||||
| 17 | 4825 | void TransmissionControllerBase::update(gear_e /*gear*/) { | ||
| 18 | 4825 | postState(); | ||
| 19 | 4825 | } | ||
| 20 | ||||
| 21 | 9650 | gear_e TransmissionControllerBase::setCurrentGear(gear_e gear) { | ||
| 22 | 9650 | currentGear = gear; | ||
| 23 | 9650 | return getCurrentGear(); | ||
| 24 | } | |||
| 25 | ||||
| 26 | 19309 | gear_e TransmissionControllerBase::getCurrentGear() const { | ||
| 27 | 19309 | return currentGear; | ||
| 28 | } | |||
| 29 | ||||
| 30 | 4825 | void TransmissionControllerBase::postState() { | ||
| 31 | #if EFI_TUNER_STUDIO | |||
| 32 | 4825 | auto iss = Sensor::get(SensorType::InputShaftSpeed); | ||
| 33 | 4825 | auto rpm = Sensor::get(SensorType::Rpm); | ||
| 34 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 4825 times.
|
4825 | if (iss.Valid && rpm.Valid) { |
| 35 | ✗ | tcRatio = rpm.Value / iss.Value; | ||
| 36 | } | |||
| 37 | 4825 | tcuCurrentGear = getCurrentGear(); | ||
| 38 | #endif | |||
| 39 | 4825 | } | ||
| 40 | ||||
| 41 | // call to mark the start of the shift | |||
| 42 | 9 | void TransmissionControllerBase::measureShiftTime(gear_e gear) { | ||
| 43 | 9 | m_shiftTime = true; | ||
| 44 | 9 | m_shiftTimer.reset(); | ||
| 45 | 9 | m_shiftTimeGear = gear; | ||
| 46 | 9 | } | ||
| 47 | ||||
| 48 | 4825 | float TransmissionControllerBase::isShiftCompleted() { | ||
| 49 | 4825 | auto detected = Sensor::get(SensorType::DetectedGear); | ||
| 50 | 4825 | auto iss = Sensor::get(SensorType::InputShaftSpeed); | ||
| 51 | // If gear detection is set up and the gear we are trying to shift into has been detected | |||
| 52 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 4825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 4825 times.
|
4825 | if (detected.Valid && m_shiftTime && (int)m_shiftTimeGear == detected.Value) { |
| 53 | ✗ | m_shiftTime = false; | ||
| 54 | ✗ | return m_shiftTimer.getElapsedSeconds(); | ||
| 55 | // If ISS isn't configured, we want to use a fixed value. | |||
| 56 |
7/8✓ Branch 0 taken 4825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2423 times.
✓ Branch 3 taken 2402 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 2420 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 4822 times.
|
2/2✓ Decision 'true' taken 3 times.
✓ Decision 'false' taken 4822 times.
|
4825 | } else if (!iss.Valid && m_shiftTime && m_shiftTimer.hasElapsedMs(config->tcu_shiftTime)) { |
| 57 | 3 | m_shiftTime = false; | ||
| 58 | // convert ms to seconds for gauge | |||
| 59 | 3 | return config->tcu_shiftTime * 0.001; | ||
| 60 | } else { | |||
| 61 | // a return value of 0 means the shift is not completed yet | |||
| 62 | 4822 | return 0; | ||
| 63 | } | |||
| 64 | } | |||
| 65 | #endif // EFI_TCU | |||
| 66 |