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>
14 #include <limits>
16 #include "Os/Mutex.hpp"
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 dataReturnIn_handler(FwIndexType portNum,
155  Fw::Buffer& data,
156  const ComCfg::FrameContext& context) override;
157 
158  // ----------------------------------------------------------------------
159  // Hook implementations for typed async input ports
160  // ----------------------------------------------------------------------
161 
164  void bufferQueueIn_overflowHook(FwIndexType portNum,
165  Fw::Buffer& fwBuffer
166  ) override;
167 
168  // ----------------------------------------------------------------------
169  // Helper Functions
170  // ----------------------------------------------------------------------
171 
174  bool enqueue(const FwIndexType queueNum,
175  QueueType queueType,
176  const U8* data,
177  const FwSizeType size
178  );
179 
182  void sendComBuffer(Fw::ComBuffer& comBuffer,
183  FwIndexType queueIndex
184  );
185 
188  void sendBuffer(Fw::Buffer& buffer,
189  FwIndexType queueIndex
190  );
191 
194  void processQueue();
195 
196  private:
197  // ----------------------------------------------------------------------
198  // Member variables
199  // ----------------------------------------------------------------------
200  Types::Queue m_queues[TOTAL_PORT_COUNT];
201  QueueMetadata m_prioritizedList[TOTAL_PORT_COUNT];
202  bool m_throttle[TOTAL_PORT_COUNT];
203  SendState m_state;
204 
205  // Storage for Fw::MemAllocator properties
206  FwEnumStoreType m_allocationId;
207  Fw::MemAllocator* m_allocator;
208  void* m_allocation;
209 };
210 
211 } // end namespace Svc
212 
213 #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:31
void cleanup()
Definition: ComQueue.cpp:45
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:53
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:52
Auto-generated base for ComQueue component.