F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
HealthComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title HealthComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for Health component base class
5 // ======================================================================
6 
7 #include <cstdio>
8 
10 #include "Fw/Types/Assert.hpp"
11 #if FW_ENABLE_TEXT_LOGGING
12 #include "Fw/Types/String.hpp"
13 #endif
14 
15 namespace Svc {
16 
17  namespace {
18  enum MsgTypeEnum {
19  HEALTH_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
20  PINGRETURN_PING,
21  CMD_HLTH_ENABLE,
22  CMD_HLTH_PING_ENABLE,
23  CMD_HLTH_CHNG_PING,
24  };
25 
26  // Get the max size by constructing a union of the async input, command, and
27  // internal port serialization sizes
28  union BuffUnion {
29  BYTE PingReturnPortSize[Svc::InputPingPort::SERIALIZED_SIZE];
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(NATIVE_INT_TYPE) +
46  sizeof(NATIVE_INT_TYPE)
47  };
48 
49  NATIVE_UINT_TYPE 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  NATIVE_INT_TYPE queueDepth,
75  NATIVE_INT_TYPE instance
76  )
77  {
78  // Initialize base class
80 
81  // Connect input port CmdDisp
82  for (
83  PlatformIntType port = 0;
84  port < static_cast<PlatformIntType>(this->getNum_CmdDisp_InputPorts());
85  port++
86  ) {
87  this->m_CmdDisp_InputPort[port].init();
88  this->m_CmdDisp_InputPort[port].addCallComp(
89  this,
90  m_p_CmdDisp_in
91  );
92  this->m_CmdDisp_InputPort[port].setPortNum(port);
93 
94 #if FW_OBJECT_NAMES == 1
95  // The port name consists of this->m_objName and some extra info.
96  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
97  // However, the compiler may assume that this->m_objName fills
98  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
99  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
100  // bytes to cover the extra info.
101  char portName[2*FW_OBJ_NAME_MAX_SIZE];
102  (void) snprintf(
103  portName,
104  sizeof(portName),
105  "%s_CmdDisp_InputPort[%" PRI_PlatformIntType "]",
106  this->m_objName,
107  port
108  );
109  this->m_CmdDisp_InputPort[port].setObjName(portName);
110 #endif
111  }
112 
113  // Connect input port PingReturn
114  for (
115  PlatformIntType port = 0;
116  port < static_cast<PlatformIntType>(this->getNum_PingReturn_InputPorts());
117  port++
118  ) {
119  this->m_PingReturn_InputPort[port].init();
120  this->m_PingReturn_InputPort[port].addCallComp(
121  this,
122  m_p_PingReturn_in
123  );
124  this->m_PingReturn_InputPort[port].setPortNum(port);
125 
126 #if FW_OBJECT_NAMES == 1
127  // The port name consists of this->m_objName and some extra info.
128  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
129  // However, the compiler may assume that this->m_objName fills
130  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
131  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
132  // bytes to cover the extra info.
133  char portName[2*FW_OBJ_NAME_MAX_SIZE];
134  (void) snprintf(
135  portName,
136  sizeof(portName),
137  "%s_PingReturn_InputPort[%" PRI_PlatformIntType "]",
138  this->m_objName,
139  port
140  );
141  this->m_PingReturn_InputPort[port].setObjName(portName);
142 #endif
143  }
144 
145  // Connect input port Run
146  for (
147  PlatformIntType port = 0;
148  port < static_cast<PlatformIntType>(this->getNum_Run_InputPorts());
149  port++
150  ) {
151  this->m_Run_InputPort[port].init();
152  this->m_Run_InputPort[port].addCallComp(
153  this,
154  m_p_Run_in
155  );
156  this->m_Run_InputPort[port].setPortNum(port);
157 
158 #if FW_OBJECT_NAMES == 1
159  // The port name consists of this->m_objName and some extra info.
160  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
161  // However, the compiler may assume that this->m_objName fills
162  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
163  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
164  // bytes to cover the extra info.
165  char portName[2*FW_OBJ_NAME_MAX_SIZE];
166  (void) snprintf(
167  portName,
168  sizeof(portName),
169  "%s_Run_InputPort[%" PRI_PlatformIntType "]",
170  this->m_objName,
171  port
172  );
173  this->m_Run_InputPort[port].setObjName(portName);
174 #endif
175  }
176 
177  // Connect output port CmdReg
178  for (
179  PlatformIntType port = 0;
180  port < static_cast<PlatformIntType>(this->getNum_CmdReg_OutputPorts());
181  port++
182  ) {
183  this->m_CmdReg_OutputPort[port].init();
184 
185 #if FW_OBJECT_NAMES == 1
186  // The port name consists of this->m_objName and some extra info.
187  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
188  // However, the compiler may assume that this->m_objName fills
189  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
190  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
191  // bytes to cover the extra info.
192  char portName[2*FW_OBJ_NAME_MAX_SIZE];
193  (void) snprintf(
194  portName,
195  sizeof(portName),
196  "%s_CmdReg_OutputPort[%" PRI_PlatformIntType "]",
197  this->m_objName,
198  port
199  );
200  this->m_CmdReg_OutputPort[port].setObjName(portName);
201 #endif
202  }
203 
204  // Connect output port CmdStatus
205  for (
206  PlatformIntType port = 0;
207  port < static_cast<PlatformIntType>(this->getNum_CmdStatus_OutputPorts());
208  port++
209  ) {
210  this->m_CmdStatus_OutputPort[port].init();
211 
212 #if FW_OBJECT_NAMES == 1
213  // The port name consists of this->m_objName and some extra info.
214  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
215  // However, the compiler may assume that this->m_objName fills
216  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
217  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
218  // bytes to cover the extra info.
219  char portName[2*FW_OBJ_NAME_MAX_SIZE];
220  (void) snprintf(
221  portName,
222  sizeof(portName),
223  "%s_CmdStatus_OutputPort[%" PRI_PlatformIntType "]",
224  this->m_objName,
225  port
226  );
227  this->m_CmdStatus_OutputPort[port].setObjName(portName);
228 #endif
229  }
230 
231  // Connect output port Log
232  for (
233  PlatformIntType port = 0;
234  port < static_cast<PlatformIntType>(this->getNum_Log_OutputPorts());
235  port++
236  ) {
237  this->m_Log_OutputPort[port].init();
238 
239 #if FW_OBJECT_NAMES == 1
240  // The port name consists of this->m_objName and some extra info.
241  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
242  // However, the compiler may assume that this->m_objName fills
243  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
244  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
245  // bytes to cover the extra info.
246  char portName[2*FW_OBJ_NAME_MAX_SIZE];
247  (void) snprintf(
248  portName,
249  sizeof(portName),
250  "%s_Log_OutputPort[%" PRI_PlatformIntType "]",
251  this->m_objName,
252  port
253  );
254  this->m_Log_OutputPort[port].setObjName(portName);
255 #endif
256  }
257 
258 #if FW_ENABLE_TEXT_LOGGING == 1
259  // Connect output port LogText
260  for (
261  PlatformIntType port = 0;
262  port < static_cast<PlatformIntType>(this->getNum_LogText_OutputPorts());
263  port++
264  ) {
265  this->m_LogText_OutputPort[port].init();
266 
267 #if FW_OBJECT_NAMES == 1
268  // The port name consists of this->m_objName and some extra info.
269  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
270  // However, the compiler may assume that this->m_objName fills
271  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
272  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
273  // bytes to cover the extra info.
274  char portName[2*FW_OBJ_NAME_MAX_SIZE];
275  (void) snprintf(
276  portName,
277  sizeof(portName),
278  "%s_LogText_OutputPort[%" PRI_PlatformIntType "]",
279  this->m_objName,
280  port
281  );
282  this->m_LogText_OutputPort[port].setObjName(portName);
283 #endif
284  }
285 #endif
286 
287  // Connect output port Time
288  for (
289  PlatformIntType port = 0;
290  port < static_cast<PlatformIntType>(this->getNum_Time_OutputPorts());
291  port++
292  ) {
293  this->m_Time_OutputPort[port].init();
294 
295 #if FW_OBJECT_NAMES == 1
296  // The port name consists of this->m_objName and some extra info.
297  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
298  // However, the compiler may assume that this->m_objName fills
299  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
300  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
301  // bytes to cover the extra info.
302  char portName[2*FW_OBJ_NAME_MAX_SIZE];
303  (void) snprintf(
304  portName,
305  sizeof(portName),
306  "%s_Time_OutputPort[%" PRI_PlatformIntType "]",
307  this->m_objName,
308  port
309  );
310  this->m_Time_OutputPort[port].setObjName(portName);
311 #endif
312  }
313 
314  // Connect output port Tlm
315  for (
316  PlatformIntType port = 0;
317  port < static_cast<PlatformIntType>(this->getNum_Tlm_OutputPorts());
318  port++
319  ) {
320  this->m_Tlm_OutputPort[port].init();
321 
322 #if FW_OBJECT_NAMES == 1
323  // The port name consists of this->m_objName and some extra info.
324  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
325  // However, the compiler may assume that this->m_objName fills
326  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
327  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
328  // bytes to cover the extra info.
329  char portName[2*FW_OBJ_NAME_MAX_SIZE];
330  (void) snprintf(
331  portName,
332  sizeof(portName),
333  "%s_Tlm_OutputPort[%" PRI_PlatformIntType "]",
334  this->m_objName,
335  port
336  );
337  this->m_Tlm_OutputPort[port].setObjName(portName);
338 #endif
339  }
340 
341  // Connect output port PingSend
342  for (
343  PlatformIntType port = 0;
344  port < static_cast<PlatformIntType>(this->getNum_PingSend_OutputPorts());
345  port++
346  ) {
347  this->m_PingSend_OutputPort[port].init();
348 
349 #if FW_OBJECT_NAMES == 1
350  // The port name consists of this->m_objName and some extra info.
351  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
352  // However, the compiler may assume that this->m_objName fills
353  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
354  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
355  // bytes to cover the extra info.
356  char portName[2*FW_OBJ_NAME_MAX_SIZE];
357  (void) snprintf(
358  portName,
359  sizeof(portName),
360  "%s_PingSend_OutputPort[%" PRI_PlatformIntType "]",
361  this->m_objName,
362  port
363  );
364  this->m_PingSend_OutputPort[port].setObjName(portName);
365 #endif
366  }
367 
368  // Connect output port WdogStroke
369  for (
370  PlatformIntType port = 0;
371  port < static_cast<PlatformIntType>(this->getNum_WdogStroke_OutputPorts());
372  port++
373  ) {
374  this->m_WdogStroke_OutputPort[port].init();
375 
376 #if FW_OBJECT_NAMES == 1
377  // The port name consists of this->m_objName and some extra info.
378  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
379  // However, the compiler may assume that this->m_objName fills
380  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
381  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
382  // bytes to cover the extra info.
383  char portName[2*FW_OBJ_NAME_MAX_SIZE];
384  (void) snprintf(
385  portName,
386  sizeof(portName),
387  "%s_WdogStroke_OutputPort[%" PRI_PlatformIntType "]",
388  this->m_objName,
389  port
390  );
391  this->m_WdogStroke_OutputPort[port].setObjName(portName);
392 #endif
393  }
394 
395  Os::Queue::QueueStatus qStat = this->createQueue(
396  queueDepth,
397  ComponentIpcSerializableBuffer::SERIALIZATION_SIZE
398  );
399  FW_ASSERT(
400  Os::Queue::QUEUE_OK == qStat,
401  static_cast<FwAssertArgType>(qStat)
402  );
403  }
404 
405  // ----------------------------------------------------------------------
406  // Getters for special input ports
407  // ----------------------------------------------------------------------
408 
411  {
412  FW_ASSERT(
413  portNum < this->getNum_CmdDisp_InputPorts(),
414  static_cast<FwAssertArgType>(portNum)
415  );
416 
417  return &this->m_CmdDisp_InputPort[portNum];
418  }
419 
420  // ----------------------------------------------------------------------
421  // Getters for typed input ports
422  // ----------------------------------------------------------------------
423 
426  {
427  FW_ASSERT(
428  portNum < this->getNum_PingReturn_InputPorts(),
429  static_cast<FwAssertArgType>(portNum)
430  );
431 
432  return &this->m_PingReturn_InputPort[portNum];
433  }
434 
437  {
438  FW_ASSERT(
439  portNum < this->getNum_Run_InputPorts(),
440  static_cast<FwAssertArgType>(portNum)
441  );
442 
443  return &this->m_Run_InputPort[portNum];
444  }
445 
446  // ----------------------------------------------------------------------
447  // Connect input ports to special output ports
448  // ----------------------------------------------------------------------
449 
452  NATIVE_INT_TYPE portNum,
453  Fw::InputCmdRegPort* port
454  )
455  {
456  FW_ASSERT(
457  portNum < this->getNum_CmdReg_OutputPorts(),
458  static_cast<FwAssertArgType>(portNum)
459  );
460 
461  this->m_CmdReg_OutputPort[portNum].addCallPort(port);
462  }
463 
466  NATIVE_INT_TYPE portNum,
468  )
469  {
470  FW_ASSERT(
471  portNum < this->getNum_CmdStatus_OutputPorts(),
472  static_cast<FwAssertArgType>(portNum)
473  );
474 
475  this->m_CmdStatus_OutputPort[portNum].addCallPort(port);
476  }
477 
480  NATIVE_INT_TYPE portNum,
481  Fw::InputLogPort* port
482  )
483  {
484  FW_ASSERT(
485  portNum < this->getNum_Log_OutputPorts(),
486  static_cast<FwAssertArgType>(portNum)
487  );
488 
489  this->m_Log_OutputPort[portNum].addCallPort(port);
490  }
491 
492 #if FW_ENABLE_TEXT_LOGGING == 1
493 
494  void HealthComponentBase ::
495  set_LogText_OutputPort(
496  NATIVE_INT_TYPE portNum,
498  )
499  {
500  FW_ASSERT(
501  portNum < this->getNum_LogText_OutputPorts(),
502  static_cast<FwAssertArgType>(portNum)
503  );
504 
505  this->m_LogText_OutputPort[portNum].addCallPort(port);
506  }
507 
508 #endif
509 
512  NATIVE_INT_TYPE portNum,
513  Fw::InputTimePort* port
514  )
515  {
516  FW_ASSERT(
517  portNum < this->getNum_Time_OutputPorts(),
518  static_cast<FwAssertArgType>(portNum)
519  );
520 
521  this->m_Time_OutputPort[portNum].addCallPort(port);
522  }
523 
526  NATIVE_INT_TYPE portNum,
527  Fw::InputTlmPort* port
528  )
529  {
530  FW_ASSERT(
531  portNum < this->getNum_Tlm_OutputPorts(),
532  static_cast<FwAssertArgType>(portNum)
533  );
534 
535  this->m_Tlm_OutputPort[portNum].addCallPort(port);
536  }
537 
538  // ----------------------------------------------------------------------
539  // Connect typed input ports to typed output ports
540  // ----------------------------------------------------------------------
541 
544  NATIVE_INT_TYPE portNum,
545  Svc::InputPingPort* port
546  )
547  {
548  FW_ASSERT(
549  portNum < this->getNum_PingSend_OutputPorts(),
550  static_cast<FwAssertArgType>(portNum)
551  );
552 
553  this->m_PingSend_OutputPort[portNum].addCallPort(port);
554  }
555 
558  NATIVE_INT_TYPE portNum,
560  )
561  {
562  FW_ASSERT(
563  portNum < this->getNum_WdogStroke_OutputPorts(),
564  static_cast<FwAssertArgType>(portNum)
565  );
566 
567  this->m_WdogStroke_OutputPort[portNum].addCallPort(port);
568  }
569 
570 #if FW_PORT_SERIALIZATION
571 
572  // ----------------------------------------------------------------------
573  // Connect serial input ports to special output ports
574  // ----------------------------------------------------------------------
575 
578  NATIVE_INT_TYPE portNum,
579  Fw::InputSerializePort* port
580  )
581  {
582  FW_ASSERT(
583  portNum < this->getNum_CmdReg_OutputPorts(),
584  static_cast<FwAssertArgType>(portNum)
585  );
586 
587  this->m_CmdReg_OutputPort[portNum].registerSerialPort(port);
588  }
589 
592  NATIVE_INT_TYPE portNum,
593  Fw::InputSerializePort* port
594  )
595  {
596  FW_ASSERT(
597  portNum < this->getNum_CmdStatus_OutputPorts(),
598  static_cast<FwAssertArgType>(portNum)
599  );
600 
601  this->m_CmdStatus_OutputPort[portNum].registerSerialPort(port);
602  }
603 
606  NATIVE_INT_TYPE portNum,
607  Fw::InputSerializePort* port
608  )
609  {
610  FW_ASSERT(
611  portNum < this->getNum_Log_OutputPorts(),
612  static_cast<FwAssertArgType>(portNum)
613  );
614 
615  this->m_Log_OutputPort[portNum].registerSerialPort(port);
616  }
617 
618 #if FW_ENABLE_TEXT_LOGGING == 1
619 
620  void HealthComponentBase ::
621  set_LogText_OutputPort(
622  NATIVE_INT_TYPE portNum,
623  Fw::InputSerializePort* port
624  )
625  {
626  FW_ASSERT(
627  portNum < this->getNum_LogText_OutputPorts(),
628  static_cast<FwAssertArgType>(portNum)
629  );
630 
631  this->m_LogText_OutputPort[portNum].registerSerialPort(port);
632  }
633 
634 #endif
635 
638  NATIVE_INT_TYPE portNum,
639  Fw::InputSerializePort* port
640  )
641  {
642  FW_ASSERT(
643  portNum < this->getNum_Time_OutputPorts(),
644  static_cast<FwAssertArgType>(portNum)
645  );
646 
647  this->m_Time_OutputPort[portNum].registerSerialPort(port);
648  }
649 
652  NATIVE_INT_TYPE portNum,
653  Fw::InputSerializePort* port
654  )
655  {
656  FW_ASSERT(
657  portNum < this->getNum_Tlm_OutputPorts(),
658  static_cast<FwAssertArgType>(portNum)
659  );
660 
661  this->m_Tlm_OutputPort[portNum].registerSerialPort(port);
662  }
663 
664 #endif
665 
666 #if FW_PORT_SERIALIZATION
667 
668  // ----------------------------------------------------------------------
669  // Connect serial input ports to typed output ports
670  // ----------------------------------------------------------------------
671 
674  NATIVE_INT_TYPE portNum,
675  Fw::InputSerializePort* port
676  )
677  {
678  FW_ASSERT(
679  portNum < this->getNum_PingSend_OutputPorts(),
680  static_cast<FwAssertArgType>(portNum)
681  );
682 
683  this->m_PingSend_OutputPort[portNum].registerSerialPort(port);
684  }
685 
688  NATIVE_INT_TYPE portNum,
689  Fw::InputSerializePort* port
690  )
691  {
692  FW_ASSERT(
693  portNum < this->getNum_WdogStroke_OutputPorts(),
694  static_cast<FwAssertArgType>(portNum)
695  );
696 
697  this->m_WdogStroke_OutputPort[portNum].registerSerialPort(port);
698  }
699 
700 #endif
701 
702  // ----------------------------------------------------------------------
703  // Command registration
704  // ----------------------------------------------------------------------
705 
707  regCommands()
708  {
709  FW_ASSERT(this->m_CmdReg_OutputPort[0].isConnected());
710 
711  this->m_CmdReg_OutputPort[0].invoke(
712  this->getIdBase() + OPCODE_HLTH_ENABLE
713  );
714 
715  this->m_CmdReg_OutputPort[0].invoke(
717  );
718 
719  this->m_CmdReg_OutputPort[0].invoke(
721  );
722  }
723 
724  // ----------------------------------------------------------------------
725  // Component construction and destruction
726  // ----------------------------------------------------------------------
727 
729  HealthComponentBase(const char* compName) :
730  Fw::QueuedComponentBase(compName)
731  {
732 
733  }
734 
737  {
738 
739  }
740 
741  // ----------------------------------------------------------------------
742  // Getters for numbers of special input ports
743  // ----------------------------------------------------------------------
744 
747  {
748  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_CmdDisp_InputPort));
749  }
750 
751  // ----------------------------------------------------------------------
752  // Getters for numbers of typed input ports
753  // ----------------------------------------------------------------------
754 
757  {
758  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_PingReturn_InputPort));
759  }
760 
763  {
764  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Run_InputPort));
765  }
766 
767  // ----------------------------------------------------------------------
768  // Getters for numbers of special output ports
769  // ----------------------------------------------------------------------
770 
773  {
774  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_CmdReg_OutputPort));
775  }
776 
779  {
780  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_CmdStatus_OutputPort));
781  }
782 
785  {
786  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Log_OutputPort));
787  }
788 
789 #if FW_ENABLE_TEXT_LOGGING == 1
790 
791  NATIVE_INT_TYPE HealthComponentBase ::
792  getNum_LogText_OutputPorts() const
793  {
794  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_LogText_OutputPort));
795  }
796 
797 #endif
798 
801  {
802  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Time_OutputPort));
803  }
804 
807  {
808  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Tlm_OutputPort));
809  }
810 
811  // ----------------------------------------------------------------------
812  // Getters for numbers of typed output ports
813  // ----------------------------------------------------------------------
814 
817  {
818  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_PingSend_OutputPort));
819  }
820 
823  {
824  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_WdogStroke_OutputPort));
825  }
826 
827  // ----------------------------------------------------------------------
828  // Connection status queries for special output ports
829  // ----------------------------------------------------------------------
830 
833  {
834  FW_ASSERT(
835  portNum < this->getNum_CmdReg_OutputPorts(),
836  static_cast<FwAssertArgType>(portNum)
837  );
838 
839  return this->m_CmdReg_OutputPort[portNum].isConnected();
840  }
841 
844  {
845  FW_ASSERT(
846  portNum < this->getNum_CmdStatus_OutputPorts(),
847  static_cast<FwAssertArgType>(portNum)
848  );
849 
850  return this->m_CmdStatus_OutputPort[portNum].isConnected();
851  }
852 
855  {
856  FW_ASSERT(
857  portNum < this->getNum_Log_OutputPorts(),
858  static_cast<FwAssertArgType>(portNum)
859  );
860 
861  return this->m_Log_OutputPort[portNum].isConnected();
862  }
863 
864 #if FW_ENABLE_TEXT_LOGGING == 1
865 
866  bool HealthComponentBase ::
867  isConnected_LogText_OutputPort(NATIVE_INT_TYPE portNum)
868  {
869  FW_ASSERT(
870  portNum < this->getNum_LogText_OutputPorts(),
871  static_cast<FwAssertArgType>(portNum)
872  );
873 
874  return this->m_LogText_OutputPort[portNum].isConnected();
875  }
876 
877 #endif
878 
881  {
882  FW_ASSERT(
883  portNum < this->getNum_Time_OutputPorts(),
884  static_cast<FwAssertArgType>(portNum)
885  );
886 
887  return this->m_Time_OutputPort[portNum].isConnected();
888  }
889 
892  {
893  FW_ASSERT(
894  portNum < this->getNum_Tlm_OutputPorts(),
895  static_cast<FwAssertArgType>(portNum)
896  );
897 
898  return this->m_Tlm_OutputPort[portNum].isConnected();
899  }
900 
901  // ----------------------------------------------------------------------
902  // Connection status queries for typed output ports
903  // ----------------------------------------------------------------------
904 
907  {
908  FW_ASSERT(
909  portNum < this->getNum_PingSend_OutputPorts(),
910  static_cast<FwAssertArgType>(portNum)
911  );
912 
913  return this->m_PingSend_OutputPort[portNum].isConnected();
914  }
915 
918  {
919  FW_ASSERT(
920  portNum < this->getNum_WdogStroke_OutputPorts(),
921  static_cast<FwAssertArgType>(portNum)
922  );
923 
924  return this->m_WdogStroke_OutputPort[portNum].isConnected();
925  }
926 
927  // ----------------------------------------------------------------------
928  // Port handler base-class functions for typed input ports
929  //
930  // Call these functions directly to bypass the corresponding ports
931  // ----------------------------------------------------------------------
932 
935  NATIVE_INT_TYPE portNum,
936  U32 key
937  )
938  {
939  // Make sure port number is valid
940  FW_ASSERT(
941  portNum < this->getNum_PingReturn_InputPorts(),
942  static_cast<FwAssertArgType>(portNum)
943  );
944 
945  // Call pre-message hook
947  portNum,
948  key
949  );
950  ComponentIpcSerializableBuffer msg;
952 
953  // Serialize message ID
954  _status = msg.serialize(
955  static_cast<NATIVE_INT_TYPE>(PINGRETURN_PING)
956  );
957  FW_ASSERT(
958  _status == Fw::FW_SERIALIZE_OK,
959  static_cast<FwAssertArgType>(_status)
960  );
961 
962  // Serialize port number
963  _status = msg.serialize(portNum);
964  FW_ASSERT(
965  _status == Fw::FW_SERIALIZE_OK,
966  static_cast<FwAssertArgType>(_status)
967  );
968 
969  // Serialize argument key
970  _status = msg.serialize(key);
971  FW_ASSERT(
972  _status == Fw::FW_SERIALIZE_OK,
973  static_cast<FwAssertArgType>(_status)
974  );
975 
976  // Send message
978  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
979 
980  FW_ASSERT(
981  qStatus == Os::Queue::QUEUE_OK,
982  static_cast<FwAssertArgType>(qStatus)
983  );
984  }
985 
988  NATIVE_INT_TYPE portNum,
989  NATIVE_UINT_TYPE context
990  )
991  {
992  // Make sure port number is valid
993  FW_ASSERT(
994  portNum < this->getNum_Run_InputPorts(),
995  static_cast<FwAssertArgType>(portNum)
996  );
997 
998  // Call handler function
999  this->Run_handler(
1000  portNum,
1001  context
1002  );
1003  }
1004 
1005  // ----------------------------------------------------------------------
1006  // Pre-message hooks for typed async input ports
1007  //
1008  // Each of these functions is invoked just before processing a message
1009  // on the corresponding port. By default, they do nothing. You can
1010  // override them to provide specific pre-message behavior.
1011  // ----------------------------------------------------------------------
1012 
1015  NATIVE_INT_TYPE portNum,
1016  U32 key
1017  )
1018  {
1019  // Default: no-op
1020  }
1021 
1022  // ----------------------------------------------------------------------
1023  // Invocation functions for typed output ports
1024  // ----------------------------------------------------------------------
1025 
1028  NATIVE_INT_TYPE portNum,
1029  U32 key
1030  )
1031  {
1032  FW_ASSERT(
1033  portNum < this->getNum_PingSend_OutputPorts(),
1034  static_cast<FwAssertArgType>(portNum)
1035  );
1036  this->m_PingSend_OutputPort[portNum].invoke(
1037  key
1038  );
1039  }
1040 
1043  NATIVE_INT_TYPE portNum,
1044  U32 code
1045  )
1046  {
1047  FW_ASSERT(
1048  portNum < this->getNum_WdogStroke_OutputPorts(),
1049  static_cast<FwAssertArgType>(portNum)
1050  );
1051  this->m_WdogStroke_OutputPort[portNum].invoke(
1052  code
1053  );
1054  }
1055 
1056  // ----------------------------------------------------------------------
1057  // Command response
1058  // ----------------------------------------------------------------------
1059 
1062  FwOpcodeType opCode,
1063  U32 cmdSeq,
1064  Fw::CmdResponse response
1065  )
1066  {
1067  FW_ASSERT(this->m_CmdStatus_OutputPort[0].isConnected());
1068  this->m_CmdStatus_OutputPort[0].invoke(opCode, cmdSeq, response);
1069  }
1070 
1071  // ----------------------------------------------------------------------
1072  // Command handler base-class functions
1073  //
1074  // Call these functions directly to bypass the command input port
1075  // ----------------------------------------------------------------------
1076 
1079  FwOpcodeType opCode,
1080  U32 cmdSeq,
1081  Fw::CmdArgBuffer& args
1082  )
1083  {
1084  // Call pre-message hook
1085  this->HLTH_ENABLE_preMsgHook(opCode,cmdSeq);
1086 
1087  // Defer deserializing arguments to the message dispatcher
1088  // to avoid deserializing and reserializing just for IPC
1089  ComponentIpcSerializableBuffer msg;
1091 
1092  // Serialize for IPC
1093  _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(CMD_HLTH_ENABLE));
1094  FW_ASSERT (
1095  _status == Fw::FW_SERIALIZE_OK,
1096  static_cast<FwAssertArgType>(_status)
1097  );
1098 
1099  // Fake port number to make message dequeue work
1100  NATIVE_INT_TYPE port = 0;
1101 
1102  _status = msg.serialize(port);
1103  FW_ASSERT (
1104  _status == Fw::FW_SERIALIZE_OK,
1105  static_cast<FwAssertArgType>(_status)
1106  );
1107 
1108  _status = msg.serialize(opCode);
1109  FW_ASSERT (
1110  _status == Fw::FW_SERIALIZE_OK,
1111  static_cast<FwAssertArgType>(_status)
1112  );
1113 
1114  _status = msg.serialize(cmdSeq);
1115  FW_ASSERT (
1116  _status == Fw::FW_SERIALIZE_OK,
1117  static_cast<FwAssertArgType>(_status)
1118  );
1119 
1120  _status = msg.serialize(args);
1121  FW_ASSERT (
1122  _status == Fw::FW_SERIALIZE_OK,
1123  static_cast<FwAssertArgType>(_status)
1124  );
1125 
1126  // Send message
1128  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1129 
1130  FW_ASSERT(
1131  qStatus == Os::Queue::QUEUE_OK,
1132  static_cast<FwAssertArgType>(qStatus)
1133  );
1134  }
1135 
1138  FwOpcodeType opCode,
1139  U32 cmdSeq,
1140  Fw::CmdArgBuffer& args
1141  )
1142  {
1143  // Call pre-message hook
1144  this->HLTH_PING_ENABLE_preMsgHook(opCode,cmdSeq);
1145 
1146  // Defer deserializing arguments to the message dispatcher
1147  // to avoid deserializing and reserializing just for IPC
1148  ComponentIpcSerializableBuffer msg;
1150 
1151  // Serialize for IPC
1152  _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(CMD_HLTH_PING_ENABLE));
1153  FW_ASSERT (
1154  _status == Fw::FW_SERIALIZE_OK,
1155  static_cast<FwAssertArgType>(_status)
1156  );
1157 
1158  // Fake port number to make message dequeue work
1159  NATIVE_INT_TYPE port = 0;
1160 
1161  _status = msg.serialize(port);
1162  FW_ASSERT (
1163  _status == Fw::FW_SERIALIZE_OK,
1164  static_cast<FwAssertArgType>(_status)
1165  );
1166 
1167  _status = msg.serialize(opCode);
1168  FW_ASSERT (
1169  _status == Fw::FW_SERIALIZE_OK,
1170  static_cast<FwAssertArgType>(_status)
1171  );
1172 
1173  _status = msg.serialize(cmdSeq);
1174  FW_ASSERT (
1175  _status == Fw::FW_SERIALIZE_OK,
1176  static_cast<FwAssertArgType>(_status)
1177  );
1178 
1179  _status = msg.serialize(args);
1180  FW_ASSERT (
1181  _status == Fw::FW_SERIALIZE_OK,
1182  static_cast<FwAssertArgType>(_status)
1183  );
1184 
1185  // Send message
1187  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1188 
1189  FW_ASSERT(
1190  qStatus == Os::Queue::QUEUE_OK,
1191  static_cast<FwAssertArgType>(qStatus)
1192  );
1193  }
1194 
1197  FwOpcodeType opCode,
1198  U32 cmdSeq,
1199  Fw::CmdArgBuffer& args
1200  )
1201  {
1202  // Call pre-message hook
1203  this->HLTH_CHNG_PING_preMsgHook(opCode,cmdSeq);
1204 
1205  // Defer deserializing arguments to the message dispatcher
1206  // to avoid deserializing and reserializing just for IPC
1207  ComponentIpcSerializableBuffer msg;
1209 
1210  // Serialize for IPC
1211  _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(CMD_HLTH_CHNG_PING));
1212  FW_ASSERT (
1213  _status == Fw::FW_SERIALIZE_OK,
1214  static_cast<FwAssertArgType>(_status)
1215  );
1216 
1217  // Fake port number to make message dequeue work
1218  NATIVE_INT_TYPE port = 0;
1219 
1220  _status = msg.serialize(port);
1221  FW_ASSERT (
1222  _status == Fw::FW_SERIALIZE_OK,
1223  static_cast<FwAssertArgType>(_status)
1224  );
1225 
1226  _status = msg.serialize(opCode);
1227  FW_ASSERT (
1228  _status == Fw::FW_SERIALIZE_OK,
1229  static_cast<FwAssertArgType>(_status)
1230  );
1231 
1232  _status = msg.serialize(cmdSeq);
1233  FW_ASSERT (
1234  _status == Fw::FW_SERIALIZE_OK,
1235  static_cast<FwAssertArgType>(_status)
1236  );
1237 
1238  _status = msg.serialize(args);
1239  FW_ASSERT (
1240  _status == Fw::FW_SERIALIZE_OK,
1241  static_cast<FwAssertArgType>(_status)
1242  );
1243 
1244  // Send message
1246  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1247 
1248  FW_ASSERT(
1249  qStatus == Os::Queue::QUEUE_OK,
1250  static_cast<FwAssertArgType>(qStatus)
1251  );
1252  }
1253 
1254  // ----------------------------------------------------------------------
1255  // Pre-message hooks for async commands
1256  //
1257  // Each of these functions is invoked just before processing the
1258  // corresponding command. By default they do nothing. You can
1259  // override them to provide specific pre-command behavior.
1260  // ----------------------------------------------------------------------
1261 
1264  FwOpcodeType opCode,
1265  U32 cmdSeq
1266  )
1267  {
1268  // Defaults to no-op; can be overridden
1269  (void) opCode;
1270  (void) cmdSeq;
1271  }
1272 
1275  FwOpcodeType opCode,
1276  U32 cmdSeq
1277  )
1278  {
1279  // Defaults to no-op; can be overridden
1280  (void) opCode;
1281  (void) cmdSeq;
1282  }
1283 
1286  FwOpcodeType opCode,
1287  U32 cmdSeq
1288  )
1289  {
1290  // Defaults to no-op; can be overridden
1291  (void) opCode;
1292  (void) cmdSeq;
1293  }
1294 
1295  // ----------------------------------------------------------------------
1296  // Event logging functions
1297  // ----------------------------------------------------------------------
1298 
1301  {
1302  // Get the time
1303  Fw::Time _logTime;
1304  if (this->m_Time_OutputPort[0].isConnected()) {
1305  this->m_Time_OutputPort[0].invoke(_logTime);
1306  }
1307 
1308  FwEventIdType _id = static_cast<FwEventIdType>(0);
1309 
1310  _id = this->getIdBase() + EVENTID_HLTH_PING_WARN;
1311 
1312  // Emit the event on the log port
1313  if (this->m_Log_OutputPort[0].isConnected()) {
1314  Fw::LogBuffer _logBuff;
1316 
1317 #if FW_AMPCS_COMPATIBLE
1318  // Serialize the number of arguments
1319  _status = _logBuff.serialize(static_cast<U8>(1));
1320  FW_ASSERT(
1321  _status == Fw::FW_SERIALIZE_OK,
1322  static_cast<FwAssertArgType>(_status)
1323  );
1324 #endif
1325 
1326  _status = entry.serialize(_logBuff, 40);
1327  FW_ASSERT(
1328  _status == Fw::FW_SERIALIZE_OK,
1329  static_cast<FwAssertArgType>(_status)
1330  );
1331 
1332  this->m_Log_OutputPort[0].invoke(
1333  _id,
1334  _logTime,
1336  _logBuff
1337  );
1338  }
1339 
1340  // Emit the event on the text log port
1341 #if FW_ENABLE_TEXT_LOGGING
1342  if (this->m_LogText_OutputPort[0].isConnected()) {
1343 #if FW_OBJECT_NAMES == 1
1344  const char* _formatString =
1345  "(%s) %s: Ping entry %s late warning";
1346 #else
1347  const char* _formatString =
1348  "%s: Ping entry %s late warning";
1349 #endif
1350 
1351  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1352 
1353  (void) snprintf(
1354  _textBuffer,
1356  _formatString,
1357 #if FW_OBJECT_NAMES == 1
1358  this->m_objName,
1359 #endif
1360  "HLTH_PING_WARN ",
1361  entry.toChar()
1362  );
1363 
1364  // Null terminate
1365  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1366  Fw::TextLogString _logString = _textBuffer;
1367  this->m_LogText_OutputPort[0].invoke(
1368  _id,
1369  _logTime,
1371  _logString
1372  );
1373  }
1374 #endif
1375  }
1376 
1379  {
1380  // Get the time
1381  Fw::Time _logTime;
1382  if (this->m_Time_OutputPort[0].isConnected()) {
1383  this->m_Time_OutputPort[0].invoke(_logTime);
1384  }
1385 
1386  FwEventIdType _id = static_cast<FwEventIdType>(0);
1387 
1388  _id = this->getIdBase() + EVENTID_HLTH_PING_LATE;
1389 
1390  // Emit the event on the log port
1391  if (this->m_Log_OutputPort[0].isConnected()) {
1392  Fw::LogBuffer _logBuff;
1394 
1395 #if FW_AMPCS_COMPATIBLE
1396  // Serialize the number of arguments
1397  _status = _logBuff.serialize(static_cast<U8>(1 + 1));
1398  FW_ASSERT(
1399  _status == Fw::FW_SERIALIZE_OK,
1400  static_cast<FwAssertArgType>(_status)
1401  );
1402 
1403  // For FATAL, add stack size of 4 and a dummy entry. No support for stacks yet.
1404  _status = _logBuff.serialize(static_cast<U8>(4));
1405  FW_ASSERT(
1406  _status == Fw::FW_SERIALIZE_OK,
1407  static_cast<FwAssertArgType>(_status)
1408  );
1409 
1410  _status = _logBuff.serialize(static_cast<U32>(0));
1411  FW_ASSERT(
1412  _status == Fw::FW_SERIALIZE_OK,
1413  static_cast<FwAssertArgType>(_status)
1414  );
1415 #endif
1416 
1417  _status = entry.serialize(_logBuff, 40);
1418  FW_ASSERT(
1419  _status == Fw::FW_SERIALIZE_OK,
1420  static_cast<FwAssertArgType>(_status)
1421  );
1422 
1423  this->m_Log_OutputPort[0].invoke(
1424  _id,
1425  _logTime,
1427  _logBuff
1428  );
1429  }
1430 
1431  // Emit the event on the text log port
1432 #if FW_ENABLE_TEXT_LOGGING
1433  if (this->m_LogText_OutputPort[0].isConnected()) {
1434 #if FW_OBJECT_NAMES == 1
1435  const char* _formatString =
1436  "(%s) %s: Ping entry %s did not respond";
1437 #else
1438  const char* _formatString =
1439  "%s: Ping entry %s did not respond";
1440 #endif
1441 
1442  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1443 
1444  (void) snprintf(
1445  _textBuffer,
1447  _formatString,
1448 #if FW_OBJECT_NAMES == 1
1449  this->m_objName,
1450 #endif
1451  "HLTH_PING_LATE ",
1452  entry.toChar()
1453  );
1454 
1455  // Null terminate
1456  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1457  Fw::TextLogString _logString = _textBuffer;
1458  this->m_LogText_OutputPort[0].invoke(
1459  _id,
1460  _logTime,
1462  _logString
1463  );
1464  }
1465 #endif
1466  }
1467 
1470  const Fw::LogStringArg& entry,
1471  U32 badKey
1472  )
1473  {
1474  // Get the time
1475  Fw::Time _logTime;
1476  if (this->m_Time_OutputPort[0].isConnected()) {
1477  this->m_Time_OutputPort[0].invoke(_logTime);
1478  }
1479 
1480  FwEventIdType _id = static_cast<FwEventIdType>(0);
1481 
1482  _id = this->getIdBase() + EVENTID_HLTH_PING_WRONG_KEY;
1483 
1484  // Emit the event on the log port
1485  if (this->m_Log_OutputPort[0].isConnected()) {
1486  Fw::LogBuffer _logBuff;
1488 
1489 #if FW_AMPCS_COMPATIBLE
1490  // Serialize the number of arguments
1491  _status = _logBuff.serialize(static_cast<U8>(2 + 1));
1492  FW_ASSERT(
1493  _status == Fw::FW_SERIALIZE_OK,
1494  static_cast<FwAssertArgType>(_status)
1495  );
1496 
1497  // For FATAL, add stack size of 4 and a dummy entry. No support for stacks yet.
1498  _status = _logBuff.serialize(static_cast<U8>(4));
1499  FW_ASSERT(
1500  _status == Fw::FW_SERIALIZE_OK,
1501  static_cast<FwAssertArgType>(_status)
1502  );
1503 
1504  _status = _logBuff.serialize(static_cast<U32>(0));
1505  FW_ASSERT(
1506  _status == Fw::FW_SERIALIZE_OK,
1507  static_cast<FwAssertArgType>(_status)
1508  );
1509 #endif
1510 
1511  _status = entry.serialize(_logBuff, 40);
1512  FW_ASSERT(
1513  _status == Fw::FW_SERIALIZE_OK,
1514  static_cast<FwAssertArgType>(_status)
1515  );
1516 
1517 #if FW_AMPCS_COMPATIBLE
1518  // Serialize the argument size
1519  _status = _logBuff.serialize(
1520  static_cast<U8>(sizeof(U32))
1521  );
1522  FW_ASSERT(
1523  _status == Fw::FW_SERIALIZE_OK,
1524  static_cast<FwAssertArgType>(_status)
1525  );
1526 #endif
1527  _status = _logBuff.serialize(badKey);
1528  FW_ASSERT(
1529  _status == Fw::FW_SERIALIZE_OK,
1530  static_cast<FwAssertArgType>(_status)
1531  );
1532 
1533  this->m_Log_OutputPort[0].invoke(
1534  _id,
1535  _logTime,
1537  _logBuff
1538  );
1539  }
1540 
1541  // Emit the event on the text log port
1542 #if FW_ENABLE_TEXT_LOGGING
1543  if (this->m_LogText_OutputPort[0].isConnected()) {
1544 #if FW_OBJECT_NAMES == 1
1545  const char* _formatString =
1546  "(%s) %s: Ping entry %s responded with wrong key 0x%" PRIx32 "";
1547 #else
1548  const char* _formatString =
1549  "%s: Ping entry %s responded with wrong key 0x%" PRIx32 "";
1550 #endif
1551 
1552  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1553 
1554  (void) snprintf(
1555  _textBuffer,
1557  _formatString,
1558 #if FW_OBJECT_NAMES == 1
1559  this->m_objName,
1560 #endif
1561  "HLTH_PING_WRONG_KEY ",
1562  entry.toChar(),
1563  badKey
1564  );
1565 
1566  // Null terminate
1567  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1568  Fw::TextLogString _logString = _textBuffer;
1569  this->m_LogText_OutputPort[0].invoke(
1570  _id,
1571  _logTime,
1573  _logString
1574  );
1575  }
1576 #endif
1577  }
1578 
1581  {
1582  // Get the time
1583  Fw::Time _logTime;
1584  if (this->m_Time_OutputPort[0].isConnected()) {
1585  this->m_Time_OutputPort[0].invoke(_logTime);
1586  }
1587 
1588  FwEventIdType _id = static_cast<FwEventIdType>(0);
1589 
1590  _id = this->getIdBase() + EVENTID_HLTH_CHECK_ENABLE;
1591 
1592  // Emit the event on the log port
1593  if (this->m_Log_OutputPort[0].isConnected()) {
1594  Fw::LogBuffer _logBuff;
1596 
1597 #if FW_AMPCS_COMPATIBLE
1598  // Serialize the number of arguments
1599  _status = _logBuff.serialize(static_cast<U8>(1));
1600  FW_ASSERT(
1601  _status == Fw::FW_SERIALIZE_OK,
1602  static_cast<FwAssertArgType>(_status)
1603  );
1604 #endif
1605 
1606 #if FW_AMPCS_COMPATIBLE
1607  // Serialize the argument size
1608  _status = _logBuff.serialize(
1609  static_cast<U8>(Fw::Enabled::SERIALIZED_SIZE)
1610  );
1611  FW_ASSERT(
1612  _status == Fw::FW_SERIALIZE_OK,
1613  static_cast<FwAssertArgType>(_status)
1614  );
1615 #endif
1616  _status = _logBuff.serialize(enabled);
1617  FW_ASSERT(
1618  _status == Fw::FW_SERIALIZE_OK,
1619  static_cast<FwAssertArgType>(_status)
1620  );
1621 
1622  this->m_Log_OutputPort[0].invoke(
1623  _id,
1624  _logTime,
1626  _logBuff
1627  );
1628  }
1629 
1630  // Emit the event on the text log port
1631 #if FW_ENABLE_TEXT_LOGGING
1632  if (this->m_LogText_OutputPort[0].isConnected()) {
1633 #if FW_OBJECT_NAMES == 1
1634  const char* _formatString =
1635  "(%s) %s: Health checking set to %s";
1636 #else
1637  const char* _formatString =
1638  "%s: Health checking set to %s";
1639 #endif
1640 
1641  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1642 
1643  Fw::String enabledStr;
1644  enabled.toString(enabledStr);
1645 
1646  (void) snprintf(
1647  _textBuffer,
1649  _formatString,
1650 #if FW_OBJECT_NAMES == 1
1651  this->m_objName,
1652 #endif
1653  "HLTH_CHECK_ENABLE ",
1654  enabledStr.toChar()
1655  );
1656 
1657  // Null terminate
1658  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1659  Fw::TextLogString _logString = _textBuffer;
1660  this->m_LogText_OutputPort[0].invoke(
1661  _id,
1662  _logTime,
1664  _logString
1665  );
1666  }
1667 #endif
1668  }
1669 
1672  Fw::Enabled enabled,
1673  const Fw::LogStringArg& entry
1674  )
1675  {
1676  // Get the time
1677  Fw::Time _logTime;
1678  if (this->m_Time_OutputPort[0].isConnected()) {
1679  this->m_Time_OutputPort[0].invoke(_logTime);
1680  }
1681 
1682  FwEventIdType _id = static_cast<FwEventIdType>(0);
1683 
1684  _id = this->getIdBase() + EVENTID_HLTH_CHECK_PING;
1685 
1686  // Emit the event on the log port
1687  if (this->m_Log_OutputPort[0].isConnected()) {
1688  Fw::LogBuffer _logBuff;
1690 
1691 #if FW_AMPCS_COMPATIBLE
1692  // Serialize the number of arguments
1693  _status = _logBuff.serialize(static_cast<U8>(2));
1694  FW_ASSERT(
1695  _status == Fw::FW_SERIALIZE_OK,
1696  static_cast<FwAssertArgType>(_status)
1697  );
1698 #endif
1699 
1700 #if FW_AMPCS_COMPATIBLE
1701  // Serialize the argument size
1702  _status = _logBuff.serialize(
1703  static_cast<U8>(Fw::Enabled::SERIALIZED_SIZE)
1704  );
1705  FW_ASSERT(
1706  _status == Fw::FW_SERIALIZE_OK,
1707  static_cast<FwAssertArgType>(_status)
1708  );
1709 #endif
1710  _status = _logBuff.serialize(enabled);
1711  FW_ASSERT(
1712  _status == Fw::FW_SERIALIZE_OK,
1713  static_cast<FwAssertArgType>(_status)
1714  );
1715 
1716  _status = entry.serialize(_logBuff, 40);
1717  FW_ASSERT(
1718  _status == Fw::FW_SERIALIZE_OK,
1719  static_cast<FwAssertArgType>(_status)
1720  );
1721 
1722  this->m_Log_OutputPort[0].invoke(
1723  _id,
1724  _logTime,
1726  _logBuff
1727  );
1728  }
1729 
1730  // Emit the event on the text log port
1731 #if FW_ENABLE_TEXT_LOGGING
1732  if (this->m_LogText_OutputPort[0].isConnected()) {
1733 #if FW_OBJECT_NAMES == 1
1734  const char* _formatString =
1735  "(%s) %s: Health checking set to %s for %s";
1736 #else
1737  const char* _formatString =
1738  "%s: Health checking set to %s for %s";
1739 #endif
1740 
1741  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1742 
1743  Fw::String enabledStr;
1744  enabled.toString(enabledStr);
1745 
1746  (void) snprintf(
1747  _textBuffer,
1749  _formatString,
1750 #if FW_OBJECT_NAMES == 1
1751  this->m_objName,
1752 #endif
1753  "HLTH_CHECK_PING ",
1754  enabledStr.toChar(),
1755  entry.toChar()
1756  );
1757 
1758  // Null terminate
1759  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1760  Fw::TextLogString _logString = _textBuffer;
1761  this->m_LogText_OutputPort[0].invoke(
1762  _id,
1763  _logTime,
1765  _logString
1766  );
1767  }
1768 #endif
1769  }
1770 
1773  {
1774  // Get the time
1775  Fw::Time _logTime;
1776  if (this->m_Time_OutputPort[0].isConnected()) {
1777  this->m_Time_OutputPort[0].invoke(_logTime);
1778  }
1779 
1780  FwEventIdType _id = static_cast<FwEventIdType>(0);
1781 
1783 
1784  // Emit the event on the log port
1785  if (this->m_Log_OutputPort[0].isConnected()) {
1786  Fw::LogBuffer _logBuff;
1788 
1789 #if FW_AMPCS_COMPATIBLE
1790  // Serialize the number of arguments
1791  _status = _logBuff.serialize(static_cast<U8>(1));
1792  FW_ASSERT(
1793  _status == Fw::FW_SERIALIZE_OK,
1794  static_cast<FwAssertArgType>(_status)
1795  );
1796 #endif
1797 
1798  _status = entry.serialize(_logBuff, 40);
1799  FW_ASSERT(
1800  _status == Fw::FW_SERIALIZE_OK,
1801  static_cast<FwAssertArgType>(_status)
1802  );
1803 
1804  this->m_Log_OutputPort[0].invoke(
1805  _id,
1806  _logTime,
1808  _logBuff
1809  );
1810  }
1811 
1812  // Emit the event on the text log port
1813 #if FW_ENABLE_TEXT_LOGGING
1814  if (this->m_LogText_OutputPort[0].isConnected()) {
1815 #if FW_OBJECT_NAMES == 1
1816  const char* _formatString =
1817  "(%s) %s: Couldn't find entry %s";
1818 #else
1819  const char* _formatString =
1820  "%s: Couldn't find entry %s";
1821 #endif
1822 
1823  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1824 
1825  (void) snprintf(
1826  _textBuffer,
1828  _formatString,
1829 #if FW_OBJECT_NAMES == 1
1830  this->m_objName,
1831 #endif
1832  "HLTH_CHECK_LOOKUP_ERROR ",
1833  entry.toChar()
1834  );
1835 
1836  // Null terminate
1837  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1838  Fw::TextLogString _logString = _textBuffer;
1839  this->m_LogText_OutputPort[0].invoke(
1840  _id,
1841  _logTime,
1843  _logString
1844  );
1845  }
1846 #endif
1847  }
1848 
1851  const Fw::LogStringArg& entry,
1852  U32 warn,
1853  U32 fatal
1854  )
1855  {
1856  // Get the time
1857  Fw::Time _logTime;
1858  if (this->m_Time_OutputPort[0].isConnected()) {
1859  this->m_Time_OutputPort[0].invoke(_logTime);
1860  }
1861 
1862  FwEventIdType _id = static_cast<FwEventIdType>(0);
1863 
1864  _id = this->getIdBase() + EVENTID_HLTH_PING_UPDATED;
1865 
1866  // Emit the event on the log port
1867  if (this->m_Log_OutputPort[0].isConnected()) {
1868  Fw::LogBuffer _logBuff;
1870 
1871 #if FW_AMPCS_COMPATIBLE
1872  // Serialize the number of arguments
1873  _status = _logBuff.serialize(static_cast<U8>(3));
1874  FW_ASSERT(
1875  _status == Fw::FW_SERIALIZE_OK,
1876  static_cast<FwAssertArgType>(_status)
1877  );
1878 #endif
1879 
1880  _status = entry.serialize(_logBuff, 40);
1881  FW_ASSERT(
1882  _status == Fw::FW_SERIALIZE_OK,
1883  static_cast<FwAssertArgType>(_status)
1884  );
1885 
1886 #if FW_AMPCS_COMPATIBLE
1887  // Serialize the argument size
1888  _status = _logBuff.serialize(
1889  static_cast<U8>(sizeof(U32))
1890  );
1891  FW_ASSERT(
1892  _status == Fw::FW_SERIALIZE_OK,
1893  static_cast<FwAssertArgType>(_status)
1894  );
1895 #endif
1896  _status = _logBuff.serialize(warn);
1897  FW_ASSERT(
1898  _status == Fw::FW_SERIALIZE_OK,
1899  static_cast<FwAssertArgType>(_status)
1900  );
1901 
1902 #if FW_AMPCS_COMPATIBLE
1903  // Serialize the argument size
1904  _status = _logBuff.serialize(
1905  static_cast<U8>(sizeof(U32))
1906  );
1907  FW_ASSERT(
1908  _status == Fw::FW_SERIALIZE_OK,
1909  static_cast<FwAssertArgType>(_status)
1910  );
1911 #endif
1912  _status = _logBuff.serialize(fatal);
1913  FW_ASSERT(
1914  _status == Fw::FW_SERIALIZE_OK,
1915  static_cast<FwAssertArgType>(_status)
1916  );
1917 
1918  this->m_Log_OutputPort[0].invoke(
1919  _id,
1920  _logTime,
1922  _logBuff
1923  );
1924  }
1925 
1926  // Emit the event on the text log port
1927 #if FW_ENABLE_TEXT_LOGGING
1928  if (this->m_LogText_OutputPort[0].isConnected()) {
1929 #if FW_OBJECT_NAMES == 1
1930  const char* _formatString =
1931  "(%s) %s: Health ping for %s changed to WARN %" PRIu32 " FATAL %" PRIu32 "";
1932 #else
1933  const char* _formatString =
1934  "%s: Health ping for %s changed to WARN %" PRIu32 " FATAL %" PRIu32 "";
1935 #endif
1936 
1937  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1938 
1939  (void) snprintf(
1940  _textBuffer,
1942  _formatString,
1943 #if FW_OBJECT_NAMES == 1
1944  this->m_objName,
1945 #endif
1946  "HLTH_PING_UPDATED ",
1947  entry.toChar(),
1948  warn,
1949  fatal
1950  );
1951 
1952  // Null terminate
1953  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1954  Fw::TextLogString _logString = _textBuffer;
1955  this->m_LogText_OutputPort[0].invoke(
1956  _id,
1957  _logTime,
1959  _logString
1960  );
1961  }
1962 #endif
1963  }
1964 
1967  const Fw::LogStringArg& entry,
1968  U32 warn,
1969  U32 fatal
1970  )
1971  {
1972  // Get the time
1973  Fw::Time _logTime;
1974  if (this->m_Time_OutputPort[0].isConnected()) {
1975  this->m_Time_OutputPort[0].invoke(_logTime);
1976  }
1977 
1978  FwEventIdType _id = static_cast<FwEventIdType>(0);
1979 
1981 
1982  // Emit the event on the log port
1983  if (this->m_Log_OutputPort[0].isConnected()) {
1984  Fw::LogBuffer _logBuff;
1986 
1987 #if FW_AMPCS_COMPATIBLE
1988  // Serialize the number of arguments
1989  _status = _logBuff.serialize(static_cast<U8>(3));
1990  FW_ASSERT(
1991  _status == Fw::FW_SERIALIZE_OK,
1992  static_cast<FwAssertArgType>(_status)
1993  );
1994 #endif
1995 
1996  _status = entry.serialize(_logBuff, 40);
1997  FW_ASSERT(
1998  _status == Fw::FW_SERIALIZE_OK,
1999  static_cast<FwAssertArgType>(_status)
2000  );
2001 
2002 #if FW_AMPCS_COMPATIBLE
2003  // Serialize the argument size
2004  _status = _logBuff.serialize(
2005  static_cast<U8>(sizeof(U32))
2006  );
2007  FW_ASSERT(
2008  _status == Fw::FW_SERIALIZE_OK,
2009  static_cast<FwAssertArgType>(_status)
2010  );
2011 #endif
2012  _status = _logBuff.serialize(warn);
2013  FW_ASSERT(
2014  _status == Fw::FW_SERIALIZE_OK,
2015  static_cast<FwAssertArgType>(_status)
2016  );
2017 
2018 #if FW_AMPCS_COMPATIBLE
2019  // Serialize the argument size
2020  _status = _logBuff.serialize(
2021  static_cast<U8>(sizeof(U32))
2022  );
2023  FW_ASSERT(
2024  _status == Fw::FW_SERIALIZE_OK,
2025  static_cast<FwAssertArgType>(_status)
2026  );
2027 #endif
2028  _status = _logBuff.serialize(fatal);
2029  FW_ASSERT(
2030  _status == Fw::FW_SERIALIZE_OK,
2031  static_cast<FwAssertArgType>(_status)
2032  );
2033 
2034  this->m_Log_OutputPort[0].invoke(
2035  _id,
2036  _logTime,
2038  _logBuff
2039  );
2040  }
2041 
2042  // Emit the event on the text log port
2043 #if FW_ENABLE_TEXT_LOGGING
2044  if (this->m_LogText_OutputPort[0].isConnected()) {
2045 #if FW_OBJECT_NAMES == 1
2046  const char* _formatString =
2047  "(%s) %s: Health ping for %s invalid values: WARN %" PRIu32 " FATAL %" PRIu32 "";
2048 #else
2049  const char* _formatString =
2050  "%s: Health ping for %s invalid values: WARN %" PRIu32 " FATAL %" PRIu32 "";
2051 #endif
2052 
2053  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
2054 
2055  (void) snprintf(
2056  _textBuffer,
2058  _formatString,
2059 #if FW_OBJECT_NAMES == 1
2060  this->m_objName,
2061 #endif
2062  "HLTH_PING_INVALID_VALUES ",
2063  entry.toChar(),
2064  warn,
2065  fatal
2066  );
2067 
2068  // Null terminate
2069  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
2070  Fw::TextLogString _logString = _textBuffer;
2071  this->m_LogText_OutputPort[0].invoke(
2072  _id,
2073  _logTime,
2075  _logString
2076  );
2077  }
2078 #endif
2079  }
2080 
2081  // ----------------------------------------------------------------------
2082  // Telemetry write functions
2083  // ----------------------------------------------------------------------
2084 
2087  U32 arg,
2088  Fw::Time _tlmTime
2089  )
2090  {
2091  if (this->m_Tlm_OutputPort[0].isConnected()) {
2092  if (
2093  this->m_Time_OutputPort[0].isConnected() &&
2094  (_tlmTime == Fw::ZERO_TIME)
2095  ) {
2096  this->m_Time_OutputPort[0].invoke(_tlmTime);
2097  }
2098 
2099  Fw::TlmBuffer _tlmBuff;
2100  Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
2101  FW_ASSERT(
2102  _stat == Fw::FW_SERIALIZE_OK,
2103  static_cast<FwAssertArgType>(_stat)
2104  );
2105 
2106  FwChanIdType _id;
2107 
2108  _id = this->getIdBase() + CHANNELID_PINGLATEWARNINGS;
2109 
2110  this->m_Tlm_OutputPort[0].invoke(
2111  _id,
2112  _tlmTime,
2113  _tlmBuff
2114  );
2115  }
2116  }
2117 
2118  // ----------------------------------------------------------------------
2119  // Time
2120  // ----------------------------------------------------------------------
2121 
2123  getTime()
2124  {
2125  if (this->m_Time_OutputPort[0].isConnected()) {
2126  Fw::Time _time;
2127  this->m_Time_OutputPort[0].invoke(_time);
2128  return _time;
2129  }
2130  else {
2131  return Fw::Time(TB_NONE, 0, 0);
2132  }
2133  }
2134 
2135  // ----------------------------------------------------------------------
2136  // Message dispatch functions
2137  // ----------------------------------------------------------------------
2138 
2140  doDispatch()
2141  {
2142  ComponentIpcSerializableBuffer msg;
2143  NATIVE_INT_TYPE priority = 0;
2144 
2145  Os::Queue::QueueStatus msgStatus = this->m_queue.receive(
2146  msg,
2147  priority,
2149  );
2150  if (Os::Queue::QUEUE_NO_MORE_MSGS == msgStatus) {
2152  }
2153  else {
2154  FW_ASSERT(
2155  msgStatus == Os::Queue::QUEUE_OK,
2156  static_cast<FwAssertArgType>(msgStatus)
2157  );
2158  }
2159 
2160  // Reset to beginning of buffer
2161  msg.resetDeser();
2162 
2163  NATIVE_INT_TYPE desMsg = 0;
2164  Fw::SerializeStatus deserStatus = msg.deserialize(desMsg);
2165  FW_ASSERT(
2166  deserStatus == Fw::FW_SERIALIZE_OK,
2167  static_cast<FwAssertArgType>(deserStatus)
2168  );
2169 
2170  MsgTypeEnum msgType = static_cast<MsgTypeEnum>(desMsg);
2171 
2172  if (msgType == HEALTH_COMPONENT_EXIT) {
2173  return MSG_DISPATCH_EXIT;
2174  }
2175 
2176  NATIVE_INT_TYPE portNum = 0;
2177  deserStatus = msg.deserialize(portNum);
2178  FW_ASSERT(
2179  deserStatus == Fw::FW_SERIALIZE_OK,
2180  static_cast<FwAssertArgType>(deserStatus)
2181  );
2182 
2183  switch (msgType) {
2184  // Handle async input port PingReturn
2185  case PINGRETURN_PING: {
2186  // Deserialize argument key
2187  U32 key;
2188  deserStatus = msg.deserialize(key);
2189  FW_ASSERT(
2190  deserStatus == Fw::FW_SERIALIZE_OK,
2191  static_cast<FwAssertArgType>(deserStatus)
2192  );
2193  // Call handler function
2194  this->PingReturn_handler(
2195  portNum,
2196  key
2197  );
2198 
2199  break;
2200  }
2201 
2202  // Handle command HLTH_ENABLE
2203  case CMD_HLTH_ENABLE: {
2204  // Deserialize opcode
2205  FwOpcodeType opCode = 0;
2206  deserStatus = msg.deserialize(opCode);
2207  FW_ASSERT (
2208  deserStatus == Fw::FW_SERIALIZE_OK,
2209  static_cast<FwAssertArgType>(deserStatus)
2210  );
2211 
2212  // Deserialize command sequence
2213  U32 cmdSeq = 0;
2214  deserStatus = msg.deserialize(cmdSeq);
2215  FW_ASSERT (
2216  deserStatus == Fw::FW_SERIALIZE_OK,
2217  static_cast<FwAssertArgType>(deserStatus)
2218  );
2219 
2220  // Deserialize command argument buffer
2221  Fw::CmdArgBuffer args;
2222  deserStatus = msg.deserialize(args);
2223  FW_ASSERT (
2224  deserStatus == Fw::FW_SERIALIZE_OK,
2225  static_cast<FwAssertArgType>(deserStatus)
2226  );
2227 
2228  // Reset buffer
2229  args.resetDeser();
2230 
2231  // Deserialize argument enable
2232  Fw::Enabled enable;
2233  deserStatus = args.deserialize(enable);
2234  if (deserStatus != Fw::FW_SERIALIZE_OK) {
2235  if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2236  this->cmdResponse_out(
2237  opCode,
2238  cmdSeq,
2240  );
2241  }
2242  // Don't crash the task if bad arguments were passed from the ground
2243  break;
2244  }
2245 
2246  // Make sure there was no data left over.
2247  // That means the argument buffer size was incorrect.
2248 #if FW_CMD_CHECK_RESIDUAL
2249  if (args.getBuffLeft() != 0) {
2250  if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2251  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2252  }
2253  // Don't crash the task if bad arguments were passed from the ground
2254  break;
2255  }
2256 #endif
2257 
2258  // Call handler function
2259  this->HLTH_ENABLE_cmdHandler(
2260  opCode, cmdSeq,
2261  enable
2262  );
2263 
2264  break;
2265  }
2266 
2267  // Handle command HLTH_PING_ENABLE
2268  case CMD_HLTH_PING_ENABLE: {
2269  // Deserialize opcode
2270  FwOpcodeType opCode = 0;
2271  deserStatus = msg.deserialize(opCode);
2272  FW_ASSERT (
2273  deserStatus == Fw::FW_SERIALIZE_OK,
2274  static_cast<FwAssertArgType>(deserStatus)
2275  );
2276 
2277  // Deserialize command sequence
2278  U32 cmdSeq = 0;
2279  deserStatus = msg.deserialize(cmdSeq);
2280  FW_ASSERT (
2281  deserStatus == Fw::FW_SERIALIZE_OK,
2282  static_cast<FwAssertArgType>(deserStatus)
2283  );
2284 
2285  // Deserialize command argument buffer
2286  Fw::CmdArgBuffer args;
2287  deserStatus = msg.deserialize(args);
2288  FW_ASSERT (
2289  deserStatus == Fw::FW_SERIALIZE_OK,
2290  static_cast<FwAssertArgType>(deserStatus)
2291  );
2292 
2293  // Reset buffer
2294  args.resetDeser();
2295 
2296  // Deserialize argument entry
2297  Fw::CmdStringArg entry;
2298  deserStatus = args.deserialize(entry);
2299  if (deserStatus != Fw::FW_SERIALIZE_OK) {
2300  if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2301  this->cmdResponse_out(
2302  opCode,
2303  cmdSeq,
2305  );
2306  }
2307  // Don't crash the task if bad arguments were passed from the ground
2308  break;
2309  }
2310 
2311  // Deserialize argument enable
2312  Fw::Enabled enable;
2313  deserStatus = args.deserialize(enable);
2314  if (deserStatus != Fw::FW_SERIALIZE_OK) {
2315  if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2316  this->cmdResponse_out(
2317  opCode,
2318  cmdSeq,
2320  );
2321  }
2322  // Don't crash the task if bad arguments were passed from the ground
2323  break;
2324  }
2325 
2326  // Make sure there was no data left over.
2327  // That means the argument buffer size was incorrect.
2328 #if FW_CMD_CHECK_RESIDUAL
2329  if (args.getBuffLeft() != 0) {
2330  if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2331  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2332  }
2333  // Don't crash the task if bad arguments were passed from the ground
2334  break;
2335  }
2336 #endif
2337 
2338  // Call handler function
2340  opCode, cmdSeq,
2341  entry,
2342  enable
2343  );
2344 
2345  break;
2346  }
2347 
2348  // Handle command HLTH_CHNG_PING
2349  case CMD_HLTH_CHNG_PING: {
2350  // Deserialize opcode
2351  FwOpcodeType opCode = 0;
2352  deserStatus = msg.deserialize(opCode);
2353  FW_ASSERT (
2354  deserStatus == Fw::FW_SERIALIZE_OK,
2355  static_cast<FwAssertArgType>(deserStatus)
2356  );
2357 
2358  // Deserialize command sequence
2359  U32 cmdSeq = 0;
2360  deserStatus = msg.deserialize(cmdSeq);
2361  FW_ASSERT (
2362  deserStatus == Fw::FW_SERIALIZE_OK,
2363  static_cast<FwAssertArgType>(deserStatus)
2364  );
2365 
2366  // Deserialize command argument buffer
2367  Fw::CmdArgBuffer args;
2368  deserStatus = msg.deserialize(args);
2369  FW_ASSERT (
2370  deserStatus == Fw::FW_SERIALIZE_OK,
2371  static_cast<FwAssertArgType>(deserStatus)
2372  );
2373 
2374  // Reset buffer
2375  args.resetDeser();
2376 
2377  // Deserialize argument entry
2378  Fw::CmdStringArg entry;
2379  deserStatus = args.deserialize(entry);
2380  if (deserStatus != Fw::FW_SERIALIZE_OK) {
2381  if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2382  this->cmdResponse_out(
2383  opCode,
2384  cmdSeq,
2386  );
2387  }
2388  // Don't crash the task if bad arguments were passed from the ground
2389  break;
2390  }
2391 
2392  // Deserialize argument warningValue
2393  U32 warningValue;
2394  deserStatus = args.deserialize(warningValue);
2395  if (deserStatus != Fw::FW_SERIALIZE_OK) {
2396  if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2397  this->cmdResponse_out(
2398  opCode,
2399  cmdSeq,
2401  );
2402  }
2403  // Don't crash the task if bad arguments were passed from the ground
2404  break;
2405  }
2406 
2407  // Deserialize argument fatalValue
2408  U32 fatalValue;
2409  deserStatus = args.deserialize(fatalValue);
2410  if (deserStatus != Fw::FW_SERIALIZE_OK) {
2411  if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2412  this->cmdResponse_out(
2413  opCode,
2414  cmdSeq,
2416  );
2417  }
2418  // Don't crash the task if bad arguments were passed from the ground
2419  break;
2420  }
2421 
2422  // Make sure there was no data left over.
2423  // That means the argument buffer size was incorrect.
2424 #if FW_CMD_CHECK_RESIDUAL
2425  if (args.getBuffLeft() != 0) {
2426  if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2427  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2428  }
2429  // Don't crash the task if bad arguments were passed from the ground
2430  break;
2431  }
2432 #endif
2433 
2434  // Call handler function
2436  opCode, cmdSeq,
2437  entry,
2438  warningValue,
2439  fatalValue
2440  );
2441 
2442  break;
2443  }
2444 
2445  default:
2446  return MSG_DISPATCH_ERROR;
2447  }
2448 
2449  return MSG_DISPATCH_OK;
2450  }
2451 
2452  // ----------------------------------------------------------------------
2453  // Calls for messages received on special input ports
2454  // ----------------------------------------------------------------------
2455 
2456  void HealthComponentBase ::
2457  m_p_CmdDisp_in(
2458  Fw::PassiveComponentBase* callComp,
2459  NATIVE_INT_TYPE portNum,
2460  FwOpcodeType opCode,
2461  U32 cmdSeq,
2462  Fw::CmdArgBuffer& args
2463  )
2464  {
2465  FW_ASSERT(callComp);
2466  HealthComponentBase* compPtr = static_cast<HealthComponentBase*>(callComp);
2467 
2468  const U32 idBase = callComp->getIdBase();
2469  FW_ASSERT(opCode >= idBase, opCode, idBase);
2470 
2471  // Select base class function based on opcode
2472  switch (opCode - idBase) {
2473  case OPCODE_HLTH_ENABLE: {
2474  compPtr->HLTH_ENABLE_cmdHandlerBase(
2475  opCode,
2476  cmdSeq,
2477  args
2478  );
2479  break;
2480  }
2481 
2482  case OPCODE_HLTH_PING_ENABLE: {
2484  opCode,
2485  cmdSeq,
2486  args
2487  );
2488  break;
2489  }
2490 
2491  case OPCODE_HLTH_CHNG_PING: {
2493  opCode,
2494  cmdSeq,
2495  args
2496  );
2497  break;
2498  }
2499  }
2500  }
2501 
2502  // ----------------------------------------------------------------------
2503  // Calls for messages received on typed input ports
2504  // ----------------------------------------------------------------------
2505 
2506  void HealthComponentBase ::
2507  m_p_PingReturn_in(
2508  Fw::PassiveComponentBase* callComp,
2509  NATIVE_INT_TYPE portNum,
2510  U32 key
2511  )
2512  {
2513  FW_ASSERT(callComp);
2514  HealthComponentBase* compPtr = static_cast<HealthComponentBase*>(callComp);
2515  compPtr->PingReturn_handlerBase(
2516  portNum,
2517  key
2518  );
2519  }
2520 
2521  void HealthComponentBase ::
2522  m_p_Run_in(
2523  Fw::PassiveComponentBase* callComp,
2524  NATIVE_INT_TYPE portNum,
2525  NATIVE_UINT_TYPE context
2526  )
2527  {
2528  FW_ASSERT(callComp);
2529  HealthComponentBase* compPtr = static_cast<HealthComponentBase*>(callComp);
2530  compPtr->Run_handlerBase(
2531  portNum,
2532  context
2533  );
2534  }
2535 
2536 }
#define FW_ASSERT(...)
Definition: Assert.hpp:14
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:51
U8 BYTE
byte type
Definition: BasicTypes.h:27
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:26
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:66
PlatformUIntType NATIVE_UINT_TYPE
Definition: BasicTypes.h:52
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
#define PRI_PlatformIntType
@ TB_NONE
No time base has been established.
Definition: FpConfig.h:39
PlatformAssertArgType FwAssertArgType
Definition: FpConfig.h:21
U32 FwChanIdType
Definition: FpConfig.h:59
U32 FwEventIdType
Definition: FpConfig.h:62
U32 FwOpcodeType
Definition: FpConfig.h:56
#define FW_LOG_TEXT_BUFFER_SIZE
Max size of string for text log message.
Definition: FpConfig.h:299
#define FW_OBJ_NAME_MAX_SIZE
Size of object name (if object names enabled). AC Limits to 80, truncation occurs above 80.
Definition: FpConfig.h:184
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects)
Definition: FpConfig.h:88
@ ACTIVE_COMPONENT_EXIT
message to exit active component task
Enum representing a command response.
@ FORMAT_ERROR
Command failed to deserialize.
Enabled and disabled states.
@ SERIALIZED_SIZE
The size of the serial representation.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CmdPortAc.cpp:62
void init()
Initialization function.
Definition: CmdPortAc.cpp:56
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition: CmdPortAc.hpp:37
void setPortNum(NATIVE_INT_TYPE portNum)
@ WARNING_HI
A serious but recoverable event.
@ ACTIVITY_HI
Important informational events.
@ FATAL
A fatal non-recoverable event.
@ WARNING_LO
A less serious but recoverable event.
const char * toChar() const override
Definition: LogString.cpp:49
SerializeStatus serialize(SerializeBufferBase &buffer) const override
serialization function
Definition: LogString.cpp:57
void init()
Object initializer.
Definition: ObjBase.cpp:27
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 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::QueueStatus createQueue(NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize)
Os::Queue m_queue
queue object for active component
@ MSG_DISPATCH_EMPTY
No more messages in the queue.
@ 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 getBuffLeft() const
returns how much deserialization buffer is left
void resetDeser()
reset deserialization to beginning
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
const char * toChar() const
gets char buffer
Definition: String.cpp:48
Definition: Time.hpp:9
QueueStatus
Definition: Queue.hpp:27
@ QUEUE_NO_MORE_MSGS
If non-blocking, all the messages have been drained.
Definition: Queue.hpp:29
@ QUEUE_OK
message sent/received okay
Definition: Queue.hpp:28
QueueStatus send(const Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE priority, QueueBlocking block)
send a message
Definition: QueueCommon.cpp:13
QueueStatus receive(Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE &priority, QueueBlocking block)
receive a message
Definition: QueueCommon.cpp:22
QueueBlocking
Definition: Queue.hpp:40
@ QUEUE_NONBLOCKING
Queue receive always returns even if there is no message.
Definition: Queue.hpp:42
Auto-generated base for Health component.
bool isConnected_CmdStatus_OutputPort(NATIVE_INT_TYPE portNum)
NATIVE_INT_TYPE getNum_CmdReg_OutputPorts() const
void tlmWrite_PingLateWarnings(U32 arg, Fw::Time _tlmTime=Fw::Time())
void PingReturn_handlerBase(NATIVE_INT_TYPE portNum, U32 key)
Handler base-class function for input port PingReturn.
NATIVE_INT_TYPE getNum_PingReturn_InputPorts() const
void log_ACTIVITY_HI_HLTH_CHECK_PING(Fw::Enabled enabled, const Fw::LogStringArg &entry)
virtual void PingReturn_handler(NATIVE_INT_TYPE portNum, U32 key)=0
Handler for input port PingReturn.
virtual MsgDispatchStatus doDispatch()
Called in the message loop to dispatch a message from the queue.
virtual void HLTH_PING_ENABLE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdStringArg &entry, Fw::Enabled enable)=0
void HLTH_PING_ENABLE_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
void HLTH_CHNG_PING_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
bool isConnected_Log_OutputPort(NATIVE_INT_TYPE portNum)
void log_FATAL_HLTH_PING_WRONG_KEY(const Fw::LogStringArg &entry, U32 badKey)
virtual void PingReturn_preMsgHook(NATIVE_INT_TYPE portNum, U32 key)
Pre-message hook for async input port PingReturn.
bool isConnected_WdogStroke_OutputPort(NATIVE_INT_TYPE portNum)
Svc::InputPingPort * get_PingReturn_InputPort(NATIVE_INT_TYPE portNum)
void set_PingSend_OutputPort(NATIVE_INT_TYPE portNum, Svc::InputPingPort *port)
Connect port to PingSend[portNum].
void log_FATAL_HLTH_PING_LATE(const Fw::LogStringArg &entry)
void set_CmdReg_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputCmdRegPort *port)
Connect port to CmdReg[portNum].
NATIVE_INT_TYPE getNum_PingSend_OutputPorts() const
@ EVENTID_HLTH_PING_UPDATED
Report changed ping.
@ EVENTID_HLTH_CHECK_LOOKUP_ERROR
Entry was not found.
@ EVENTID_HLTH_CHECK_PING
Report a particular entry on or off.
@ EVENTID_HLTH_CHECK_ENABLE
Report checking turned on or off.
@ EVENTID_HLTH_PING_LATE
Declare FATAL since task is no longer responding.
@ EVENTID_HLTH_PING_INVALID_VALUES
Report changed ping.
@ EVENTID_HLTH_PING_WRONG_KEY
Declare FATAL since task is no longer responding.
@ EVENTID_HLTH_PING_WARN
Warn that a ping target is longer than the warning value.
void set_WdogStroke_OutputPort(NATIVE_INT_TYPE portNum, Svc::InputWatchDogPort *port)
Connect port to WdogStroke[portNum].
void log_WARNING_LO_HLTH_CHECK_LOOKUP_ERROR(const Fw::LogStringArg &entry)
bool isConnected_PingSend_OutputPort(NATIVE_INT_TYPE portNum)
NATIVE_INT_TYPE getNum_CmdDisp_InputPorts() const
virtual ~HealthComponentBase()
Destroy HealthComponentBase object.
Svc::InputSchedPort * get_Run_InputPort(NATIVE_INT_TYPE portNum)
NATIVE_INT_TYPE getNum_Tlm_OutputPorts() const
NATIVE_INT_TYPE getNum_Time_OutputPorts() const
void log_WARNING_HI_HLTH_PING_WARN(const Fw::LogStringArg &entry)
virtual void HLTH_ENABLE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Fw::Enabled enable)=0
void HLTH_ENABLE_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
NATIVE_INT_TYPE getNum_CmdStatus_OutputPorts() const
virtual void Run_handler(NATIVE_INT_TYPE portNum, NATIVE_UINT_TYPE context)=0
Handler for input port Run.
void log_ACTIVITY_HI_HLTH_CHECK_ENABLE(Fw::Enabled enabled)
bool isConnected_Tlm_OutputPort(NATIVE_INT_TYPE portNum)
void regCommands()
Register commands with the Command Dispatcher.
void set_Log_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputLogPort *port)
Connect port to Log[portNum].
bool isConnected_CmdReg_OutputPort(NATIVE_INT_TYPE portNum)
void set_Time_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
virtual void HLTH_CHNG_PING_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command HLTH_CHNG_PING.
virtual void HLTH_PING_ENABLE_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command HLTH_PING_ENABLE.
Fw::InputCmdPort * get_CmdDisp_InputPort(NATIVE_INT_TYPE portNum)
void PingSend_out(NATIVE_INT_TYPE portNum, U32 key)
Invoke output port PingSend.
NATIVE_INT_TYPE getNum_WdogStroke_OutputPorts() const
void log_WARNING_HI_HLTH_PING_INVALID_VALUES(const Fw::LogStringArg &entry, U32 warn, U32 fatal)
@ CHANNELID_PINGLATEWARNINGS
Channel ID for PingLateWarnings.
NATIVE_INT_TYPE getNum_Run_InputPorts() const
NATIVE_INT_TYPE getNum_Log_OutputPorts() const
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
void set_CmdStatus_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputCmdResponsePort *port)
Connect port to CmdStatus[portNum].
void set_Tlm_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputTlmPort *port)
Connect port to Tlm[portNum].
HealthComponentBase(const char *compName="")
Construct HealthComponentBase object.
bool isConnected_Time_OutputPort(NATIVE_INT_TYPE portNum)
virtual void HLTH_ENABLE_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command HLTH_ENABLE.
void Run_handlerBase(NATIVE_INT_TYPE portNum, NATIVE_UINT_TYPE context)
Handler base-class function for input port Run.
@ OPCODE_HLTH_CHNG_PING
Change ping value.
@ OPCODE_HLTH_ENABLE
A command to enable or disable health checks.
@ OPCODE_HLTH_PING_ENABLE
Ignore a particular ping entry.
void log_ACTIVITY_HI_HLTH_PING_UPDATED(const Fw::LogStringArg &entry, U32 warn, U32 fatal)
void WdogStroke_out(NATIVE_INT_TYPE portNum, U32 code)
Invoke output port WdogStroke.
virtual void HLTH_CHNG_PING_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdStringArg &entry, U32 warningValue, U32 fatalValue)=0
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition: PingPortAc.hpp:36
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: PingPortAc.cpp:62
void init()
Initialization function.
Definition: PingPortAc.cpp:56
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 invoke(U32 code)
Invoke a port interface.
void init()
Initialization function.
void addCallPort(InputWatchDogPort *callPort)
Register an input port.
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
const Time ZERO_TIME
Definition: Time.cpp:5