27 BufferAccumulator(
const char*
const compName)
30 m_bufferMemory(nullptr),
33 m_waitForBuffer(false),
26BufferAccumulator :: {
…}
47BufferAccumulator ::~BufferAccumulator() {}
53void BufferAccumulator ::allocateQueue(
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);
53void BufferAccumulator ::allocateQueue( {
…}
68 allocator.
deallocate(this->m_allocatorId, this->m_bufferMemory);
75void BufferAccumulator ::bufferSendInFill_handler(
const NATIVE_INT_TYPE portNum,
78 const bool status = this->m_bufferQueue.enqueue(buffer);
80 if (this->m_numWarnings > 0) {
81 this->log_ACTIVITY_HI_BA_BufferAccepted();
83 this->m_numWarnings = 0;
85 if (this->m_numWarnings == 0) {
86 this->log_WARNING_HI_BA_QueueFull();
91 this->sendStoredBuffer();
94 this->tlmWrite_BA_NumQueuedBuffers(this->m_bufferQueue.getSize());
97void BufferAccumulator ::bufferSendInReturn_handler(
100 this->bufferSendOutReturn_out(0, buffer);
101 this->m_waitForBuffer =
false;
103 (this->m_numDrained < this->m_numToDrain)) {
106 this->sendStoredBuffer();
112 this->pingOut_out(0, key);
119void 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;
144void 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) {
149 this->log_WARNING_HI_BA_StillDraining(this->m_numDrained, this->m_numToDrain);
155 this->log_WARNING_HI_BA_AlreadyDraining();
160 if (numToDrain == 0) {
161 this->log_ACTIVITY_HI_BA_PartialDrainDone(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;
176 this->log_WARNING_LO_BA_NonBlockDrain(this->m_numToDrain, numToDrain);
182 if (0 == this->m_numToDrain) {
183 this->log_ACTIVITY_HI_BA_PartialDrainDone(0);
190 if (!this->m_waitForBuffer) {
192 this->sendStoredBuffer();
200void 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++;
210 this->bufferSendOutDrain_out(0, buffer);
211 this->m_waitForBuffer =
true;
212 this->m_send =
false;
213 }
else if (this->m_numToDrain > 0) {
214 this->log_WARNING_HI_BA_DrainStalled(this->m_numDrained, this->m_numToDrain);
222 if ((this->m_numToDrain > 0) &&
223 (this->m_numDrained == this->m_numToDrain)) {
225 this->log_ACTIVITY_HI_BA_PartialDrainDone(this->m_numDrained);
227 this->m_numToDrain = 0;
228 this->m_numDrained = 0;
229 this->m_send =
false;
233 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.
void init()
Object initializer.
Auto-generated base for BufferAccumulator component.