F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
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
8#include "Fw/Types/Assert.hpp"
10#if FW_ENABLE_TEXT_LOGGING
11#include "Fw/Types/String.hpp"
12#endif
13
14namespace Svc {
15
16 // ----------------------------------------------------------------------
17 // Component initialization
18 // ----------------------------------------------------------------------
19
20 void PolyDbComponentBase ::
21 init(FwEnumStoreType instance)
22 {
23 // Initialize base class
25
26 // Connect input port getValue
27 for (
28 FwIndexType port = 0;
29 port < static_cast<FwIndexType>(this->getNum_getValue_InputPorts());
30 port++
31 ) {
32 this->m_getValue_InputPort[port].init();
33 this->m_getValue_InputPort[port].addCallComp(
34 this,
35 m_p_getValue_in
36 );
37 this->m_getValue_InputPort[port].setPortNum(port);
38
39#if FW_OBJECT_NAMES == 1
40 Fw::ObjectName portName;
41 portName.format(
42 "%s_getValue_InputPort[%" PRI_PlatformIntType "]",
43 this->m_objName.toChar(),
44 port
45 );
46 this->m_getValue_InputPort[port].setObjName(portName.toChar());
47#endif
48 }
49
50 // Connect input port setValue
51 for (
52 FwIndexType port = 0;
53 port < static_cast<FwIndexType>(this->getNum_setValue_InputPorts());
54 port++
55 ) {
56 this->m_setValue_InputPort[port].init();
57 this->m_setValue_InputPort[port].addCallComp(
58 this,
59 m_p_setValue_in
60 );
61 this->m_setValue_InputPort[port].setPortNum(port);
62
63#if FW_OBJECT_NAMES == 1
64 Fw::ObjectName portName;
65 portName.format(
66 "%s_setValue_InputPort[%" PRI_PlatformIntType "]",
67 this->m_objName.toChar(),
68 port
69 );
70 this->m_setValue_InputPort[port].setObjName(portName.toChar());
71#endif
72 }
73 }
74
75 // ----------------------------------------------------------------------
76 // Getters for typed input ports
77 // ----------------------------------------------------------------------
78
79 Svc::InputPolyPort* PolyDbComponentBase ::
80 get_getValue_InputPort(FwIndexType portNum)
81 {
83 portNum < this->getNum_getValue_InputPorts(),
84 static_cast<FwAssertArgType>(portNum)
85 );
86
87 return &this->m_getValue_InputPort[portNum];
88 }
89
90 Svc::InputPolyPort* PolyDbComponentBase ::
91 get_setValue_InputPort(FwIndexType portNum)
92 {
94 portNum < this->getNum_setValue_InputPorts(),
95 static_cast<FwAssertArgType>(portNum)
96 );
97
98 return &this->m_setValue_InputPort[portNum];
99 }
100
101 // ----------------------------------------------------------------------
102 // Component construction and destruction
103 // ----------------------------------------------------------------------
104
105 PolyDbComponentBase ::
106 PolyDbComponentBase(const char* compName) :
107 Fw::PassiveComponentBase(compName)
108 {
109
110 }
111
112 PolyDbComponentBase ::
113 ~PolyDbComponentBase()
114 {
115
116 }
117
118 // ----------------------------------------------------------------------
119 // Getters for numbers of typed input ports
120 // ----------------------------------------------------------------------
121
122 FwIndexType PolyDbComponentBase ::
123 getNum_getValue_InputPorts() const
124 {
125 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_getValue_InputPort));
126 }
127
128 FwIndexType PolyDbComponentBase ::
129 getNum_setValue_InputPorts() const
130 {
131 return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_setValue_InputPort));
132 }
133
134 // ----------------------------------------------------------------------
135 // Port handler base-class functions for typed input ports
136 //
137 // Call these functions directly to bypass the corresponding ports
138 // ----------------------------------------------------------------------
139
140 void PolyDbComponentBase ::
141 getValue_handlerBase(
142 FwIndexType portNum,
143 const Svc::PolyDbCfg::PolyDbEntry& entry,
145 Fw::Time& time,
146 Fw::PolyType& val
147 )
148 {
149 // Make sure port number is valid
150 FW_ASSERT(
151 portNum < this->getNum_getValue_InputPorts(),
152 static_cast<FwAssertArgType>(portNum)
153 );
154
155 // Lock guard mutex before calling
156 this->lock();
157
158 // Call handler function
159 this->getValue_handler(
160 portNum,
161 entry,
162 status,
163 time,
164 val
165 );
166
167 // Unlock guard mutex
168 this->unLock();
169 }
170
171 void PolyDbComponentBase ::
172 setValue_handlerBase(
173 FwIndexType portNum,
174 const Svc::PolyDbCfg::PolyDbEntry& entry,
176 Fw::Time& time,
177 Fw::PolyType& val
178 )
179 {
180 // Make sure port number is valid
181 FW_ASSERT(
182 portNum < this->getNum_setValue_InputPorts(),
183 static_cast<FwAssertArgType>(portNum)
184 );
185
186 // Lock guard mutex before calling
187 this->lock();
188
189 // Call handler function
190 this->setValue_handler(
191 portNum,
192 entry,
193 status,
194 time,
195 val
196 );
197
198 // Unlock guard mutex
199 this->unLock();
200 }
201
202 // ----------------------------------------------------------------------
203 // Mutex operations for guarded ports
204 //
205 // You can override these operations to provide more sophisticated
206 // synchronization
207 // ----------------------------------------------------------------------
208
209 void PolyDbComponentBase ::
210 lock()
211 {
212 this->m_guardedPortMutex.lock();
213 }
214
215 void PolyDbComponentBase ::
216 unLock()
217 {
218 this->m_guardedPortMutex.unLock();
219 }
220
221 // ----------------------------------------------------------------------
222 // Calls for messages received on typed input ports
223 // ----------------------------------------------------------------------
224
225 void PolyDbComponentBase ::
226 m_p_getValue_in(
227 Fw::PassiveComponentBase* callComp,
228 FwIndexType portNum,
229 const Svc::PolyDbCfg::PolyDbEntry& entry,
231 Fw::Time& time,
232 Fw::PolyType& val
233 )
234 {
235 FW_ASSERT(callComp);
236 PolyDbComponentBase* compPtr = static_cast<PolyDbComponentBase*>(callComp);
237 compPtr->getValue_handlerBase(
238 portNum,
239 entry,
240 status,
241 time,
242 val
243 );
244 }
245
246 void PolyDbComponentBase ::
247 m_p_setValue_in(
248 Fw::PassiveComponentBase* callComp,
249 FwIndexType portNum,
250 const Svc::PolyDbCfg::PolyDbEntry& entry,
252 Fw::Time& time,
253 Fw::PolyType& val
254 )
255 {
256 FW_ASSERT(callComp);
257 PolyDbComponentBase* compPtr = static_cast<PolyDbComponentBase*>(callComp);
258 compPtr->setValue_handlerBase(
259 portNum,
260 entry,
261 status,
262 time,
263 val
264 );
265 }
266
267}
#define FW_ASSERT(...)
Definition Assert.hpp:14
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition BasicTypes.h:70
#define PRI_PlatformIntType
I32 FwEnumStoreType
Definition FpConfig.h:64
PlatformAssertArgType FwAssertArgType
Definition FpConfig.h:39
PlatformIndexType FwIndexType
Definition FpConfig.h:25
void init()
Object initializer.
Definition ObjBase.cpp:27
const char * toChar() const
void format(const CHAR *formatString,...)
write formatted string to buffer
An enumeration for measurement status.
Auto-generated base for PolyDb component.
void setValue_handlerBase(FwIndexType portNum, const Svc::PolyDbCfg::PolyDbEntry &entry, Svc::MeasurementStatus &status, Fw::Time &time, Fw::PolyType &val)
Handler base-class function for input port setValue.
void getValue_handlerBase(FwIndexType portNum, const Svc::PolyDbCfg::PolyDbEntry &entry, Svc::MeasurementStatus &status, Fw::Time &time, Fw::PolyType &val)
Handler base-class function for input port getValue.