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"
10 
11 namespace Svc {
12 
13  namespace {
14 
15  // ----------------------------------------------------------------------
16  // Port buffer class
17  // ----------------------------------------------------------------------
18 
19  class FileWritePortBuffer : public Fw::LinearBufferBase {
20 
21  public:
22 
23  Fw::Serializable::SizeType getCapacity() const {
25  }
26 
27  U8* getBuffAddr() {
28  return m_buff;
29  }
30 
31  const U8* getBuffAddr() const {
32  return m_buff;
33  }
34 
35  private:
36 
38 
39  };
40 
41  }
42 
43  // ----------------------------------------------------------------------
44  // Input Port Member functions
45  // ----------------------------------------------------------------------
46 
49  Fw::InputPortBase(),
50  m_func(nullptr)
51  {
52 
53  }
54 
57  {
59  }
60 
63  Fw::PassiveComponentBase* callComp,
64  CompFuncPtr funcPtr
65  )
66  {
67  FW_ASSERT(callComp != nullptr);
68  FW_ASSERT(funcPtr != nullptr);
69 
70  this->m_comp = callComp;
71  this->m_func = funcPtr;
72  this->m_connObj = callComp;
73  }
74 
77  const Fw::StringBase& path,
78  Fw::Buffer& buffer,
79  FwSizeType offsetBytes,
80  bool append
81  )
82  {
83 #if FW_PORT_TRACING == 1
84  this->trace();
85 #endif
86 
87  FW_ASSERT(this->m_comp != nullptr);
88  FW_ASSERT(this->m_func != nullptr);
89 
90  return this->m_func(this->m_comp, this->m_portNum, path, buffer, offsetBytes, append);
91  }
92 
93 #if FW_PORT_SERIALIZATION == 1
94 
95  Fw::SerializeStatus InputFileWritePort ::
96  invokeSerial(Fw::LinearBufferBase& _buffer)
97  {
98  Fw::SerializeStatus _status;
99 
100 #if FW_PORT_TRACING == 1
101  this->trace();
102 #endif
103 
104  FW_ASSERT(this->m_comp != nullptr);
105  FW_ASSERT(this->m_func != nullptr);
106 
107  char __fprime_ac_path_buffer[Fw::StringBase::BUFFER_SIZE(200)];
108  Fw::ExternalString path(__fprime_ac_path_buffer, sizeof __fprime_ac_path_buffer);
109  _status = _buffer.deserializeTo(path);
110  if (_status != Fw::FW_SERIALIZE_OK) {
111  return _status;
112  }
113 
114  Fw::Buffer buffer;
115  _status = _buffer.deserializeTo(buffer);
116  if (_status != Fw::FW_SERIALIZE_OK) {
117  return _status;
118  }
119 
120  FwSizeType offsetBytes;
121  _status = _buffer.deserializeTo(offsetBytes);
122  if (_status != Fw::FW_SERIALIZE_OK) {
123  return _status;
124  }
125 
126  bool append;
127  _status = _buffer.deserializeTo(append);
128  if (_status != Fw::FW_SERIALIZE_OK) {
129  return _status;
130  }
131 
132  this->m_func(this->m_comp, this->m_portNum, path, buffer, offsetBytes, append);
133 
134  return Fw::FW_SERIALIZE_OK;
135  }
136 
137 #endif
138 
139  // ----------------------------------------------------------------------
140  // Output Port Member functions
141  // ----------------------------------------------------------------------
142 
145  Fw::OutputPortBase(),
146  m_port(nullptr)
147  {
148 
149  }
150 
153  {
155  }
156 
159  {
160  FW_ASSERT(callPort != nullptr);
161 
162  this->m_port = callPort;
163  this->m_connObj = callPort;
164 
165 #if FW_PORT_SERIALIZATION == 1
166  this->m_serPort = nullptr;
167 #endif
168  }
169 
172  const Fw::StringBase& path,
173  Fw::Buffer& buffer,
174  FwSizeType offsetBytes,
175  bool append
176  ) const
177  {
178 #if FW_PORT_TRACING == 1
179  this->trace();
180 #endif
181 
182 #if FW_PORT_SERIALIZATION
183  FW_ASSERT((this->m_port != nullptr) || (this->m_serPort != nullptr));
184 
185  if (this->m_port != nullptr) {
186  this->m_port->invoke(path, buffer, offsetBytes, append);
187  }
188  else {
189  Fw::SerializeStatus _status;
190  FileWritePortBuffer _buffer;
191 
192  _status = _buffer.serializeFrom(path);
193  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
194 
195  _status = _buffer.serializeFrom(buffer);
196  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
197 
198  _status = _buffer.serializeFrom(offsetBytes);
199  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
200 
201  _status = _buffer.serializeFrom(append);
202  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
203 
204  _status = this->m_serPort->invokeSerial(_buffer);
205  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
206  }
207 #else
208  FW_ASSERT(this->m_port != nullptr);
209  this->m_port->invoke(path, buffer, offsetBytes, append);
210 #endif
211  }
212 
213 }
Serialization/Deserialization operation was successful.
OutputFileWritePort()
Constructor.
The size of the serial representations of the port arguments.
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 interface.
SerializeStatus
forward declaration for string
void addCallPort(InputFileWritePort *callPort)
Register an input port.
InputFileWritePort()
Constructor.
void init() override
void invoke(const Fw::StringBase &path, Fw::Buffer &buffer, FwSizeType offsetBytes, bool append)
Invoke a port interface.
FwSizeType SizeType
Input FileWrite port.
A string backed by an external buffer.
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
PassiveComponentBase * m_comp
void init() override
RateGroupDivider component implementation.
SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG) override
Deserialize an 8-bit unsigned integer value.
Implementation of malloc based allocator.
static constexpr SizeType BUFFER_SIZE(SizeType maxLength)
Get the size of a null-terminated string buffer.
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.