F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
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 #include <limits>
17 
18 namespace Svc {
19 
20 // ----------------------------------------------------------------------
21 // Types
22 // ----------------------------------------------------------------------
23 
24 class ComQueue final : public ComQueueComponentBase {
25  public:
28 
31 
32  static_assert((COM_PORT_COUNT + BUFFER_PORT_COUNT) <= std::numeric_limits<FwIndexType>::max(),
33  "FwIndexType not large enough to hold com and buffer ports");
36 
51  };
52 
68  };
69 
70  private:
71  // ----------------------------------------------------------------------
72  // Internal data structures
73  // ----------------------------------------------------------------------
74 
80  struct QueueMetadata {
81  FwSizeType depth;
82  FwIndexType priority;
83  FwIndexType index;
84  FwSizeType msgSize;
85  };
86 
90  enum SendState {
91  READY,
92  WAITING
93  };
94 
95  public:
96  // ----------------------------------------------------------------------
97  // Construction, initialization, and destruction
98  // ----------------------------------------------------------------------
99 
102  ComQueue(const char* const compName
103  );
104 
107  ~ComQueue();
108 
113  void configure(QueueConfigurationTable queueConfig,
114  FwEnumStoreType allocationId,
115  Fw::MemAllocator& allocator
116  );
117 
120  void cleanup();
121 
122  private:
123  // ----------------------------------------------------------------------
124  // Handler implementations for user-defined typed input ports
125  // ----------------------------------------------------------------------
126 
129  void bufferQueueIn_handler(const FwIndexType portNum,
130  Fw::Buffer& fwBuffer ) override;
131 
134  void comPacketQueueIn_handler(const FwIndexType portNum,
135  Fw::ComBuffer& data,
136  U32 context
137  ) override;
138 
141  void comStatusIn_handler(const FwIndexType portNum,
142  Fw::Success& condition
143  ) override;
144 
147  void run_handler(const FwIndexType portNum,
148  U32 context
149  ) override;
150 
154  void bufferReturnIn_handler(FwIndexType portNum,
155  Fw::Buffer& data,
156  const ComCfg::FrameContext& context) override;
157 
158 
159  // ----------------------------------------------------------------------
160  // Hook implementations for typed async input ports
161  // ----------------------------------------------------------------------
162 
165  void bufferQueueIn_overflowHook(FwIndexType portNum,
166  Fw::Buffer& fwBuffer
167  ) override;
168 
169  // ----------------------------------------------------------------------
170  // Helper Functions
171  // ----------------------------------------------------------------------
172 
175  bool enqueue(const FwIndexType queueNum,
176  QueueType queueType,
177  const U8* data,
178  const FwSizeType size
179  );
180 
183  void sendComBuffer(Fw::ComBuffer& comBuffer,
184  FwIndexType queueIndex
185  );
186 
189  void sendBuffer(Fw::Buffer& buffer,
190  FwIndexType queueIndex
191  );
192 
195  void processQueue();
196 
197 
198  PRIVATE:
199  // ----------------------------------------------------------------------
200  // Member variables
201  // ----------------------------------------------------------------------
202  Types::Queue m_queues[TOTAL_PORT_COUNT];
203  QueueMetadata m_prioritizedList[TOTAL_PORT_COUNT];
204  bool m_throttle[TOTAL_PORT_COUNT];
205  SendState m_state;
206 
207  // Storage for Fw::MemAllocator properties
208  FwEnumStoreType m_allocationId;
209  Fw::MemAllocator* m_allocator;
210  void* m_allocation;
211 
212 };
213 
214 } // end namespace Svc
215 
216 #endif
configuration data for each queue
Definition: ComQueue.hpp:48
PlatformSizeType FwSizeType
I32 FwEnumStoreType
QueueConfigurationEntry entries[TOTAL_PORT_COUNT]
Definition: ComQueue.hpp:63
configuration table for each queue
Definition: ComQueue.hpp:62
static const FwIndexType TOTAL_PORT_COUNT
Total count of input buffer ports and thus total queues.
Definition: ComQueue.hpp:35
ComQueue(const char *const compName)
Definition: ComQueue.cpp:30
void cleanup()
Definition: ComQueue.cpp:44
static const FwIndexType BUFFER_PORT_COUNT
Definition: ComQueue.hpp:30
static const FwIndexType COM_PORT_COUNT
< Count of Fw::Com input ports and thus Fw::Com queues
Definition: ComQueue.hpp:27
QueueConfigurationTable()
constructs a basic un-prioritized table with depth 0
Definition: ComQueue.cpp:21
FwIndexType priority
Priority of the queue [0, TOTAL_PORT_COUNT)
Definition: ComQueue.hpp:50
FwSizeType depth
Depth of the queue [0, infinity)
Definition: ComQueue.hpp:49
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:56
PlatformIndexType FwIndexType
Type used to pass context info between components during framing/deframing.
RateGroupDivider component implementation.
Defines a base class for a memory allocator for classes.
Success/Failure.
void configure(QueueConfigurationTable queueConfig, FwEnumStoreType allocationId, Fw::MemAllocator &allocator)
Definition: ComQueue.cpp:51
Auto-generated base for ComQueue component.