17 ComQueue ::QueueConfigurationTable ::QueueConfigurationTable() {
19 this->entries[i].priority = 0;
20 this->entries[i].depth = 0;
29 m_allocation(nullptr) {
32 this->m_throttle[i] =
false;
44 if ((this->m_allocator !=
nullptr) && (this->m_allocation !=
nullptr)) {
45 this->m_allocator->
deallocate(this->m_allocationId, this->m_allocation);
56 this->m_allocator = &allocator;
57 this->m_allocationId = allocationId;
58 this->m_allocation =
nullptr;
82 QueueMetadata& entry = this->m_prioritizedList[currentPriorityIndex];
85 entry.index = entryIndex;
89 totalAllocation +=
static_cast<NATIVE_UINT_TYPE>(entry.depth * entry.msgSize);
90 currentPriorityIndex++;
95 bool recoverable =
false;
96 this->m_allocation = this->m_allocator->
allocate(this->m_allocationId, totalAllocation, recoverable);
104 FwSizeType allocationSize = this->m_prioritizedList[i].depth * this->m_prioritizedList[i].msgSize;
106 this->m_prioritizedList[i].index);
108 (allocationSize + allocationOffset) <= totalAllocation,
114 if (allocationSize > 0) {
115 this->m_queues[this->m_prioritizedList[i].index].
setup(
116 reinterpret_cast<U8*
>(this->m_allocation) + allocationOffset, allocationSize,
117 this->m_prioritizedList[i].depth, this->m_prioritizedList[i].msgSize);
119 allocationOffset += allocationSize;
123 allocationOffset == totalAllocation,
146 switch (this->m_state) {
150 this->m_state = READY;
151 this->processQueue();
153 FW_ASSERT((this->m_state == WAITING || this->m_state == READY), this->m_state);
155 this->m_state = WAITING;
166 void ComQueue::run_handler(
const NATIVE_INT_TYPE portNum, U32 context) {
168 ComQueueDepth comQueueDepth;
169 for (U32 i = 0; i < comQueueDepth.SIZE; i++) {
176 BuffQueueDepth buffQueueDepth;
177 for (U32 i = 0; i < buffQueueDepth.SIZE; i++) {
188 void ComQueue::enqueue(
const FwIndexType queueNum, QueueType queueType,
const U8* data,
const FwSizeType size) {
194 expectedSize == size,
201 this->m_throttle[queueNum] =
true;
204 if (this->m_state == READY) {
205 this->processQueue();
212 this->m_state = WAITING;
215 void ComQueue::sendBuffer(
Fw::Buffer& buffer) {
219 this->m_state = WAITING;
222 void ComQueue::processQueue() {
230 for (priorityIndex = 0; priorityIndex <
TOTAL_PORT_COUNT; priorityIndex++) {
231 QueueMetadata& entry = this->m_prioritizedList[priorityIndex];
242 queue.
dequeue(
reinterpret_cast<U8*
>(&comBuffer),
sizeof(comBuffer));
243 this->sendComBuffer(comBuffer);
246 queue.
dequeue(
reinterpret_cast<U8*
>(&buffer),
sizeof(buffer));
247 this->sendBuffer(buffer);
251 this->m_throttle[entry.index] =
false;
254 sendPriority = entry.priority;
261 for (priorityIndex++;
262 priorityIndex <
TOTAL_PORT_COUNT && (this->m_prioritizedList[priorityIndex].priority == sendPriority);
265 QueueMetadata temp = this->m_prioritizedList[priorityIndex];
266 this->m_prioritizedList[priorityIndex] = this->m_prioritizedList[priorityIndex - 1];
267 this->m_prioritizedList[priorityIndex - 1] = temp;
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
PlatformUIntType NATIVE_UINT_TYPE
C++ header for working with basic fprime types.
PlatformAssertArgType FwAssertArgType
PlatformSizeType FwSizeType
PlatformIndexType FwIndexType
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.
@ SUCCESS
Representing success.
Auto-generated base for ComQueue component.
void tlmWrite_comQueueDepth(const Svc::ComQueueDepth &arg, Fw::Time _tlmTime=Fw::Time())
void tlmWrite_buffQueueDepth(const Svc::BuffQueueDepth &arg, Fw::Time _tlmTime=Fw::Time())
void buffQueueSend_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port buffQueueSend.
void comQueueSend_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Invoke output port comQueueSend.
void log_WARNING_HI_QueueOverflow(Svc::QueueType queueType, U32 index)
ComQueue(const char *const compName)
void configure(QueueConfigurationTable queueConfig, NATIVE_UINT_TYPE allocationId, Fw::MemAllocator &allocator)
static const FwIndexType BUFFER_PORT_COUNT
Total count of input buffer ports and thus total queues.
static const FwIndexType COM_PORT_COUNT
< Count of Fw::Com input ports and thus Fw::Com queues
static const FwIndexType TOTAL_PORT_COUNT
NATIVE_UINT_TYPE getQueueSize() const
void setup(U8 *const storage, const FwSizeType storage_size, const FwSizeType depth, const FwSizeType message_size)
setup the queue object to setup storage
Fw::SerializeStatus dequeue(U8 *const message, const FwSizeType size)
pops a fixed-size message off the front of the queue
Fw::SerializeStatus enqueue(const U8 *const message, const FwSizeType size)
pushes a fixed-size message onto the back of the queue
NATIVE_UINT_TYPE get_high_water_mark() const
void clear_high_water_mark()
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_NO_ROOM_LEFT
No room left in the buffer to serialize data.
FwIndexType priority
Priority of the queue [0, TOTAL_PORT_COUNT)
FwSizeType depth
Depth of the queue [0, infinity)
configuration table for each queue
QueueConfigurationEntry entries[TOTAL_PORT_COUNT]