27 BufferAccumulator(
const char*
const compName)
30 bufferMemory(nullptr),
26BufferAccumulator :: {
…}
47BufferAccumulator ::~BufferAccumulator() {}
53void BufferAccumulator ::allocateQueue(
58 this->allocatorId = identifier;
60 bool recoverable =
false;
62 allocator.
allocate(identifier, memSize, recoverable));
64 bufferQueue.init(this->bufferMemory, maxNumBuffers);
53void BufferAccumulator ::allocateQueue( {
…}
68 allocator.
deallocate(this->allocatorId, this->bufferMemory);
75void BufferAccumulator ::bufferSendInFill_handler(
const NATIVE_INT_TYPE portNum,
78 const bool status = this->bufferQueue.enqueue(buffer);
80 if (this->numWarnings > 0) {
81 this->log_ACTIVITY_HI_BA_BufferAccepted();
83 this->numWarnings = 0;
85 if (this->numWarnings == 0) {
86 this->log_WARNING_HI_BA_QueueFull();
91 this->sendStoredBuffer();
94 this->tlmWrite_BA_NumQueuedBuffers(this->bufferQueue.getSize());
97void BufferAccumulator ::bufferSendInReturn_handler(
100 this->bufferSendOutReturn_out(0, buffer);
101 this->waitForBuffer =
false;
103 (this->numDrained < this->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->numToDrain > 0) {
126 this->numToDrain = 0;
127 this->numDrained = 0;
134 if (!this->waitForBuffer) {
136 this->sendStoredBuffer();
144void BufferAccumulator ::BA_DrainBuffers_cmdHandler(
145 const FwOpcodeType opCode,
const U32 cmdSeq, U32 numToDrain,
146 BufferAccumulator_BlockMode blockMode) {
148 if (this->numDrained < this->numToDrain) {
149 this->log_WARNING_HI_BA_StillDraining(this->numDrained, this->numToDrain);
155 this->log_WARNING_HI_BA_AlreadyDraining();
160 if (numToDrain == 0) {
161 this->log_ACTIVITY_HI_BA_PartialDrainDone(0);
166 this->opCode = opCode;
167 this->cmdSeq = cmdSeq;
168 this->numDrained = 0;
169 this->numToDrain = numToDrain;
172 U32 numBuffers = this->bufferQueue.getSize();
174 if (numBuffers < numToDrain) {
175 this->numToDrain = numBuffers;
176 this->log_WARNING_LO_BA_NonBlockDrain(this->numToDrain, numToDrain);
182 if (0 == this->numToDrain) {
183 this->log_ACTIVITY_HI_BA_PartialDrainDone(0);
190 if (!this->waitForBuffer) {
192 this->sendStoredBuffer();
200void BufferAccumulator ::sendStoredBuffer() {
204 if ((this->numToDrain == 0) ||
205 (this->numDrained < this->numToDrain)) {
207 const bool status = this->bufferQueue.dequeue(buffer);
210 this->bufferSendOutDrain_out(0, buffer);
211 this->waitForBuffer =
true;
213 }
else if (this->numToDrain > 0) {
214 this->log_WARNING_HI_BA_DrainStalled(this->numDrained, this->numToDrain);
222 if ((this->numToDrain > 0) &&
223 (this->numDrained == this->numToDrain)) {
225 this->log_ACTIVITY_HI_BA_PartialDrainDone(this->numDrained);
227 this->numToDrain = 0;
228 this->numDrained = 0;
233 this->tlmWrite_BA_NumQueuedBuffers(this->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.