F´ Flight Software - C/C++ Documentation  devel
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 <cstdio>
8 
10 #include "Fw/Types/Assert.hpp"
11 #if FW_ENABLE_TEXT_LOGGING
12 #include "Fw/Types/String.hpp"
13 #endif
14 
15 namespace Svc {
16 
17  // ----------------------------------------------------------------------
18  // Component initialization
19  // ----------------------------------------------------------------------
20 
22  init(NATIVE_INT_TYPE instance)
23  {
24  // Initialize base class
26 
27  // Connect input port CycleIn
28  for (
29  PlatformIntType port = 0;
30  port < static_cast<PlatformIntType>(this->getNum_CycleIn_InputPorts());
31  port++
32  ) {
33  this->m_CycleIn_InputPort[port].init();
34  this->m_CycleIn_InputPort[port].addCallComp(
35  this,
36  m_p_CycleIn_in
37  );
38  this->m_CycleIn_InputPort[port].setPortNum(port);
39 
40 #if FW_OBJECT_NAMES == 1
41  // The port name consists of this->m_objName and some extra info.
42  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
43  // However, the compiler may assume that this->m_objName fills
44  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
45  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
46  // bytes to cover the extra info.
47  char portName[2*FW_OBJ_NAME_MAX_SIZE];
48  (void) snprintf(
49  portName,
50  sizeof(portName),
51  "%s_CycleIn_InputPort[%" PRI_PlatformIntType "]",
52  this->m_objName,
53  port
54  );
55  this->m_CycleIn_InputPort[port].setObjName(portName);
56 #endif
57  }
58 
59  // Connect output port Time
60  for (
61  PlatformIntType port = 0;
62  port < static_cast<PlatformIntType>(this->getNum_Time_OutputPorts());
63  port++
64  ) {
65  this->m_Time_OutputPort[port].init();
66 
67 #if FW_OBJECT_NAMES == 1
68  // The port name consists of this->m_objName and some extra info.
69  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
70  // However, the compiler may assume that this->m_objName fills
71  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
72  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
73  // bytes to cover the extra info.
74  char portName[2*FW_OBJ_NAME_MAX_SIZE];
75  (void) snprintf(
76  portName,
77  sizeof(portName),
78  "%s_Time_OutputPort[%" PRI_PlatformIntType "]",
79  this->m_objName,
80  port
81  );
82  this->m_Time_OutputPort[port].setObjName(portName);
83 #endif
84  }
85 
86  // Connect output port Tlm
87  for (
88  PlatformIntType port = 0;
89  port < static_cast<PlatformIntType>(this->getNum_Tlm_OutputPorts());
90  port++
91  ) {
92  this->m_Tlm_OutputPort[port].init();
93 
94 #if FW_OBJECT_NAMES == 1
95  // The port name consists of this->m_objName and some extra info.
96  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
97  // However, the compiler may assume that this->m_objName fills
98  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
99  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
100  // bytes to cover the extra info.
101  char portName[2*FW_OBJ_NAME_MAX_SIZE];
102  (void) snprintf(
103  portName,
104  sizeof(portName),
105  "%s_Tlm_OutputPort[%" PRI_PlatformIntType "]",
106  this->m_objName,
107  port
108  );
109  this->m_Tlm_OutputPort[port].setObjName(portName);
110 #endif
111  }
112 
113  // Connect output port RateGroupMemberOut
114  for (
115  PlatformIntType port = 0;
116  port < static_cast<PlatformIntType>(this->getNum_RateGroupMemberOut_OutputPorts());
117  port++
118  ) {
119  this->m_RateGroupMemberOut_OutputPort[port].init();
120 
121 #if FW_OBJECT_NAMES == 1
122  // The port name consists of this->m_objName and some extra info.
123  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
124  // However, the compiler may assume that this->m_objName fills
125  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
126  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
127  // bytes to cover the extra info.
128  char portName[2*FW_OBJ_NAME_MAX_SIZE];
129  (void) snprintf(
130  portName,
131  sizeof(portName),
132  "%s_RateGroupMemberOut_OutputPort[%" PRI_PlatformIntType "]",
133  this->m_objName,
134  port
135  );
136  this->m_RateGroupMemberOut_OutputPort[port].setObjName(portName);
137 #endif
138  }
139  }
140 
141  // ----------------------------------------------------------------------
142  // Getters for typed input ports
143  // ----------------------------------------------------------------------
144 
147  {
148  FW_ASSERT(
149  portNum < this->getNum_CycleIn_InputPorts(),
150  static_cast<FwAssertArgType>(portNum)
151  );
152 
153  return &this->m_CycleIn_InputPort[portNum];
154  }
155 
156  // ----------------------------------------------------------------------
157  // Connect input ports to special output ports
158  // ----------------------------------------------------------------------
159 
162  NATIVE_INT_TYPE portNum,
163  Fw::InputTimePort* port
164  )
165  {
166  FW_ASSERT(
167  portNum < this->getNum_Time_OutputPorts(),
168  static_cast<FwAssertArgType>(portNum)
169  );
170 
171  this->m_Time_OutputPort[portNum].addCallPort(port);
172  }
173 
176  NATIVE_INT_TYPE portNum,
177  Fw::InputTlmPort* port
178  )
179  {
180  FW_ASSERT(
181  portNum < this->getNum_Tlm_OutputPorts(),
182  static_cast<FwAssertArgType>(portNum)
183  );
184 
185  this->m_Tlm_OutputPort[portNum].addCallPort(port);
186  }
187 
188  // ----------------------------------------------------------------------
189  // Connect typed input ports to typed output ports
190  // ----------------------------------------------------------------------
191 
194  NATIVE_INT_TYPE portNum,
195  Svc::InputSchedPort* port
196  )
197  {
198  FW_ASSERT(
199  portNum < this->getNum_RateGroupMemberOut_OutputPorts(),
200  static_cast<FwAssertArgType>(portNum)
201  );
202 
203  this->m_RateGroupMemberOut_OutputPort[portNum].addCallPort(port);
204  }
205 
206 #if FW_PORT_SERIALIZATION
207 
208  // ----------------------------------------------------------------------
209  // Connect serial input ports to special output ports
210  // ----------------------------------------------------------------------
211 
214  NATIVE_INT_TYPE portNum,
215  Fw::InputSerializePort* port
216  )
217  {
218  FW_ASSERT(
219  portNum < this->getNum_Time_OutputPorts(),
220  static_cast<FwAssertArgType>(portNum)
221  );
222 
223  this->m_Time_OutputPort[portNum].registerSerialPort(port);
224  }
225 
228  NATIVE_INT_TYPE portNum,
229  Fw::InputSerializePort* port
230  )
231  {
232  FW_ASSERT(
233  portNum < this->getNum_Tlm_OutputPorts(),
234  static_cast<FwAssertArgType>(portNum)
235  );
236 
237  this->m_Tlm_OutputPort[portNum].registerSerialPort(port);
238  }
239 
240 #endif
241 
242 #if FW_PORT_SERIALIZATION
243 
244  // ----------------------------------------------------------------------
245  // Connect serial input ports to typed output ports
246  // ----------------------------------------------------------------------
247 
250  NATIVE_INT_TYPE portNum,
251  Fw::InputSerializePort* port
252  )
253  {
254  FW_ASSERT(
255  portNum < this->getNum_RateGroupMemberOut_OutputPorts(),
256  static_cast<FwAssertArgType>(portNum)
257  );
258 
259  this->m_RateGroupMemberOut_OutputPort[portNum].registerSerialPort(port);
260  }
261 
262 #endif
263 
264  // ----------------------------------------------------------------------
265  // Component construction and destruction
266  // ----------------------------------------------------------------------
267 
269  PassiveRateGroupComponentBase(const char* compName) :
270  Fw::PassiveComponentBase(compName)
271  {
272  // Write telemetry channel MaxCycleTime
273  this->m_first_update_MaxCycleTime = true;
274  this->m_last_MaxCycleTime = 0;
275  }
276 
279  {
280 
281  }
282 
283  // ----------------------------------------------------------------------
284  // Getters for numbers of typed input ports
285  // ----------------------------------------------------------------------
286 
289  {
290  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_CycleIn_InputPort));
291  }
292 
293  // ----------------------------------------------------------------------
294  // Getters for numbers of special output ports
295  // ----------------------------------------------------------------------
296 
299  {
300  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Time_OutputPort));
301  }
302 
305  {
306  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Tlm_OutputPort));
307  }
308 
309  // ----------------------------------------------------------------------
310  // Getters for numbers of typed output ports
311  // ----------------------------------------------------------------------
312 
315  {
316  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_RateGroupMemberOut_OutputPort));
317  }
318 
319  // ----------------------------------------------------------------------
320  // Connection status queries for special output ports
321  // ----------------------------------------------------------------------
322 
325  {
326  FW_ASSERT(
327  portNum < this->getNum_Time_OutputPorts(),
328  static_cast<FwAssertArgType>(portNum)
329  );
330 
331  return this->m_Time_OutputPort[portNum].isConnected();
332  }
333 
336  {
337  FW_ASSERT(
338  portNum < this->getNum_Tlm_OutputPorts(),
339  static_cast<FwAssertArgType>(portNum)
340  );
341 
342  return this->m_Tlm_OutputPort[portNum].isConnected();
343  }
344 
345  // ----------------------------------------------------------------------
346  // Connection status queries for typed output ports
347  // ----------------------------------------------------------------------
348 
351  {
352  FW_ASSERT(
353  portNum < this->getNum_RateGroupMemberOut_OutputPorts(),
354  static_cast<FwAssertArgType>(portNum)
355  );
356 
357  return this->m_RateGroupMemberOut_OutputPort[portNum].isConnected();
358  }
359 
360  // ----------------------------------------------------------------------
361  // Port handler base-class functions for typed input ports
362  //
363  // Call these functions directly to bypass the corresponding ports
364  // ----------------------------------------------------------------------
365 
368  NATIVE_INT_TYPE portNum,
369  Svc::TimerVal& cycleStart
370  )
371  {
372  // Make sure port number is valid
373  FW_ASSERT(
374  portNum < this->getNum_CycleIn_InputPorts(),
375  static_cast<FwAssertArgType>(portNum)
376  );
377 
378  // Call handler function
379  this->CycleIn_handler(
380  portNum,
381  cycleStart
382  );
383  }
384 
385  // ----------------------------------------------------------------------
386  // Invocation functions for typed output ports
387  // ----------------------------------------------------------------------
388 
391  NATIVE_INT_TYPE portNum,
392  NATIVE_UINT_TYPE context
393  )
394  {
395  FW_ASSERT(
396  portNum < this->getNum_RateGroupMemberOut_OutputPorts(),
397  static_cast<FwAssertArgType>(portNum)
398  );
399  this->m_RateGroupMemberOut_OutputPort[portNum].invoke(
400  context
401  );
402  }
403 
404  // ----------------------------------------------------------------------
405  // Telemetry write functions
406  // ----------------------------------------------------------------------
407 
410  U32 arg,
411  Fw::Time _tlmTime
412  )
413  {
414  // Check to see if it is the first time
415  if (not this->m_first_update_MaxCycleTime) {
416  // Check to see if value has changed. If not, don't write it.
417  if (arg == this->m_last_MaxCycleTime) {
418  return;
419  }
420  else {
421  this->m_last_MaxCycleTime = arg;
422  }
423  }
424  else {
425  this->m_first_update_MaxCycleTime = false;
426  this->m_last_MaxCycleTime = arg;
427  }
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.serialize(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_MAXCYCLETIME;
447 
448  this->m_Tlm_OutputPort[0].invoke(
449  _id,
450  _tlmTime,
451  _tlmBuff
452  );
453  }
454  }
455 
458  U32 arg,
459  Fw::Time _tlmTime
460  )
461  {
462  if (this->m_Tlm_OutputPort[0].isConnected()) {
463  if (
464  this->m_Time_OutputPort[0].isConnected() &&
465  (_tlmTime == Fw::ZERO_TIME)
466  ) {
467  this->m_Time_OutputPort[0].invoke(_tlmTime);
468  }
469 
470  Fw::TlmBuffer _tlmBuff;
471  Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
472  FW_ASSERT(
473  _stat == Fw::FW_SERIALIZE_OK,
474  static_cast<FwAssertArgType>(_stat)
475  );
476 
477  FwChanIdType _id;
478 
479  _id = this->getIdBase() + CHANNELID_CYCLETIME;
480 
481  this->m_Tlm_OutputPort[0].invoke(
482  _id,
483  _tlmTime,
484  _tlmBuff
485  );
486  }
487  }
488 
491  U32 arg,
492  Fw::Time _tlmTime
493  )
494  {
495  if (this->m_Tlm_OutputPort[0].isConnected()) {
496  if (
497  this->m_Time_OutputPort[0].isConnected() &&
498  (_tlmTime == Fw::ZERO_TIME)
499  ) {
500  this->m_Time_OutputPort[0].invoke(_tlmTime);
501  }
502 
503  Fw::TlmBuffer _tlmBuff;
504  Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
505  FW_ASSERT(
506  _stat == Fw::FW_SERIALIZE_OK,
507  static_cast<FwAssertArgType>(_stat)
508  );
509 
510  FwChanIdType _id;
511 
512  _id = this->getIdBase() + CHANNELID_CYCLECOUNT;
513 
514  this->m_Tlm_OutputPort[0].invoke(
515  _id,
516  _tlmTime,
517  _tlmBuff
518  );
519  }
520  }
521 
522  // ----------------------------------------------------------------------
523  // Time
524  // ----------------------------------------------------------------------
525 
527  getTime()
528  {
529  if (this->m_Time_OutputPort[0].isConnected()) {
530  Fw::Time _time;
531  this->m_Time_OutputPort[0].invoke(_time);
532  return _time;
533  }
534  else {
535  return Fw::Time(TB_NONE, 0, 0);
536  }
537  }
538 
539  // ----------------------------------------------------------------------
540  // Calls for messages received on typed input ports
541  // ----------------------------------------------------------------------
542 
543  void PassiveRateGroupComponentBase ::
544  m_p_CycleIn_in(
545  Fw::PassiveComponentBase* callComp,
546  NATIVE_INT_TYPE portNum,
547  Svc::TimerVal& cycleStart
548  )
549  {
550  FW_ASSERT(callComp);
551  PassiveRateGroupComponentBase* compPtr = static_cast<PassiveRateGroupComponentBase*>(callComp);
552  compPtr->CycleIn_handlerBase(
553  portNum,
554  cycleStart
555  );
556  }
557 
558 }
#define FW_ASSERT(...)
Definition: Assert.hpp:14
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:51
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:66
PlatformUIntType NATIVE_UINT_TYPE
Definition: BasicTypes.h:52
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
#define PRI_PlatformIntType
@ TB_NONE
No time base has been established.
Definition: FpConfig.h:39
PlatformAssertArgType FwAssertArgType
Definition: FpConfig.h:21
U32 FwChanIdType
Definition: FpConfig.h:59
#define FW_OBJ_NAME_MAX_SIZE
Size of object name (if object names enabled). AC Limits to 80, truncation occurs above 80.
Definition: FpConfig.h:184
void setPortNum(NATIVE_INT_TYPE portNum)
void init()
Object initializer.
Definition: ObjBase.cpp:27
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
void invoke(Fw::Time &time)
Invoke a port interface.
Definition: TimePortAc.cpp:147
void init()
Initialization function.
Definition: TimePortAc.cpp:128
void addCallPort(InputTlmPort *callPort)
Register an input port.
Definition: TlmPortAc.cpp:150
void init()
Initialization function.
Definition: TlmPortAc.cpp:144
void invoke(FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val)
Invoke a port interface.
Definition: TlmPortAc.cpp:163
bool isConnected()
Definition: PortBase.cpp:41
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
Definition: Time.hpp:9
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CyclePortAc.cpp:62
void init()
Initialization function.
Definition: CyclePortAc.cpp:56
void invoke(NATIVE_UINT_TYPE context)
Invoke a port interface.
void init()
Initialization function.
void addCallPort(InputSchedPort *callPort)
Register an input port.
Auto-generated base for PassiveRateGroup component.
void set_Tlm_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputTlmPort *port)
Connect port to Tlm[portNum].
PassiveRateGroupComponentBase(const char *compName="")
Construct PassiveRateGroupComponentBase object.
void tlmWrite_CycleTime(U32 arg, Fw::Time _tlmTime=Fw::Time())
void set_Time_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
void RateGroupMemberOut_out(NATIVE_INT_TYPE portNum, NATIVE_UINT_TYPE context)
Invoke output port RateGroupMemberOut.
void CycleIn_handlerBase(NATIVE_INT_TYPE portNum, Svc::TimerVal &cycleStart)
Handler base-class function for input port CycleIn.
bool isConnected_Tlm_OutputPort(NATIVE_INT_TYPE portNum)
virtual ~PassiveRateGroupComponentBase()
Destroy PassiveRateGroupComponentBase object.
NATIVE_INT_TYPE getNum_RateGroupMemberOut_OutputPorts() const
void tlmWrite_CycleCount(U32 arg, Fw::Time _tlmTime=Fw::Time())
Svc::InputCyclePort * get_CycleIn_InputPort(NATIVE_INT_TYPE portNum)
@ CHANNELID_MAXCYCLETIME
Channel ID for MaxCycleTime.
@ CHANNELID_CYCLECOUNT
Channel ID for CycleCount.
bool isConnected_Time_OutputPort(NATIVE_INT_TYPE portNum)
void tlmWrite_MaxCycleTime(U32 arg, Fw::Time _tlmTime=Fw::Time())
bool isConnected_RateGroupMemberOut_OutputPort(NATIVE_INT_TYPE portNum)
void set_RateGroupMemberOut_OutputPort(NATIVE_INT_TYPE portNum, Svc::InputSchedPort *port)
Connect port to RateGroupMemberOut[portNum].
virtual void CycleIn_handler(NATIVE_INT_TYPE portNum, Svc::TimerVal &cycleStart)=0
Handler for input port CycleIn.
Serializable class for carrying timer values.
Definition: TimerVal.hpp:22
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
const Time ZERO_TIME
Definition: Time.cpp:5