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 
8 #include "Fw/Types/Assert.hpp"
10 #if FW_ENABLE_TEXT_LOGGING
11 #include "Fw/Types/String.hpp"
12 #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  // Write telemetry channel MaxCycleTime
240  this->m_first_update_MaxCycleTime = true;
241  this->m_last_MaxCycleTime = 0;
242  }
243 
246  {
247 
248  }
249 
250  // ----------------------------------------------------------------------
251  // Getters for numbers of typed input ports
252  // ----------------------------------------------------------------------
253 
256  {
257  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_CycleIn_InputPort));
258  }
259 
260  // ----------------------------------------------------------------------
261  // Getters for numbers of special output ports
262  // ----------------------------------------------------------------------
263 
266  {
267  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Time_OutputPort));
268  }
269 
272  {
273  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Tlm_OutputPort));
274  }
275 
276  // ----------------------------------------------------------------------
277  // Getters for numbers of typed output ports
278  // ----------------------------------------------------------------------
279 
282  {
283  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_RateGroupMemberOut_OutputPort));
284  }
285 
286  // ----------------------------------------------------------------------
287  // Connection status queries for special output ports
288  // ----------------------------------------------------------------------
289 
292  {
293  FW_ASSERT(
294  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
295  static_cast<FwAssertArgType>(portNum)
296  );
297 
298  return this->m_Time_OutputPort[portNum].isConnected();
299  }
300 
303  {
304  FW_ASSERT(
305  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
306  static_cast<FwAssertArgType>(portNum)
307  );
308 
309  return this->m_Tlm_OutputPort[portNum].isConnected();
310  }
311 
312  // ----------------------------------------------------------------------
313  // Connection status queries for typed output ports
314  // ----------------------------------------------------------------------
315 
318  {
319  FW_ASSERT(
320  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
321  static_cast<FwAssertArgType>(portNum)
322  );
323 
324  return this->m_RateGroupMemberOut_OutputPort[portNum].isConnected();
325  }
326 
327  // ----------------------------------------------------------------------
328  // Port handler base-class functions for typed input ports
329  //
330  // Call these functions directly to bypass the corresponding ports
331  // ----------------------------------------------------------------------
332 
335  FwIndexType portNum,
336  Os::RawTime& cycleStart
337  )
338  {
339  // Make sure port number is valid
340  FW_ASSERT(
341  (0 <= portNum) && (portNum < this->getNum_CycleIn_InputPorts()),
342  static_cast<FwAssertArgType>(portNum)
343  );
344 
345  // Call handler function
346  this->CycleIn_handler(
347  portNum,
348  cycleStart
349  );
350  }
351 
352  // ----------------------------------------------------------------------
353  // Invocation functions for typed output ports
354  // ----------------------------------------------------------------------
355 
358  FwIndexType portNum,
359  U32 context
360  )
361  {
362  FW_ASSERT(
363  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
364  static_cast<FwAssertArgType>(portNum)
365  );
366 
367  FW_ASSERT(
368  this->m_RateGroupMemberOut_OutputPort[portNum].isConnected(),
369  static_cast<FwAssertArgType>(portNum)
370  );
371  this->m_RateGroupMemberOut_OutputPort[portNum].invoke(
372  context
373  );
374  }
375 
376  // ----------------------------------------------------------------------
377  // Telemetry write functions
378  // ----------------------------------------------------------------------
379 
382  U32 arg,
383  Fw::Time _tlmTime
384  )
385  {
386  // Check to see if it is the first time
387  if (not this->m_first_update_MaxCycleTime) {
388  // Check to see if value has changed. If not, don't write it.
389  if (arg == this->m_last_MaxCycleTime) {
390  return;
391  }
392  else {
393  this->m_last_MaxCycleTime = arg;
394  }
395  }
396  else {
397  this->m_first_update_MaxCycleTime = false;
398  this->m_last_MaxCycleTime = arg;
399  }
400 
401  if (this->m_Tlm_OutputPort[0].isConnected()) {
402  if (
403  this->m_Time_OutputPort[0].isConnected() &&
404  (_tlmTime == Fw::ZERO_TIME)
405  ) {
406  this->m_Time_OutputPort[0].invoke(_tlmTime);
407  }
408 
409  Fw::TlmBuffer _tlmBuff;
410  Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
411  FW_ASSERT(
412  _stat == Fw::FW_SERIALIZE_OK,
413  static_cast<FwAssertArgType>(_stat)
414  );
415 
416  FwChanIdType _id;
417 
418  _id = this->getIdBase() + CHANNELID_MAXCYCLETIME;
419 
420  this->m_Tlm_OutputPort[0].invoke(
421  _id,
422  _tlmTime,
423  _tlmBuff
424  );
425  }
426  }
427 
430  U32 arg,
431  Fw::Time _tlmTime
432  ) const
433  {
434  if (this->m_Tlm_OutputPort[0].isConnected()) {
435  if (
436  this->m_Time_OutputPort[0].isConnected() &&
437  (_tlmTime == Fw::ZERO_TIME)
438  ) {
439  this->m_Time_OutputPort[0].invoke(_tlmTime);
440  }
441 
442  Fw::TlmBuffer _tlmBuff;
443  Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
444  FW_ASSERT(
445  _stat == Fw::FW_SERIALIZE_OK,
446  static_cast<FwAssertArgType>(_stat)
447  );
448 
449  FwChanIdType _id;
450 
451  _id = this->getIdBase() + CHANNELID_CYCLETIME;
452 
453  this->m_Tlm_OutputPort[0].invoke(
454  _id,
455  _tlmTime,
456  _tlmBuff
457  );
458  }
459  }
460 
463  U32 arg,
464  Fw::Time _tlmTime
465  ) const
466  {
467  if (this->m_Tlm_OutputPort[0].isConnected()) {
468  if (
469  this->m_Time_OutputPort[0].isConnected() &&
470  (_tlmTime == Fw::ZERO_TIME)
471  ) {
472  this->m_Time_OutputPort[0].invoke(_tlmTime);
473  }
474 
475  Fw::TlmBuffer _tlmBuff;
476  Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
477  FW_ASSERT(
478  _stat == Fw::FW_SERIALIZE_OK,
479  static_cast<FwAssertArgType>(_stat)
480  );
481 
482  FwChanIdType _id;
483 
484  _id = this->getIdBase() + CHANNELID_CYCLECOUNT;
485 
486  this->m_Tlm_OutputPort[0].invoke(
487  _id,
488  _tlmTime,
489  _tlmBuff
490  );
491  }
492  }
493 
494  // ----------------------------------------------------------------------
495  // Time
496  // ----------------------------------------------------------------------
497 
499  getTime() const
500  {
501  if (this->m_Time_OutputPort[0].isConnected()) {
502  Fw::Time _time;
503  this->m_Time_OutputPort[0].invoke(_time);
504  return _time;
505  }
506  else {
507  return Fw::Time(TB_NONE, 0, 0);
508  }
509  }
510 
511  // ----------------------------------------------------------------------
512  // Calls for messages received on typed input ports
513  // ----------------------------------------------------------------------
514 
515  void PassiveRateGroupComponentBase ::
516  m_p_CycleIn_in(
517  Fw::PassiveComponentBase* callComp,
518  FwIndexType portNum,
519  Os::RawTime& cycleStart
520  )
521  {
522  FW_ASSERT(callComp);
523  PassiveRateGroupComponentBase* compPtr = static_cast<PassiveRateGroupComponentBase*>(callComp);
524  compPtr->CycleIn_handlerBase(
525  portNum,
526  cycleStart
527  );
528  }
529 
530 }
Serialization/Deserialization operation was successful.
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
Definition: Time.hpp:9
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CyclePortAc.cpp:62
I32 FwEnumStoreType
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
U32 FwChanIdType
The type of a telemetry channel identifier.
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
void addCallPort(InputTlmPort *callPort)
Register an input port.
Definition: TlmPortAc.cpp:150
void init()
Object initializer.
Definition: ObjBase.cpp:26
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
No time base has been established.
Definition: FpConfig.h:30
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:42
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
void tlmWrite_CycleCount(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
PlatformIndexType FwIndexType
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:93
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.
void CycleIn_handlerBase(FwIndexType portNum, Os::RawTime &cycleStart)
Handler base-class function for input port CycleIn.
Svc::InputCyclePort * get_CycleIn_InputPort(FwIndexType portNum)
#define FW_ASSERT(...)
Definition: Assert.hpp:14
void addCallPort(InputSchedPort *callPort)
Register an input port.