F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
RateGroupDriverComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title RateGroupDriverComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for RateGroupDriver 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 CycleIn
28  for (
29  PlatformIntType port = 0;
30  port < static_cast<PlatformIntType>(this->getNum_CycleIn_InputPorts());
31  port++
32  ) {
33  this->m_CycleIn_InputPort[port].init();
34  this->m_CycleIn_InputPort[port].addCallComp(
35  this,
36  m_p_CycleIn_in
37  );
38  this->m_CycleIn_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_CycleIn_InputPort[%" PRI_PlatformIntType "]",
52  this->m_objName,
53  port
54  );
55  this->m_CycleIn_InputPort[port].setObjName(portName);
56 #endif
57  }
58 
59  // Connect output port CycleOut
60  for (
61  PlatformIntType port = 0;
62  port < static_cast<PlatformIntType>(this->getNum_CycleOut_OutputPorts());
63  port++
64  ) {
65  this->m_CycleOut_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_CycleOut_OutputPort[%" PRI_PlatformIntType "]",
79  this->m_objName,
80  port
81  );
82  this->m_CycleOut_OutputPort[port].setObjName(portName);
83 #endif
84  }
85  }
86 
87  // ----------------------------------------------------------------------
88  // Getters for typed input ports
89  // ----------------------------------------------------------------------
90 
93  {
94  FW_ASSERT(
95  portNum < this->getNum_CycleIn_InputPorts(),
96  static_cast<FwAssertArgType>(portNum)
97  );
98 
99  return &this->m_CycleIn_InputPort[portNum];
100  }
101 
102  // ----------------------------------------------------------------------
103  // Connect typed input ports to typed output ports
104  // ----------------------------------------------------------------------
105 
108  NATIVE_INT_TYPE portNum,
109  Svc::InputCyclePort* port
110  )
111  {
112  FW_ASSERT(
113  portNum < this->getNum_CycleOut_OutputPorts(),
114  static_cast<FwAssertArgType>(portNum)
115  );
116 
117  this->m_CycleOut_OutputPort[portNum].addCallPort(port);
118  }
119 
120 #if FW_PORT_SERIALIZATION
121 
122  // ----------------------------------------------------------------------
123  // Connect serial input ports to typed output ports
124  // ----------------------------------------------------------------------
125 
128  NATIVE_INT_TYPE portNum,
129  Fw::InputSerializePort* port
130  )
131  {
132  FW_ASSERT(
133  portNum < this->getNum_CycleOut_OutputPorts(),
134  static_cast<FwAssertArgType>(portNum)
135  );
136 
137  this->m_CycleOut_OutputPort[portNum].registerSerialPort(port);
138  }
139 
140 #endif
141 
142  // ----------------------------------------------------------------------
143  // Component construction and destruction
144  // ----------------------------------------------------------------------
145 
147  RateGroupDriverComponentBase(const char* compName) :
148  Fw::PassiveComponentBase(compName)
149  {
150 
151  }
152 
155  {
156 
157  }
158 
159  // ----------------------------------------------------------------------
160  // Getters for numbers of typed input ports
161  // ----------------------------------------------------------------------
162 
165  {
166  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_CycleIn_InputPort));
167  }
168 
169  // ----------------------------------------------------------------------
170  // Getters for numbers of typed output ports
171  // ----------------------------------------------------------------------
172 
175  {
176  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_CycleOut_OutputPort));
177  }
178 
179  // ----------------------------------------------------------------------
180  // Connection status queries for typed output ports
181  // ----------------------------------------------------------------------
182 
185  {
186  FW_ASSERT(
187  portNum < this->getNum_CycleOut_OutputPorts(),
188  static_cast<FwAssertArgType>(portNum)
189  );
190 
191  return this->m_CycleOut_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 
202  NATIVE_INT_TYPE portNum,
203  Svc::TimerVal& cycleStart
204  )
205  {
206  // Make sure port number is valid
207  FW_ASSERT(
208  portNum < this->getNum_CycleIn_InputPorts(),
209  static_cast<FwAssertArgType>(portNum)
210  );
211 
212  // Call handler function
213  this->CycleIn_handler(
214  portNum,
215  cycleStart
216  );
217  }
218 
219  // ----------------------------------------------------------------------
220  // Invocation functions for typed output ports
221  // ----------------------------------------------------------------------
222 
225  NATIVE_INT_TYPE portNum,
226  Svc::TimerVal& cycleStart
227  )
228  {
229  FW_ASSERT(
230  portNum < this->getNum_CycleOut_OutputPorts(),
231  static_cast<FwAssertArgType>(portNum)
232  );
233  this->m_CycleOut_OutputPort[portNum].invoke(
234  cycleStart
235  );
236  }
237 
238  // ----------------------------------------------------------------------
239  // Calls for messages received on typed input ports
240  // ----------------------------------------------------------------------
241 
242  void RateGroupDriverComponentBase ::
243  m_p_CycleIn_in(
244  Fw::PassiveComponentBase* callComp,
245  NATIVE_INT_TYPE portNum,
246  Svc::TimerVal& cycleStart
247  )
248  {
249  FW_ASSERT(callComp);
250  RateGroupDriverComponentBase* compPtr = static_cast<RateGroupDriverComponentBase*>(callComp);
251  compPtr->CycleIn_handlerBase(
252  portNum,
253  cycleStart
254  );
255  }
256 
257 }
#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
#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
bool isConnected()
Definition: PortBase.cpp:41
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CyclePortAc.cpp:62
void init()
Initialization function.
Definition: CyclePortAc.cpp:56
void init()
Initialization function.
void addCallPort(InputCyclePort *callPort)
Register an input port.
void invoke(Svc::TimerVal &cycleStart)
Invoke a port interface.
Auto-generated base for RateGroupDriver component.
virtual void CycleIn_handler(NATIVE_INT_TYPE portNum, Svc::TimerVal &cycleStart)=0
Handler for input port CycleIn.
bool isConnected_CycleOut_OutputPort(NATIVE_INT_TYPE portNum)
void CycleIn_handlerBase(NATIVE_INT_TYPE portNum, Svc::TimerVal &cycleStart)
Handler base-class function for input port CycleIn.
Svc::InputCyclePort * get_CycleIn_InputPort(NATIVE_INT_TYPE portNum)
RateGroupDriverComponentBase(const char *compName="")
Construct RateGroupDriverComponentBase object.
void CycleOut_out(NATIVE_INT_TYPE portNum, Svc::TimerVal &cycleStart)
Invoke output port CycleOut.
virtual ~RateGroupDriverComponentBase()
Destroy RateGroupDriverComponentBase object.
void set_CycleOut_OutputPort(NATIVE_INT_TYPE portNum, Svc::InputCyclePort *port)
Connect port to CycleOut[portNum].
Serializable class for carrying timer values.
Definition: TimerVal.hpp:22