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  this->m_PktSend_OutputPort[portNum].invoke(
1055  data,
1056  context
1057  );
1058  }
1059 
1062  FwIndexType portNum,
1063  U32 key
1064  )
1065  {
1066  FW_ASSERT(
1067  portNum < this->getNum_pingOut_OutputPorts(),
1068  static_cast<FwAssertArgType>(portNum)
1069  );
1070  this->m_pingOut_OutputPort[portNum].invoke(
1071  key
1072  );
1073  }
1074 
1075  // ----------------------------------------------------------------------
1076  // Command response
1077  // ----------------------------------------------------------------------
1078 
1081  FwOpcodeType opCode,
1082  U32 cmdSeq,
1083  Fw::CmdResponse response
1084  )
1085  {
1086  FW_ASSERT(this->m_cmdResponseOut_OutputPort[0].isConnected());
1087  this->m_cmdResponseOut_OutputPort[0].invoke(opCode, cmdSeq, response);
1088  }
1089 
1090  // ----------------------------------------------------------------------
1091  // Command handler base-class functions
1092  //
1093  // Call these functions directly to bypass the command input port
1094  // ----------------------------------------------------------------------
1095 
1098  FwOpcodeType opCode,
1099  U32 cmdSeq,
1100  Fw::CmdArgBuffer& args
1101  )
1102  {
1103  // Call pre-message hook
1104  this->SET_LEVEL_preMsgHook(opCode,cmdSeq);
1105 
1106  // Defer deserializing arguments to the message dispatcher
1107  // to avoid deserializing and reserializing just for IPC
1108  ComponentIpcSerializableBuffer msg;
1110 
1111  // Serialize for IPC
1112  _status = msg.serialize(static_cast<FwEnumStoreType>(CMD_SET_LEVEL));
1113  FW_ASSERT (
1114  _status == Fw::FW_SERIALIZE_OK,
1115  static_cast<FwAssertArgType>(_status)
1116  );
1117 
1118  // Fake port number to make message dequeue work
1119  FwIndexType port = 0;
1120 
1121  _status = msg.serialize(port);
1122  FW_ASSERT (
1123  _status == Fw::FW_SERIALIZE_OK,
1124  static_cast<FwAssertArgType>(_status)
1125  );
1126 
1127  _status = msg.serialize(opCode);
1128  FW_ASSERT (
1129  _status == Fw::FW_SERIALIZE_OK,
1130  static_cast<FwAssertArgType>(_status)
1131  );
1132 
1133  _status = msg.serialize(cmdSeq);
1134  FW_ASSERT (
1135  _status == Fw::FW_SERIALIZE_OK,
1136  static_cast<FwAssertArgType>(_status)
1137  );
1138 
1139  _status = msg.serialize(args);
1140  FW_ASSERT (
1141  _status == Fw::FW_SERIALIZE_OK,
1142  static_cast<FwAssertArgType>(_status)
1143  );
1144 
1145  // Send message
1147  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1148 
1149  FW_ASSERT(
1150  qStatus == Os::Queue::OP_OK,
1151  static_cast<FwAssertArgType>(qStatus)
1152  );
1153  }
1154 
1157  FwOpcodeType opCode,
1158  U32 cmdSeq,
1159  Fw::CmdArgBuffer& args
1160  )
1161  {
1162  // Call pre-message hook
1163  this->SEND_PKT_preMsgHook(opCode,cmdSeq);
1164 
1165  // Defer deserializing arguments to the message dispatcher
1166  // to avoid deserializing and reserializing just for IPC
1167  ComponentIpcSerializableBuffer msg;
1169 
1170  // Serialize for IPC
1171  _status = msg.serialize(static_cast<FwEnumStoreType>(CMD_SEND_PKT));
1172  FW_ASSERT (
1173  _status == Fw::FW_SERIALIZE_OK,
1174  static_cast<FwAssertArgType>(_status)
1175  );
1176 
1177  // Fake port number to make message dequeue work
1178  FwIndexType port = 0;
1179 
1180  _status = msg.serialize(port);
1181  FW_ASSERT (
1182  _status == Fw::FW_SERIALIZE_OK,
1183  static_cast<FwAssertArgType>(_status)
1184  );
1185 
1186  _status = msg.serialize(opCode);
1187  FW_ASSERT (
1188  _status == Fw::FW_SERIALIZE_OK,
1189  static_cast<FwAssertArgType>(_status)
1190  );
1191 
1192  _status = msg.serialize(cmdSeq);
1193  FW_ASSERT (
1194  _status == Fw::FW_SERIALIZE_OK,
1195  static_cast<FwAssertArgType>(_status)
1196  );
1197 
1198  _status = msg.serialize(args);
1199  FW_ASSERT (
1200  _status == Fw::FW_SERIALIZE_OK,
1201  static_cast<FwAssertArgType>(_status)
1202  );
1203 
1204  // Send message
1206  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1207 
1208  FW_ASSERT(
1209  qStatus == Os::Queue::OP_OK,
1210  static_cast<FwAssertArgType>(qStatus)
1211  );
1212  }
1213 
1214  // ----------------------------------------------------------------------
1215  // Pre-message hooks for async commands
1216  //
1217  // Each of these functions is invoked just before processing the
1218  // corresponding command. By default they do nothing. You can
1219  // override them to provide specific pre-command behavior.
1220  // ----------------------------------------------------------------------
1221 
1224  FwOpcodeType opCode,
1225  U32 cmdSeq
1226  )
1227  {
1228  // Defaults to no-op; can be overridden
1229  (void) opCode;
1230  (void) cmdSeq;
1231  }
1232 
1235  FwOpcodeType opCode,
1236  U32 cmdSeq
1237  )
1238  {
1239  // Defaults to no-op; can be overridden
1240  (void) opCode;
1241  (void) cmdSeq;
1242  }
1243 
1244  // ----------------------------------------------------------------------
1245  // Event logging functions
1246  // ----------------------------------------------------------------------
1247 
1250  {
1251  // Get the time
1252  Fw::Time _logTime;
1253  if (this->m_timeGetOut_OutputPort[0].isConnected()) {
1254  this->m_timeGetOut_OutputPort[0].invoke(_logTime);
1255  }
1256 
1257  FwEventIdType _id = static_cast<FwEventIdType>(0);
1258 
1259  _id = this->getIdBase() + EVENTID_NOCHAN;
1260 
1261  // Emit the event on the log port
1262  if (this->m_eventOut_OutputPort[0].isConnected()) {
1263  Fw::LogBuffer _logBuff;
1265 
1266 #if FW_AMPCS_COMPATIBLE
1267  // Serialize the number of arguments
1268  _status = _logBuff.serialize(static_cast<U8>(1));
1269  FW_ASSERT(
1270  _status == Fw::FW_SERIALIZE_OK,
1271  static_cast<FwAssertArgType>(_status)
1272  );
1273 #endif
1274 
1275 #if FW_AMPCS_COMPATIBLE
1276  // Serialize the argument size
1277  _status = _logBuff.serialize(
1278  static_cast<U8>(sizeof(U32))
1279  );
1280  FW_ASSERT(
1281  _status == Fw::FW_SERIALIZE_OK,
1282  static_cast<FwAssertArgType>(_status)
1283  );
1284 #endif
1285  _status = _logBuff.serialize(Id);
1286  FW_ASSERT(
1287  _status == Fw::FW_SERIALIZE_OK,
1288  static_cast<FwAssertArgType>(_status)
1289  );
1290 
1291  this->m_eventOut_OutputPort[0].invoke(
1292  _id,
1293  _logTime,
1295  _logBuff
1296  );
1297  }
1298 
1299  // Emit the event on the text log port
1300 #if FW_ENABLE_TEXT_LOGGING
1301  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1302 #if FW_OBJECT_NAMES == 1
1303  const char* _formatString =
1304  "(%s) %s: Telemetry ID 0x%" PRIx32 " not packetized";
1305 #else
1306  const char* _formatString =
1307  "%s: Telemetry ID 0x%" PRIx32 " not packetized";
1308 #endif
1309 
1310  Fw::TextLogString _logString;
1311  _logString.format(
1312  _formatString,
1313 #if FW_OBJECT_NAMES == 1
1314  this->m_objName.toChar(),
1315 #endif
1316  "NoChan ",
1317  Id
1318  );
1319 
1320  this->m_textEventOut_OutputPort[0].invoke(
1321  _id,
1322  _logTime,
1324  _logString
1325  );
1326  }
1327 #endif
1328  }
1329 
1332  {
1333  // Get the time
1334  Fw::Time _logTime;
1335  if (this->m_timeGetOut_OutputPort[0].isConnected()) {
1336  this->m_timeGetOut_OutputPort[0].invoke(_logTime);
1337  }
1338 
1339  FwEventIdType _id = static_cast<FwEventIdType>(0);
1340 
1341  _id = this->getIdBase() + EVENTID_LEVELSET;
1342 
1343  // Emit the event on the log port
1344  if (this->m_eventOut_OutputPort[0].isConnected()) {
1345  Fw::LogBuffer _logBuff;
1347 
1348 #if FW_AMPCS_COMPATIBLE
1349  // Serialize the number of arguments
1350  _status = _logBuff.serialize(static_cast<U8>(1));
1351  FW_ASSERT(
1352  _status == Fw::FW_SERIALIZE_OK,
1353  static_cast<FwAssertArgType>(_status)
1354  );
1355 #endif
1356 
1357 #if FW_AMPCS_COMPATIBLE
1358  // Serialize the argument size
1359  _status = _logBuff.serialize(
1360  static_cast<U8>(sizeof(U32))
1361  );
1362  FW_ASSERT(
1363  _status == Fw::FW_SERIALIZE_OK,
1364  static_cast<FwAssertArgType>(_status)
1365  );
1366 #endif
1367  _status = _logBuff.serialize(id);
1368  FW_ASSERT(
1369  _status == Fw::FW_SERIALIZE_OK,
1370  static_cast<FwAssertArgType>(_status)
1371  );
1372 
1373  this->m_eventOut_OutputPort[0].invoke(
1374  _id,
1375  _logTime,
1377  _logBuff
1378  );
1379  }
1380 
1381  // Emit the event on the text log port
1382 #if FW_ENABLE_TEXT_LOGGING
1383  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1384 #if FW_OBJECT_NAMES == 1
1385  const char* _formatString =
1386  "(%s) %s: Telemetry send level to %" PRIu32 "";
1387 #else
1388  const char* _formatString =
1389  "%s: Telemetry send level to %" PRIu32 "";
1390 #endif
1391 
1392  Fw::TextLogString _logString;
1393  _logString.format(
1394  _formatString,
1395 #if FW_OBJECT_NAMES == 1
1396  this->m_objName.toChar(),
1397 #endif
1398  "LevelSet ",
1399  id
1400  );
1401 
1402  this->m_textEventOut_OutputPort[0].invoke(
1403  _id,
1404  _logTime,
1406  _logString
1407  );
1408  }
1409 #endif
1410  }
1411 
1414  U32 level,
1415  U32 max
1416  ) const
1417  {
1418  // Get the time
1419  Fw::Time _logTime;
1420  if (this->m_timeGetOut_OutputPort[0].isConnected()) {
1421  this->m_timeGetOut_OutputPort[0].invoke(_logTime);
1422  }
1423 
1424  FwEventIdType _id = static_cast<FwEventIdType>(0);
1425 
1426  _id = this->getIdBase() + EVENTID_MAXLEVELEXCEED;
1427 
1428  // Emit the event on the log port
1429  if (this->m_eventOut_OutputPort[0].isConnected()) {
1430  Fw::LogBuffer _logBuff;
1432 
1433 #if FW_AMPCS_COMPATIBLE
1434  // Serialize the number of arguments
1435  _status = _logBuff.serialize(static_cast<U8>(2));
1436  FW_ASSERT(
1437  _status == Fw::FW_SERIALIZE_OK,
1438  static_cast<FwAssertArgType>(_status)
1439  );
1440 #endif
1441 
1442 #if FW_AMPCS_COMPATIBLE
1443  // Serialize the argument size
1444  _status = _logBuff.serialize(
1445  static_cast<U8>(sizeof(U32))
1446  );
1447  FW_ASSERT(
1448  _status == Fw::FW_SERIALIZE_OK,
1449  static_cast<FwAssertArgType>(_status)
1450  );
1451 #endif
1452  _status = _logBuff.serialize(level);
1453  FW_ASSERT(
1454  _status == Fw::FW_SERIALIZE_OK,
1455  static_cast<FwAssertArgType>(_status)
1456  );
1457 
1458 #if FW_AMPCS_COMPATIBLE
1459  // Serialize the argument size
1460  _status = _logBuff.serialize(
1461  static_cast<U8>(sizeof(U32))
1462  );
1463  FW_ASSERT(
1464  _status == Fw::FW_SERIALIZE_OK,
1465  static_cast<FwAssertArgType>(_status)
1466  );
1467 #endif
1468  _status = _logBuff.serialize(max);
1469  FW_ASSERT(
1470  _status == Fw::FW_SERIALIZE_OK,
1471  static_cast<FwAssertArgType>(_status)
1472  );
1473 
1474  this->m_eventOut_OutputPort[0].invoke(
1475  _id,
1476  _logTime,
1478  _logBuff
1479  );
1480  }
1481 
1482  // Emit the event on the text log port
1483 #if FW_ENABLE_TEXT_LOGGING
1484  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1485 #if FW_OBJECT_NAMES == 1
1486  const char* _formatString =
1487  "(%s) %s: Requested send level %" PRIu32 " higher than max packet level of %" PRIu32 "";
1488 #else
1489  const char* _formatString =
1490  "%s: Requested send level %" PRIu32 " higher than max packet level of %" PRIu32 "";
1491 #endif
1492 
1493  Fw::TextLogString _logString;
1494  _logString.format(
1495  _formatString,
1496 #if FW_OBJECT_NAMES == 1
1497  this->m_objName.toChar(),
1498 #endif
1499  "MaxLevelExceed ",
1500  level,
1501  max
1502  );
1503 
1504  this->m_textEventOut_OutputPort[0].invoke(
1505  _id,
1506  _logTime,
1508  _logString
1509  );
1510  }
1511 #endif
1512  }
1513 
1516  {
1517  // Get the time
1518  Fw::Time _logTime;
1519  if (this->m_timeGetOut_OutputPort[0].isConnected()) {
1520  this->m_timeGetOut_OutputPort[0].invoke(_logTime);
1521  }
1522 
1523  FwEventIdType _id = static_cast<FwEventIdType>(0);
1524 
1525  _id = this->getIdBase() + EVENTID_PACKETSENT;
1526 
1527  // Emit the event on the log port
1528  if (this->m_eventOut_OutputPort[0].isConnected()) {
1529  Fw::LogBuffer _logBuff;
1531 
1532 #if FW_AMPCS_COMPATIBLE
1533  // Serialize the number of arguments
1534  _status = _logBuff.serialize(static_cast<U8>(1));
1535  FW_ASSERT(
1536  _status == Fw::FW_SERIALIZE_OK,
1537  static_cast<FwAssertArgType>(_status)
1538  );
1539 #endif
1540 
1541 #if FW_AMPCS_COMPATIBLE
1542  // Serialize the argument size
1543  _status = _logBuff.serialize(
1544  static_cast<U8>(sizeof(U32))
1545  );
1546  FW_ASSERT(
1547  _status == Fw::FW_SERIALIZE_OK,
1548  static_cast<FwAssertArgType>(_status)
1549  );
1550 #endif
1551  _status = _logBuff.serialize(id);
1552  FW_ASSERT(
1553  _status == Fw::FW_SERIALIZE_OK,
1554  static_cast<FwAssertArgType>(_status)
1555  );
1556 
1557  this->m_eventOut_OutputPort[0].invoke(
1558  _id,
1559  _logTime,
1561  _logBuff
1562  );
1563  }
1564 
1565  // Emit the event on the text log port
1566 #if FW_ENABLE_TEXT_LOGGING
1567  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1568 #if FW_OBJECT_NAMES == 1
1569  const char* _formatString =
1570  "(%s) %s: Sent packet ID %" PRIu32 "";
1571 #else
1572  const char* _formatString =
1573  "%s: Sent packet ID %" PRIu32 "";
1574 #endif
1575 
1576  Fw::TextLogString _logString;
1577  _logString.format(
1578  _formatString,
1579 #if FW_OBJECT_NAMES == 1
1580  this->m_objName.toChar(),
1581 #endif
1582  "PacketSent ",
1583  id
1584  );
1585 
1586  this->m_textEventOut_OutputPort[0].invoke(
1587  _id,
1588  _logTime,
1590  _logString
1591  );
1592  }
1593 #endif
1594  }
1595 
1598  {
1599  // Get the time
1600  Fw::Time _logTime;
1601  if (this->m_timeGetOut_OutputPort[0].isConnected()) {
1602  this->m_timeGetOut_OutputPort[0].invoke(_logTime);
1603  }
1604 
1605  FwEventIdType _id = static_cast<FwEventIdType>(0);
1606 
1607  _id = this->getIdBase() + EVENTID_PACKETNOTFOUND;
1608 
1609  // Emit the event on the log port
1610  if (this->m_eventOut_OutputPort[0].isConnected()) {
1611  Fw::LogBuffer _logBuff;
1613 
1614 #if FW_AMPCS_COMPATIBLE
1615  // Serialize the number of arguments
1616  _status = _logBuff.serialize(static_cast<U8>(1));
1617  FW_ASSERT(
1618  _status == Fw::FW_SERIALIZE_OK,
1619  static_cast<FwAssertArgType>(_status)
1620  );
1621 #endif
1622 
1623 #if FW_AMPCS_COMPATIBLE
1624  // Serialize the argument size
1625  _status = _logBuff.serialize(
1626  static_cast<U8>(sizeof(U32))
1627  );
1628  FW_ASSERT(
1629  _status == Fw::FW_SERIALIZE_OK,
1630  static_cast<FwAssertArgType>(_status)
1631  );
1632 #endif
1633  _status = _logBuff.serialize(id);
1634  FW_ASSERT(
1635  _status == Fw::FW_SERIALIZE_OK,
1636  static_cast<FwAssertArgType>(_status)
1637  );
1638 
1639  this->m_eventOut_OutputPort[0].invoke(
1640  _id,
1641  _logTime,
1643  _logBuff
1644  );
1645  }
1646 
1647  // Emit the event on the text log port
1648 #if FW_ENABLE_TEXT_LOGGING
1649  if (this->m_textEventOut_OutputPort[0].isConnected()) {
1650 #if FW_OBJECT_NAMES == 1
1651  const char* _formatString =
1652  "(%s) %s: Could not find packet ID %" PRIu32 "";
1653 #else
1654  const char* _formatString =
1655  "%s: Could not find packet ID %" PRIu32 "";
1656 #endif
1657 
1658  Fw::TextLogString _logString;
1659  _logString.format(
1660  _formatString,
1661 #if FW_OBJECT_NAMES == 1
1662  this->m_objName.toChar(),
1663 #endif
1664  "PacketNotFound ",
1665  id
1666  );
1667 
1668  this->m_textEventOut_OutputPort[0].invoke(
1669  _id,
1670  _logTime,
1672  _logString
1673  );
1674  }
1675 #endif
1676  }
1677 
1678  // ----------------------------------------------------------------------
1679  // Telemetry write functions
1680  // ----------------------------------------------------------------------
1681 
1684  U32 arg,
1685  Fw::Time _tlmTime
1686  ) const
1687  {
1688  if (this->m_tlmOut_OutputPort[0].isConnected()) {
1689  if (
1690  this->m_timeGetOut_OutputPort[0].isConnected() &&
1691  (_tlmTime == Fw::ZERO_TIME)
1692  ) {
1693  this->m_timeGetOut_OutputPort[0].invoke(_tlmTime);
1694  }
1695 
1696  Fw::TlmBuffer _tlmBuff;
1697  Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
1698  FW_ASSERT(
1699  _stat == Fw::FW_SERIALIZE_OK,
1700  static_cast<FwAssertArgType>(_stat)
1701  );
1702 
1703  FwChanIdType _id;
1704 
1705  _id = this->getIdBase() + CHANNELID_SENDLEVEL;
1706 
1707  this->m_tlmOut_OutputPort[0].invoke(
1708  _id,
1709  _tlmTime,
1710  _tlmBuff
1711  );
1712  }
1713  }
1714 
1715  // ----------------------------------------------------------------------
1716  // Time
1717  // ----------------------------------------------------------------------
1718 
1721  {
1722  if (this->m_timeGetOut_OutputPort[0].isConnected()) {
1723  Fw::Time _time;
1724  this->m_timeGetOut_OutputPort[0].invoke(_time);
1725  return _time;
1726  }
1727  else {
1728  return Fw::Time(TB_NONE, 0, 0);
1729  }
1730  }
1731 
1732  // ----------------------------------------------------------------------
1733  // Message dispatch functions
1734  // ----------------------------------------------------------------------
1735 
1736  Fw::QueuedComponentBase::MsgDispatchStatus TlmPacketizerComponentBase ::
1737  doDispatch()
1738  {
1739  ComponentIpcSerializableBuffer msg;
1740  FwQueuePriorityType priority = 0;
1741 
1742  Os::Queue::Status msgStatus = this->m_queue.receive(
1743  msg,
1745  priority
1746  );
1747  FW_ASSERT(
1748  msgStatus == Os::Queue::OP_OK,
1749  static_cast<FwAssertArgType>(msgStatus)
1750  );
1751 
1752  // Reset to beginning of buffer
1753  msg.resetDeser();
1754 
1755  FwEnumStoreType desMsg = 0;
1756  Fw::SerializeStatus deserStatus = msg.deserialize(desMsg);
1757  FW_ASSERT(
1758  deserStatus == Fw::FW_SERIALIZE_OK,
1759  static_cast<FwAssertArgType>(deserStatus)
1760  );
1761 
1762  MsgTypeEnum msgType = static_cast<MsgTypeEnum>(desMsg);
1763 
1764  if (msgType == TLMPACKETIZER_COMPONENT_EXIT) {
1765  return MSG_DISPATCH_EXIT;
1766  }
1767 
1768  FwIndexType portNum = 0;
1769  deserStatus = msg.deserialize(portNum);
1770  FW_ASSERT(
1771  deserStatus == Fw::FW_SERIALIZE_OK,
1772  static_cast<FwAssertArgType>(deserStatus)
1773  );
1774 
1775  switch (msgType) {
1776  // Handle async input port Run
1777  case RUN_SCHED: {
1778  // Deserialize argument context
1779  U32 context;
1780  deserStatus = msg.deserialize(context);
1781  FW_ASSERT(
1782  deserStatus == Fw::FW_SERIALIZE_OK,
1783  static_cast<FwAssertArgType>(deserStatus)
1784  );
1785  // Call handler function
1786  this->Run_handler(
1787  portNum,
1788  context
1789  );
1790 
1791  break;
1792  }
1793 
1794  // Handle async input port pingIn
1795  case PINGIN_PING: {
1796  // Deserialize argument key
1797  U32 key;
1798  deserStatus = msg.deserialize(key);
1799  FW_ASSERT(
1800  deserStatus == Fw::FW_SERIALIZE_OK,
1801  static_cast<FwAssertArgType>(deserStatus)
1802  );
1803  // Call handler function
1804  this->pingIn_handler(
1805  portNum,
1806  key
1807  );
1808 
1809  break;
1810  }
1811 
1812  // Handle command SET_LEVEL
1813  case CMD_SET_LEVEL: {
1814  // Deserialize opcode
1815  FwOpcodeType opCode = 0;
1816  deserStatus = msg.deserialize(opCode);
1817  FW_ASSERT (
1818  deserStatus == Fw::FW_SERIALIZE_OK,
1819  static_cast<FwAssertArgType>(deserStatus)
1820  );
1821 
1822  // Deserialize command sequence
1823  U32 cmdSeq = 0;
1824  deserStatus = msg.deserialize(cmdSeq);
1825  FW_ASSERT (
1826  deserStatus == Fw::FW_SERIALIZE_OK,
1827  static_cast<FwAssertArgType>(deserStatus)
1828  );
1829 
1830  // Deserialize command argument buffer
1831  Fw::CmdArgBuffer args;
1832  deserStatus = msg.deserialize(args);
1833  FW_ASSERT (
1834  deserStatus == Fw::FW_SERIALIZE_OK,
1835  static_cast<FwAssertArgType>(deserStatus)
1836  );
1837 
1838  // Reset buffer
1839  args.resetDeser();
1840 
1841  // Deserialize argument level
1842  U32 level;
1843  deserStatus = args.deserialize(level);
1844  if (deserStatus != Fw::FW_SERIALIZE_OK) {
1845  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
1846  this->cmdResponse_out(
1847  opCode,
1848  cmdSeq,
1850  );
1851  }
1852  // Don't crash the task if bad arguments were passed from the ground
1853  break;
1854  }
1855 
1856  // Make sure there was no data left over.
1857  // That means the argument buffer size was incorrect.
1858 #if FW_CMD_CHECK_RESIDUAL
1859  if (args.getBuffLeft() != 0) {
1860  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
1861  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
1862  }
1863  // Don't crash the task if bad arguments were passed from the ground
1864  break;
1865  }
1866 #endif
1867 
1868  // Call handler function
1869  this->SET_LEVEL_cmdHandler(
1870  opCode, cmdSeq,
1871  level
1872  );
1873 
1874  break;
1875  }
1876 
1877  // Handle command SEND_PKT
1878  case CMD_SEND_PKT: {
1879  // Deserialize opcode
1880  FwOpcodeType opCode = 0;
1881  deserStatus = msg.deserialize(opCode);
1882  FW_ASSERT (
1883  deserStatus == Fw::FW_SERIALIZE_OK,
1884  static_cast<FwAssertArgType>(deserStatus)
1885  );
1886 
1887  // Deserialize command sequence
1888  U32 cmdSeq = 0;
1889  deserStatus = msg.deserialize(cmdSeq);
1890  FW_ASSERT (
1891  deserStatus == Fw::FW_SERIALIZE_OK,
1892  static_cast<FwAssertArgType>(deserStatus)
1893  );
1894 
1895  // Deserialize command argument buffer
1896  Fw::CmdArgBuffer args;
1897  deserStatus = msg.deserialize(args);
1898  FW_ASSERT (
1899  deserStatus == Fw::FW_SERIALIZE_OK,
1900  static_cast<FwAssertArgType>(deserStatus)
1901  );
1902 
1903  // Reset buffer
1904  args.resetDeser();
1905 
1906  // Deserialize argument id
1907  U32 id;
1908  deserStatus = args.deserialize(id);
1909  if (deserStatus != Fw::FW_SERIALIZE_OK) {
1910  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
1911  this->cmdResponse_out(
1912  opCode,
1913  cmdSeq,
1915  );
1916  }
1917  // Don't crash the task if bad arguments were passed from the ground
1918  break;
1919  }
1920 
1921  // Make sure there was no data left over.
1922  // That means the argument buffer size was incorrect.
1923 #if FW_CMD_CHECK_RESIDUAL
1924  if (args.getBuffLeft() != 0) {
1925  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
1926  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
1927  }
1928  // Don't crash the task if bad arguments were passed from the ground
1929  break;
1930  }
1931 #endif
1932 
1933  // Call handler function
1934  this->SEND_PKT_cmdHandler(
1935  opCode, cmdSeq,
1936  id
1937  );
1938 
1939  break;
1940  }
1941 
1942  default:
1943  return MSG_DISPATCH_ERROR;
1944  }
1945 
1946  return MSG_DISPATCH_OK;
1947  }
1948 
1949  // ----------------------------------------------------------------------
1950  // Calls for messages received on special input ports
1951  // ----------------------------------------------------------------------
1952 
1953  void TlmPacketizerComponentBase ::
1954  m_p_cmdIn_in(
1955  Fw::PassiveComponentBase* callComp,
1956  FwIndexType portNum,
1957  FwOpcodeType opCode,
1958  U32 cmdSeq,
1959  Fw::CmdArgBuffer& args
1960  )
1961  {
1962  FW_ASSERT(callComp);
1963  TlmPacketizerComponentBase* compPtr = static_cast<TlmPacketizerComponentBase*>(callComp);
1964 
1965  const U32 idBase = callComp->getIdBase();
1966  FW_ASSERT(opCode >= idBase, static_cast<FwAssertArgType>(opCode), static_cast<FwAssertArgType>(idBase));
1967 
1968  // Select base class function based on opcode
1969  switch (opCode - idBase) {
1970  case OPCODE_SET_LEVEL: {
1971  compPtr->SET_LEVEL_cmdHandlerBase(
1972  opCode,
1973  cmdSeq,
1974  args
1975  );
1976  break;
1977  }
1978 
1979  case OPCODE_SEND_PKT: {
1980  compPtr->SEND_PKT_cmdHandlerBase(
1981  opCode,
1982  cmdSeq,
1983  args
1984  );
1985  break;
1986  }
1987  }
1988  }
1989 
1990  // ----------------------------------------------------------------------
1991  // Calls for messages received on typed input ports
1992  // ----------------------------------------------------------------------
1993 
1994  void TlmPacketizerComponentBase ::
1995  m_p_Run_in(
1996  Fw::PassiveComponentBase* callComp,
1997  FwIndexType portNum,
1998  U32 context
1999  )
2000  {
2001  FW_ASSERT(callComp);
2002  TlmPacketizerComponentBase* compPtr = static_cast<TlmPacketizerComponentBase*>(callComp);
2003  compPtr->Run_handlerBase(
2004  portNum,
2005  context
2006  );
2007  }
2008 
2009  void TlmPacketizerComponentBase ::
2010  m_p_TlmRecv_in(
2011  Fw::PassiveComponentBase* callComp,
2012  FwIndexType portNum,
2013  FwChanIdType id,
2014  Fw::Time& timeTag,
2015  Fw::TlmBuffer& val
2016  )
2017  {
2018  FW_ASSERT(callComp);
2019  TlmPacketizerComponentBase* compPtr = static_cast<TlmPacketizerComponentBase*>(callComp);
2020  compPtr->TlmRecv_handlerBase(
2021  portNum,
2022  id,
2023  timeTag,
2024  val
2025  );
2026  }
2027 
2028  void TlmPacketizerComponentBase ::
2029  m_p_pingIn_in(
2030  Fw::PassiveComponentBase* callComp,
2031  FwIndexType portNum,
2032  U32 key
2033  )
2034  {
2035  FW_ASSERT(callComp);
2036  TlmPacketizerComponentBase* compPtr = static_cast<TlmPacketizerComponentBase*>(callComp);
2037  compPtr->pingIn_handlerBase(
2038  portNum,
2039  key
2040  );
2041  }
2042 
2043 }
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)
NATIVE_UINT_TYPE SizeType
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.
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
The size of the serial representations of the port arguments.
Definition: CmdPortAc.hpp:37
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:45
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
void setPortNum(NATIVE_INT_TYPE 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
The size of the serial representations of the port arguments.
Definition: PingPortAc.hpp:36
void invoke(Fw::Time &time) const
Invoke a port interface.
Definition: TimePortAc.cpp:147
U32 FwOpcodeType
Definition: FpConfig.h:91
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
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.
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:30
BlockingType
message type
Definition: Queue.hpp:44
#define PRI_PlatformIntType
Command failed to deserialize.
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
message to exit active component task
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:70
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
message sent/received okay
Definition: Queue.hpp:31
U8 BYTE
byte type
Definition: BasicTypes.h:31
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:46
The size of the serial representations of the port arguments.
Definition: SchedPortAc.hpp:36
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.
Telemetry channel is not part of a telemetry packet.
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].