F´ Flight Software - C/C++ Documentation  NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
BufferAccumulator.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title BufferAccumulator.hpp
3 // \author bocchino
4 // \brief BufferAccumulator interface
5 //
6 // \copyright
7 // Copyright (C) 2017 California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12 
13 #ifndef Svc_BufferAccumulator_HPP
14 #define Svc_BufferAccumulator_HPP
15 
16 #include "Svc/BufferAccumulator/BufferAccumulatorComponentAc.hpp"
17 #include "Os/Queue.hpp"
19 
20 namespace Svc {
21 
23  public BufferAccumulatorComponentBase
24  {
25 
26  PRIVATE:
27 
28  // ----------------------------------------------------------------------
29  // Types
30  // ----------------------------------------------------------------------
31 
33  class ArrayFIFOBuffer {
34 
35  public:
37  ArrayFIFOBuffer();
38 
40  ~ArrayFIFOBuffer();
41 
42  void init(Fw::Buffer *const elements,
43  NATIVE_UINT_TYPE capacity
44  );
45 
49  bool enqueue(
50  const Fw::Buffer& e
51  );
52 
55  bool dequeue(
56  Fw::Buffer& e
57  );
58 
61  U32 getSize() const;
62 
65  U32 getCapacity() const;
66 
67  PRIVATE:
68 
69  // ----------------------------------------------------------------------
70  // Private member variables
71  // ----------------------------------------------------------------------
72 
74  Fw::Buffer * elements;
75 
77  NATIVE_UINT_TYPE capacity;
78 
80  NATIVE_UINT_TYPE enqueueIndex;
81 
83  NATIVE_UINT_TYPE dequeueIndex;
84 
86  NATIVE_UINT_TYPE size;
87  }; //class ArrayFIFOBuffer
88 
89  public:
90 
91  // ----------------------------------------------------------------------
92  // Construction, initialization, and destruction
93  // ----------------------------------------------------------------------
94 
98  const char *const compName
99  );
100 
103  void init(
104  const NATIVE_INT_TYPE queueDepth,
105  const NATIVE_INT_TYPE instance = 0
106  );
107 
111 
112  // ----------------------------------------------------------------------
113  // Public methods
114  // ----------------------------------------------------------------------
115 
118  void allocateQueue(
119  NATIVE_INT_TYPE identifier,
120  Fw::MemAllocator& allocator,
121  NATIVE_UINT_TYPE maxNumBuffers
122  );
123 
125  void deallocateQueue(Fw::MemAllocator& allocator);
126 
127 
128  PRIVATE:
129 
130  // ----------------------------------------------------------------------
131  // Handler implementations for user-defined typed input ports
132  // ----------------------------------------------------------------------
133 
136  void bufferSendInFill_handler(
137  const NATIVE_INT_TYPE portNum,
138  Fw::Buffer& buffer
139  );
140 
143  void bufferSendInReturn_handler(
144  const NATIVE_INT_TYPE portNum,
145  Fw::Buffer& buffer
146  );
147 
150  void pingIn_handler(
151  const NATIVE_INT_TYPE portNum,
152  U32 key
153  );
154 
157  void schedIn_handler(
158  const NATIVE_INT_TYPE portNum,
159  NATIVE_UINT_TYPE context
160  );
161 
162  PRIVATE:
163 
164  // ----------------------------------------------------------------------
165  // Command handler implementations
166  // ----------------------------------------------------------------------
167 
170  void BA_SetMode_cmdHandler(
171  const FwOpcodeType opCode,
172  const U32 cmdSeq,
173  OpState mode
174  );
175  PRIVATE:
176 
177  // ----------------------------------------------------------------------
178  // Private helper methods
179  // ----------------------------------------------------------------------
180 
182  void sendStoredBuffer();
183 
184  PRIVATE:
185 
186  // ----------------------------------------------------------------------
187  // Private member variables
188  // ----------------------------------------------------------------------
189 
191  OpState mode;
192 
194  Fw::Buffer * bufferMemory;
195 
197  ArrayFIFOBuffer bufferQueue;
198 
200  bool send;
201 
203  U32 numWarnings;
204 
206  NATIVE_INT_TYPE allocatorId;
207 
208  };
209 
210 }
211 
212 #endif
MemAllocator.hpp
Defines a base class for a memory allocator for classes.
NATIVE_UINT_TYPE
unsigned int NATIVE_UINT_TYPE
native unsigned integer type declaration
Definition: BasicTypes.hpp:28
Svc::BufferAccumulator::BufferAccumulator
BufferAccumulator(const char *const compName)
Definition: BufferAccumulator.cpp:23
Fw::Buffer
Definition: Buffer.hpp:43
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:27
Svc::BufferAccumulator::init
void init(const NATIVE_INT_TYPE queueDepth, const NATIVE_INT_TYPE instance=0)
Definition: BufferAccumulator.cpp:36
Svc::BufferAccumulator
Definition: BufferAccumulator.hpp:22
Svc::BufferAccumulator::~BufferAccumulator
~BufferAccumulator()
Definition: BufferAccumulator.cpp:45
Svc::BufferAccumulator::deallocateQueue
void deallocateQueue(Fw::MemAllocator &allocator)
Return allocated queue. Should be done during shutdown.
Definition: BufferAccumulator.cpp:71
Svc::BufferAccumulator::allocateQueue
void allocateQueue(NATIVE_INT_TYPE identifier, Fw::MemAllocator &allocator, NATIVE_UINT_TYPE maxNumBuffers)
Definition: BufferAccumulator.cpp:54
FwOpcodeType
#define FwOpcodeType
Type representation for a command opcode.
Definition: FpConfig.hpp:62
Fw::MemAllocator
Definition: MemAllocator.hpp:44
Svc
Definition: ActiveRateGroupCfg.hpp:18
Queue.hpp