F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
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
98
99 // ----------------------------------------------------------------------
100 // Public methods
101 // ----------------------------------------------------------------------
102
105 void allocateQueue(
106 NATIVE_INT_TYPE identifier, Fw::MemAllocator& allocator,
107 NATIVE_UINT_TYPE maxNumBuffers
108 );
109
111 void deallocateQueue(Fw::MemAllocator& allocator);
112
113 PRIVATE:
114
115 // ----------------------------------------------------------------------
116 // Handler implementations for user-defined typed input ports
117 // ----------------------------------------------------------------------
118
121 void
122 bufferSendInFill_handler(
123 const NATIVE_INT_TYPE portNum,
124 Fw::Buffer& buffer);
125
128 void bufferSendInReturn_handler(
129 const NATIVE_INT_TYPE portNum,
130 Fw::Buffer& buffer);
131
134 void pingIn_handler(const NATIVE_INT_TYPE portNum,
135 U32 key
136 );
137
138 PRIVATE:
139
140 // ----------------------------------------------------------------------
141 // Command handler implementations
142 // ----------------------------------------------------------------------
143
146 void BA_SetMode_cmdHandler(const FwOpcodeType opCode,
147 const U32 cmdSeq,
149 );
150
153 void BA_DrainBuffers_cmdHandler(const FwOpcodeType opCode,
154 const U32 cmdSeq,
155 U32 numToDrain,
157 );
158
159 PRIVATE:
160
161 // ----------------------------------------------------------------------
162 // Private helper methods
163 // ----------------------------------------------------------------------
164
166 void sendStoredBuffer();
167
168 PRIVATE:
169
170 // ----------------------------------------------------------------------
171 // Private member variables
172 // ----------------------------------------------------------------------
173
176
178 Fw::Buffer* m_bufferMemory;
179
181 ArrayFIFOBuffer m_bufferQueue;
182
184 bool m_send;
185
188 bool m_waitForBuffer;
189
192 U32 m_numWarnings;
193
195 U32 m_numDrained;
196
198 U32 m_numToDrain;
199
201 FwOpcodeType m_opCode;
202
204 U32 m_cmdSeq;
205
207 NATIVE_INT_TYPE m_allocatorId;
208 };
209
210} // namespace Svc
211
212#endif
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:55
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:56
U32 FwOpcodeType
Definition FpConfig.h:91
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.