30 m_bufferMemory(nullptr),
33 m_waitForBuffer(false),
58 this->m_allocatorId = identifier;
60 bool recoverable =
false;
61 this->m_bufferMemory =
static_cast<Fw::Buffer*
>(
62 allocator.
allocate(identifier, memSize, recoverable));
64 m_bufferQueue.init(this->m_bufferMemory, maxNumBuffers);
68 allocator.
deallocate(this->m_allocatorId, this->m_bufferMemory);
75 void BufferAccumulator ::bufferSendInFill_handler(
const NATIVE_INT_TYPE portNum,
78 const bool status = this->m_bufferQueue.enqueue(buffer);
80 if (this->m_numWarnings > 0) {
83 this->m_numWarnings = 0;
85 if (this->m_numWarnings == 0) {
91 this->sendStoredBuffer();
97 void BufferAccumulator ::bufferSendInReturn_handler(
101 this->m_waitForBuffer =
false;
103 (this->m_numDrained < this->m_numToDrain)) {
106 this->sendStoredBuffer();
119 void BufferAccumulator ::BA_SetMode_cmdHandler(
const FwOpcodeType opCode,
121 BufferAccumulator_OpState mode) {
124 if (this->m_numToDrain > 0) {
126 this->m_numToDrain = 0;
127 this->m_numDrained = 0;
134 if (!this->m_waitForBuffer) {
136 this->sendStoredBuffer();
139 this->m_send =
false;
144 void BufferAccumulator ::BA_DrainBuffers_cmdHandler(
145 const FwOpcodeType opCode,
const U32 cmdSeq, U32 numToDrain,
146 BufferAccumulator_BlockMode blockMode) {
148 if (this->m_numDrained < this->m_numToDrain) {
160 if (numToDrain == 0) {
166 this->m_opCode = opCode;
167 this->m_cmdSeq = cmdSeq;
168 this->m_numDrained = 0;
169 this->m_numToDrain = numToDrain;
172 U32 numBuffers = this->m_bufferQueue.getSize();
174 if (numBuffers < numToDrain) {
175 this->m_numToDrain = numBuffers;
182 if (0 == this->m_numToDrain) {
190 if (!this->m_waitForBuffer) {
192 this->sendStoredBuffer();
200 void BufferAccumulator ::sendStoredBuffer() {
204 if ((this->m_numToDrain == 0) ||
205 (this->m_numDrained < this->m_numToDrain)) {
207 const bool status = this->m_bufferQueue.dequeue(buffer);
209 this->m_numDrained++;
211 this->m_waitForBuffer =
true;
212 this->m_send =
false;
213 }
else if (this->m_numToDrain > 0) {
222 if ((this->m_numToDrain > 0) &&
223 (this->m_numDrained == this->m_numToDrain)) {
227 this->m_numToDrain = 0;
228 this->m_numDrained = 0;
229 this->m_send =
false;
PlatformIntType NATIVE_INT_TYPE
PlatformUIntType NATIVE_UINT_TYPE
C++ header for working with basic fprime types.
@ VALIDATION_ERROR
Command failed validation.
@ OK
Command successfully executed.
virtual void deallocate(const NATIVE_UINT_TYPE identifier, void *ptr)=0
Deallocate memory.
virtual void * allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE &size, bool &recoverable)=0
Allocate memory.
void init()
Object initializer.
Auto-generated base for BufferAccumulator component.
void log_WARNING_HI_BA_StillDraining(U32 numDrained, U32 numToDrain)
void bufferSendOutReturn_out(NATIVE_INT_TYPE portNum, Fw::Buffer &fwBuffer)
Invoke output port bufferSendOutReturn.
void log_ACTIVITY_HI_BA_PartialDrainDone(U32 numDrained)
void bufferSendOutDrain_out(NATIVE_INT_TYPE portNum, Fw::Buffer &fwBuffer)
Invoke output port bufferSendOutDrain.
void log_ACTIVITY_HI_BA_BufferAccepted()
void pingOut_out(NATIVE_INT_TYPE portNum, U32 key)
Invoke output port pingOut.
void log_WARNING_HI_BA_QueueFull()
void log_WARNING_HI_BA_AlreadyDraining()
void log_WARNING_LO_BA_NonBlockDrain(U32 numWillDrain, U32 numReqDrain)
void log_WARNING_HI_BA_DrainStalled(U32 numDrained, U32 numToDrain)
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
void tlmWrite_BA_NumQueuedBuffers(U32 arg, Fw::Time _tlmTime=Fw::Time())
void allocateQueue(NATIVE_INT_TYPE identifier, Fw::MemAllocator &allocator, NATIVE_UINT_TYPE maxNumBuffers)
void deallocateQueue(Fw::MemAllocator &allocator)
Return allocated queue. Should be done during shutdown.
BufferAccumulator(const char *const compName)