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 char portName[120];
42 (void) snprintf(
43 portName,
44 sizeof(portName),
45 "%s_comIn_InputPort[%" PRI_PlatformIntType "]",
46 this->m_objName,
47 port
48 );
49 this->m_comIn_InputPort[port].setObjName(portName);
50#endif
51 }
52
53 // Connect output port comOut
54 for (
55 PlatformIntType port = 0;
56 port < static_cast<PlatformIntType>(this->getNum_comOut_OutputPorts());
57 port++
58 ) {
59 this->m_comOut_OutputPort[port].init();
60
61#if FW_OBJECT_NAMES == 1
62 char portName[120];
63 (void) snprintf(
64 portName,
65 sizeof(portName),
66 "%s_comOut_OutputPort[%" PRI_PlatformIntType "]",
67 this->m_objName,
68 port
69 );
70 this->m_comOut_OutputPort[port].setObjName(portName);
71#endif
72 }
73 }
74
75 // ----------------------------------------------------------------------
76 // Getters for typed input ports
77 // ----------------------------------------------------------------------
78
79 Fw::InputComPort* ComSplitterComponentBase ::
80 get_comIn_InputPort(NATIVE_INT_TYPE portNum)
81 {
83 portNum < this->getNum_comIn_InputPorts(),
84 static_cast<FwAssertArgType>(portNum)
85 );
86
87 return &this->m_comIn_InputPort[portNum];
88 }
89
90 // ----------------------------------------------------------------------
91 // Connect typed input ports to typed output ports
92 // ----------------------------------------------------------------------
93
94 void ComSplitterComponentBase ::
95 set_comOut_OutputPort(
96 NATIVE_INT_TYPE portNum,
98 )
99 {
100 FW_ASSERT(
101 portNum < this->getNum_comOut_OutputPorts(),
102 static_cast<FwAssertArgType>(portNum)
103 );
104
105 this->m_comOut_OutputPort[portNum].addCallPort(port);
106 }
107
108#if FW_PORT_SERIALIZATION
109
110 // ----------------------------------------------------------------------
111 // Connect serial input ports to typed output ports
112 // ----------------------------------------------------------------------
113
114 void ComSplitterComponentBase ::
115 set_comOut_OutputPort(
116 NATIVE_INT_TYPE portNum,
117 Fw::InputSerializePort* port
118 )
119 {
120 FW_ASSERT(
121 portNum < this->getNum_comOut_OutputPorts(),
122 static_cast<FwAssertArgType>(portNum)
123 );
124
125 this->m_comOut_OutputPort[portNum].registerSerialPort(port);
126 }
127
128#endif
129
130 // ----------------------------------------------------------------------
131 // Component construction and destruction
132 // ----------------------------------------------------------------------
133
134 ComSplitterComponentBase ::
135 ComSplitterComponentBase(const char* compName) :
136 Fw::PassiveComponentBase(compName)
137 {
138
139 }
140
141 ComSplitterComponentBase ::
142 ~ComSplitterComponentBase()
143 {
144
145 }
146
147 // ----------------------------------------------------------------------
148 // Getters for numbers of typed input ports
149 // ----------------------------------------------------------------------
150
151 NATIVE_INT_TYPE ComSplitterComponentBase ::
152 getNum_comIn_InputPorts() const
153 {
154 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_comIn_InputPort));
155 }
156
157 // ----------------------------------------------------------------------
158 // Getters for numbers of typed output ports
159 // ----------------------------------------------------------------------
160
161 NATIVE_INT_TYPE ComSplitterComponentBase ::
162 getNum_comOut_OutputPorts() const
163 {
164 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_comOut_OutputPort));
165 }
166
167 // ----------------------------------------------------------------------
168 // Connection status queries for typed output ports
169 // ----------------------------------------------------------------------
170
171 bool ComSplitterComponentBase ::
172 isConnected_comOut_OutputPort(NATIVE_INT_TYPE portNum)
173 {
174 FW_ASSERT(
175 portNum < this->getNum_comOut_OutputPorts(),
176 static_cast<FwAssertArgType>(portNum)
177 );
178
179 return this->m_comOut_OutputPort[portNum].isConnected();
180 }
181
182 // ----------------------------------------------------------------------
183 // Port handler base-class functions for typed input ports
184 //
185 // Call these functions directly to bypass the corresponding ports
186 // ----------------------------------------------------------------------
187
188 void ComSplitterComponentBase ::
189 comIn_handlerBase(
190 NATIVE_INT_TYPE portNum,
191 Fw::ComBuffer& data,
192 U32 context
193 )
194 {
195 // Make sure port number is valid
196 FW_ASSERT(
197 portNum < this->getNum_comIn_InputPorts(),
198 static_cast<FwAssertArgType>(portNum)
199 );
200
201 // Down call to pure virtual handler method implemented in Impl class
202 this->comIn_handler(
203 portNum,
204 data,
205 context
206 );
207 }
208
209 // ----------------------------------------------------------------------
210 // Invocation functions for typed output ports
211 // ----------------------------------------------------------------------
212
213 void ComSplitterComponentBase ::
214 comOut_out(
215 NATIVE_INT_TYPE portNum,
216 Fw::ComBuffer& data,
217 U32 context
218 )
219 {
220 FW_ASSERT(
221 portNum < this->getNum_comOut_OutputPorts(),
222 static_cast<FwAssertArgType>(portNum)
223 );
224 this->m_comOut_OutputPort[portNum].invoke(
225 data,
226 context
227 );
228 }
229
230 // ----------------------------------------------------------------------
231 // Calls for messages received on typed input ports
232 // ----------------------------------------------------------------------
233
234 void ComSplitterComponentBase ::
235 m_p_comIn_in(
236 Fw::PassiveComponentBase* callComp,
237 NATIVE_INT_TYPE portNum,
238 Fw::ComBuffer& data,
239 U32 context
240 )
241 {
242 FW_ASSERT(callComp);
243 ComSplitterComponentBase* compPtr = static_cast<ComSplitterComponentBase*>(callComp);
244 compPtr->comIn_handlerBase(
245 portNum,
246 data,
247 context
248 );
249 }
250
251}
#define FW_ASSERT(...)
Definition Assert.hpp:7
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.