F´ Flight Software - C/C++ Documentation
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 
17 
18 #include "Os/Queue.hpp"
20 
21 namespace Svc {
22 
23  // Forward declaration for UTs
24  namespace Accumulate { class BufferAccumulatorTester; }
25  namespace Drain { class BufferAccumulatorTester; }
26  namespace Errors { class BufferAccumulatorTester; }
27 
29 
34 
35  private:
36 
37  // ----------------------------------------------------------------------
38  // Types
39  // ----------------------------------------------------------------------
40 
42  class ArrayFIFOBuffer {
43  public:
45  ArrayFIFOBuffer();
46 
48  ~ArrayFIFOBuffer();
49 
50  void init(Fw::Buffer* const elements,
51  FwSizeType capacity
52  );
53 
57  bool enqueue(const Fw::Buffer& e
58  );
59 
62  bool dequeue(Fw::Buffer& e
63  );
64 
67  FwSizeType getSize() const;
68 
71  FwSizeType getCapacity() const;
72 
73  private:
74 
75  // ----------------------------------------------------------------------
76  // Private member variables
77  // ----------------------------------------------------------------------
78 
80  Fw::Buffer* m_elements;
81 
83  FwSizeType m_capacity;
84 
86  FwSizeType m_enqueueIndex;
87 
89  FwSizeType m_dequeueIndex;
90 
92  FwSizeType m_size;
93  }; // class ArrayFIFOBuffer
94 
95  public:
96  // ----------------------------------------------------------------------
97  // Construction, initialization, and destruction
98  // ----------------------------------------------------------------------
99 
103  const char* const compName
104  );
105 
109 
110  // ----------------------------------------------------------------------
111  // Public methods
112  // ----------------------------------------------------------------------
113 
116  void allocateQueue(
117  FwEnumStoreType identifier, Fw::MemAllocator& allocator,
118  FwSizeType maxNumBuffers
119  );
120 
122  void deallocateQueue(Fw::MemAllocator& allocator);
123 
124  private:
125 
126  // ----------------------------------------------------------------------
127  // Handler implementations for user-defined typed input ports
128  // ----------------------------------------------------------------------
129 
132  void
133  bufferSendInFill_handler(
134  const FwIndexType portNum,
135  Fw::Buffer& buffer);
136 
139  void bufferSendInReturn_handler(
140  const FwIndexType portNum,
141  Fw::Buffer& buffer);
142 
145  void pingIn_handler(const FwIndexType portNum,
146  U32 key
147  );
148 
149  private:
150 
151  // ----------------------------------------------------------------------
152  // Command handler implementations
153  // ----------------------------------------------------------------------
154 
157  void BA_SetMode_cmdHandler(const FwOpcodeType opCode,
158  const U32 cmdSeq,
160  );
161 
164  void BA_DrainBuffers_cmdHandler(const FwOpcodeType opCode,
165  const U32 cmdSeq,
166  U32 numToDrain,
168  );
169 
170  private:
171 
172  // ----------------------------------------------------------------------
173  // Private helper methods
174  // ----------------------------------------------------------------------
175 
177  void sendStoredBuffer();
178 
179  private:
180 
181  // ----------------------------------------------------------------------
182  // Private member variables
183  // ----------------------------------------------------------------------
184 
187 
189  Fw::Buffer* m_bufferMemory;
190 
192  ArrayFIFOBuffer m_bufferQueue;
193 
195  bool m_send;
196 
199  bool m_waitForBuffer;
200 
203  U32 m_numWarnings;
204 
206  FwSizeType m_numDrained;
207 
209  FwSizeType m_numToDrain;
210 
212  FwOpcodeType m_opCode;
213 
215  U32 m_cmdSeq;
216 
218  FwEnumStoreType m_allocatorId;
219  };
220 
221 } // namespace Svc
222 
223 #endif
FwIdType FwOpcodeType
The type of a command opcode.
PlatformSizeType FwSizeType
I32 FwEnumStoreType
void init()
Object initializer.
Definition: ObjBase.cpp:26
BufferAccumulator(const char *const compName)
friend class Svc::Accumulate::BufferAccumulatorTester
friend class BufferAccumulatorTester
void allocateQueue(FwEnumStoreType identifier, Fw::MemAllocator &allocator, FwSizeType maxNumBuffers)
friend class Svc::Drain::BufferAccumulatorTester
PlatformIndexType FwIndexType
void deallocateQueue(Fw::MemAllocator &allocator)
Return allocated queue. Should be done during shutdown.
RateGroupDivider component implementation.
Defines a base class for a memory allocator for classes.
friend class Svc::Errors::BufferAccumulatorTester
Auto-generated base for BufferAccumulator component.