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
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
21namespace Svc {
22
24 PRIVATE:
25
26 // ----------------------------------------------------------------------
27 // Types
28 // ----------------------------------------------------------------------
29
31 class ArrayFIFOBuffer {
32 public:
34 ArrayFIFOBuffer();
35
37 ~ArrayFIFOBuffer();
38
39 void init(Fw::Buffer* const elements,
40 NATIVE_UINT_TYPE capacity
41 );
42
46 bool enqueue(const Fw::Buffer& e
47 );
48
51 bool dequeue(Fw::Buffer& e
52 );
53
56 U32 getSize() const;
57
60 U32 getCapacity() const;
61
62 PRIVATE:
63
64 // ----------------------------------------------------------------------
65 // Private member variables
66 // ----------------------------------------------------------------------
67
69 Fw::Buffer* m_elements;
70
72 NATIVE_UINT_TYPE m_capacity;
73
75 NATIVE_UINT_TYPE m_enqueueIndex;
76
78 NATIVE_UINT_TYPE m_dequeueIndex;
79
81 NATIVE_UINT_TYPE m_size;
82 }; // class ArrayFIFOBuffer
83
84 public:
85 // ----------------------------------------------------------------------
86 // Construction, initialization, and destruction
87 // ----------------------------------------------------------------------
88
92 const char* const compName
93 );
94
97 void init(const NATIVE_INT_TYPE queueDepth,
98 const NATIVE_INT_TYPE instance = 0
99 );
100
104
105 // ----------------------------------------------------------------------
106 // Public methods
107 // ----------------------------------------------------------------------
108
111 void allocateQueue(
112 NATIVE_INT_TYPE identifier, Fw::MemAllocator& allocator,
113 NATIVE_UINT_TYPE maxNumBuffers
114 );
115
117 void deallocateQueue(Fw::MemAllocator& allocator);
118
119 PRIVATE:
120
121 // ----------------------------------------------------------------------
122 // Handler implementations for user-defined typed input ports
123 // ----------------------------------------------------------------------
124
127 void
128 bufferSendInFill_handler(
129 const NATIVE_INT_TYPE portNum,
130 Fw::Buffer& buffer);
131
134 void bufferSendInReturn_handler(
135 const NATIVE_INT_TYPE portNum,
136 Fw::Buffer& buffer);
137
140 void pingIn_handler(const NATIVE_INT_TYPE portNum,
141 U32 key
142 );
143
144 PRIVATE:
145
146 // ----------------------------------------------------------------------
147 // Command handler implementations
148 // ----------------------------------------------------------------------
149
152 void BA_SetMode_cmdHandler(const FwOpcodeType opCode,
153 const U32 cmdSeq,
155 );
156
159 void BA_DrainBuffers_cmdHandler(const FwOpcodeType opCode,
160 const U32 cmdSeq,
161 U32 numToDrain,
163 );
164
165 PRIVATE:
166
167 // ----------------------------------------------------------------------
168 // Private helper methods
169 // ----------------------------------------------------------------------
170
172 void sendStoredBuffer();
173
174 PRIVATE:
175
176 // ----------------------------------------------------------------------
177 // Private member variables
178 // ----------------------------------------------------------------------
179
182
184 Fw::Buffer* m_bufferMemory;
185
187 ArrayFIFOBuffer m_bufferQueue;
188
190 bool m_send;
191
194 bool m_waitForBuffer;
195
198 U32 m_numWarnings;
199
201 U32 m_numDrained;
202
204 U32 m_numToDrain;
205
207 FwOpcodeType m_opCode;
208
210 U32 m_cmdSeq;
211
213 NATIVE_INT_TYPE m_allocatorId;
214 };
215
216} // namespace Svc
217
218#endif
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:52
U32 FwOpcodeType
Definition FpConfig.h:56
Defines a base class for a memory allocator for classes.
void init()
Object initializer.
Definition ObjBase.cpp:27
Auto-generated base for BufferAccumulator component.
void allocateQueue(NATIVE_INT_TYPE identifier, Fw::MemAllocator &allocator, NATIVE_UINT_TYPE maxNumBuffers)
void deallocateQueue(Fw::MemAllocator &allocator)
Return allocated queue. Should be done during shutdown.
BufferAccumulator(const char *const compName)