GCC Code Coverage Report


Directory: ./
File: Svc/ActiveRateGroup/ActiveRateGroup.cpp
Date: 2026-09-03 22:12:29
Exec Total Coverage
Lines: 39 54 72.2%
Functions: 7 8 87.5%
Branches: 18 32 56.2%

Line Branch Exec Source
1 /*
2 * \author: Tim Canham
3 * \file:
4 * \brief
5 *
6 * This file implements the ActiveRateGroup component,
7 * which invokes a set of components the comprise the rate group.
8 *
9 * Copyright 2014-2015, by the California Institute of Technology.
10 * ALL RIGHTS RESERVED. United States Government Sponsorship
11 * acknowledged.
12 *
13 */
14
15 #include <Fw/FPrimeBasicTypes.hpp>
16 #include <Fw/Types/Assert.hpp>
17 #include <Os/Console.hpp>
18 #include <Svc/ActiveRateGroup/ActiveRateGroup.hpp>
19 #include <config/ActiveRateGroupCfg.hpp>
20
21 namespace Svc {
22
23 3 ActiveRateGroup::ActiveRateGroup(const char* compName)
24 : ActiveRateGroupComponentBase(compName),
25 3 m_cycles(0),
26 3 m_maxTime(0),
27 3 m_cycleStarted(false),
28 3 m_numContexts(0),
29 3 m_overrunThrottle(0),
30 3 m_cycleSlips(0) {}
31
32 3 void ActiveRateGroup::configure(const ContextArray& contexts) {
33 static_assert(FW_NUM_ARRAY_ELEMENTS(m_contexts) == NUM_RATEGROUPMEMBEROUT_OUTPUT_PORTS,
34 "Context table size must match the number of rate group member output ports");
35
36 3 this->m_numContexts = CONNECTION_COUNT_MAX;
37 // copy context values
38
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 3 times.
33 for (FwIndexType entry = 0; entry < this->m_numContexts; entry++) {
39 30 this->m_contexts[entry] = contexts[static_cast<FwSizeType>(entry)];
40 }
41 3 }
42
43 void ActiveRateGroup::configure(const U32 contexts[], const FwIndexType numContexts) {
44 FW_ASSERT(contexts != nullptr);
45 FW_ASSERT(numContexts == this->getNum_RateGroupMemberOut_OutputPorts(), static_cast<FwAssertArgType>(numContexts),
46 static_cast<FwAssertArgType>(this->getNum_RateGroupMemberOut_OutputPorts()));
47
48 ContextArray contextArray;
49 for (FwIndexType entry = 0; entry < numContexts; entry++) {
50 contextArray[static_cast<FwSizeType>(entry)] = contexts[entry];
51 }
52 this->configure(contextArray);
53 }
54
55 6 ActiveRateGroup::~ActiveRateGroup() {}
56
57 3 void ActiveRateGroup::preamble() {
58 3 this->log_DIAGNOSTIC_RateGroupStarted();
59 3 }
60
61 399 void ActiveRateGroup::CycleIn_handler(FwIndexType portNum, Os::RawTime& cycleStart) {
62 // Make sure it's been configured
63 399 FW_ASSERT(this->m_numContexts != 0);
64
65
1/1
✓ Branch 1 taken 409 times.
399 Os::RawTime endTime;
66
67 409 this->m_cycleStarted = false;
68
69 // invoke any members of the rate group
70
2/2
✓ Branch 0 taken 4060 times.
✓ Branch 1 taken 467 times.
4527 for (FwIndexType port = 0; port < this->m_numContexts; port++) {
71
3/3
✓ Branch 1 taken 4112 times.
✓ Branch 3 taken 3053 times.
✓ Branch 4 taken 1059 times.
4060 if (this->isConnected_RateGroupMemberOut_OutputPort(port)) {
72
1/1
✓ Branch 1 taken 3059 times.
3053 this->RateGroupMemberOut_out(port, static_cast<U32>(this->m_contexts[port]));
73 }
74 }
75
76 // grab timer for endTime of cycle
77
1/1
✓ Branch 1 taken 412 times.
467 Os::RawTime::Status timeStatus = endTime.now();
78
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 412 times.
412 if (timeStatus != Os::RawTime::Status::OP_OK) {
79 this->log_WARNING_HI_RateGroupTimeGetError(Os::RawTimeStatus(static_cast<Os::RawTimeStatus::T>(timeStatus)));
80 }
81
82 // get rate group execution time
83 U32 cycleTime;
84 // Cast to void as the only possible error is overflow, which we can't handle other
85 // than capping cycleTime to max value of U32 (which is done in getDiffUsec anyways)
86
1/1
✓ Branch 1 taken 412 times.
412 (void)endTime.getDiffUsec(cycleStart, cycleTime);
87
88 // check to see if the time has exceeded the previous maximum
89
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 396 times.
412 if (cycleTime > this->m_maxTime) {
90 16 this->m_maxTime = cycleTime;
91 }
92
93 // update cycle telemetry
94
2/2
✓ Branch 1 taken 412 times.
✓ Branch 4 taken 412 times.
412 this->tlmWrite_RgMaxTime(this->m_maxTime);
95
96 // check for cycle slip. That will happen if new cycle message has been received
97 // which will cause flag will be set again.
98
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 412 times.
412 if (this->m_cycleStarted) {
99 this->m_cycleSlips++;
100 if (this->m_overrunThrottle < ACTIVE_RATE_GROUP_OVERRUN_THROTTLE) {
101 this->log_WARNING_HI_RateGroupCycleSlip(this->m_cycles);
102 this->m_overrunThrottle++;
103 }
104 // update cycle slips
105 this->tlmWrite_RgCycleSlips(this->m_cycleSlips);
106 } else { // if cycle is okay start decrementing throttle value
107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 412 times.
412 if (this->m_overrunThrottle > 0) {
108 this->m_overrunThrottle--;
109 }
110 }
111
112 // increment cycle
113 412 this->m_cycles++;
114 412 }
115
116 412 void ActiveRateGroup::CycleIn_preMsgHook(FwIndexType portNum, Os::RawTime& cycleStart) {
117 // set flag to indicate cycle has started. Check in thread for overflow.
118 412 this->m_cycleStarted = true;
119 412 }
120
121 177 void ActiveRateGroup::PingIn_handler(FwIndexType portNum, U32 key) {
122 // return the key to health
123 177 this->PingOut_out(0, key);
124 177 }
125
126 } // namespace Svc
127