F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
FileWritePortAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title FileWritePortAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for FileWrite port
5 // ======================================================================
6 
7 #include "Fw/Types/Assert.hpp"
9 
10 namespace Svc {
11 
12  // ----------------------------------------------------------------------
13  // Public constructors for FileWritePortSerializer
14  // ----------------------------------------------------------------------
15 
18  m_path(m___fprime_ac_path_buffer, sizeof m___fprime_ac_path_buffer),
19  m_buffer(),
20  m_offsetBytes(),
21  m_append()
22  {
23 
24  }
25 
26  // ----------------------------------------------------------------------
27  // Public member functions for FileWritePortSerializer
28  // ----------------------------------------------------------------------
29 
32  {
34  if (_status == Fw::FW_SERIALIZE_OK) {
35  _status = _buffer.deserializeTo(m_path);
36  }
37  if (_status == Fw::FW_SERIALIZE_OK) {
38  _status = _buffer.deserializeTo(m_buffer);
39  }
40  if (_status == Fw::FW_SERIALIZE_OK) {
41  _status = _buffer.deserializeTo(m_offsetBytes);
42  }
43  if (_status == Fw::FW_SERIALIZE_OK) {
44  _status = _buffer.deserializeTo(m_append);
45  }
46  return _status;
47  }
48 
49  // ----------------------------------------------------------------------
50  // Public static functions for FileWritePortSerializer
51  // ----------------------------------------------------------------------
52 
55  const Fw::StringBase& path,
56  Fw::Buffer& buffer,
57  FwSizeType offsetBytes,
58  bool append,
59  Fw::SerialBufferBase& _buffer
60  )
61  {
63  if (_status == Fw::FW_SERIALIZE_OK) {
64  _status = _buffer.serializeFrom(path);
65  }
66  if (_status == Fw::FW_SERIALIZE_OK) {
67  _status = _buffer.serializeFrom(buffer);
68  }
69  if (_status == Fw::FW_SERIALIZE_OK) {
70  _status = _buffer.serializeFrom(offsetBytes);
71  }
72  if (_status == Fw::FW_SERIALIZE_OK) {
73  _status = _buffer.serializeFrom(append);
74  }
75  return _status;
76  }
77 
78 #if !FW_DIRECT_PORT_CALLS
79 
80  // ----------------------------------------------------------------------
81  // Public constructors for InputFileWritePort
82  // ----------------------------------------------------------------------
83 
86  Fw::InputPortBase(),
87  m_func(nullptr)
88  {
89 
90  }
91 
92  // ----------------------------------------------------------------------
93  // Public member functions for InputFileWritePort
94  // ----------------------------------------------------------------------
95 
98  {
100  }
101 
104  Fw::PassiveComponentBase* callComp,
105  CompFuncPtr funcPtr
106  )
107  {
108  FW_ASSERT(callComp != nullptr);
109  FW_ASSERT(funcPtr != nullptr);
110 
111  this->m_comp = callComp;
112  this->m_func = funcPtr;
113  this->m_connObj = callComp;
114  }
115 
118  const Fw::StringBase& path,
119  Fw::Buffer& buffer,
120  FwSizeType offsetBytes,
121  bool append
122  )
123  {
124 #if FW_PORT_TRACING == 1
125  this->trace();
126 #endif
127 
128  FW_ASSERT(this->m_comp != nullptr);
129  FW_ASSERT(this->m_func != nullptr);
130 
131  return this->m_func(this->m_comp, this->m_portNum, path, buffer, offsetBytes, append);
132  }
133 
134  // ----------------------------------------------------------------------
135  // Private member functions for InputFileWritePort
136  // ----------------------------------------------------------------------
137 
138 #if FW_PORT_SERIALIZATION == 1
139 
140  Fw::SerializeStatus InputFileWritePort ::
141  invokeSerial(Fw::LinearBufferBase& _buffer)
142  {
143 #if FW_PORT_TRACING == 1
144  this->trace();
145 #endif
146 
147  FW_ASSERT(this->m_comp != nullptr);
148  FW_ASSERT(this->m_func != nullptr);
149 
150  FileWritePortSerializer _serializer;
151  Fw::SerializeStatus _status = _serializer.deserializePortArgs(_buffer);
152  if (_status != Fw::FW_SERIALIZE_OK) {
153  return _status;
154  }
155 
156  this->m_func(this->m_comp, this->m_portNum, _serializer.m_path, _serializer.m_buffer, _serializer.m_offsetBytes, _serializer.m_append);
157 
158  return Fw::FW_SERIALIZE_OK;
159  }
160 
161 #endif
162 
163  // ----------------------------------------------------------------------
164  // Public constructors for OutputFileWritePort
165  // ----------------------------------------------------------------------
166 
169  Fw::OutputPortBase(),
170  m_port(nullptr)
171  {
172 
173  }
174 
175  // ----------------------------------------------------------------------
176  // Public member functions for OutputFileWritePort
177  // ----------------------------------------------------------------------
178 
181  {
183  }
184 
187  {
188  FW_ASSERT(callPort != nullptr);
189 
190  this->m_port = callPort;
191  this->m_connObj = callPort;
192 
193 #if FW_PORT_SERIALIZATION == 1
194  this->m_serPort = nullptr;
195 #endif
196  }
197 
200  const Fw::StringBase& path,
201  Fw::Buffer& buffer,
202  FwSizeType offsetBytes,
203  bool append
204  ) const
205  {
206 #if FW_PORT_TRACING == 1
207  this->trace();
208 #endif
209 
210 #if FW_PORT_SERIALIZATION
211  FW_ASSERT((this->m_port != nullptr) || (this->m_serPort != nullptr));
212 
213  if (this->m_port != nullptr) {
214  this->m_port->invoke(path, buffer, offsetBytes, append);
215  }
216  else {
217  Fw::SerializeStatus _status;
218  FileWritePortBuffer _buffer;
219 
220  _status = FileWritePortSerializer::serializePortArgs(path, buffer, offsetBytes, append, _buffer);
221  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
222 
223  _status = this->m_serPort->invokeSerial(_buffer);
224  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
225  }
226 #else
227  FW_ASSERT(this->m_port != nullptr);
228  this->m_port->invoke(path, buffer, offsetBytes, append);
229 #endif
230  }
231 
232 #endif
233 
234 }
Serialization/Deserialization operation was successful.
OutputFileWritePort()
Constructor.
PlatformSizeType FwSizeType
void init()
Initialization function.
FwIndexType m_portNum
void invoke(const Fw::StringBase &path, Fw::Buffer &buffer, FwSizeType offsetBytes, bool append) const
Invoke a port connection.
static Fw::SerializeStatus serializePortArgs(const Fw::StringBase &path, Fw::Buffer &buffer, FwSizeType offsetBytes, bool append, Fw::SerialBufferBase &_buffer)
Serialize port arguments into a buffer.
Serializer for FileWrite port.
virtual SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)=0
Serialize an 8-bit unsigned integer value.
SerializeStatus
forward declaration for string
void addCallPort(InputFileWritePort *callPort)
Register an input port.
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
InputFileWritePort()
Constructor.
Serialization buffer for FileWrite port.
Fw::SerializeStatus deserializePortArgs(Fw::SerialBufferBase &_buffer)
Deserialze port arguments into members.
void init() override
void invoke(const Fw::StringBase &path, Fw::Buffer &buffer, FwSizeType offsetBytes, bool append)
Invoke a port interface.
Input FileWrite port.
FileWritePortSerializer()
Constructor.
PassiveComponentBase * m_comp
void init() override
RateGroupDivider component implementation.
Implementation of malloc based allocator.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Fw::ObjBase * m_connObj
Definition: PortBase.hpp:34
#define FW_ASSERT(...)
Definition: Assert.hpp:14
void init()
Initialization function.