| 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 | 16 | numBytes(0), | |
| 22 | 32 | m_schedInQueued(false) {} | |
| 23 | |||
| 24 | 32 | DpManager::~DpManager() {} | |
| 25 | |||
| 26 | // ---------------------------------------------------------------------- | ||
| 27 | // Handler implementations for user-defined typed input ports | ||
| 28 | // ---------------------------------------------------------------------- | ||
| 29 | |||
| 30 | 4 | Fw::Success DpManager::productGetIn_handler(const FwIndexType portNum, | |
| 31 | FwDpIdType id, | ||
| 32 | FwSizeType size, | ||
| 33 | Fw::Buffer& buffer) { | ||
| 34 | 4 | return this->getBuffer(portNum, id, size, buffer); | |
| 35 | } | ||
| 36 | |||
| 37 | 2066 | void DpManager::productRequestIn_handler(const FwIndexType portNum, FwDpIdType id, FwSizeType size) { | |
| 38 | // Get a buffer | ||
| 39 |
1/1✓ Branch 2 taken 2066 times.
|
2066 | Fw::Buffer buffer; |
| 40 |
1/1✓ Branch 2 taken 2066 times.
|
2066 | const Fw::Success status = this->getBuffer(portNum, id, size, buffer); |
| 41 | // Send buffer on productResponseOut | ||
| 42 |
1/1✓ Branch 5 taken 2066 times.
|
2066 | this->productResponseOut_out(portNum, id, buffer, status); |
| 43 | 4132 | } | |
| 44 | |||
| 45 | 1963 | void DpManager::productSendIn_handler(const FwIndexType portNum, FwDpIdType id, const Fw::Buffer& buffer) { | |
| 46 | // id is unused | ||
| 47 | (void)id; | ||
| 48 | // Update state variables | ||
| 49 | 1963 | ++this->numDataProducts; | |
| 50 |
1/1✓ Branch 4 taken 1963 times.
|
1963 | this->numBytes += buffer.getSize(); |
| 51 | // Send the buffer on productSendOut | ||
| 52 |
1/1✓ Branch 2 taken 1963 times.
|
1963 | Fw::Buffer sendBuffer = buffer; |
| 53 |
1/1✓ Branch 5 taken 1963 times.
|
1963 | this->productSendOut_out(portNum, sendBuffer); |
| 54 | 3926 | } | |
| 55 | |||
| 56 | 1992 | void DpManager::schedIn_handler(const FwIndexType portNum, U32 context) { | |
| 57 | 1992 | bool expected = false; | |
| 58 |
1/2✓ Branch 4 taken 1992 times.
✗ Branch 5 not taken.
|
1992 | if (this->m_schedInQueued.compare_exchange_strong(expected, true)) { |
| 59 |
1/1✓ Branch 5 taken 1992 times.
|
1992 | this->schedInInternal_internalInterfaceInvoke(); |
| 60 | } | ||
| 61 | 1992 | } | |
| 62 | |||
| 63 | ✗ | void DpManager::schedInInternal_overflowHook() { | |
| 64 | ✗ | this->m_schedInQueued = false; | |
| 65 | ✗ | } | |
| 66 | |||
| 67 | 1992 | void DpManager::schedInInternal_internalInterfaceHandler() { | |
| 68 | 1992 | this->m_schedInQueued = false; | |
| 69 | // Emit telemetry | ||
| 70 |
2/2✓ Branch 6 taken 1992 times.
✓ Branch 13 taken 1992 times.
|
1992 | this->tlmWrite_NumSuccessfulAllocations(this->numSuccessfulAllocations); |
| 71 |
2/2✓ Branch 6 taken 1992 times.
✓ Branch 13 taken 1992 times.
|
1992 | this->tlmWrite_NumFailedAllocations(this->numFailedAllocations); |
| 72 |
2/2✓ Branch 6 taken 1992 times.
✓ Branch 13 taken 1992 times.
|
1992 | this->tlmWrite_NumDataProducts(this->numDataProducts); |
| 73 |
2/2✓ Branch 6 taken 1992 times.
✓ Branch 13 taken 1992 times.
|
1992 | this->tlmWrite_NumBytes(this->numBytes); |
| 74 | 1992 | } | |
| 75 | |||
| 76 | // ---------------------------------------------------------------------- | ||
| 77 | // Handler implementations for commands | ||
| 78 | // ---------------------------------------------------------------------- | ||
| 79 | |||
| 80 | 2015 | void DpManager ::CLEAR_EVENT_THROTTLE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) { | |
| 81 | 2015 | this->log_WARNING_HI_BufferAllocationFailed_ThrottleClear(); | |
| 82 |
2/2✓ Branch 6 taken 2015 times.
✓ Branch 9 taken 2015 times.
|
2015 | this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); |
| 83 | 2015 | } | |
| 84 | |||
| 85 | // ---------------------------------------------------------------------- | ||
| 86 | // Private helper functions | ||
| 87 | // ---------------------------------------------------------------------- | ||
| 88 | |||
| 89 | 2070 | Fw::Success DpManager::getBuffer(FwIndexType portNum, FwDpIdType id, FwSizeType size, Fw::Buffer& buffer) { | |
| 90 | // Set status | ||
| 91 | 2070 | Fw::Success status(Fw::Success::FAILURE); | |
| 92 | // Get a buffer | ||
| 93 |
2/2✓ Branch 3 taken 2070 times.
✓ Branch 10 taken 2070 times.
|
2070 | buffer = this->bufferGetOut_out(portNum, static_cast<U32>(size)); |
| 94 |
3/3✓ Branch 4 taken 2070 times.
✓ Branch 6 taken 1046 times.
✓ Branch 7 taken 1024 times.
|
2070 | if (buffer.isValid()) { |
| 95 | // Buffer is valid | ||
| 96 | 1046 | ++this->numSuccessfulAllocations; | |
| 97 |
1/1✓ Branch 3 taken 1046 times.
|
1046 | status = Fw::Success::SUCCESS; |
| 98 | } else { | ||
| 99 | // Buffer is invalid | ||
| 100 | 1024 | ++this->numFailedAllocations; | |
| 101 |
1/1✓ Branch 5 taken 1024 times.
|
1024 | this->log_WARNING_HI_BufferAllocationFailed(id); |
| 102 | } | ||
| 103 | 2070 | return status; | |
| 104 | ✗ | } | |
| 105 | |||
| 106 | } // end namespace Svc | ||
| 107 |