F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
ComQueue.hpp
Go to the documentation of this file.
1// ======================================================================
2// \title ComQueue.hpp
3// \author vbai
4// \brief hpp file for ComQueue component implementation class
5// ======================================================================
6
7#ifndef Svc_ComQueue_HPP
8#define Svc_ComQueue_HPP
9
10#include <Fw/Buffer/Buffer.hpp>
11#include <Fw/Com/ComBuffer.hpp>
13#include <Utils/Types/Queue.hpp>
15#include "Os/Mutex.hpp"
16
17namespace Svc {
18
19// ----------------------------------------------------------------------
20// Types
21// ----------------------------------------------------------------------
22
24 public:
27
30
33
49
66
67 private:
68 // ----------------------------------------------------------------------
69 // Internal data structures
70 // ----------------------------------------------------------------------
71
77 struct QueueMetadata {
78 FwSizeType depth;
79 FwIndexType priority;
80 FwIndexType index;
81 FwSizeType msgSize;
82 };
83
87 enum SendState {
88 READY,
89 WAITING
90 };
91
92 public:
93 // ----------------------------------------------------------------------
94 // Construction, initialization, and destruction
95 // ----------------------------------------------------------------------
96
99 ComQueue(const char* const compName
100 );
101
104 ~ComQueue();
105
110 void configure(QueueConfigurationTable queueConfig,
111 NATIVE_UINT_TYPE allocationId,
112 Fw::MemAllocator& allocator
113 );
114
117 void cleanup();
118
119 private:
120 // ----------------------------------------------------------------------
121 // Handler implementations for user-defined typed input ports
122 // ----------------------------------------------------------------------
123
126 void buffQueueIn_handler(const NATIVE_INT_TYPE portNum,
127 Fw::Buffer& fwBuffer );
128
131 void comQueueIn_handler(const NATIVE_INT_TYPE portNum,
132 Fw::ComBuffer& data,
133 U32 context
134 );
135
138 void comStatusIn_handler(const NATIVE_INT_TYPE portNum,
139 Fw::Success& condition
140 );
141
144 void run_handler(const NATIVE_INT_TYPE portNum,
145 U32 context
146 );
147
148 // ----------------------------------------------------------------------
149 // Hook implementations for typed async input ports
150 // ----------------------------------------------------------------------
151
154 void buffQueueIn_overflowHook(FwIndexType portNum,
155 Fw::Buffer& fwBuffer
156 );
157
158 // ----------------------------------------------------------------------
159 // Helper Functions
160 // ----------------------------------------------------------------------
161
164 bool enqueue(const FwIndexType queueNum,
165 QueueType queueType,
166 const U8* data,
167 const FwSizeType size
168 );
169
172 void sendComBuffer(Fw::ComBuffer& comBuffer
173 );
174
177 void sendBuffer(Fw::Buffer& buffer
178 );
179
182 void processQueue();
183 // ----------------------------------------------------------------------
184 // Member variables
185 // ----------------------------------------------------------------------
187 QueueMetadata m_prioritizedList[TOTAL_PORT_COUNT];
188 bool m_throttle[TOTAL_PORT_COUNT];
189 SendState m_state;
190
191 // Storage for Fw::MemAllocator properties
192 NATIVE_UINT_TYPE m_allocationId;
193 Fw::MemAllocator* m_allocator;
194 void* m_allocation;
195};
196
197} // end namespace Svc
198
199#endif
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:55
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:30
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:56
PlatformSizeType FwSizeType
Definition FpConfig.h:35
PlatformIndexType FwIndexType
Definition FpConfig.h:25
Defines a base class for a memory allocator for classes.
Success/Failure.
Auto-generated base for ComQueue component.
void configure(QueueConfigurationTable queueConfig, NATIVE_UINT_TYPE allocationId, Fw::MemAllocator &allocator)
Definition ComQueue.cpp:45
void cleanup()
Definition ComQueue.cpp:38
static const FwIndexType BUFFER_PORT_COUNT
Total count of input buffer ports and thus total queues.
Definition ComQueue.hpp:29
static const FwIndexType COM_PORT_COUNT
< Count of Fw::Com input ports and thus Fw::Com queues
Definition ComQueue.hpp:26
static const FwIndexType TOTAL_PORT_COUNT
Definition ComQueue.hpp:32
configuration data for each queue
Definition ComQueue.hpp:45
FwIndexType priority
Priority of the queue [0, TOTAL_PORT_COUNT)
Definition ComQueue.hpp:47
FwSizeType depth
Depth of the queue [0, infinity)
Definition ComQueue.hpp:46
configuration table for each queue
Definition ComQueue.hpp:59
QueueConfigurationEntry entries[TOTAL_PORT_COUNT]
Definition ComQueue.hpp:60
QueueConfigurationTable()
constructs a basic un-prioritized table with depth 0
Definition ComQueue.cpp:17