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 {
26  BYTE CycleInPortSize[Svc::CyclePortBuffer::CAPACITY];
27  BYTE PingInPortSize[Svc::PingPortBuffer::CAPACITY];
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  ComponentIpcSerializableBuffer() : Fw::LinearBufferBase(m_buff, sizeof(m_buff)) {
48 
49  }
50 
51  private:
52  // Should be the max of all the input ports serialized sizes...
53  U8 m_buff[SERIALIZATION_SIZE];
54 
55  };
56  }
57 
58  // ----------------------------------------------------------------------
59  // Component initialization
60  // ----------------------------------------------------------------------
61 
64  FwSizeType queueDepth,
65  FwEnumStoreType instance
66  )
67  {
68  // Initialize base class
70 
71 #if !FW_DIRECT_PORT_CALLS
72  // Connect input port CycleIn
73  for (
74  FwIndexType port = 0;
75  port < static_cast<FwIndexType>(this->getNum_CycleIn_InputPorts());
76  port++
77  ) {
78  this->m_CycleIn_InputPort[port].init();
79  this->m_CycleIn_InputPort[port].addCallComp(
80  this,
81  m_p_CycleIn_in
82  );
83  this->m_CycleIn_InputPort[port].setPortNum(port);
84 
85 #if FW_OBJECT_NAMES == 1
86  Fw::ObjectName portName;
87  portName.format(
88  "%s_CycleIn_InputPort[%" PRI_FwIndexType "]",
89  this->m_objName.toChar(),
90  port
91  );
92  this->m_CycleIn_InputPort[port].setObjName(portName.toChar());
93 #endif
94  }
95 #endif
96 
97 #if !FW_DIRECT_PORT_CALLS
98  // Connect input port PingIn
99  for (
100  FwIndexType port = 0;
101  port < static_cast<FwIndexType>(this->getNum_PingIn_InputPorts());
102  port++
103  ) {
104  this->m_PingIn_InputPort[port].init();
105  this->m_PingIn_InputPort[port].addCallComp(
106  this,
107  m_p_PingIn_in
108  );
109  this->m_PingIn_InputPort[port].setPortNum(port);
110 
111 #if FW_OBJECT_NAMES == 1
112  Fw::ObjectName portName;
113  portName.format(
114  "%s_PingIn_InputPort[%" PRI_FwIndexType "]",
115  this->m_objName.toChar(),
116  port
117  );
118  this->m_PingIn_InputPort[port].setObjName(portName.toChar());
119 #endif
120  }
121 #endif
122 
123 #if !FW_DIRECT_PORT_CALLS
124  // Connect output port Log
125  for (
126  FwIndexType port = 0;
127  port < static_cast<FwIndexType>(this->getNum_Log_OutputPorts());
128  port++
129  ) {
130  this->m_Log_OutputPort[port].init();
131 
132 #if FW_OBJECT_NAMES == 1
133  Fw::ObjectName portName;
134  portName.format(
135  "%s_Log_OutputPort[%" PRI_FwIndexType "]",
136  this->m_objName.toChar(),
137  port
138  );
139  this->m_Log_OutputPort[port].setObjName(portName.toChar());
140 #endif
141  }
142 #endif
143 
144 #if !FW_DIRECT_PORT_CALLS && FW_ENABLE_TEXT_LOGGING
145  // Connect output port LogText
146  for (
147  FwIndexType port = 0;
148  port < static_cast<FwIndexType>(this->getNum_LogText_OutputPorts());
149  port++
150  ) {
151  this->m_LogText_OutputPort[port].init();
152 
153 #if FW_OBJECT_NAMES == 1
154  Fw::ObjectName portName;
155  portName.format(
156  "%s_LogText_OutputPort[%" PRI_FwIndexType "]",
157  this->m_objName.toChar(),
158  port
159  );
160  this->m_LogText_OutputPort[port].setObjName(portName.toChar());
161 #endif
162  }
163 #endif
164 
165 #if !FW_DIRECT_PORT_CALLS
166  // Connect output port Time
167  for (
168  FwIndexType port = 0;
169  port < static_cast<FwIndexType>(this->getNum_Time_OutputPorts());
170  port++
171  ) {
172  this->m_Time_OutputPort[port].init();
173 
174 #if FW_OBJECT_NAMES == 1
175  Fw::ObjectName portName;
176  portName.format(
177  "%s_Time_OutputPort[%" PRI_FwIndexType "]",
178  this->m_objName.toChar(),
179  port
180  );
181  this->m_Time_OutputPort[port].setObjName(portName.toChar());
182 #endif
183  }
184 #endif
185 
186 #if !FW_DIRECT_PORT_CALLS
187  // Connect output port Tlm
188  for (
189  FwIndexType port = 0;
190  port < static_cast<FwIndexType>(this->getNum_Tlm_OutputPorts());
191  port++
192  ) {
193  this->m_Tlm_OutputPort[port].init();
194 
195 #if FW_OBJECT_NAMES == 1
196  Fw::ObjectName portName;
197  portName.format(
198  "%s_Tlm_OutputPort[%" PRI_FwIndexType "]",
199  this->m_objName.toChar(),
200  port
201  );
202  this->m_Tlm_OutputPort[port].setObjName(portName.toChar());
203 #endif
204  }
205 #endif
206 
207 #if !FW_DIRECT_PORT_CALLS
208  // Connect output port PingOut
209  for (
210  FwIndexType port = 0;
211  port < static_cast<FwIndexType>(this->getNum_PingOut_OutputPorts());
212  port++
213  ) {
214  this->m_PingOut_OutputPort[port].init();
215 
216 #if FW_OBJECT_NAMES == 1
217  Fw::ObjectName portName;
218  portName.format(
219  "%s_PingOut_OutputPort[%" PRI_FwIndexType "]",
220  this->m_objName.toChar(),
221  port
222  );
223  this->m_PingOut_OutputPort[port].setObjName(portName.toChar());
224 #endif
225  }
226 #endif
227 
228 #if !FW_DIRECT_PORT_CALLS
229  // Connect output port RateGroupMemberOut
230  for (
231  FwIndexType port = 0;
232  port < static_cast<FwIndexType>(this->getNum_RateGroupMemberOut_OutputPorts());
233  port++
234  ) {
235  this->m_RateGroupMemberOut_OutputPort[port].init();
236 
237 #if FW_OBJECT_NAMES == 1
238  Fw::ObjectName portName;
239  portName.format(
240  "%s_RateGroupMemberOut_OutputPort[%" PRI_FwIndexType "]",
241  this->m_objName.toChar(),
242  port
243  );
244  this->m_RateGroupMemberOut_OutputPort[port].setObjName(portName.toChar());
245 #endif
246  }
247 #endif
248 
249  // Create the queue
250  Os::Queue::Status qStat = this->createQueue(
251  queueDepth,
252  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
253  );
254  FW_ASSERT(
255  Os::Queue::Status::OP_OK == qStat,
256  static_cast<FwAssertArgType>(qStat)
257  );
258  }
259 
260 #if !FW_DIRECT_PORT_CALLS
261 
262  // ----------------------------------------------------------------------
263  // Getters for typed input ports
264  // ----------------------------------------------------------------------
265 
268  {
269  FW_ASSERT(
270  (0 <= portNum) && (portNum < this->getNum_CycleIn_InputPorts()),
271  static_cast<FwAssertArgType>(portNum)
272  );
273 
274  return &this->m_CycleIn_InputPort[portNum];
275  }
276 
279  {
280  FW_ASSERT(
281  (0 <= portNum) && (portNum < this->getNum_PingIn_InputPorts()),
282  static_cast<FwAssertArgType>(portNum)
283  );
284 
285  return &this->m_PingIn_InputPort[portNum];
286  }
287 
288 #endif
289 
290 #if !FW_DIRECT_PORT_CALLS
291 
292  // ----------------------------------------------------------------------
293  // Connect input ports to special output ports
294  // ----------------------------------------------------------------------
295 
298  FwIndexType portNum,
299  Fw::InputLogPort* port
300  )
301  {
302  FW_ASSERT(
303  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
304  static_cast<FwAssertArgType>(portNum)
305  );
306 
307  this->m_Log_OutputPort[portNum].addCallPort(port);
308  }
309 
310 #if FW_ENABLE_TEXT_LOGGING == 1
311 
312  void ActiveRateGroupComponentBase ::
313  set_LogText_OutputPort(
314  FwIndexType portNum,
316  )
317  {
318  FW_ASSERT(
319  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
320  static_cast<FwAssertArgType>(portNum)
321  );
322 
323  this->m_LogText_OutputPort[portNum].addCallPort(port);
324  }
325 
326 #endif
327 
330  FwIndexType portNum,
331  Fw::InputTimePort* port
332  )
333  {
334  FW_ASSERT(
335  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
336  static_cast<FwAssertArgType>(portNum)
337  );
338 
339  this->m_Time_OutputPort[portNum].addCallPort(port);
340  }
341 
344  FwIndexType portNum,
345  Fw::InputTlmPort* port
346  )
347  {
348  FW_ASSERT(
349  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
350  static_cast<FwAssertArgType>(portNum)
351  );
352 
353  this->m_Tlm_OutputPort[portNum].addCallPort(port);
354  }
355 
356 #endif
357 
358 #if !FW_DIRECT_PORT_CALLS
359 
360  // ----------------------------------------------------------------------
361  // Connect typed input ports to typed output ports
362  // ----------------------------------------------------------------------
363 
366  FwIndexType portNum,
367  Svc::InputPingPort* port
368  )
369  {
370  FW_ASSERT(
371  (0 <= portNum) && (portNum < this->getNum_PingOut_OutputPorts()),
372  static_cast<FwAssertArgType>(portNum)
373  );
374 
375  this->m_PingOut_OutputPort[portNum].addCallPort(port);
376  }
377 
380  FwIndexType portNum,
381  Svc::InputSchedPort* port
382  )
383  {
384  FW_ASSERT(
385  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
386  static_cast<FwAssertArgType>(portNum)
387  );
388 
389  this->m_RateGroupMemberOut_OutputPort[portNum].addCallPort(port);
390  }
391 
392 #endif
393 
394 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
395 
396  // ----------------------------------------------------------------------
397  // Connect serial input ports to special output ports
398  // ----------------------------------------------------------------------
399 
402  FwIndexType portNum,
403  Fw::InputSerializePort* port
404  )
405  {
406  FW_ASSERT(
407  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
408  static_cast<FwAssertArgType>(portNum)
409  );
410 
411  this->m_Log_OutputPort[portNum].registerSerialPort(port);
412  }
413 
414 #if FW_ENABLE_TEXT_LOGGING == 1
415 
416  void ActiveRateGroupComponentBase ::
417  set_LogText_OutputPort(
418  FwIndexType portNum,
419  Fw::InputSerializePort* port
420  )
421  {
422  FW_ASSERT(
423  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
424  static_cast<FwAssertArgType>(portNum)
425  );
426 
427  this->m_LogText_OutputPort[portNum].registerSerialPort(port);
428  }
429 
430 #endif
431 
434  FwIndexType portNum,
435  Fw::InputSerializePort* port
436  )
437  {
438  FW_ASSERT(
439  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
440  static_cast<FwAssertArgType>(portNum)
441  );
442 
443  this->m_Time_OutputPort[portNum].registerSerialPort(port);
444  }
445 
448  FwIndexType portNum,
449  Fw::InputSerializePort* port
450  )
451  {
452  FW_ASSERT(
453  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
454  static_cast<FwAssertArgType>(portNum)
455  );
456 
457  this->m_Tlm_OutputPort[portNum].registerSerialPort(port);
458  }
459 
460 #endif
461 
462 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
463 
464  // ----------------------------------------------------------------------
465  // Connect serial input ports to typed output ports
466  // ----------------------------------------------------------------------
467 
470  FwIndexType portNum,
471  Fw::InputSerializePort* port
472  )
473  {
474  FW_ASSERT(
475  (0 <= portNum) && (portNum < this->getNum_PingOut_OutputPorts()),
476  static_cast<FwAssertArgType>(portNum)
477  );
478 
479  this->m_PingOut_OutputPort[portNum].registerSerialPort(port);
480  }
481 
484  FwIndexType portNum,
485  Fw::InputSerializePort* port
486  )
487  {
488  FW_ASSERT(
489  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
490  static_cast<FwAssertArgType>(portNum)
491  );
492 
493  this->m_RateGroupMemberOut_OutputPort[portNum].registerSerialPort(port);
494  }
495 
496 #endif
497 
498  // ----------------------------------------------------------------------
499  // Component construction and destruction
500  // ----------------------------------------------------------------------
501 
503  ActiveRateGroupComponentBase(const char* compName) :
504  Fw::ActiveComponentBase(compName)
505  {
506  this->m_RateGroupTimeGetErrorThrottle = 0;
507  }
508 
511  {
512 
513  }
514 
515 #if !FW_DIRECT_PORT_CALLS
516 
517  // ----------------------------------------------------------------------
518  // Connection status queries for special output ports
519  // ----------------------------------------------------------------------
520 
523  {
524  FW_ASSERT(
525  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
526  static_cast<FwAssertArgType>(portNum)
527  );
528 
529  return this->m_Log_OutputPort[portNum].isConnected();
530  }
531 
532 #if FW_ENABLE_TEXT_LOGGING == 1
533 
534  bool ActiveRateGroupComponentBase ::
535  isConnected_LogText_OutputPort(FwIndexType portNum) const
536  {
537  FW_ASSERT(
538  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
539  static_cast<FwAssertArgType>(portNum)
540  );
541 
542  return this->m_LogText_OutputPort[portNum].isConnected();
543  }
544 
545 #endif
546 
549  {
550  FW_ASSERT(
551  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
552  static_cast<FwAssertArgType>(portNum)
553  );
554 
555  return this->m_Time_OutputPort[portNum].isConnected();
556  }
557 
560  {
561  FW_ASSERT(
562  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
563  static_cast<FwAssertArgType>(portNum)
564  );
565 
566  return this->m_Tlm_OutputPort[portNum].isConnected();
567  }
568 
569 #endif
570 
571 #if !FW_DIRECT_PORT_CALLS
572 
573  // ----------------------------------------------------------------------
574  // Connection status queries for typed output ports
575  // ----------------------------------------------------------------------
576 
579  {
580  FW_ASSERT(
581  (0 <= portNum) && (portNum < this->getNum_PingOut_OutputPorts()),
582  static_cast<FwAssertArgType>(portNum)
583  );
584 
585  return this->m_PingOut_OutputPort[portNum].isConnected();
586  }
587 
590  {
591  FW_ASSERT(
592  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
593  static_cast<FwAssertArgType>(portNum)
594  );
595 
596  return this->m_RateGroupMemberOut_OutputPort[portNum].isConnected();
597  }
598 
599 #endif
600 
601  // ----------------------------------------------------------------------
602  // Port handler base-class functions for typed input ports
603  //
604  // Call these functions directly to bypass the corresponding ports
605  // ----------------------------------------------------------------------
606 
609  FwIndexType portNum,
610  Os::RawTime& cycleStart
611  )
612  {
613  // Make sure port number is valid
614  FW_ASSERT(
615  (0 <= portNum) && (portNum < this->getNum_CycleIn_InputPorts()),
616  static_cast<FwAssertArgType>(portNum)
617  );
618 
619  // Call pre-message hook
621  portNum,
622  cycleStart
623  );
624  ComponentIpcSerializableBuffer msg;
626 
627  // Serialize message ID
628  _status = msg.serializeFrom(
629  static_cast<FwEnumStoreType>(CYCLEIN_CYCLE)
630  );
631  FW_ASSERT(
632  _status == Fw::FW_SERIALIZE_OK,
633  static_cast<FwAssertArgType>(_status)
634  );
635 
636  // Serialize port number
637  _status = msg.serializeFrom(portNum);
638  FW_ASSERT(
639  _status == Fw::FW_SERIALIZE_OK,
640  static_cast<FwAssertArgType>(_status)
641  );
642 
643  // Serialize argument cycleStart
644  _status = msg.serializeFrom(cycleStart);
645  FW_ASSERT(
646  _status == Fw::FW_SERIALIZE_OK,
647  static_cast<FwAssertArgType>(_status)
648  );
649 
650  // Send message
652  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
653 
654  if (qStatus == Os::Queue::Status::FULL) {
655  this->incNumMsgDropped();
656  return;
657  }
658 
659  FW_ASSERT(
660  qStatus == Os::Queue::OP_OK,
661  static_cast<FwAssertArgType>(qStatus)
662  );
663  }
664 
667  FwIndexType portNum,
668  U32 key
669  )
670  {
671  // Make sure port number is valid
672  FW_ASSERT(
673  (0 <= portNum) && (portNum < this->getNum_PingIn_InputPorts()),
674  static_cast<FwAssertArgType>(portNum)
675  );
676 
677  // Call pre-message hook
679  portNum,
680  key
681  );
682  ComponentIpcSerializableBuffer msg;
684 
685  // Serialize message ID
686  _status = msg.serializeFrom(
687  static_cast<FwEnumStoreType>(PINGIN_PING)
688  );
689  FW_ASSERT(
690  _status == Fw::FW_SERIALIZE_OK,
691  static_cast<FwAssertArgType>(_status)
692  );
693 
694  // Serialize port number
695  _status = msg.serializeFrom(portNum);
696  FW_ASSERT(
697  _status == Fw::FW_SERIALIZE_OK,
698  static_cast<FwAssertArgType>(_status)
699  );
700 
701  // Serialize argument key
702  _status = msg.serializeFrom(key);
703  FW_ASSERT(
704  _status == Fw::FW_SERIALIZE_OK,
705  static_cast<FwAssertArgType>(_status)
706  );
707 
708  // Send message
710  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
711 
712  FW_ASSERT(
713  qStatus == Os::Queue::OP_OK,
714  static_cast<FwAssertArgType>(qStatus)
715  );
716  }
717 
718  // ----------------------------------------------------------------------
719  // Pre-message hooks for typed async input ports
720  //
721  // Each of these functions is invoked just before processing a message
722  // on the corresponding port. By default, they do nothing. You can
723  // override them to provide specific pre-message behavior.
724  // ----------------------------------------------------------------------
725 
728  FwIndexType portNum,
729  Os::RawTime& cycleStart
730  )
731  {
732  // Default: no-op
733  }
734 
737  FwIndexType portNum,
738  U32 key
739  )
740  {
741  // Default: no-op
742  }
743 
744 #if !FW_DIRECT_PORT_CALLS
745 
746  // ----------------------------------------------------------------------
747  // Invocation functions for typed output ports
748  // ----------------------------------------------------------------------
749 
752  FwIndexType portNum,
753  U32 key
754  ) const
755  {
756  FW_ASSERT(
757  (0 <= portNum) && (portNum < this->getNum_PingOut_OutputPorts()),
758  static_cast<FwAssertArgType>(portNum)
759  );
760 
761  FW_ASSERT(
762  this->m_PingOut_OutputPort[portNum].isConnected(),
763  static_cast<FwAssertArgType>(portNum)
764  );
765  this->m_PingOut_OutputPort[portNum].invoke(
766  key
767  );
768  }
769 
772  FwIndexType portNum,
773  U32 context
774  ) const
775  {
776  FW_ASSERT(
777  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
778  static_cast<FwAssertArgType>(portNum)
779  );
780 
781  FW_ASSERT(
782  this->m_RateGroupMemberOut_OutputPort[portNum].isConnected(),
783  static_cast<FwAssertArgType>(portNum)
784  );
785  this->m_RateGroupMemberOut_OutputPort[portNum].invoke(
786  context
787  );
788  }
789 
790 #endif
791 
792  // ----------------------------------------------------------------------
793  // Event logging functions
794  // ----------------------------------------------------------------------
795 
798  {
799  // Get the time
800  Fw::Time _logTime;
801  if (this->isConnected_Time_OutputPort(0)) {
802  this->Time_out(0, _logTime);
803  }
804 
805  const FwEventIdType _id = this->getIdBase() + EVENTID_RATEGROUPSTARTED;
806 
807  // Emit the event on the log port
808  if (this->isConnected_Log_OutputPort(0)) {
809  Fw::LogBuffer _logBuff;
810 
811 #if FW_AMPCS_COMPATIBLE
813  // Serialize the number of arguments
814  _status = _logBuff.serializeFrom(static_cast<U8>(0));
815  FW_ASSERT(
816  _status == Fw::FW_SERIALIZE_OK,
817  static_cast<FwAssertArgType>(_status)
818  );
819 #endif
820 
821  this->Log_out(
822  0,
823  _id,
824  _logTime,
826  _logBuff
827  );
828  }
829 
830  // Emit the event on the text log port
831 #if FW_ENABLE_TEXT_LOGGING
832  if (this->isConnected_LogText_OutputPort(0)) {
833 #if FW_OBJECT_NAMES == 1
834  const char* _formatString =
835  "(%s) %s: Rate group started.";
836 #else
837  const char* _formatString =
838  "%s: Rate group started.";
839 #endif
840 
841  Fw::TextLogString _logString;
842  (void) _logString.format(
843  _formatString,
844 #if FW_OBJECT_NAMES == 1
845  this->m_objName.toChar(),
846 #endif
847  "RateGroupStarted "
848  );
849 
850  this->LogText_out(
851  0,
852  _id,
853  _logTime,
855  _logString
856  );
857  }
858 #endif
859  }
860 
863  {
864  // Get the time
865  Fw::Time _logTime;
866  if (this->isConnected_Time_OutputPort(0)) {
867  this->Time_out(0, _logTime);
868  }
869 
870  const FwEventIdType _id = this->getIdBase() + EVENTID_RATEGROUPCYCLESLIP;
871 
872  // Emit the event on the log port
873  if (this->isConnected_Log_OutputPort(0)) {
874  Fw::LogBuffer _logBuff;
876 
877 #if FW_AMPCS_COMPATIBLE
878  // Serialize the number of arguments
879  _status = _logBuff.serializeFrom(static_cast<U8>(1));
880  FW_ASSERT(
881  _status == Fw::FW_SERIALIZE_OK,
882  static_cast<FwAssertArgType>(_status)
883  );
884 #endif
885 
886 #if FW_AMPCS_COMPATIBLE
887  // Serialize the argument size
888  _status = _logBuff.serializeFrom(
889  static_cast<U8>(sizeof(U32))
890  );
891  FW_ASSERT(
892  _status == Fw::FW_SERIALIZE_OK,
893  static_cast<FwAssertArgType>(_status)
894  );
895 #endif
896  _status = _logBuff.serializeFrom(cycle);
897  FW_ASSERT(
898  _status == Fw::FW_SERIALIZE_OK,
899  static_cast<FwAssertArgType>(_status)
900  );
901 
902  this->Log_out(
903  0,
904  _id,
905  _logTime,
907  _logBuff
908  );
909  }
910 
911  // Emit the event on the text log port
912 #if FW_ENABLE_TEXT_LOGGING
913  if (this->isConnected_LogText_OutputPort(0)) {
914 #if FW_OBJECT_NAMES == 1
915  const char* _formatString =
916  "(%s) %s: Rate group cycle slipped on cycle %" PRIu32 "";
917 #else
918  const char* _formatString =
919  "%s: Rate group cycle slipped on cycle %" PRIu32 "";
920 #endif
921 
922  Fw::TextLogString _logString;
923  (void) _logString.format(
924  _formatString,
925 #if FW_OBJECT_NAMES == 1
926  this->m_objName.toChar(),
927 #endif
928  "RateGroupCycleSlip ",
929  cycle
930  );
931 
932  this->LogText_out(
933  0,
934  _id,
935  _logTime,
937  _logString
938  );
939  }
940 #endif
941  }
942 
945  {
946  // Check throttle value
947  if (this->m_RateGroupTimeGetErrorThrottle >= EVENTID_RATEGROUPTIMEGETERROR_THROTTLE) {
948  return;
949  }
950  else {
951  this->m_RateGroupTimeGetErrorThrottle++;
952  }
953 
954  // Get the time
955  Fw::Time _logTime;
956  if (this->isConnected_Time_OutputPort(0)) {
957  this->Time_out(0, _logTime);
958  }
959 
961 
962  // Emit the event on the log port
963  if (this->isConnected_Log_OutputPort(0)) {
964  Fw::LogBuffer _logBuff;
966 
967 #if FW_AMPCS_COMPATIBLE
968  // Serialize the number of arguments
969  _status = _logBuff.serializeFrom(static_cast<U8>(1));
970  FW_ASSERT(
971  _status == Fw::FW_SERIALIZE_OK,
972  static_cast<FwAssertArgType>(_status)
973  );
974 #endif
975 
976 #if FW_AMPCS_COMPATIBLE
977  // Serialize the argument size
978  _status = _logBuff.serializeFrom(
979  static_cast<U8>(Os::RawTimeStatus::SERIALIZED_SIZE)
980  );
981  FW_ASSERT(
982  _status == Fw::FW_SERIALIZE_OK,
983  static_cast<FwAssertArgType>(_status)
984  );
985 #endif
986  _status = _logBuff.serializeFrom(status);
987  FW_ASSERT(
988  _status == Fw::FW_SERIALIZE_OK,
989  static_cast<FwAssertArgType>(_status)
990  );
991 
992  this->Log_out(
993  0,
994  _id,
995  _logTime,
997  _logBuff
998  );
999  }
1000 
1001  // Emit the event on the text log port
1002 #if FW_ENABLE_TEXT_LOGGING
1003  if (this->isConnected_LogText_OutputPort(0)) {
1004 #if FW_OBJECT_NAMES == 1
1005  const char* _formatString =
1006  "(%s) %s: Rate group failed to read cycle end time with status %s";
1007 #else
1008  const char* _formatString =
1009  "%s: Rate group failed to read cycle end time with status %s";
1010 #endif
1011 
1012  Fw::String statusStr;
1013  status.toString(statusStr);
1014 
1015  Fw::TextLogString _logString;
1016  (void) _logString.format(
1017  _formatString,
1018 #if FW_OBJECT_NAMES == 1
1019  this->m_objName.toChar(),
1020 #endif
1021  "RateGroupTimeGetError ",
1022  statusStr.toChar()
1023  );
1024 
1025  this->LogText_out(
1026  0,
1027  _id,
1028  _logTime,
1030  _logString
1031  );
1032  }
1033 #endif
1034  }
1035 
1036  // ----------------------------------------------------------------------
1037  // Event throttle reset functions
1038  // ----------------------------------------------------------------------
1039 
1042  {
1043  // Reset throttle counter
1044  this->m_RateGroupTimeGetErrorThrottle = 0;
1045  }
1046 
1047  // ----------------------------------------------------------------------
1048  // Telemetry serialized write
1049  // ----------------------------------------------------------------------
1050 
1053  FwChanIdType id,
1054  Fw::TlmBuffer& _tlmBuff,
1055  Fw::Time _tlmTime
1056  ) const
1057  {
1058  if (this->isConnected_Tlm_OutputPort(0)) {
1059  if (
1060  this->isConnected_Time_OutputPort(0) &&
1061  (_tlmTime == Fw::ZERO_TIME)
1062  ) {
1063  this->Time_out(0, _tlmTime);
1064  }
1065 
1066  FwChanIdType _id;
1067  _id = this->getIdBase() + id;
1068 
1069  this->Tlm_out(
1070  0,
1071  _id,
1072  _tlmTime,
1073  _tlmBuff
1074  );
1075  }
1076  }
1077 
1078  // ----------------------------------------------------------------------
1079  // Telemetry write functions
1080  // ----------------------------------------------------------------------
1081 
1084  U32 arg,
1085  Fw::Time _tlmTime
1086  )
1087  {
1088  // Check to see if it is the first time
1089  if (not this->m_first_update_RgMaxTime) {
1090  // Check to see if value has changed. If not, don't write it.
1091  if (arg == this->m_last_RgMaxTime) {
1092  return;
1093  }
1094  else {
1095  this->m_last_RgMaxTime = arg;
1096  }
1097  }
1098  else {
1099  this->m_first_update_RgMaxTime = false;
1100  this->m_last_RgMaxTime = arg;
1101  }
1102 
1103  if (this->isConnected_Tlm_OutputPort(0)) {
1104  Fw::TlmBuffer _tlmBuff;
1105  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
1106  FW_ASSERT(
1107  _stat == Fw::FW_SERIALIZE_OK,
1108  static_cast<FwAssertArgType>(_stat)
1109  );
1110 
1111  this->tlmWrite(
1113  _tlmBuff,
1114  _tlmTime
1115  );
1116  }
1117  }
1118 
1121  U32 arg,
1122  Fw::Time _tlmTime
1123  )
1124  {
1125  // Check to see if it is the first time
1126  if (not this->m_first_update_RgCycleSlips) {
1127  // Check to see if value has changed. If not, don't write it.
1128  if (arg == this->m_last_RgCycleSlips) {
1129  return;
1130  }
1131  else {
1132  this->m_last_RgCycleSlips = arg;
1133  }
1134  }
1135  else {
1136  this->m_first_update_RgCycleSlips = false;
1137  this->m_last_RgCycleSlips = arg;
1138  }
1139 
1140  if (this->isConnected_Tlm_OutputPort(0)) {
1141  Fw::TlmBuffer _tlmBuff;
1142  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
1143  FW_ASSERT(
1144  _stat == Fw::FW_SERIALIZE_OK,
1145  static_cast<FwAssertArgType>(_stat)
1146  );
1147 
1148  this->tlmWrite(
1150  _tlmBuff,
1151  _tlmTime
1152  );
1153  }
1154  }
1155 
1156  // ----------------------------------------------------------------------
1157  // Time
1158  // ----------------------------------------------------------------------
1159 
1161  getTime() const
1162  {
1163  if (this->isConnected_Time_OutputPort(0)) {
1164  Fw::Time _time;
1165  this->Time_out(0, _time);
1166  return _time;
1167  }
1168  else {
1169  return Fw::Time(TimeBase::TB_NONE, 0, 0);
1170  }
1171  }
1172 
1173  // ----------------------------------------------------------------------
1174  // Message dispatch functions
1175  // ----------------------------------------------------------------------
1176 
1177  Fw::QueuedComponentBase::MsgDispatchStatus ActiveRateGroupComponentBase ::
1178  doDispatch()
1179  {
1180  ComponentIpcSerializableBuffer _msg;
1181  FwQueuePriorityType _priority = 0;
1182 
1183  Os::Queue::Status _msgStatus = this->m_queue.receive(
1184  _msg,
1186  _priority
1187  );
1188  FW_ASSERT(
1189  _msgStatus == Os::Queue::OP_OK,
1190  static_cast<FwAssertArgType>(_msgStatus)
1191  );
1192 
1193  // Reset to beginning of buffer
1194  _msg.resetDeser();
1195 
1196  FwEnumStoreType _desMsg = 0;
1197  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
1198  FW_ASSERT(
1199  _deserStatus == Fw::FW_SERIALIZE_OK,
1200  static_cast<FwAssertArgType>(_deserStatus)
1201  );
1202 
1203  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
1204 
1205  if (_msgType == ACTIVERATEGROUP_COMPONENT_EXIT) {
1206  return MSG_DISPATCH_EXIT;
1207  }
1208 
1209  FwIndexType portNum = 0;
1210  _deserStatus = _msg.deserializeTo(portNum);
1211  FW_ASSERT(
1212  _deserStatus == Fw::FW_SERIALIZE_OK,
1213  static_cast<FwAssertArgType>(_deserStatus)
1214  );
1215 
1216  switch (_msgType) {
1217  // Handle async input port CycleIn
1218  case CYCLEIN_CYCLE: {
1219  // Deserialize argument cycleStart
1220  Os::RawTime cycleStart;
1221  _deserStatus = _msg.deserializeTo(cycleStart);
1222  FW_ASSERT(
1223  _deserStatus == Fw::FW_SERIALIZE_OK,
1224  static_cast<FwAssertArgType>(_deserStatus)
1225  );
1226  // Call handler function
1227  this->CycleIn_handler(
1228  portNum,
1229  cycleStart
1230  );
1231 
1232  break;
1233  }
1234 
1235  // Handle async input port PingIn
1236  case PINGIN_PING: {
1237  // Deserialize argument key
1238  U32 key;
1239  _deserStatus = _msg.deserializeTo(key);
1240  FW_ASSERT(
1241  _deserStatus == Fw::FW_SERIALIZE_OK,
1242  static_cast<FwAssertArgType>(_deserStatus)
1243  );
1244  // Call handler function
1245  this->PingIn_handler(
1246  portNum,
1247  key
1248  );
1249 
1250  break;
1251  }
1252 
1253  default:
1254  return MSG_DISPATCH_ERROR;
1255  }
1256 
1257  return MSG_DISPATCH_OK;
1258  }
1259 
1260  // ----------------------------------------------------------------------
1261  // Calls for messages received on typed input ports
1262  // ----------------------------------------------------------------------
1263 
1264  void ActiveRateGroupComponentBase ::
1265  m_p_CycleIn_in(
1266  Fw::PassiveComponentBase* callComp,
1267  FwIndexType portNum,
1268  Os::RawTime& cycleStart
1269  )
1270  {
1271  FW_ASSERT(callComp != nullptr);
1272  ActiveRateGroupComponentBase* compPtr = static_cast<ActiveRateGroupComponentBase*>(callComp);
1273  compPtr->CycleIn_handlerBase(
1274  portNum,
1275  cycleStart
1276  );
1277  }
1278 
1279  void ActiveRateGroupComponentBase ::
1280  m_p_PingIn_in(
1281  Fw::PassiveComponentBase* callComp,
1282  FwIndexType portNum,
1283  U32 key
1284  )
1285  {
1286  FW_ASSERT(callComp != nullptr);
1287  ActiveRateGroupComponentBase* compPtr = static_cast<ActiveRateGroupComponentBase*>(callComp);
1288  compPtr->PingIn_handlerBase(
1289  portNum,
1290  key
1291  );
1292  }
1293 
1294 #if !FW_DIRECT_PORT_CALLS
1295 
1296  // ----------------------------------------------------------------------
1297  // Invocation functions for special output ports
1298  // ----------------------------------------------------------------------
1299 
1300  void ActiveRateGroupComponentBase ::
1301  Log_out(
1302  FwIndexType portNum,
1303  FwEventIdType id,
1304  Fw::Time& timeTag,
1305  const Fw::LogSeverity& severity,
1306  Fw::LogBuffer& args
1307  ) const
1308  {
1309  FW_ASSERT(
1310  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
1311  static_cast<FwAssertArgType>(portNum)
1312  );
1313 
1314  FW_ASSERT(
1315  this->m_Log_OutputPort[portNum].isConnected(),
1316  static_cast<FwAssertArgType>(portNum)
1317  );
1318  this->m_Log_OutputPort[portNum].invoke(
1319  id,
1320  timeTag,
1321  severity,
1322  args
1323  );
1324  }
1325 
1326 #if FW_ENABLE_TEXT_LOGGING
1327 
1328  void ActiveRateGroupComponentBase ::
1329  LogText_out(
1330  FwIndexType portNum,
1331  FwEventIdType id,
1332  Fw::Time& timeTag,
1333  const Fw::LogSeverity& severity,
1334  Fw::TextLogString& text
1335  ) const
1336  {
1337  FW_ASSERT(
1338  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
1339  static_cast<FwAssertArgType>(portNum)
1340  );
1341 
1342  FW_ASSERT(
1343  this->m_LogText_OutputPort[portNum].isConnected(),
1344  static_cast<FwAssertArgType>(portNum)
1345  );
1346  this->m_LogText_OutputPort[portNum].invoke(
1347  id,
1348  timeTag,
1349  severity,
1350  text
1351  );
1352  }
1353 
1354 #endif
1355 
1356  void ActiveRateGroupComponentBase ::
1357  Time_out(
1358  FwIndexType portNum,
1359  Fw::Time& time
1360  ) const
1361  {
1362  FW_ASSERT(
1363  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
1364  static_cast<FwAssertArgType>(portNum)
1365  );
1366 
1367  FW_ASSERT(
1368  this->m_Time_OutputPort[portNum].isConnected(),
1369  static_cast<FwAssertArgType>(portNum)
1370  );
1371  this->m_Time_OutputPort[portNum].invoke(
1372  time
1373  );
1374  }
1375 
1376  void ActiveRateGroupComponentBase ::
1377  Tlm_out(
1378  FwIndexType portNum,
1379  FwChanIdType id,
1380  Fw::Time& timeTag,
1381  Fw::TlmBuffer& val
1382  ) const
1383  {
1384  FW_ASSERT(
1385  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
1386  static_cast<FwAssertArgType>(portNum)
1387  );
1388 
1389  FW_ASSERT(
1390  this->m_Tlm_OutputPort[portNum].isConnected(),
1391  static_cast<FwAssertArgType>(portNum)
1392  );
1393  this->m_Tlm_OutputPort[portNum].invoke(
1394  id,
1395  timeTag,
1396  val
1397  );
1398  }
1399 
1400 #endif
1401 
1402 }
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:157
void tlmWrite_RgCycleSlips(U32 arg, Fw::Time _tlmTime=Fw::Time())
Warning event that rate group has had a cycle slip.
Operation succeeded.
Definition: Os.hpp:27
FPP shadow-enum representing Os::RawTime::Status.
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:71
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CyclePortAc.cpp:79
I32 FwEnumStoreType
static constexpr FwIndexType getNum_Log_OutputPorts()
Status
status returned from the queue send function
Definition: Queue.hpp:30
message to exit active component task
void log_WARNING_HI_RateGroupTimeGetError(const Os::RawTimeStatus &status)
void PingOut_out(FwIndexType portNum, U32 key) const
Invoke output port PingOut.
Warning event that reading the cycle end time failed.
bool isConnected_Tlm_OutputPort(FwIndexType portNum) const
static constexpr FwIndexType getNum_Time_OutputPorts()
void invoke(U32 key) const
Invoke a port connection.
Definition: PingPortAc.cpp:170
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:171
No time base has been established (Required)
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
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].
void addCallPort(InputTlmPort *callPort)
Register an input port.
Definition: TlmPortAc.cpp:177
void init()
Object initializer.
Definition: ObjBase.cpp:24
ActiveRateGroupComponentBase(const char *compName="")
Construct ActiveRateGroupComponentBase object.
SerializeStatus
forward declaration for string
bool isConnected_Time_OutputPort(FwIndexType portNum) const
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.
bool isConnected_PingOut_OutputPort(FwIndexType portNum) const
static constexpr FwSizeType CAPACITY
Definition: PingPortAc.hpp:34
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:40
void init()
Initialization function.
Definition: TimePortAc.cpp:151
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize)
void log_WARNING_HI_RateGroupTimeGetError_ThrottleClear()
Reset throttle value for RateGroupTimeGetError.
void invoke(U32 context) const
Invoke a port connection.
void init()
Initialization function.
Definition: PingPortAc.cpp:151
void invoke(Fw::Time &time) const
Invoke a port connection.
Definition: TimePortAc.cpp:170
FwIdType FwChanIdType
The type of a telemetry channel identifier.
static constexpr FwIndexType getNum_PingOut_OutputPorts()
void addCallPort(InputPingPort *callPort)
Register an input port.
Definition: PingPortAc.cpp:157
Status send(const U8 *buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType) override
send a message into the queue through delegate
Definition: Queue.cpp:54
void tlmWrite_RgMaxTime(U32 arg, Fw::Time _tlmTime=Fw::Time())
A serious but recoverable event.
void invoke(FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) const
Invoke a port connection.
Definition: TlmPortAc.cpp:190
const char * toChar() const
Convert to a C-style char*.
bool isConnected() const
Definition: PortBase.cpp:38
Enum representing event severity.
#define PRI_FwIndexType
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:58
void init()
Initialization function.
Definition: LogPortAc.cpp:180
void setPortNum(FwIndexType portNum)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:54
BlockingType
message type
Definition: Queue.hpp:46
void init()
Initialization function.
Definition: CyclePortAc.cpp:73
bool isConnected_Log_OutputPort(FwIndexType portNum) const
void RateGroupMemberOut_out(FwIndexType portNum, U32 context) const
Invoke output port RateGroupMemberOut.
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 connection.
Definition: LogPortAc.cpp:199
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
static constexpr FwSizeType CAPACITY
Definition: CyclePortAc.hpp:35
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:186
void init()
Initialization function.
static constexpr FwIndexType getNum_CycleIn_InputPorts()
void tlmWrite(FwChanIdType id, Fw::TlmBuffer &_tlmBuff, Fw::Time _tlmTime=Fw::Time()) const
void incNumMsgDropped()
increment the number of messages dropped
void init()
Initialization function.
Definition: PingPortAc.cpp:73
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:57
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: PingPortAc.cpp:79
Message will return with status when space is unavailable.
Definition: Queue.hpp:48
bool isConnected_RateGroupMemberOut_OutputPort(FwIndexType portNum) const
Implementation of malloc based allocator.
Svc::InputCyclePort * get_CycleIn_InputPort(FwIndexType portNum)
The size of the serial representation.
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.