GCC Code Coverage Report


Directory: ./
File: Svc/DpManager/DpManager.cpp
Date: 2026-09-03 22:12:29
Exec Total Coverage
Lines: 27 39 69.2%
Functions: 6 8 75.0%
Branches: 16 23 69.6%

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 1 DpManager::DpManager(const char* const compName)
17 : DpManagerComponentBase(compName),
18 1 numSuccessfulAllocations(0),
19 1 numFailedAllocations(0),
20 1 numDataProducts(0),
21 1 numBytes(0) {}
22
23 2 DpManager::~DpManager() {}
24
25 // ----------------------------------------------------------------------
26 // Handler implementations for user-defined typed input ports
27 // ----------------------------------------------------------------------
28
29 2 Fw::Success DpManager::productGetIn_handler(const FwIndexType portNum,
30 FwDpIdType id,
31 FwSizeType size,
32 Fw::Buffer& buffer) {
33 2 return this->getBuffer(portNum, id, size, buffer);
34 }
35
36 void DpManager::productRequestIn_handler(const FwIndexType portNum, FwDpIdType id, FwSizeType size) {
37 // Get a buffer
38 Fw::Buffer buffer;
39 const Fw::Success status = this->getBuffer(portNum, id, size, buffer);
40 // Send buffer on productResponseOut
41 this->productResponseOut_out(portNum, id, buffer, status);
42 }
43
44 2 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 2 ++this->numDataProducts;
49
1/1
✓ Branch 1 taken 2 times.
2 this->numBytes += buffer.getSize();
50 // Send the buffer on productSendOut
51
1/1
✓ Branch 1 taken 2 times.
2 Fw::Buffer sendBuffer = buffer;
52
1/1
✓ Branch 1 taken 2 times.
2 this->productSendOut_out(portNum, sendBuffer);
53 2 }
54
55 59 void DpManager::schedIn_handler(const FwIndexType portNum, U32 context) {
56 // Emit telemetry
57
2/2
✓ Branch 1 taken 59 times.
✓ Branch 5 taken 59 times.
59 this->tlmWrite_NumSuccessfulAllocations(this->numSuccessfulAllocations);
58
2/2
✓ Branch 1 taken 59 times.
✓ Branch 5 taken 59 times.
59 this->tlmWrite_NumFailedAllocations(this->numFailedAllocations);
59
2/2
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
59 this->tlmWrite_NumDataProducts(this->numDataProducts);
60
2/2
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
59 this->tlmWrite_NumBytes(this->numBytes);
61 59 }
62
63 // ----------------------------------------------------------------------
64 // Handler implementations for commands
65 // ----------------------------------------------------------------------
66
67 void DpManager ::CLEAR_EVENT_THROTTLE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
68 this->log_WARNING_HI_BufferAllocationFailed_ThrottleClear();
69 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
70 }
71
72 // ----------------------------------------------------------------------
73 // Private helper functions
74 // ----------------------------------------------------------------------
75
76 2 Fw::Success DpManager::getBuffer(FwIndexType portNum, FwDpIdType id, FwSizeType size, Fw::Buffer& buffer) {
77 // Set status
78 2 Fw::Success status(Fw::Success::FAILURE);
79 // Get a buffer
80
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 buffer = this->bufferGetOut_out(portNum, static_cast<U32>(size));
81
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
2 if (buffer.isValid()) {
82 // Buffer is valid
83 2 ++this->numSuccessfulAllocations;
84
1/1
✓ Branch 1 taken 2 times.
2 status = Fw::Success::SUCCESS;
85 } else {
86 // Buffer is invalid
87 ++this->numFailedAllocations;
88 this->log_WARNING_HI_BufferAllocationFailed(id);
89 }
90 2 return status;
91 }
92
93 } // end namespace Svc
94