F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VersionPortAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title VersionPortAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for Version port
5 // ======================================================================
6 
8 #include "Fw/Types/Assert.hpp"
10 
11 namespace Svc {
12 
13  namespace {
14 
15  // ----------------------------------------------------------------------
16  // Port buffer class
17  // ----------------------------------------------------------------------
18 
19  class VersionPortBuffer : public Fw::SerializeBufferBase {
20 
21  public:
22 
23  Fw::Serializable::SizeType getBuffCapacity() 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 
56  init()
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 
76  invoke(
77  const Svc::VersionCfg::VersionEnum& version_id,
78  Fw::StringBase& version_string,
79  Svc::VersionStatus& status
80  )
81  {
82 #if FW_PORT_TRACING == 1
83  this->trace();
84 #endif
85 
86  FW_ASSERT(this->m_comp != nullptr);
87  FW_ASSERT(this->m_func != nullptr);
88 
89  return this->m_func(this->m_comp, this->m_portNum, version_id, version_string, status);
90  }
91 
92 #if FW_PORT_SERIALIZATION == 1
93 
94  Fw::SerializeStatus InputVersionPort ::
95  invokeSerial(Fw::SerializeBufferBase& _buffer)
96  {
97  Fw::SerializeStatus _status;
98 
99 #if FW_PORT_TRACING == 1
100  this->trace();
101 #endif
102 
103  FW_ASSERT(this->m_comp != nullptr);
104  FW_ASSERT(this->m_func != nullptr);
105 
106  Svc::VersionCfg::VersionEnum version_id;
107  _status = _buffer.deserialize(version_id);
108  if (_status != Fw::FW_SERIALIZE_OK) {
109  return _status;
110  }
111 
112  char __fprime_ac_version_string_buffer[Fw::StringBase::BUFFER_SIZE(80)];
113  Fw::ExternalString version_string(__fprime_ac_version_string_buffer, sizeof __fprime_ac_version_string_buffer);
114  _status = _buffer.deserialize(version_string);
115  if (_status != Fw::FW_SERIALIZE_OK) {
116  return _status;
117  }
118 
119  Svc::VersionStatus status;
120  _status = _buffer.deserialize(status);
121  if (_status != Fw::FW_SERIALIZE_OK) {
122  return _status;
123  }
124 
125  this->m_func(this->m_comp, this->m_portNum, version_id, version_string, status);
126 
127  return Fw::FW_SERIALIZE_OK;
128  }
129 
130 #endif
131 
132  // ----------------------------------------------------------------------
133  // Output Port Member functions
134  // ----------------------------------------------------------------------
135 
138  Fw::OutputPortBase(),
139  m_port(nullptr)
140  {
141 
142  }
143 
145  init()
146  {
148  }
149 
152  {
153  FW_ASSERT(callPort != nullptr);
154 
155  this->m_port = callPort;
156  this->m_connObj = callPort;
157 
158 #if FW_PORT_SERIALIZATION == 1
159  this->m_serPort = nullptr;
160 #endif
161  }
162 
164  invoke(
165  const Svc::VersionCfg::VersionEnum& version_id,
166  Fw::StringBase& version_string,
167  Svc::VersionStatus& status
168  )
169  {
170 #if FW_PORT_TRACING == 1
171  this->trace();
172 #endif
173 
174 #if FW_PORT_SERIALIZATION
175  FW_ASSERT((this->m_port != nullptr) || (this->m_serPort != nullptr));
176 
177  if (this->m_port != nullptr) {
178  this->m_port->invoke(version_id, version_string, status);
179  }
180  else {
181  Fw::SerializeStatus _status;
182  VersionPortBuffer _buffer;
183 
184  _status = _buffer.serialize(version_id);
185  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
186 
187  _status = _buffer.serialize(version_string);
188  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
189 
190  _status = _buffer.serialize(status);
191  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
192 
193  _status = this->m_serPort->invokeSerial(_buffer);
194  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
195  }
196 #else
197  FW_ASSERT(this->m_port != nullptr);
198  this->m_port->invoke(version_id, version_string, status);
199 #endif
200  }
201 
202 }
#define FW_ASSERT(...)
Definition: Assert.hpp:14
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:30
PlatformAssertArgType FwAssertArgType
Definition: FpConfig.h:39
A string backed by an external buffer.
NATIVE_INT_TYPE m_portNum
virtual void init()
PassiveComponentBase * m_comp
virtual void init()
Fw::ObjBase * m_connObj
Definition: PortBase.hpp:33
NATIVE_UINT_TYPE SizeType
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
static constexpr SizeType BUFFER_SIZE(SizeType maxLength)
Get the size of a null-terminated string buffer.
Definition: StringBase.hpp:41
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
void init()
Initialization function.
InputVersionPort()
Constructor.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void invoke(const Svc::VersionCfg::VersionEnum &version_id, Fw::StringBase &version_string, Svc::VersionStatus &status)
Invoke a port interface.
void addCallPort(InputVersionPort *callPort)
Register an input port.
void init()
Initialization function.
void invoke(const Svc::VersionCfg::VersionEnum &version_id, Fw::StringBase &version_string, Svc::VersionStatus &status)
Invoke a port interface.
OutputVersionPort()
Constructor.
An enumeration for version status.
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.