27 BufferAccumulator(
const char*
const compName)
30 m_bufferMemory(nullptr),
33 m_waitForBuffer(false),
42BufferAccumulator ::~BufferAccumulator() {}
48void BufferAccumulator ::allocateQueue(
53 this->m_allocatorId = identifier;
55 bool recoverable =
false;
56 this->m_bufferMemory =
static_cast<Fw::Buffer*
>(
59 m_bufferQueue.init(this->m_bufferMemory, maxNumBuffers);
70void BufferAccumulator ::bufferSendInFill_handler(
const NATIVE_INT_TYPE portNum,
73 const bool status = this->m_bufferQueue.enqueue(buffer);
75 if (this->m_numWarnings > 0) {
76 this->log_ACTIVITY_HI_BA_BufferAccepted();
78 this->m_numWarnings = 0;
80 if (this->m_numWarnings == 0) {
81 this->log_WARNING_HI_BA_QueueFull();
86 this->sendStoredBuffer();
89 this->tlmWrite_BA_NumQueuedBuffers(this->m_bufferQueue.getSize());
92void BufferAccumulator ::bufferSendInReturn_handler(
95 this->bufferSendOutReturn_out(0, buffer);
96 this->m_waitForBuffer =
false;
98 (this->m_numDrained < this->m_numToDrain)) {
101 this->sendStoredBuffer();
107 this->pingOut_out(0, key);
114void BufferAccumulator ::BA_SetMode_cmdHandler(
const FwOpcodeType opCode,
116 BufferAccumulator_OpState mode) {
119 if (this->m_numToDrain > 0) {
121 this->m_numToDrain = 0;
122 this->m_numDrained = 0;
129 if (!this->m_waitForBuffer) {
131 this->sendStoredBuffer();
134 this->m_send =
false;
139void BufferAccumulator ::BA_DrainBuffers_cmdHandler(
140 const FwOpcodeType opCode,
const U32 cmdSeq, U32 numToDrain,
141 BufferAccumulator_BlockMode blockMode) {
143 if (this->m_numDrained < this->m_numToDrain) {
144 this->log_WARNING_HI_BA_StillDraining(this->m_numDrained, this->m_numToDrain);
150 this->log_WARNING_HI_BA_AlreadyDraining();
155 if (numToDrain == 0) {
156 this->log_ACTIVITY_HI_BA_PartialDrainDone(0);
161 this->m_opCode = opCode;
162 this->m_cmdSeq = cmdSeq;
163 this->m_numDrained = 0;
164 this->m_numToDrain = numToDrain;
167 U32 numBuffers = this->m_bufferQueue.getSize();
169 if (numBuffers < numToDrain) {
170 this->m_numToDrain = numBuffers;
171 this->log_WARNING_LO_BA_NonBlockDrain(this->m_numToDrain, numToDrain);
177 if (0 == this->m_numToDrain) {
178 this->log_ACTIVITY_HI_BA_PartialDrainDone(0);
185 if (!this->m_waitForBuffer) {
187 this->sendStoredBuffer();
195void BufferAccumulator ::sendStoredBuffer() {
199 if ((this->m_numToDrain == 0) ||
200 (this->m_numDrained < this->m_numToDrain)) {
202 const bool status = this->m_bufferQueue.dequeue(buffer);
204 this->m_numDrained++;
205 this->bufferSendOutDrain_out(0, buffer);
206 this->m_waitForBuffer =
true;
207 this->m_send =
false;
208 }
else if (this->m_numToDrain > 0) {
209 this->log_WARNING_HI_BA_DrainStalled(this->m_numDrained, this->m_numToDrain);
217 if ((this->m_numToDrain > 0) &&
218 (this->m_numDrained == this->m_numToDrain)) {
220 this->log_ACTIVITY_HI_BA_PartialDrainDone(this->m_numDrained);
222 this->m_numToDrain = 0;
223 this->m_numDrained = 0;
224 this->m_send =
false;
228 this->tlmWrite_BA_NumQueuedBuffers(this->m_bufferQueue.getSize());
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 * allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE &size, bool &recoverable)=0
Allocate memory.
virtual void deallocate(const NATIVE_UINT_TYPE identifier, void *ptr)=0
Deallocate memory.
Auto-generated base for BufferAccumulator component.