GCC Code Coverage Report


Directory: Svc/RateGroupDriver/
File: RateGroupDriver.cpp
Date: 2026-09-03 21:18:21
Exec Total Coverage
Lines: 23 23 100.0%
Functions: 4 4 100.0%
Branches: 11 16 68.8%

Line Branch Exec Source
1 #include <Fw/FPrimeBasicTypes.hpp>
2 #include <Fw/Types/Assert.hpp>
3 #include <Svc/RateGroupDriver/RateGroupDriver.hpp>
4 #include <cstdio>
5 #include <cstring>
6
7 namespace Svc {
8
9 2 RateGroupDriver::RateGroupDriver(const char* compName)
10 2 : RateGroupDriverComponentBase(compName), m_ticks(0), m_rollover(1), m_configured(false) {}
11
12 3 void RateGroupDriver::configure(const DividerSet& dividerSet) {
13 // verify port/table size matches
14 static_assert(FW_NUM_ARRAY_ELEMENTS(m_dividers) == NUM_CYCLEOUT_OUTPUT_PORTS,
15 "Divider table size must match the number of cycle output ports");
16 // reset rollover so a reconfigure does not multiply onto the prior product
17 3 this->m_rollover = 1;
18 // copy provided array of dividers
19
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 3 times.
12 for (FwIndexType entry = 0; entry < RateGroupDriver::DIVIDER_SIZE; entry++) {
20 // A port with an offset equal or bigger than the divisor is not accepted because it would never be called
21 9 FW_ASSERT((dividerSet.dividers[entry].offset == 0) ||
22 (dividerSet.dividers[entry].offset < dividerSet.dividers[entry].divisor),
23 static_cast<FwAssertArgType>(dividerSet.dividers[entry].offset),
24 static_cast<FwAssertArgType>(dividerSet.dividers[entry].divisor));
25 9 this->m_dividers[entry] = dividerSet.dividers[entry];
26 // rollover value should be product of all dividers to make sure integer rollover doesn't jump cycles
27 // only use non-zero dividers
28
1/2
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 if (dividerSet.dividers[entry].divisor != 0) {
29 // Ensure that rollover will not overflow
30 9 FW_ASSERT((std::numeric_limits<FwSizeType>::max() / dividerSet.dividers[entry].divisor) >= this->m_rollover,
31 static_cast<FwAssertArgType>(this->m_rollover),
32 static_cast<FwAssertArgType>(dividerSet.dividers[entry].divisor));
33 9 this->m_rollover *= dividerSet.dividers[entry].divisor;
34 }
35 }
36 3 this->m_configured = true;
37 3 }
38
39 4 RateGroupDriver::~RateGroupDriver() {}
40
41 120 void RateGroupDriver::CycleIn_handler(FwIndexType portNum, Os::RawTime& cycleStart) {
42 // Make sure that the dividers have been configured:
43 // If this asserts, add the configure() call to initialization.
44 120 FW_ASSERT(this->m_configured);
45
46 // Loop through each divider. For a given port, the port will be called when the divider value
47 // divides evenly into the number of ticks. For example, if the divider value for a port is 4,
48 // it would be called every fourth invocation of the CycleIn port.
49
2/2
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 120 times.
480 for (FwIndexType entry = 0; entry < RateGroupDriver::DIVIDER_SIZE; entry++) {
50
1/2
✓ Branch 5 taken 360 times.
✗ Branch 6 not taken.
360 if (this->m_dividers[entry].divisor != 0) {
51
1/2
✓ Branch 5 taken 360 times.
✗ Branch 6 not taken.
360 if (this->isConnected_CycleOut_OutputPort(static_cast<FwIndexType>(entry))) {
52
3/4
✗ Branch 9 not taken.
✓ Branch 10 taken 360 times.
✓ Branch 16 taken 220 times.
✓ Branch 17 taken 140 times.
360 if ((this->m_ticks % this->m_dividers[entry].divisor) == this->m_dividers[entry].offset) {
53 220 this->CycleOut_out(static_cast<FwIndexType>(entry), cycleStart);
54 }
55 }
56 }
57 }
58
59 // rollover the tick value when the tick count reaches the rollover value
60 // the rollover value is the product of all the dividers. See comment in constructor.
61 120 FW_ASSERT(this->m_rollover > 0);
62
1/2
✗ Branch 8 not taken.
✓ Branch 9 taken 120 times.
120 this->m_ticks = (this->m_ticks + 1) % this->m_rollover;
63 120 }
64
65 } // namespace Svc
66