30 m_bufferMemory(nullptr),
33 m_waitForBuffer(false),
53 this->m_allocatorId = identifier;
56 (std::numeric_limits<FwSizeType>::max() / maxNumBuffers) >=
sizeof(
Fw::Buffer)
59 bool recoverable =
false;
60 this->m_bufferMemory =
static_cast<Fw::Buffer*
>(
61 allocator.
allocate(identifier, memSize, recoverable));
63 m_bufferQueue.init(this->m_bufferMemory, maxNumBuffers);
67 allocator.
deallocate(static_cast<FwEnumStoreType>(this->m_allocatorId), this->m_bufferMemory);
74 void BufferAccumulator ::bufferSendInFill_handler(
const FwIndexType portNum,
77 const bool status = this->m_bufferQueue.enqueue(buffer);
79 if (this->m_numWarnings > 0) {
82 this->m_numWarnings = 0;
84 if (this->m_numWarnings == 0) {
90 this->sendStoredBuffer();
96 void BufferAccumulator ::bufferSendInReturn_handler(
100 this->m_waitForBuffer =
false;
102 (this->m_numDrained < this->m_numToDrain)) {
105 this->sendStoredBuffer();
109 void BufferAccumulator ::pingIn_handler(
const FwIndexType portNum,
118 void BufferAccumulator ::BA_SetMode_cmdHandler(
const FwOpcodeType opCode,
120 BufferAccumulator_OpState mode) {
123 if (this->m_numToDrain > 0) {
125 this->m_numToDrain = 0;
126 this->m_numDrained = 0;
133 if (!this->m_waitForBuffer) {
135 this->sendStoredBuffer();
138 this->m_send =
false;
143 void BufferAccumulator ::BA_DrainBuffers_cmdHandler(
144 const FwOpcodeType opCode,
const U32 cmdSeq, U32 numToDrain,
145 BufferAccumulator_BlockMode blockMode) {
147 if (this->m_numDrained < this->m_numToDrain) {
159 if (numToDrain == 0) {
165 this->m_opCode = opCode;
166 this->m_cmdSeq = cmdSeq;
167 this->m_numDrained = 0;
168 this->m_numToDrain =
static_cast<FwSizeType>(numToDrain);
171 FwSizeType numBuffers = this->m_bufferQueue.getSize();
173 if (numBuffers < static_cast<FwSizeType>(numToDrain)) {
174 this->m_numToDrain = numBuffers;
181 if (0 == this->m_numToDrain) {
189 if (!this->m_waitForBuffer) {
191 this->sendStoredBuffer();
199 void BufferAccumulator ::sendStoredBuffer() {
203 if ((this->m_numToDrain == 0) ||
204 (this->m_numDrained < this->m_numToDrain)) {
206 const bool status = this->m_bufferQueue.dequeue(buffer);
208 this->m_numDrained++;
210 this->m_waitForBuffer =
true;
211 this->m_send =
false;
212 }
else if (this->m_numToDrain > 0) {
221 if ((this->m_numToDrain > 0) &&
222 (this->m_numDrained == this->m_numToDrain)) {
226 this->m_numToDrain = 0;
227 this->m_numDrained = 0;
228 this->m_send =
false;
void bufferSendOutReturn_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port bufferSendOutReturn.
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)
U32 FwOpcodeType
The type of a command opcode.
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.