F´ Flight Software - C/C++ Documentation devel
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 void init(const NATIVE_INT_TYPE queueDepth,
105 const NATIVE_INT_TYPE instance = 0
106 );
107
110 ~ComQueue();
111
116 void configure(QueueConfigurationTable queueConfig,
117 NATIVE_UINT_TYPE allocationId,
118 Fw::MemAllocator& allocator
119 );
120
123 void cleanup();
124
125 private:
126 // ----------------------------------------------------------------------
127 // Handler implementations for user-defined typed input ports
128 // ----------------------------------------------------------------------
129
132 void buffQueueIn_handler(const NATIVE_INT_TYPE portNum,
133 Fw::Buffer& fwBuffer );
134
137 void comQueueIn_handler(const NATIVE_INT_TYPE portNum,
138 Fw::ComBuffer& data,
139 U32 context
140 );
141
144 void comStatusIn_handler(const NATIVE_INT_TYPE portNum,
145 Fw::Success& condition
146 );
147
150 void run_handler(const NATIVE_INT_TYPE portNum,
151 NATIVE_UINT_TYPE context
152 );
153
154 // ----------------------------------------------------------------------
155 // Helper Functions
156 // ----------------------------------------------------------------------
157
160 void enqueue(const FwIndexType queueNum,
161 QueueType queueType,
162 const U8* data,
163 const FwSizeType size
164 );
165
168 void sendComBuffer(Fw::ComBuffer& comBuffer
169 );
170
173 void sendBuffer(Fw::Buffer& buffer
174 );
175
178 void processQueue();
179 // ----------------------------------------------------------------------
180 // Member variables
181 // ----------------------------------------------------------------------
183 QueueMetadata m_prioritizedList[TOTAL_PORT_COUNT];
184 bool m_throttle[TOTAL_PORT_COUNT];
185 SendState m_state;
186
187 // Storage for Fw::MemAllocator properties
188 NATIVE_UINT_TYPE m_allocationId;
189 Fw::MemAllocator* m_allocator;
190 void* m_allocation;
191};
192
193} // end namespace Svc
194
195#endif
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:26
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:52
PlatformSizeType FwSizeType
Definition FpConfig.h:18
PlatformIndexType FwIndexType
Definition FpConfig.h:15
Defines a base class for a memory allocator for classes.
void init()
Object initializer.
Definition ObjBase.cpp:27
Success/Failure.
Auto-generated base for ComQueue component.
ComQueue(const char *const compName)
Definition ComQueue.cpp:24
void configure(QueueConfigurationTable queueConfig, NATIVE_UINT_TYPE allocationId, Fw::MemAllocator &allocator)
Definition ComQueue.cpp:49
void cleanup()
Definition ComQueue.cpp:42
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