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 {
25 class BufferAccumulatorTester;
26 }
27 namespace Drain {
28 class BufferAccumulatorTester;
29 }
30 namespace Errors {
31 class BufferAccumulatorTester;
32 }
33 
39 
40  private:
41  // ----------------------------------------------------------------------
42  // Types
43  // ----------------------------------------------------------------------
44 
46  class ArrayFIFOBuffer {
47  public:
49  ArrayFIFOBuffer();
50 
52  ~ArrayFIFOBuffer();
53 
54  void init(Fw::Buffer* const elements,
55  FwSizeType capacity
56  );
57 
61  bool enqueue(const Fw::Buffer& e
62  );
63 
66  bool dequeue(Fw::Buffer& e
67  );
68 
71  FwSizeType getSize() const;
72 
75  FwSizeType getCapacity() const;
76 
77  private:
78  // ----------------------------------------------------------------------
79  // Private member variables
80  // ----------------------------------------------------------------------
81 
83  Fw::Buffer* m_elements;
84 
86  FwSizeType m_capacity;
87 
89  FwSizeType m_enqueueIndex;
90 
92  FwSizeType m_dequeueIndex;
93 
95  FwSizeType m_size;
96  }; // class ArrayFIFOBuffer
97 
98  public:
99  // ----------------------------------------------------------------------
100  // Construction, initialization, and destruction
101  // ----------------------------------------------------------------------
102 
105  BufferAccumulator(const char* const compName
106  );
107 
111 
112  // ----------------------------------------------------------------------
113  // Public methods
114  // ----------------------------------------------------------------------
115 
118  void allocateQueue(FwEnumStoreType identifier,
119  Fw::MemAllocator& allocator,
120  FwSizeType maxNumBuffers
121  );
122 
124  void deallocateQueue(Fw::MemAllocator& allocator);
125 
126  private:
127  // ----------------------------------------------------------------------
128  // Handler implementations for user-defined typed input ports
129  // ----------------------------------------------------------------------
130 
133  void bufferSendInFill_handler(const FwIndexType portNum,
134  Fw::Buffer& buffer);
135 
138  void bufferSendInReturn_handler(const FwIndexType portNum,
139  Fw::Buffer& buffer);
140 
143  void pingIn_handler(const FwIndexType portNum,
144  U32 key
145  );
146 
147  private:
148  // ----------------------------------------------------------------------
149  // Command handler implementations
150  // ----------------------------------------------------------------------
151 
154  void BA_SetMode_cmdHandler(const FwOpcodeType opCode,
155  const U32 cmdSeq,
157  );
158 
161  void BA_DrainBuffers_cmdHandler(const FwOpcodeType opCode,
162  const U32 cmdSeq,
163  U32 numToDrain,
164  BufferAccumulator_BlockMode blockMode);
165 
166  private:
167  // ----------------------------------------------------------------------
168  // Private helper methods
169  // ----------------------------------------------------------------------
170 
172  void sendStoredBuffer();
173 
174  private:
175  // ----------------------------------------------------------------------
176  // Private member variables
177  // ----------------------------------------------------------------------
178 
181 
183  Fw::Buffer* m_bufferMemory;
184 
186  ArrayFIFOBuffer m_bufferQueue;
187 
189  bool m_send;
190 
193  bool m_waitForBuffer;
194 
197  U32 m_numWarnings;
198 
200  FwSizeType m_numDrained;
201 
203  FwSizeType m_numToDrain;
204 
206  FwOpcodeType m_opCode;
207 
209  U32 m_cmdSeq;
210 
212  FwEnumStoreType m_allocatorId;
213 };
214 
215 } // namespace Svc
216 
217 #endif
FwIdType FwOpcodeType
The type of a command opcode.
PlatformSizeType FwSizeType
I32 FwEnumStoreType
void init()
Object initializer.
Definition: ObjBase.cpp:24
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.