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  // 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_FwIndexType "]",
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_FwIndexType "]",
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 
81  {
82  FW_ASSERT(
83  (0 <= portNum) && (portNum < this->getNum_getValue_InputPorts()),
84  static_cast<FwAssertArgType>(portNum)
85  );
86 
87  return &this->m_getValue_InputPort[portNum];
88  }
89 
92  {
93  FW_ASSERT(
94  (0 <= portNum) && (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 
106  PolyDbComponentBase(const char* compName) :
107  Fw::PassiveComponentBase(compName)
108  {
109 
110  }
111 
114  {
115 
116  }
117 
118  // ----------------------------------------------------------------------
119  // Port handler base-class functions for typed input ports
120  //
121  // Call these functions directly to bypass the corresponding ports
122  // ----------------------------------------------------------------------
123 
126  FwIndexType portNum,
127  const Svc::PolyDbCfg::PolyDbEntry& entry,
128  Svc::MeasurementStatus& status,
129  Fw::Time& time,
130  Fw::PolyType& val
131  )
132  {
133  // Make sure port number is valid
134  FW_ASSERT(
135  (0 <= portNum) && (portNum < this->getNum_getValue_InputPorts()),
136  static_cast<FwAssertArgType>(portNum)
137  );
138 
139  // Lock guard mutex before calling
140  this->lock();
141 
142  // Call handler function
143  this->getValue_handler(
144  portNum,
145  entry,
146  status,
147  time,
148  val
149  );
150 
151  // Unlock guard mutex
152  this->unLock();
153  }
154 
157  FwIndexType portNum,
158  const Svc::PolyDbCfg::PolyDbEntry& entry,
159  Svc::MeasurementStatus& status,
160  Fw::Time& time,
161  Fw::PolyType& val
162  )
163  {
164  // Make sure port number is valid
165  FW_ASSERT(
166  (0 <= portNum) && (portNum < this->getNum_setValue_InputPorts()),
167  static_cast<FwAssertArgType>(portNum)
168  );
169 
170  // Lock guard mutex before calling
171  this->lock();
172 
173  // Call handler function
174  this->setValue_handler(
175  portNum,
176  entry,
177  status,
178  time,
179  val
180  );
181 
182  // Unlock guard mutex
183  this->unLock();
184  }
185 
186  // ----------------------------------------------------------------------
187  // Mutex operations for guarded ports
188  //
189  // You can override these operations to provide more sophisticated
190  // synchronization
191  // ----------------------------------------------------------------------
192 
195  {
196  this->m_guardedPortMutex.lock();
197  }
198 
201  {
202  this->m_guardedPortMutex.unLock();
203  }
204 
205  // ----------------------------------------------------------------------
206  // Calls for messages received on typed input ports
207  // ----------------------------------------------------------------------
208 
209  void PolyDbComponentBase ::
210  m_p_getValue_in(
211  Fw::PassiveComponentBase* callComp,
212  FwIndexType portNum,
213  const Svc::PolyDbCfg::PolyDbEntry& entry,
214  Svc::MeasurementStatus& status,
215  Fw::Time& time,
216  Fw::PolyType& val
217  )
218  {
219  FW_ASSERT(callComp);
220  PolyDbComponentBase* compPtr = static_cast<PolyDbComponentBase*>(callComp);
221  compPtr->getValue_handlerBase(
222  portNum,
223  entry,
224  status,
225  time,
226  val
227  );
228  }
229 
230  void PolyDbComponentBase ::
231  m_p_setValue_in(
232  Fw::PassiveComponentBase* callComp,
233  FwIndexType portNum,
234  const Svc::PolyDbCfg::PolyDbEntry& entry,
235  Svc::MeasurementStatus& status,
236  Fw::Time& time,
237  Fw::PolyType& val
238  )
239  {
240  FW_ASSERT(callComp);
241  PolyDbComponentBase* compPtr = static_cast<PolyDbComponentBase*>(callComp);
242  compPtr->setValue_handlerBase(
243  portNum,
244  entry,
245  status,
246  time,
247  val
248  );
249  }
250 
251 }
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*.
Definition: ObjectName.hpp:50
#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:56
PlatformIndexType FwIndexType
Svc::InputPolyPort * get_getValue_InputPort(FwIndexType portNum)
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: PolyPortAc.cpp:62
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