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
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 // ----------------------------------------------------------------------
18 // Component initialization
19 // ----------------------------------------------------------------------
20
21 void PolyDbComponentBase ::
22 init(NATIVE_INT_TYPE instance)
23 {
24 // Initialize base class
26
27 // Connect input port getValue
28 for (
29 PlatformIntType port = 0;
30 port < static_cast<PlatformIntType>(this->getNum_getValue_InputPorts());
31 port++
32 ) {
33 this->m_getValue_InputPort[port].init();
34 this->m_getValue_InputPort[port].addCallComp(
35 this,
36 m_p_getValue_in
37 );
38 this->m_getValue_InputPort[port].setPortNum(port);
39
40#if FW_OBJECT_NAMES == 1
41 // The port name consists of this->m_objName and some extra info.
42 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
43 // However, the compiler may assume that this->m_objName fills
44 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
45 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
46 // bytes to cover the extra info.
47 char portName[2*FW_OBJ_NAME_MAX_SIZE];
48 (void) snprintf(
49 portName,
50 sizeof(portName),
51 "%s_getValue_InputPort[%" PRI_PlatformIntType "]",
52 this->m_objName,
53 port
54 );
55 this->m_getValue_InputPort[port].setObjName(portName);
56#endif
57 }
58
59 // Connect input port setValue
60 for (
61 PlatformIntType port = 0;
62 port < static_cast<PlatformIntType>(this->getNum_setValue_InputPorts());
63 port++
64 ) {
65 this->m_setValue_InputPort[port].init();
66 this->m_setValue_InputPort[port].addCallComp(
67 this,
68 m_p_setValue_in
69 );
70 this->m_setValue_InputPort[port].setPortNum(port);
71
72#if FW_OBJECT_NAMES == 1
73 // The port name consists of this->m_objName and some extra info.
74 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
75 // However, the compiler may assume that this->m_objName fills
76 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
77 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
78 // bytes to cover the extra info.
79 char portName[2*FW_OBJ_NAME_MAX_SIZE];
80 (void) snprintf(
81 portName,
82 sizeof(portName),
83 "%s_setValue_InputPort[%" PRI_PlatformIntType "]",
84 this->m_objName,
85 port
86 );
87 this->m_setValue_InputPort[port].setObjName(portName);
88#endif
89 }
90 }
91
92 // ----------------------------------------------------------------------
93 // Getters for typed input ports
94 // ----------------------------------------------------------------------
95
96 Svc::InputPolyPort* PolyDbComponentBase ::
97 get_getValue_InputPort(NATIVE_INT_TYPE portNum)
98 {
100 portNum < this->getNum_getValue_InputPorts(),
101 static_cast<FwAssertArgType>(portNum)
102 );
103
104 return &this->m_getValue_InputPort[portNum];
105 }
106
107 Svc::InputPolyPort* PolyDbComponentBase ::
108 get_setValue_InputPort(NATIVE_INT_TYPE portNum)
109 {
110 FW_ASSERT(
111 portNum < this->getNum_setValue_InputPorts(),
112 static_cast<FwAssertArgType>(portNum)
113 );
114
115 return &this->m_setValue_InputPort[portNum];
116 }
117
118 // ----------------------------------------------------------------------
119 // Component construction and destruction
120 // ----------------------------------------------------------------------
121
122 PolyDbComponentBase ::
123 PolyDbComponentBase(const char* compName) :
124 Fw::PassiveComponentBase(compName)
125 {
126
127 }
128
129 PolyDbComponentBase ::
130 ~PolyDbComponentBase()
131 {
132
133 }
134
135 // ----------------------------------------------------------------------
136 // Getters for numbers of typed input ports
137 // ----------------------------------------------------------------------
138
139 NATIVE_INT_TYPE PolyDbComponentBase ::
140 getNum_getValue_InputPorts() const
141 {
142 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_getValue_InputPort));
143 }
144
145 NATIVE_INT_TYPE PolyDbComponentBase ::
146 getNum_setValue_InputPorts() const
147 {
148 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_setValue_InputPort));
149 }
150
151 // ----------------------------------------------------------------------
152 // Port handler base-class functions for typed input ports
153 //
154 // Call these functions directly to bypass the corresponding ports
155 // ----------------------------------------------------------------------
156
157 void PolyDbComponentBase ::
158 getValue_handlerBase(
159 NATIVE_INT_TYPE portNum,
160 U32 entry,
162 Fw::Time& time,
163 Fw::PolyType& val
164 )
165 {
166 // Make sure port number is valid
167 FW_ASSERT(
168 portNum < this->getNum_getValue_InputPorts(),
169 static_cast<FwAssertArgType>(portNum)
170 );
171
172 // Lock guard mutex before calling
173 this->lock();
174
175 // Call handler function
176 this->getValue_handler(
177 portNum,
178 entry,
179 status,
180 time,
181 val
182 );
183
184 // Unlock guard mutex
185 this->unLock();
186 }
187
188 void PolyDbComponentBase ::
189 setValue_handlerBase(
190 NATIVE_INT_TYPE portNum,
191 U32 entry,
193 Fw::Time& time,
194 Fw::PolyType& val
195 )
196 {
197 // Make sure port number is valid
198 FW_ASSERT(
199 portNum < this->getNum_setValue_InputPorts(),
200 static_cast<FwAssertArgType>(portNum)
201 );
202
203 // Lock guard mutex before calling
204 this->lock();
205
206 // Call handler function
207 this->setValue_handler(
208 portNum,
209 entry,
210 status,
211 time,
212 val
213 );
214
215 // Unlock guard mutex
216 this->unLock();
217 }
218
219 // ----------------------------------------------------------------------
220 // Mutex operations for guarded ports
221 //
222 // You can override these operations to provide more sophisticated
223 // synchronization
224 // ----------------------------------------------------------------------
225
226 void PolyDbComponentBase ::
227 lock()
228 {
229 this->m_guardedPortMutex.lock();
230 }
231
232 void PolyDbComponentBase ::
233 unLock()
234 {
235 this->m_guardedPortMutex.unLock();
236 }
237
238 // ----------------------------------------------------------------------
239 // Calls for messages received on typed input ports
240 // ----------------------------------------------------------------------
241
242 void PolyDbComponentBase ::
243 m_p_getValue_in(
244 Fw::PassiveComponentBase* callComp,
245 NATIVE_INT_TYPE portNum,
246 U32 entry,
248 Fw::Time& time,
249 Fw::PolyType& val
250 )
251 {
252 FW_ASSERT(callComp);
253 PolyDbComponentBase* compPtr = static_cast<PolyDbComponentBase*>(callComp);
254 compPtr->getValue_handlerBase(
255 portNum,
256 entry,
257 status,
258 time,
259 val
260 );
261 }
262
263 void PolyDbComponentBase ::
264 m_p_setValue_in(
265 Fw::PassiveComponentBase* callComp,
266 NATIVE_INT_TYPE portNum,
267 U32 entry,
269 Fw::Time& time,
270 Fw::PolyType& val
271 )
272 {
273 FW_ASSERT(callComp);
274 PolyDbComponentBase* compPtr = static_cast<PolyDbComponentBase*>(callComp);
275 compPtr->setValue_handlerBase(
276 portNum,
277 entry,
278 status,
279 time,
280 val
281 );
282 }
283
284}
#define FW_ASSERT(...)
Definition Assert.hpp:14
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition BasicTypes.h:66
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
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.