Line | Branch | Decision | Exec | Source |
---|---|---|---|---|
1 | #pragma once | |||
2 | ||||
3 | #include "rusefi_types.h" | |||
4 | ||||
5 | /** | |||
6 | * Stores the recent peak value, preventing loss of intermittent peaks in a signal. | |||
7 | */ | |||
8 | template <typename TValue, efidur_t TTimeoutPeriod> | |||
9 | class PeakDetect { | |||
10 | public: | |||
11 | 453 | TValue detect(TValue currentValue, efitick_t nowNt) { | ||
12 |
4/4PeakDetect<float, 5000000l>::detect(float, long):
✓ Branch 0 taken 440 times.
✓ Branch 1 taken 8 times.
PeakDetect<int, 100l>::detect(int, long):
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
|
4/4PeakDetect<float, 5000000l>::detect(float, long):
✓ Decision 'true' taken 12 times.
✓ Decision 'false' taken 436 times.
PeakDetect<int, 100l>::detect(int, long):
✓ Decision 'true' taken 3 times.
✓ Decision 'false' taken 2 times.
|
453 | if ((nowNt > m_lastPeakTime + TTimeoutPeriod) || // if timed out |
13 |
4/4PeakDetect<float, 5000000l>::detect(float, long):
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 436 times.
PeakDetect<int, 100l>::detect(int, long):
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
|
443 | (currentValue > m_peak)) { // or current is higher than the previous peak | |
14 | // store new peak and time | |||
15 | 15 | m_peak = currentValue; | ||
16 | 15 | m_lastPeakTime = nowNt; | ||
17 | } | |||
18 | ||||
19 | 453 | return m_peak; | ||
20 | } | |||
21 | ||||
22 | private: | |||
23 | TValue m_peak = std::numeric_limits<TValue>::min(); | |||
24 | efitick_t m_lastPeakTime = std::numeric_limits<efitick_t>::min(); | |||
25 | }; | |||
26 |