F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
TlmPacketizerComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title TlmPacketizerComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for TlmPacketizer 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  TLMPACKETIZER_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
19  RUN_SCHED,
20  PINGIN_PING,
21  CMD_SET_LEVEL,
22  CMD_SEND_PKT,
23  };
24 
25  // Get the max size by constructing a union of the async input, command, and
26  // internal port serialization sizes
27  union BuffUnion {
31  };
32 
33  // Define a message buffer class large enough to handle all the
34  // asynchronous inputs to the component
35  class ComponentIpcSerializableBuffer :
37  {
38 
39  public:
40 
41  enum {
42  // Offset into data in buffer: Size of message ID and port number
43  DATA_OFFSET = sizeof(FwEnumStoreType) + sizeof(FwIndexType),
44  // Max data size
45  MAX_DATA_SIZE = sizeof(BuffUnion),
46  // Max message size: Size of message id + size of port + max data size
47  SERIALIZATION_SIZE = DATA_OFFSET + MAX_DATA_SIZE
48  };
49 
50  Fw::Serializable::SizeType getBuffCapacity() const {
51  return sizeof(m_buff);
52  }
53 
54  U8* getBuffAddr() {
55  return m_buff;
56  }
57 
58  const U8* getBuffAddr() const {
59  return m_buff;
60  }
61 
62  private:
63  // Should be the max of all the input ports serialized sizes...
64  U8 m_buff[SERIALIZATION_SIZE];
65 
66  };
67  }
68 
69  // ----------------------------------------------------------------------
70  // Component initialization
71  // ----------------------------------------------------------------------
72 
75  FwSizeType queueDepth,
76  FwEnumStoreType instance
77  )
78  {
79  // Initialize base class
81 
82  // Connect input port cmdIn
83  for (
84  FwIndexType port = 0;
85  port < static_cast<FwIndexType>(this->getNum_cmdIn_InputPorts());
86  port++
87  ) {
88  this->m_cmdIn_InputPort[port].init();
89  this->m_cmdIn_InputPort[port].addCallComp(
90  this,
91  m_p_cmdIn_in
92  );
93  this->m_cmdIn_InputPort[port].setPortNum(port);
94 
95 #if FW_OBJECT_NAMES == 1
96  Fw::ObjectName portName;
97  portName.format(
98  "%s_cmdIn_InputPort[%" PRI_FwIndexType "]",
99  this->m_objName.toChar(),
100  port
101  );
102  this->m_cmdIn_InputPort[port].setObjName(portName.toChar());
103 #endif
104  }
105 
106  // Connect input port Run
107  for (
108  FwIndexType port = 0;
109  port < static_cast<FwIndexType>(this->getNum_Run_InputPorts());
110  port++
111  ) {
112  this->m_Run_InputPort[port].init();
113  this->m_Run_InputPort[port].addCallComp(
114  this,
115  m_p_Run_in
116  );
117  this->m_Run_InputPort[port].setPortNum(port);
118 
119 #if FW_OBJECT_NAMES == 1
120  Fw::ObjectName portName;
121  portName.format(
122  "%s_Run_InputPort[%" PRI_FwIndexType "]",
123  this->m_objName.toChar(),
124  port
125  );
126  this->m_Run_InputPort[port].setObjName(portName.toChar());
127 #endif
128  }
129 
130  // Connect input port TlmGet
131  for (
132  FwIndexType port = 0;
133  port < static_cast<FwIndexType>(this->getNum_TlmGet_InputPorts());
134  port++
135  ) {
136  this->m_TlmGet_InputPort[port].init();
137  this->m_TlmGet_InputPort[port].addCallComp(
138  this,
139  m_p_TlmGet_in
140  );
141  this->m_TlmGet_InputPort[port].setPortNum(port);
142 
143 #if FW_OBJECT_NAMES == 1
144  Fw::ObjectName portName;
145  portName.format(
146  "%s_TlmGet_InputPort[%" PRI_FwIndexType "]",
147  this->m_objName.toChar(),
148  port
149  );
150  this->m_TlmGet_InputPort[port].setObjName(portName.toChar());
151 #endif
152  }
153 
154  // Connect input port TlmRecv
155  for (
156  FwIndexType port = 0;
157  port < static_cast<FwIndexType>(this->getNum_TlmRecv_InputPorts());
158  port++
159  ) {
160  this->m_TlmRecv_InputPort[port].init();
161  this->m_TlmRecv_InputPort[port].addCallComp(
162  this,
163  m_p_TlmRecv_in
164  );
165  this->m_TlmRecv_InputPort[port].setPortNum(port);
166 
167 #if FW_OBJECT_NAMES == 1
168  Fw::ObjectName portName;
169  portName.format(
170  "%s_TlmRecv_InputPort[%" PRI_FwIndexType "]",
171  this->m_objName.toChar(),
172  port
173  );
174  this->m_TlmRecv_InputPort[port].setObjName(portName.toChar());
175 #endif
176  }
177 
178  // Connect input port pingIn
179  for (
180  FwIndexType port = 0;
181  port < static_cast<FwIndexType>(this->getNum_pingIn_InputPorts());
182  port++
183  ) {
184  this->m_pingIn_InputPort[port].init();
185  this->m_pingIn_InputPort[port].addCallComp(
186  this,
187  m_p_pingIn_in
188  );
189  this->m_pingIn_InputPort[port].setPortNum(port);
190 
191 #if FW_OBJECT_NAMES == 1
192  Fw::ObjectName portName;
193  portName.format(
194  "%s_pingIn_InputPort[%" PRI_FwIndexType "]",
195  this->m_objName.toChar(),
196  port
197  );
198  this->m_pingIn_InputPort[port].setObjName(portName.toChar());
199 #endif
200  }
201 
202  // Connect output port cmdRegOut
203  for (
204  FwIndexType port = 0;
205  port < static_cast<FwIndexType>(this->getNum_cmdRegOut_OutputPorts());
206  port++
207  ) {
208  this->m_cmdRegOut_OutputPort[port].init();
209 
210 #if FW_OBJECT_NAMES == 1
211  Fw::ObjectName portName;
212  portName.format(
213  "%s_cmdRegOut_OutputPort[%" PRI_FwIndexType "]",
214  this->m_objName.toChar(),
215  port
216  );
217  this->m_cmdRegOut_OutputPort[port].setObjName(portName.toChar());
218 #endif
219  }
220 
221  // Connect output port cmdResponseOut
222  for (
223  FwIndexType port = 0;
224  port < static_cast<FwIndexType>(this->getNum_cmdResponseOut_OutputPorts());
225  port++
226  ) {
227  this->m_cmdResponseOut_OutputPort[port].init();
228 
229 #if FW_OBJECT_NAMES == 1
230  Fw::ObjectName portName;
231  portName.format(
232  "%s_cmdResponseOut_OutputPort[%" PRI_FwIndexType "]",
233  this->m_objName.toChar(),
234  port
235  );
236  this->m_cmdResponseOut_OutputPort[port].setObjName(portName.toChar());
237 #endif
238  }
239 
240  // Connect output port eventOut
241  for (
242  FwIndexType port = 0;
243  port < static_cast<FwIndexType>(this->getNum_eventOut_OutputPorts());
244  port++
245  ) {
246  this->m_eventOut_OutputPort[port].init();
247 
248 #if FW_OBJECT_NAMES == 1
249  Fw::ObjectName portName;
250  portName.format(
251  "%s_eventOut_OutputPort[%" PRI_FwIndexType "]",
252  this->m_objName.toChar(),
253  port
254  );
255  this->m_eventOut_OutputPort[port].setObjName(portName.toChar());
256 #endif
257  }
258 
259 #if FW_ENABLE_TEXT_LOGGING == 1
260  // Connect output port textEventOut
261  for (
262  FwIndexType port = 0;
263  port < static_cast<FwIndexType>(this->getNum_textEventOut_OutputPorts());
264  port++
265  ) {
266  this->m_textEventOut_OutputPort[port].init();
267 
268 #if FW_OBJECT_NAMES == 1
269  Fw::ObjectName portName;
270  portName.format(
271  "%s_textEventOut_OutputPort[%" PRI_FwIndexType "]",
272  this->m_objName.toChar(),
273  port
274  );
275  this->m_textEventOut_OutputPort[port].setObjName(portName.toChar());
276 #endif
277  }
278 #endif
279 
280  // Connect output port timeGetOut
281  for (
282  FwIndexType port = 0;
283  port < static_cast<FwIndexType>(this->getNum_timeGetOut_OutputPorts());
284  port++
285  ) {
286  this->m_timeGetOut_OutputPort[port].init();
287 
288 #if FW_OBJECT_NAMES == 1
289  Fw::ObjectName portName;
290  portName.format(
291  "%s_timeGetOut_OutputPort[%" PRI_FwIndexType "]",
292  this->m_objName.toChar(),
293  port
294  );
295  this->m_timeGetOut_OutputPort[port].setObjName(portName.toChar());
296 #endif
297  }
298 
299  // Connect output port tlmOut
300  for (
301  FwIndexType port = 0;
302  port < static_cast<FwIndexType>(this->getNum_tlmOut_OutputPorts());
303  port++
304  ) {
305  this->m_tlmOut_OutputPort[port].init();
306 
307 #if FW_OBJECT_NAMES == 1
308  Fw::ObjectName portName;
309  portName.format(
310  "%s_tlmOut_OutputPort[%" PRI_FwIndexType "]",
311  this->m_objName.toChar(),
312  port
313  );
314  this->m_tlmOut_OutputPort[port].setObjName(portName.toChar());
315 #endif
316  }
317 
318  // Connect output port PktSend
319  for (
320  FwIndexType port = 0;
321  port < static_cast<FwIndexType>(this->getNum_PktSend_OutputPorts());
322  port++
323  ) {
324  this->m_PktSend_OutputPort[port].init();
325 
326 #if FW_OBJECT_NAMES == 1
327  Fw::ObjectName portName;
328  portName.format(
329  "%s_PktSend_OutputPort[%" PRI_FwIndexType "]",
330  this->m_objName.toChar(),
331  port
332  );
333  this->m_PktSend_OutputPort[port].setObjName(portName.toChar());
334 #endif
335  }
336 
337  // Connect output port pingOut
338  for (
339  FwIndexType port = 0;
340  port < static_cast<FwIndexType>(this->getNum_pingOut_OutputPorts());
341  port++
342  ) {
343  this->m_pingOut_OutputPort[port].init();
344 
345 #if FW_OBJECT_NAMES == 1
346  Fw::ObjectName portName;
347  portName.format(
348  "%s_pingOut_OutputPort[%" PRI_FwIndexType "]",
349  this->m_objName.toChar(),
350  port
351  );
352  this->m_pingOut_OutputPort[port].setObjName(portName.toChar());
353 #endif
354  }
355 
356  // Create the queue
357  Os::Queue::Status qStat = this->createQueue(
358  queueDepth,
359  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
360  );
361  FW_ASSERT(
362  Os::Queue::Status::OP_OK == qStat,
363  static_cast<FwAssertArgType>(qStat)
364  );
365  }
366 
367  // ----------------------------------------------------------------------
368  // Getters for special input ports
369  // ----------------------------------------------------------------------
370 
373  {
374  FW_ASSERT(
375  (0 <= portNum) && (portNum < this->getNum_cmdIn_InputPorts()),
376  static_cast<FwAssertArgType>(portNum)
377  );
378 
379  return &this->m_cmdIn_InputPort[portNum];
380  }
381 
382  // ----------------------------------------------------------------------
383  // Getters for typed input ports
384  // ----------------------------------------------------------------------
385 
388  {
389  FW_ASSERT(
390  (0 <= portNum) && (portNum < this->getNum_Run_InputPorts()),
391  static_cast<FwAssertArgType>(portNum)
392  );
393 
394  return &this->m_Run_InputPort[portNum];
395  }
396 
399  {
400  FW_ASSERT(
401  (0 <= portNum) && (portNum < this->getNum_TlmGet_InputPorts()),
402  static_cast<FwAssertArgType>(portNum)
403  );
404 
405  return &this->m_TlmGet_InputPort[portNum];
406  }
407 
410  {
411  FW_ASSERT(
412  (0 <= portNum) && (portNum < this->getNum_TlmRecv_InputPorts()),
413  static_cast<FwAssertArgType>(portNum)
414  );
415 
416  return &this->m_TlmRecv_InputPort[portNum];
417  }
418 
421  {
422  FW_ASSERT(
423  (0 <= portNum) && (portNum < this->getNum_pingIn_InputPorts()),
424  static_cast<FwAssertArgType>(portNum)
425  );
426 
427  return &this->m_pingIn_InputPort[portNum];
428  }
429 
430  // ----------------------------------------------------------------------
431  // Connect input ports to special output ports
432  // ----------------------------------------------------------------------
433 
436  FwIndexType portNum,
437  Fw::InputCmdRegPort* port
438  )
439  {
440  FW_ASSERT(
441  (0 <= portNum) && (portNum < this->getNum_cmdRegOut_OutputPorts()),
442  static_cast<FwAssertArgType>(portNum)
443  );
444 
445  this->m_cmdRegOut_OutputPort[portNum].addCallPort(port);
446  }
447 
450  FwIndexType portNum,
452  )
453  {
454  FW_ASSERT(
455  (0 <= portNum) && (portNum < this->getNum_cmdResponseOut_OutputPorts()),
456  static_cast<FwAssertArgType>(portNum)
457  );
458 
459  this->m_cmdResponseOut_OutputPort[portNum].addCallPort(port);
460  }
461 
464  FwIndexType portNum,
465  Fw::InputLogPort* port
466  )
467  {
468  FW_ASSERT(
469  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
470  static_cast<FwAssertArgType>(portNum)
471  );
472 
473  this->m_eventOut_OutputPort[portNum].addCallPort(port);
474  }
475 
476 #if FW_ENABLE_TEXT_LOGGING == 1
477 
478  void TlmPacketizerComponentBase ::
479  set_textEventOut_OutputPort(
480  FwIndexType portNum,
482  )
483  {
484  FW_ASSERT(
485  (0 <= portNum) && (portNum < this->getNum_textEventOut_OutputPorts()),
486  static_cast<FwAssertArgType>(portNum)
487  );
488 
489  this->m_textEventOut_OutputPort[portNum].addCallPort(port);
490  }
491 
492 #endif
493 
496  FwIndexType portNum,
497  Fw::InputTimePort* port
498  )
499  {
500  FW_ASSERT(
501  (0 <= portNum) && (portNum < this->getNum_timeGetOut_OutputPorts()),
502  static_cast<FwAssertArgType>(portNum)
503  );
504 
505  this->m_timeGetOut_OutputPort[portNum].addCallPort(port);
506  }
507 
510  FwIndexType portNum,
511  Fw::InputTlmPort* port
512  )
513  {
514  FW_ASSERT(
515  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
516  static_cast<FwAssertArgType>(portNum)
517  );
518 
519  this->m_tlmOut_OutputPort[portNum].addCallPort(port);
520  }
521 
522  // ----------------------------------------------------------------------
523  // Connect typed input ports to typed output ports
524  // ----------------------------------------------------------------------
525 
528  FwIndexType portNum,
529  Fw::InputComPort* port
530  )
531  {
532  FW_ASSERT(
533  (0 <= portNum) && (portNum < this->getNum_PktSend_OutputPorts()),
534  static_cast<FwAssertArgType>(portNum)
535  );
536 
537  this->m_PktSend_OutputPort[portNum].addCallPort(port);
538  }
539 
542  FwIndexType portNum,
543  Svc::InputPingPort* port
544  )
545  {
546  FW_ASSERT(
547  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
548  static_cast<FwAssertArgType>(portNum)
549  );
550 
551  this->m_pingOut_OutputPort[portNum].addCallPort(port);
552  }
553 
554 #if FW_PORT_SERIALIZATION
555 
556  // ----------------------------------------------------------------------
557  // Connect serial input ports to special output ports
558  // ----------------------------------------------------------------------
559 
562  FwIndexType portNum,
563  Fw::InputSerializePort* port
564  )
565  {
566  FW_ASSERT(
567  (0 <= portNum) && (portNum < this->getNum_cmdRegOut_OutputPorts()),
568  static_cast<FwAssertArgType>(portNum)
569  );
570 
571  this->m_cmdRegOut_OutputPort[portNum].registerSerialPort(port);
572  }
573 
576  FwIndexType portNum,
577  Fw::InputSerializePort* port
578  )
579  {
580  FW_ASSERT(
581  (0 <= portNum) && (portNum < this->getNum_cmdResponseOut_OutputPorts()),
582  static_cast<FwAssertArgType>(portNum)
583  );
584 
585  this->m_cmdResponseOut_OutputPort[portNum].registerSerialPort(port);
586  }
587 
590  FwIndexType portNum,
591  Fw::InputSerializePort* port
592  )
593  {
594  FW_ASSERT(
595  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
596  static_cast<FwAssertArgType>(portNum)
597  );
598 
599  this->m_eventOut_OutputPort[portNum].registerSerialPort(port);
600  }
601 
602 #if FW_ENABLE_TEXT_LOGGING == 1
603 
604  void TlmPacketizerComponentBase ::
605  set_textEventOut_OutputPort(
606  FwIndexType portNum,
607  Fw::InputSerializePort* port
608  )
609  {
610  FW_ASSERT(
611  (0 <= portNum) && (portNum < this->getNum_textEventOut_OutputPorts()),
612  static_cast<FwAssertArgType>(portNum)
613  );
614 
615  this->m_textEventOut_OutputPort[portNum].registerSerialPort(port);
616  }
617 
618 #endif
619 
622  FwIndexType portNum,
623  Fw::InputSerializePort* port
624  )
625  {
626  FW_ASSERT(
627  (0 <= portNum) && (portNum < this->getNum_timeGetOut_OutputPorts()),
628  static_cast<FwAssertArgType>(portNum)
629  );
630 
631  this->m_timeGetOut_OutputPort[portNum].registerSerialPort(port);
632  }
633 
636  FwIndexType portNum,
637  Fw::InputSerializePort* port
638  )
639  {
640  FW_ASSERT(
641  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
642  static_cast<FwAssertArgType>(portNum)
643  );
644 
645  this->m_tlmOut_OutputPort[portNum].registerSerialPort(port);
646  }
647 
648 #endif
649 
650 #if FW_PORT_SERIALIZATION
651 
652  // ----------------------------------------------------------------------
653  // Connect serial input ports to typed output ports
654  // ----------------------------------------------------------------------
655 
658  FwIndexType portNum,
659  Fw::InputSerializePort* port
660  )
661  {
662  FW_ASSERT(
663  (0 <= portNum) && (portNum < this->getNum_PktSend_OutputPorts()),
664  static_cast<FwAssertArgType>(portNum)
665  );
666 
667  this->m_PktSend_OutputPort[portNum].registerSerialPort(port);
668  }
669 
672  FwIndexType portNum,
673  Fw::InputSerializePort* port
674  )
675  {
676  FW_ASSERT(
677  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
678  static_cast<FwAssertArgType>(portNum)
679  );
680 
681  this->m_pingOut_OutputPort[portNum].registerSerialPort(port);
682  }
683 
684 #endif
685 
686  // ----------------------------------------------------------------------
687  // Command registration
688  // ----------------------------------------------------------------------
689 
692  {
693  FW_ASSERT(this->m_cmdRegOut_OutputPort[0].isConnected());
694 
695  this->m_cmdRegOut_OutputPort[0].invoke(
696  this->getIdBase() + OPCODE_SET_LEVEL
697  );
698 
699  this->m_cmdRegOut_OutputPort[0].invoke(
700  this->getIdBase() + OPCODE_SEND_PKT
701  );
702  }
703 
704  // ----------------------------------------------------------------------
705  // Component construction and destruction
706  // ----------------------------------------------------------------------
707 
709  TlmPacketizerComponentBase(const char* compName) :
710  Fw::ActiveComponentBase(compName)
711  {
712 
713  }
714 
717  {
718 
719  }
720 
721  // ----------------------------------------------------------------------
722  // Connection status queries for special output ports
723  // ----------------------------------------------------------------------
724 
727  {
728  FW_ASSERT(
729  (0 <= portNum) && (portNum < this->getNum_cmdRegOut_OutputPorts()),
730  static_cast<FwAssertArgType>(portNum)
731  );
732 
733  return this->m_cmdRegOut_OutputPort[portNum].isConnected();
734  }
735 
738  {
739  FW_ASSERT(
740  (0 <= portNum) && (portNum < this->getNum_cmdResponseOut_OutputPorts()),
741  static_cast<FwAssertArgType>(portNum)
742  );
743 
744  return this->m_cmdResponseOut_OutputPort[portNum].isConnected();
745  }
746 
749  {
750  FW_ASSERT(
751  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
752  static_cast<FwAssertArgType>(portNum)
753  );
754 
755  return this->m_eventOut_OutputPort[portNum].isConnected();
756  }
757 
758 #if FW_ENABLE_TEXT_LOGGING == 1
759 
760  bool TlmPacketizerComponentBase ::
761  isConnected_textEventOut_OutputPort(FwIndexType portNum)
762  {
763  FW_ASSERT(
764  (0 <= portNum) && (portNum < this->getNum_textEventOut_OutputPorts()),
765  static_cast<FwAssertArgType>(portNum)
766  );
767 
768  return this->m_textEventOut_OutputPort[portNum].isConnected();
769  }
770 
771 #endif
772 
775  {
776  FW_ASSERT(
777  (0 <= portNum) && (portNum < this->getNum_timeGetOut_OutputPorts()),
778  static_cast<FwAssertArgType>(portNum)
779  );
780 
781  return this->m_timeGetOut_OutputPort[portNum].isConnected();
782  }
783 
786  {
787  FW_ASSERT(
788  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
789  static_cast<FwAssertArgType>(portNum)
790  );
791 
792  return this->m_tlmOut_OutputPort[portNum].isConnected();
793  }
794 
795  // ----------------------------------------------------------------------
796  // Connection status queries for typed output ports
797  // ----------------------------------------------------------------------
798 
801  {
802  FW_ASSERT(
803  (0 <= portNum) && (portNum < this->getNum_PktSend_OutputPorts()),
804  static_cast<FwAssertArgType>(portNum)
805  );
806 
807  return this->m_PktSend_OutputPort[portNum].isConnected();
808  }
809 
812  {
813  FW_ASSERT(
814  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
815  static_cast<FwAssertArgType>(portNum)
816  );
817 
818  return this->m_pingOut_OutputPort[portNum].isConnected();
819  }
820 
821  // ----------------------------------------------------------------------
822  // Port handler base-class functions for typed input ports
823  //
824  // Call these functions directly to bypass the corresponding ports
825  // ----------------------------------------------------------------------
826 
829  FwIndexType portNum,
830  U32 context
831  )
832  {
833  // Make sure port number is valid
834  FW_ASSERT(
835  (0 <= portNum) && (portNum < this->getNum_Run_InputPorts()),
836  static_cast<FwAssertArgType>(portNum)
837  );
838 
839  // Call pre-message hook
841  portNum,
842  context
843  );
844  ComponentIpcSerializableBuffer msg;
846 
847  // Serialize message ID
848  _status = msg.serializeFrom(
849  static_cast<FwEnumStoreType>(RUN_SCHED)
850  );
851  FW_ASSERT(
852  _status == Fw::FW_SERIALIZE_OK,
853  static_cast<FwAssertArgType>(_status)
854  );
855 
856  // Serialize port number
857  _status = msg.serializeFrom(portNum);
858  FW_ASSERT(
859  _status == Fw::FW_SERIALIZE_OK,
860  static_cast<FwAssertArgType>(_status)
861  );
862 
863  // Serialize argument context
864  _status = msg.serializeFrom(context);
865  FW_ASSERT(
866  _status == Fw::FW_SERIALIZE_OK,
867  static_cast<FwAssertArgType>(_status)
868  );
869 
870  // Send message
872  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
873 
874  FW_ASSERT(
875  qStatus == Os::Queue::OP_OK,
876  static_cast<FwAssertArgType>(qStatus)
877  );
878  }
879 
882  FwIndexType portNum,
883  FwChanIdType id,
884  Fw::Time& timeTag,
885  Fw::TlmBuffer& val
886  )
887  {
888  // Make sure port number is valid
889  FW_ASSERT(
890  (0 <= portNum) && (portNum < this->getNum_TlmGet_InputPorts()),
891  static_cast<FwAssertArgType>(portNum)
892  );
893 
894  Fw::TlmValid retVal;
895 
896  // Call handler function
897  retVal = this->TlmGet_handler(
898  portNum,
899  id,
900  timeTag,
901  val
902  );
903 
904  return retVal;
905  }
906 
909  FwIndexType portNum,
910  FwChanIdType id,
911  Fw::Time& timeTag,
912  Fw::TlmBuffer& val
913  )
914  {
915  // Make sure port number is valid
916  FW_ASSERT(
917  (0 <= portNum) && (portNum < this->getNum_TlmRecv_InputPorts()),
918  static_cast<FwAssertArgType>(portNum)
919  );
920 
921  // Call handler function
922  this->TlmRecv_handler(
923  portNum,
924  id,
925  timeTag,
926  val
927  );
928  }
929 
932  FwIndexType portNum,
933  U32 key
934  )
935  {
936  // Make sure port number is valid
937  FW_ASSERT(
938  (0 <= portNum) && (portNum < this->getNum_pingIn_InputPorts()),
939  static_cast<FwAssertArgType>(portNum)
940  );
941 
942  // Call pre-message hook
944  portNum,
945  key
946  );
947  ComponentIpcSerializableBuffer msg;
949 
950  // Serialize message ID
951  _status = msg.serializeFrom(
952  static_cast<FwEnumStoreType>(PINGIN_PING)
953  );
954  FW_ASSERT(
955  _status == Fw::FW_SERIALIZE_OK,
956  static_cast<FwAssertArgType>(_status)
957  );
958 
959  // Serialize port number
960  _status = msg.serializeFrom(portNum);
961  FW_ASSERT(
962  _status == Fw::FW_SERIALIZE_OK,
963  static_cast<FwAssertArgType>(_status)
964  );
965 
966  // Serialize argument key
967  _status = msg.serializeFrom(key);
968  FW_ASSERT(
969  _status == Fw::FW_SERIALIZE_OK,
970  static_cast<FwAssertArgType>(_status)
971  );
972 
973  // Send message
975  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
976 
977  FW_ASSERT(
978  qStatus == Os::Queue::OP_OK,
979  static_cast<FwAssertArgType>(qStatus)
980  );
981  }
982 
983  // ----------------------------------------------------------------------
984  // Pre-message hooks for typed async input ports
985  //
986  // Each of these functions is invoked just before processing a message
987  // on the corresponding port. By default, they do nothing. You can
988  // override them to provide specific pre-message behavior.
989  // ----------------------------------------------------------------------
990 
993  FwIndexType portNum,
994  U32 context
995  )
996  {
997  // Default: no-op
998  }
999 
1002  FwIndexType portNum,
1003  U32 key
1004  )
1005  {
1006  // Default: no-op
1007  }
1008 
1009  // ----------------------------------------------------------------------
1010  // Invocation functions for typed output ports
1011  // ----------------------------------------------------------------------
1012 
1015  FwIndexType portNum,
1016  Fw::ComBuffer& data,
1017  U32 context
1018  )
1019  {
1020  FW_ASSERT(
1021  (0 <= portNum) && (portNum < this->getNum_PktSend_OutputPorts()),
1022  static_cast<FwAssertArgType>(portNum)
1023  );
1024 
1025  FW_ASSERT(
1026  this->m_PktSend_OutputPort[portNum].isConnected(),
1027  static_cast<FwAssertArgType>(portNum)
1028  );
1029  this->m_PktSend_OutputPort[portNum].invoke(
1030  data,
1031  context
1032  );
1033  }
1034 
1037  FwIndexType portNum,
1038  U32 key
1039  )
1040  {
1041  FW_ASSERT(
1042  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
1043  static_cast<FwAssertArgType>(portNum)
1044  );
1045 
1046  FW_ASSERT(
1047  this->m_pingOut_OutputPort[portNum].isConnected(),
1048  static_cast<FwAssertArgType>(portNum)
1049  );
1050  this->m_pingOut_OutputPort[portNum].invoke(
1051  key
1052  );
1053  }
1054 
1055  // ----------------------------------------------------------------------
1056  // Command response
1057  // ----------------------------------------------------------------------
1058 
1061  FwOpcodeType opCode,
1062  U32 cmdSeq,
1063  Fw::CmdResponse response
1064  )
1065  {
1066  FW_ASSERT(this->m_cmdResponseOut_OutputPort[0].isConnected());
1067  this->m_cmdResponseOut_OutputPort[0].invoke(opCode, cmdSeq, response);
1068  }
1069 
1070  // ----------------------------------------------------------------------
1071  // Command handler base-class functions
1072  //
1073  // Call these functions directly to bypass the command input port
1074  // ----------------------------------------------------------------------
1075 
1078  FwOpcodeType opCode,
1079  U32 cmdSeq,
1080  Fw::CmdArgBuffer& args
1081  )
1082  {
1083  // Call pre-message hook
1084  this->SET_LEVEL_preMsgHook(opCode,cmdSeq);
1085 
1086  // Defer deserializing arguments to the message dispatcher
1087  // to avoid deserializing and reserializing just for IPC
1088  ComponentIpcSerializableBuffer msg;
1090 
1091  // Serialize for IPC
1092  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(CMD_SET_LEVEL));
1093  FW_ASSERT (
1094  _status == Fw::FW_SERIALIZE_OK,
1095  static_cast<FwAssertArgType>(_status)
1096  );
1097 
1098  // Fake port number to make message dequeue work
1099  FwIndexType port = 0;
1100 
1101  _status = msg.serializeFrom(port);
1102  FW_ASSERT (
1103  _status == Fw::FW_SERIALIZE_OK,
1104  static_cast<FwAssertArgType>(_status)
1105  );
1106 
1107  _status = msg.serializeFrom(opCode);
1108  FW_ASSERT (
1109  _status == Fw::FW_SERIALIZE_OK,
1110  static_cast<FwAssertArgType>(_status)
1111  );
1112 
1113  _status = msg.serializeFrom(cmdSeq);
1114  FW_ASSERT (
1115  _status == Fw::FW_SERIALIZE_OK,
1116  static_cast<FwAssertArgType>(_status)
1117  );
1118 
1119  _status = msg.serializeFrom(args);
1120  FW_ASSERT (
1121  _status == Fw::FW_SERIALIZE_OK,
1122  static_cast<FwAssertArgType>(_status)
1123  );
1124 
1125  // Send message
1127  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1128 
1129  FW_ASSERT(
1130  qStatus == Os::Queue::OP_OK,
1131  static_cast<FwAssertArgType>(qStatus)
1132  );
1133  }
1134 
1137  FwOpcodeType opCode,
1138  U32 cmdSeq,
1139  Fw::CmdArgBuffer& args
1140  )
1141  {
1142  // Call pre-message hook
1143  this->SEND_PKT_preMsgHook(opCode,cmdSeq);
1144 
1145  // Defer deserializing arguments to the message dispatcher
1146  // to avoid deserializing and reserializing just for IPC
1147  ComponentIpcSerializableBuffer msg;
1149 
1150  // Serialize for IPC
1151  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(CMD_SEND_PKT));
1152  FW_ASSERT (
1153  _status == Fw::FW_SERIALIZE_OK,
1154  static_cast<FwAssertArgType>(_status)
1155  );
1156 
1157  // Fake port number to make message dequeue work
1158  FwIndexType port = 0;
1159 
1160  _status = msg.serializeFrom(port);
1161  FW_ASSERT (
1162  _status == Fw::FW_SERIALIZE_OK,
1163  static_cast<FwAssertArgType>(_status)
1164  );
1165 
1166  _status = msg.serializeFrom(opCode);
1167  FW_ASSERT (
1168  _status == Fw::FW_SERIALIZE_OK,
1169  static_cast<FwAssertArgType>(_status)
1170  );
1171 
1172  _status = msg.serializeFrom(cmdSeq);
1173  FW_ASSERT (
1174  _status == Fw::FW_SERIALIZE_OK,
1175  static_cast<FwAssertArgType>(_status)
1176  );
1177 
1178  _status = msg.serializeFrom(args);
1179  FW_ASSERT (
1180  _status == Fw::FW_SERIALIZE_OK,
1181  static_cast<FwAssertArgType>(_status)
1182  );
1183 
1184  // Send message
1186  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1187 
1188  FW_ASSERT(
1189  qStatus == Os::Queue::OP_OK,
1190  static_cast<FwAssertArgType>(qStatus)
1191  );
1192  }
1193 
1194  // ----------------------------------------------------------------------
1195  // Pre-message hooks for async commands
1196  //
1197  // Each of these functions is invoked just before processing the
1198  // corresponding command. By default they do nothing. You can
1199  // override them to provide specific pre-command behavior.
1200  // ----------------------------------------------------------------------
1201 
1204  FwOpcodeType opCode,
1205  U32 cmdSeq
1206  )
1207  {
1208  // Defaults to no-op; can be overridden
1209  (void) opCode;
1210  (void) cmdSeq;
1211  }
1212 
1215  FwOpcodeType opCode,
1216  U32 cmdSeq
1217  )
1218  {
1219  // Defaults to no-op; can be overridden
1220  (void) opCode;
1221  (void) cmdSeq;
1222  }
1223 
1224  // ----------------------------------------------------------------------
1225  // Event logging functions
1226  // ----------------------------------------------------------------------
1227 
1230  {
1231  // Get the time
1232  Fw::Time _logTime;
1233  if (this->m_timeGetOut_OutputPort[0].isConnected()) {
1234  this->m_timeGetOut_OutputPort[0].invoke(_logTime);
1235  }
1236 
1237  FwEventIdType _id = static_cast<FwEventIdType>(0);
1238 
1239  _id = this->getIdBase() + EVENTID_NOCHAN;
1240 
1241  // Emit the event on the log port
1242  if (this->m_eventOut_OutputPort[0].isConnected()) {
1243  Fw::LogBuffer _logBuff;
1245 
1246 #if FW_AMPCS_COMPATIBLE
1247  // Serialize the number of arguments
1248  _status = _logBuff.serializeFrom(static_cast<U8>(1));
1249  FW_ASSERT(
1250  _status == Fw::FW_SERIALIZE_OK,
1251  static_cast<FwAssertArgType>(_status)
1252  );
1253 #endif
1254 
1255 #if FW_AMPCS_COMPATIBLE
1256  // Serialize the argument size
1257  _status = _logBuff.serializeFrom(
1258  static_cast<U8>(sizeof(FwChanIdType))
1259  );
1260  FW_ASSERT(
1261  _status == Fw::FW_SERIALIZE_OK,
1262  static_cast<FwAssertArgType>(_status)
1263  );
1264 #endif
1265  _status = _logBuff.serializeFrom(Id);
1266  FW_ASSERT(
1267  _status == Fw::FW_SERIALIZE_OK,
1268  static_cast<FwAssertArgType>(_status)
1269  );
1270 
1271  this->m_eventOut_OutputPort[0].invoke(
1272  _id,
1273  _logTime,
1275  _logBuff
1276  );
1277  }
1278 
1279  // Emit the event on the text log port
1280 #if FW_ENABLE_TEXT_LOGGING
1281  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1282 #if FW_OBJECT_NAMES == 1
1283  const char* _formatString =
1284  "(%s) %s: Telemetry ID 0x%" PRIx32 " not packetized";
1285 #else
1286  const char* _formatString =
1287  "%s: Telemetry ID 0x%" PRIx32 " not packetized";
1288 #endif
1289 
1290  Fw::TextLogString _logString;
1291  _logString.format(
1292  _formatString,
1293 #if FW_OBJECT_NAMES == 1
1294  this->m_objName.toChar(),
1295 #endif
1296  "NoChan ",
1297  Id
1298  );
1299 
1300  this->m_textEventOut_OutputPort[0].invoke(
1301  _id,
1302  _logTime,
1304  _logString
1305  );
1306  }
1307 #endif
1308  }
1309 
1312  {
1313  // Get the time
1314  Fw::Time _logTime;
1315  if (this->m_timeGetOut_OutputPort[0].isConnected()) {
1316  this->m_timeGetOut_OutputPort[0].invoke(_logTime);
1317  }
1318 
1319  FwEventIdType _id = static_cast<FwEventIdType>(0);
1320 
1321  _id = this->getIdBase() + EVENTID_LEVELSET;
1322 
1323  // Emit the event on the log port
1324  if (this->m_eventOut_OutputPort[0].isConnected()) {
1325  Fw::LogBuffer _logBuff;
1327 
1328 #if FW_AMPCS_COMPATIBLE
1329  // Serialize the number of arguments
1330  _status = _logBuff.serializeFrom(static_cast<U8>(1));
1331  FW_ASSERT(
1332  _status == Fw::FW_SERIALIZE_OK,
1333  static_cast<FwAssertArgType>(_status)
1334  );
1335 #endif
1336 
1337 #if FW_AMPCS_COMPATIBLE
1338  // Serialize the argument size
1339  _status = _logBuff.serializeFrom(
1340  static_cast<U8>(sizeof(FwChanIdType))
1341  );
1342  FW_ASSERT(
1343  _status == Fw::FW_SERIALIZE_OK,
1344  static_cast<FwAssertArgType>(_status)
1345  );
1346 #endif
1347  _status = _logBuff.serializeFrom(id);
1348  FW_ASSERT(
1349  _status == Fw::FW_SERIALIZE_OK,
1350  static_cast<FwAssertArgType>(_status)
1351  );
1352 
1353  this->m_eventOut_OutputPort[0].invoke(
1354  _id,
1355  _logTime,
1357  _logBuff
1358  );
1359  }
1360 
1361  // Emit the event on the text log port
1362 #if FW_ENABLE_TEXT_LOGGING
1363  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1364 #if FW_OBJECT_NAMES == 1
1365  const char* _formatString =
1366  "(%s) %s: Telemetry send level to %" PRIu32 "";
1367 #else
1368  const char* _formatString =
1369  "%s: Telemetry send level to %" PRIu32 "";
1370 #endif
1371 
1372  Fw::TextLogString _logString;
1373  _logString.format(
1374  _formatString,
1375 #if FW_OBJECT_NAMES == 1
1376  this->m_objName.toChar(),
1377 #endif
1378  "LevelSet ",
1379  id
1380  );
1381 
1382  this->m_textEventOut_OutputPort[0].invoke(
1383  _id,
1384  _logTime,
1386  _logString
1387  );
1388  }
1389 #endif
1390  }
1391 
1394  FwChanIdType level,
1395  FwChanIdType max
1396  ) const
1397  {
1398  // Get the time
1399  Fw::Time _logTime;
1400  if (this->m_timeGetOut_OutputPort[0].isConnected()) {
1401  this->m_timeGetOut_OutputPort[0].invoke(_logTime);
1402  }
1403 
1404  FwEventIdType _id = static_cast<FwEventIdType>(0);
1405 
1406  _id = this->getIdBase() + EVENTID_MAXLEVELEXCEED;
1407 
1408  // Emit the event on the log port
1409  if (this->m_eventOut_OutputPort[0].isConnected()) {
1410  Fw::LogBuffer _logBuff;
1412 
1413 #if FW_AMPCS_COMPATIBLE
1414  // Serialize the number of arguments
1415  _status = _logBuff.serializeFrom(static_cast<U8>(2));
1416  FW_ASSERT(
1417  _status == Fw::FW_SERIALIZE_OK,
1418  static_cast<FwAssertArgType>(_status)
1419  );
1420 #endif
1421 
1422 #if FW_AMPCS_COMPATIBLE
1423  // Serialize the argument size
1424  _status = _logBuff.serializeFrom(
1425  static_cast<U8>(sizeof(FwChanIdType))
1426  );
1427  FW_ASSERT(
1428  _status == Fw::FW_SERIALIZE_OK,
1429  static_cast<FwAssertArgType>(_status)
1430  );
1431 #endif
1432  _status = _logBuff.serializeFrom(level);
1433  FW_ASSERT(
1434  _status == Fw::FW_SERIALIZE_OK,
1435  static_cast<FwAssertArgType>(_status)
1436  );
1437 
1438 #if FW_AMPCS_COMPATIBLE
1439  // Serialize the argument size
1440  _status = _logBuff.serializeFrom(
1441  static_cast<U8>(sizeof(FwChanIdType))
1442  );
1443  FW_ASSERT(
1444  _status == Fw::FW_SERIALIZE_OK,
1445  static_cast<FwAssertArgType>(_status)
1446  );
1447 #endif
1448  _status = _logBuff.serializeFrom(max);
1449  FW_ASSERT(
1450  _status == Fw::FW_SERIALIZE_OK,
1451  static_cast<FwAssertArgType>(_status)
1452  );
1453 
1454  this->m_eventOut_OutputPort[0].invoke(
1455  _id,
1456  _logTime,
1458  _logBuff
1459  );
1460  }
1461 
1462  // Emit the event on the text log port
1463 #if FW_ENABLE_TEXT_LOGGING
1464  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1465 #if FW_OBJECT_NAMES == 1
1466  const char* _formatString =
1467  "(%s) %s: Requested send level %" PRIu32 " higher than max packet level of %" PRIu32 "";
1468 #else
1469  const char* _formatString =
1470  "%s: Requested send level %" PRIu32 " higher than max packet level of %" PRIu32 "";
1471 #endif
1472 
1473  Fw::TextLogString _logString;
1474  _logString.format(
1475  _formatString,
1476 #if FW_OBJECT_NAMES == 1
1477  this->m_objName.toChar(),
1478 #endif
1479  "MaxLevelExceed ",
1480  level,
1481  max
1482  );
1483 
1484  this->m_textEventOut_OutputPort[0].invoke(
1485  _id,
1486  _logTime,
1488  _logString
1489  );
1490  }
1491 #endif
1492  }
1493 
1496  {
1497  // Get the time
1498  Fw::Time _logTime;
1499  if (this->m_timeGetOut_OutputPort[0].isConnected()) {
1500  this->m_timeGetOut_OutputPort[0].invoke(_logTime);
1501  }
1502 
1503  FwEventIdType _id = static_cast<FwEventIdType>(0);
1504 
1505  _id = this->getIdBase() + EVENTID_PACKETSENT;
1506 
1507  // Emit the event on the log port
1508  if (this->m_eventOut_OutputPort[0].isConnected()) {
1509  Fw::LogBuffer _logBuff;
1511 
1512 #if FW_AMPCS_COMPATIBLE
1513  // Serialize the number of arguments
1514  _status = _logBuff.serializeFrom(static_cast<U8>(1));
1515  FW_ASSERT(
1516  _status == Fw::FW_SERIALIZE_OK,
1517  static_cast<FwAssertArgType>(_status)
1518  );
1519 #endif
1520 
1521 #if FW_AMPCS_COMPATIBLE
1522  // Serialize the argument size
1523  _status = _logBuff.serializeFrom(
1524  static_cast<U8>(sizeof(U32))
1525  );
1526  FW_ASSERT(
1527  _status == Fw::FW_SERIALIZE_OK,
1528  static_cast<FwAssertArgType>(_status)
1529  );
1530 #endif
1531  _status = _logBuff.serializeFrom(id);
1532  FW_ASSERT(
1533  _status == Fw::FW_SERIALIZE_OK,
1534  static_cast<FwAssertArgType>(_status)
1535  );
1536 
1537  this->m_eventOut_OutputPort[0].invoke(
1538  _id,
1539  _logTime,
1541  _logBuff
1542  );
1543  }
1544 
1545  // Emit the event on the text log port
1546 #if FW_ENABLE_TEXT_LOGGING
1547  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1548 #if FW_OBJECT_NAMES == 1
1549  const char* _formatString =
1550  "(%s) %s: Sent packet ID %" PRIu32 "";
1551 #else
1552  const char* _formatString =
1553  "%s: Sent packet ID %" PRIu32 "";
1554 #endif
1555 
1556  Fw::TextLogString _logString;
1557  _logString.format(
1558  _formatString,
1559 #if FW_OBJECT_NAMES == 1
1560  this->m_objName.toChar(),
1561 #endif
1562  "PacketSent ",
1563  id
1564  );
1565 
1566  this->m_textEventOut_OutputPort[0].invoke(
1567  _id,
1568  _logTime,
1570  _logString
1571  );
1572  }
1573 #endif
1574  }
1575 
1578  {
1579  // Get the time
1580  Fw::Time _logTime;
1581  if (this->m_timeGetOut_OutputPort[0].isConnected()) {
1582  this->m_timeGetOut_OutputPort[0].invoke(_logTime);
1583  }
1584 
1585  FwEventIdType _id = static_cast<FwEventIdType>(0);
1586 
1587  _id = this->getIdBase() + EVENTID_PACKETNOTFOUND;
1588 
1589  // Emit the event on the log port
1590  if (this->m_eventOut_OutputPort[0].isConnected()) {
1591  Fw::LogBuffer _logBuff;
1593 
1594 #if FW_AMPCS_COMPATIBLE
1595  // Serialize the number of arguments
1596  _status = _logBuff.serializeFrom(static_cast<U8>(1));
1597  FW_ASSERT(
1598  _status == Fw::FW_SERIALIZE_OK,
1599  static_cast<FwAssertArgType>(_status)
1600  );
1601 #endif
1602 
1603 #if FW_AMPCS_COMPATIBLE
1604  // Serialize the argument size
1605  _status = _logBuff.serializeFrom(
1606  static_cast<U8>(sizeof(U32))
1607  );
1608  FW_ASSERT(
1609  _status == Fw::FW_SERIALIZE_OK,
1610  static_cast<FwAssertArgType>(_status)
1611  );
1612 #endif
1613  _status = _logBuff.serializeFrom(id);
1614  FW_ASSERT(
1615  _status == Fw::FW_SERIALIZE_OK,
1616  static_cast<FwAssertArgType>(_status)
1617  );
1618 
1619  this->m_eventOut_OutputPort[0].invoke(
1620  _id,
1621  _logTime,
1623  _logBuff
1624  );
1625  }
1626 
1627  // Emit the event on the text log port
1628 #if FW_ENABLE_TEXT_LOGGING
1629  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1630 #if FW_OBJECT_NAMES == 1
1631  const char* _formatString =
1632  "(%s) %s: Could not find packet ID %" PRIu32 "";
1633 #else
1634  const char* _formatString =
1635  "%s: Could not find packet ID %" PRIu32 "";
1636 #endif
1637 
1638  Fw::TextLogString _logString;
1639  _logString.format(
1640  _formatString,
1641 #if FW_OBJECT_NAMES == 1
1642  this->m_objName.toChar(),
1643 #endif
1644  "PacketNotFound ",
1645  id
1646  );
1647 
1648  this->m_textEventOut_OutputPort[0].invoke(
1649  _id,
1650  _logTime,
1652  _logString
1653  );
1654  }
1655 #endif
1656  }
1657 
1658  // ----------------------------------------------------------------------
1659  // Telemetry write functions
1660  // ----------------------------------------------------------------------
1661 
1664  FwChanIdType arg,
1665  Fw::Time _tlmTime
1666  ) const
1667  {
1668  if (this->m_tlmOut_OutputPort[0].isConnected()) {
1669  if (
1670  this->m_timeGetOut_OutputPort[0].isConnected() &&
1671  (_tlmTime == Fw::ZERO_TIME)
1672  ) {
1673  this->m_timeGetOut_OutputPort[0].invoke(_tlmTime);
1674  }
1675 
1676  Fw::TlmBuffer _tlmBuff;
1677  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
1678  FW_ASSERT(
1679  _stat == Fw::FW_SERIALIZE_OK,
1680  static_cast<FwAssertArgType>(_stat)
1681  );
1682 
1683  FwChanIdType _id;
1684 
1685  _id = this->getIdBase() + CHANNELID_SENDLEVEL;
1686 
1687  this->m_tlmOut_OutputPort[0].invoke(
1688  _id,
1689  _tlmTime,
1690  _tlmBuff
1691  );
1692  }
1693  }
1694 
1695  // ----------------------------------------------------------------------
1696  // Time
1697  // ----------------------------------------------------------------------
1698 
1700  getTime() const
1701  {
1702  if (this->m_timeGetOut_OutputPort[0].isConnected()) {
1703  Fw::Time _time;
1704  this->m_timeGetOut_OutputPort[0].invoke(_time);
1705  return _time;
1706  }
1707  else {
1708  return Fw::Time(TimeBase::TB_NONE, 0, 0);
1709  }
1710  }
1711 
1712  // ----------------------------------------------------------------------
1713  // Message dispatch functions
1714  // ----------------------------------------------------------------------
1715 
1716  Fw::QueuedComponentBase::MsgDispatchStatus TlmPacketizerComponentBase ::
1717  doDispatch()
1718  {
1719  ComponentIpcSerializableBuffer _msg;
1720  FwQueuePriorityType _priority = 0;
1721 
1722  Os::Queue::Status _msgStatus = this->m_queue.receive(
1723  _msg,
1725  _priority
1726  );
1727  FW_ASSERT(
1728  _msgStatus == Os::Queue::OP_OK,
1729  static_cast<FwAssertArgType>(_msgStatus)
1730  );
1731 
1732  // Reset to beginning of buffer
1733  _msg.resetDeser();
1734 
1735  FwEnumStoreType _desMsg = 0;
1736  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
1737  FW_ASSERT(
1738  _deserStatus == Fw::FW_SERIALIZE_OK,
1739  static_cast<FwAssertArgType>(_deserStatus)
1740  );
1741 
1742  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
1743 
1744  if (_msgType == TLMPACKETIZER_COMPONENT_EXIT) {
1745  return MSG_DISPATCH_EXIT;
1746  }
1747 
1748  FwIndexType portNum = 0;
1749  _deserStatus = _msg.deserializeTo(portNum);
1750  FW_ASSERT(
1751  _deserStatus == Fw::FW_SERIALIZE_OK,
1752  static_cast<FwAssertArgType>(_deserStatus)
1753  );
1754 
1755  switch (_msgType) {
1756  // Handle async input port Run
1757  case RUN_SCHED: {
1758  // Deserialize argument context
1759  U32 context;
1760  _deserStatus = _msg.deserializeTo(context);
1761  FW_ASSERT(
1762  _deserStatus == Fw::FW_SERIALIZE_OK,
1763  static_cast<FwAssertArgType>(_deserStatus)
1764  );
1765  // Call handler function
1766  this->Run_handler(
1767  portNum,
1768  context
1769  );
1770 
1771  break;
1772  }
1773 
1774  // Handle async input port pingIn
1775  case PINGIN_PING: {
1776  // Deserialize argument key
1777  U32 key;
1778  _deserStatus = _msg.deserializeTo(key);
1779  FW_ASSERT(
1780  _deserStatus == Fw::FW_SERIALIZE_OK,
1781  static_cast<FwAssertArgType>(_deserStatus)
1782  );
1783  // Call handler function
1784  this->pingIn_handler(
1785  portNum,
1786  key
1787  );
1788 
1789  break;
1790  }
1791 
1792  // Handle command SET_LEVEL
1793  case CMD_SET_LEVEL: {
1794  // Deserialize opcode
1795  FwOpcodeType _opCode = 0;
1796  _deserStatus = _msg.deserializeTo(_opCode);
1797  FW_ASSERT (
1798  _deserStatus == Fw::FW_SERIALIZE_OK,
1799  static_cast<FwAssertArgType>(_deserStatus)
1800  );
1801 
1802  // Deserialize command sequence
1803  U32 _cmdSeq = 0;
1804  _deserStatus = _msg.deserializeTo(_cmdSeq);
1805  FW_ASSERT (
1806  _deserStatus == Fw::FW_SERIALIZE_OK,
1807  static_cast<FwAssertArgType>(_deserStatus)
1808  );
1809 
1810  // Deserialize command argument buffer
1811  Fw::CmdArgBuffer args;
1812  _deserStatus = _msg.deserializeTo(args);
1813  FW_ASSERT (
1814  _deserStatus == Fw::FW_SERIALIZE_OK,
1815  static_cast<FwAssertArgType>(_deserStatus)
1816  );
1817 
1818  // Reset buffer
1819  args.resetDeser();
1820 
1821  // Deserialize argument level
1822  FwChanIdType level;
1823  _deserStatus = args.deserializeTo(level);
1824  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
1825  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
1826  this->cmdResponse_out(
1827  _opCode,
1828  _cmdSeq,
1830  );
1831  }
1832  // Don't crash the task if bad arguments were passed from the ground
1833  break;
1834  }
1835 
1836  // Make sure there was no data left over.
1837  // That means the argument buffer size was incorrect.
1838 #if FW_CMD_CHECK_RESIDUAL
1839  if (args.getBuffLeft() != 0) {
1840  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
1841  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
1842  }
1843  // Don't crash the task if bad arguments were passed from the ground
1844  break;
1845  }
1846 #endif
1847 
1848  // Call handler function
1849  this->SET_LEVEL_cmdHandler(
1850  _opCode, _cmdSeq,
1851  level
1852  );
1853 
1854  break;
1855  }
1856 
1857  // Handle command SEND_PKT
1858  case CMD_SEND_PKT: {
1859  // Deserialize opcode
1860  FwOpcodeType _opCode = 0;
1861  _deserStatus = _msg.deserializeTo(_opCode);
1862  FW_ASSERT (
1863  _deserStatus == Fw::FW_SERIALIZE_OK,
1864  static_cast<FwAssertArgType>(_deserStatus)
1865  );
1866 
1867  // Deserialize command sequence
1868  U32 _cmdSeq = 0;
1869  _deserStatus = _msg.deserializeTo(_cmdSeq);
1870  FW_ASSERT (
1871  _deserStatus == Fw::FW_SERIALIZE_OK,
1872  static_cast<FwAssertArgType>(_deserStatus)
1873  );
1874 
1875  // Deserialize command argument buffer
1876  Fw::CmdArgBuffer args;
1877  _deserStatus = _msg.deserializeTo(args);
1878  FW_ASSERT (
1879  _deserStatus == Fw::FW_SERIALIZE_OK,
1880  static_cast<FwAssertArgType>(_deserStatus)
1881  );
1882 
1883  // Reset buffer
1884  args.resetDeser();
1885 
1886  // Deserialize argument id
1887  U32 id;
1888  _deserStatus = args.deserializeTo(id);
1889  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
1890  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
1891  this->cmdResponse_out(
1892  _opCode,
1893  _cmdSeq,
1895  );
1896  }
1897  // Don't crash the task if bad arguments were passed from the ground
1898  break;
1899  }
1900 
1901  // Make sure there was no data left over.
1902  // That means the argument buffer size was incorrect.
1903 #if FW_CMD_CHECK_RESIDUAL
1904  if (args.getBuffLeft() != 0) {
1905  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
1906  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
1907  }
1908  // Don't crash the task if bad arguments were passed from the ground
1909  break;
1910  }
1911 #endif
1912 
1913  // Call handler function
1914  this->SEND_PKT_cmdHandler(
1915  _opCode, _cmdSeq,
1916  id
1917  );
1918 
1919  break;
1920  }
1921 
1922  default:
1923  return MSG_DISPATCH_ERROR;
1924  }
1925 
1926  return MSG_DISPATCH_OK;
1927  }
1928 
1929  // ----------------------------------------------------------------------
1930  // Calls for messages received on special input ports
1931  // ----------------------------------------------------------------------
1932 
1933  void TlmPacketizerComponentBase ::
1934  m_p_cmdIn_in(
1935  Fw::PassiveComponentBase* callComp,
1936  FwIndexType portNum,
1937  FwOpcodeType opCode,
1938  U32 cmdSeq,
1939  Fw::CmdArgBuffer& args
1940  )
1941  {
1942  FW_ASSERT(callComp);
1943  TlmPacketizerComponentBase* compPtr = static_cast<TlmPacketizerComponentBase*>(callComp);
1944 
1945  const U32 idBase = callComp->getIdBase();
1946  FW_ASSERT(opCode >= idBase, static_cast<FwAssertArgType>(opCode), static_cast<FwAssertArgType>(idBase));
1947 
1948  // Select base class function based on opcode
1949  switch (opCode - idBase) {
1950  case OPCODE_SET_LEVEL: {
1951  compPtr->SET_LEVEL_cmdHandlerBase(
1952  opCode,
1953  cmdSeq,
1954  args
1955  );
1956  break;
1957  }
1958 
1959  case OPCODE_SEND_PKT: {
1960  compPtr->SEND_PKT_cmdHandlerBase(
1961  opCode,
1962  cmdSeq,
1963  args
1964  );
1965  break;
1966  }
1967  }
1968  }
1969 
1970  // ----------------------------------------------------------------------
1971  // Calls for messages received on typed input ports
1972  // ----------------------------------------------------------------------
1973 
1974  void TlmPacketizerComponentBase ::
1975  m_p_Run_in(
1976  Fw::PassiveComponentBase* callComp,
1977  FwIndexType portNum,
1978  U32 context
1979  )
1980  {
1981  FW_ASSERT(callComp);
1982  TlmPacketizerComponentBase* compPtr = static_cast<TlmPacketizerComponentBase*>(callComp);
1983  compPtr->Run_handlerBase(
1984  portNum,
1985  context
1986  );
1987  }
1988 
1989  Fw::TlmValid TlmPacketizerComponentBase ::
1990  m_p_TlmGet_in(
1991  Fw::PassiveComponentBase* callComp,
1992  FwIndexType portNum,
1993  FwChanIdType id,
1994  Fw::Time& timeTag,
1995  Fw::TlmBuffer& val
1996  )
1997  {
1998  FW_ASSERT(callComp);
1999  TlmPacketizerComponentBase* compPtr = static_cast<TlmPacketizerComponentBase*>(callComp);
2000  return compPtr->TlmGet_handlerBase(
2001  portNum,
2002  id,
2003  timeTag,
2004  val
2005  );
2006  }
2007 
2008  void TlmPacketizerComponentBase ::
2009  m_p_TlmRecv_in(
2010  Fw::PassiveComponentBase* callComp,
2011  FwIndexType portNum,
2012  FwChanIdType id,
2013  Fw::Time& timeTag,
2014  Fw::TlmBuffer& val
2015  )
2016  {
2017  FW_ASSERT(callComp);
2018  TlmPacketizerComponentBase* compPtr = static_cast<TlmPacketizerComponentBase*>(callComp);
2019  compPtr->TlmRecv_handlerBase(
2020  portNum,
2021  id,
2022  timeTag,
2023  val
2024  );
2025  }
2026 
2027  void TlmPacketizerComponentBase ::
2028  m_p_pingIn_in(
2029  Fw::PassiveComponentBase* callComp,
2030  FwIndexType portNum,
2031  U32 key
2032  )
2033  {
2034  FW_ASSERT(callComp);
2035  TlmPacketizerComponentBase* compPtr = static_cast<TlmPacketizerComponentBase*>(callComp);
2036  compPtr->pingIn_handlerBase(
2037  portNum,
2038  key
2039  );
2040  }
2041 
2042 }
Serialization/Deserialization operation was successful.
void SEND_PKT_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
void invoke(Fw::ComBuffer &data, U32 context) const
Invoke a port interface.
Definition: ComPortAc.cpp:156
void init()
Initialization function.
Definition: ComPortAc.cpp:137
void set_PktSend_OutputPort(FwIndexType portNum, Fw::InputComPort *port)
Connect port to PktSend[portNum].
FwIdType FwOpcodeType
The type of a command opcode.
Operation succeeded.
Definition: Os.hpp:26
void pingIn_handlerBase(FwIndexType portNum, U32 key)
Handler base-class function for input port pingIn.
PlatformSizeType FwSizeType
Status receive(U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority) override
receive a message from the queue through delegate
Definition: Queue.cpp:63
Fw::InputCmdPort * get_cmdIn_InputPort(FwIndexType portNum)
I32 FwEnumStoreType
static constexpr FwIndexType getNum_cmdResponseOut_OutputPorts()
void init()
Initialization function.
virtual void TlmRecv_handler(FwIndexType portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val)=0
Handler for input port TlmRecv.
void Run_handlerBase(FwIndexType portNum, U32 context)
Handler base-class function for input port Run.
Status
status returned from the queue send function
Definition: Queue.hpp:30
void init()
Initialization function.
Definition: SchedPortAc.cpp:56
static constexpr FwIndexType getNum_PktSend_OutputPorts()
void init()
Initialization function.
Definition: CmdPortAc.cpp:56
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: TlmPortAc.cpp:62
The size of the serial representations of the port arguments.
Definition: SchedPortAc.hpp:36
void log_WARNING_LO_NoChan(FwChanIdType Id) const
static constexpr FwIndexType getNum_pingIn_InputPorts()
SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)
deserialize 8-bit unsigned int
void invoke(U32 key) const
Invoke a port interface.
Definition: PingPortAc.cpp:147
void TlmRecv_handlerBase(FwIndexType portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val)
Handler base-class function for input port TlmRecv.
const Time ZERO_TIME
Definition: Time.cpp:5
void PktSend_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Invoke output port PktSend.
bool isConnected_tlmOut_OutputPort(FwIndexType portNum)
void init()
Initialization function.
Definition: TlmPortAc.cpp:144
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
Enum representing a command response.
void init()
Initialization function.
Definition: TlmPortAc.cpp:56
No time base has been established (Required)
void addCallPort(InputCmdRegPort *callPort)
Register an input port.
virtual void pingIn_preMsgHook(FwIndexType portNum, U32 key)
Pre-message hook for async input port pingIn.
virtual void SET_LEVEL_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, FwChanIdType level)=0
Os::Queue m_queue
queue object for active component
void addCallPort(InputTlmPort *callPort)
Register an input port.
Definition: TlmPortAc.cpp:150
virtual ~TlmPacketizerComponentBase()
Destroy TlmPacketizerComponentBase object.
void set_pingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to pingOut[portNum].
void init()
Object initializer.
Definition: ObjBase.cpp:24
void tlmWrite_SendLevel(FwChanIdType arg, Fw::Time _tlmTime=Fw::Time()) const
Telemetry channel is not part of a telemetry packet.
SerializeStatus
forward declaration for string
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CmdPortAc.cpp:62
Message will block until space is available.
Definition: Queue.hpp:47
FwIdType FwEventIdType
The type of an event identifier.
void invoke(FwOpcodeType opCode) const
Invoke a port interface.
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:40
Serializable::SizeType getBuffLeft() const
returns how much deserialization buffer is left
Svc::InputPingPort * get_pingIn_InputPort(FwIndexType portNum)
void init()
Initialization function.
Definition: TimePortAc.cpp:128
static constexpr FwIndexType getNum_cmdRegOut_OutputPorts()
Fw::InputTlmGetPort * get_TlmGet_InputPort(FwIndexType portNum)
Less important informational events.
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize)
virtual void Run_preMsgHook(FwIndexType portNum, U32 context)
Pre-message hook for async input port Run.
A less serious but recoverable event.
void init()
Initialization function.
Definition: PingPortAc.cpp:128
static constexpr FwIndexType getNum_timeGetOut_OutputPorts()
void invoke(Fw::Time &time) const
Invoke a port interface.
Definition: TimePortAc.cpp:147
const char * toChar() const
Definition: ObjectName.hpp:50
void invoke(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response) const
Invoke a port interface.
FwIdType FwChanIdType
The type of a telemetry channel identifier.
FwSizeType SizeType
void addCallPort(InputPingPort *callPort)
Register an input port.
Definition: PingPortAc.cpp:134
Status send(const U8 *buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType) override
send a message into the queue through delegate
Definition: Queue.cpp:46
The size of the serial representations of the port arguments.
Definition: CmdPortAc.hpp:38
void resetDeser()
reset deserialization to beginning
virtual void pingIn_handler(FwIndexType portNum, U32 key)=0
Handler for input port pingIn.
void invoke(FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) const
Invoke a port interface.
Definition: TlmPortAc.cpp:163
bool isConnected_cmdRegOut_OutputPort(FwIndexType portNum)
void set_eventOut_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to eventOut[portNum].
bool isConnected() const
Definition: PortBase.cpp:38
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)
serialize 8-bit unsigned int
static constexpr FwIndexType getNum_tlmOut_OutputPorts()
void set_tlmOut_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to tlmOut[portNum].
#define PRI_FwIndexType
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:55
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: LogPortAc.cpp:151
virtual void Run_handler(FwIndexType portNum, U32 context)=0
Handler for input port Run.
void setPortNum(FwIndexType portNum)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
message to exit active component task
BlockingType
message type
Definition: Queue.hpp:46
static constexpr FwIndexType getNum_eventOut_OutputPorts()
Command failed to deserialize.
PlatformQueuePriorityType FwQueuePriorityType
The type of queue priorities used.
Important informational events.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: SchedPortAc.cpp:62
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args) const
Invoke a port interface.
Definition: LogPortAc.cpp:170
virtual void SEND_PKT_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, U32 id)=0
void log_WARNING_LO_MaxLevelExceed(FwChanIdType level, FwChanIdType max) const
A message was sent requesting an exit of the loop.
PlatformIndexType FwIndexType
TlmPacketizerComponentBase(const char *compName="")
Construct TlmPacketizerComponentBase object.
The size of the serial representations of the port arguments.
Definition: PingPortAc.hpp:36
void log_ACTIVITY_HI_LevelSet(FwChanIdType id) const
void set_timeGetOut_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to timeGetOut[portNum].
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:157
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void init()
Initialization function.
virtual void SEND_PKT_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command SEND_PKT.
void init()
Initialization function.
Definition: PingPortAc.cpp:56
RateGroupDivider component implementation.
message sent/received okay
Definition: Queue.hpp:31
U8 BYTE
byte type
Definition: BasicTypes.h:56
bool isConnected_PktSend_OutputPort(FwIndexType portNum)
Svc::InputSchedPort * get_Run_InputPort(FwIndexType portNum)
bool isConnected_pingOut_OutputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_TlmGet_InputPorts()
void addCallPort(InputComPort *callPort)
Register an input port.
Definition: ComPortAc.cpp:143
Fw::InputTlmPort * get_TlmRecv_InputPort(FwIndexType portNum)
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: PingPortAc.cpp:62
bool isConnected_timeGetOut_OutputPort(FwIndexType portNum)
void regCommands()
Register commands with the Command Dispatcher.
bool isConnected_eventOut_OutputPort(FwIndexType portNum)
Message will return with status when space is unavailable.
Definition: Queue.hpp:48
Implementation of malloc based allocator.
bool isConnected_cmdResponseOut_OutputPort(FwIndexType portNum)
void init()
Initialization function.
void SET_LEVEL_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
virtual void SET_LEVEL_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command SET_LEVEL.
static constexpr FwIndexType getNum_pingOut_OutputPorts()
#define FW_ASSERT(...)
Definition: Assert.hpp:14
static constexpr FwIndexType getNum_Run_InputPorts()
void set_cmdResponseOut_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to cmdResponseOut[portNum].
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
void addCallPort(InputCmdResponsePort *callPort)
Register an input port.
virtual Fw::TlmValid TlmGet_handler(FwIndexType portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val)=0
Handler for input port TlmGet.
static constexpr FwIndexType getNum_TlmRecv_InputPorts()
void set_cmdRegOut_OutputPort(FwIndexType portNum, Fw::InputCmdRegPort *port)
Connect port to cmdRegOut[portNum].
static constexpr FwIndexType getNum_cmdIn_InputPorts()