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
PolyDbComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title PolyDbComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for PolyDb component base class
5// ======================================================================
6
7#include <cstdio>
8
10#include "Fw/Types/Assert.hpp"
11#if FW_ENABLE_TEXT_LOGGING
12#include "Fw/Types/String.hpp"
13#endif
14
15namespace Svc {
16
17 namespace {
18 // Get the max size by doing a union of the input and internal port serialization sizes
19 union BuffUnion {
22 };
23
24 // Define a message buffer class large enough to handle all the
25 // asynchronous inputs to the component
26 class ComponentIpcSerializableBuffer :
28 {
29
30 public:
31
32 enum {
33 // Max. message size = size of data + message id + port
34 SERIALIZATION_SIZE =
35 sizeof(BuffUnion) +
36 sizeof(NATIVE_INT_TYPE) +
37 sizeof(NATIVE_INT_TYPE)
38 };
39
40 NATIVE_UINT_TYPE getBuffCapacity() const {
41 return sizeof(m_buff);
42 }
43
44 U8* getBuffAddr() {
45 return m_buff;
46 }
47
48 const U8* getBuffAddr() const {
49 return m_buff;
50 }
51
52 private:
53 // Should be the max of all the input ports serialized sizes...
54 U8 m_buff[SERIALIZATION_SIZE];
55
56 };
57 }
58
59 // ----------------------------------------------------------------------
60 // Component initialization
61 // ----------------------------------------------------------------------
62
63 void PolyDbComponentBase ::
64 init(NATIVE_INT_TYPE instance)
65 {
66 // Initialize base class
68
69 // Connect input port getValue
70 for (
71 PlatformIntType port = 0;
72 port < static_cast<PlatformIntType>(this->getNum_getValue_InputPorts());
73 port++
74 ) {
75 this->m_getValue_InputPort[port].init();
76 this->m_getValue_InputPort[port].addCallComp(
77 this,
78 m_p_getValue_in
79 );
80 this->m_getValue_InputPort[port].setPortNum(port);
81
82#if FW_OBJECT_NAMES == 1
83 char portName[120];
84 (void) snprintf(
85 portName,
86 sizeof(portName),
87 "%s_getValue_InputPort[%" PRI_PlatformIntType "]",
88 this->m_objName,
89 port
90 );
91 this->m_getValue_InputPort[port].setObjName(portName);
92#endif
93 }
94
95 // Connect input port setValue
96 for (
97 PlatformIntType port = 0;
98 port < static_cast<PlatformIntType>(this->getNum_setValue_InputPorts());
99 port++
100 ) {
101 this->m_setValue_InputPort[port].init();
102 this->m_setValue_InputPort[port].addCallComp(
103 this,
104 m_p_setValue_in
105 );
106 this->m_setValue_InputPort[port].setPortNum(port);
107
108#if FW_OBJECT_NAMES == 1
109 char portName[120];
110 (void) snprintf(
111 portName,
112 sizeof(portName),
113 "%s_setValue_InputPort[%" PRI_PlatformIntType "]",
114 this->m_objName,
115 port
116 );
117 this->m_setValue_InputPort[port].setObjName(portName);
118#endif
119 }
120 }
121
122 // ----------------------------------------------------------------------
123 // Getters for typed input ports
124 // ----------------------------------------------------------------------
125
126 Svc::InputPolyPort* PolyDbComponentBase ::
127 get_getValue_InputPort(NATIVE_INT_TYPE portNum)
128 {
129 FW_ASSERT(
130 portNum < this->getNum_getValue_InputPorts(),
131 static_cast<FwAssertArgType>(portNum)
132 );
133
134 return &this->m_getValue_InputPort[portNum];
135 }
136
137 Svc::InputPolyPort* PolyDbComponentBase ::
138 get_setValue_InputPort(NATIVE_INT_TYPE portNum)
139 {
140 FW_ASSERT(
141 portNum < this->getNum_setValue_InputPorts(),
142 static_cast<FwAssertArgType>(portNum)
143 );
144
145 return &this->m_setValue_InputPort[portNum];
146 }
147
148 // ----------------------------------------------------------------------
149 // Component construction and destruction
150 // ----------------------------------------------------------------------
151
152 PolyDbComponentBase ::
153 PolyDbComponentBase(const char* compName) :
154 Fw::PassiveComponentBase(compName)
155 {
156
157 }
158
159 PolyDbComponentBase ::
160 ~PolyDbComponentBase()
161 {
162
163 }
164
165 // ----------------------------------------------------------------------
166 // Getters for numbers of typed input ports
167 // ----------------------------------------------------------------------
168
169 NATIVE_INT_TYPE PolyDbComponentBase ::
170 getNum_getValue_InputPorts()
171 {
172 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_getValue_InputPort));
173 }
174
175 NATIVE_INT_TYPE PolyDbComponentBase ::
176 getNum_setValue_InputPorts()
177 {
178 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_setValue_InputPort));
179 }
180
181 // ----------------------------------------------------------------------
182 // Port handler base-class functions for typed input ports
183 //
184 // Call these functions directly to bypass the corresponding ports
185 // ----------------------------------------------------------------------
186
187 void PolyDbComponentBase ::
188 getValue_handlerBase(
189 NATIVE_INT_TYPE portNum,
190 U32 entry,
192 Fw::Time& time,
193 Fw::PolyType& val
194 )
195 {
196 // Make sure port number is valid
197 FW_ASSERT(
198 portNum < this->getNum_getValue_InputPorts(),
199 static_cast<FwAssertArgType>(portNum)
200 );
201
202 // Lock guard mutex before calling
203 this->lock();
204
205 // Down call to pure virtual handler method implemented in Impl class
206 this->getValue_handler(
207 portNum,
208 entry,
209 status,
210 time,
211 val
212 );
213
214 // Unlock guard mutex
215 this->unLock();
216 }
217
218 void PolyDbComponentBase ::
219 setValue_handlerBase(
220 NATIVE_INT_TYPE portNum,
221 U32 entry,
223 Fw::Time& time,
224 Fw::PolyType& val
225 )
226 {
227 // Make sure port number is valid
228 FW_ASSERT(
229 portNum < this->getNum_setValue_InputPorts(),
230 static_cast<FwAssertArgType>(portNum)
231 );
232
233 // Lock guard mutex before calling
234 this->lock();
235
236 // Down call to pure virtual handler method implemented in Impl class
237 this->setValue_handler(
238 portNum,
239 entry,
240 status,
241 time,
242 val
243 );
244
245 // Unlock guard mutex
246 this->unLock();
247 }
248
249 // ----------------------------------------------------------------------
250 // Mutex operations for guarded ports
251 //
252 // You can override these operations to provide more sophisticated
253 // synchronization
254 // ----------------------------------------------------------------------
255
256 void PolyDbComponentBase ::
257 lock()
258 {
259 this->m_guardedPortMutex.lock();
260 }
261
262 void PolyDbComponentBase ::
263 unLock()
264 {
265 this->m_guardedPortMutex.unLock();
266 }
267
268 // ----------------------------------------------------------------------
269 // Calls for messages received on typed input ports
270 // ----------------------------------------------------------------------
271
272 void PolyDbComponentBase ::
273 m_p_getValue_in(
274 Fw::PassiveComponentBase* callComp,
275 NATIVE_INT_TYPE portNum,
276 U32 entry,
278 Fw::Time& time,
279 Fw::PolyType& val
280 )
281 {
282 FW_ASSERT(callComp);
283 PolyDbComponentBase* compPtr = static_cast<PolyDbComponentBase*>(callComp);
284 compPtr->getValue_handlerBase(
285 portNum,
286 entry,
287 status,
288 time,
289 val
290 );
291 }
292
293 void PolyDbComponentBase ::
294 m_p_setValue_in(
295 Fw::PassiveComponentBase* callComp,
296 NATIVE_INT_TYPE portNum,
297 U32 entry,
299 Fw::Time& time,
300 Fw::PolyType& val
301 )
302 {
303 FW_ASSERT(callComp);
304 PolyDbComponentBase* compPtr = static_cast<PolyDbComponentBase*>(callComp);
305 compPtr->setValue_handlerBase(
306 portNum,
307 entry,
308 status,
309 time,
310 val
311 );
312 }
313
314}
#define FW_ASSERT(...)
Definition Assert.hpp:7
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
U8 BYTE
byte type
Definition BasicTypes.h:27
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:26
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition BasicTypes.h:66
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:52
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
#define PRI_PlatformIntType
PlatformAssertArgType FwAssertArgType
Definition FpConfig.h:21
void init()
Object initializer.
Definition ObjBase.cpp:27
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
An enumeration for measurement status.
Auto-generated base for PolyDb component.
void getValue_handlerBase(NATIVE_INT_TYPE portNum, U32 entry, Svc::MeasurementStatus &status, Fw::Time &time, Fw::PolyType &val)
Handler base-class function for input port getValue.
void setValue_handlerBase(NATIVE_INT_TYPE portNum, U32 entry, Svc::MeasurementStatus &status, Fw::Time &time, Fw::PolyType &val)
Handler base-class function for input port setValue.