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"
32 
33 namespace Svc {
34 
41  {
42 
43  // ----------------------------------------------------------------------
44  // Friend classes
45  // ----------------------------------------------------------------------
46 
48  friend class HealthTesterBase;
50  friend class HealthTester;
51 
52  protected:
53 
54  // ----------------------------------------------------------------------
55  // Constants
56  // ----------------------------------------------------------------------
57 
59  enum {
61  };
62 
64  enum {
67  };
68 
70  enum {
77  };
78 
80  enum {
83  };
84 
86  enum {
90  };
91 
93  enum {
102  };
103 
105  enum {
107  };
108 
109  public:
110 
111  // ----------------------------------------------------------------------
112  // Component initialization
113  // ----------------------------------------------------------------------
114 
116  void init(
117  FwSizeType queueDepth,
118  FwEnumStoreType instance = 0
119  );
120 
121  public:
122 
123  // ----------------------------------------------------------------------
124  // Getters for special input ports
125  // ----------------------------------------------------------------------
126 
131  FwIndexType portNum
132  );
133 
134  public:
135 
136  // ----------------------------------------------------------------------
137  // Getters for typed input ports
138  // ----------------------------------------------------------------------
139 
144  FwIndexType portNum
145  );
146 
151  FwIndexType portNum
152  );
153 
154  public:
155 
156  // ----------------------------------------------------------------------
157  // Connect input ports to special output ports
158  // ----------------------------------------------------------------------
159 
162  FwIndexType portNum,
163  Fw::InputCmdRegPort* port
164  );
165 
168  FwIndexType portNum,
170  );
171 
173  void set_Log_OutputPort(
174  FwIndexType portNum,
175  Fw::InputLogPort* port
176  );
177 
178 #if FW_ENABLE_TEXT_LOGGING == 1
179 
181  void set_LogText_OutputPort(
182  FwIndexType portNum,
183  Fw::InputLogTextPort* port
184  );
185 
186 #endif
187 
189  void set_Time_OutputPort(
190  FwIndexType portNum,
191  Fw::InputTimePort* port
192  );
193 
195  void set_Tlm_OutputPort(
196  FwIndexType portNum,
197  Fw::InputTlmPort* port
198  );
199 
200  public:
201 
202  // ----------------------------------------------------------------------
203  // Connect typed input ports to typed output ports
204  // ----------------------------------------------------------------------
205 
208  FwIndexType portNum,
209  Svc::InputPingPort* port
210  );
211 
214  FwIndexType portNum,
216  );
217 
218 #if FW_PORT_SERIALIZATION
219 
220  public:
221 
222  // ----------------------------------------------------------------------
223  // Connect serial input ports to special output ports
224  // ----------------------------------------------------------------------
225 
228  FwIndexType portNum,
229  Fw::InputSerializePort* port
230  );
231 
234  FwIndexType portNum,
235  Fw::InputSerializePort* port
236  );
237 
239  void set_Log_OutputPort(
240  FwIndexType portNum,
241  Fw::InputSerializePort* port
242  );
243 
244 #if FW_ENABLE_TEXT_LOGGING == 1
245 
247  void set_LogText_OutputPort(
248  FwIndexType portNum,
249  Fw::InputSerializePort* port
250  );
251 
252 #endif
253 
255  void set_Time_OutputPort(
256  FwIndexType portNum,
257  Fw::InputSerializePort* port
258  );
259 
261  void set_Tlm_OutputPort(
262  FwIndexType portNum,
263  Fw::InputSerializePort* port
264  );
265 
266 #endif
267 
268 #if FW_PORT_SERIALIZATION
269 
270  public:
271 
272  // ----------------------------------------------------------------------
273  // Connect serial input ports to typed output ports
274  // ----------------------------------------------------------------------
275 
278  FwIndexType portNum,
279  Fw::InputSerializePort* port
280  );
281 
284  FwIndexType portNum,
285  Fw::InputSerializePort* port
286  );
287 
288 #endif
289 
290  public:
291 
292  // ----------------------------------------------------------------------
293  // Command registration
294  // ----------------------------------------------------------------------
295 
299  void regCommands();
300 
301  protected:
302 
303  // ----------------------------------------------------------------------
304  // Component construction and destruction
305  // ----------------------------------------------------------------------
306 
309  const char* compName = ""
310  );
311 
313  virtual ~HealthComponentBase();
314 
315  protected:
316 
317  // ----------------------------------------------------------------------
318  // Getters for numbers of special input ports
319  // ----------------------------------------------------------------------
320 
326  }
327 
328  protected:
329 
330  // ----------------------------------------------------------------------
331  // Getters for numbers of typed input ports
332  // ----------------------------------------------------------------------
333 
339  }
340 
344  static constexpr FwIndexType getNum_Run_InputPorts() {
345  return NUM_RUN_INPUT_PORTS;
346  }
347 
348  protected:
349 
350  // ----------------------------------------------------------------------
351  // Getters for numbers of special output ports
352  // ----------------------------------------------------------------------
353 
359  }
360 
366  }
367 
371  static constexpr FwIndexType getNum_Log_OutputPorts() {
372  return NUM_LOG_OUTPUT_PORTS;
373  }
374 
375 #if FW_ENABLE_TEXT_LOGGING == 1
376 
380  static constexpr FwIndexType getNum_LogText_OutputPorts() {
382  }
383 
384 #endif
385 
390  return NUM_TIME_OUTPUT_PORTS;
391  }
392 
396  static constexpr FwIndexType getNum_Tlm_OutputPorts() {
397  return NUM_TLM_OUTPUT_PORTS;
398  }
399 
400  protected:
401 
402  // ----------------------------------------------------------------------
403  // Getters for numbers of typed output ports
404  // ----------------------------------------------------------------------
405 
411  }
412 
418  }
419 
420  protected:
421 
422  // ----------------------------------------------------------------------
423  // Connection status queries for special output ports
424  // ----------------------------------------------------------------------
425 
430  FwIndexType portNum
431  );
432 
437  FwIndexType portNum
438  );
439 
444  FwIndexType portNum
445  );
446 
447 #if FW_ENABLE_TEXT_LOGGING == 1
448 
452  bool isConnected_LogText_OutputPort(
453  FwIndexType portNum
454  );
455 
456 #endif
457 
462  FwIndexType portNum
463  );
464 
469  FwIndexType portNum
470  );
471 
472  protected:
473 
474  // ----------------------------------------------------------------------
475  // Connection status queries for typed output ports
476  // ----------------------------------------------------------------------
477 
482  FwIndexType portNum
483  );
484 
489  FwIndexType portNum
490  );
491 
492  protected:
493 
494  // ----------------------------------------------------------------------
495  // Handlers to implement for typed input ports
496  // ----------------------------------------------------------------------
497 
499  virtual void PingReturn_handler(
500  FwIndexType portNum,
501  U32 key
502  ) = 0;
503 
505  virtual void Run_handler(
506  FwIndexType portNum,
507  U32 context
508  ) = 0;
509 
510  protected:
511 
512  // ----------------------------------------------------------------------
513  // Port handler base-class functions for typed input ports
514  //
515  // Call these functions directly to bypass the corresponding ports
516  // ----------------------------------------------------------------------
517 
520  FwIndexType portNum,
521  U32 key
522  );
523 
525  void Run_handlerBase(
526  FwIndexType portNum,
527  U32 context
528  );
529 
530  protected:
531 
532  // ----------------------------------------------------------------------
533  // Pre-message hooks for typed async input ports
534  //
535  // Each of these functions is invoked just before processing a message
536  // on the corresponding port. By default, they do nothing. You can
537  // override them to provide specific pre-message behavior.
538  // ----------------------------------------------------------------------
539 
541  virtual void PingReturn_preMsgHook(
542  FwIndexType portNum,
543  U32 key
544  );
545 
546  protected:
547 
548  // ----------------------------------------------------------------------
549  // Invocation functions for typed output ports
550  // ----------------------------------------------------------------------
551 
553  void PingSend_out(
554  FwIndexType portNum,
555  U32 key
556  );
557 
559  void WdogStroke_out(
560  FwIndexType portNum,
561  U32 code
562  );
563 
564  protected:
565 
566  // ----------------------------------------------------------------------
567  // Command response
568  // ----------------------------------------------------------------------
569 
571  void cmdResponse_out(
572  FwOpcodeType opCode,
573  U32 cmdSeq,
574  Fw::CmdResponse response
575  );
576 
577  protected:
578 
579  // ----------------------------------------------------------------------
580  // Command handlers to implement
581  // ----------------------------------------------------------------------
582 
586  virtual void HLTH_ENABLE_cmdHandler(
587  FwOpcodeType opCode,
588  U32 cmdSeq,
589  Fw::Enabled enable
590  ) = 0;
591 
595  virtual void HLTH_PING_ENABLE_cmdHandler(
596  FwOpcodeType opCode,
597  U32 cmdSeq,
598  const Fw::CmdStringArg& entry,
599  Fw::Enabled enable
600  ) = 0;
601 
605  virtual void HLTH_CHNG_PING_cmdHandler(
606  FwOpcodeType opCode,
607  U32 cmdSeq,
608  const Fw::CmdStringArg& entry,
609  U32 warningValue,
610  U32 fatalValue
611  ) = 0;
612 
613  protected:
614 
615  // ----------------------------------------------------------------------
616  // Command handler base-class functions
617  //
618  // Call these functions directly to bypass the command input port
619  // ----------------------------------------------------------------------
620 
625  FwOpcodeType opCode,
626  U32 cmdSeq,
627  Fw::CmdArgBuffer& args
628  );
629 
634  FwOpcodeType opCode,
635  U32 cmdSeq,
636  Fw::CmdArgBuffer& args
637  );
638 
643  FwOpcodeType opCode,
644  U32 cmdSeq,
645  Fw::CmdArgBuffer& args
646  );
647 
648  protected:
649 
650  // ----------------------------------------------------------------------
651  // Pre-message hooks for async commands
652  //
653  // Each of these functions is invoked just before processing the
654  // corresponding command. By default they do nothing. You can
655  // override them to provide specific pre-command behavior.
656  // ----------------------------------------------------------------------
657 
659  virtual void HLTH_ENABLE_preMsgHook(
660  FwOpcodeType opCode,
661  U32 cmdSeq
662  );
663 
665  virtual void HLTH_PING_ENABLE_preMsgHook(
666  FwOpcodeType opCode,
667  U32 cmdSeq
668  );
669 
671  virtual void HLTH_CHNG_PING_preMsgHook(
672  FwOpcodeType opCode,
673  U32 cmdSeq
674  );
675 
676  protected:
677 
678  // ----------------------------------------------------------------------
679  // Event logging functions
680  // ----------------------------------------------------------------------
681 
686  const Fw::StringBase& entry
687  ) const;
688 
693  const Fw::StringBase& entry
694  ) const;
695 
700  const Fw::StringBase& entry,
701  U32 badKey
702  ) const;
703 
708  Fw::Enabled enabled
709  ) const;
710 
715  Fw::Enabled enabled,
716  const Fw::StringBase& entry
717  ) const;
718 
723  const Fw::StringBase& entry
724  ) const;
725 
730  const Fw::StringBase& entry,
731  U32 warn,
732  U32 fatal
733  ) const;
734 
739  const Fw::StringBase& entry,
740  U32 warn,
741  U32 fatal
742  ) const;
743 
744  protected:
745 
746  // ----------------------------------------------------------------------
747  // Telemetry write functions
748  // ----------------------------------------------------------------------
749 
754  U32 arg,
755  Fw::Time _tlmTime = Fw::Time()
756  ) const;
757 
758  protected:
759 
760  // ----------------------------------------------------------------------
761  // Time
762  // ----------------------------------------------------------------------
763 
767  Fw::Time getTime() const;
768 
769  protected:
770 
771  // ----------------------------------------------------------------------
772  // Message dispatch functions
773  // ----------------------------------------------------------------------
774 
776  virtual MsgDispatchStatus doDispatch();
777 
778  protected:
779 
780  // ----------------------------------------------------------------------
781  // Helper functions for dispatching current messages
782  // ----------------------------------------------------------------------
783 
786 
787  private:
788 
789  // ----------------------------------------------------------------------
790  // Calls for messages received on special input ports
791  // ----------------------------------------------------------------------
792 
794  static void m_p_CmdDisp_in(
795  Fw::PassiveComponentBase* callComp,
796  FwIndexType portNum,
797  FwOpcodeType opCode,
798  U32 cmdSeq,
799  Fw::CmdArgBuffer& args
800  );
801 
802  private:
803 
804  // ----------------------------------------------------------------------
805  // Calls for messages received on typed input ports
806  // ----------------------------------------------------------------------
807 
809  static void m_p_PingReturn_in(
810  Fw::PassiveComponentBase* callComp,
811  FwIndexType portNum,
812  U32 key
813  );
814 
816  static void m_p_Run_in(
817  Fw::PassiveComponentBase* callComp,
818  FwIndexType portNum,
819  U32 context
820  );
821 
822  private:
823 
824  // ----------------------------------------------------------------------
825  // Special input ports
826  // ----------------------------------------------------------------------
827 
829  Fw::InputCmdPort m_CmdDisp_InputPort[NUM_CMDDISP_INPUT_PORTS];
830 
831  private:
832 
833  // ----------------------------------------------------------------------
834  // Typed input ports
835  // ----------------------------------------------------------------------
836 
838  Svc::InputPingPort m_PingReturn_InputPort[NUM_PINGRETURN_INPUT_PORTS];
839 
841  Svc::InputSchedPort m_Run_InputPort[NUM_RUN_INPUT_PORTS];
842 
843  private:
844 
845  // ----------------------------------------------------------------------
846  // Special output ports
847  // ----------------------------------------------------------------------
848 
850  Fw::OutputCmdRegPort m_CmdReg_OutputPort[NUM_CMDREG_OUTPUT_PORTS];
851 
854 
856  Fw::OutputLogPort m_Log_OutputPort[NUM_LOG_OUTPUT_PORTS];
857 
858 #if FW_ENABLE_TEXT_LOGGING == 1
859 
861  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
862 
863 #endif
864 
866  Fw::OutputTimePort m_Time_OutputPort[NUM_TIME_OUTPUT_PORTS];
867 
869  Fw::OutputTlmPort m_Tlm_OutputPort[NUM_TLM_OUTPUT_PORTS];
870 
871  private:
872 
873  // ----------------------------------------------------------------------
874  // Typed output ports
875  // ----------------------------------------------------------------------
876 
878  Svc::OutputPingPort m_PingSend_OutputPort[NUM_PINGSEND_OUTPUT_PORTS];
879 
881  Svc::OutputWatchDogPort m_WdogStroke_OutputPort[NUM_WDOGSTROKE_OUTPUT_PORTS];
882 
883  };
884 
885 }
886 
887 #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.
Warn that a ping target is longer than the warning value.
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)
Report a particular entry on or off.
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()
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)
A command to enable or disable health checks.
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)
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)
Declare FATAL since task is no longer responding.
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