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 #if !FW_DIRECT_PORT_CALLS
27  // Connect input port CycleIn
28  for (
29  FwIndexType port = 0;
30  port < static_cast<FwIndexType>(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  Fw::ObjectName portName;
42  portName.format(
43  "%s_CycleIn_InputPort[%" PRI_FwIndexType "]",
44  this->m_objName.toChar(),
45  port
46  );
47  this->m_CycleIn_InputPort[port].setObjName(portName.toChar());
48 #endif
49  }
50 #endif
51 
52 #if !FW_DIRECT_PORT_CALLS
53  // Connect output port Time
54  for (
55  FwIndexType port = 0;
56  port < static_cast<FwIndexType>(this->getNum_Time_OutputPorts());
57  port++
58  ) {
59  this->m_Time_OutputPort[port].init();
60 
61 #if FW_OBJECT_NAMES == 1
62  Fw::ObjectName portName;
63  portName.format(
64  "%s_Time_OutputPort[%" PRI_FwIndexType "]",
65  this->m_objName.toChar(),
66  port
67  );
68  this->m_Time_OutputPort[port].setObjName(portName.toChar());
69 #endif
70  }
71 #endif
72 
73 #if !FW_DIRECT_PORT_CALLS
74  // Connect output port Tlm
75  for (
76  FwIndexType port = 0;
77  port < static_cast<FwIndexType>(this->getNum_Tlm_OutputPorts());
78  port++
79  ) {
80  this->m_Tlm_OutputPort[port].init();
81 
82 #if FW_OBJECT_NAMES == 1
83  Fw::ObjectName portName;
84  portName.format(
85  "%s_Tlm_OutputPort[%" PRI_FwIndexType "]",
86  this->m_objName.toChar(),
87  port
88  );
89  this->m_Tlm_OutputPort[port].setObjName(portName.toChar());
90 #endif
91  }
92 #endif
93 
94 #if !FW_DIRECT_PORT_CALLS
95  // Connect output port RateGroupMemberOut
96  for (
97  FwIndexType port = 0;
98  port < static_cast<FwIndexType>(this->getNum_RateGroupMemberOut_OutputPorts());
99  port++
100  ) {
101  this->m_RateGroupMemberOut_OutputPort[port].init();
102 
103 #if FW_OBJECT_NAMES == 1
104  Fw::ObjectName portName;
105  portName.format(
106  "%s_RateGroupMemberOut_OutputPort[%" PRI_FwIndexType "]",
107  this->m_objName.toChar(),
108  port
109  );
110  this->m_RateGroupMemberOut_OutputPort[port].setObjName(portName.toChar());
111 #endif
112  }
113 #endif
114  }
115 
116 #if !FW_DIRECT_PORT_CALLS
117 
118  // ----------------------------------------------------------------------
119  // Getters for typed input ports
120  // ----------------------------------------------------------------------
121 
124  {
125  FW_ASSERT(
126  (0 <= portNum) && (portNum < this->getNum_CycleIn_InputPorts()),
127  static_cast<FwAssertArgType>(portNum)
128  );
129 
130  return &this->m_CycleIn_InputPort[portNum];
131  }
132 
133 #endif
134 
135 #if !FW_DIRECT_PORT_CALLS
136 
137  // ----------------------------------------------------------------------
138  // Connect input ports to special output ports
139  // ----------------------------------------------------------------------
140 
143  FwIndexType portNum,
144  Fw::InputTimePort* port
145  )
146  {
147  FW_ASSERT(
148  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
149  static_cast<FwAssertArgType>(portNum)
150  );
151 
152  this->m_Time_OutputPort[portNum].addCallPort(port);
153  }
154 
157  FwIndexType portNum,
158  Fw::InputTlmPort* port
159  )
160  {
161  FW_ASSERT(
162  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
163  static_cast<FwAssertArgType>(portNum)
164  );
165 
166  this->m_Tlm_OutputPort[portNum].addCallPort(port);
167  }
168 
169 #endif
170 
171 #if !FW_DIRECT_PORT_CALLS
172 
173  // ----------------------------------------------------------------------
174  // Connect typed input ports to typed output ports
175  // ----------------------------------------------------------------------
176 
179  FwIndexType portNum,
180  Svc::InputSchedPort* port
181  )
182  {
183  FW_ASSERT(
184  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
185  static_cast<FwAssertArgType>(portNum)
186  );
187 
188  this->m_RateGroupMemberOut_OutputPort[portNum].addCallPort(port);
189  }
190 
191 #endif
192 
193 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
194 
195  // ----------------------------------------------------------------------
196  // Connect serial input ports to special output ports
197  // ----------------------------------------------------------------------
198 
201  FwIndexType portNum,
202  Fw::InputSerializePort* port
203  )
204  {
205  FW_ASSERT(
206  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
207  static_cast<FwAssertArgType>(portNum)
208  );
209 
210  this->m_Time_OutputPort[portNum].registerSerialPort(port);
211  }
212 
215  FwIndexType portNum,
216  Fw::InputSerializePort* port
217  )
218  {
219  FW_ASSERT(
220  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
221  static_cast<FwAssertArgType>(portNum)
222  );
223 
224  this->m_Tlm_OutputPort[portNum].registerSerialPort(port);
225  }
226 
227 #endif
228 
229 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
230 
231  // ----------------------------------------------------------------------
232  // Connect serial input ports to typed output ports
233  // ----------------------------------------------------------------------
234 
237  FwIndexType portNum,
238  Fw::InputSerializePort* port
239  )
240  {
241  FW_ASSERT(
242  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
243  static_cast<FwAssertArgType>(portNum)
244  );
245 
246  this->m_RateGroupMemberOut_OutputPort[portNum].registerSerialPort(port);
247  }
248 
249 #endif
250 
251  // ----------------------------------------------------------------------
252  // Component construction and destruction
253  // ----------------------------------------------------------------------
254 
256  PassiveRateGroupComponentBase(const char* compName) :
257  Fw::PassiveComponentBase(compName)
258  {
259 
260  }
261 
264  {
265 
266  }
267 
268 #if !FW_DIRECT_PORT_CALLS
269 
270  // ----------------------------------------------------------------------
271  // Connection status queries for special output ports
272  // ----------------------------------------------------------------------
273 
276  {
277  FW_ASSERT(
278  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
279  static_cast<FwAssertArgType>(portNum)
280  );
281 
282  return this->m_Time_OutputPort[portNum].isConnected();
283  }
284 
287  {
288  FW_ASSERT(
289  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
290  static_cast<FwAssertArgType>(portNum)
291  );
292 
293  return this->m_Tlm_OutputPort[portNum].isConnected();
294  }
295 
296 #endif
297 
298 #if !FW_DIRECT_PORT_CALLS
299 
300  // ----------------------------------------------------------------------
301  // Connection status queries for typed output ports
302  // ----------------------------------------------------------------------
303 
306  {
307  FW_ASSERT(
308  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
309  static_cast<FwAssertArgType>(portNum)
310  );
311 
312  return this->m_RateGroupMemberOut_OutputPort[portNum].isConnected();
313  }
314 
315 #endif
316 
317  // ----------------------------------------------------------------------
318  // Port handler base-class functions for typed input ports
319  //
320  // Call these functions directly to bypass the corresponding ports
321  // ----------------------------------------------------------------------
322 
325  FwIndexType portNum,
326  Os::RawTime& cycleStart
327  )
328  {
329  // Make sure port number is valid
330  FW_ASSERT(
331  (0 <= portNum) && (portNum < this->getNum_CycleIn_InputPorts()),
332  static_cast<FwAssertArgType>(portNum)
333  );
334 
335  // Call handler function
336  this->CycleIn_handler(
337  portNum,
338  cycleStart
339  );
340  }
341 
342 #if !FW_DIRECT_PORT_CALLS
343 
344  // ----------------------------------------------------------------------
345  // Invocation functions for typed output ports
346  // ----------------------------------------------------------------------
347 
350  FwIndexType portNum,
351  U32 context
352  ) const
353  {
354  FW_ASSERT(
355  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
356  static_cast<FwAssertArgType>(portNum)
357  );
358 
359  FW_ASSERT(
360  this->m_RateGroupMemberOut_OutputPort[portNum].isConnected(),
361  static_cast<FwAssertArgType>(portNum)
362  );
363  this->m_RateGroupMemberOut_OutputPort[portNum].invoke(
364  context
365  );
366  }
367 
368 #endif
369 
370  // ----------------------------------------------------------------------
371  // Telemetry serialized write
372  // ----------------------------------------------------------------------
373 
376  FwChanIdType id,
377  Fw::TlmBuffer& _tlmBuff,
378  Fw::Time _tlmTime
379  ) const
380  {
381  if (this->isConnected_Tlm_OutputPort(0)) {
382  if (
383  this->isConnected_Time_OutputPort(0) &&
384  (_tlmTime == Fw::ZERO_TIME)
385  ) {
386  this->Time_out(0, _tlmTime);
387  }
388 
389  FwChanIdType _id;
390  _id = this->getIdBase() + id;
391 
392  this->Tlm_out(
393  0,
394  _id,
395  _tlmTime,
396  _tlmBuff
397  );
398  }
399  }
400 
401  // ----------------------------------------------------------------------
402  // Telemetry write functions
403  // ----------------------------------------------------------------------
404 
407  U32 arg,
408  Fw::Time _tlmTime
409  )
410  {
411  // Check to see if it is the first time
412  if (not this->m_first_update_MaxCycleTime) {
413  // Check to see if value has changed. If not, don't write it.
414  if (arg == this->m_last_MaxCycleTime) {
415  return;
416  }
417  else {
418  this->m_last_MaxCycleTime = arg;
419  }
420  }
421  else {
422  this->m_first_update_MaxCycleTime = false;
423  this->m_last_MaxCycleTime = arg;
424  }
425 
426  if (this->isConnected_Tlm_OutputPort(0)) {
427  Fw::TlmBuffer _tlmBuff;
428  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
429  FW_ASSERT(
430  _stat == Fw::FW_SERIALIZE_OK,
431  static_cast<FwAssertArgType>(_stat)
432  );
433 
434  this->tlmWrite(
436  _tlmBuff,
437  _tlmTime
438  );
439  }
440  }
441 
444  U32 arg,
445  Fw::Time _tlmTime
446  ) const
447  {
448  if (this->isConnected_Tlm_OutputPort(0)) {
449  Fw::TlmBuffer _tlmBuff;
450  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
451  FW_ASSERT(
452  _stat == Fw::FW_SERIALIZE_OK,
453  static_cast<FwAssertArgType>(_stat)
454  );
455 
456  this->tlmWrite(
458  _tlmBuff,
459  _tlmTime
460  );
461  }
462  }
463 
466  U32 arg,
467  Fw::Time _tlmTime
468  ) const
469  {
470  if (this->isConnected_Tlm_OutputPort(0)) {
471  Fw::TlmBuffer _tlmBuff;
472  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
473  FW_ASSERT(
474  _stat == Fw::FW_SERIALIZE_OK,
475  static_cast<FwAssertArgType>(_stat)
476  );
477 
478  this->tlmWrite(
480  _tlmBuff,
481  _tlmTime
482  );
483  }
484  }
485 
486  // ----------------------------------------------------------------------
487  // Time
488  // ----------------------------------------------------------------------
489 
491  getTime() const
492  {
493  if (this->isConnected_Time_OutputPort(0)) {
494  Fw::Time _time;
495  this->Time_out(0, _time);
496  return _time;
497  }
498  else {
499  return Fw::Time(TimeBase::TB_NONE, 0, 0);
500  }
501  }
502 
503  // ----------------------------------------------------------------------
504  // Calls for messages received on typed input ports
505  // ----------------------------------------------------------------------
506 
507  void PassiveRateGroupComponentBase ::
508  m_p_CycleIn_in(
509  Fw::PassiveComponentBase* callComp,
510  FwIndexType portNum,
511  Os::RawTime& cycleStart
512  )
513  {
514  FW_ASSERT(callComp);
515  PassiveRateGroupComponentBase* compPtr = static_cast<PassiveRateGroupComponentBase*>(callComp);
516  compPtr->CycleIn_handlerBase(
517  portNum,
518  cycleStart
519  );
520  }
521 
522 #if !FW_DIRECT_PORT_CALLS
523 
524  // ----------------------------------------------------------------------
525  // Invocation functions for special output ports
526  // ----------------------------------------------------------------------
527 
528  void PassiveRateGroupComponentBase ::
529  Time_out(
530  FwIndexType portNum,
531  Fw::Time& time
532  ) const
533  {
534  FW_ASSERT(
535  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
536  static_cast<FwAssertArgType>(portNum)
537  );
538 
539  FW_ASSERT(
540  this->m_Time_OutputPort[portNum].isConnected(),
541  static_cast<FwAssertArgType>(portNum)
542  );
543  this->m_Time_OutputPort[portNum].invoke(
544  time
545  );
546  }
547 
548  void PassiveRateGroupComponentBase ::
549  Tlm_out(
550  FwIndexType portNum,
551  FwChanIdType id,
552  Fw::Time& timeTag,
553  Fw::TlmBuffer& val
554  ) const
555  {
556  FW_ASSERT(
557  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
558  static_cast<FwAssertArgType>(portNum)
559  );
560 
561  FW_ASSERT(
562  this->m_Tlm_OutputPort[portNum].isConnected(),
563  static_cast<FwAssertArgType>(portNum)
564  );
565  this->m_Tlm_OutputPort[portNum].invoke(
566  id,
567  timeTag,
568  val
569  );
570  }
571 
572 #endif
573 
574 }
Serialization/Deserialization operation was successful.
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:157
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CyclePortAc.cpp:79
I32 FwEnumStoreType
bool isConnected_RateGroupMemberOut_OutputPort(FwIndexType portNum) const
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:171
No time base has been established (Required)
void addCallPort(InputTlmPort *callPort)
Register an input port.
Definition: TlmPortAc.cpp:177
void RateGroupMemberOut_out(FwIndexType portNum, U32 context) const
Invoke output port RateGroupMemberOut.
void init()
Object initializer.
Definition: ObjBase.cpp:24
SerializeStatus
forward declaration for string
bool isConnected_Time_OutputPort(FwIndexType portNum) const
void init()
Initialization function.
Definition: TimePortAc.cpp:151
void invoke(U32 context) const
Invoke a port connection.
void invoke(Fw::Time &time) const
Invoke a port connection.
Definition: TimePortAc.cpp:170
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].
bool isConnected_Tlm_OutputPort(FwIndexType portNum) const
const char * toChar() const
Convert to a C-style char*.
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 connection.
Definition: TlmPortAc.cpp:190
bool isConnected() const
Definition: PortBase.cpp:38
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:39
void setPortNum(FwIndexType portNum)
void tlmWrite_MaxCycleTime(U32 arg, Fw::Time _tlmTime=Fw::Time())
void init()
Initialization function.
Definition: CyclePortAc.cpp:73
static constexpr FwIndexType getNum_Time_OutputPorts()
void tlmWrite_CycleCount(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
PlatformIndexType FwIndexType
void init()
Initialization function.
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.
void tlmWrite(FwChanIdType id, Fw::TlmBuffer &_tlmBuff, Fw::Time _tlmTime=Fw::Time()) const
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.