F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
FprimeRouterComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title FprimeRouterComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for FprimeRouter component base class
5 // ======================================================================
6 
7 #include "Fw/Types/Assert.hpp"
9 #if FW_ENABLE_TEXT_LOGGING
10 #include "Fw/Types/String.hpp"
11 #endif
13 
14 namespace Svc {
15 
16  // ----------------------------------------------------------------------
17  // Component initialization
18  // ----------------------------------------------------------------------
19 
22  {
23  // Initialize base class
25 
26 #if !FW_DIRECT_PORT_CALLS
27  // Connect input port cmdResponseIn
28  for (
29  FwIndexType port = 0;
30  port < static_cast<FwIndexType>(this->getNum_cmdResponseIn_InputPorts());
31  port++
32  ) {
33  this->m_cmdResponseIn_InputPort[port].init();
34  this->m_cmdResponseIn_InputPort[port].addCallComp(
35  this,
36  m_p_cmdResponseIn_in
37  );
38  this->m_cmdResponseIn_InputPort[port].setPortNum(port);
39 
40 #if FW_OBJECT_NAMES == 1
41  Fw::ObjectName portName;
42  portName.format(
43  "%s_cmdResponseIn_InputPort[%" PRI_FwIndexType "]",
44  this->m_objName.toChar(),
45  port
46  );
47  this->m_cmdResponseIn_InputPort[port].setObjName(portName.toChar());
48 #endif
49  }
50 #endif
51 
52 #if !FW_DIRECT_PORT_CALLS
53  // Connect input port dataIn
54  for (
55  FwIndexType port = 0;
56  port < static_cast<FwIndexType>(this->getNum_dataIn_InputPorts());
57  port++
58  ) {
59  this->m_dataIn_InputPort[port].init();
60  this->m_dataIn_InputPort[port].addCallComp(
61  this,
62  m_p_dataIn_in
63  );
64  this->m_dataIn_InputPort[port].setPortNum(port);
65 
66 #if FW_OBJECT_NAMES == 1
67  Fw::ObjectName portName;
68  portName.format(
69  "%s_dataIn_InputPort[%" PRI_FwIndexType "]",
70  this->m_objName.toChar(),
71  port
72  );
73  this->m_dataIn_InputPort[port].setObjName(portName.toChar());
74 #endif
75  }
76 #endif
77 
78 #if !FW_DIRECT_PORT_CALLS
79  // Connect input port fileBufferReturnIn
80  for (
81  FwIndexType port = 0;
82  port < static_cast<FwIndexType>(this->getNum_fileBufferReturnIn_InputPorts());
83  port++
84  ) {
85  this->m_fileBufferReturnIn_InputPort[port].init();
86  this->m_fileBufferReturnIn_InputPort[port].addCallComp(
87  this,
88  m_p_fileBufferReturnIn_in
89  );
90  this->m_fileBufferReturnIn_InputPort[port].setPortNum(port);
91 
92 #if FW_OBJECT_NAMES == 1
93  Fw::ObjectName portName;
94  portName.format(
95  "%s_fileBufferReturnIn_InputPort[%" PRI_FwIndexType "]",
96  this->m_objName.toChar(),
97  port
98  );
99  this->m_fileBufferReturnIn_InputPort[port].setObjName(portName.toChar());
100 #endif
101  }
102 #endif
103 
104 #if !FW_DIRECT_PORT_CALLS
105  // Connect output port logOut
106  for (
107  FwIndexType port = 0;
108  port < static_cast<FwIndexType>(this->getNum_logOut_OutputPorts());
109  port++
110  ) {
111  this->m_logOut_OutputPort[port].init();
112 
113 #if FW_OBJECT_NAMES == 1
114  Fw::ObjectName portName;
115  portName.format(
116  "%s_logOut_OutputPort[%" PRI_FwIndexType "]",
117  this->m_objName.toChar(),
118  port
119  );
120  this->m_logOut_OutputPort[port].setObjName(portName.toChar());
121 #endif
122  }
123 #endif
124 
125 #if !FW_DIRECT_PORT_CALLS && FW_ENABLE_TEXT_LOGGING
126  // Connect output port logTextOut
127  for (
128  FwIndexType port = 0;
129  port < static_cast<FwIndexType>(this->getNum_logTextOut_OutputPorts());
130  port++
131  ) {
132  this->m_logTextOut_OutputPort[port].init();
133 
134 #if FW_OBJECT_NAMES == 1
135  Fw::ObjectName portName;
136  portName.format(
137  "%s_logTextOut_OutputPort[%" PRI_FwIndexType "]",
138  this->m_objName.toChar(),
139  port
140  );
141  this->m_logTextOut_OutputPort[port].setObjName(portName.toChar());
142 #endif
143  }
144 #endif
145 
146 #if !FW_DIRECT_PORT_CALLS
147  // Connect output port timeCaller
148  for (
149  FwIndexType port = 0;
150  port < static_cast<FwIndexType>(this->getNum_timeCaller_OutputPorts());
151  port++
152  ) {
153  this->m_timeCaller_OutputPort[port].init();
154 
155 #if FW_OBJECT_NAMES == 1
156  Fw::ObjectName portName;
157  portName.format(
158  "%s_timeCaller_OutputPort[%" PRI_FwIndexType "]",
159  this->m_objName.toChar(),
160  port
161  );
162  this->m_timeCaller_OutputPort[port].setObjName(portName.toChar());
163 #endif
164  }
165 #endif
166 
167 #if !FW_DIRECT_PORT_CALLS
168  // Connect output port commandOut
169  for (
170  FwIndexType port = 0;
171  port < static_cast<FwIndexType>(this->getNum_commandOut_OutputPorts());
172  port++
173  ) {
174  this->m_commandOut_OutputPort[port].init();
175 
176 #if FW_OBJECT_NAMES == 1
177  Fw::ObjectName portName;
178  portName.format(
179  "%s_commandOut_OutputPort[%" PRI_FwIndexType "]",
180  this->m_objName.toChar(),
181  port
182  );
183  this->m_commandOut_OutputPort[port].setObjName(portName.toChar());
184 #endif
185  }
186 #endif
187 
188 #if !FW_DIRECT_PORT_CALLS
189  // Connect output port dataReturnOut
190  for (
191  FwIndexType port = 0;
192  port < static_cast<FwIndexType>(this->getNum_dataReturnOut_OutputPorts());
193  port++
194  ) {
195  this->m_dataReturnOut_OutputPort[port].init();
196 
197 #if FW_OBJECT_NAMES == 1
198  Fw::ObjectName portName;
199  portName.format(
200  "%s_dataReturnOut_OutputPort[%" PRI_FwIndexType "]",
201  this->m_objName.toChar(),
202  port
203  );
204  this->m_dataReturnOut_OutputPort[port].setObjName(portName.toChar());
205 #endif
206  }
207 #endif
208 
209 #if !FW_DIRECT_PORT_CALLS
210  // Connect output port fileOut
211  for (
212  FwIndexType port = 0;
213  port < static_cast<FwIndexType>(this->getNum_fileOut_OutputPorts());
214  port++
215  ) {
216  this->m_fileOut_OutputPort[port].init();
217 
218 #if FW_OBJECT_NAMES == 1
219  Fw::ObjectName portName;
220  portName.format(
221  "%s_fileOut_OutputPort[%" PRI_FwIndexType "]",
222  this->m_objName.toChar(),
223  port
224  );
225  this->m_fileOut_OutputPort[port].setObjName(portName.toChar());
226 #endif
227  }
228 #endif
229 
230 #if !FW_DIRECT_PORT_CALLS
231  // Connect output port unknownDataOut
232  for (
233  FwIndexType port = 0;
234  port < static_cast<FwIndexType>(this->getNum_unknownDataOut_OutputPorts());
235  port++
236  ) {
237  this->m_unknownDataOut_OutputPort[port].init();
238 
239 #if FW_OBJECT_NAMES == 1
240  Fw::ObjectName portName;
241  portName.format(
242  "%s_unknownDataOut_OutputPort[%" PRI_FwIndexType "]",
243  this->m_objName.toChar(),
244  port
245  );
246  this->m_unknownDataOut_OutputPort[port].setObjName(portName.toChar());
247 #endif
248  }
249 #endif
250  }
251 
252 #if !FW_DIRECT_PORT_CALLS
253 
254  // ----------------------------------------------------------------------
255  // Getters for typed input ports
256  // ----------------------------------------------------------------------
257 
260  {
261  FW_ASSERT(
262  (0 <= portNum) && (portNum < this->getNum_cmdResponseIn_InputPorts()),
263  static_cast<FwAssertArgType>(portNum)
264  );
265 
266  return &this->m_cmdResponseIn_InputPort[portNum];
267  }
268 
271  {
272  FW_ASSERT(
273  (0 <= portNum) && (portNum < this->getNum_dataIn_InputPorts()),
274  static_cast<FwAssertArgType>(portNum)
275  );
276 
277  return &this->m_dataIn_InputPort[portNum];
278  }
279 
282  {
283  FW_ASSERT(
284  (0 <= portNum) && (portNum < this->getNum_fileBufferReturnIn_InputPorts()),
285  static_cast<FwAssertArgType>(portNum)
286  );
287 
288  return &this->m_fileBufferReturnIn_InputPort[portNum];
289  }
290 
291 #endif
292 
293 #if !FW_DIRECT_PORT_CALLS
294 
295  // ----------------------------------------------------------------------
296  // Connect input ports to special output ports
297  // ----------------------------------------------------------------------
298 
301  FwIndexType portNum,
302  Fw::InputLogPort* port
303  )
304  {
305  FW_ASSERT(
306  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
307  static_cast<FwAssertArgType>(portNum)
308  );
309 
310  this->m_logOut_OutputPort[portNum].addCallPort(port);
311  }
312 
313 #if FW_ENABLE_TEXT_LOGGING == 1
314 
315  void FprimeRouterComponentBase ::
316  set_logTextOut_OutputPort(
317  FwIndexType portNum,
319  )
320  {
321  FW_ASSERT(
322  (0 <= portNum) && (portNum < this->getNum_logTextOut_OutputPorts()),
323  static_cast<FwAssertArgType>(portNum)
324  );
325 
326  this->m_logTextOut_OutputPort[portNum].addCallPort(port);
327  }
328 
329 #endif
330 
333  FwIndexType portNum,
334  Fw::InputTimePort* port
335  )
336  {
337  FW_ASSERT(
338  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
339  static_cast<FwAssertArgType>(portNum)
340  );
341 
342  this->m_timeCaller_OutputPort[portNum].addCallPort(port);
343  }
344 
345 #endif
346 
347 #if !FW_DIRECT_PORT_CALLS
348 
349  // ----------------------------------------------------------------------
350  // Connect typed input ports to typed output ports
351  // ----------------------------------------------------------------------
352 
355  FwIndexType portNum,
356  Fw::InputComPort* port
357  )
358  {
359  FW_ASSERT(
360  (0 <= portNum) && (portNum < this->getNum_commandOut_OutputPorts()),
361  static_cast<FwAssertArgType>(portNum)
362  );
363 
364  this->m_commandOut_OutputPort[portNum].addCallPort(port);
365  }
366 
369  FwIndexType portNum,
371  )
372  {
373  FW_ASSERT(
374  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
375  static_cast<FwAssertArgType>(portNum)
376  );
377 
378  this->m_dataReturnOut_OutputPort[portNum].addCallPort(port);
379  }
380 
383  FwIndexType portNum,
385  )
386  {
387  FW_ASSERT(
388  (0 <= portNum) && (portNum < this->getNum_fileOut_OutputPorts()),
389  static_cast<FwAssertArgType>(portNum)
390  );
391 
392  this->m_fileOut_OutputPort[portNum].addCallPort(port);
393  }
394 
397  FwIndexType portNum,
399  )
400  {
401  FW_ASSERT(
402  (0 <= portNum) && (portNum < this->getNum_unknownDataOut_OutputPorts()),
403  static_cast<FwAssertArgType>(portNum)
404  );
405 
406  this->m_unknownDataOut_OutputPort[portNum].addCallPort(port);
407  }
408 
409 #endif
410 
411 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
412 
413  // ----------------------------------------------------------------------
414  // Connect serial input ports to special output ports
415  // ----------------------------------------------------------------------
416 
419  FwIndexType portNum,
420  Fw::InputSerializePort* port
421  )
422  {
423  FW_ASSERT(
424  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
425  static_cast<FwAssertArgType>(portNum)
426  );
427 
428  this->m_logOut_OutputPort[portNum].registerSerialPort(port);
429  }
430 
431 #if FW_ENABLE_TEXT_LOGGING == 1
432 
433  void FprimeRouterComponentBase ::
434  set_logTextOut_OutputPort(
435  FwIndexType portNum,
436  Fw::InputSerializePort* port
437  )
438  {
439  FW_ASSERT(
440  (0 <= portNum) && (portNum < this->getNum_logTextOut_OutputPorts()),
441  static_cast<FwAssertArgType>(portNum)
442  );
443 
444  this->m_logTextOut_OutputPort[portNum].registerSerialPort(port);
445  }
446 
447 #endif
448 
451  FwIndexType portNum,
452  Fw::InputSerializePort* port
453  )
454  {
455  FW_ASSERT(
456  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
457  static_cast<FwAssertArgType>(portNum)
458  );
459 
460  this->m_timeCaller_OutputPort[portNum].registerSerialPort(port);
461  }
462 
463 #endif
464 
465 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
466 
467  // ----------------------------------------------------------------------
468  // Connect serial input ports to typed output ports
469  // ----------------------------------------------------------------------
470 
473  FwIndexType portNum,
474  Fw::InputSerializePort* port
475  )
476  {
477  FW_ASSERT(
478  (0 <= portNum) && (portNum < this->getNum_commandOut_OutputPorts()),
479  static_cast<FwAssertArgType>(portNum)
480  );
481 
482  this->m_commandOut_OutputPort[portNum].registerSerialPort(port);
483  }
484 
487  FwIndexType portNum,
488  Fw::InputSerializePort* port
489  )
490  {
491  FW_ASSERT(
492  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
493  static_cast<FwAssertArgType>(portNum)
494  );
495 
496  this->m_dataReturnOut_OutputPort[portNum].registerSerialPort(port);
497  }
498 
501  FwIndexType portNum,
502  Fw::InputSerializePort* port
503  )
504  {
505  FW_ASSERT(
506  (0 <= portNum) && (portNum < this->getNum_fileOut_OutputPorts()),
507  static_cast<FwAssertArgType>(portNum)
508  );
509 
510  this->m_fileOut_OutputPort[portNum].registerSerialPort(port);
511  }
512 
515  FwIndexType portNum,
516  Fw::InputSerializePort* port
517  )
518  {
519  FW_ASSERT(
520  (0 <= portNum) && (portNum < this->getNum_unknownDataOut_OutputPorts()),
521  static_cast<FwAssertArgType>(portNum)
522  );
523 
524  this->m_unknownDataOut_OutputPort[portNum].registerSerialPort(port);
525  }
526 
527 #endif
528 
529  // ----------------------------------------------------------------------
530  // Component construction and destruction
531  // ----------------------------------------------------------------------
532 
534  FprimeRouterComponentBase(const char* compName) :
535  Fw::PassiveComponentBase(compName)
536  {
537 
538  }
539 
542  {
543 
544  }
545 
546 #if !FW_DIRECT_PORT_CALLS
547 
548  // ----------------------------------------------------------------------
549  // Connection status queries for special output ports
550  // ----------------------------------------------------------------------
551 
554  {
555  FW_ASSERT(
556  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
557  static_cast<FwAssertArgType>(portNum)
558  );
559 
560  return this->m_logOut_OutputPort[portNum].isConnected();
561  }
562 
563 #if FW_ENABLE_TEXT_LOGGING == 1
564 
565  bool FprimeRouterComponentBase ::
566  isConnected_logTextOut_OutputPort(FwIndexType portNum) const
567  {
568  FW_ASSERT(
569  (0 <= portNum) && (portNum < this->getNum_logTextOut_OutputPorts()),
570  static_cast<FwAssertArgType>(portNum)
571  );
572 
573  return this->m_logTextOut_OutputPort[portNum].isConnected();
574  }
575 
576 #endif
577 
580  {
581  FW_ASSERT(
582  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
583  static_cast<FwAssertArgType>(portNum)
584  );
585 
586  return this->m_timeCaller_OutputPort[portNum].isConnected();
587  }
588 
589 #endif
590 
591 #if !FW_DIRECT_PORT_CALLS
592 
593  // ----------------------------------------------------------------------
594  // Connection status queries for typed output ports
595  // ----------------------------------------------------------------------
596 
599  {
600  FW_ASSERT(
601  (0 <= portNum) && (portNum < this->getNum_commandOut_OutputPorts()),
602  static_cast<FwAssertArgType>(portNum)
603  );
604 
605  return this->m_commandOut_OutputPort[portNum].isConnected();
606  }
607 
610  {
611  FW_ASSERT(
612  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
613  static_cast<FwAssertArgType>(portNum)
614  );
615 
616  return this->m_dataReturnOut_OutputPort[portNum].isConnected();
617  }
618 
621  {
622  FW_ASSERT(
623  (0 <= portNum) && (portNum < this->getNum_fileOut_OutputPorts()),
624  static_cast<FwAssertArgType>(portNum)
625  );
626 
627  return this->m_fileOut_OutputPort[portNum].isConnected();
628  }
629 
632  {
633  FW_ASSERT(
634  (0 <= portNum) && (portNum < this->getNum_unknownDataOut_OutputPorts()),
635  static_cast<FwAssertArgType>(portNum)
636  );
637 
638  return this->m_unknownDataOut_OutputPort[portNum].isConnected();
639  }
640 
641 #endif
642 
643  // ----------------------------------------------------------------------
644  // Port handler base-class functions for typed input ports
645  //
646  // Call these functions directly to bypass the corresponding ports
647  // ----------------------------------------------------------------------
648 
651  FwIndexType portNum,
652  FwOpcodeType opCode,
653  U32 cmdSeq,
654  const Fw::CmdResponse& response
655  )
656  {
657  // Make sure port number is valid
658  FW_ASSERT(
659  (0 <= portNum) && (portNum < this->getNum_cmdResponseIn_InputPorts()),
660  static_cast<FwAssertArgType>(portNum)
661  );
662 
663  // Call handler function
664  this->cmdResponseIn_handler(
665  portNum,
666  opCode,
667  cmdSeq,
668  response
669  );
670  }
671 
674  FwIndexType portNum,
675  Fw::Buffer& data,
676  const ComCfg::FrameContext& context
677  )
678  {
679  // Make sure port number is valid
680  FW_ASSERT(
681  (0 <= portNum) && (portNum < this->getNum_dataIn_InputPorts()),
682  static_cast<FwAssertArgType>(portNum)
683  );
684 
685  // Lock guard mutex before calling
686  this->lock();
687 
688  // Call handler function
689  this->dataIn_handler(
690  portNum,
691  data,
692  context
693  );
694 
695  // Unlock guard mutex
696  this->unLock();
697  }
698 
701  FwIndexType portNum,
702  Fw::Buffer& fwBuffer
703  )
704  {
705  // Make sure port number is valid
706  FW_ASSERT(
707  (0 <= portNum) && (portNum < this->getNum_fileBufferReturnIn_InputPorts()),
708  static_cast<FwAssertArgType>(portNum)
709  );
710 
711  // Lock guard mutex before calling
712  this->lock();
713 
714  // Call handler function
716  portNum,
717  fwBuffer
718  );
719 
720  // Unlock guard mutex
721  this->unLock();
722  }
723 
724 #if !FW_DIRECT_PORT_CALLS
725 
726  // ----------------------------------------------------------------------
727  // Invocation functions for typed output ports
728  // ----------------------------------------------------------------------
729 
732  FwIndexType portNum,
733  Fw::ComBuffer& data,
734  U32 context
735  ) const
736  {
737  FW_ASSERT(
738  (0 <= portNum) && (portNum < this->getNum_commandOut_OutputPorts()),
739  static_cast<FwAssertArgType>(portNum)
740  );
741 
742  FW_ASSERT(
743  this->m_commandOut_OutputPort[portNum].isConnected(),
744  static_cast<FwAssertArgType>(portNum)
745  );
746  this->m_commandOut_OutputPort[portNum].invoke(
747  data,
748  context
749  );
750  }
751 
754  FwIndexType portNum,
755  Fw::Buffer& data,
756  const ComCfg::FrameContext& context
757  ) const
758  {
759  FW_ASSERT(
760  (0 <= portNum) && (portNum < this->getNum_dataReturnOut_OutputPorts()),
761  static_cast<FwAssertArgType>(portNum)
762  );
763 
764  FW_ASSERT(
765  this->m_dataReturnOut_OutputPort[portNum].isConnected(),
766  static_cast<FwAssertArgType>(portNum)
767  );
768  this->m_dataReturnOut_OutputPort[portNum].invoke(
769  data,
770  context
771  );
772  }
773 
776  FwIndexType portNum,
777  Fw::Buffer& fwBuffer
778  ) const
779  {
780  FW_ASSERT(
781  (0 <= portNum) && (portNum < this->getNum_fileOut_OutputPorts()),
782  static_cast<FwAssertArgType>(portNum)
783  );
784 
785  FW_ASSERT(
786  this->m_fileOut_OutputPort[portNum].isConnected(),
787  static_cast<FwAssertArgType>(portNum)
788  );
789  this->m_fileOut_OutputPort[portNum].invoke(
790  fwBuffer
791  );
792  }
793 
796  FwIndexType portNum,
797  Fw::Buffer& data,
798  const ComCfg::FrameContext& context
799  ) const
800  {
801  FW_ASSERT(
802  (0 <= portNum) && (portNum < this->getNum_unknownDataOut_OutputPorts()),
803  static_cast<FwAssertArgType>(portNum)
804  );
805 
806  FW_ASSERT(
807  this->m_unknownDataOut_OutputPort[portNum].isConnected(),
808  static_cast<FwAssertArgType>(portNum)
809  );
810  this->m_unknownDataOut_OutputPort[portNum].invoke(
811  data,
812  context
813  );
814  }
815 
816 #endif
817 
818  // ----------------------------------------------------------------------
819  // Event logging functions
820  // ----------------------------------------------------------------------
821 
824  {
825  // Get the time
826  Fw::Time _logTime;
827  if (this->isConnected_timeCaller_OutputPort(0)) {
828  this->timeCaller_out(0, _logTime);
829  }
830 
831  const FwEventIdType _id = this->getIdBase() + EVENTID_SERIALIZATIONERROR;
832 
833  // Emit the event on the log port
834  if (this->isConnected_logOut_OutputPort(0)) {
835  Fw::LogBuffer _logBuff;
837 
838 #if FW_AMPCS_COMPATIBLE
839  // Serialize the number of arguments
840  _status = _logBuff.serializeFrom(static_cast<U8>(1));
841  FW_ASSERT(
842  _status == Fw::FW_SERIALIZE_OK,
843  static_cast<FwAssertArgType>(_status)
844  );
845 #endif
846 
847 #if FW_AMPCS_COMPATIBLE
848  // Serialize the argument size
849  _status = _logBuff.serializeFrom(
850  static_cast<U8>(sizeof(U32))
851  );
852  FW_ASSERT(
853  _status == Fw::FW_SERIALIZE_OK,
854  static_cast<FwAssertArgType>(_status)
855  );
856 #endif
857  _status = _logBuff.serializeFrom(status);
858  FW_ASSERT(
859  _status == Fw::FW_SERIALIZE_OK,
860  static_cast<FwAssertArgType>(_status)
861  );
862 
863  this->logOut_out(
864  0,
865  _id,
866  _logTime,
868  _logBuff
869  );
870  }
871 
872  // Emit the event on the text log port
873 #if FW_ENABLE_TEXT_LOGGING
874  if (this->isConnected_logTextOut_OutputPort(0)) {
875 #if FW_OBJECT_NAMES == 1
876  const char* _formatString =
877  "(%s) %s: Serializing com buffer failed with status %" PRIu32 "";
878 #else
879  const char* _formatString =
880  "%s: Serializing com buffer failed with status %" PRIu32 "";
881 #endif
882 
883  Fw::TextLogString _logString;
884  (void) _logString.format(
885  _formatString,
886 #if FW_OBJECT_NAMES == 1
887  this->m_objName.toChar(),
888 #endif
889  "SerializationError ",
890  status
891  );
892 
893  this->logTextOut_out(
894  0,
895  _id,
896  _logTime,
898  _logString
899  );
900  }
901 #endif
902  }
903 
906  {
907  // Get the time
908  Fw::Time _logTime;
909  if (this->isConnected_timeCaller_OutputPort(0)) {
910  this->timeCaller_out(0, _logTime);
911  }
912 
914 
915  // Emit the event on the log port
916  if (this->isConnected_logOut_OutputPort(0)) {
917  Fw::LogBuffer _logBuff;
919 
920 #if FW_AMPCS_COMPATIBLE
921  // Serialize the number of arguments
922  _status = _logBuff.serializeFrom(static_cast<U8>(1));
923  FW_ASSERT(
924  _status == Fw::FW_SERIALIZE_OK,
925  static_cast<FwAssertArgType>(_status)
926  );
927 #endif
928 
929 #if FW_AMPCS_COMPATIBLE
930  // Serialize the argument size
931  _status = _logBuff.serializeFrom(
932  static_cast<U8>(sizeof(U32))
933  );
934  FW_ASSERT(
935  _status == Fw::FW_SERIALIZE_OK,
936  static_cast<FwAssertArgType>(_status)
937  );
938 #endif
939  _status = _logBuff.serializeFrom(status);
940  FW_ASSERT(
941  _status == Fw::FW_SERIALIZE_OK,
942  static_cast<FwAssertArgType>(_status)
943  );
944 
945  this->logOut_out(
946  0,
947  _id,
948  _logTime,
950  _logBuff
951  );
952  }
953 
954  // Emit the event on the text log port
955 #if FW_ENABLE_TEXT_LOGGING
956  if (this->isConnected_logTextOut_OutputPort(0)) {
957 #if FW_OBJECT_NAMES == 1
958  const char* _formatString =
959  "(%s) %s: Deserializing packet type failed with status %" PRIu32 "";
960 #else
961  const char* _formatString =
962  "%s: Deserializing packet type failed with status %" PRIu32 "";
963 #endif
964 
965  Fw::TextLogString _logString;
966  (void) _logString.format(
967  _formatString,
968 #if FW_OBJECT_NAMES == 1
969  this->m_objName.toChar(),
970 #endif
971  "DeserializationError ",
972  status
973  );
974 
975  this->logTextOut_out(
976  0,
977  _id,
978  _logTime,
980  _logString
981  );
982  }
983 #endif
984  }
985 
988  {
989  // Get the time
990  Fw::Time _logTime;
991  if (this->isConnected_timeCaller_OutputPort(0)) {
992  this->timeCaller_out(0, _logTime);
993  }
994 
996 
997  // Emit the event on the log port
998  if (this->isConnected_logOut_OutputPort(0)) {
999  Fw::LogBuffer _logBuff;
1000 
1001 #if FW_AMPCS_COMPATIBLE
1003  // Serialize the number of arguments
1004  _status = _logBuff.serializeFrom(static_cast<U8>(0));
1005  FW_ASSERT(
1006  _status == Fw::FW_SERIALIZE_OK,
1007  static_cast<FwAssertArgType>(_status)
1008  );
1009 #endif
1010 
1011  this->logOut_out(
1012  0,
1013  _id,
1014  _logTime,
1016  _logBuff
1017  );
1018  }
1019 
1020  // Emit the event on the text log port
1021 #if FW_ENABLE_TEXT_LOGGING
1022  if (this->isConnected_logTextOut_OutputPort(0)) {
1023 #if FW_OBJECT_NAMES == 1
1024  const char* _formatString =
1025  "(%s) %s: Buffer-to-context table full on fileOut; context will be lost for this buffer";
1026 #else
1027  const char* _formatString =
1028  "%s: Buffer-to-context table full on fileOut; context will be lost for this buffer";
1029 #endif
1030 
1031  Fw::TextLogString _logString;
1032  (void) _logString.format(
1033  _formatString,
1034 #if FW_OBJECT_NAMES == 1
1035  this->m_objName.toChar(),
1036 #endif
1037  "FileOutContextTableFull "
1038  );
1039 
1040  this->logTextOut_out(
1041  0,
1042  _id,
1043  _logTime,
1045  _logString
1046  );
1047  }
1048 #endif
1049  }
1050 
1053  {
1054  // Get the time
1055  Fw::Time _logTime;
1056  if (this->isConnected_timeCaller_OutputPort(0)) {
1057  this->timeCaller_out(0, _logTime);
1058  }
1059 
1061 
1062  // Emit the event on the log port
1063  if (this->isConnected_logOut_OutputPort(0)) {
1064  Fw::LogBuffer _logBuff;
1065 
1066 #if FW_AMPCS_COMPATIBLE
1068  // Serialize the number of arguments
1069  _status = _logBuff.serializeFrom(static_cast<U8>(0));
1070  FW_ASSERT(
1071  _status == Fw::FW_SERIALIZE_OK,
1072  static_cast<FwAssertArgType>(_status)
1073  );
1074 #endif
1075 
1076  this->logOut_out(
1077  0,
1078  _id,
1079  _logTime,
1081  _logBuff
1082  );
1083  }
1084 
1085  // Emit the event on the text log port
1086 #if FW_ENABLE_TEXT_LOGGING
1087  if (this->isConnected_logTextOut_OutputPort(0)) {
1088 #if FW_OBJECT_NAMES == 1
1089  const char* _formatString =
1090  "(%s) %s: Buffer-to-context table full on unknownDataOut; context will be lost for this buffer";
1091 #else
1092  const char* _formatString =
1093  "%s: Buffer-to-context table full on unknownDataOut; context will be lost for this buffer";
1094 #endif
1095 
1096  Fw::TextLogString _logString;
1097  (void) _logString.format(
1098  _formatString,
1099 #if FW_OBJECT_NAMES == 1
1100  this->m_objName.toChar(),
1101 #endif
1102  "UnknownDataOutContextTableFull "
1103  );
1104 
1105  this->logTextOut_out(
1106  0,
1107  _id,
1108  _logTime,
1110  _logString
1111  );
1112  }
1113 #endif
1114  }
1115 
1118  {
1119  // Get the time
1120  Fw::Time _logTime;
1121  if (this->isConnected_timeCaller_OutputPort(0)) {
1122  this->timeCaller_out(0, _logTime);
1123  }
1124 
1126 
1127  // Emit the event on the log port
1128  if (this->isConnected_logOut_OutputPort(0)) {
1129  Fw::LogBuffer _logBuff;
1130 
1131 #if FW_AMPCS_COMPATIBLE
1133  // Serialize the number of arguments
1134  _status = _logBuff.serializeFrom(static_cast<U8>(0));
1135  FW_ASSERT(
1136  _status == Fw::FW_SERIALIZE_OK,
1137  static_cast<FwAssertArgType>(_status)
1138  );
1139 #endif
1140 
1141  this->logOut_out(
1142  0,
1143  _id,
1144  _logTime,
1146  _logBuff
1147  );
1148  }
1149 
1150  // Emit the event on the text log port
1151 #if FW_ENABLE_TEXT_LOGGING
1152  if (this->isConnected_logTextOut_OutputPort(0)) {
1153 #if FW_OBJECT_NAMES == 1
1154  const char* _formatString =
1155  "(%s) %s: Returned buffer not found in context table; returning with empty context";
1156 #else
1157  const char* _formatString =
1158  "%s: Returned buffer not found in context table; returning with empty context";
1159 #endif
1160 
1161  Fw::TextLogString _logString;
1162  (void) _logString.format(
1163  _formatString,
1164 #if FW_OBJECT_NAMES == 1
1165  this->m_objName.toChar(),
1166 #endif
1167  "BufferContextNotFound "
1168  );
1169 
1170  this->logTextOut_out(
1171  0,
1172  _id,
1173  _logTime,
1175  _logString
1176  );
1177  }
1178 #endif
1179  }
1180 
1181  // ----------------------------------------------------------------------
1182  // Time
1183  // ----------------------------------------------------------------------
1184 
1186  getTime() const
1187  {
1188  if (this->isConnected_timeCaller_OutputPort(0)) {
1189  Fw::Time _time;
1190  this->timeCaller_out(0, _time);
1191  return _time;
1192  }
1193  else {
1194  return Fw::Time(TimeBase::TB_NONE, 0, 0);
1195  }
1196  }
1197 
1198  // ----------------------------------------------------------------------
1199  // Mutex operations for guarded ports
1200  //
1201  // You can override these operations to provide more sophisticated
1202  // synchronization
1203  // ----------------------------------------------------------------------
1204 
1207  {
1208  this->m_guardedPortMutex.lock();
1209  }
1210 
1213  {
1214  this->m_guardedPortMutex.unLock();
1215  }
1216 
1217  // ----------------------------------------------------------------------
1218  // Calls for messages received on typed input ports
1219  // ----------------------------------------------------------------------
1220 
1221  void FprimeRouterComponentBase ::
1222  m_p_cmdResponseIn_in(
1223  Fw::PassiveComponentBase* callComp,
1224  FwIndexType portNum,
1225  FwOpcodeType opCode,
1226  U32 cmdSeq,
1227  const Fw::CmdResponse& response
1228  )
1229  {
1230  FW_ASSERT(callComp != nullptr);
1231  FprimeRouterComponentBase* compPtr = static_cast<FprimeRouterComponentBase*>(callComp);
1232  compPtr->cmdResponseIn_handlerBase(
1233  portNum,
1234  opCode,
1235  cmdSeq,
1236  response
1237  );
1238  }
1239 
1240  void FprimeRouterComponentBase ::
1241  m_p_dataIn_in(
1242  Fw::PassiveComponentBase* callComp,
1243  FwIndexType portNum,
1244  Fw::Buffer& data,
1245  const ComCfg::FrameContext& context
1246  )
1247  {
1248  FW_ASSERT(callComp != nullptr);
1249  FprimeRouterComponentBase* compPtr = static_cast<FprimeRouterComponentBase*>(callComp);
1250  compPtr->dataIn_handlerBase(
1251  portNum,
1252  data,
1253  context
1254  );
1255  }
1256 
1257  void FprimeRouterComponentBase ::
1258  m_p_fileBufferReturnIn_in(
1259  Fw::PassiveComponentBase* callComp,
1260  FwIndexType portNum,
1261  Fw::Buffer& fwBuffer
1262  )
1263  {
1264  FW_ASSERT(callComp != nullptr);
1265  FprimeRouterComponentBase* compPtr = static_cast<FprimeRouterComponentBase*>(callComp);
1266  compPtr->fileBufferReturnIn_handlerBase(
1267  portNum,
1268  fwBuffer
1269  );
1270  }
1271 
1272 #if !FW_DIRECT_PORT_CALLS
1273 
1274  // ----------------------------------------------------------------------
1275  // Invocation functions for special output ports
1276  // ----------------------------------------------------------------------
1277 
1278  void FprimeRouterComponentBase ::
1279  logOut_out(
1280  FwIndexType portNum,
1281  FwEventIdType id,
1282  Fw::Time& timeTag,
1283  const Fw::LogSeverity& severity,
1284  Fw::LogBuffer& args
1285  ) const
1286  {
1287  FW_ASSERT(
1288  (0 <= portNum) && (portNum < this->getNum_logOut_OutputPorts()),
1289  static_cast<FwAssertArgType>(portNum)
1290  );
1291 
1292  FW_ASSERT(
1293  this->m_logOut_OutputPort[portNum].isConnected(),
1294  static_cast<FwAssertArgType>(portNum)
1295  );
1296  this->m_logOut_OutputPort[portNum].invoke(
1297  id,
1298  timeTag,
1299  severity,
1300  args
1301  );
1302  }
1303 
1304 #if FW_ENABLE_TEXT_LOGGING
1305 
1306  void FprimeRouterComponentBase ::
1307  logTextOut_out(
1308  FwIndexType portNum,
1309  FwEventIdType id,
1310  Fw::Time& timeTag,
1311  const Fw::LogSeverity& severity,
1312  Fw::TextLogString& text
1313  ) const
1314  {
1315  FW_ASSERT(
1316  (0 <= portNum) && (portNum < this->getNum_logTextOut_OutputPorts()),
1317  static_cast<FwAssertArgType>(portNum)
1318  );
1319 
1320  FW_ASSERT(
1321  this->m_logTextOut_OutputPort[portNum].isConnected(),
1322  static_cast<FwAssertArgType>(portNum)
1323  );
1324  this->m_logTextOut_OutputPort[portNum].invoke(
1325  id,
1326  timeTag,
1327  severity,
1328  text
1329  );
1330  }
1331 
1332 #endif
1333 
1334  void FprimeRouterComponentBase ::
1335  timeCaller_out(
1336  FwIndexType portNum,
1337  Fw::Time& time
1338  ) const
1339  {
1340  FW_ASSERT(
1341  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
1342  static_cast<FwAssertArgType>(portNum)
1343  );
1344 
1345  FW_ASSERT(
1346  this->m_timeCaller_OutputPort[portNum].isConnected(),
1347  static_cast<FwAssertArgType>(portNum)
1348  );
1349  this->m_timeCaller_OutputPort[portNum].invoke(
1350  time
1351  );
1352  }
1353 
1354 #endif
1355 
1356 }
void set_timeCaller_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to timeCaller[portNum].
Serialization/Deserialization operation was successful.
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:157
void invoke(Fw::ComBuffer &data, U32 context) const
Invoke a port connection.
Definition: ComPortAc.cpp:181
void init()
Initialization function.
Definition: ComPortAc.cpp:162
static constexpr FwIndexType getNum_dataIn_InputPorts()
virtual ~FprimeRouterComponentBase()
Destroy FprimeRouterComponentBase object.
static constexpr FwIndexType getNum_fileBufferReturnIn_InputPorts()
FwIdType FwOpcodeType
The type of a command opcode.
An error occurred while deserializing a packet.
void dataIn_handlerBase(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context)
Handler base-class function for input port dataIn.
void fileBufferReturnIn_handlerBase(FwIndexType portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port fileBufferReturnIn.
bool isConnected_dataReturnOut_OutputPort(FwIndexType portNum) const
void unknownDataOut_out(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context) const
Invoke output port unknownDataOut.
I32 FwEnumStoreType
bool isConnected_commandOut_OutputPort(FwIndexType portNum) const
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
bool isConnected_timeCaller_OutputPort(FwIndexType portNum) const
FprimeRouterComponentBase(const char *compName="")
Construct FprimeRouterComponentBase object.
void unLock()
unlock the mutex and assert success
Definition: Mutex.cpp:41
virtual void lock()
Lock the guarded mutex.
static constexpr FwIndexType getNum_unknownDataOut_OutputPorts()
An error occurred while serializing a com buffer.
void fileOut_out(FwIndexType portNum, Fw::Buffer &fwBuffer) const
Invoke output port fileOut.
Enum representing a command response.
No time base has been established (Required)
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
void commandOut_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context) const
Invoke output port commandOut.
Fw::InputCmdResponsePort * get_cmdResponseIn_InputPort(FwIndexType portNum)
void addCallPort(InputComDataWithContextPort *callPort)
Register an input port.
static constexpr FwIndexType getNum_commandOut_OutputPorts()
void init()
Object initializer.
Definition: ObjBase.cpp:24
SerializeStatus
forward declaration for string
FwIdType FwEventIdType
The type of an event identifier.
void set_logOut_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to logOut[portNum].
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:40
virtual void unLock()
Unlock the guarded mutex.
Fw::InputBufferSendPort * get_fileBufferReturnIn_InputPort(FwIndexType portNum)
void set_dataReturnOut_OutputPort(FwIndexType portNum, Svc::InputComDataWithContextPort *port)
Connect port to dataReturnOut[portNum].
void init()
Initialization function.
Definition: TimePortAc.cpp:151
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void invoke(Fw::Buffer &fwBuffer) const
Invoke a port connection.
void cmdResponseIn_handlerBase(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)
Handler base-class function for input port cmdResponseIn.
void init()
Initialization function.
void addCallPort(InputBufferSendPort *callPort)
Register an input port.
void invoke(Fw::Time &time) const
Invoke a port connection.
Definition: TimePortAc.cpp:170
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
static constexpr FwIndexType getNum_dataReturnOut_OutputPorts()
void invoke(Fw::Buffer &data, const ComCfg::FrameContext &context) const
Invoke a port connection.
A serious but recoverable event.
void init()
Initialization function.
Auto-generated base for FprimeRouter component.
const char * toChar() const
Convert to a C-style char*.
bool isConnected() const
Definition: PortBase.cpp:38
Enum representing event severity.
void set_fileOut_OutputPort(FwIndexType portNum, Fw::InputBufferSendPort *port)
Connect port to fileOut[portNum].
#define PRI_FwIndexType
Svc::InputComDataWithContextPort * get_dataIn_InputPort(FwIndexType portNum)
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)
static constexpr FwIndexType getNum_logOut_OutputPorts()
static constexpr FwIndexType getNum_fileOut_OutputPorts()
void dataReturnOut_out(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context) const
Invoke output port dataReturnOut.
void init()
Initialization function.
void init()
Initialization function.
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args) const
Invoke a port connection.
Definition: LogPortAc.cpp:199
void init()
Initialization function.
void set_unknownDataOut_OutputPort(FwIndexType portNum, Svc::InputComDataWithContextPort *port)
Connect port to unknownDataOut[portNum].
bool isConnected_unknownDataOut_OutputPort(FwIndexType portNum) const
static constexpr FwIndexType getNum_cmdResponseIn_InputPorts()
PlatformIndexType FwIndexType
void log_WARNING_HI_DeserializationError(U32 status) const
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:186
void log_WARNING_HI_SerializationError(U32 status) const
Type used to pass context info between components during framing/deframing.
bool isConnected_fileOut_OutputPort(FwIndexType portNum) const
RateGroupDivider component implementation.
void set_commandOut_OutputPort(FwIndexType portNum, Fw::InputComPort *port)
Connect port to commandOut[portNum].
void addCallPort(InputComPort *callPort)
Register an input port.
Definition: ComPortAc.cpp:168
virtual void cmdResponseIn_handler(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)=0
Handler for input port cmdResponseIn.
bool isConnected_logOut_OutputPort(FwIndexType portNum) const
Implementation of malloc based allocator.
static constexpr FwIndexType getNum_timeCaller_OutputPorts()
virtual void dataIn_handler(FwIndexType portNum, Fw::Buffer &data, const ComCfg::FrameContext &context)=0
Handler for input port dataIn.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
virtual void fileBufferReturnIn_handler(FwIndexType portNum, Fw::Buffer &fwBuffer)=0
Handler for input port fileBufferReturnIn.
void lock()
lock the mutex and assert success
Definition: Mutex.cpp:34