F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
FatalHandlerComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title FatalHandlerComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for FatalHandler 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  // ----------------------------------------------------------------------
18  // Component initialization
19  // ----------------------------------------------------------------------
20 
22  init(NATIVE_INT_TYPE instance)
23  {
24  // Initialize base class
26 
27  // Connect input port FatalReceive
28  for (
29  PlatformIntType port = 0;
30  port < static_cast<PlatformIntType>(this->getNum_FatalReceive_InputPorts());
31  port++
32  ) {
33  this->m_FatalReceive_InputPort[port].init();
34  this->m_FatalReceive_InputPort[port].addCallComp(
35  this,
36  m_p_FatalReceive_in
37  );
38  this->m_FatalReceive_InputPort[port].setPortNum(port);
39 
40 #if FW_OBJECT_NAMES == 1
41  // The port name consists of this->m_objName and some extra info.
42  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
43  // However, the compiler may assume that this->m_objName fills
44  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
45  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
46  // bytes to cover the extra info.
47  char portName[2*FW_OBJ_NAME_MAX_SIZE];
48  (void) snprintf(
49  portName,
50  sizeof(portName),
51  "%s_FatalReceive_InputPort[%" PRI_PlatformIntType "]",
52  this->m_objName,
53  port
54  );
55  this->m_FatalReceive_InputPort[port].setObjName(portName);
56 #endif
57  }
58  }
59 
60  // ----------------------------------------------------------------------
61  // Getters for typed input ports
62  // ----------------------------------------------------------------------
63 
66  {
67  FW_ASSERT(
68  portNum < this->getNum_FatalReceive_InputPorts(),
69  static_cast<FwAssertArgType>(portNum)
70  );
71 
72  return &this->m_FatalReceive_InputPort[portNum];
73  }
74 
75  // ----------------------------------------------------------------------
76  // Component construction and destruction
77  // ----------------------------------------------------------------------
78 
80  FatalHandlerComponentBase(const char* compName) :
81  Fw::PassiveComponentBase(compName)
82  {
83 
84  }
85 
88  {
89 
90  }
91 
92  // ----------------------------------------------------------------------
93  // Getters for numbers of typed input ports
94  // ----------------------------------------------------------------------
95 
98  {
99  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_FatalReceive_InputPort));
100  }
101 
102  // ----------------------------------------------------------------------
103  // Port handler base-class functions for typed input ports
104  //
105  // Call these functions directly to bypass the corresponding ports
106  // ----------------------------------------------------------------------
107 
110  NATIVE_INT_TYPE portNum,
111  FwEventIdType Id
112  )
113  {
114  // Make sure port number is valid
115  FW_ASSERT(
116  portNum < this->getNum_FatalReceive_InputPorts(),
117  static_cast<FwAssertArgType>(portNum)
118  );
119 
120  // Call handler function
121  this->FatalReceive_handler(
122  portNum,
123  Id
124  );
125  }
126 
127  // ----------------------------------------------------------------------
128  // Calls for messages received on typed input ports
129  // ----------------------------------------------------------------------
130 
131  void FatalHandlerComponentBase ::
132  m_p_FatalReceive_in(
133  Fw::PassiveComponentBase* callComp,
134  NATIVE_INT_TYPE portNum,
135  FwEventIdType Id
136  )
137  {
138  FW_ASSERT(callComp);
139  FatalHandlerComponentBase* compPtr = static_cast<FatalHandlerComponentBase*>(callComp);
140  compPtr->FatalReceive_handlerBase(
141  portNum,
142  Id
143  );
144  }
145 
146 }
#define FW_ASSERT(...)
Definition: Assert.hpp:14
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:51
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:66
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
#define PRI_PlatformIntType
PlatformAssertArgType FwAssertArgType
Definition: FpConfig.h:21
U32 FwEventIdType
Definition: FpConfig.h:62
#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
void setPortNum(NATIVE_INT_TYPE portNum)
void init()
Object initializer.
Definition: ObjBase.cpp:27
Auto-generated base for FatalHandler component.
virtual void FatalReceive_handler(NATIVE_INT_TYPE portNum, FwEventIdType Id)=0
Handler for input port FatalReceive.
NATIVE_INT_TYPE getNum_FatalReceive_InputPorts() const
Svc::InputFatalEventPort * get_FatalReceive_InputPort(NATIVE_INT_TYPE portNum)
FatalHandlerComponentBase(const char *compName="")
Construct FatalHandlerComponentBase object.
virtual ~FatalHandlerComponentBase()
Destroy FatalHandlerComponentBase object.
void FatalReceive_handlerBase(NATIVE_INT_TYPE portNum, FwEventIdType Id)
Handler base-class function for input port FatalReceive.
void init()
Initialization function.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.