GCC Code Coverage Report


Directory: Svc/DpManager/
File: DpManager.cpp
Date: 2026-09-23 21:14:20
Exec Total Coverage
Lines: 38 39 97.4%
Functions: 8 8 100.0%
Branches: 23 23 100.0%

Line Branch Exec Source
1 // ======================================================================
2 // \title DpManager.cpp
3 // \author bocchino
4 // \brief cpp file for DpManager component implementation class
5 // ======================================================================
6
7 #include "Svc/DpManager/DpManager.hpp"
8 #include "Fw/FPrimeBasicTypes.hpp"
9
10 namespace Svc {
11
12 // ----------------------------------------------------------------------
13 // Construction, initialization, and destruction
14 // ----------------------------------------------------------------------
15
16 16 DpManager::DpManager(const char* const compName)
17 : DpManagerComponentBase(compName),
18 16 numSuccessfulAllocations(0),
19 16 numFailedAllocations(0),
20 16 numDataProducts(0),
21 32 numBytes(0) {}
22
23 32 DpManager::~DpManager() {}
24
25 // ----------------------------------------------------------------------
26 // Handler implementations for user-defined typed input ports
27 // ----------------------------------------------------------------------
28
29 4 Fw::Success DpManager::productGetIn_handler(const FwIndexType portNum,
30 FwDpIdType id,
31 FwSizeType size,
32 Fw::Buffer& buffer) {
33 4 return this->getBuffer(portNum, id, size, buffer);
34 }
35
36 1965 void DpManager::productRequestIn_handler(const FwIndexType portNum, FwDpIdType id, FwSizeType size) {
37 // Get a buffer
38
1/1
✓ Branch 2 taken 1965 times.
1965 Fw::Buffer buffer;
39
1/1
✓ Branch 2 taken 1965 times.
1965 const Fw::Success status = this->getBuffer(portNum, id, size, buffer);
40 // Send buffer on productResponseOut
41
1/1
✓ Branch 5 taken 1965 times.
1965 this->productResponseOut_out(portNum, id, buffer, status);
42 3930 }
43
44 1963 void DpManager::productSendIn_handler(const FwIndexType portNum, FwDpIdType id, const Fw::Buffer& buffer) {
45 // id is unused
46 (void)id;
47 // Update state variables
48 1963 ++this->numDataProducts;
49
1/1
✓ Branch 4 taken 1963 times.
1963 this->numBytes += buffer.getSize();
50 // Send the buffer on productSendOut
51
1/1
✓ Branch 2 taken 1963 times.
1963 Fw::Buffer sendBuffer = buffer;
52
1/1
✓ Branch 5 taken 1963 times.
1963 this->productSendOut_out(portNum, sendBuffer);
53 3926 }
54
55 2067 void DpManager::schedIn_handler(const FwIndexType portNum, U32 context) {
56 // Emit telemetry
57
2/2
✓ Branch 6 taken 2067 times.
✓ Branch 13 taken 2067 times.
2067 this->tlmWrite_NumSuccessfulAllocations(this->numSuccessfulAllocations);
58
2/2
✓ Branch 6 taken 2067 times.
✓ Branch 13 taken 2067 times.
2067 this->tlmWrite_NumFailedAllocations(this->numFailedAllocations);
59
2/2
✓ Branch 6 taken 2067 times.
✓ Branch 13 taken 2067 times.
2067 this->tlmWrite_NumDataProducts(this->numDataProducts);
60
2/2
✓ Branch 6 taken 2067 times.
✓ Branch 13 taken 2067 times.
2067 this->tlmWrite_NumBytes(this->numBytes);
61 2067 }
62
63 // ----------------------------------------------------------------------
64 // Handler implementations for commands
65 // ----------------------------------------------------------------------
66
67 2017 void DpManager ::CLEAR_EVENT_THROTTLE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
68 2017 this->log_WARNING_HI_BufferAllocationFailed_ThrottleClear();
69
2/2
✓ Branch 6 taken 2017 times.
✓ Branch 9 taken 2017 times.
2017 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
70 2017 }
71
72 // ----------------------------------------------------------------------
73 // Private helper functions
74 // ----------------------------------------------------------------------
75
76 1969 Fw::Success DpManager::getBuffer(FwIndexType portNum, FwDpIdType id, FwSizeType size, Fw::Buffer& buffer) {
77 // Set status
78 1969 Fw::Success status(Fw::Success::FAILURE);
79 // Get a buffer
80
2/2
✓ Branch 3 taken 1969 times.
✓ Branch 10 taken 1969 times.
1969 buffer = this->bufferGetOut_out(portNum, static_cast<U32>(size));
81
3/3
✓ Branch 4 taken 1969 times.
✓ Branch 6 taken 972 times.
✓ Branch 7 taken 997 times.
1969 if (buffer.isValid()) {
82 // Buffer is valid
83 972 ++this->numSuccessfulAllocations;
84
1/1
✓ Branch 3 taken 972 times.
972 status = Fw::Success::SUCCESS;
85 } else {
86 // Buffer is invalid
87 997 ++this->numFailedAllocations;
88
1/1
✓ Branch 5 taken 997 times.
997 this->log_WARNING_HI_BufferAllocationFailed(id);
89 }
90 1969 return status;
91 ✗ }
92
93 } // end namespace Svc
94