F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
HealthComponentAc.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title HealthComponentAc.hpp
3 // \author Generated by fpp-to-cpp
4 // \brief hpp file for Health component base class
5 // ======================================================================
6 
7 #ifndef Svc_HealthComponentAc_HPP
8 #define Svc_HealthComponentAc_HPP
9 
10 #include <atomic>
11 
12 #include "Fw/Cmd/CmdPortAc.hpp"
13 #include "Fw/Cmd/CmdRegPortAc.hpp"
15 #include "Fw/Cmd/CmdString.hpp"
17 #include "Fw/FPrimeBasicTypes.hpp"
18 #include "Fw/Log/LogPortAc.hpp"
19 #include "Fw/Log/LogString.hpp"
20 #if FW_ENABLE_TEXT_LOGGING == 1
21 #include "Fw/Log/LogTextPortAc.hpp"
22 #endif
25 #include "Fw/Time/TimePortAc.hpp"
26 #include "Fw/Tlm/TlmPortAc.hpp"
27 #include "Fw/Tlm/TlmString.hpp"
29 #include "Svc/Ping/PingPortAc.hpp"
33 
34 namespace Svc {
35 
42  {
43 
44  // ----------------------------------------------------------------------
45  // Friend classes
46  // ----------------------------------------------------------------------
47 
49  friend class HealthTesterBase;
51  friend class HealthTester;
52 
53  protected:
54 
55  // ----------------------------------------------------------------------
56  // Constants
57  // ----------------------------------------------------------------------
58 
60  enum {
62  };
63 
65  enum {
68  };
69 
71  enum {
78  };
79 
81  enum {
84  };
85 
87  enum {
91  };
92 
94  enum {
103  };
104 
106  enum {
108  };
109 
110  public:
111 
112  // ----------------------------------------------------------------------
113  // Component initialization
114  // ----------------------------------------------------------------------
115 
117  void init(
118  FwSizeType queueDepth,
119  FwEnumStoreType instance = 0
120  );
121 
122  public:
123 
124  // ----------------------------------------------------------------------
125  // Getters for special input ports
126  // ----------------------------------------------------------------------
127 
132  FwIndexType portNum
133  );
134 
135  public:
136 
137  // ----------------------------------------------------------------------
138  // Getters for typed input ports
139  // ----------------------------------------------------------------------
140 
145  FwIndexType portNum
146  );
147 
152  FwIndexType portNum
153  );
154 
155  public:
156 
157  // ----------------------------------------------------------------------
158  // Connect input ports to special output ports
159  // ----------------------------------------------------------------------
160 
163  FwIndexType portNum,
164  Fw::InputCmdRegPort* port
165  );
166 
169  FwIndexType portNum,
171  );
172 
174  void set_Log_OutputPort(
175  FwIndexType portNum,
176  Fw::InputLogPort* port
177  );
178 
179 #if FW_ENABLE_TEXT_LOGGING == 1
180 
182  void set_LogText_OutputPort(
183  FwIndexType portNum,
184  Fw::InputLogTextPort* port
185  );
186 
187 #endif
188 
190  void set_Time_OutputPort(
191  FwIndexType portNum,
192  Fw::InputTimePort* port
193  );
194 
196  void set_Tlm_OutputPort(
197  FwIndexType portNum,
198  Fw::InputTlmPort* port
199  );
200 
201  public:
202 
203  // ----------------------------------------------------------------------
204  // Connect typed input ports to typed output ports
205  // ----------------------------------------------------------------------
206 
209  FwIndexType portNum,
210  Svc::InputPingPort* port
211  );
212 
215  FwIndexType portNum,
217  );
218 
219 #if FW_PORT_SERIALIZATION
220 
221  public:
222 
223  // ----------------------------------------------------------------------
224  // Connect serial input ports to special output ports
225  // ----------------------------------------------------------------------
226 
229  FwIndexType portNum,
230  Fw::InputSerializePort* port
231  );
232 
235  FwIndexType portNum,
236  Fw::InputSerializePort* port
237  );
238 
240  void set_Log_OutputPort(
241  FwIndexType portNum,
242  Fw::InputSerializePort* port
243  );
244 
245 #if FW_ENABLE_TEXT_LOGGING == 1
246 
248  void set_LogText_OutputPort(
249  FwIndexType portNum,
250  Fw::InputSerializePort* port
251  );
252 
253 #endif
254 
256  void set_Time_OutputPort(
257  FwIndexType portNum,
258  Fw::InputSerializePort* port
259  );
260 
262  void set_Tlm_OutputPort(
263  FwIndexType portNum,
264  Fw::InputSerializePort* port
265  );
266 
267 #endif
268 
269 #if FW_PORT_SERIALIZATION
270 
271  public:
272 
273  // ----------------------------------------------------------------------
274  // Connect serial input ports to typed output ports
275  // ----------------------------------------------------------------------
276 
279  FwIndexType portNum,
280  Fw::InputSerializePort* port
281  );
282 
285  FwIndexType portNum,
286  Fw::InputSerializePort* port
287  );
288 
289 #endif
290 
291  public:
292 
293  // ----------------------------------------------------------------------
294  // Command registration
295  // ----------------------------------------------------------------------
296 
300  void regCommands();
301 
302  protected:
303 
304  // ----------------------------------------------------------------------
305  // Component construction and destruction
306  // ----------------------------------------------------------------------
307 
310  const char* compName = ""
311  );
312 
314  virtual ~HealthComponentBase();
315 
316  protected:
317 
318  // ----------------------------------------------------------------------
319  // Getters for numbers of special input ports
320  // ----------------------------------------------------------------------
321 
327  }
328 
329  protected:
330 
331  // ----------------------------------------------------------------------
332  // Getters for numbers of typed input ports
333  // ----------------------------------------------------------------------
334 
340  }
341 
345  static constexpr FwIndexType getNum_Run_InputPorts() {
346  return NUM_RUN_INPUT_PORTS;
347  }
348 
349  protected:
350 
351  // ----------------------------------------------------------------------
352  // Getters for numbers of special output ports
353  // ----------------------------------------------------------------------
354 
360  }
361 
367  }
368 
372  static constexpr FwIndexType getNum_Log_OutputPorts() {
373  return NUM_LOG_OUTPUT_PORTS;
374  }
375 
376 #if FW_ENABLE_TEXT_LOGGING == 1
377 
381  static constexpr FwIndexType getNum_LogText_OutputPorts() {
383  }
384 
385 #endif
386 
391  return NUM_TIME_OUTPUT_PORTS;
392  }
393 
397  static constexpr FwIndexType getNum_Tlm_OutputPorts() {
398  return NUM_TLM_OUTPUT_PORTS;
399  }
400 
401  protected:
402 
403  // ----------------------------------------------------------------------
404  // Getters for numbers of typed output ports
405  // ----------------------------------------------------------------------
406 
412  }
413 
419  }
420 
421  protected:
422 
423  // ----------------------------------------------------------------------
424  // Connection status queries for special output ports
425  // ----------------------------------------------------------------------
426 
431  FwIndexType portNum
432  );
433 
438  FwIndexType portNum
439  );
440 
445  FwIndexType portNum
446  );
447 
448 #if FW_ENABLE_TEXT_LOGGING == 1
449 
453  bool isConnected_LogText_OutputPort(
454  FwIndexType portNum
455  );
456 
457 #endif
458 
463  FwIndexType portNum
464  );
465 
470  FwIndexType portNum
471  );
472 
473  protected:
474 
475  // ----------------------------------------------------------------------
476  // Connection status queries for typed output ports
477  // ----------------------------------------------------------------------
478 
483  FwIndexType portNum
484  );
485 
490  FwIndexType portNum
491  );
492 
493  protected:
494 
495  // ----------------------------------------------------------------------
496  // Handlers to implement for typed input ports
497  // ----------------------------------------------------------------------
498 
500  virtual void PingReturn_handler(
501  FwIndexType portNum,
502  U32 key
503  ) = 0;
504 
506  virtual void Run_handler(
507  FwIndexType portNum,
508  U32 context
509  ) = 0;
510 
511  protected:
512 
513  // ----------------------------------------------------------------------
514  // Port handler base-class functions for typed input ports
515  //
516  // Call these functions directly to bypass the corresponding ports
517  // ----------------------------------------------------------------------
518 
521  FwIndexType portNum,
522  U32 key
523  );
524 
526  void Run_handlerBase(
527  FwIndexType portNum,
528  U32 context
529  );
530 
531  protected:
532 
533  // ----------------------------------------------------------------------
534  // Pre-message hooks for typed async input ports
535  //
536  // Each of these functions is invoked just before processing a message
537  // on the corresponding port. By default, they do nothing. You can
538  // override them to provide specific pre-message behavior.
539  // ----------------------------------------------------------------------
540 
542  virtual void PingReturn_preMsgHook(
543  FwIndexType portNum,
544  U32 key
545  );
546 
547  protected:
548 
549  // ----------------------------------------------------------------------
550  // Invocation functions for typed output ports
551  // ----------------------------------------------------------------------
552 
554  void PingSend_out(
555  FwIndexType portNum,
556  U32 key
557  );
558 
560  void WdogStroke_out(
561  FwIndexType portNum,
562  U32 code
563  );
564 
565  protected:
566 
567  // ----------------------------------------------------------------------
568  // Command response
569  // ----------------------------------------------------------------------
570 
572  void cmdResponse_out(
573  FwOpcodeType opCode,
574  U32 cmdSeq,
575  Fw::CmdResponse response
576  );
577 
578  protected:
579 
580  // ----------------------------------------------------------------------
581  // Command handlers to implement
582  // ----------------------------------------------------------------------
583 
587  virtual void HLTH_ENABLE_cmdHandler(
588  FwOpcodeType opCode,
589  U32 cmdSeq,
590  Fw::Enabled enable
591  ) = 0;
592 
596  virtual void HLTH_PING_ENABLE_cmdHandler(
597  FwOpcodeType opCode,
598  U32 cmdSeq,
599  const Fw::CmdStringArg& entry,
600  Fw::Enabled enable
601  ) = 0;
602 
606  virtual void HLTH_CHNG_PING_cmdHandler(
607  FwOpcodeType opCode,
608  U32 cmdSeq,
609  const Fw::CmdStringArg& entry,
610  U32 warningValue,
611  U32 fatalValue
612  ) = 0;
613 
614  protected:
615 
616  // ----------------------------------------------------------------------
617  // Command handler base-class functions
618  //
619  // Call these functions directly to bypass the command input port
620  // ----------------------------------------------------------------------
621 
626  FwOpcodeType opCode,
627  U32 cmdSeq,
628  Fw::CmdArgBuffer& args
629  );
630 
635  FwOpcodeType opCode,
636  U32 cmdSeq,
637  Fw::CmdArgBuffer& args
638  );
639 
644  FwOpcodeType opCode,
645  U32 cmdSeq,
646  Fw::CmdArgBuffer& args
647  );
648 
649  protected:
650 
651  // ----------------------------------------------------------------------
652  // Pre-message hooks for async commands
653  //
654  // Each of these functions is invoked just before processing the
655  // corresponding command. By default they do nothing. You can
656  // override them to provide specific pre-command behavior.
657  // ----------------------------------------------------------------------
658 
660  virtual void HLTH_ENABLE_preMsgHook(
661  FwOpcodeType opCode,
662  U32 cmdSeq
663  );
664 
666  virtual void HLTH_PING_ENABLE_preMsgHook(
667  FwOpcodeType opCode,
668  U32 cmdSeq
669  );
670 
672  virtual void HLTH_CHNG_PING_preMsgHook(
673  FwOpcodeType opCode,
674  U32 cmdSeq
675  );
676 
677  protected:
678 
679  // ----------------------------------------------------------------------
680  // Event logging functions
681  // ----------------------------------------------------------------------
682 
687  const Fw::StringBase& entry
688  ) const;
689 
694  const Fw::StringBase& entry
695  ) const;
696 
701  const Fw::StringBase& entry,
702  U32 badKey
703  ) const;
704 
709  Fw::Enabled enabled
710  ) const;
711 
716  Fw::Enabled enabled,
717  const Fw::StringBase& entry
718  ) const;
719 
724  const Fw::StringBase& entry
725  ) const;
726 
731  const Fw::StringBase& entry,
732  U32 warn,
733  U32 fatal
734  ) const;
735 
740  const Fw::StringBase& entry,
741  U32 warn,
742  U32 fatal
743  ) const;
744 
745  protected:
746 
747  // ----------------------------------------------------------------------
748  // Telemetry write functions
749  // ----------------------------------------------------------------------
750 
755  U32 arg,
756  Fw::Time _tlmTime = Fw::Time()
757  ) const;
758 
759  protected:
760 
761  // ----------------------------------------------------------------------
762  // Time
763  // ----------------------------------------------------------------------
764 
768  Fw::Time getTime() const;
769 
770  protected:
771 
772  // ----------------------------------------------------------------------
773  // Message dispatch functions
774  // ----------------------------------------------------------------------
775 
777  virtual MsgDispatchStatus doDispatch();
778 
779  protected:
780 
781  // ----------------------------------------------------------------------
782  // Helper functions for dispatching current messages
783  // ----------------------------------------------------------------------
784 
787 
788  private:
789 
790  // ----------------------------------------------------------------------
791  // Calls for messages received on special input ports
792  // ----------------------------------------------------------------------
793 
795  static void m_p_CmdDisp_in(
796  Fw::PassiveComponentBase* callComp,
797  FwIndexType portNum,
798  FwOpcodeType opCode,
799  U32 cmdSeq,
800  Fw::CmdArgBuffer& args
801  );
802 
803  private:
804 
805  // ----------------------------------------------------------------------
806  // Calls for messages received on typed input ports
807  // ----------------------------------------------------------------------
808 
810  static void m_p_PingReturn_in(
811  Fw::PassiveComponentBase* callComp,
812  FwIndexType portNum,
813  U32 key
814  );
815 
817  static void m_p_Run_in(
818  Fw::PassiveComponentBase* callComp,
819  FwIndexType portNum,
820  U32 context
821  );
822 
823  private:
824 
825  // ----------------------------------------------------------------------
826  // Special input ports
827  // ----------------------------------------------------------------------
828 
830  Fw::InputCmdPort m_CmdDisp_InputPort[NUM_CMDDISP_INPUT_PORTS];
831 
832  private:
833 
834  // ----------------------------------------------------------------------
835  // Typed input ports
836  // ----------------------------------------------------------------------
837 
839  Svc::InputPingPort m_PingReturn_InputPort[NUM_PINGRETURN_INPUT_PORTS];
840 
842  Svc::InputSchedPort m_Run_InputPort[NUM_RUN_INPUT_PORTS];
843 
844  private:
845 
846  // ----------------------------------------------------------------------
847  // Special output ports
848  // ----------------------------------------------------------------------
849 
851  Fw::OutputCmdRegPort m_CmdReg_OutputPort[NUM_CMDREG_OUTPUT_PORTS];
852 
855 
857  Fw::OutputLogPort m_Log_OutputPort[NUM_LOG_OUTPUT_PORTS];
858 
859 #if FW_ENABLE_TEXT_LOGGING == 1
860 
862  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
863 
864 #endif
865 
867  Fw::OutputTimePort m_Time_OutputPort[NUM_TIME_OUTPUT_PORTS];
868 
870  Fw::OutputTlmPort m_Tlm_OutputPort[NUM_TLM_OUTPUT_PORTS];
871 
872  private:
873 
874  // ----------------------------------------------------------------------
875  // Typed output ports
876  // ----------------------------------------------------------------------
877 
879  Svc::OutputPingPort m_PingSend_OutputPort[NUM_PINGSEND_OUTPUT_PORTS];
880 
882  Svc::OutputWatchDogPort m_WdogStroke_OutputPort[NUM_WDOGSTROKE_OUTPUT_PORTS];
883 
884  };
885 
886 }
887 
888 #endif
virtual void HLTH_CHNG_PING_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdStringArg &entry, U32 warningValue, U32 fatalValue)=0
void regCommands()
Register commands with the Command Dispatcher.
Auto-generated base for Health component.
virtual void Run_handler(FwIndexType portNum, U32 context)=0
Handler for input port Run.
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
virtual ~HealthComponentBase()
Destroy HealthComponentBase object.
FwIdType FwOpcodeType
The type of a command opcode.
void tlmWrite_PingLateWarnings(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
void log_FATAL_HLTH_PING_WRONG_KEY(const Fw::StringBase &entry, U32 badKey) const
PlatformSizeType FwSizeType
void set_CmdStatus_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to CmdStatus[portNum].
I32 FwEnumStoreType
virtual MsgDispatchStatus doDispatch()
Called in the message loop to dispatch a message from the queue.
virtual void PingReturn_preMsgHook(FwIndexType portNum, U32 key)
Pre-message hook for async input port PingReturn.
void log_WARNING_LO_HLTH_CHECK_LOOKUP_ERROR(const Fw::StringBase &entry) const
Declare FATAL since task is no longer responding.
static constexpr FwIndexType getNum_Tlm_OutputPorts()
void log_WARNING_HI_HLTH_PING_INVALID_VALUES(const Fw::StringBase &entry, U32 warn, U32 fatal) const
bool isConnected_Log_OutputPort(FwIndexType portNum)
bool isConnected_CmdReg_OutputPort(FwIndexType portNum)
Enum representing a command response.
bool isConnected_CmdStatus_OutputPort(FwIndexType portNum)
void set_WdogStroke_OutputPort(FwIndexType portNum, Svc::InputWatchDogPort *port)
Connect port to WdogStroke[portNum].
static constexpr FwIndexType getNum_CmdStatus_OutputPorts()
Report a particular entry on or off.
A command to enable or disable health checks.
virtual void HLTH_ENABLE_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command HLTH_ENABLE.
void set_CmdReg_OutputPort(FwIndexType portNum, Fw::InputCmdRegPort *port)
Connect port to CmdReg[portNum].
void init()
Object initializer.
Definition: ObjBase.cpp:24
static constexpr FwIndexType getNum_Log_OutputPorts()
Svc::InputPingPort * get_PingReturn_InputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_Run_InputPorts()
static constexpr FwIndexType getNum_PingSend_OutputPorts()
void PingReturn_handlerBase(FwIndexType portNum, U32 key)
Handler base-class function for input port PingReturn.
static constexpr FwIndexType getNum_CmdDisp_InputPorts()
void log_ACTIVITY_HI_HLTH_CHECK_PING(Fw::Enabled enabled, const Fw::StringBase &entry) const
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
friend class HealthTester
Friend class tester implementation to support white-box testing.
bool isConnected_Time_OutputPort(FwIndexType portNum)
void WdogStroke_out(FwIndexType portNum, U32 code)
Invoke output port WdogStroke.
void HLTH_PING_ENABLE_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
Declare FATAL since task is no longer responding.
virtual void HLTH_ENABLE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Fw::Enabled enable)=0
void set_PingSend_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to PingSend[portNum].
Enabled and disabled states.
bool isConnected_WdogStroke_OutputPort(FwIndexType portNum)
bool isConnected_PingSend_OutputPort(FwIndexType portNum)
Warn that a ping target is longer than the warning value.
static constexpr FwIndexType getNum_WdogStroke_OutputPorts()
void log_FATAL_HLTH_PING_LATE(const Fw::StringBase &entry) const
Fw::InputCmdPort * get_CmdDisp_InputPort(FwIndexType portNum)
bool isConnected_Tlm_OutputPort(FwIndexType portNum)
HealthComponentBase(const char *compName="")
Construct HealthComponentBase object.
virtual void HLTH_PING_ENABLE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdStringArg &entry, Fw::Enabled enable)=0
virtual void HLTH_CHNG_PING_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command HLTH_CHNG_PING.
static constexpr FwIndexType getNum_CmdReg_OutputPorts()
PlatformIndexType FwIndexType
virtual void PingReturn_handler(FwIndexType portNum, U32 key)=0
Handler for input port PingReturn.
void set_Tlm_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to Tlm[portNum].
RateGroupDivider component implementation.
Svc::InputSchedPort * get_Run_InputPort(FwIndexType portNum)
void set_Log_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to Log[portNum].
static constexpr FwIndexType getNum_PingReturn_InputPorts()
MsgDispatchStatus dispatchCurrentMessages()
Dispatch all current messages unless ERROR or EXIT occurs.
void log_ACTIVITY_HI_HLTH_CHECK_ENABLE(Fw::Enabled enabled) const
void HLTH_CHNG_PING_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
void log_WARNING_HI_HLTH_PING_WARN(const Fw::StringBase &entry) const
void HLTH_ENABLE_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
virtual void HLTH_PING_ENABLE_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command HLTH_PING_ENABLE.
friend class HealthTesterBase
Friend class tester to support autocoded test harness.
static constexpr FwIndexType getNum_Time_OutputPorts()
void Run_handlerBase(FwIndexType portNum, U32 context)
Handler base-class function for input port Run.
void PingSend_out(FwIndexType portNum, U32 key)
Invoke output port PingSend.
void log_ACTIVITY_HI_HLTH_PING_UPDATED(const Fw::StringBase &entry, U32 warn, U32 fatal) const