| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include <Fw/Types/Assert.hpp> | ||
| 2 | #include <Svc/Types/EventSeverityFilter/EventSeverityFilter.hpp> | ||
| 3 | |||
| 4 | namespace Svc { | ||
| 5 | |||
| 6 | 25 | EventSeverityFilter::EventSeverityFilter() { | |
| 7 |
2/2✓ Branch 0 taken 150 times.
✓ Branch 1 taken 25 times.
|
175 | for (FwSizeType i = 0; i < NUM_FILTER_LEVELS; i++) { |
| 8 | 150 | this->m_enabled[i] = true; | |
| 9 | } | ||
| 10 | 25 | } | |
| 11 | |||
| 12 | 159 | void EventSeverityFilter::setFilter(Fw::LogSeverity severity, bool enabled) { | |
| 13 | 159 | FwSizeType index = 0; | |
| 14 |
4/4✓ Branch 3 taken 159 times.
✓ Branch 6 taken 159 times.
✓ Branch 18 taken 158 times.
✓ Branch 19 taken 1 times.
|
159 | if (toIndex(severity, index) == Fw::Success::SUCCESS) { |
| 15 | 158 | this->m_enabled[index] = enabled; | |
| 16 | } | ||
| 17 | 159 | } | |
| 18 | |||
| 19 | 131 | bool EventSeverityFilter::isFiltered(Fw::LogSeverity severity) const { | |
| 20 | 131 | FwSizeType index = 0; | |
| 21 |
4/4✓ Branch 3 taken 131 times.
✓ Branch 6 taken 131 times.
✓ Branch 18 taken 9 times.
✓ Branch 19 taken 122 times.
|
131 | if (toIndex(severity, index) != Fw::Success::SUCCESS) { |
| 22 | // FATAL / unknown are never filtered | ||
| 23 | 9 | return false; | |
| 24 | } | ||
| 25 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 122 times.
|
122 | return !this->m_enabled[index]; |
| 26 | } | ||
| 27 | |||
| 28 | 52 | bool EventSeverityFilter::isEnabled(Fw::LogSeverity severity) const { | |
| 29 | 52 | FwSizeType index = 0; | |
| 30 |
4/4✓ Branch 3 taken 52 times.
✓ Branch 6 taken 52 times.
✓ Branch 18 taken 3 times.
✓ Branch 19 taken 49 times.
|
52 | if (toIndex(severity, index) != Fw::Success::SUCCESS) { |
| 31 | // FATAL is always enabled | ||
| 32 | 3 | return true; | |
| 33 | } | ||
| 34 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
|
49 | return this->m_enabled[index]; |
| 35 | } | ||
| 36 | |||
| 37 | constexpr Fw::LogSeverity::t EventSeverityFilter::SEVERITY_ORDER[EventSeverityFilter::NUM_FILTER_LEVELS]; | ||
| 38 | |||
| 39 | 36 | Fw::Success EventSeverityFilter::fromIndex(FwSizeType index, Fw::LogSeverity& severity) { | |
| 40 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
|
36 | if (index >= NUM_FILTER_LEVELS) { |
| 41 | ✗ | return Fw::Success::FAILURE; | |
| 42 | } | ||
| 43 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
|
36 | severity = SEVERITY_ORDER[index]; |
| 44 | 36 | return Fw::Success::SUCCESS; | |
| 45 | } | ||
| 46 | |||
| 47 | 342 | Fw::Success EventSeverityFilter::toIndex(Fw::LogSeverity severity, FwSizeType& index) { | |
| 48 |
8/9✗ Branch 3 not taken.
✓ Branch 4 taken 342 times.
✓ Branch 5 taken 48 times.
✓ Branch 6 taken 53 times.
✓ Branch 7 taken 44 times.
✓ Branch 8 taken 87 times.
✓ Branch 9 taken 45 times.
✓ Branch 10 taken 52 times.
✓ Branch 11 taken 13 times.
|
342 | switch (severity.e) { |
| 49 | 48 | case Fw::LogSeverity::WARNING_HI: | |
| 50 | 48 | index = 0; | |
| 51 | 48 | return Fw::Success::SUCCESS; | |
| 52 | 53 | case Fw::LogSeverity::WARNING_LO: | |
| 53 | 53 | index = 1; | |
| 54 | 53 | return Fw::Success::SUCCESS; | |
| 55 | 44 | case Fw::LogSeverity::COMMAND: | |
| 56 | 44 | index = 2; | |
| 57 | 44 | return Fw::Success::SUCCESS; | |
| 58 | 87 | case Fw::LogSeverity::ACTIVITY_HI: | |
| 59 | 87 | index = 3; | |
| 60 | 87 | return Fw::Success::SUCCESS; | |
| 61 | 45 | case Fw::LogSeverity::ACTIVITY_LO: | |
| 62 | 45 | index = 4; | |
| 63 | 45 | return Fw::Success::SUCCESS; | |
| 64 | 52 | case Fw::LogSeverity::DIAGNOSTIC: | |
| 65 | 52 | index = 5; | |
| 66 | 52 | return Fw::Success::SUCCESS; | |
| 67 | 13 | default: | |
| 68 | 13 | return Fw::Success::FAILURE; | |
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 72 | } // namespace Svc | ||
| 73 |