29 m_bufferMemory(nullptr),
32 m_waitForBuffer(false),
52 this->m_allocatorId = identifier;
56 bool recoverable =
false;
57 this->m_bufferMemory =
static_cast<Fw::Buffer*
>(allocator.
allocate(identifier, memSize, recoverable));
59 m_bufferQueue.init(this->m_bufferMemory, maxNumBuffers);
60 this->m_mode = initialMode;
65 allocator.
deallocate(static_cast<FwEnumStoreType>(this->m_allocatorId), this->m_bufferMemory);
73 const bool status = this->m_bufferQueue.enqueue(buffer);
75 if (this->m_numWarnings > 0) {
78 this->m_numWarnings = 0;
80 if (this->m_numWarnings == 0) {
86 this->sendStoredBuffer();
94 this->m_waitForBuffer =
false;
96 (this->m_numDrained < this->m_numToDrain)) {
99 this->sendStoredBuffer();
103 void BufferAccumulator ::pingIn_handler(
const FwIndexType portNum, U32 key) {
111 void BufferAccumulator ::BA_SetMode_cmdHandler(
const FwOpcodeType opCode,
113 BufferAccumulator_OpState mode) {
115 if (this->m_numToDrain > 0) {
117 this->m_numToDrain = 0;
118 this->m_numDrained = 0;
125 if (!this->m_waitForBuffer) {
127 this->sendStoredBuffer();
130 this->m_send =
false;
135 void BufferAccumulator ::BA_DrainBuffers_cmdHandler(
const FwOpcodeType opCode,
138 BufferAccumulator_BlockMode blockMode) {
139 if (this->m_numDrained < this->m_numToDrain) {
141 static_cast<U32>(this->m_numToDrain));
152 if (numToDrain == 0) {
158 this->m_opCode = opCode;
159 this->m_cmdSeq = cmdSeq;
160 this->m_numDrained = 0;
161 this->m_numToDrain =
static_cast<FwSizeType>(numToDrain);
164 FwSizeType numBuffers = this->m_bufferQueue.getSize();
166 if (numBuffers < static_cast<FwSizeType>(numToDrain)) {
167 this->m_numToDrain = numBuffers;
174 if (0 == this->m_numToDrain) {
182 if (!this->m_waitForBuffer) {
184 this->sendStoredBuffer();
192 void BufferAccumulator ::sendStoredBuffer() {
195 if ((this->m_numToDrain == 0) ||
196 (this->m_numDrained < this->m_numToDrain)) {
198 const bool status = this->m_bufferQueue.dequeue(buffer);
200 this->m_numDrained++;
202 this->m_waitForBuffer =
true;
203 this->m_send =
false;
204 }
else if (this->m_numToDrain > 0) {
206 static_cast<U32>(this->m_numToDrain));
214 if ((this->m_numToDrain > 0) &&
215 (this->m_numDrained == this->m_numToDrain)) {
219 this->m_numToDrain = 0;
220 this->m_numDrained = 0;
221 this->m_send =
false;
virtual void * allocate(const FwEnumStoreType identifier, FwSizeType &size, bool &recoverable, FwSizeType alignment=alignof(std::max_align_t))=0
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.
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.