F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
DpManager.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title DpManager.cpp
3 // \author bocchino
4 // \brief cpp file for DpManager component implementation class
5 // ======================================================================
6 
9 
10 namespace Svc {
11 
12 // ----------------------------------------------------------------------
13 // Construction, initialization, and destruction
14 // ----------------------------------------------------------------------
15 
16 DpManager::DpManager(const char* const compName)
17  : DpManagerComponentBase(compName),
18  numSuccessfulAllocations(0),
19  numFailedAllocations(0),
20  numDataProducts(0),
21  numBytes(0),
22  m_schedInQueued(false) {}
23 
25 
26 // ----------------------------------------------------------------------
27 // Handler implementations for user-defined typed input ports
28 // ----------------------------------------------------------------------
29 
30 Fw::Success DpManager::productGetIn_handler(const FwIndexType portNum,
31  FwDpIdType id,
32  FwSizeType size,
33  Fw::Buffer& buffer) {
34  return this->getBuffer(portNum, id, size, buffer);
35 }
36 
37 void DpManager::productRequestIn_handler(const FwIndexType portNum, FwDpIdType id, FwSizeType size) {
38  // Get a buffer
39  Fw::Buffer buffer;
40  const Fw::Success status = this->getBuffer(portNum, id, size, buffer);
41  // Send buffer on productResponseOut
42  this->productResponseOut_out(portNum, id, buffer, status);
43 }
44 
45 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  ++this->numDataProducts;
50  this->numBytes += buffer.getSize();
51  // Send the buffer on productSendOut
52  Fw::Buffer sendBuffer = buffer;
53  this->productSendOut_out(portNum, sendBuffer);
54 }
55 
56 void DpManager::schedIn_handler(const FwIndexType portNum, U32 context) {
57  bool expected = false;
58  if (this->m_schedInQueued.compare_exchange_strong(expected, true)) {
60  }
61 }
62 
63 void DpManager::schedInInternal_overflowHook() {
64  this->m_schedInQueued = false;
65 }
66 
67 void DpManager::schedInInternal_internalInterfaceHandler() {
68  this->m_schedInQueued = false;
69  // Emit telemetry
70  this->tlmWrite_NumSuccessfulAllocations(this->numSuccessfulAllocations);
71  this->tlmWrite_NumFailedAllocations(this->numFailedAllocations);
72  this->tlmWrite_NumDataProducts(this->numDataProducts);
73  this->tlmWrite_NumBytes(this->numBytes);
74 }
75 
76 // ----------------------------------------------------------------------
77 // Handler implementations for commands
78 // ----------------------------------------------------------------------
79 
80 void DpManager ::CLEAR_EVENT_THROTTLE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
82  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
83 }
84 
85 // ----------------------------------------------------------------------
86 // Private helper functions
87 // ----------------------------------------------------------------------
88 
89 Fw::Success DpManager::getBuffer(FwIndexType portNum, FwDpIdType id, FwSizeType size, Fw::Buffer& buffer) {
90  // Set status
92  // Get a buffer
93  buffer = this->bufferGetOut_out(portNum, static_cast<U32>(size));
94  if (buffer.isValid()) {
95  // Buffer is valid
96  ++this->numSuccessfulAllocations;
97  status = Fw::Success::SUCCESS;
98  } else {
99  // Buffer is invalid
100  ++this->numFailedAllocations;
102  }
103  return status;
104 }
105 
106 } // end namespace Svc
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
FwIdType FwOpcodeType
The type of a command opcode.
Representing success.
void log_WARNING_HI_BufferAllocationFailed_ThrottleClear()
Reset throttle value for BufferAllocationFailed.
PlatformSizeType FwSizeType
void tlmWrite_NumSuccessfulAllocations(U32 arg, Fw::Time _tlmTime=Fw::Time())
~DpManager()
Destroy the DpManager.
Definition: DpManager.cpp:24
void tlmWrite_NumFailedAllocations(U32 arg, Fw::Time _tlmTime=Fw::Time())
bool isValid() const
Definition: Buffer.cpp:78
void productResponseOut_out(FwIndexType portNum, FwDpIdType id, const Fw::Buffer &buffer, const Fw::Success &status) const
Invoke output port productResponseOut.
void tlmWrite_NumDataProducts(U32 arg, Fw::Time _tlmTime=Fw::Time())
Representing failure.
Command successfully executed.
Auto-generated base for DpManager component.
FwSizeType getSize() const
Definition: Buffer.cpp:90
Fw::Buffer bufferGetOut_out(FwIndexType portNum, FwSizeType size) const
Invoke output port bufferGetOut.
void log_WARNING_HI_BufferAllocationFailed(FwDpIdType id)
FwIdType FwDpIdType
The type of a data product identifier.
void productSendOut_out(FwIndexType portNum, Fw::Buffer &fwBuffer) const
Invoke output port productSendOut.
PlatformIndexType FwIndexType
RateGroupDivider component implementation.
DpManager(const char *const compName)
Construct a DpManager.
Definition: DpManager.cpp:16
void schedInInternal_internalInterfaceInvoke()
Internal interface base-class function for schedInInternal.
void tlmWrite_NumBytes(U64 arg, Fw::Time _tlmTime=Fw::Time())
Success/Failure.