F´ Flight Software - C/C++ Documentation
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 "Fw/Types/Assert.hpp"
9 #if FW_ENABLE_TEXT_LOGGING
10 #include "Fw/Types/String.hpp"
11 #endif
13 
14 namespace Svc {
15 
16  namespace {
17  enum MsgTypeEnum {
18  ACTIVERATEGROUP_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
19  CYCLEIN_CYCLE,
20  PINGIN_PING,
21  };
22 
23  // Get the max size by constructing a union of the async input, command, and
24  // internal port serialization sizes
25  union BuffUnion {
28  };
29 
30  // Define a message buffer class large enough to handle all the
31  // asynchronous inputs to the component
32  class ComponentIpcSerializableBuffer :
34  {
35 
36  public:
37 
38  enum {
39  // Offset into data in buffer: Size of message ID and port number
40  DATA_OFFSET = sizeof(FwEnumStoreType) + sizeof(FwIndexType),
41  // Max data size
42  MAX_DATA_SIZE = sizeof(BuffUnion),
43  // Max message size: Size of message id + size of port + max data size
44  SERIALIZATION_SIZE = DATA_OFFSET + MAX_DATA_SIZE
45  };
46 
47  Fw::Serializable::SizeType getCapacity() 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 
72  FwSizeType queueDepth,
73  FwEnumStoreType instance
74  )
75  {
76  // Initialize base class
78 
79  // Connect input port CycleIn
80  for (
81  FwIndexType port = 0;
82  port < static_cast<FwIndexType>(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  Fw::ObjectName portName;
94  portName.format(
95  "%s_CycleIn_InputPort[%" PRI_FwIndexType "]",
96  this->m_objName.toChar(),
97  port
98  );
99  this->m_CycleIn_InputPort[port].setObjName(portName.toChar());
100 #endif
101  }
102 
103  // Connect input port PingIn
104  for (
105  FwIndexType port = 0;
106  port < static_cast<FwIndexType>(this->getNum_PingIn_InputPorts());
107  port++
108  ) {
109  this->m_PingIn_InputPort[port].init();
110  this->m_PingIn_InputPort[port].addCallComp(
111  this,
112  m_p_PingIn_in
113  );
114  this->m_PingIn_InputPort[port].setPortNum(port);
115 
116 #if FW_OBJECT_NAMES == 1
117  Fw::ObjectName portName;
118  portName.format(
119  "%s_PingIn_InputPort[%" PRI_FwIndexType "]",
120  this->m_objName.toChar(),
121  port
122  );
123  this->m_PingIn_InputPort[port].setObjName(portName.toChar());
124 #endif
125  }
126 
127  // Connect output port Log
128  for (
129  FwIndexType port = 0;
130  port < static_cast<FwIndexType>(this->getNum_Log_OutputPorts());
131  port++
132  ) {
133  this->m_Log_OutputPort[port].init();
134 
135 #if FW_OBJECT_NAMES == 1
136  Fw::ObjectName portName;
137  portName.format(
138  "%s_Log_OutputPort[%" PRI_FwIndexType "]",
139  this->m_objName.toChar(),
140  port
141  );
142  this->m_Log_OutputPort[port].setObjName(portName.toChar());
143 #endif
144  }
145 
146 #if FW_ENABLE_TEXT_LOGGING == 1
147  // Connect output port LogText
148  for (
149  FwIndexType port = 0;
150  port < static_cast<FwIndexType>(this->getNum_LogText_OutputPorts());
151  port++
152  ) {
153  this->m_LogText_OutputPort[port].init();
154 
155 #if FW_OBJECT_NAMES == 1
156  Fw::ObjectName portName;
157  portName.format(
158  "%s_LogText_OutputPort[%" PRI_FwIndexType "]",
159  this->m_objName.toChar(),
160  port
161  );
162  this->m_LogText_OutputPort[port].setObjName(portName.toChar());
163 #endif
164  }
165 #endif
166 
167  // Connect output port Time
168  for (
169  FwIndexType port = 0;
170  port < static_cast<FwIndexType>(this->getNum_Time_OutputPorts());
171  port++
172  ) {
173  this->m_Time_OutputPort[port].init();
174 
175 #if FW_OBJECT_NAMES == 1
176  Fw::ObjectName portName;
177  portName.format(
178  "%s_Time_OutputPort[%" PRI_FwIndexType "]",
179  this->m_objName.toChar(),
180  port
181  );
182  this->m_Time_OutputPort[port].setObjName(portName.toChar());
183 #endif
184  }
185 
186  // Connect output port Tlm
187  for (
188  FwIndexType port = 0;
189  port < static_cast<FwIndexType>(this->getNum_Tlm_OutputPorts());
190  port++
191  ) {
192  this->m_Tlm_OutputPort[port].init();
193 
194 #if FW_OBJECT_NAMES == 1
195  Fw::ObjectName portName;
196  portName.format(
197  "%s_Tlm_OutputPort[%" PRI_FwIndexType "]",
198  this->m_objName.toChar(),
199  port
200  );
201  this->m_Tlm_OutputPort[port].setObjName(portName.toChar());
202 #endif
203  }
204 
205  // Connect output port PingOut
206  for (
207  FwIndexType port = 0;
208  port < static_cast<FwIndexType>(this->getNum_PingOut_OutputPorts());
209  port++
210  ) {
211  this->m_PingOut_OutputPort[port].init();
212 
213 #if FW_OBJECT_NAMES == 1
214  Fw::ObjectName portName;
215  portName.format(
216  "%s_PingOut_OutputPort[%" PRI_FwIndexType "]",
217  this->m_objName.toChar(),
218  port
219  );
220  this->m_PingOut_OutputPort[port].setObjName(portName.toChar());
221 #endif
222  }
223 
224  // Connect output port RateGroupMemberOut
225  for (
226  FwIndexType port = 0;
227  port < static_cast<FwIndexType>(this->getNum_RateGroupMemberOut_OutputPorts());
228  port++
229  ) {
230  this->m_RateGroupMemberOut_OutputPort[port].init();
231 
232 #if FW_OBJECT_NAMES == 1
233  Fw::ObjectName portName;
234  portName.format(
235  "%s_RateGroupMemberOut_OutputPort[%" PRI_FwIndexType "]",
236  this->m_objName.toChar(),
237  port
238  );
239  this->m_RateGroupMemberOut_OutputPort[port].setObjName(portName.toChar());
240 #endif
241  }
242 
243  // Create the queue
244  Os::Queue::Status qStat = this->createQueue(
245  queueDepth,
246  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
247  );
248  FW_ASSERT(
249  Os::Queue::Status::OP_OK == qStat,
250  static_cast<FwAssertArgType>(qStat)
251  );
252  }
253 
254  // ----------------------------------------------------------------------
255  // Getters for typed input ports
256  // ----------------------------------------------------------------------
257 
260  {
261  FW_ASSERT(
262  (0 <= portNum) && (portNum < this->getNum_CycleIn_InputPorts()),
263  static_cast<FwAssertArgType>(portNum)
264  );
265 
266  return &this->m_CycleIn_InputPort[portNum];
267  }
268 
271  {
272  FW_ASSERT(
273  (0 <= portNum) && (portNum < this->getNum_PingIn_InputPorts()),
274  static_cast<FwAssertArgType>(portNum)
275  );
276 
277  return &this->m_PingIn_InputPort[portNum];
278  }
279 
280  // ----------------------------------------------------------------------
281  // Connect input ports to special output ports
282  // ----------------------------------------------------------------------
283 
286  FwIndexType portNum,
287  Fw::InputLogPort* port
288  )
289  {
290  FW_ASSERT(
291  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
292  static_cast<FwAssertArgType>(portNum)
293  );
294 
295  this->m_Log_OutputPort[portNum].addCallPort(port);
296  }
297 
298 #if FW_ENABLE_TEXT_LOGGING == 1
299 
300  void ActiveRateGroupComponentBase ::
301  set_LogText_OutputPort(
302  FwIndexType portNum,
304  )
305  {
306  FW_ASSERT(
307  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
308  static_cast<FwAssertArgType>(portNum)
309  );
310 
311  this->m_LogText_OutputPort[portNum].addCallPort(port);
312  }
313 
314 #endif
315 
318  FwIndexType portNum,
319  Fw::InputTimePort* port
320  )
321  {
322  FW_ASSERT(
323  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
324  static_cast<FwAssertArgType>(portNum)
325  );
326 
327  this->m_Time_OutputPort[portNum].addCallPort(port);
328  }
329 
332  FwIndexType portNum,
333  Fw::InputTlmPort* port
334  )
335  {
336  FW_ASSERT(
337  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
338  static_cast<FwAssertArgType>(portNum)
339  );
340 
341  this->m_Tlm_OutputPort[portNum].addCallPort(port);
342  }
343 
344  // ----------------------------------------------------------------------
345  // Connect typed input ports to typed output ports
346  // ----------------------------------------------------------------------
347 
350  FwIndexType portNum,
351  Svc::InputPingPort* port
352  )
353  {
354  FW_ASSERT(
355  (0 <= portNum) && (portNum < this->getNum_PingOut_OutputPorts()),
356  static_cast<FwAssertArgType>(portNum)
357  );
358 
359  this->m_PingOut_OutputPort[portNum].addCallPort(port);
360  }
361 
364  FwIndexType portNum,
365  Svc::InputSchedPort* port
366  )
367  {
368  FW_ASSERT(
369  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
370  static_cast<FwAssertArgType>(portNum)
371  );
372 
373  this->m_RateGroupMemberOut_OutputPort[portNum].addCallPort(port);
374  }
375 
376 #if FW_PORT_SERIALIZATION
377 
378  // ----------------------------------------------------------------------
379  // Connect serial input ports to special output ports
380  // ----------------------------------------------------------------------
381 
384  FwIndexType portNum,
385  Fw::InputSerializePort* port
386  )
387  {
388  FW_ASSERT(
389  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
390  static_cast<FwAssertArgType>(portNum)
391  );
392 
393  this->m_Log_OutputPort[portNum].registerSerialPort(port);
394  }
395 
396 #if FW_ENABLE_TEXT_LOGGING == 1
397 
398  void ActiveRateGroupComponentBase ::
399  set_LogText_OutputPort(
400  FwIndexType portNum,
401  Fw::InputSerializePort* port
402  )
403  {
404  FW_ASSERT(
405  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
406  static_cast<FwAssertArgType>(portNum)
407  );
408 
409  this->m_LogText_OutputPort[portNum].registerSerialPort(port);
410  }
411 
412 #endif
413 
416  FwIndexType portNum,
417  Fw::InputSerializePort* port
418  )
419  {
420  FW_ASSERT(
421  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
422  static_cast<FwAssertArgType>(portNum)
423  );
424 
425  this->m_Time_OutputPort[portNum].registerSerialPort(port);
426  }
427 
430  FwIndexType portNum,
431  Fw::InputSerializePort* port
432  )
433  {
434  FW_ASSERT(
435  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
436  static_cast<FwAssertArgType>(portNum)
437  );
438 
439  this->m_Tlm_OutputPort[portNum].registerSerialPort(port);
440  }
441 
442 #endif
443 
444 #if FW_PORT_SERIALIZATION
445 
446  // ----------------------------------------------------------------------
447  // Connect serial input ports to typed output ports
448  // ----------------------------------------------------------------------
449 
452  FwIndexType portNum,
453  Fw::InputSerializePort* port
454  )
455  {
456  FW_ASSERT(
457  (0 <= portNum) && (portNum < this->getNum_PingOut_OutputPorts()),
458  static_cast<FwAssertArgType>(portNum)
459  );
460 
461  this->m_PingOut_OutputPort[portNum].registerSerialPort(port);
462  }
463 
466  FwIndexType portNum,
467  Fw::InputSerializePort* port
468  )
469  {
470  FW_ASSERT(
471  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
472  static_cast<FwAssertArgType>(portNum)
473  );
474 
475  this->m_RateGroupMemberOut_OutputPort[portNum].registerSerialPort(port);
476  }
477 
478 #endif
479 
480  // ----------------------------------------------------------------------
481  // Component construction and destruction
482  // ----------------------------------------------------------------------
483 
485  ActiveRateGroupComponentBase(const char* compName) :
486  Fw::ActiveComponentBase(compName)
487  {
488 
489  }
490 
493  {
494 
495  }
496 
497  // ----------------------------------------------------------------------
498  // Connection status queries for special output ports
499  // ----------------------------------------------------------------------
500 
503  {
504  FW_ASSERT(
505  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
506  static_cast<FwAssertArgType>(portNum)
507  );
508 
509  return this->m_Log_OutputPort[portNum].isConnected();
510  }
511 
512 #if FW_ENABLE_TEXT_LOGGING == 1
513 
514  bool ActiveRateGroupComponentBase ::
515  isConnected_LogText_OutputPort(FwIndexType portNum)
516  {
517  FW_ASSERT(
518  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
519  static_cast<FwAssertArgType>(portNum)
520  );
521 
522  return this->m_LogText_OutputPort[portNum].isConnected();
523  }
524 
525 #endif
526 
529  {
530  FW_ASSERT(
531  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
532  static_cast<FwAssertArgType>(portNum)
533  );
534 
535  return this->m_Time_OutputPort[portNum].isConnected();
536  }
537 
540  {
541  FW_ASSERT(
542  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
543  static_cast<FwAssertArgType>(portNum)
544  );
545 
546  return this->m_Tlm_OutputPort[portNum].isConnected();
547  }
548 
549  // ----------------------------------------------------------------------
550  // Connection status queries for typed output ports
551  // ----------------------------------------------------------------------
552 
555  {
556  FW_ASSERT(
557  (0 <= portNum) && (portNum < this->getNum_PingOut_OutputPorts()),
558  static_cast<FwAssertArgType>(portNum)
559  );
560 
561  return this->m_PingOut_OutputPort[portNum].isConnected();
562  }
563 
566  {
567  FW_ASSERT(
568  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
569  static_cast<FwAssertArgType>(portNum)
570  );
571 
572  return this->m_RateGroupMemberOut_OutputPort[portNum].isConnected();
573  }
574 
575  // ----------------------------------------------------------------------
576  // Port handler base-class functions for typed input ports
577  //
578  // Call these functions directly to bypass the corresponding ports
579  // ----------------------------------------------------------------------
580 
583  FwIndexType portNum,
584  Os::RawTime& cycleStart
585  )
586  {
587  // Make sure port number is valid
588  FW_ASSERT(
589  (0 <= portNum) && (portNum < this->getNum_CycleIn_InputPorts()),
590  static_cast<FwAssertArgType>(portNum)
591  );
592 
593  // Call pre-message hook
595  portNum,
596  cycleStart
597  );
598  ComponentIpcSerializableBuffer msg;
600 
601  // Serialize message ID
602  _status = msg.serializeFrom(
603  static_cast<FwEnumStoreType>(CYCLEIN_CYCLE)
604  );
605  FW_ASSERT(
606  _status == Fw::FW_SERIALIZE_OK,
607  static_cast<FwAssertArgType>(_status)
608  );
609 
610  // Serialize port number
611  _status = msg.serializeFrom(portNum);
612  FW_ASSERT(
613  _status == Fw::FW_SERIALIZE_OK,
614  static_cast<FwAssertArgType>(_status)
615  );
616 
617  // Serialize argument cycleStart
618  _status = msg.serializeFrom(cycleStart);
619  FW_ASSERT(
620  _status == Fw::FW_SERIALIZE_OK,
621  static_cast<FwAssertArgType>(_status)
622  );
623 
624  // Send message
626  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
627 
628  if (qStatus == Os::Queue::Status::FULL) {
629  this->incNumMsgDropped();
630  return;
631  }
632 
633  FW_ASSERT(
634  qStatus == Os::Queue::OP_OK,
635  static_cast<FwAssertArgType>(qStatus)
636  );
637  }
638 
641  FwIndexType portNum,
642  U32 key
643  )
644  {
645  // Make sure port number is valid
646  FW_ASSERT(
647  (0 <= portNum) && (portNum < this->getNum_PingIn_InputPorts()),
648  static_cast<FwAssertArgType>(portNum)
649  );
650 
651  // Call pre-message hook
653  portNum,
654  key
655  );
656  ComponentIpcSerializableBuffer msg;
658 
659  // Serialize message ID
660  _status = msg.serializeFrom(
661  static_cast<FwEnumStoreType>(PINGIN_PING)
662  );
663  FW_ASSERT(
664  _status == Fw::FW_SERIALIZE_OK,
665  static_cast<FwAssertArgType>(_status)
666  );
667 
668  // Serialize port number
669  _status = msg.serializeFrom(portNum);
670  FW_ASSERT(
671  _status == Fw::FW_SERIALIZE_OK,
672  static_cast<FwAssertArgType>(_status)
673  );
674 
675  // Serialize argument key
676  _status = msg.serializeFrom(key);
677  FW_ASSERT(
678  _status == Fw::FW_SERIALIZE_OK,
679  static_cast<FwAssertArgType>(_status)
680  );
681 
682  // Send message
684  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
685 
686  FW_ASSERT(
687  qStatus == Os::Queue::OP_OK,
688  static_cast<FwAssertArgType>(qStatus)
689  );
690  }
691 
692  // ----------------------------------------------------------------------
693  // Pre-message hooks for typed async input ports
694  //
695  // Each of these functions is invoked just before processing a message
696  // on the corresponding port. By default, they do nothing. You can
697  // override them to provide specific pre-message behavior.
698  // ----------------------------------------------------------------------
699 
702  FwIndexType portNum,
703  Os::RawTime& cycleStart
704  )
705  {
706  // Default: no-op
707  }
708 
711  FwIndexType portNum,
712  U32 key
713  )
714  {
715  // Default: no-op
716  }
717 
718  // ----------------------------------------------------------------------
719  // Invocation functions for typed output ports
720  // ----------------------------------------------------------------------
721 
724  FwIndexType portNum,
725  U32 key
726  )
727  {
728  FW_ASSERT(
729  (0 <= portNum) && (portNum < this->getNum_PingOut_OutputPorts()),
730  static_cast<FwAssertArgType>(portNum)
731  );
732 
733  FW_ASSERT(
734  this->m_PingOut_OutputPort[portNum].isConnected(),
735  static_cast<FwAssertArgType>(portNum)
736  );
737  this->m_PingOut_OutputPort[portNum].invoke(
738  key
739  );
740  }
741 
744  FwIndexType portNum,
745  U32 context
746  )
747  {
748  FW_ASSERT(
749  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
750  static_cast<FwAssertArgType>(portNum)
751  );
752 
753  FW_ASSERT(
754  this->m_RateGroupMemberOut_OutputPort[portNum].isConnected(),
755  static_cast<FwAssertArgType>(portNum)
756  );
757  this->m_RateGroupMemberOut_OutputPort[portNum].invoke(
758  context
759  );
760  }
761 
762  // ----------------------------------------------------------------------
763  // Event logging functions
764  // ----------------------------------------------------------------------
765 
768  {
769  // Get the time
770  Fw::Time _logTime;
771  if (this->m_Time_OutputPort[0].isConnected()) {
772  this->m_Time_OutputPort[0].invoke(_logTime);
773  }
774 
775  FwEventIdType _id = static_cast<FwEventIdType>(0);
776 
777  _id = this->getIdBase() + EVENTID_RATEGROUPSTARTED;
778 
779  // Emit the event on the log port
780  if (this->m_Log_OutputPort[0].isConnected()) {
781  Fw::LogBuffer _logBuff;
782 
783 #if FW_AMPCS_COMPATIBLE
785  // Serialize the number of arguments
786  _status = _logBuff.serializeFrom(static_cast<U8>(0));
787  FW_ASSERT(
788  _status == Fw::FW_SERIALIZE_OK,
789  static_cast<FwAssertArgType>(_status)
790  );
791 #endif
792 
793  this->m_Log_OutputPort[0].invoke(
794  _id,
795  _logTime,
797  _logBuff
798  );
799  }
800 
801  // Emit the event on the text log port
802 #if FW_ENABLE_TEXT_LOGGING
803  if (this->m_LogText_OutputPort[0].isConnected()) {
804 #if FW_OBJECT_NAMES == 1
805  const char* _formatString =
806  "(%s) %s: Rate group started.";
807 #else
808  const char* _formatString =
809  "%s: Rate group started.";
810 #endif
811 
812  Fw::TextLogString _logString;
813  _logString.format(
814  _formatString,
815 #if FW_OBJECT_NAMES == 1
816  this->m_objName.toChar(),
817 #endif
818  "RateGroupStarted "
819  );
820 
821  this->m_LogText_OutputPort[0].invoke(
822  _id,
823  _logTime,
825  _logString
826  );
827  }
828 #endif
829  }
830 
833  {
834  // Get the time
835  Fw::Time _logTime;
836  if (this->m_Time_OutputPort[0].isConnected()) {
837  this->m_Time_OutputPort[0].invoke(_logTime);
838  }
839 
840  FwEventIdType _id = static_cast<FwEventIdType>(0);
841 
842  _id = this->getIdBase() + EVENTID_RATEGROUPCYCLESLIP;
843 
844  // Emit the event on the log port
845  if (this->m_Log_OutputPort[0].isConnected()) {
846  Fw::LogBuffer _logBuff;
848 
849 #if FW_AMPCS_COMPATIBLE
850  // Serialize the number of arguments
851  _status = _logBuff.serializeFrom(static_cast<U8>(1));
852  FW_ASSERT(
853  _status == Fw::FW_SERIALIZE_OK,
854  static_cast<FwAssertArgType>(_status)
855  );
856 #endif
857 
858 #if FW_AMPCS_COMPATIBLE
859  // Serialize the argument size
860  _status = _logBuff.serializeFrom(
861  static_cast<U8>(sizeof(U32))
862  );
863  FW_ASSERT(
864  _status == Fw::FW_SERIALIZE_OK,
865  static_cast<FwAssertArgType>(_status)
866  );
867 #endif
868  _status = _logBuff.serializeFrom(cycle);
869  FW_ASSERT(
870  _status == Fw::FW_SERIALIZE_OK,
871  static_cast<FwAssertArgType>(_status)
872  );
873 
874  this->m_Log_OutputPort[0].invoke(
875  _id,
876  _logTime,
878  _logBuff
879  );
880  }
881 
882  // Emit the event on the text log port
883 #if FW_ENABLE_TEXT_LOGGING
884  if (this->m_LogText_OutputPort[0].isConnected()) {
885 #if FW_OBJECT_NAMES == 1
886  const char* _formatString =
887  "(%s) %s: Rate group cycle slipped on cycle %" PRIu32 "";
888 #else
889  const char* _formatString =
890  "%s: Rate group cycle slipped on cycle %" PRIu32 "";
891 #endif
892 
893  Fw::TextLogString _logString;
894  _logString.format(
895  _formatString,
896 #if FW_OBJECT_NAMES == 1
897  this->m_objName.toChar(),
898 #endif
899  "RateGroupCycleSlip ",
900  cycle
901  );
902 
903  this->m_LogText_OutputPort[0].invoke(
904  _id,
905  _logTime,
907  _logString
908  );
909  }
910 #endif
911  }
912 
913  // ----------------------------------------------------------------------
914  // Telemetry write functions
915  // ----------------------------------------------------------------------
916 
919  U32 arg,
920  Fw::Time _tlmTime
921  )
922  {
923  // Check to see if it is the first time
924  if (not this->m_first_update_RgMaxTime) {
925  // Check to see if value has changed. If not, don't write it.
926  if (arg == this->m_last_RgMaxTime) {
927  return;
928  }
929  else {
930  this->m_last_RgMaxTime = arg;
931  }
932  }
933  else {
934  this->m_first_update_RgMaxTime = false;
935  this->m_last_RgMaxTime = arg;
936  }
937 
938  if (this->m_Tlm_OutputPort[0].isConnected()) {
939  if (
940  this->m_Time_OutputPort[0].isConnected() &&
941  (_tlmTime == Fw::ZERO_TIME)
942  ) {
943  this->m_Time_OutputPort[0].invoke(_tlmTime);
944  }
945 
946  Fw::TlmBuffer _tlmBuff;
947  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
948  FW_ASSERT(
949  _stat == Fw::FW_SERIALIZE_OK,
950  static_cast<FwAssertArgType>(_stat)
951  );
952 
953  FwChanIdType _id;
954 
955  _id = this->getIdBase() + CHANNELID_RGMAXTIME;
956 
957  this->m_Tlm_OutputPort[0].invoke(
958  _id,
959  _tlmTime,
960  _tlmBuff
961  );
962  }
963  }
964 
967  U32 arg,
968  Fw::Time _tlmTime
969  )
970  {
971  // Check to see if it is the first time
972  if (not this->m_first_update_RgCycleSlips) {
973  // Check to see if value has changed. If not, don't write it.
974  if (arg == this->m_last_RgCycleSlips) {
975  return;
976  }
977  else {
978  this->m_last_RgCycleSlips = arg;
979  }
980  }
981  else {
982  this->m_first_update_RgCycleSlips = false;
983  this->m_last_RgCycleSlips = arg;
984  }
985 
986  if (this->m_Tlm_OutputPort[0].isConnected()) {
987  if (
988  this->m_Time_OutputPort[0].isConnected() &&
989  (_tlmTime == Fw::ZERO_TIME)
990  ) {
991  this->m_Time_OutputPort[0].invoke(_tlmTime);
992  }
993 
994  Fw::TlmBuffer _tlmBuff;
995  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
996  FW_ASSERT(
997  _stat == Fw::FW_SERIALIZE_OK,
998  static_cast<FwAssertArgType>(_stat)
999  );
1000 
1001  FwChanIdType _id;
1002 
1003  _id = this->getIdBase() + CHANNELID_RGCYCLESLIPS;
1004 
1005  this->m_Tlm_OutputPort[0].invoke(
1006  _id,
1007  _tlmTime,
1008  _tlmBuff
1009  );
1010  }
1011  }
1012 
1013  // ----------------------------------------------------------------------
1014  // Time
1015  // ----------------------------------------------------------------------
1016 
1018  getTime() const
1019  {
1020  if (this->m_Time_OutputPort[0].isConnected()) {
1021  Fw::Time _time;
1022  this->m_Time_OutputPort[0].invoke(_time);
1023  return _time;
1024  }
1025  else {
1026  return Fw::Time(TimeBase::TB_NONE, 0, 0);
1027  }
1028  }
1029 
1030  // ----------------------------------------------------------------------
1031  // Message dispatch functions
1032  // ----------------------------------------------------------------------
1033 
1034  Fw::QueuedComponentBase::MsgDispatchStatus ActiveRateGroupComponentBase ::
1035  doDispatch()
1036  {
1037  ComponentIpcSerializableBuffer _msg;
1038  FwQueuePriorityType _priority = 0;
1039 
1040  Os::Queue::Status _msgStatus = this->m_queue.receive(
1041  _msg,
1043  _priority
1044  );
1045  FW_ASSERT(
1046  _msgStatus == Os::Queue::OP_OK,
1047  static_cast<FwAssertArgType>(_msgStatus)
1048  );
1049 
1050  // Reset to beginning of buffer
1051  _msg.resetDeser();
1052 
1053  FwEnumStoreType _desMsg = 0;
1054  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
1055  FW_ASSERT(
1056  _deserStatus == Fw::FW_SERIALIZE_OK,
1057  static_cast<FwAssertArgType>(_deserStatus)
1058  );
1059 
1060  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
1061 
1062  if (_msgType == ACTIVERATEGROUP_COMPONENT_EXIT) {
1063  return MSG_DISPATCH_EXIT;
1064  }
1065 
1066  FwIndexType portNum = 0;
1067  _deserStatus = _msg.deserializeTo(portNum);
1068  FW_ASSERT(
1069  _deserStatus == Fw::FW_SERIALIZE_OK,
1070  static_cast<FwAssertArgType>(_deserStatus)
1071  );
1072 
1073  switch (_msgType) {
1074  // Handle async input port CycleIn
1075  case CYCLEIN_CYCLE: {
1076  // Deserialize argument cycleStart
1077  Os::RawTime cycleStart;
1078  _deserStatus = _msg.deserializeTo(cycleStart);
1079  FW_ASSERT(
1080  _deserStatus == Fw::FW_SERIALIZE_OK,
1081  static_cast<FwAssertArgType>(_deserStatus)
1082  );
1083  // Call handler function
1084  this->CycleIn_handler(
1085  portNum,
1086  cycleStart
1087  );
1088 
1089  break;
1090  }
1091 
1092  // Handle async input port PingIn
1093  case PINGIN_PING: {
1094  // Deserialize argument key
1095  U32 key;
1096  _deserStatus = _msg.deserializeTo(key);
1097  FW_ASSERT(
1098  _deserStatus == Fw::FW_SERIALIZE_OK,
1099  static_cast<FwAssertArgType>(_deserStatus)
1100  );
1101  // Call handler function
1102  this->PingIn_handler(
1103  portNum,
1104  key
1105  );
1106 
1107  break;
1108  }
1109 
1110  default:
1111  return MSG_DISPATCH_ERROR;
1112  }
1113 
1114  return MSG_DISPATCH_OK;
1115  }
1116 
1117  // ----------------------------------------------------------------------
1118  // Calls for messages received on typed input ports
1119  // ----------------------------------------------------------------------
1120 
1121  void ActiveRateGroupComponentBase ::
1122  m_p_CycleIn_in(
1123  Fw::PassiveComponentBase* callComp,
1124  FwIndexType portNum,
1125  Os::RawTime& cycleStart
1126  )
1127  {
1128  FW_ASSERT(callComp);
1129  ActiveRateGroupComponentBase* compPtr = static_cast<ActiveRateGroupComponentBase*>(callComp);
1130  compPtr->CycleIn_handlerBase(
1131  portNum,
1132  cycleStart
1133  );
1134  }
1135 
1136  void ActiveRateGroupComponentBase ::
1137  m_p_PingIn_in(
1138  Fw::PassiveComponentBase* callComp,
1139  FwIndexType portNum,
1140  U32 key
1141  )
1142  {
1143  FW_ASSERT(callComp);
1144  ActiveRateGroupComponentBase* compPtr = static_cast<ActiveRateGroupComponentBase*>(callComp);
1145  compPtr->PingIn_handlerBase(
1146  portNum,
1147  key
1148  );
1149  }
1150 
1151 }
void set_PingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to PingOut[portNum].
Serialization/Deserialization operation was successful.
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
void tlmWrite_RgCycleSlips(U32 arg, Fw::Time _tlmTime=Fw::Time())
Operation succeeded.
Definition: Os.hpp:26
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
PlatformSizeType FwSizeType
static constexpr FwIndexType getNum_PingIn_InputPorts()
static constexpr FwIndexType getNum_RateGroupMemberOut_OutputPorts()
void CycleIn_handlerBase(FwIndexType portNum, Os::RawTime &cycleStart)
Handler base-class function for input port CycleIn.
Status receive(U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority) override
receive a message from the queue through delegate
Definition: Queue.cpp:63
void PingOut_out(FwIndexType portNum, U32 key)
Invoke output port PingOut.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CyclePortAc.cpp:62
I32 FwEnumStoreType
static constexpr FwIndexType getNum_Log_OutputPorts()
Status
status returned from the queue send function
Definition: Queue.hpp:30
The size of the serial representations of the port arguments.
Definition: PingPortAc.hpp:36
static constexpr FwIndexType getNum_Time_OutputPorts()
void invoke(U32 key) const
Invoke a port interface.
Definition: PingPortAc.cpp:147
const Time ZERO_TIME
Definition: Time.cpp:5
virtual void PingIn_preMsgHook(FwIndexType portNum, U32 key)
Pre-message hook for async input port PingIn.
virtual ~ActiveRateGroupComponentBase()
Destroy ActiveRateGroupComponentBase object.
void init()
Initialization function.
Definition: TlmPortAc.cpp:144
No time base has been established (Required)
bool isConnected_Time_OutputPort(FwIndexType portNum)
Os::Queue m_queue
queue object for active component
Software diagnostic events.
virtual void CycleIn_preMsgHook(FwIndexType portNum, Os::RawTime &cycleStart)
Pre-message hook for async input port CycleIn.
void set_Log_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to Log[portNum].
Warning event that rate group has had a cycle slip.
void addCallPort(InputTlmPort *callPort)
Register an input port.
Definition: TlmPortAc.cpp:150
void init()
Object initializer.
Definition: ObjBase.cpp:24
ActiveRateGroupComponentBase(const char *compName="")
Construct ActiveRateGroupComponentBase object.
SerializeStatus
forward declaration for string
void set_RateGroupMemberOut_OutputPort(FwIndexType portNum, Svc::InputSchedPort *port)
Connect port to RateGroupMemberOut[portNum].
Message will block until space is available.
Definition: Queue.hpp:47
FwIdType FwEventIdType
The type of an event identifier.
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:26
void init()
Initialization function.
Definition: TimePortAc.cpp:128
bool isConnected_Log_OutputPort(FwIndexType portNum)
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize)
void invoke(U32 context) const
Invoke a port interface.
void init()
Initialization function.
Definition: PingPortAc.cpp:128
void invoke(Fw::Time &time) const
Invoke a port interface.
Definition: TimePortAc.cpp:147
const char * toChar() const
Convert to a C-style char*.
Definition: ObjectName.hpp:50
FwIdType FwChanIdType
The type of a telemetry channel identifier.
FwSizeType SizeType
static constexpr FwIndexType getNum_PingOut_OutputPorts()
void addCallPort(InputPingPort *callPort)
Register an input port.
Definition: PingPortAc.cpp:134
Status send(const U8 *buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType) override
send a message into the queue through delegate
Definition: Queue.cpp:46
bool isConnected_Tlm_OutputPort(FwIndexType portNum)
void tlmWrite_RgMaxTime(U32 arg, Fw::Time _tlmTime=Fw::Time())
A serious but recoverable event.
The size of the serial representations of the port arguments.
Definition: CyclePortAc.hpp:37
void invoke(FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) const
Invoke a port interface.
Definition: TlmPortAc.cpp:163
bool isConnected() const
Definition: PortBase.cpp:38
#define PRI_FwIndexType
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:39
void init()
Initialization function.
Definition: LogPortAc.cpp:151
void setPortNum(FwIndexType portNum)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
BlockingType
message type
Definition: Queue.hpp:46
void init()
Initialization function.
Definition: CyclePortAc.cpp:56
PlatformQueuePriorityType FwQueuePriorityType
The type of queue priorities used.
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args) const
Invoke a port interface.
Definition: LogPortAc.cpp:170
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
bool isConnected_RateGroupMemberOut_OutputPort(FwIndexType portNum)
virtual void CycleIn_handler(FwIndexType portNum, Os::RawTime &cycleStart)=0
Handler for input port CycleIn.
A message was sent requesting an exit of the loop.
PlatformIndexType FwIndexType
static constexpr FwIndexType getNum_Tlm_OutputPorts()
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:157
void init()
Initialization function.
static constexpr FwIndexType getNum_CycleIn_InputPorts()
void incNumMsgDropped()
increment the number of messages dropped
void init()
Initialization function.
Definition: PingPortAc.cpp:56
Svc::InputPingPort * get_PingIn_InputPort(FwIndexType portNum)
RateGroupDivider component implementation.
virtual void PingIn_handler(FwIndexType portNum, U32 key)=0
Handler for input port PingIn.
message sent/received okay
Definition: Queue.hpp:31
U8 BYTE
byte type
Definition: BasicTypes.h:56
message to exit active component task
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: PingPortAc.cpp:62
bool isConnected_PingOut_OutputPort(FwIndexType portNum)
Message will return with status when space is unavailable.
Definition: Queue.hpp:48
Implementation of malloc based allocator.
Svc::InputCyclePort * get_CycleIn_InputPort(FwIndexType portNum)
void RateGroupMemberOut_out(FwIndexType portNum, U32 context)
Invoke output port RateGroupMemberOut.
void set_Tlm_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to Tlm[portNum].
void PingIn_handlerBase(FwIndexType portNum, U32 key)
Handler base-class function for input port PingIn.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
void addCallPort(InputSchedPort *callPort)
Register an input port.