F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
ActiveRateGroupComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title ActiveRateGroupComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for ActiveRateGroup 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  namespace {
18  enum MsgTypeEnum {
19  ACTIVERATEGROUP_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
20  CYCLEIN_CYCLE,
21  PINGIN_PING,
22  };
23 
24  // Get the max size by constructing a union of the async input, command, and
25  // internal port serialization sizes
26  union BuffUnion {
29  };
30 
31  // Define a message buffer class large enough to handle all the
32  // asynchronous inputs to the component
33  class ComponentIpcSerializableBuffer :
35  {
36 
37  public:
38 
39  enum {
40  // Max. message size = size of data + message id + port
41  SERIALIZATION_SIZE =
42  sizeof(BuffUnion) +
43  sizeof(NATIVE_INT_TYPE) +
44  sizeof(NATIVE_INT_TYPE)
45  };
46 
47  NATIVE_UINT_TYPE getBuffCapacity() const {
48  return sizeof(m_buff);
49  }
50 
51  U8* getBuffAddr() {
52  return m_buff;
53  }
54 
55  const U8* getBuffAddr() const {
56  return m_buff;
57  }
58 
59  private:
60  // Should be the max of all the input ports serialized sizes...
61  U8 m_buff[SERIALIZATION_SIZE];
62 
63  };
64  }
65 
66  // ----------------------------------------------------------------------
67  // Component initialization
68  // ----------------------------------------------------------------------
69 
71  init(
72  NATIVE_INT_TYPE queueDepth,
73  NATIVE_INT_TYPE instance
74  )
75  {
76  // Initialize base class
78 
79  // Connect input port CycleIn
80  for (
81  PlatformIntType port = 0;
82  port < static_cast<PlatformIntType>(this->getNum_CycleIn_InputPorts());
83  port++
84  ) {
85  this->m_CycleIn_InputPort[port].init();
86  this->m_CycleIn_InputPort[port].addCallComp(
87  this,
88  m_p_CycleIn_in
89  );
90  this->m_CycleIn_InputPort[port].setPortNum(port);
91 
92 #if FW_OBJECT_NAMES == 1
93  // The port name consists of this->m_objName and some extra info.
94  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
95  // However, the compiler may assume that this->m_objName fills
96  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
97  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
98  // bytes to cover the extra info.
99  char portName[2*FW_OBJ_NAME_MAX_SIZE];
100  (void) snprintf(
101  portName,
102  sizeof(portName),
103  "%s_CycleIn_InputPort[%" PRI_PlatformIntType "]",
104  this->m_objName,
105  port
106  );
107  this->m_CycleIn_InputPort[port].setObjName(portName);
108 #endif
109  }
110 
111  // Connect input port PingIn
112  for (
113  PlatformIntType port = 0;
114  port < static_cast<PlatformIntType>(this->getNum_PingIn_InputPorts());
115  port++
116  ) {
117  this->m_PingIn_InputPort[port].init();
118  this->m_PingIn_InputPort[port].addCallComp(
119  this,
120  m_p_PingIn_in
121  );
122  this->m_PingIn_InputPort[port].setPortNum(port);
123 
124 #if FW_OBJECT_NAMES == 1
125  // The port name consists of this->m_objName and some extra info.
126  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
127  // However, the compiler may assume that this->m_objName fills
128  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
129  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
130  // bytes to cover the extra info.
131  char portName[2*FW_OBJ_NAME_MAX_SIZE];
132  (void) snprintf(
133  portName,
134  sizeof(portName),
135  "%s_PingIn_InputPort[%" PRI_PlatformIntType "]",
136  this->m_objName,
137  port
138  );
139  this->m_PingIn_InputPort[port].setObjName(portName);
140 #endif
141  }
142 
143  // Connect output port Log
144  for (
145  PlatformIntType port = 0;
146  port < static_cast<PlatformIntType>(this->getNum_Log_OutputPorts());
147  port++
148  ) {
149  this->m_Log_OutputPort[port].init();
150 
151 #if FW_OBJECT_NAMES == 1
152  // The port name consists of this->m_objName and some extra info.
153  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
154  // However, the compiler may assume that this->m_objName fills
155  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
156  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
157  // bytes to cover the extra info.
158  char portName[2*FW_OBJ_NAME_MAX_SIZE];
159  (void) snprintf(
160  portName,
161  sizeof(portName),
162  "%s_Log_OutputPort[%" PRI_PlatformIntType "]",
163  this->m_objName,
164  port
165  );
166  this->m_Log_OutputPort[port].setObjName(portName);
167 #endif
168  }
169 
170 #if FW_ENABLE_TEXT_LOGGING == 1
171  // Connect output port LogText
172  for (
173  PlatformIntType port = 0;
174  port < static_cast<PlatformIntType>(this->getNum_LogText_OutputPorts());
175  port++
176  ) {
177  this->m_LogText_OutputPort[port].init();
178 
179 #if FW_OBJECT_NAMES == 1
180  // The port name consists of this->m_objName and some extra info.
181  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
182  // However, the compiler may assume that this->m_objName fills
183  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
184  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
185  // bytes to cover the extra info.
186  char portName[2*FW_OBJ_NAME_MAX_SIZE];
187  (void) snprintf(
188  portName,
189  sizeof(portName),
190  "%s_LogText_OutputPort[%" PRI_PlatformIntType "]",
191  this->m_objName,
192  port
193  );
194  this->m_LogText_OutputPort[port].setObjName(portName);
195 #endif
196  }
197 #endif
198 
199  // Connect output port Time
200  for (
201  PlatformIntType port = 0;
202  port < static_cast<PlatformIntType>(this->getNum_Time_OutputPorts());
203  port++
204  ) {
205  this->m_Time_OutputPort[port].init();
206 
207 #if FW_OBJECT_NAMES == 1
208  // The port name consists of this->m_objName and some extra info.
209  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
210  // However, the compiler may assume that this->m_objName fills
211  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
212  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
213  // bytes to cover the extra info.
214  char portName[2*FW_OBJ_NAME_MAX_SIZE];
215  (void) snprintf(
216  portName,
217  sizeof(portName),
218  "%s_Time_OutputPort[%" PRI_PlatformIntType "]",
219  this->m_objName,
220  port
221  );
222  this->m_Time_OutputPort[port].setObjName(portName);
223 #endif
224  }
225 
226  // Connect output port Tlm
227  for (
228  PlatformIntType port = 0;
229  port < static_cast<PlatformIntType>(this->getNum_Tlm_OutputPorts());
230  port++
231  ) {
232  this->m_Tlm_OutputPort[port].init();
233 
234 #if FW_OBJECT_NAMES == 1
235  // The port name consists of this->m_objName and some extra info.
236  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
237  // However, the compiler may assume that this->m_objName fills
238  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
239  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
240  // bytes to cover the extra info.
241  char portName[2*FW_OBJ_NAME_MAX_SIZE];
242  (void) snprintf(
243  portName,
244  sizeof(portName),
245  "%s_Tlm_OutputPort[%" PRI_PlatformIntType "]",
246  this->m_objName,
247  port
248  );
249  this->m_Tlm_OutputPort[port].setObjName(portName);
250 #endif
251  }
252 
253  // Connect output port PingOut
254  for (
255  PlatformIntType port = 0;
256  port < static_cast<PlatformIntType>(this->getNum_PingOut_OutputPorts());
257  port++
258  ) {
259  this->m_PingOut_OutputPort[port].init();
260 
261 #if FW_OBJECT_NAMES == 1
262  // The port name consists of this->m_objName and some extra info.
263  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
264  // However, the compiler may assume that this->m_objName fills
265  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
266  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
267  // bytes to cover the extra info.
268  char portName[2*FW_OBJ_NAME_MAX_SIZE];
269  (void) snprintf(
270  portName,
271  sizeof(portName),
272  "%s_PingOut_OutputPort[%" PRI_PlatformIntType "]",
273  this->m_objName,
274  port
275  );
276  this->m_PingOut_OutputPort[port].setObjName(portName);
277 #endif
278  }
279 
280  // Connect output port RateGroupMemberOut
281  for (
282  PlatformIntType port = 0;
283  port < static_cast<PlatformIntType>(this->getNum_RateGroupMemberOut_OutputPorts());
284  port++
285  ) {
286  this->m_RateGroupMemberOut_OutputPort[port].init();
287 
288 #if FW_OBJECT_NAMES == 1
289  // The port name consists of this->m_objName and some extra info.
290  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
291  // However, the compiler may assume that this->m_objName fills
292  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
293  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
294  // bytes to cover the extra info.
295  char portName[2*FW_OBJ_NAME_MAX_SIZE];
296  (void) snprintf(
297  portName,
298  sizeof(portName),
299  "%s_RateGroupMemberOut_OutputPort[%" PRI_PlatformIntType "]",
300  this->m_objName,
301  port
302  );
303  this->m_RateGroupMemberOut_OutputPort[port].setObjName(portName);
304 #endif
305  }
306 
307  Os::Queue::QueueStatus qStat = this->createQueue(
308  queueDepth,
309  ComponentIpcSerializableBuffer::SERIALIZATION_SIZE
310  );
311  FW_ASSERT(
312  Os::Queue::QUEUE_OK == qStat,
313  static_cast<FwAssertArgType>(qStat)
314  );
315  }
316 
317  // ----------------------------------------------------------------------
318  // Getters for typed input ports
319  // ----------------------------------------------------------------------
320 
323  {
324  FW_ASSERT(
325  portNum < this->getNum_CycleIn_InputPorts(),
326  static_cast<FwAssertArgType>(portNum)
327  );
328 
329  return &this->m_CycleIn_InputPort[portNum];
330  }
331 
334  {
335  FW_ASSERT(
336  portNum < this->getNum_PingIn_InputPorts(),
337  static_cast<FwAssertArgType>(portNum)
338  );
339 
340  return &this->m_PingIn_InputPort[portNum];
341  }
342 
343  // ----------------------------------------------------------------------
344  // Connect input ports to special output ports
345  // ----------------------------------------------------------------------
346 
349  NATIVE_INT_TYPE portNum,
350  Fw::InputLogPort* port
351  )
352  {
353  FW_ASSERT(
354  portNum < this->getNum_Log_OutputPorts(),
355  static_cast<FwAssertArgType>(portNum)
356  );
357 
358  this->m_Log_OutputPort[portNum].addCallPort(port);
359  }
360 
361 #if FW_ENABLE_TEXT_LOGGING == 1
362 
363  void ActiveRateGroupComponentBase ::
364  set_LogText_OutputPort(
365  NATIVE_INT_TYPE portNum,
367  )
368  {
369  FW_ASSERT(
370  portNum < this->getNum_LogText_OutputPorts(),
371  static_cast<FwAssertArgType>(portNum)
372  );
373 
374  this->m_LogText_OutputPort[portNum].addCallPort(port);
375  }
376 
377 #endif
378 
381  NATIVE_INT_TYPE portNum,
382  Fw::InputTimePort* port
383  )
384  {
385  FW_ASSERT(
386  portNum < this->getNum_Time_OutputPorts(),
387  static_cast<FwAssertArgType>(portNum)
388  );
389 
390  this->m_Time_OutputPort[portNum].addCallPort(port);
391  }
392 
395  NATIVE_INT_TYPE portNum,
396  Fw::InputTlmPort* port
397  )
398  {
399  FW_ASSERT(
400  portNum < this->getNum_Tlm_OutputPorts(),
401  static_cast<FwAssertArgType>(portNum)
402  );
403 
404  this->m_Tlm_OutputPort[portNum].addCallPort(port);
405  }
406 
407  // ----------------------------------------------------------------------
408  // Connect typed input ports to typed output ports
409  // ----------------------------------------------------------------------
410 
413  NATIVE_INT_TYPE portNum,
414  Svc::InputPingPort* port
415  )
416  {
417  FW_ASSERT(
418  portNum < this->getNum_PingOut_OutputPorts(),
419  static_cast<FwAssertArgType>(portNum)
420  );
421 
422  this->m_PingOut_OutputPort[portNum].addCallPort(port);
423  }
424 
427  NATIVE_INT_TYPE portNum,
428  Svc::InputSchedPort* port
429  )
430  {
431  FW_ASSERT(
432  portNum < this->getNum_RateGroupMemberOut_OutputPorts(),
433  static_cast<FwAssertArgType>(portNum)
434  );
435 
436  this->m_RateGroupMemberOut_OutputPort[portNum].addCallPort(port);
437  }
438 
439 #if FW_PORT_SERIALIZATION
440 
441  // ----------------------------------------------------------------------
442  // Connect serial input ports to special output ports
443  // ----------------------------------------------------------------------
444 
447  NATIVE_INT_TYPE portNum,
448  Fw::InputSerializePort* port
449  )
450  {
451  FW_ASSERT(
452  portNum < this->getNum_Log_OutputPorts(),
453  static_cast<FwAssertArgType>(portNum)
454  );
455 
456  this->m_Log_OutputPort[portNum].registerSerialPort(port);
457  }
458 
459 #if FW_ENABLE_TEXT_LOGGING == 1
460 
461  void ActiveRateGroupComponentBase ::
462  set_LogText_OutputPort(
463  NATIVE_INT_TYPE portNum,
464  Fw::InputSerializePort* port
465  )
466  {
467  FW_ASSERT(
468  portNum < this->getNum_LogText_OutputPorts(),
469  static_cast<FwAssertArgType>(portNum)
470  );
471 
472  this->m_LogText_OutputPort[portNum].registerSerialPort(port);
473  }
474 
475 #endif
476 
479  NATIVE_INT_TYPE portNum,
480  Fw::InputSerializePort* port
481  )
482  {
483  FW_ASSERT(
484  portNum < this->getNum_Time_OutputPorts(),
485  static_cast<FwAssertArgType>(portNum)
486  );
487 
488  this->m_Time_OutputPort[portNum].registerSerialPort(port);
489  }
490 
493  NATIVE_INT_TYPE portNum,
494  Fw::InputSerializePort* port
495  )
496  {
497  FW_ASSERT(
498  portNum < this->getNum_Tlm_OutputPorts(),
499  static_cast<FwAssertArgType>(portNum)
500  );
501 
502  this->m_Tlm_OutputPort[portNum].registerSerialPort(port);
503  }
504 
505 #endif
506 
507 #if FW_PORT_SERIALIZATION
508 
509  // ----------------------------------------------------------------------
510  // Connect serial input ports to typed output ports
511  // ----------------------------------------------------------------------
512 
515  NATIVE_INT_TYPE portNum,
516  Fw::InputSerializePort* port
517  )
518  {
519  FW_ASSERT(
520  portNum < this->getNum_PingOut_OutputPorts(),
521  static_cast<FwAssertArgType>(portNum)
522  );
523 
524  this->m_PingOut_OutputPort[portNum].registerSerialPort(port);
525  }
526 
529  NATIVE_INT_TYPE portNum,
530  Fw::InputSerializePort* port
531  )
532  {
533  FW_ASSERT(
534  portNum < this->getNum_RateGroupMemberOut_OutputPorts(),
535  static_cast<FwAssertArgType>(portNum)
536  );
537 
538  this->m_RateGroupMemberOut_OutputPort[portNum].registerSerialPort(port);
539  }
540 
541 #endif
542 
543  // ----------------------------------------------------------------------
544  // Component construction and destruction
545  // ----------------------------------------------------------------------
546 
548  ActiveRateGroupComponentBase(const char* compName) :
549  Fw::ActiveComponentBase(compName)
550  {
551  // Write telemetry channel RgMaxTime
552  this->m_first_update_RgMaxTime = true;
553  this->m_last_RgMaxTime = 0;
554 
555  // Write telemetry channel RgCycleSlips
556  this->m_first_update_RgCycleSlips = true;
557  this->m_last_RgCycleSlips = 0;
558  }
559 
562  {
563 
564  }
565 
566  // ----------------------------------------------------------------------
567  // Getters for numbers of typed input ports
568  // ----------------------------------------------------------------------
569 
572  {
573  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_CycleIn_InputPort));
574  }
575 
578  {
579  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_PingIn_InputPort));
580  }
581 
582  // ----------------------------------------------------------------------
583  // Getters for numbers of special output ports
584  // ----------------------------------------------------------------------
585 
588  {
589  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Log_OutputPort));
590  }
591 
592 #if FW_ENABLE_TEXT_LOGGING == 1
593 
594  NATIVE_INT_TYPE ActiveRateGroupComponentBase ::
595  getNum_LogText_OutputPorts() const
596  {
597  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_LogText_OutputPort));
598  }
599 
600 #endif
601 
604  {
605  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Time_OutputPort));
606  }
607 
610  {
611  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Tlm_OutputPort));
612  }
613 
614  // ----------------------------------------------------------------------
615  // Getters for numbers of typed output ports
616  // ----------------------------------------------------------------------
617 
620  {
621  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_PingOut_OutputPort));
622  }
623 
626  {
627  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_RateGroupMemberOut_OutputPort));
628  }
629 
630  // ----------------------------------------------------------------------
631  // Connection status queries for special output ports
632  // ----------------------------------------------------------------------
633 
636  {
637  FW_ASSERT(
638  portNum < this->getNum_Log_OutputPorts(),
639  static_cast<FwAssertArgType>(portNum)
640  );
641 
642  return this->m_Log_OutputPort[portNum].isConnected();
643  }
644 
645 #if FW_ENABLE_TEXT_LOGGING == 1
646 
647  bool ActiveRateGroupComponentBase ::
648  isConnected_LogText_OutputPort(NATIVE_INT_TYPE portNum)
649  {
650  FW_ASSERT(
651  portNum < this->getNum_LogText_OutputPorts(),
652  static_cast<FwAssertArgType>(portNum)
653  );
654 
655  return this->m_LogText_OutputPort[portNum].isConnected();
656  }
657 
658 #endif
659 
662  {
663  FW_ASSERT(
664  portNum < this->getNum_Time_OutputPorts(),
665  static_cast<FwAssertArgType>(portNum)
666  );
667 
668  return this->m_Time_OutputPort[portNum].isConnected();
669  }
670 
673  {
674  FW_ASSERT(
675  portNum < this->getNum_Tlm_OutputPorts(),
676  static_cast<FwAssertArgType>(portNum)
677  );
678 
679  return this->m_Tlm_OutputPort[portNum].isConnected();
680  }
681 
682  // ----------------------------------------------------------------------
683  // Connection status queries for typed output ports
684  // ----------------------------------------------------------------------
685 
688  {
689  FW_ASSERT(
690  portNum < this->getNum_PingOut_OutputPorts(),
691  static_cast<FwAssertArgType>(portNum)
692  );
693 
694  return this->m_PingOut_OutputPort[portNum].isConnected();
695  }
696 
699  {
700  FW_ASSERT(
701  portNum < this->getNum_RateGroupMemberOut_OutputPorts(),
702  static_cast<FwAssertArgType>(portNum)
703  );
704 
705  return this->m_RateGroupMemberOut_OutputPort[portNum].isConnected();
706  }
707 
708  // ----------------------------------------------------------------------
709  // Port handler base-class functions for typed input ports
710  //
711  // Call these functions directly to bypass the corresponding ports
712  // ----------------------------------------------------------------------
713 
716  NATIVE_INT_TYPE portNum,
717  Svc::TimerVal& cycleStart
718  )
719  {
720  // Make sure port number is valid
721  FW_ASSERT(
722  portNum < this->getNum_CycleIn_InputPorts(),
723  static_cast<FwAssertArgType>(portNum)
724  );
725 
726  // Call pre-message hook
728  portNum,
729  cycleStart
730  );
731  ComponentIpcSerializableBuffer msg;
733 
734  // Serialize message ID
735  _status = msg.serialize(
736  static_cast<NATIVE_INT_TYPE>(CYCLEIN_CYCLE)
737  );
738  FW_ASSERT(
739  _status == Fw::FW_SERIALIZE_OK,
740  static_cast<FwAssertArgType>(_status)
741  );
742 
743  // Serialize port number
744  _status = msg.serialize(portNum);
745  FW_ASSERT(
746  _status == Fw::FW_SERIALIZE_OK,
747  static_cast<FwAssertArgType>(_status)
748  );
749 
750  // Serialize argument cycleStart
751  _status = msg.serialize(cycleStart);
752  FW_ASSERT(
753  _status == Fw::FW_SERIALIZE_OK,
754  static_cast<FwAssertArgType>(_status)
755  );
756 
757  // Send message
759  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
760 
761  if (qStatus == Os::Queue::QUEUE_FULL) {
762  this->incNumMsgDropped();
763  return;
764  }
765 
766  FW_ASSERT(
767  qStatus == Os::Queue::QUEUE_OK,
768  static_cast<FwAssertArgType>(qStatus)
769  );
770  }
771 
774  NATIVE_INT_TYPE portNum,
775  U32 key
776  )
777  {
778  // Make sure port number is valid
779  FW_ASSERT(
780  portNum < this->getNum_PingIn_InputPorts(),
781  static_cast<FwAssertArgType>(portNum)
782  );
783 
784  // Call pre-message hook
786  portNum,
787  key
788  );
789  ComponentIpcSerializableBuffer msg;
791 
792  // Serialize message ID
793  _status = msg.serialize(
794  static_cast<NATIVE_INT_TYPE>(PINGIN_PING)
795  );
796  FW_ASSERT(
797  _status == Fw::FW_SERIALIZE_OK,
798  static_cast<FwAssertArgType>(_status)
799  );
800 
801  // Serialize port number
802  _status = msg.serialize(portNum);
803  FW_ASSERT(
804  _status == Fw::FW_SERIALIZE_OK,
805  static_cast<FwAssertArgType>(_status)
806  );
807 
808  // Serialize argument key
809  _status = msg.serialize(key);
810  FW_ASSERT(
811  _status == Fw::FW_SERIALIZE_OK,
812  static_cast<FwAssertArgType>(_status)
813  );
814 
815  // Send message
817  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
818 
819  FW_ASSERT(
820  qStatus == Os::Queue::QUEUE_OK,
821  static_cast<FwAssertArgType>(qStatus)
822  );
823  }
824 
825  // ----------------------------------------------------------------------
826  // Pre-message hooks for typed async input ports
827  //
828  // Each of these functions is invoked just before processing a message
829  // on the corresponding port. By default, they do nothing. You can
830  // override them to provide specific pre-message behavior.
831  // ----------------------------------------------------------------------
832 
835  NATIVE_INT_TYPE portNum,
836  Svc::TimerVal& cycleStart
837  )
838  {
839  // Default: no-op
840  }
841 
844  NATIVE_INT_TYPE portNum,
845  U32 key
846  )
847  {
848  // Default: no-op
849  }
850 
851  // ----------------------------------------------------------------------
852  // Invocation functions for typed output ports
853  // ----------------------------------------------------------------------
854 
857  NATIVE_INT_TYPE portNum,
858  U32 key
859  )
860  {
861  FW_ASSERT(
862  portNum < this->getNum_PingOut_OutputPorts(),
863  static_cast<FwAssertArgType>(portNum)
864  );
865  this->m_PingOut_OutputPort[portNum].invoke(
866  key
867  );
868  }
869 
872  NATIVE_INT_TYPE portNum,
873  NATIVE_UINT_TYPE context
874  )
875  {
876  FW_ASSERT(
877  portNum < this->getNum_RateGroupMemberOut_OutputPorts(),
878  static_cast<FwAssertArgType>(portNum)
879  );
880  this->m_RateGroupMemberOut_OutputPort[portNum].invoke(
881  context
882  );
883  }
884 
885  // ----------------------------------------------------------------------
886  // Event logging functions
887  // ----------------------------------------------------------------------
888 
891  {
892  // Get the time
893  Fw::Time _logTime;
894  if (this->m_Time_OutputPort[0].isConnected()) {
895  this->m_Time_OutputPort[0].invoke(_logTime);
896  }
897 
898  FwEventIdType _id = static_cast<FwEventIdType>(0);
899 
900  _id = this->getIdBase() + EVENTID_RATEGROUPSTARTED;
901 
902  // Emit the event on the log port
903  if (this->m_Log_OutputPort[0].isConnected()) {
904  Fw::LogBuffer _logBuff;
905 
906 #if FW_AMPCS_COMPATIBLE
908  // Serialize the number of arguments
909  _status = _logBuff.serialize(static_cast<U8>(0));
910  FW_ASSERT(
911  _status == Fw::FW_SERIALIZE_OK,
912  static_cast<FwAssertArgType>(_status)
913  );
914 #endif
915 
916  this->m_Log_OutputPort[0].invoke(
917  _id,
918  _logTime,
920  _logBuff
921  );
922  }
923 
924  // Emit the event on the text log port
925 #if FW_ENABLE_TEXT_LOGGING
926  if (this->m_LogText_OutputPort[0].isConnected()) {
927 #if FW_OBJECT_NAMES == 1
928  const char* _formatString =
929  "(%s) %s: Rate group started.";
930 #else
931  const char* _formatString =
932  "%s: Rate group started.";
933 #endif
934 
935  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
936 
937  (void) snprintf(
938  _textBuffer,
940  _formatString,
941 #if FW_OBJECT_NAMES == 1
942  this->m_objName,
943 #endif
944  "RateGroupStarted "
945  );
946 
947  // Null terminate
948  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
949  Fw::TextLogString _logString = _textBuffer;
950  this->m_LogText_OutputPort[0].invoke(
951  _id,
952  _logTime,
954  _logString
955  );
956  }
957 #endif
958  }
959 
962  {
963  // Get the time
964  Fw::Time _logTime;
965  if (this->m_Time_OutputPort[0].isConnected()) {
966  this->m_Time_OutputPort[0].invoke(_logTime);
967  }
968 
969  FwEventIdType _id = static_cast<FwEventIdType>(0);
970 
971  _id = this->getIdBase() + EVENTID_RATEGROUPCYCLESLIP;
972 
973  // Emit the event on the log port
974  if (this->m_Log_OutputPort[0].isConnected()) {
975  Fw::LogBuffer _logBuff;
977 
978 #if FW_AMPCS_COMPATIBLE
979  // Serialize the number of arguments
980  _status = _logBuff.serialize(static_cast<U8>(1));
981  FW_ASSERT(
982  _status == Fw::FW_SERIALIZE_OK,
983  static_cast<FwAssertArgType>(_status)
984  );
985 #endif
986 
987 #if FW_AMPCS_COMPATIBLE
988  // Serialize the argument size
989  _status = _logBuff.serialize(
990  static_cast<U8>(sizeof(U32))
991  );
992  FW_ASSERT(
993  _status == Fw::FW_SERIALIZE_OK,
994  static_cast<FwAssertArgType>(_status)
995  );
996 #endif
997  _status = _logBuff.serialize(cycle);
998  FW_ASSERT(
999  _status == Fw::FW_SERIALIZE_OK,
1000  static_cast<FwAssertArgType>(_status)
1001  );
1002 
1003  this->m_Log_OutputPort[0].invoke(
1004  _id,
1005  _logTime,
1007  _logBuff
1008  );
1009  }
1010 
1011  // Emit the event on the text log port
1012 #if FW_ENABLE_TEXT_LOGGING
1013  if (this->m_LogText_OutputPort[0].isConnected()) {
1014 #if FW_OBJECT_NAMES == 1
1015  const char* _formatString =
1016  "(%s) %s: Rate group cycle slipped on cycle %" PRIu32 "";
1017 #else
1018  const char* _formatString =
1019  "%s: Rate group cycle slipped on cycle %" PRIu32 "";
1020 #endif
1021 
1022  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1023 
1024  (void) snprintf(
1025  _textBuffer,
1027  _formatString,
1028 #if FW_OBJECT_NAMES == 1
1029  this->m_objName,
1030 #endif
1031  "RateGroupCycleSlip ",
1032  cycle
1033  );
1034 
1035  // Null terminate
1036  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1037  Fw::TextLogString _logString = _textBuffer;
1038  this->m_LogText_OutputPort[0].invoke(
1039  _id,
1040  _logTime,
1042  _logString
1043  );
1044  }
1045 #endif
1046  }
1047 
1048  // ----------------------------------------------------------------------
1049  // Telemetry write functions
1050  // ----------------------------------------------------------------------
1051 
1054  U32 arg,
1055  Fw::Time _tlmTime
1056  )
1057  {
1058  // Check to see if it is the first time
1059  if (not this->m_first_update_RgMaxTime) {
1060  // Check to see if value has changed. If not, don't write it.
1061  if (arg == this->m_last_RgMaxTime) {
1062  return;
1063  }
1064  else {
1065  this->m_last_RgMaxTime = arg;
1066  }
1067  }
1068  else {
1069  this->m_first_update_RgMaxTime = false;
1070  this->m_last_RgMaxTime = arg;
1071  }
1072 
1073  if (this->m_Tlm_OutputPort[0].isConnected()) {
1074  if (
1075  this->m_Time_OutputPort[0].isConnected() &&
1076  (_tlmTime == Fw::ZERO_TIME)
1077  ) {
1078  this->m_Time_OutputPort[0].invoke(_tlmTime);
1079  }
1080 
1081  Fw::TlmBuffer _tlmBuff;
1082  Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
1083  FW_ASSERT(
1084  _stat == Fw::FW_SERIALIZE_OK,
1085  static_cast<FwAssertArgType>(_stat)
1086  );
1087 
1088  FwChanIdType _id;
1089 
1090  _id = this->getIdBase() + CHANNELID_RGMAXTIME;
1091 
1092  this->m_Tlm_OutputPort[0].invoke(
1093  _id,
1094  _tlmTime,
1095  _tlmBuff
1096  );
1097  }
1098  }
1099 
1102  U32 arg,
1103  Fw::Time _tlmTime
1104  )
1105  {
1106  // Check to see if it is the first time
1107  if (not this->m_first_update_RgCycleSlips) {
1108  // Check to see if value has changed. If not, don't write it.
1109  if (arg == this->m_last_RgCycleSlips) {
1110  return;
1111  }
1112  else {
1113  this->m_last_RgCycleSlips = arg;
1114  }
1115  }
1116  else {
1117  this->m_first_update_RgCycleSlips = false;
1118  this->m_last_RgCycleSlips = arg;
1119  }
1120 
1121  if (this->m_Tlm_OutputPort[0].isConnected()) {
1122  if (
1123  this->m_Time_OutputPort[0].isConnected() &&
1124  (_tlmTime == Fw::ZERO_TIME)
1125  ) {
1126  this->m_Time_OutputPort[0].invoke(_tlmTime);
1127  }
1128 
1129  Fw::TlmBuffer _tlmBuff;
1130  Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
1131  FW_ASSERT(
1132  _stat == Fw::FW_SERIALIZE_OK,
1133  static_cast<FwAssertArgType>(_stat)
1134  );
1135 
1136  FwChanIdType _id;
1137 
1138  _id = this->getIdBase() + CHANNELID_RGCYCLESLIPS;
1139 
1140  this->m_Tlm_OutputPort[0].invoke(
1141  _id,
1142  _tlmTime,
1143  _tlmBuff
1144  );
1145  }
1146  }
1147 
1148  // ----------------------------------------------------------------------
1149  // Time
1150  // ----------------------------------------------------------------------
1151 
1153  getTime()
1154  {
1155  if (this->m_Time_OutputPort[0].isConnected()) {
1156  Fw::Time _time;
1157  this->m_Time_OutputPort[0].invoke(_time);
1158  return _time;
1159  }
1160  else {
1161  return Fw::Time(TB_NONE, 0, 0);
1162  }
1163  }
1164 
1165  // ----------------------------------------------------------------------
1166  // Message dispatch functions
1167  // ----------------------------------------------------------------------
1168 
1169  Fw::QueuedComponentBase::MsgDispatchStatus ActiveRateGroupComponentBase ::
1170  doDispatch()
1171  {
1172  ComponentIpcSerializableBuffer msg;
1173  NATIVE_INT_TYPE priority = 0;
1174 
1175  Os::Queue::QueueStatus msgStatus = this->m_queue.receive(
1176  msg,
1177  priority,
1179  );
1180  FW_ASSERT(
1181  msgStatus == Os::Queue::QUEUE_OK,
1182  static_cast<FwAssertArgType>(msgStatus)
1183  );
1184 
1185  // Reset to beginning of buffer
1186  msg.resetDeser();
1187 
1188  NATIVE_INT_TYPE desMsg = 0;
1189  Fw::SerializeStatus deserStatus = msg.deserialize(desMsg);
1190  FW_ASSERT(
1191  deserStatus == Fw::FW_SERIALIZE_OK,
1192  static_cast<FwAssertArgType>(deserStatus)
1193  );
1194 
1195  MsgTypeEnum msgType = static_cast<MsgTypeEnum>(desMsg);
1196 
1197  if (msgType == ACTIVERATEGROUP_COMPONENT_EXIT) {
1198  return MSG_DISPATCH_EXIT;
1199  }
1200 
1201  NATIVE_INT_TYPE portNum = 0;
1202  deserStatus = msg.deserialize(portNum);
1203  FW_ASSERT(
1204  deserStatus == Fw::FW_SERIALIZE_OK,
1205  static_cast<FwAssertArgType>(deserStatus)
1206  );
1207 
1208  switch (msgType) {
1209  // Handle async input port CycleIn
1210  case CYCLEIN_CYCLE: {
1211  // Deserialize argument cycleStart
1212  Svc::TimerVal cycleStart;
1213  deserStatus = msg.deserialize(cycleStart);
1214  FW_ASSERT(
1215  deserStatus == Fw::FW_SERIALIZE_OK,
1216  static_cast<FwAssertArgType>(deserStatus)
1217  );
1218  // Call handler function
1219  this->CycleIn_handler(
1220  portNum,
1221  cycleStart
1222  );
1223 
1224  break;
1225  }
1226 
1227  // Handle async input port PingIn
1228  case PINGIN_PING: {
1229  // Deserialize argument key
1230  U32 key;
1231  deserStatus = msg.deserialize(key);
1232  FW_ASSERT(
1233  deserStatus == Fw::FW_SERIALIZE_OK,
1234  static_cast<FwAssertArgType>(deserStatus)
1235  );
1236  // Call handler function
1237  this->PingIn_handler(
1238  portNum,
1239  key
1240  );
1241 
1242  break;
1243  }
1244 
1245  default:
1246  return MSG_DISPATCH_ERROR;
1247  }
1248 
1249  return MSG_DISPATCH_OK;
1250  }
1251 
1252  // ----------------------------------------------------------------------
1253  // Calls for messages received on typed input ports
1254  // ----------------------------------------------------------------------
1255 
1256  void ActiveRateGroupComponentBase ::
1257  m_p_CycleIn_in(
1258  Fw::PassiveComponentBase* callComp,
1259  NATIVE_INT_TYPE portNum,
1260  Svc::TimerVal& cycleStart
1261  )
1262  {
1263  FW_ASSERT(callComp);
1264  ActiveRateGroupComponentBase* compPtr = static_cast<ActiveRateGroupComponentBase*>(callComp);
1265  compPtr->CycleIn_handlerBase(
1266  portNum,
1267  cycleStart
1268  );
1269  }
1270 
1271  void ActiveRateGroupComponentBase ::
1272  m_p_PingIn_in(
1273  Fw::PassiveComponentBase* callComp,
1274  NATIVE_INT_TYPE portNum,
1275  U32 key
1276  )
1277  {
1278  FW_ASSERT(callComp);
1279  ActiveRateGroupComponentBase* compPtr = static_cast<ActiveRateGroupComponentBase*>(callComp);
1280  compPtr->PingIn_handlerBase(
1281  portNum,
1282  key
1283  );
1284  }
1285 
1286 }
#define FW_ASSERT(...)
Definition: Assert.hpp:14
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:51
U8 BYTE
byte type
Definition: BasicTypes.h:27
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:26
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:66
PlatformUIntType NATIVE_UINT_TYPE
Definition: BasicTypes.h:52
BYTE PingInPortSize[Svc::InputPingPort::SERIALIZED_SIZE]
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
U32 FwEventIdType
Definition: FpConfig.h:62
#define FW_LOG_TEXT_BUFFER_SIZE
Max size of string for text log message.
Definition: FpConfig.h:299
#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
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects)
Definition: FpConfig.h:88
@ ACTIVE_COMPONENT_EXIT
message to exit active component task
void setPortNum(NATIVE_INT_TYPE portNum)
@ WARNING_HI
A serious but recoverable event.
@ DIAGNOSTIC
Software diagnostic events.
void init()
Object initializer.
Definition: ObjBase.cpp:27
void init()
Initialization function.
Definition: LogPortAc.cpp:151
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args)
Invoke a port interface.
Definition: LogPortAc.cpp:170
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:157
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
Os::Queue::QueueStatus createQueue(NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize)
Os::Queue m_queue
queue object for active component
void incNumMsgDropped()
increment the number of messages dropped
@ MSG_DISPATCH_OK
Dispatch was normal.
@ MSG_DISPATCH_EXIT
A message was sent requesting an exit of the loop.
@ MSG_DISPATCH_ERROR
Errors dispatching messages.
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
Definition: Time.hpp:9
QueueStatus
Definition: Queue.hpp:27
@ QUEUE_OK
message sent/received okay
Definition: Queue.hpp:28
@ QUEUE_FULL
queue was full when attempting to send a message
Definition: Queue.hpp:36
QueueStatus send(const Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE priority, QueueBlocking block)
send a message
Definition: QueueCommon.cpp:13
QueueStatus receive(Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE &priority, QueueBlocking block)
receive a message
Definition: QueueCommon.cpp:22
QueueBlocking
Definition: Queue.hpp:40
@ QUEUE_BLOCKING
Queue receive blocks until a message arrives.
Definition: Queue.hpp:41
@ QUEUE_NONBLOCKING
Queue receive always returns even if there is no message.
Definition: Queue.hpp:42
void set_PingOut_OutputPort(NATIVE_INT_TYPE portNum, Svc::InputPingPort *port)
Connect port to PingOut[portNum].
void tlmWrite_RgMaxTime(U32 arg, Fw::Time _tlmTime=Fw::Time())
void PingIn_handlerBase(NATIVE_INT_TYPE portNum, U32 key)
Handler base-class function for input port PingIn.
void tlmWrite_RgCycleSlips(U32 arg, Fw::Time _tlmTime=Fw::Time())
virtual void CycleIn_preMsgHook(NATIVE_INT_TYPE portNum, Svc::TimerVal &cycleStart)
Pre-message hook for async input port CycleIn.
virtual void PingIn_preMsgHook(NATIVE_INT_TYPE portNum, U32 key)
Pre-message hook for async input port PingIn.
void set_Time_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
virtual ~ActiveRateGroupComponentBase()
Destroy ActiveRateGroupComponentBase object.
void RateGroupMemberOut_out(NATIVE_INT_TYPE portNum, NATIVE_UINT_TYPE context)
Invoke output port RateGroupMemberOut.
ActiveRateGroupComponentBase(const char *compName="")
Construct ActiveRateGroupComponentBase object.
virtual void PingIn_handler(NATIVE_INT_TYPE portNum, U32 key)=0
Handler for input port PingIn.
void set_RateGroupMemberOut_OutputPort(NATIVE_INT_TYPE portNum, Svc::InputSchedPort *port)
Connect port to RateGroupMemberOut[portNum].
bool isConnected_PingOut_OutputPort(NATIVE_INT_TYPE portNum)
@ EVENTID_RATEGROUPSTARTED
Informational event that rate group has started.
@ EVENTID_RATEGROUPCYCLESLIP
Warning event that rate group has had a cycle slip.
Svc::InputCyclePort * get_CycleIn_InputPort(NATIVE_INT_TYPE portNum)
void PingOut_out(NATIVE_INT_TYPE portNum, U32 key)
Invoke output port PingOut.
bool isConnected_Time_OutputPort(NATIVE_INT_TYPE portNum)
virtual void CycleIn_handler(NATIVE_INT_TYPE portNum, Svc::TimerVal &cycleStart)=0
Handler for input port CycleIn.
bool isConnected_RateGroupMemberOut_OutputPort(NATIVE_INT_TYPE portNum)
void set_Tlm_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputTlmPort *port)
Connect port to Tlm[portNum].
bool isConnected_Tlm_OutputPort(NATIVE_INT_TYPE portNum)
Svc::InputPingPort * get_PingIn_InputPort(NATIVE_INT_TYPE portNum)
void CycleIn_handlerBase(NATIVE_INT_TYPE portNum, Svc::TimerVal &cycleStart)
Handler base-class function for input port CycleIn.
void set_Log_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputLogPort *port)
Connect port to Log[portNum].
bool isConnected_Log_OutputPort(NATIVE_INT_TYPE portNum)
NATIVE_INT_TYPE getNum_RateGroupMemberOut_OutputPorts() const
@ CHANNELID_RGMAXTIME
Channel ID for RgMaxTime.
@ CHANNELID_RGCYCLESLIPS
Channel ID for RgCycleSlips.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CyclePortAc.cpp:62
void init()
Initialization function.
Definition: CyclePortAc.cpp:56
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition: CyclePortAc.hpp:37
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition: PingPortAc.hpp:36
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: PingPortAc.cpp:62
void init()
Initialization function.
Definition: PingPortAc.cpp:56
void invoke(U32 key)
Invoke a port interface.
Definition: PingPortAc.cpp:147
void init()
Initialization function.
Definition: PingPortAc.cpp:128
void addCallPort(InputPingPort *callPort)
Register an input port.
Definition: PingPortAc.cpp:134
void invoke(NATIVE_UINT_TYPE context)
Invoke a port interface.
void init()
Initialization function.
void addCallPort(InputSchedPort *callPort)
Register an input port.
Serializable class for carrying timer values.
Definition: TimerVal.hpp:22
Fw::SerializeStatus deserialize(Fw::SerializeBufferBase &buffer)
Deserialization function.
Definition: TimerVal.cpp:54
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
const Time ZERO_TIME
Definition: Time.cpp:5