F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
TimeIntervalPortAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title TimeIntervalPortAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for TimeInterval port
5 // ======================================================================
6 
8 #include "Fw/Types/Assert.hpp"
9 
10 namespace Fw {
11 
12  // ----------------------------------------------------------------------
13  // Public constructors for TimeIntervalPortSerializer
14  // ----------------------------------------------------------------------
15 
18  m_timeInterval()
19  {
20 
21  }
22 
23  // ----------------------------------------------------------------------
24  // Public member functions for TimeIntervalPortSerializer
25  // ----------------------------------------------------------------------
26 
29  {
31  if (_status == Fw::FW_SERIALIZE_OK) {
32  _status = _buffer.deserializeTo(m_timeInterval);
33  }
34  return _status;
35  }
36 
37  // ----------------------------------------------------------------------
38  // Public static functions for TimeIntervalPortSerializer
39  // ----------------------------------------------------------------------
40 
43  Fw::TimeInterval& timeInterval,
44  Fw::SerialBufferBase& _buffer
45  )
46  {
48  if (_status == Fw::FW_SERIALIZE_OK) {
49  _status = _buffer.serializeFrom(timeInterval);
50  }
51  return _status;
52  }
53 
54 #if !FW_DIRECT_PORT_CALLS
55 
56  // ----------------------------------------------------------------------
57  // Public constructors for InputTimeIntervalPort
58  // ----------------------------------------------------------------------
59 
62  Fw::InputPortBase(),
63  m_func(nullptr)
64  {
65 
66  }
67 
68  // ----------------------------------------------------------------------
69  // Public member functions for InputTimeIntervalPort
70  // ----------------------------------------------------------------------
71 
74  {
76  }
77 
80  Fw::PassiveComponentBase* callComp,
81  CompFuncPtr funcPtr
82  )
83  {
84  FW_ASSERT(callComp != nullptr);
85  FW_ASSERT(funcPtr != nullptr);
86 
87  this->m_comp = callComp;
88  this->m_func = funcPtr;
89  this->m_connObj = callComp;
90  }
91 
93  invoke(Fw::TimeInterval& timeInterval)
94  {
95 #if FW_PORT_TRACING == 1
96  this->trace();
97 #endif
98 
99  FW_ASSERT(this->m_comp != nullptr);
100  FW_ASSERT(this->m_func != nullptr);
101 
102  return this->m_func(this->m_comp, this->m_portNum, timeInterval);
103  }
104 
105  // ----------------------------------------------------------------------
106  // Private member functions for InputTimeIntervalPort
107  // ----------------------------------------------------------------------
108 
109 #if FW_PORT_SERIALIZATION == 1
110 
111  Fw::SerializeStatus InputTimeIntervalPort ::
112  invokeSerial(Fw::LinearBufferBase& _buffer)
113  {
114 #if FW_PORT_TRACING == 1
115  this->trace();
116 #endif
117 
118  FW_ASSERT(this->m_comp != nullptr);
119  FW_ASSERT(this->m_func != nullptr);
120 
121  TimeIntervalPortSerializer _serializer;
122  Fw::SerializeStatus _status = _serializer.deserializePortArgs(_buffer);
123  if (_status != Fw::FW_SERIALIZE_OK) {
124  return _status;
125  }
126 
127  this->m_func(this->m_comp, this->m_portNum, _serializer.m_timeInterval);
128 
129  return Fw::FW_SERIALIZE_OK;
130  }
131 
132 #endif
133 
134  // ----------------------------------------------------------------------
135  // Public constructors for OutputTimeIntervalPort
136  // ----------------------------------------------------------------------
137 
140  Fw::OutputPortBase(),
141  m_port(nullptr)
142  {
143 
144  }
145 
146  // ----------------------------------------------------------------------
147  // Public member functions for OutputTimeIntervalPort
148  // ----------------------------------------------------------------------
149 
152  {
154  }
155 
158  {
159  FW_ASSERT(callPort != nullptr);
160 
161  this->m_port = callPort;
162  this->m_connObj = callPort;
163 
164 #if FW_PORT_SERIALIZATION == 1
165  this->m_serPort = nullptr;
166 #endif
167  }
168 
170  invoke(Fw::TimeInterval& timeInterval) const
171  {
172 #if FW_PORT_TRACING == 1
173  this->trace();
174 #endif
175 
176 #if FW_PORT_SERIALIZATION
177  FW_ASSERT((this->m_port != nullptr) || (this->m_serPort != nullptr));
178 
179  if (this->m_port != nullptr) {
180  this->m_port->invoke(timeInterval);
181  }
182  else {
183  Fw::SerializeStatus _status;
184  TimeIntervalPortBuffer _buffer;
185 
186  _status = TimeIntervalPortSerializer::serializePortArgs(timeInterval, _buffer);
187  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
188 
189  _status = this->m_serPort->invokeSerial(_buffer);
190  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
191  }
192 #else
193  FW_ASSERT(this->m_port != nullptr);
194  this->m_port->invoke(timeInterval);
195 #endif
196  }
197 
198 #endif
199 
200 }
Serialization/Deserialization operation was successful.
Fw::SerializeStatus deserializePortArgs(Fw::SerialBufferBase &_buffer)
Deserialze port arguments into members.
FwIndexType m_portNum
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void init()
Initialization function.
void addCallPort(InputTimeIntervalPort *callPort)
Register an input port.
virtual SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)=0
Serialize an 8-bit unsigned integer value.
SerializeStatus
forward declaration for string
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
void init() override
static Fw::SerializeStatus serializePortArgs(Fw::TimeInterval &timeInterval, Fw::SerialBufferBase &_buffer)
Serialize port arguments into a buffer.
void init()
Initialization function.
void invoke(Fw::TimeInterval &timeInterval) const
Invoke a port connection.
PassiveComponentBase * m_comp
void invoke(Fw::TimeInterval &timeInterval)
Invoke a port interface.
void init() override
Implementation of malloc based allocator.
Fw::ObjBase * m_connObj
Definition: PortBase.hpp:34
#define FW_ASSERT(...)
Definition: Assert.hpp:14