F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
TlmChanComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title TlmChanComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for TlmChan 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  TLMCHAN_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
19  RUN_SCHED,
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 {
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  Fw::Serializable::SizeType getCapacity() const {
48  return sizeof(m_buff);
49  }
50 
51  U8* getBuffAddr() {
52  return m_buff;
53  }
54 
55  const U8* getBuffAddr() const {
56  return m_buff;
57  }
58 
59  private:
60  // Should be the max of all the input ports serialized sizes...
61  U8 m_buff[SERIALIZATION_SIZE];
62 
63  };
64  }
65 
66  // ----------------------------------------------------------------------
67  // Component initialization
68  // ----------------------------------------------------------------------
69 
72  FwSizeType queueDepth,
73  FwEnumStoreType instance
74  )
75  {
76  // Initialize base class
78 
79 #if !FW_DIRECT_PORT_CALLS
80  // Connect input port Run
81  for (
82  FwIndexType port = 0;
83  port < static_cast<FwIndexType>(this->getNum_Run_InputPorts());
84  port++
85  ) {
86  this->m_Run_InputPort[port].init();
87  this->m_Run_InputPort[port].addCallComp(
88  this,
89  m_p_Run_in
90  );
91  this->m_Run_InputPort[port].setPortNum(port);
92 
93 #if FW_OBJECT_NAMES == 1
94  Fw::ObjectName portName;
95  portName.format(
96  "%s_Run_InputPort[%" PRI_FwIndexType "]",
97  this->m_objName.toChar(),
98  port
99  );
100  this->m_Run_InputPort[port].setObjName(portName.toChar());
101 #endif
102  }
103 #endif
104 
105 #if !FW_DIRECT_PORT_CALLS
106  // Connect input port TlmGet
107  for (
108  FwIndexType port = 0;
109  port < static_cast<FwIndexType>(this->getNum_TlmGet_InputPorts());
110  port++
111  ) {
112  this->m_TlmGet_InputPort[port].init();
113  this->m_TlmGet_InputPort[port].addCallComp(
114  this,
115  m_p_TlmGet_in
116  );
117  this->m_TlmGet_InputPort[port].setPortNum(port);
118 
119 #if FW_OBJECT_NAMES == 1
120  Fw::ObjectName portName;
121  portName.format(
122  "%s_TlmGet_InputPort[%" PRI_FwIndexType "]",
123  this->m_objName.toChar(),
124  port
125  );
126  this->m_TlmGet_InputPort[port].setObjName(portName.toChar());
127 #endif
128  }
129 #endif
130 
131 #if !FW_DIRECT_PORT_CALLS
132  // Connect input port TlmRecv
133  for (
134  FwIndexType port = 0;
135  port < static_cast<FwIndexType>(this->getNum_TlmRecv_InputPorts());
136  port++
137  ) {
138  this->m_TlmRecv_InputPort[port].init();
139  this->m_TlmRecv_InputPort[port].addCallComp(
140  this,
141  m_p_TlmRecv_in
142  );
143  this->m_TlmRecv_InputPort[port].setPortNum(port);
144 
145 #if FW_OBJECT_NAMES == 1
146  Fw::ObjectName portName;
147  portName.format(
148  "%s_TlmRecv_InputPort[%" PRI_FwIndexType "]",
149  this->m_objName.toChar(),
150  port
151  );
152  this->m_TlmRecv_InputPort[port].setObjName(portName.toChar());
153 #endif
154  }
155 #endif
156 
157 #if !FW_DIRECT_PORT_CALLS
158  // Connect input port pingIn
159  for (
160  FwIndexType port = 0;
161  port < static_cast<FwIndexType>(this->getNum_pingIn_InputPorts());
162  port++
163  ) {
164  this->m_pingIn_InputPort[port].init();
165  this->m_pingIn_InputPort[port].addCallComp(
166  this,
167  m_p_pingIn_in
168  );
169  this->m_pingIn_InputPort[port].setPortNum(port);
170 
171 #if FW_OBJECT_NAMES == 1
172  Fw::ObjectName portName;
173  portName.format(
174  "%s_pingIn_InputPort[%" PRI_FwIndexType "]",
175  this->m_objName.toChar(),
176  port
177  );
178  this->m_pingIn_InputPort[port].setObjName(portName.toChar());
179 #endif
180  }
181 #endif
182 
183 #if !FW_DIRECT_PORT_CALLS
184  // Connect output port eventOut
185  for (
186  FwIndexType port = 0;
187  port < static_cast<FwIndexType>(this->getNum_eventOut_OutputPorts());
188  port++
189  ) {
190  this->m_eventOut_OutputPort[port].init();
191 
192 #if FW_OBJECT_NAMES == 1
193  Fw::ObjectName portName;
194  portName.format(
195  "%s_eventOut_OutputPort[%" PRI_FwIndexType "]",
196  this->m_objName.toChar(),
197  port
198  );
199  this->m_eventOut_OutputPort[port].setObjName(portName.toChar());
200 #endif
201  }
202 #endif
203 
204 #if !FW_DIRECT_PORT_CALLS && FW_ENABLE_TEXT_LOGGING
205  // Connect output port eventOutText
206  for (
207  FwIndexType port = 0;
208  port < static_cast<FwIndexType>(this->getNum_eventOutText_OutputPorts());
209  port++
210  ) {
211  this->m_eventOutText_OutputPort[port].init();
212 
213 #if FW_OBJECT_NAMES == 1
214  Fw::ObjectName portName;
215  portName.format(
216  "%s_eventOutText_OutputPort[%" PRI_FwIndexType "]",
217  this->m_objName.toChar(),
218  port
219  );
220  this->m_eventOutText_OutputPort[port].setObjName(portName.toChar());
221 #endif
222  }
223 #endif
224 
225 #if !FW_DIRECT_PORT_CALLS
226  // Connect output port timeCaller
227  for (
228  FwIndexType port = 0;
229  port < static_cast<FwIndexType>(this->getNum_timeCaller_OutputPorts());
230  port++
231  ) {
232  this->m_timeCaller_OutputPort[port].init();
233 
234 #if FW_OBJECT_NAMES == 1
235  Fw::ObjectName portName;
236  portName.format(
237  "%s_timeCaller_OutputPort[%" PRI_FwIndexType "]",
238  this->m_objName.toChar(),
239  port
240  );
241  this->m_timeCaller_OutputPort[port].setObjName(portName.toChar());
242 #endif
243  }
244 #endif
245 
246 #if !FW_DIRECT_PORT_CALLS
247  // Connect output port PktSend
248  for (
249  FwIndexType port = 0;
250  port < static_cast<FwIndexType>(this->getNum_PktSend_OutputPorts());
251  port++
252  ) {
253  this->m_PktSend_OutputPort[port].init();
254 
255 #if FW_OBJECT_NAMES == 1
256  Fw::ObjectName portName;
257  portName.format(
258  "%s_PktSend_OutputPort[%" PRI_FwIndexType "]",
259  this->m_objName.toChar(),
260  port
261  );
262  this->m_PktSend_OutputPort[port].setObjName(portName.toChar());
263 #endif
264  }
265 #endif
266 
267 #if !FW_DIRECT_PORT_CALLS
268  // Connect output port pingOut
269  for (
270  FwIndexType port = 0;
271  port < static_cast<FwIndexType>(this->getNum_pingOut_OutputPorts());
272  port++
273  ) {
274  this->m_pingOut_OutputPort[port].init();
275 
276 #if FW_OBJECT_NAMES == 1
277  Fw::ObjectName portName;
278  portName.format(
279  "%s_pingOut_OutputPort[%" PRI_FwIndexType "]",
280  this->m_objName.toChar(),
281  port
282  );
283  this->m_pingOut_OutputPort[port].setObjName(portName.toChar());
284 #endif
285  }
286 #endif
287 
288  // Create the queue
289  Os::Queue::Status qStat = this->createQueue(
290  queueDepth,
291  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
292  );
293  FW_ASSERT(
294  Os::Queue::Status::OP_OK == qStat,
295  static_cast<FwAssertArgType>(qStat)
296  );
297  }
298 
299 #if !FW_DIRECT_PORT_CALLS
300 
301  // ----------------------------------------------------------------------
302  // Getters for typed input ports
303  // ----------------------------------------------------------------------
304 
307  {
308  FW_ASSERT(
309  (0 <= portNum) && (portNum < this->getNum_Run_InputPorts()),
310  static_cast<FwAssertArgType>(portNum)
311  );
312 
313  return &this->m_Run_InputPort[portNum];
314  }
315 
318  {
319  FW_ASSERT(
320  (0 <= portNum) && (portNum < this->getNum_TlmGet_InputPorts()),
321  static_cast<FwAssertArgType>(portNum)
322  );
323 
324  return &this->m_TlmGet_InputPort[portNum];
325  }
326 
329  {
330  FW_ASSERT(
331  (0 <= portNum) && (portNum < this->getNum_TlmRecv_InputPorts()),
332  static_cast<FwAssertArgType>(portNum)
333  );
334 
335  return &this->m_TlmRecv_InputPort[portNum];
336  }
337 
340  {
341  FW_ASSERT(
342  (0 <= portNum) && (portNum < this->getNum_pingIn_InputPorts()),
343  static_cast<FwAssertArgType>(portNum)
344  );
345 
346  return &this->m_pingIn_InputPort[portNum];
347  }
348 
349 #endif
350 
351 #if !FW_DIRECT_PORT_CALLS
352 
353  // ----------------------------------------------------------------------
354  // Connect input ports to special output ports
355  // ----------------------------------------------------------------------
356 
359  FwIndexType portNum,
360  Fw::InputLogPort* port
361  )
362  {
363  FW_ASSERT(
364  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
365  static_cast<FwAssertArgType>(portNum)
366  );
367 
368  this->m_eventOut_OutputPort[portNum].addCallPort(port);
369  }
370 
371 #if FW_ENABLE_TEXT_LOGGING == 1
372 
373  void TlmChanComponentBase ::
374  set_eventOutText_OutputPort(
375  FwIndexType portNum,
377  )
378  {
379  FW_ASSERT(
380  (0 <= portNum) && (portNum < this->getNum_eventOutText_OutputPorts()),
381  static_cast<FwAssertArgType>(portNum)
382  );
383 
384  this->m_eventOutText_OutputPort[portNum].addCallPort(port);
385  }
386 
387 #endif
388 
391  FwIndexType portNum,
392  Fw::InputTimePort* port
393  )
394  {
395  FW_ASSERT(
396  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
397  static_cast<FwAssertArgType>(portNum)
398  );
399 
400  this->m_timeCaller_OutputPort[portNum].addCallPort(port);
401  }
402 
403 #endif
404 
405 #if !FW_DIRECT_PORT_CALLS
406 
407  // ----------------------------------------------------------------------
408  // Connect typed input ports to typed output ports
409  // ----------------------------------------------------------------------
410 
413  FwIndexType portNum,
414  Fw::InputComPort* port
415  )
416  {
417  FW_ASSERT(
418  (0 <= portNum) && (portNum < this->getNum_PktSend_OutputPorts()),
419  static_cast<FwAssertArgType>(portNum)
420  );
421 
422  this->m_PktSend_OutputPort[portNum].addCallPort(port);
423  }
424 
427  FwIndexType portNum,
428  Svc::InputPingPort* port
429  )
430  {
431  FW_ASSERT(
432  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
433  static_cast<FwAssertArgType>(portNum)
434  );
435 
436  this->m_pingOut_OutputPort[portNum].addCallPort(port);
437  }
438 
439 #endif
440 
441 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
442 
443  // ----------------------------------------------------------------------
444  // Connect serial input ports to special output ports
445  // ----------------------------------------------------------------------
446 
449  FwIndexType portNum,
450  Fw::InputSerializePort* port
451  )
452  {
453  FW_ASSERT(
454  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
455  static_cast<FwAssertArgType>(portNum)
456  );
457 
458  this->m_eventOut_OutputPort[portNum].registerSerialPort(port);
459  }
460 
461 #if FW_ENABLE_TEXT_LOGGING == 1
462 
463  void TlmChanComponentBase ::
464  set_eventOutText_OutputPort(
465  FwIndexType portNum,
466  Fw::InputSerializePort* port
467  )
468  {
469  FW_ASSERT(
470  (0 <= portNum) && (portNum < this->getNum_eventOutText_OutputPorts()),
471  static_cast<FwAssertArgType>(portNum)
472  );
473 
474  this->m_eventOutText_OutputPort[portNum].registerSerialPort(port);
475  }
476 
477 #endif
478 
481  FwIndexType portNum,
482  Fw::InputSerializePort* port
483  )
484  {
485  FW_ASSERT(
486  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
487  static_cast<FwAssertArgType>(portNum)
488  );
489 
490  this->m_timeCaller_OutputPort[portNum].registerSerialPort(port);
491  }
492 
493 #endif
494 
495 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
496 
497  // ----------------------------------------------------------------------
498  // Connect serial input ports to typed output ports
499  // ----------------------------------------------------------------------
500 
503  FwIndexType portNum,
504  Fw::InputSerializePort* port
505  )
506  {
507  FW_ASSERT(
508  (0 <= portNum) && (portNum < this->getNum_PktSend_OutputPorts()),
509  static_cast<FwAssertArgType>(portNum)
510  );
511 
512  this->m_PktSend_OutputPort[portNum].registerSerialPort(port);
513  }
514 
517  FwIndexType portNum,
518  Fw::InputSerializePort* port
519  )
520  {
521  FW_ASSERT(
522  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
523  static_cast<FwAssertArgType>(portNum)
524  );
525 
526  this->m_pingOut_OutputPort[portNum].registerSerialPort(port);
527  }
528 
529 #endif
530 
531  // ----------------------------------------------------------------------
532  // Component construction and destruction
533  // ----------------------------------------------------------------------
534 
536  TlmChanComponentBase(const char* compName) :
537  Fw::ActiveComponentBase(compName)
538  {
539 
540  }
541 
544  {
545 
546  }
547 
548 #if !FW_DIRECT_PORT_CALLS
549 
550  // ----------------------------------------------------------------------
551  // Connection status queries for special output ports
552  // ----------------------------------------------------------------------
553 
556  {
557  FW_ASSERT(
558  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
559  static_cast<FwAssertArgType>(portNum)
560  );
561 
562  return this->m_eventOut_OutputPort[portNum].isConnected();
563  }
564 
565 #if FW_ENABLE_TEXT_LOGGING == 1
566 
567  bool TlmChanComponentBase ::
568  isConnected_eventOutText_OutputPort(FwIndexType portNum) const
569  {
570  FW_ASSERT(
571  (0 <= portNum) && (portNum < this->getNum_eventOutText_OutputPorts()),
572  static_cast<FwAssertArgType>(portNum)
573  );
574 
575  return this->m_eventOutText_OutputPort[portNum].isConnected();
576  }
577 
578 #endif
579 
582  {
583  FW_ASSERT(
584  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
585  static_cast<FwAssertArgType>(portNum)
586  );
587 
588  return this->m_timeCaller_OutputPort[portNum].isConnected();
589  }
590 
591 #endif
592 
593 #if !FW_DIRECT_PORT_CALLS
594 
595  // ----------------------------------------------------------------------
596  // Connection status queries for typed output ports
597  // ----------------------------------------------------------------------
598 
601  {
602  FW_ASSERT(
603  (0 <= portNum) && (portNum < this->getNum_PktSend_OutputPorts()),
604  static_cast<FwAssertArgType>(portNum)
605  );
606 
607  return this->m_PktSend_OutputPort[portNum].isConnected();
608  }
609 
612  {
613  FW_ASSERT(
614  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
615  static_cast<FwAssertArgType>(portNum)
616  );
617 
618  return this->m_pingOut_OutputPort[portNum].isConnected();
619  }
620 
621 #endif
622 
623  // ----------------------------------------------------------------------
624  // Port handler base-class functions for typed input ports
625  //
626  // Call these functions directly to bypass the corresponding ports
627  // ----------------------------------------------------------------------
628 
631  FwIndexType portNum,
632  U32 context
633  )
634  {
635  // Make sure port number is valid
636  FW_ASSERT(
637  (0 <= portNum) && (portNum < this->getNum_Run_InputPorts()),
638  static_cast<FwAssertArgType>(portNum)
639  );
640 
641  // Call pre-message hook
643  portNum,
644  context
645  );
646  ComponentIpcSerializableBuffer msg;
648 
649  // Serialize message ID
650  _status = msg.serializeFrom(
651  static_cast<FwEnumStoreType>(RUN_SCHED)
652  );
653  FW_ASSERT(
654  _status == Fw::FW_SERIALIZE_OK,
655  static_cast<FwAssertArgType>(_status)
656  );
657 
658  // Serialize port number
659  _status = msg.serializeFrom(portNum);
660  FW_ASSERT(
661  _status == Fw::FW_SERIALIZE_OK,
662  static_cast<FwAssertArgType>(_status)
663  );
664 
665  // Serialize argument context
666  _status = msg.serializeFrom(context);
667  FW_ASSERT(
668  _status == Fw::FW_SERIALIZE_OK,
669  static_cast<FwAssertArgType>(_status)
670  );
671 
672  // Send message
674  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
675 
676  FW_ASSERT(
677  qStatus == Os::Queue::OP_OK,
678  static_cast<FwAssertArgType>(qStatus)
679  );
680  }
681 
684  FwIndexType portNum,
685  FwChanIdType id,
686  Fw::Time& timeTag,
687  Fw::TlmBuffer& val
688  )
689  {
690  // Make sure port number is valid
691  FW_ASSERT(
692  (0 <= portNum) && (portNum < this->getNum_TlmGet_InputPorts()),
693  static_cast<FwAssertArgType>(portNum)
694  );
695 
696  Fw::TlmValid retVal;
697 
698  // Lock guard mutex before calling
699  this->lock();
700 
701  // Call handler function
702  retVal = this->TlmGet_handler(
703  portNum,
704  id,
705  timeTag,
706  val
707  );
708 
709  // Unlock guard mutex
710  this->unLock();
711 
712  return retVal;
713  }
714 
717  FwIndexType portNum,
718  FwChanIdType id,
719  Fw::Time& timeTag,
720  Fw::TlmBuffer& val
721  )
722  {
723  // Make sure port number is valid
724  FW_ASSERT(
725  (0 <= portNum) && (portNum < this->getNum_TlmRecv_InputPorts()),
726  static_cast<FwAssertArgType>(portNum)
727  );
728 
729  // Lock guard mutex before calling
730  this->lock();
731 
732  // Call handler function
733  this->TlmRecv_handler(
734  portNum,
735  id,
736  timeTag,
737  val
738  );
739 
740  // Unlock guard mutex
741  this->unLock();
742  }
743 
746  FwIndexType portNum,
747  U32 key
748  )
749  {
750  // Make sure port number is valid
751  FW_ASSERT(
752  (0 <= portNum) && (portNum < this->getNum_pingIn_InputPorts()),
753  static_cast<FwAssertArgType>(portNum)
754  );
755 
756  // Call pre-message hook
758  portNum,
759  key
760  );
761  ComponentIpcSerializableBuffer msg;
763 
764  // Serialize message ID
765  _status = msg.serializeFrom(
766  static_cast<FwEnumStoreType>(PINGIN_PING)
767  );
768  FW_ASSERT(
769  _status == Fw::FW_SERIALIZE_OK,
770  static_cast<FwAssertArgType>(_status)
771  );
772 
773  // Serialize port number
774  _status = msg.serializeFrom(portNum);
775  FW_ASSERT(
776  _status == Fw::FW_SERIALIZE_OK,
777  static_cast<FwAssertArgType>(_status)
778  );
779 
780  // Serialize argument key
781  _status = msg.serializeFrom(key);
782  FW_ASSERT(
783  _status == Fw::FW_SERIALIZE_OK,
784  static_cast<FwAssertArgType>(_status)
785  );
786 
787  // Send message
789  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
790 
791  FW_ASSERT(
792  qStatus == Os::Queue::OP_OK,
793  static_cast<FwAssertArgType>(qStatus)
794  );
795  }
796 
797  // ----------------------------------------------------------------------
798  // Pre-message hooks for typed async input ports
799  //
800  // Each of these functions is invoked just before processing a message
801  // on the corresponding port. By default, they do nothing. You can
802  // override them to provide specific pre-message behavior.
803  // ----------------------------------------------------------------------
804 
807  FwIndexType portNum,
808  U32 context
809  )
810  {
811  // Default: no-op
812  }
813 
816  FwIndexType portNum,
817  U32 key
818  )
819  {
820  // Default: no-op
821  }
822 
823 #if !FW_DIRECT_PORT_CALLS
824 
825  // ----------------------------------------------------------------------
826  // Invocation functions for typed output ports
827  // ----------------------------------------------------------------------
828 
831  FwIndexType portNum,
832  Fw::ComBuffer& data,
833  U32 context
834  ) const
835  {
836  FW_ASSERT(
837  (0 <= portNum) && (portNum < this->getNum_PktSend_OutputPorts()),
838  static_cast<FwAssertArgType>(portNum)
839  );
840 
841  FW_ASSERT(
842  this->m_PktSend_OutputPort[portNum].isConnected(),
843  static_cast<FwAssertArgType>(portNum)
844  );
845  this->m_PktSend_OutputPort[portNum].invoke(
846  data,
847  context
848  );
849  }
850 
853  FwIndexType portNum,
854  U32 key
855  ) const
856  {
857  FW_ASSERT(
858  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
859  static_cast<FwAssertArgType>(portNum)
860  );
861 
862  FW_ASSERT(
863  this->m_pingOut_OutputPort[portNum].isConnected(),
864  static_cast<FwAssertArgType>(portNum)
865  );
866  this->m_pingOut_OutputPort[portNum].invoke(
867  key
868  );
869  }
870 
871 #endif
872 
873  // ----------------------------------------------------------------------
874  // Event logging functions
875  // ----------------------------------------------------------------------
876 
879  U32 numDeferred,
880  U32 numTimesDeferredCountReached
881  ) const
882  {
883  // Get the time
884  Fw::Time _logTime;
885  if (this->isConnected_timeCaller_OutputPort(0)) {
886  this->timeCaller_out(0, _logTime);
887  }
888 
890 
891  // Emit the event on the log port
892  if (this->isConnected_eventOut_OutputPort(0)) {
893  Fw::LogBuffer _logBuff;
895 
896 #if FW_AMPCS_COMPATIBLE
897  // Serialize the number of arguments
898  _status = _logBuff.serializeFrom(static_cast<U8>(2));
899  FW_ASSERT(
900  _status == Fw::FW_SERIALIZE_OK,
901  static_cast<FwAssertArgType>(_status)
902  );
903 #endif
904 
905 #if FW_AMPCS_COMPATIBLE
906  // Serialize the argument size
907  _status = _logBuff.serializeFrom(
908  static_cast<U8>(sizeof(U32))
909  );
910  FW_ASSERT(
911  _status == Fw::FW_SERIALIZE_OK,
912  static_cast<FwAssertArgType>(_status)
913  );
914 #endif
915  _status = _logBuff.serializeFrom(numDeferred);
916  FW_ASSERT(
917  _status == Fw::FW_SERIALIZE_OK,
918  static_cast<FwAssertArgType>(_status)
919  );
920 
921 #if FW_AMPCS_COMPATIBLE
922  // Serialize the argument size
923  _status = _logBuff.serializeFrom(
924  static_cast<U8>(sizeof(U32))
925  );
926  FW_ASSERT(
927  _status == Fw::FW_SERIALIZE_OK,
928  static_cast<FwAssertArgType>(_status)
929  );
930 #endif
931  _status = _logBuff.serializeFrom(numTimesDeferredCountReached);
932  FW_ASSERT(
933  _status == Fw::FW_SERIALIZE_OK,
934  static_cast<FwAssertArgType>(_status)
935  );
936 
937  this->eventOut_out(
938  0,
939  _id,
940  _logTime,
942  _logBuff
943  );
944  }
945 
946  // Emit the event on the text log port
947 #if FW_ENABLE_TEXT_LOGGING
948  if (this->isConnected_eventOutText_OutputPort(0)) {
949 #if FW_OBJECT_NAMES == 1
950  const char* _formatString =
951  "(%s) %s: TlmChan epoch processing cap reached: %" PRIu32 " entries deferred (cumulative: %" PRIu32 ")";
952 #else
953  const char* _formatString =
954  "%s: TlmChan epoch processing cap reached: %" PRIu32 " entries deferred (cumulative: %" PRIu32 ")";
955 #endif
956 
957  Fw::TextLogString _logString;
958  _logString.format(
959  _formatString,
960 #if FW_OBJECT_NAMES == 1
961  this->m_objName.toChar(),
962 #endif
963  "TlmChanEpochProcessingCapReached ",
964  numDeferred,
965  numTimesDeferredCountReached
966  );
967 
968  this->eventOutText_out(
969  0,
970  _id,
971  _logTime,
973  _logString
974  );
975  }
976 #endif
977  }
978 
979  // ----------------------------------------------------------------------
980  // Time
981  // ----------------------------------------------------------------------
982 
984  getTime() const
985  {
986  if (this->isConnected_timeCaller_OutputPort(0)) {
987  Fw::Time _time;
988  this->timeCaller_out(0, _time);
989  return _time;
990  }
991  else {
992  return Fw::Time(TimeBase::TB_NONE, 0, 0);
993  }
994  }
995 
996  // ----------------------------------------------------------------------
997  // Mutex operations for guarded ports
998  //
999  // You can override these operations to provide more sophisticated
1000  // synchronization
1001  // ----------------------------------------------------------------------
1002 
1005  {
1006  this->m_guardedPortMutex.lock();
1007  }
1008 
1011  {
1012  this->m_guardedPortMutex.unLock();
1013  }
1014 
1015  // ----------------------------------------------------------------------
1016  // Message dispatch functions
1017  // ----------------------------------------------------------------------
1018 
1019  Fw::QueuedComponentBase::MsgDispatchStatus TlmChanComponentBase ::
1020  doDispatch()
1021  {
1022  ComponentIpcSerializableBuffer _msg;
1023  FwQueuePriorityType _priority = 0;
1024 
1025  Os::Queue::Status _msgStatus = this->m_queue.receive(
1026  _msg,
1028  _priority
1029  );
1030  FW_ASSERT(
1031  _msgStatus == Os::Queue::OP_OK,
1032  static_cast<FwAssertArgType>(_msgStatus)
1033  );
1034 
1035  // Reset to beginning of buffer
1036  _msg.resetDeser();
1037 
1038  FwEnumStoreType _desMsg = 0;
1039  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
1040  FW_ASSERT(
1041  _deserStatus == Fw::FW_SERIALIZE_OK,
1042  static_cast<FwAssertArgType>(_deserStatus)
1043  );
1044 
1045  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
1046 
1047  if (_msgType == TLMCHAN_COMPONENT_EXIT) {
1048  return MSG_DISPATCH_EXIT;
1049  }
1050 
1051  FwIndexType portNum = 0;
1052  _deserStatus = _msg.deserializeTo(portNum);
1053  FW_ASSERT(
1054  _deserStatus == Fw::FW_SERIALIZE_OK,
1055  static_cast<FwAssertArgType>(_deserStatus)
1056  );
1057 
1058  switch (_msgType) {
1059  // Handle async input port Run
1060  case RUN_SCHED: {
1061  // Deserialize argument context
1062  U32 context;
1063  _deserStatus = _msg.deserializeTo(context);
1064  FW_ASSERT(
1065  _deserStatus == Fw::FW_SERIALIZE_OK,
1066  static_cast<FwAssertArgType>(_deserStatus)
1067  );
1068  // Call handler function
1069  this->Run_handler(
1070  portNum,
1071  context
1072  );
1073 
1074  break;
1075  }
1076 
1077  // Handle async input port pingIn
1078  case PINGIN_PING: {
1079  // Deserialize argument key
1080  U32 key;
1081  _deserStatus = _msg.deserializeTo(key);
1082  FW_ASSERT(
1083  _deserStatus == Fw::FW_SERIALIZE_OK,
1084  static_cast<FwAssertArgType>(_deserStatus)
1085  );
1086  // Call handler function
1087  this->pingIn_handler(
1088  portNum,
1089  key
1090  );
1091 
1092  break;
1093  }
1094 
1095  default:
1096  return MSG_DISPATCH_ERROR;
1097  }
1098 
1099  return MSG_DISPATCH_OK;
1100  }
1101 
1102  // ----------------------------------------------------------------------
1103  // Calls for messages received on typed input ports
1104  // ----------------------------------------------------------------------
1105 
1106  void TlmChanComponentBase ::
1107  m_p_Run_in(
1108  Fw::PassiveComponentBase* callComp,
1109  FwIndexType portNum,
1110  U32 context
1111  )
1112  {
1113  FW_ASSERT(callComp);
1114  TlmChanComponentBase* compPtr = static_cast<TlmChanComponentBase*>(callComp);
1115  compPtr->Run_handlerBase(
1116  portNum,
1117  context
1118  );
1119  }
1120 
1121  Fw::TlmValid TlmChanComponentBase ::
1122  m_p_TlmGet_in(
1123  Fw::PassiveComponentBase* callComp,
1124  FwIndexType portNum,
1125  FwChanIdType id,
1126  Fw::Time& timeTag,
1127  Fw::TlmBuffer& val
1128  )
1129  {
1130  FW_ASSERT(callComp);
1131  TlmChanComponentBase* compPtr = static_cast<TlmChanComponentBase*>(callComp);
1132  return compPtr->TlmGet_handlerBase(
1133  portNum,
1134  id,
1135  timeTag,
1136  val
1137  );
1138  }
1139 
1140  void TlmChanComponentBase ::
1141  m_p_TlmRecv_in(
1142  Fw::PassiveComponentBase* callComp,
1143  FwIndexType portNum,
1144  FwChanIdType id,
1145  Fw::Time& timeTag,
1146  Fw::TlmBuffer& val
1147  )
1148  {
1149  FW_ASSERT(callComp);
1150  TlmChanComponentBase* compPtr = static_cast<TlmChanComponentBase*>(callComp);
1151  compPtr->TlmRecv_handlerBase(
1152  portNum,
1153  id,
1154  timeTag,
1155  val
1156  );
1157  }
1158 
1159  void TlmChanComponentBase ::
1160  m_p_pingIn_in(
1161  Fw::PassiveComponentBase* callComp,
1162  FwIndexType portNum,
1163  U32 key
1164  )
1165  {
1166  FW_ASSERT(callComp);
1167  TlmChanComponentBase* compPtr = static_cast<TlmChanComponentBase*>(callComp);
1168  compPtr->pingIn_handlerBase(
1169  portNum,
1170  key
1171  );
1172  }
1173 
1174 #if !FW_DIRECT_PORT_CALLS
1175 
1176  // ----------------------------------------------------------------------
1177  // Invocation functions for special output ports
1178  // ----------------------------------------------------------------------
1179 
1180  void TlmChanComponentBase ::
1181  eventOut_out(
1182  FwIndexType portNum,
1183  FwEventIdType id,
1184  Fw::Time& timeTag,
1185  const Fw::LogSeverity& severity,
1186  Fw::LogBuffer& args
1187  ) const
1188  {
1189  FW_ASSERT(
1190  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
1191  static_cast<FwAssertArgType>(portNum)
1192  );
1193 
1194  FW_ASSERT(
1195  this->m_eventOut_OutputPort[portNum].isConnected(),
1196  static_cast<FwAssertArgType>(portNum)
1197  );
1198  this->m_eventOut_OutputPort[portNum].invoke(
1199  id,
1200  timeTag,
1201  severity,
1202  args
1203  );
1204  }
1205 
1206 #if FW_ENABLE_TEXT_LOGGING
1207 
1208  void TlmChanComponentBase ::
1209  eventOutText_out(
1210  FwIndexType portNum,
1211  FwEventIdType id,
1212  Fw::Time& timeTag,
1213  const Fw::LogSeverity& severity,
1214  Fw::TextLogString& text
1215  ) const
1216  {
1217  FW_ASSERT(
1218  (0 <= portNum) && (portNum < this->getNum_eventOutText_OutputPorts()),
1219  static_cast<FwAssertArgType>(portNum)
1220  );
1221 
1222  FW_ASSERT(
1223  this->m_eventOutText_OutputPort[portNum].isConnected(),
1224  static_cast<FwAssertArgType>(portNum)
1225  );
1226  this->m_eventOutText_OutputPort[portNum].invoke(
1227  id,
1228  timeTag,
1229  severity,
1230  text
1231  );
1232  }
1233 
1234 #endif
1235 
1236  void TlmChanComponentBase ::
1237  timeCaller_out(
1238  FwIndexType portNum,
1239  Fw::Time& time
1240  ) const
1241  {
1242  FW_ASSERT(
1243  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
1244  static_cast<FwAssertArgType>(portNum)
1245  );
1246 
1247  FW_ASSERT(
1248  this->m_timeCaller_OutputPort[portNum].isConnected(),
1249  static_cast<FwAssertArgType>(portNum)
1250  );
1251  this->m_timeCaller_OutputPort[portNum].invoke(
1252  time
1253  );
1254  }
1255 
1256 #endif
1257 
1258 }
Serialization/Deserialization operation was successful.
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:157
virtual void TlmRecv_handler(FwIndexType portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val)=0
Handler for input port TlmRecv.
message to exit active component task
void invoke(Fw::ComBuffer &data, U32 context) const
Invoke a port connection.
Definition: ComPortAc.cpp:181
void init()
Initialization function.
Definition: ComPortAc.cpp:162
Operation succeeded.
Definition: Os.hpp:27
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
virtual Fw::TlmValid TlmGet_handler(FwIndexType portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val)=0
Handler for input port TlmGet.
PlatformSizeType FwSizeType
void pingIn_handlerBase(FwIndexType portNum, U32 key)
Handler base-class function for input port pingIn.
Fw::InputTlmPort * get_TlmRecv_InputPort(FwIndexType portNum)
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
I32 FwEnumStoreType
void init()
Initialization function.
Status
status returned from the queue send function
Definition: Queue.hpp:30
Fw::TlmValid TlmGet_handlerBase(FwIndexType portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val)
Handler base-class function for input port TlmGet.
void init()
Initialization function.
Definition: SchedPortAc.cpp:73
bool isConnected_pingOut_OutputPort(FwIndexType portNum) const
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: TlmPortAc.cpp:95
void unLock()
unlock the mutex and assert success
Definition: Mutex.cpp:41
bool isConnected_PktSend_OutputPort(FwIndexType portNum) const
void invoke(U32 key) const
Invoke a port connection.
Definition: PingPortAc.cpp:170
bool isConnected_eventOut_OutputPort(FwIndexType portNum) const
bool isConnected_timeCaller_OutputPort(FwIndexType portNum) const
virtual ~TlmChanComponentBase()
Destroy TlmChanComponentBase object.
void init()
Initialization function.
Definition: TlmPortAc.cpp:89
static constexpr FwIndexType getNum_Run_InputPorts()
No time base has been established (Required)
void set_eventOut_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to eventOut[portNum].
Os::Queue m_queue
queue object for active component
void init()
Object initializer.
Definition: ObjBase.cpp:24
SerializeStatus
forward declaration for string
virtual void pingIn_handler(FwIndexType portNum, U32 key)=0
Handler for input port pingIn.
Message will block until space is available.
Definition: Queue.hpp:47
FwIdType FwEventIdType
The type of an event identifier.
void PktSend_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context) const
Invoke output port PktSend.
static constexpr FwSizeType CAPACITY
Definition: PingPortAc.hpp:34
virtual void lock()
Lock the guarded mutex.
#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
Svc::InputSchedPort * get_Run_InputPort(FwIndexType portNum)
void pingOut_out(FwIndexType portNum, U32 key) const
Invoke output port pingOut.
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize)
void init()
Initialization function.
Definition: PingPortAc.cpp:151
void invoke(Fw::Time &time) const
Invoke a port connection.
Definition: TimePortAc.cpp:170
static constexpr FwIndexType getNum_pingIn_InputPorts()
FwIdType FwChanIdType
The type of a telemetry channel identifier.
FwSizeType SizeType
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 log_WARNING_HI_TlmChanEpochProcessingCapReached(U32 numDeferred, U32 numTimesDeferredCountReached) const
Epoch Processing cap reached; one or more telemetry entries were deferred this cycle.
static constexpr FwIndexType getNum_TlmRecv_InputPorts()
A serious but recoverable event.
const char * toChar() const
Convert to a C-style char*.
bool isConnected() const
Definition: PortBase.cpp:38
Enum representing event severity.
void set_PktSend_OutputPort(FwIndexType portNum, Fw::InputComPort *port)
Connect port to PktSend[portNum].
static constexpr FwIndexType getNum_eventOut_OutputPorts()
#define PRI_FwIndexType
static constexpr FwIndexType getNum_PktSend_OutputPorts()
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:39
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
virtual void Run_preMsgHook(FwIndexType portNum, U32 context)
Pre-message hook for async input port Run.
virtual void Run_handler(FwIndexType portNum, U32 context)=0
Handler for input port Run.
PlatformQueuePriorityType FwQueuePriorityType
The type of queue priorities used.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: SchedPortAc.cpp:79
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args) const
Invoke a port connection.
Definition: LogPortAc.cpp:199
static constexpr FwIndexType getNum_pingOut_OutputPorts()
Svc::InputPingPort * get_pingIn_InputPort(FwIndexType portNum)
A message was sent requesting an exit of the loop.
virtual void pingIn_preMsgHook(FwIndexType portNum, U32 key)
Pre-message hook for async input port pingIn.
void TlmRecv_handlerBase(FwIndexType portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val)
Handler base-class function for input port TlmRecv.
void set_timeCaller_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to timeCaller[portNum].
PlatformIndexType FwIndexType
virtual void unLock()
Unlock the guarded mutex.
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:186
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void set_pingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to pingOut[portNum].
void init()
Initialization function.
Definition: PingPortAc.cpp:73
RateGroupDivider component implementation.
message sent/received okay
Definition: Queue.hpp:31
U8 BYTE
byte type
Definition: BasicTypes.h:57
Fw::InputTlmGetPort * get_TlmGet_InputPort(FwIndexType portNum)
void addCallPort(InputComPort *callPort)
Register an input port.
Definition: ComPortAc.cpp:168
static constexpr FwIndexType getNum_timeCaller_OutputPorts()
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: PingPortAc.cpp:79
static constexpr FwIndexType getNum_TlmGet_InputPorts()
Message will return with status when space is unavailable.
Definition: Queue.hpp:48
Implementation of malloc based allocator.
TlmChanComponentBase(const char *compName="")
Construct TlmChanComponentBase object.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
static constexpr FwSizeType CAPACITY
Definition: SchedPortAc.hpp:34
void Run_handlerBase(FwIndexType portNum, U32 context)
Handler base-class function for input port Run.
void lock()
lock the mutex and assert success
Definition: Mutex.cpp:34