F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
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
15namespace Svc {
16
17 namespace {
18 // Get the max size by doing a union of the input and internal port serialization sizes
19 union BuffUnion {
21 };
22
23 // Define a message buffer class large enough to handle all the
24 // asynchronous inputs to the component
25 class ComponentIpcSerializableBuffer :
27 {
28
29 public:
30
31 enum {
32 // Max. message size = size of data + message id + port
33 SERIALIZATION_SIZE =
34 sizeof(BuffUnion) +
35 sizeof(NATIVE_INT_TYPE) +
36 sizeof(NATIVE_INT_TYPE)
37 };
38
39 NATIVE_UINT_TYPE getBuffCapacity() const {
40 return sizeof(m_buff);
41 }
42
43 U8* getBuffAddr() {
44 return m_buff;
45 }
46
47 const U8* getBuffAddr() const {
48 return m_buff;
49 }
50
51 private:
52 // Should be the max of all the input ports serialized sizes...
53 U8 m_buff[SERIALIZATION_SIZE];
54
55 };
56 }
57
58 // ----------------------------------------------------------------------
59 // Component initialization
60 // ----------------------------------------------------------------------
61
62 void FatalHandlerComponentBase ::
63 init(NATIVE_INT_TYPE instance)
64 {
65 // Initialize base class
67
68 // Connect input port FatalReceive
69 for (
70 PlatformIntType port = 0;
71 port < static_cast<PlatformIntType>(this->getNum_FatalReceive_InputPorts());
72 port++
73 ) {
74 this->m_FatalReceive_InputPort[port].init();
75 this->m_FatalReceive_InputPort[port].addCallComp(
76 this,
77 m_p_FatalReceive_in
78 );
79 this->m_FatalReceive_InputPort[port].setPortNum(port);
80
81#if FW_OBJECT_NAMES == 1
82 char portName[120];
83 (void) snprintf(
84 portName,
85 sizeof(portName),
86 "%s_FatalReceive_InputPort[%" PRI_PlatformIntType "]",
87 this->m_objName,
88 port
89 );
90 this->m_FatalReceive_InputPort[port].setObjName(portName);
91#endif
92 }
93 }
94
95 // ----------------------------------------------------------------------
96 // Getters for typed input ports
97 // ----------------------------------------------------------------------
98
99 Svc::InputFatalEventPort* FatalHandlerComponentBase ::
100 get_FatalReceive_InputPort(NATIVE_INT_TYPE portNum)
101 {
102 FW_ASSERT(
103 portNum < this->getNum_FatalReceive_InputPorts(),
104 static_cast<FwAssertArgType>(portNum)
105 );
106
107 return &this->m_FatalReceive_InputPort[portNum];
108 }
109
110 // ----------------------------------------------------------------------
111 // Component construction and destruction
112 // ----------------------------------------------------------------------
113
114 FatalHandlerComponentBase ::
115 FatalHandlerComponentBase(const char* compName) :
116 Fw::PassiveComponentBase(compName)
117 {
118
119 }
120
121 FatalHandlerComponentBase ::
122 ~FatalHandlerComponentBase()
123 {
124
125 }
126
127 // ----------------------------------------------------------------------
128 // Getters for numbers of typed input ports
129 // ----------------------------------------------------------------------
130
131 NATIVE_INT_TYPE FatalHandlerComponentBase ::
132 getNum_FatalReceive_InputPorts()
133 {
134 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_FatalReceive_InputPort));
135 }
136
137 // ----------------------------------------------------------------------
138 // Port handler base-class functions for typed input ports
139 //
140 // Call these functions directly to bypass the corresponding ports
141 // ----------------------------------------------------------------------
142
143 void FatalHandlerComponentBase ::
144 FatalReceive_handlerBase(
145 NATIVE_INT_TYPE portNum,
147 )
148 {
149 // Make sure port number is valid
150 FW_ASSERT(
151 portNum < this->getNum_FatalReceive_InputPorts(),
152 static_cast<FwAssertArgType>(portNum)
153 );
154
155 // Down call to pure virtual handler method implemented in Impl class
156 this->FatalReceive_handler(
157 portNum,
158 Id
159 );
160 }
161
162 // ----------------------------------------------------------------------
163 // Calls for messages received on typed input ports
164 // ----------------------------------------------------------------------
165
166 void FatalHandlerComponentBase ::
167 m_p_FatalReceive_in(
168 Fw::PassiveComponentBase* callComp,
169 NATIVE_INT_TYPE portNum,
171 )
172 {
173 FW_ASSERT(callComp);
174 FatalHandlerComponentBase* compPtr = static_cast<FatalHandlerComponentBase*>(callComp);
176 portNum,
177 Id
178 );
179 }
180
181}
#define FW_ASSERT(...)
Definition Assert.hpp:7
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
PlatformAssertArgType FwAssertArgType
Definition FpConfig.h:21
U32 FwEventIdType
Definition FpConfig.h:62
void init()
Object initializer.
Definition ObjBase.cpp:27
Auto-generated base for FatalHandler component.
void FatalReceive_handlerBase(NATIVE_INT_TYPE portNum, FwEventIdType Id)
Handler base-class function for input port FatalReceive.
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.