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