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