F´ Flight Software - C/C++ Documentation devel
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
ComSplitterComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title ComSplitterComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for ComSplitter 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 // ----------------------------------------------------------------------
18 // Component initialization
19 // ----------------------------------------------------------------------
20
21 void ComSplitterComponentBase ::
22 init(NATIVE_INT_TYPE instance)
23 {
24 // Initialize base class
26
27 // Connect input port comIn
28 for (
29 PlatformIntType port = 0;
30 port < static_cast<PlatformIntType>(this->getNum_comIn_InputPorts());
31 port++
32 ) {
33 this->m_comIn_InputPort[port].init();
34 this->m_comIn_InputPort[port].addCallComp(
35 this,
36 m_p_comIn_in
37 );
38 this->m_comIn_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_comIn_InputPort[%" PRI_PlatformIntType "]",
52 this->m_objName,
53 port
54 );
55 this->m_comIn_InputPort[port].setObjName(portName);
56#endif
57 }
58
59 // Connect output port comOut
60 for (
61 PlatformIntType port = 0;
62 port < static_cast<PlatformIntType>(this->getNum_comOut_OutputPorts());
63 port++
64 ) {
65 this->m_comOut_OutputPort[port].init();
66
67#if FW_OBJECT_NAMES == 1
68 // The port name consists of this->m_objName and some extra info.
69 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
70 // However, the compiler may assume that this->m_objName fills
71 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
72 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
73 // bytes to cover the extra info.
74 char portName[2*FW_OBJ_NAME_MAX_SIZE];
75 (void) snprintf(
76 portName,
77 sizeof(portName),
78 "%s_comOut_OutputPort[%" PRI_PlatformIntType "]",
79 this->m_objName,
80 port
81 );
82 this->m_comOut_OutputPort[port].setObjName(portName);
83#endif
84 }
85 }
86
87 // ----------------------------------------------------------------------
88 // Getters for typed input ports
89 // ----------------------------------------------------------------------
90
91 Fw::InputComPort* ComSplitterComponentBase ::
92 get_comIn_InputPort(NATIVE_INT_TYPE portNum)
93 {
95 portNum < this->getNum_comIn_InputPorts(),
96 static_cast<FwAssertArgType>(portNum)
97 );
98
99 return &this->m_comIn_InputPort[portNum];
100 }
101
102 // ----------------------------------------------------------------------
103 // Connect typed input ports to typed output ports
104 // ----------------------------------------------------------------------
105
106 void ComSplitterComponentBase ::
107 set_comOut_OutputPort(
108 NATIVE_INT_TYPE portNum,
109 Fw::InputComPort* port
110 )
111 {
112 FW_ASSERT(
113 portNum < this->getNum_comOut_OutputPorts(),
114 static_cast<FwAssertArgType>(portNum)
115 );
116
117 this->m_comOut_OutputPort[portNum].addCallPort(port);
118 }
119
120#if FW_PORT_SERIALIZATION
121
122 // ----------------------------------------------------------------------
123 // Connect serial input ports to typed output ports
124 // ----------------------------------------------------------------------
125
126 void ComSplitterComponentBase ::
127 set_comOut_OutputPort(
128 NATIVE_INT_TYPE portNum,
129 Fw::InputSerializePort* port
130 )
131 {
132 FW_ASSERT(
133 portNum < this->getNum_comOut_OutputPorts(),
134 static_cast<FwAssertArgType>(portNum)
135 );
136
137 this->m_comOut_OutputPort[portNum].registerSerialPort(port);
138 }
139
140#endif
141
142 // ----------------------------------------------------------------------
143 // Component construction and destruction
144 // ----------------------------------------------------------------------
145
146 ComSplitterComponentBase ::
147 ComSplitterComponentBase(const char* compName) :
148 Fw::PassiveComponentBase(compName)
149 {
150
151 }
152
153 ComSplitterComponentBase ::
154 ~ComSplitterComponentBase()
155 {
156
157 }
158
159 // ----------------------------------------------------------------------
160 // Getters for numbers of typed input ports
161 // ----------------------------------------------------------------------
162
163 NATIVE_INT_TYPE ComSplitterComponentBase ::
164 getNum_comIn_InputPorts() const
165 {
166 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_comIn_InputPort));
167 }
168
169 // ----------------------------------------------------------------------
170 // Getters for numbers of typed output ports
171 // ----------------------------------------------------------------------
172
173 NATIVE_INT_TYPE ComSplitterComponentBase ::
174 getNum_comOut_OutputPorts() const
175 {
176 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_comOut_OutputPort));
177 }
178
179 // ----------------------------------------------------------------------
180 // Connection status queries for typed output ports
181 // ----------------------------------------------------------------------
182
183 bool ComSplitterComponentBase ::
184 isConnected_comOut_OutputPort(NATIVE_INT_TYPE portNum)
185 {
186 FW_ASSERT(
187 portNum < this->getNum_comOut_OutputPorts(),
188 static_cast<FwAssertArgType>(portNum)
189 );
190
191 return this->m_comOut_OutputPort[portNum].isConnected();
192 }
193
194 // ----------------------------------------------------------------------
195 // Port handler base-class functions for typed input ports
196 //
197 // Call these functions directly to bypass the corresponding ports
198 // ----------------------------------------------------------------------
199
200 void ComSplitterComponentBase ::
201 comIn_handlerBase(
202 NATIVE_INT_TYPE portNum,
203 Fw::ComBuffer& data,
204 U32 context
205 )
206 {
207 // Make sure port number is valid
208 FW_ASSERT(
209 portNum < this->getNum_comIn_InputPorts(),
210 static_cast<FwAssertArgType>(portNum)
211 );
212
213 // Call handler function
214 this->comIn_handler(
215 portNum,
216 data,
217 context
218 );
219 }
220
221 // ----------------------------------------------------------------------
222 // Invocation functions for typed output ports
223 // ----------------------------------------------------------------------
224
225 void ComSplitterComponentBase ::
226 comOut_out(
227 NATIVE_INT_TYPE portNum,
228 Fw::ComBuffer& data,
229 U32 context
230 )
231 {
232 FW_ASSERT(
233 portNum < this->getNum_comOut_OutputPorts(),
234 static_cast<FwAssertArgType>(portNum)
235 );
236 this->m_comOut_OutputPort[portNum].invoke(
237 data,
238 context
239 );
240 }
241
242 // ----------------------------------------------------------------------
243 // Calls for messages received on typed input ports
244 // ----------------------------------------------------------------------
245
246 void ComSplitterComponentBase ::
247 m_p_comIn_in(
248 Fw::PassiveComponentBase* callComp,
249 NATIVE_INT_TYPE portNum,
250 Fw::ComBuffer& data,
251 U32 context
252 )
253 {
254 FW_ASSERT(callComp);
255 ComSplitterComponentBase* compPtr = static_cast<ComSplitterComponentBase*>(callComp);
256 compPtr->comIn_handlerBase(
257 portNum,
258 data,
259 context
260 );
261 }
262
263}
#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
void init()
Object initializer.
Definition ObjBase.cpp:27
Auto-generated base for ComSplitter component.
void comIn_handlerBase(NATIVE_INT_TYPE portNum, Fw::ComBuffer &data, U32 context)
Handler base-class function for input port comIn.