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  if (qStatus == Os::Queue::Status::FULL) {
713  this->incNumMsgDropped();
714  return;
715  }
716 
717  FW_ASSERT(
718  qStatus == Os::Queue::OP_OK,
719  static_cast<FwAssertArgType>(qStatus)
720  );
721  }
722 
723  // ----------------------------------------------------------------------
724  // Pre-message hooks for typed async input ports
725  //
726  // Each of these functions is invoked just before processing a message
727  // on the corresponding port. By default, they do nothing. You can
728  // override them to provide specific pre-message behavior.
729  // ----------------------------------------------------------------------
730 
733  FwIndexType portNum,
734  Os::RawTime& cycleStart
735  )
736  {
737  // Default: no-op
738  }
739 
742  FwIndexType portNum,
743  U32 key
744  )
745  {
746  // Default: no-op
747  }
748 
749 #if !FW_DIRECT_PORT_CALLS
750 
751  // ----------------------------------------------------------------------
752  // Invocation functions for typed output ports
753  // ----------------------------------------------------------------------
754 
757  FwIndexType portNum,
758  U32 key
759  ) const
760  {
761  FW_ASSERT(
762  (0 <= portNum) && (portNum < this->getNum_PingOut_OutputPorts()),
763  static_cast<FwAssertArgType>(portNum)
764  );
765 
766  FW_ASSERT(
767  this->m_PingOut_OutputPort[portNum].isConnected(),
768  static_cast<FwAssertArgType>(portNum)
769  );
770  this->m_PingOut_OutputPort[portNum].invoke(
771  key
772  );
773  }
774 
777  FwIndexType portNum,
778  U32 context
779  ) const
780  {
781  FW_ASSERT(
782  (0 <= portNum) && (portNum < this->getNum_RateGroupMemberOut_OutputPorts()),
783  static_cast<FwAssertArgType>(portNum)
784  );
785 
786  FW_ASSERT(
787  this->m_RateGroupMemberOut_OutputPort[portNum].isConnected(),
788  static_cast<FwAssertArgType>(portNum)
789  );
790  this->m_RateGroupMemberOut_OutputPort[portNum].invoke(
791  context
792  );
793  }
794 
795 #endif
796 
797  // ----------------------------------------------------------------------
798  // Event logging functions
799  // ----------------------------------------------------------------------
800 
803  {
804  // Get the time
805  Fw::Time _logTime;
806  if (this->isConnected_Time_OutputPort(0)) {
807  this->Time_out(0, _logTime);
808  }
809 
810  const FwEventIdType _id = this->getIdBase() + EVENTID_RATEGROUPSTARTED;
811 
812  // Emit the event on the log port
813  if (this->isConnected_Log_OutputPort(0)) {
814  Fw::LogBuffer _logBuff;
815 
816 #if FW_AMPCS_COMPATIBLE
818  // Serialize the number of arguments
819  _status = _logBuff.serializeFrom(static_cast<U8>(0));
820  FW_ASSERT(
821  _status == Fw::FW_SERIALIZE_OK,
822  static_cast<FwAssertArgType>(_status)
823  );
824 #endif
825 
826  this->Log_out(
827  0,
828  _id,
829  _logTime,
831  _logBuff
832  );
833  }
834 
835  // Emit the event on the text log port
836 #if FW_ENABLE_TEXT_LOGGING
837  if (this->isConnected_LogText_OutputPort(0)) {
838 #if FW_OBJECT_NAMES == 1
839  const char* _formatString =
840  "(%s) %s: Rate group started.";
841 #else
842  const char* _formatString =
843  "%s: Rate group started.";
844 #endif
845 
846  Fw::TextLogString _logString;
847  (void) _logString.format(
848  _formatString,
849 #if FW_OBJECT_NAMES == 1
850  this->m_objName.toChar(),
851 #endif
852  "RateGroupStarted "
853  );
854 
855  this->LogText_out(
856  0,
857  _id,
858  _logTime,
860  _logString
861  );
862  }
863 #endif
864  }
865 
868  {
869  // Get the time
870  Fw::Time _logTime;
871  if (this->isConnected_Time_OutputPort(0)) {
872  this->Time_out(0, _logTime);
873  }
874 
875  const FwEventIdType _id = this->getIdBase() + EVENTID_RATEGROUPCYCLESLIP;
876 
877  // Emit the event on the log port
878  if (this->isConnected_Log_OutputPort(0)) {
879  Fw::LogBuffer _logBuff;
881 
882 #if FW_AMPCS_COMPATIBLE
883  // Serialize the number of arguments
884  _status = _logBuff.serializeFrom(static_cast<U8>(1));
885  FW_ASSERT(
886  _status == Fw::FW_SERIALIZE_OK,
887  static_cast<FwAssertArgType>(_status)
888  );
889 #endif
890 
891 #if FW_AMPCS_COMPATIBLE
892  // Serialize the argument size
893  _status = _logBuff.serializeFrom(
894  static_cast<U8>(sizeof(U32))
895  );
896  FW_ASSERT(
897  _status == Fw::FW_SERIALIZE_OK,
898  static_cast<FwAssertArgType>(_status)
899  );
900 #endif
901  _status = _logBuff.serializeFrom(cycle);
902  FW_ASSERT(
903  _status == Fw::FW_SERIALIZE_OK,
904  static_cast<FwAssertArgType>(_status)
905  );
906 
907  this->Log_out(
908  0,
909  _id,
910  _logTime,
912  _logBuff
913  );
914  }
915 
916  // Emit the event on the text log port
917 #if FW_ENABLE_TEXT_LOGGING
918  if (this->isConnected_LogText_OutputPort(0)) {
919 #if FW_OBJECT_NAMES == 1
920  const char* _formatString =
921  "(%s) %s: Rate group cycle slipped on cycle %" PRIu32 "";
922 #else
923  const char* _formatString =
924  "%s: Rate group cycle slipped on cycle %" PRIu32 "";
925 #endif
926 
927  Fw::TextLogString _logString;
928  (void) _logString.format(
929  _formatString,
930 #if FW_OBJECT_NAMES == 1
931  this->m_objName.toChar(),
932 #endif
933  "RateGroupCycleSlip ",
934  cycle
935  );
936 
937  this->LogText_out(
938  0,
939  _id,
940  _logTime,
942  _logString
943  );
944  }
945 #endif
946  }
947 
950  {
951  // Check throttle value
952  if (this->m_RateGroupTimeGetErrorThrottle >= EVENTID_RATEGROUPTIMEGETERROR_THROTTLE) {
953  return;
954  }
955  else {
956  this->m_RateGroupTimeGetErrorThrottle++;
957  }
958 
959  // Get the time
960  Fw::Time _logTime;
961  if (this->isConnected_Time_OutputPort(0)) {
962  this->Time_out(0, _logTime);
963  }
964 
966 
967  // Emit the event on the log port
968  if (this->isConnected_Log_OutputPort(0)) {
969  Fw::LogBuffer _logBuff;
971 
972 #if FW_AMPCS_COMPATIBLE
973  // Serialize the number of arguments
974  _status = _logBuff.serializeFrom(static_cast<U8>(1));
975  FW_ASSERT(
976  _status == Fw::FW_SERIALIZE_OK,
977  static_cast<FwAssertArgType>(_status)
978  );
979 #endif
980 
981 #if FW_AMPCS_COMPATIBLE
982  // Serialize the argument size
983  _status = _logBuff.serializeFrom(
984  static_cast<U8>(Os::RawTimeStatus::SERIALIZED_SIZE)
985  );
986  FW_ASSERT(
987  _status == Fw::FW_SERIALIZE_OK,
988  static_cast<FwAssertArgType>(_status)
989  );
990 #endif
991  _status = _logBuff.serializeFrom(status);
992  FW_ASSERT(
993  _status == Fw::FW_SERIALIZE_OK,
994  static_cast<FwAssertArgType>(_status)
995  );
996 
997  this->Log_out(
998  0,
999  _id,
1000  _logTime,
1002  _logBuff
1003  );
1004  }
1005 
1006  // Emit the event on the text log port
1007 #if FW_ENABLE_TEXT_LOGGING
1008  if (this->isConnected_LogText_OutputPort(0)) {
1009 #if FW_OBJECT_NAMES == 1
1010  const char* _formatString =
1011  "(%s) %s: Rate group failed to read cycle end time with status %s";
1012 #else
1013  const char* _formatString =
1014  "%s: Rate group failed to read cycle end time with status %s";
1015 #endif
1016 
1017  Fw::String statusStr;
1018  status.toString(statusStr);
1019 
1020  Fw::TextLogString _logString;
1021  (void) _logString.format(
1022  _formatString,
1023 #if FW_OBJECT_NAMES == 1
1024  this->m_objName.toChar(),
1025 #endif
1026  "RateGroupTimeGetError ",
1027  statusStr.toChar()
1028  );
1029 
1030  this->LogText_out(
1031  0,
1032  _id,
1033  _logTime,
1035  _logString
1036  );
1037  }
1038 #endif
1039  }
1040 
1041  // ----------------------------------------------------------------------
1042  // Event throttle reset functions
1043  // ----------------------------------------------------------------------
1044 
1047  {
1048  // Reset throttle counter
1049  this->m_RateGroupTimeGetErrorThrottle = 0;
1050  }
1051 
1052  // ----------------------------------------------------------------------
1053  // Telemetry serialized write
1054  // ----------------------------------------------------------------------
1055 
1058  FwChanIdType id,
1059  Fw::TlmBuffer& _tlmBuff,
1060  Fw::Time _tlmTime
1061  ) const
1062  {
1063  if (this->isConnected_Tlm_OutputPort(0)) {
1064  if (
1065  this->isConnected_Time_OutputPort(0) &&
1066  (_tlmTime == Fw::ZERO_TIME)
1067  ) {
1068  this->Time_out(0, _tlmTime);
1069  }
1070 
1071  FwChanIdType _id;
1072  _id = this->getIdBase() + id;
1073 
1074  this->Tlm_out(
1075  0,
1076  _id,
1077  _tlmTime,
1078  _tlmBuff
1079  );
1080  }
1081  }
1082 
1083  // ----------------------------------------------------------------------
1084  // Telemetry write functions
1085  // ----------------------------------------------------------------------
1086 
1089  U32 arg,
1090  Fw::Time _tlmTime
1091  )
1092  {
1093  // Check to see if it is the first time
1094  if (not this->m_first_update_RgMaxTime) {
1095  // Check to see if value has changed. If not, don't write it.
1096  if (arg == this->m_last_RgMaxTime) {
1097  return;
1098  }
1099  else {
1100  this->m_last_RgMaxTime = arg;
1101  }
1102  }
1103  else {
1104  this->m_first_update_RgMaxTime = false;
1105  this->m_last_RgMaxTime = arg;
1106  }
1107 
1108  if (this->isConnected_Tlm_OutputPort(0)) {
1109  Fw::TlmBuffer _tlmBuff;
1110  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
1111  FW_ASSERT(
1112  _stat == Fw::FW_SERIALIZE_OK,
1113  static_cast<FwAssertArgType>(_stat)
1114  );
1115 
1116  this->tlmWrite(
1118  _tlmBuff,
1119  _tlmTime
1120  );
1121  }
1122  }
1123 
1126  U32 arg,
1127  Fw::Time _tlmTime
1128  )
1129  {
1130  // Check to see if it is the first time
1131  if (not this->m_first_update_RgCycleSlips) {
1132  // Check to see if value has changed. If not, don't write it.
1133  if (arg == this->m_last_RgCycleSlips) {
1134  return;
1135  }
1136  else {
1137  this->m_last_RgCycleSlips = arg;
1138  }
1139  }
1140  else {
1141  this->m_first_update_RgCycleSlips = false;
1142  this->m_last_RgCycleSlips = arg;
1143  }
1144 
1145  if (this->isConnected_Tlm_OutputPort(0)) {
1146  Fw::TlmBuffer _tlmBuff;
1147  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
1148  FW_ASSERT(
1149  _stat == Fw::FW_SERIALIZE_OK,
1150  static_cast<FwAssertArgType>(_stat)
1151  );
1152 
1153  this->tlmWrite(
1155  _tlmBuff,
1156  _tlmTime
1157  );
1158  }
1159  }
1160 
1161  // ----------------------------------------------------------------------
1162  // Time
1163  // ----------------------------------------------------------------------
1164 
1166  getTime() const
1167  {
1168  if (this->isConnected_Time_OutputPort(0)) {
1169  Fw::Time _time;
1170  this->Time_out(0, _time);
1171  return _time;
1172  }
1173  else {
1174  return Fw::Time(TimeBase::TB_NONE, 0, 0);
1175  }
1176  }
1177 
1178  // ----------------------------------------------------------------------
1179  // Message dispatch functions
1180  // ----------------------------------------------------------------------
1181 
1182  Fw::QueuedComponentBase::MsgDispatchStatus ActiveRateGroupComponentBase ::
1183  doDispatch()
1184  {
1185  ComponentIpcSerializableBuffer _msg;
1186  FwQueuePriorityType _priority = 0;
1187 
1188  Os::Queue::Status _msgStatus = this->m_queue.receive(
1189  _msg,
1191  _priority
1192  );
1193  FW_ASSERT(
1194  _msgStatus == Os::Queue::OP_OK,
1195  static_cast<FwAssertArgType>(_msgStatus)
1196  );
1197 
1198  // Reset to beginning of buffer
1199  _msg.resetDeser();
1200 
1201  FwEnumStoreType _desMsg = 0;
1202  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
1203  FW_ASSERT(
1204  _deserStatus == Fw::FW_SERIALIZE_OK,
1205  static_cast<FwAssertArgType>(_deserStatus)
1206  );
1207 
1208  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
1209 
1210  if (_msgType == ACTIVERATEGROUP_COMPONENT_EXIT) {
1211  return MSG_DISPATCH_EXIT;
1212  }
1213 
1214  FwIndexType portNum = 0;
1215  _deserStatus = _msg.deserializeTo(portNum);
1216  FW_ASSERT(
1217  _deserStatus == Fw::FW_SERIALIZE_OK,
1218  static_cast<FwAssertArgType>(_deserStatus)
1219  );
1220 
1221  switch (_msgType) {
1222  // Handle async input port CycleIn
1223  case CYCLEIN_CYCLE: {
1224  // Deserialize argument cycleStart
1225  Os::RawTime cycleStart;
1226  _deserStatus = _msg.deserializeTo(cycleStart);
1227  FW_ASSERT(
1228  _deserStatus == Fw::FW_SERIALIZE_OK,
1229  static_cast<FwAssertArgType>(_deserStatus)
1230  );
1231  // Call handler function
1232  this->CycleIn_handler(
1233  portNum,
1234  cycleStart
1235  );
1236 
1237  break;
1238  }
1239 
1240  // Handle async input port PingIn
1241  case PINGIN_PING: {
1242  // Deserialize argument key
1243  U32 key;
1244  _deserStatus = _msg.deserializeTo(key);
1245  FW_ASSERT(
1246  _deserStatus == Fw::FW_SERIALIZE_OK,
1247  static_cast<FwAssertArgType>(_deserStatus)
1248  );
1249  // Call handler function
1250  this->PingIn_handler(
1251  portNum,
1252  key
1253  );
1254 
1255  break;
1256  }
1257 
1258  default:
1259  return MSG_DISPATCH_ERROR;
1260  }
1261 
1262  return MSG_DISPATCH_OK;
1263  }
1264 
1265  // ----------------------------------------------------------------------
1266  // Calls for messages received on typed input ports
1267  // ----------------------------------------------------------------------
1268 
1269  void ActiveRateGroupComponentBase ::
1270  m_p_CycleIn_in(
1271  Fw::PassiveComponentBase* callComp,
1272  FwIndexType portNum,
1273  Os::RawTime& cycleStart
1274  )
1275  {
1276  FW_ASSERT(callComp != nullptr);
1277  ActiveRateGroupComponentBase* compPtr = static_cast<ActiveRateGroupComponentBase*>(callComp);
1278  compPtr->CycleIn_handlerBase(
1279  portNum,
1280  cycleStart
1281  );
1282  }
1283 
1284  void ActiveRateGroupComponentBase ::
1285  m_p_PingIn_in(
1286  Fw::PassiveComponentBase* callComp,
1287  FwIndexType portNum,
1288  U32 key
1289  )
1290  {
1291  FW_ASSERT(callComp != nullptr);
1292  ActiveRateGroupComponentBase* compPtr = static_cast<ActiveRateGroupComponentBase*>(callComp);
1293  compPtr->PingIn_handlerBase(
1294  portNum,
1295  key
1296  );
1297  }
1298 
1299 #if !FW_DIRECT_PORT_CALLS
1300 
1301  // ----------------------------------------------------------------------
1302  // Invocation functions for special output ports
1303  // ----------------------------------------------------------------------
1304 
1305  void ActiveRateGroupComponentBase ::
1306  Log_out(
1307  FwIndexType portNum,
1308  FwEventIdType id,
1309  Fw::Time& timeTag,
1310  const Fw::LogSeverity& severity,
1311  Fw::LogBuffer& args
1312  ) const
1313  {
1314  FW_ASSERT(
1315  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
1316  static_cast<FwAssertArgType>(portNum)
1317  );
1318 
1319  FW_ASSERT(
1320  this->m_Log_OutputPort[portNum].isConnected(),
1321  static_cast<FwAssertArgType>(portNum)
1322  );
1323  this->m_Log_OutputPort[portNum].invoke(
1324  id,
1325  timeTag,
1326  severity,
1327  args
1328  );
1329  }
1330 
1331 #if FW_ENABLE_TEXT_LOGGING
1332 
1333  void ActiveRateGroupComponentBase ::
1334  LogText_out(
1335  FwIndexType portNum,
1336  FwEventIdType id,
1337  Fw::Time& timeTag,
1338  const Fw::LogSeverity& severity,
1339  Fw::TextLogString& text
1340  ) const
1341  {
1342  FW_ASSERT(
1343  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
1344  static_cast<FwAssertArgType>(portNum)
1345  );
1346 
1347  FW_ASSERT(
1348  this->m_LogText_OutputPort[portNum].isConnected(),
1349  static_cast<FwAssertArgType>(portNum)
1350  );
1351  this->m_LogText_OutputPort[portNum].invoke(
1352  id,
1353  timeTag,
1354  severity,
1355  text
1356  );
1357  }
1358 
1359 #endif
1360 
1361  void ActiveRateGroupComponentBase ::
1362  Time_out(
1363  FwIndexType portNum,
1364  Fw::Time& time
1365  ) const
1366  {
1367  FW_ASSERT(
1368  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
1369  static_cast<FwAssertArgType>(portNum)
1370  );
1371 
1372  FW_ASSERT(
1373  this->m_Time_OutputPort[portNum].isConnected(),
1374  static_cast<FwAssertArgType>(portNum)
1375  );
1376  this->m_Time_OutputPort[portNum].invoke(
1377  time
1378  );
1379  }
1380 
1381  void ActiveRateGroupComponentBase ::
1382  Tlm_out(
1383  FwIndexType portNum,
1384  FwChanIdType id,
1385  Fw::Time& timeTag,
1386  Fw::TlmBuffer& val
1387  ) const
1388  {
1389  FW_ASSERT(
1390  (0 <= portNum) && (portNum < this->getNum_Tlm_OutputPorts()),
1391  static_cast<FwAssertArgType>(portNum)
1392  );
1393 
1394  FW_ASSERT(
1395  this->m_Tlm_OutputPort[portNum].isConnected(),
1396  static_cast<FwAssertArgType>(portNum)
1397  );
1398  this->m_Tlm_OutputPort[portNum].invoke(
1399  id,
1400  timeTag,
1401  val
1402  );
1403  }
1404 
1405 #endif
1406 
1407 }
void set_PingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to PingOut[portNum].
Serialization/Deserialization operation was successful.
Warning event that reading the cycle end time failed.
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:157
message to exit active component task
void tlmWrite_RgCycleSlips(U32 arg, Fw::Time _tlmTime=Fw::Time())
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
void log_WARNING_HI_RateGroupTimeGetError(const Os::RawTimeStatus &status)
void PingOut_out(FwIndexType portNum, U32 key) const
Invoke output port PingOut.
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.
Warning event that rate group has had a cycle slip.
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
The size of the serial representation.
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)
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.