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(
119  FwEnumStoreType identifier,
120  Fw::MemAllocator& allocator,
121  FwSizeType maxNumBuffers,
123  );
124 
126  void deallocateQueue(Fw::MemAllocator& allocator);
127 
128  private:
129  // ----------------------------------------------------------------------
130  // Handler implementations for user-defined typed input ports
131  // ----------------------------------------------------------------------
132 
135  void bufferSendInFill_handler(const FwIndexType portNum,
136  Fw::Buffer& buffer);
137 
140  void bufferSendInReturn_handler(const FwIndexType portNum,
141  Fw::Buffer& buffer);
142 
145  void pingIn_handler(const FwIndexType portNum,
146  U32 key
147  );
148 
149  private:
150  // ----------------------------------------------------------------------
151  // Command handler implementations
152  // ----------------------------------------------------------------------
153 
156  void BA_SetMode_cmdHandler(const FwOpcodeType opCode,
157  const U32 cmdSeq,
159  );
160 
163  void BA_DrainBuffers_cmdHandler(const FwOpcodeType opCode,
164  const U32 cmdSeq,
165  U32 numToDrain,
166  BufferAccumulator_BlockMode blockMode);
167 
168  private:
169  // ----------------------------------------------------------------------
170  // Private helper methods
171  // ----------------------------------------------------------------------
172 
174  void sendStoredBuffer();
175 
176  private:
177  // ----------------------------------------------------------------------
178  // Private member variables
179  // ----------------------------------------------------------------------
180 
183 
185  Fw::Buffer* m_bufferMemory;
186 
188  ArrayFIFOBuffer m_bufferQueue;
189 
191  bool m_send;
192 
195  bool m_waitForBuffer;
196 
199  U32 m_numWarnings;
200 
202  FwSizeType m_numDrained;
203 
205  FwSizeType m_numToDrain;
206 
208  FwOpcodeType m_opCode;
209 
211  U32 m_cmdSeq;
212 
214  FwEnumStoreType m_allocatorId;
215 };
216 
217 } // namespace Svc
218 
219 #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
Memory Allocation base class.
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.
void allocateQueue(FwEnumStoreType identifier, Fw::MemAllocator &allocator, FwSizeType maxNumBuffers, BufferAccumulator_OpState initialMode=BufferAccumulator_OpState::ACCUMULATE)