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