27 m_bufferMemory(nullptr),
30 m_waitForBuffer(false),
50 this->m_allocatorId = identifier;
55 bool recoverable =
false;
58 m_bufferQueue.init(this->m_bufferMemory, maxNumBuffers);
59 this->m_mode = initialMode;
64 allocator.
deallocate(static_cast<FwEnumStoreType>(this->m_allocatorId), this->m_bufferMemory);
72 const bool status = this->m_bufferQueue.enqueue(buffer);
74 if (this->m_numWarnings > 0) {
77 this->m_numWarnings = 0;
79 if (this->m_numWarnings == 0) {
87 this->sendStoredBuffer();
95 this->m_waitForBuffer =
false;
97 (this->m_numDrained < this->m_numToDrain)) {
100 this->sendStoredBuffer();
104 void BufferAccumulator ::pingIn_handler(
const FwIndexType portNum, U32 key) {
112 void BufferAccumulator ::BA_SetMode_cmdHandler(
const FwOpcodeType opCode,
114 const BufferAccumulator_OpState& mode) {
116 if (this->m_numToDrain > 0) {
118 this->m_numToDrain = 0;
119 this->m_numDrained = 0;
126 if (!this->m_waitForBuffer) {
128 this->sendStoredBuffer();
131 this->m_send =
false;
136 void BufferAccumulator ::BA_DrainBuffers_cmdHandler(
const FwOpcodeType opCode,
139 const BufferAccumulator_BlockMode& blockMode) {
140 if (this->m_numDrained < this->m_numToDrain) {
142 static_cast<U32>(this->m_numToDrain));
153 if (numToDrain == 0) {
159 this->m_opCode = opCode;
160 this->m_cmdSeq = cmdSeq;
161 this->m_numDrained = 0;
162 this->m_numToDrain =
static_cast<FwSizeType>(numToDrain);
165 FwSizeType numBuffers = this->m_bufferQueue.getSize();
167 if (numBuffers < static_cast<FwSizeType>(numToDrain)) {
168 this->m_numToDrain = numBuffers;
175 if (0 == this->m_numToDrain) {
183 if (!this->m_waitForBuffer) {
185 this->sendStoredBuffer();
193 void BufferAccumulator ::sendStoredBuffer() {
196 if ((this->m_numToDrain == 0) ||
197 (this->m_numDrained < this->m_numToDrain)) {
199 const bool status = this->m_bufferQueue.dequeue(buffer);
201 this->m_numDrained++;
203 this->m_waitForBuffer =
true;
204 this->m_send =
false;
205 }
else if (this->m_numToDrain > 0) {
207 static_cast<U32>(this->m_numToDrain));
215 if ((this->m_numToDrain > 0) &&
216 (this->m_numDrained == this->m_numToDrain)) {
220 this->m_numToDrain = 0;
221 this->m_numDrained = 0;
222 this->m_send =
false;
FwIdType FwOpcodeType
The type of a command opcode.
PlatformSizeType FwSizeType
void bufferSendOutReturn_out(FwIndexType portNum, Fw::Buffer &fwBuffer) const
Invoke output port bufferSendOutReturn.
void log_ACTIVITY_HI_BA_PartialDrainDone(U32 numDrained) const
void log_ACTIVITY_HI_BA_BufferAccepted() const
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 pingOut_out(FwIndexType portNum, U32 key) const
Invoke output port pingOut.
void * checkedAllocate(const FwEnumStoreType identifier, FwSizeType &size, bool &recoverable, FwSizeType alignment=alignof(std::max_align_t))
Command successfully executed.
Memory Allocation base class.
void log_WARNING_HI_BA_AlreadyDraining() const
PlatformIndexType FwIndexType
void bufferSendOutDrain_out(FwIndexType portNum, Fw::Buffer &fwBuffer) const
Invoke output port bufferSendOutDrain.
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.
virtual void deallocate(const FwEnumStoreType identifier, void *ptr)=0
Auto-generated base for BufferAccumulator component.
void allocateQueue(FwEnumStoreType identifier, Fw::MemAllocator &allocator, FwSizeType maxNumBuffers, BufferAccumulator_OpState initialMode=BufferAccumulator_OpState::ACCUMULATE)
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.