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
LinuxTimerComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title LinuxTimerComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for LinuxTimer 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 {
20
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 LinuxTimerComponentBase ::
63 init(NATIVE_INT_TYPE instance)
64 {
65 // Initialize base class
67
68 // Connect output port CycleOut
69 for (
70 PlatformIntType port = 0;
71 port < static_cast<PlatformIntType>(this->getNum_CycleOut_OutputPorts());
72 port++
73 ) {
74 this->m_CycleOut_OutputPort[port].init();
75
76#if FW_OBJECT_NAMES == 1
77 char portName[120];
78 (void) snprintf(
79 portName,
80 sizeof(portName),
81 "%s_CycleOut_OutputPort[%" PRI_PlatformIntType "]",
82 this->m_objName,
83 port
84 );
85 this->m_CycleOut_OutputPort[port].setObjName(portName);
86#endif
87 }
88 }
89
90 // ----------------------------------------------------------------------
91 // Connect typed input ports to typed output ports
92 // ----------------------------------------------------------------------
93
94 void LinuxTimerComponentBase ::
95 set_CycleOut_OutputPort(
96 NATIVE_INT_TYPE portNum,
98 )
99 {
100 FW_ASSERT(
101 portNum < this->getNum_CycleOut_OutputPorts(),
102 static_cast<FwAssertArgType>(portNum)
103 );
104
105 this->m_CycleOut_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 LinuxTimerComponentBase ::
115 set_CycleOut_OutputPort(
116 NATIVE_INT_TYPE portNum,
117 Fw::InputSerializePort* port
118 )
119 {
120 FW_ASSERT(
121 portNum < this->getNum_CycleOut_OutputPorts(),
122 static_cast<FwAssertArgType>(portNum)
123 );
124
125 this->m_CycleOut_OutputPort[portNum].registerSerialPort(port);
126 }
127
128#endif
129
130 // ----------------------------------------------------------------------
131 // Component construction and destruction
132 // ----------------------------------------------------------------------
133
134 LinuxTimerComponentBase ::
135 LinuxTimerComponentBase(const char* compName) :
136 Fw::PassiveComponentBase(compName)
137 {
138
139 }
140
141 LinuxTimerComponentBase ::
142 ~LinuxTimerComponentBase()
143 {
144
145 }
146
147 // ----------------------------------------------------------------------
148 // Getters for numbers of typed output ports
149 // ----------------------------------------------------------------------
150
151 NATIVE_INT_TYPE LinuxTimerComponentBase ::
152 getNum_CycleOut_OutputPorts()
153 {
154 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_CycleOut_OutputPort));
155 }
156
157 // ----------------------------------------------------------------------
158 // Connection status queries for typed output ports
159 // ----------------------------------------------------------------------
160
161 bool LinuxTimerComponentBase ::
162 isConnected_CycleOut_OutputPort(NATIVE_INT_TYPE portNum)
163 {
164 FW_ASSERT(
165 portNum < this->getNum_CycleOut_OutputPorts(),
166 static_cast<FwAssertArgType>(portNum)
167 );
168
169 return this->m_CycleOut_OutputPort[portNum].isConnected();
170 }
171
172 // ----------------------------------------------------------------------
173 // Invocation functions for typed output ports
174 // ----------------------------------------------------------------------
175
176 void LinuxTimerComponentBase ::
177 CycleOut_out(
178 NATIVE_INT_TYPE portNum,
179 Svc::TimerVal& cycleStart
180 )
181 {
182 FW_ASSERT(
183 portNum < this->getNum_CycleOut_OutputPorts(),
184 static_cast<FwAssertArgType>(portNum)
185 );
186 this->m_CycleOut_OutputPort[portNum].invoke(
187 cycleStart
188 );
189 }
190
191}
#define FW_ASSERT(...)
Definition Assert.hpp:7
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
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
void init()
Object initializer.
Definition ObjBase.cpp:27
Serializable class for carrying timer values.
Definition TimerVal.hpp:22