GCC Code Coverage Report


Directory: Svc/DpManager/
File: DpManager.cpp
Date: 2026-09-03 21:17:37
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 1960 void DpManager::productRequestIn_handler(const FwIndexType portNum, FwDpIdType id, FwSizeType size) {
37 // Get a buffer
38
1/1
✓ Branch 2 taken 1960 times.
1960 Fw::Buffer buffer;
39
1/1
✓ Branch 2 taken 1960 times.
1960 const Fw::Success status = this->getBuffer(portNum, id, size, buffer);
40 // Send buffer on productResponseOut
41
1/1
✓ Branch 5 taken 1960 times.
1960 this->productResponseOut_out(portNum, id, buffer, status);
42 3920 }
43
44 2040 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 2040 ++this->numDataProducts;
49
1/1
✓ Branch 4 taken 2040 times.
2040 this->numBytes += buffer.getSize();
50 // Send the buffer on productSendOut
51
1/1
✓ Branch 2 taken 2040 times.
2040 Fw::Buffer sendBuffer = buffer;
52
1/1
✓ Branch 5 taken 2040 times.
2040 this->productSendOut_out(portNum, sendBuffer);
53 4080 }
54
55 2032 void DpManager::schedIn_handler(const FwIndexType portNum, U32 context) {
56 // Emit telemetry
57
2/2
✓ Branch 6 taken 2032 times.
✓ Branch 13 taken 2032 times.
2032 this->tlmWrite_NumSuccessfulAllocations(this->numSuccessfulAllocations);
58
2/2
✓ Branch 6 taken 2032 times.
✓ Branch 13 taken 2032 times.
2032 this->tlmWrite_NumFailedAllocations(this->numFailedAllocations);
59
2/2
✓ Branch 6 taken 2032 times.
✓ Branch 13 taken 2032 times.
2032 this->tlmWrite_NumDataProducts(this->numDataProducts);
60
2/2
✓ Branch 6 taken 2032 times.
✓ Branch 13 taken 2032 times.
2032 this->tlmWrite_NumBytes(this->numBytes);
61 2032 }
62
63 // ----------------------------------------------------------------------
64 // Handler implementations for commands
65 // ----------------------------------------------------------------------
66
67 1969 void DpManager ::CLEAR_EVENT_THROTTLE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
68 1969 this->log_WARNING_HI_BufferAllocationFailed_ThrottleClear();
69
2/2
✓ Branch 6 taken 1969 times.
✓ Branch 9 taken 1969 times.
1969 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
70 1969 }
71
72 // ----------------------------------------------------------------------
73 // Private helper functions
74 // ----------------------------------------------------------------------
75
76 1964 Fw::Success DpManager::getBuffer(FwIndexType portNum, FwDpIdType id, FwSizeType size, Fw::Buffer& buffer) {
77 // Set status
78 1964 Fw::Success status(Fw::Success::FAILURE);
79 // Get a buffer
80
2/2
✓ Branch 3 taken 1964 times.
✓ Branch 10 taken 1964 times.
1964 buffer = this->bufferGetOut_out(portNum, static_cast<U32>(size));
81
3/3
✓ Branch 4 taken 1964 times.
✓ Branch 6 taken 1003 times.
✓ Branch 7 taken 961 times.
1964 if (buffer.isValid()) {
82 // Buffer is valid
83 1003 ++this->numSuccessfulAllocations;
84
1/1
✓ Branch 3 taken 1003 times.
1003 status = Fw::Success::SUCCESS;
85 } else {
86 // Buffer is invalid
87 961 ++this->numFailedAllocations;
88
1/1
✓ Branch 5 taken 961 times.
961 this->log_WARNING_HI_BufferAllocationFailed(id);
89 }
90 1964 return status;
91 }
92
93 } // end namespace Svc
94