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