GCC Code Coverage Report


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