F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
PassiveRateGroupComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title PassiveRateGroupComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for PassiveRateGroup 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 CycleIn
27  for (
28  FwIndexType port = 0;
29  port < static_cast<FwIndexType>(this->getNum_CycleIn_InputPorts());
30  port++
31  ) {
32  this->m_CycleIn_InputPort[port].init();
33  this->m_CycleIn_InputPort[port].addCallComp(
34  this,
35  m_p_CycleIn_in
36  );
37  this->m_CycleIn_InputPort[port].setPortNum(port);
38 
39 #if FW_OBJECT_NAMES == 1
40  Fw::ObjectName portName;
41  portName.format(
42  "%s_CycleIn_InputPort[%" PRI_FwIndexType "]",
43  this->m_objName.toChar(),
44  port
45  );
46  this->m_CycleIn_InputPort[port].setObjName(portName.toChar());
47 #endif
48  }
49 
50  // Connect output port Time
51  for (
52  FwIndexType port = 0;
53  port < static_cast<FwIndexType>(this->getNum_Time_OutputPorts());
54  port++
55  ) {
56  this->m_Time_OutputPort[port].init();
57 
58 #if FW_OBJECT_NAMES == 1
59  Fw::ObjectName portName;
60  portName.format(
61  "%s_Time_OutputPort[%" PRI_FwIndexType "]",
62  this->m_objName.toChar(),
63  port
64  );
65  this->m_Time_OutputPort[port].setObjName(portName.toChar());
66 #endif
67  }
68 
69  // Connect output port Tlm
70  for (
71  FwIndexType port = 0;
72  port < static_cast<FwIndexType>(this->getNum_Tlm_OutputPorts());
73  port++
74  ) {
75  this->m_Tlm_OutputPort[port].init();
76 
77 #if FW_OBJECT_NAMES == 1
78  Fw::ObjectName portName;
79  portName.format(
80  "%s_Tlm_OutputPort[%" PRI_FwIndexType "]",
81  this->m_objName.toChar(),
82  port
83  );
84  this->m_Tlm_OutputPort[port].setObjName(portName.toChar());
85 #endif
86  }
87 
88  // Connect output port RateGroupMemberOut
89  for (
90  FwIndexType port = 0;
91  port < static_cast<FwIndexType>(this->getNum_RateGroupMemberOut_OutputPorts());
92  port++
93  ) {
94  this->m_RateGroupMemberOut_OutputPort[port].init();
95 
96 #if FW_OBJECT_NAMES == 1
97  Fw::ObjectName portName;
98  portName.format(
99  "%s_RateGroupMemberOut_OutputPort[%" PRI_FwIndexType "]",
100  this->m_objName.toChar(),
101  port
102  );
103  this->m_RateGroupMemberOut_OutputPort[port].setObjName(portName.toChar());
104 #endif
105  }
106  }
107 
108  // ----------------------------------------------------------------------
109  // Getters for typed input ports
110  // ----------------------------------------------------------------------
111 
114  {
115  FW_ASSERT(
116  (0 <= portNum) && (portNum < this->getNum_CycleIn_InputPorts()),
117  static_cast<FwAssertArgType>(portNum)
118  );
119 
120  return &this->m_CycleIn_InputPort[portNum];
121  }
122 
123  // ----------------------------------------------------------------------
124  // Connect input ports to special output ports
125  // ----------------------------------------------------------------------
126 
129  FwIndexType portNum,
130  Fw::InputTimePort* port
131  )
132  {
133  FW_ASSERT(
134  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
135  static_cast<FwAssertArgType>(portNum)
136  );
137 
138  this->m_Time_OutputPort[portNum].addCallPort(port);
139  }
140 
143  FwIndexType portNum,
144  Fw::InputTlmPort* port
145  )
146  {
147  FW_ASSERT(
148  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
149  static_cast<FwAssertArgType>(portNum)
150  );
151 
152  this->m_Tlm_OutputPort[portNum].addCallPort(port);
153  }
154 
155  // ----------------------------------------------------------------------
156  // Connect typed input ports to typed output ports
157  // ----------------------------------------------------------------------
158 
161  FwIndexType portNum,
162  Svc::InputSchedPort* port
163  )
164  {
165  FW_ASSERT(
166  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
167  static_cast<FwAssertArgType>(portNum)
168  );
169 
170  this->m_RateGroupMemberOut_OutputPort[portNum].addCallPort(port);
171  }
172 
173 #if FW_PORT_SERIALIZATION
174 
175  // ----------------------------------------------------------------------
176  // Connect serial input ports to special output ports
177  // ----------------------------------------------------------------------
178 
181  FwIndexType portNum,
182  Fw::InputSerializePort* port
183  )
184  {
185  FW_ASSERT(
186  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
187  static_cast<FwAssertArgType>(portNum)
188  );
189 
190  this->m_Time_OutputPort[portNum].registerSerialPort(port);
191  }
192 
195  FwIndexType portNum,
196  Fw::InputSerializePort* port
197  )
198  {
199  FW_ASSERT(
200  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
201  static_cast<FwAssertArgType>(portNum)
202  );
203 
204  this->m_Tlm_OutputPort[portNum].registerSerialPort(port);
205  }
206 
207 #endif
208 
209 #if FW_PORT_SERIALIZATION
210 
211  // ----------------------------------------------------------------------
212  // Connect serial input ports to typed output ports
213  // ----------------------------------------------------------------------
214 
217  FwIndexType portNum,
218  Fw::InputSerializePort* port
219  )
220  {
221  FW_ASSERT(
222  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
223  static_cast<FwAssertArgType>(portNum)
224  );
225 
226  this->m_RateGroupMemberOut_OutputPort[portNum].registerSerialPort(port);
227  }
228 
229 #endif
230 
231  // ----------------------------------------------------------------------
232  // Component construction and destruction
233  // ----------------------------------------------------------------------
234 
236  PassiveRateGroupComponentBase(const char* compName) :
237  Fw::PassiveComponentBase(compName)
238  {
239 
240  }
241 
244  {
245 
246  }
247 
248  // ----------------------------------------------------------------------
249  // Connection status queries for special output ports
250  // ----------------------------------------------------------------------
251 
254  {
255  FW_ASSERT(
256  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
257  static_cast<FwAssertArgType>(portNum)
258  );
259 
260  return this->m_Time_OutputPort[portNum].isConnected();
261  }
262 
265  {
266  FW_ASSERT(
267  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
268  static_cast<FwAssertArgType>(portNum)
269  );
270 
271  return this->m_Tlm_OutputPort[portNum].isConnected();
272  }
273 
274  // ----------------------------------------------------------------------
275  // Connection status queries for typed output ports
276  // ----------------------------------------------------------------------
277 
280  {
281  FW_ASSERT(
282  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
283  static_cast<FwAssertArgType>(portNum)
284  );
285 
286  return this->m_RateGroupMemberOut_OutputPort[portNum].isConnected();
287  }
288 
289  // ----------------------------------------------------------------------
290  // Port handler base-class functions for typed input ports
291  //
292  // Call these functions directly to bypass the corresponding ports
293  // ----------------------------------------------------------------------
294 
297  FwIndexType portNum,
298  Os::RawTime& cycleStart
299  )
300  {
301  // Make sure port number is valid
302  FW_ASSERT(
303  (0 <= portNum) && (portNum < this->getNum_CycleIn_InputPorts()),
304  static_cast<FwAssertArgType>(portNum)
305  );
306 
307  // Call handler function
308  this->CycleIn_handler(
309  portNum,
310  cycleStart
311  );
312  }
313 
314  // ----------------------------------------------------------------------
315  // Invocation functions for typed output ports
316  // ----------------------------------------------------------------------
317 
320  FwIndexType portNum,
321  U32 context
322  )
323  {
324  FW_ASSERT(
325  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
326  static_cast<FwAssertArgType>(portNum)
327  );
328 
329  FW_ASSERT(
330  this->m_RateGroupMemberOut_OutputPort[portNum].isConnected(),
331  static_cast<FwAssertArgType>(portNum)
332  );
333  this->m_RateGroupMemberOut_OutputPort[portNum].invoke(
334  context
335  );
336  }
337 
338  // ----------------------------------------------------------------------
339  // Telemetry write functions
340  // ----------------------------------------------------------------------
341 
344  U32 arg,
345  Fw::Time _tlmTime
346  )
347  {
348  // Check to see if it is the first time
349  if (not this->m_first_update_MaxCycleTime) {
350  // Check to see if value has changed. If not, don't write it.
351  if (arg == this->m_last_MaxCycleTime) {
352  return;
353  }
354  else {
355  this->m_last_MaxCycleTime = arg;
356  }
357  }
358  else {
359  this->m_first_update_MaxCycleTime = false;
360  this->m_last_MaxCycleTime = arg;
361  }
362 
363  if (this->m_Tlm_OutputPort[0].isConnected()) {
364  if (
365  this->m_Time_OutputPort[0].isConnected() &&
366  (_tlmTime == Fw::ZERO_TIME)
367  ) {
368  this->m_Time_OutputPort[0].invoke(_tlmTime);
369  }
370 
371  Fw::TlmBuffer _tlmBuff;
372  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
373  FW_ASSERT(
374  _stat == Fw::FW_SERIALIZE_OK,
375  static_cast<FwAssertArgType>(_stat)
376  );
377 
378  FwChanIdType _id;
379 
380  _id = this->getIdBase() + CHANNELID_MAXCYCLETIME;
381 
382  this->m_Tlm_OutputPort[0].invoke(
383  _id,
384  _tlmTime,
385  _tlmBuff
386  );
387  }
388  }
389 
392  U32 arg,
393  Fw::Time _tlmTime
394  ) const
395  {
396  if (this->m_Tlm_OutputPort[0].isConnected()) {
397  if (
398  this->m_Time_OutputPort[0].isConnected() &&
399  (_tlmTime == Fw::ZERO_TIME)
400  ) {
401  this->m_Time_OutputPort[0].invoke(_tlmTime);
402  }
403 
404  Fw::TlmBuffer _tlmBuff;
405  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
406  FW_ASSERT(
407  _stat == Fw::FW_SERIALIZE_OK,
408  static_cast<FwAssertArgType>(_stat)
409  );
410 
411  FwChanIdType _id;
412 
413  _id = this->getIdBase() + CHANNELID_CYCLETIME;
414 
415  this->m_Tlm_OutputPort[0].invoke(
416  _id,
417  _tlmTime,
418  _tlmBuff
419  );
420  }
421  }
422 
425  U32 arg,
426  Fw::Time _tlmTime
427  ) const
428  {
429  if (this->m_Tlm_OutputPort[0].isConnected()) {
430  if (
431  this->m_Time_OutputPort[0].isConnected() &&
432  (_tlmTime == Fw::ZERO_TIME)
433  ) {
434  this->m_Time_OutputPort[0].invoke(_tlmTime);
435  }
436 
437  Fw::TlmBuffer _tlmBuff;
438  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
439  FW_ASSERT(
440  _stat == Fw::FW_SERIALIZE_OK,
441  static_cast<FwAssertArgType>(_stat)
442  );
443 
444  FwChanIdType _id;
445 
446  _id = this->getIdBase() + CHANNELID_CYCLECOUNT;
447 
448  this->m_Tlm_OutputPort[0].invoke(
449  _id,
450  _tlmTime,
451  _tlmBuff
452  );
453  }
454  }
455 
456  // ----------------------------------------------------------------------
457  // Time
458  // ----------------------------------------------------------------------
459 
461  getTime() const
462  {
463  if (this->m_Time_OutputPort[0].isConnected()) {
464  Fw::Time _time;
465  this->m_Time_OutputPort[0].invoke(_time);
466  return _time;
467  }
468  else {
469  return Fw::Time(TimeBase::TB_NONE, 0, 0);
470  }
471  }
472 
473  // ----------------------------------------------------------------------
474  // Calls for messages received on typed input ports
475  // ----------------------------------------------------------------------
476 
477  void PassiveRateGroupComponentBase ::
478  m_p_CycleIn_in(
479  Fw::PassiveComponentBase* callComp,
480  FwIndexType portNum,
481  Os::RawTime& cycleStart
482  )
483  {
484  FW_ASSERT(callComp);
485  PassiveRateGroupComponentBase* compPtr = static_cast<PassiveRateGroupComponentBase*>(callComp);
486  compPtr->CycleIn_handlerBase(
487  portNum,
488  cycleStart
489  );
490  }
491 
492 }
Serialization/Deserialization operation was successful.
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CyclePortAc.cpp:62
I32 FwEnumStoreType
static constexpr FwIndexType getNum_RateGroupMemberOut_OutputPorts()
void set_Tlm_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to Tlm[portNum].
const Time ZERO_TIME
Definition: Time.cpp:5
void init()
Initialization function.
Definition: TlmPortAc.cpp:144
No time base has been established (Required)
void addCallPort(InputTlmPort *callPort)
Register an input port.
Definition: TlmPortAc.cpp:150
void init()
Object initializer.
Definition: ObjBase.cpp:24
SerializeStatus
forward declaration for string
bool isConnected_RateGroupMemberOut_OutputPort(FwIndexType portNum)
void init()
Initialization function.
Definition: TimePortAc.cpp:128
void invoke(U32 context) const
Invoke a port interface.
void invoke(Fw::Time &time) const
Invoke a port interface.
Definition: TimePortAc.cpp:147
void tlmWrite_CycleTime(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
const char * toChar() const
Definition: ObjectName.hpp:50
FwIdType FwChanIdType
The type of a telemetry channel identifier.
virtual ~PassiveRateGroupComponentBase()
Destroy PassiveRateGroupComponentBase object.
void invoke(FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) const
Invoke a port interface.
Definition: TlmPortAc.cpp:163
bool isConnected() const
Definition: PortBase.cpp:38
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)
serialize 8-bit unsigned int
Auto-generated base for PassiveRateGroup component.
PassiveRateGroupComponentBase(const char *compName="")
Construct PassiveRateGroupComponentBase object.
#define PRI_FwIndexType
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:55
void setPortNum(FwIndexType portNum)
void tlmWrite_MaxCycleTime(U32 arg, Fw::Time _tlmTime=Fw::Time())
void init()
Initialization function.
Definition: CyclePortAc.cpp:56
static constexpr FwIndexType getNum_Time_OutputPorts()
void tlmWrite_CycleCount(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
PlatformIndexType FwIndexType
void init()
Initialization function.
void RateGroupMemberOut_out(FwIndexType portNum, U32 context)
Invoke output port RateGroupMemberOut.
void set_RateGroupMemberOut_OutputPort(FwIndexType portNum, Svc::InputSchedPort *port)
Connect port to RateGroupMemberOut[portNum].
virtual void CycleIn_handler(FwIndexType portNum, Os::RawTime &cycleStart)=0
Handler for input port CycleIn.
RateGroupDivider component implementation.
static constexpr FwIndexType getNum_Tlm_OutputPorts()
void CycleIn_handlerBase(FwIndexType portNum, Os::RawTime &cycleStart)
Handler base-class function for input port CycleIn.
static constexpr FwIndexType getNum_CycleIn_InputPorts()
Implementation of malloc based allocator.
Svc::InputCyclePort * get_CycleIn_InputPort(FwIndexType portNum)
#define FW_ASSERT(...)
Definition: Assert.hpp:14
void addCallPort(InputSchedPort *callPort)
Register an input port.