29 m_bufferMemory(nullptr),
32 m_waitForBuffer(false),
50 this->m_allocatorId = identifier;
54 bool recoverable =
false;
55 this->m_bufferMemory =
static_cast<Fw::Buffer*
>(allocator.
allocate(identifier, memSize, recoverable));
57 m_bufferQueue.init(this->m_bufferMemory, maxNumBuffers);
61 allocator.
deallocate(static_cast<FwEnumStoreType>(this->m_allocatorId), this->m_bufferMemory);
69 const bool status = this->m_bufferQueue.enqueue(buffer);
71 if (this->m_numWarnings > 0) {
74 this->m_numWarnings = 0;
76 if (this->m_numWarnings == 0) {
82 this->sendStoredBuffer();
90 this->m_waitForBuffer =
false;
92 (this->m_numDrained < this->m_numToDrain)) {
95 this->sendStoredBuffer();
99 void BufferAccumulator ::pingIn_handler(
const FwIndexType portNum, U32 key) {
107 void BufferAccumulator ::BA_SetMode_cmdHandler(
const FwOpcodeType opCode,
109 BufferAccumulator_OpState mode) {
111 if (this->m_numToDrain > 0) {
113 this->m_numToDrain = 0;
114 this->m_numDrained = 0;
121 if (!this->m_waitForBuffer) {
123 this->sendStoredBuffer();
126 this->m_send =
false;
131 void BufferAccumulator ::BA_DrainBuffers_cmdHandler(
const FwOpcodeType opCode,
134 BufferAccumulator_BlockMode blockMode) {
135 if (this->m_numDrained < this->m_numToDrain) {
137 static_cast<U32>(this->m_numToDrain));
148 if (numToDrain == 0) {
154 this->m_opCode = opCode;
155 this->m_cmdSeq = cmdSeq;
156 this->m_numDrained = 0;
157 this->m_numToDrain =
static_cast<FwSizeType>(numToDrain);
160 FwSizeType numBuffers = this->m_bufferQueue.getSize();
162 if (numBuffers < static_cast<FwSizeType>(numToDrain)) {
163 this->m_numToDrain = numBuffers;
170 if (0 == this->m_numToDrain) {
178 if (!this->m_waitForBuffer) {
180 this->sendStoredBuffer();
188 void BufferAccumulator ::sendStoredBuffer() {
191 if ((this->m_numToDrain == 0) ||
192 (this->m_numDrained < this->m_numToDrain)) {
194 const bool status = this->m_bufferQueue.dequeue(buffer);
196 this->m_numDrained++;
198 this->m_waitForBuffer =
true;
199 this->m_send =
false;
200 }
else if (this->m_numToDrain > 0) {
202 static_cast<U32>(this->m_numToDrain));
210 if ((this->m_numToDrain > 0) &&
211 (this->m_numDrained == this->m_numToDrain)) {
215 this->m_numToDrain = 0;
216 this->m_numDrained = 0;
217 this->m_send =
false;
void bufferSendOutReturn_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port bufferSendOutReturn.
FwIdType FwOpcodeType
The type of a command opcode.
PlatformSizeType FwSizeType
virtual void * allocate(const FwEnumStoreType identifier, FwSizeType &size, bool &recoverable)=0
Allocate memory.
void log_ACTIVITY_HI_BA_PartialDrainDone(U32 numDrained) const
void log_ACTIVITY_HI_BA_BufferAccepted() const
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
void log_WARNING_LO_BA_NonBlockDrain(U32 numWillDrain, U32 numReqDrain) const
BufferAccumulator(const char *const compName)
void log_WARNING_HI_BA_StillDraining(U32 numDrained, U32 numToDrain) const
void tlmWrite_BA_NumQueuedBuffers(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
void allocateQueue(FwEnumStoreType identifier, Fw::MemAllocator &allocator, FwSizeType maxNumBuffers)
Command successfully executed.
void log_WARNING_HI_BA_AlreadyDraining() const
PlatformIndexType FwIndexType
void deallocateQueue(Fw::MemAllocator &allocator)
Return allocated queue. Should be done during shutdown.
C++ header for working with basic fprime types.
void log_WARNING_HI_BA_DrainStalled(U32 numDrained, U32 numToDrain) const
void log_WARNING_HI_BA_QueueFull() const
Command failed validation.
RateGroupDivider component implementation.
void bufferSendOutDrain_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port bufferSendOutDrain.
virtual void deallocate(const FwEnumStoreType identifier, void *ptr)=0
Deallocate memory.
Auto-generated base for BufferAccumulator component.
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.