F´ Flight Software - C/C++ Documentation NASA-v1.6.0
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
16#include "Svc/BufferAccumulator/BufferAccumulatorComponentAc.hpp"
17#include "Os/Queue.hpp"
19
20namespace 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
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
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 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.
void init(const NATIVE_INT_TYPE queueDepth, const NATIVE_INT_TYPE instance=0)