F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
DpResponsePortAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title DpResponsePortAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for DpResponse port
5 // ======================================================================
6 
8 #include "Fw/Types/Assert.hpp"
9 
10 namespace Fw {
11 
12  // ----------------------------------------------------------------------
13  // Public constructors for DpResponsePortSerializer
14  // ----------------------------------------------------------------------
15 
18  m_id(),
19  m_buffer(),
20  m_status()
21  {
22 
23  }
24 
25  // ----------------------------------------------------------------------
26  // Public member functions for DpResponsePortSerializer
27  // ----------------------------------------------------------------------
28 
31  {
33  if (_status == Fw::FW_SERIALIZE_OK) {
34  _status = _buffer.deserializeTo(m_id);
35  }
36  if (_status == Fw::FW_SERIALIZE_OK) {
37  _status = _buffer.deserializeTo(m_buffer);
38  }
39  if (_status == Fw::FW_SERIALIZE_OK) {
40  _status = _buffer.deserializeTo(m_status);
41  }
42  return _status;
43  }
44 
45  // ----------------------------------------------------------------------
46  // Public static functions for DpResponsePortSerializer
47  // ----------------------------------------------------------------------
48 
51  FwDpIdType id,
52  const Fw::Buffer& buffer,
53  const Fw::Success& status,
54  Fw::SerialBufferBase& _buffer
55  )
56  {
58  if (_status == Fw::FW_SERIALIZE_OK) {
59  _status = _buffer.serializeFrom(id);
60  }
61  if (_status == Fw::FW_SERIALIZE_OK) {
62  _status = _buffer.serializeFrom(buffer);
63  }
64  if (_status == Fw::FW_SERIALIZE_OK) {
65  _status = _buffer.serializeFrom(status);
66  }
67  return _status;
68  }
69 
70 #if !FW_DIRECT_PORT_CALLS
71 
72  // ----------------------------------------------------------------------
73  // Public constructors for InputDpResponsePort
74  // ----------------------------------------------------------------------
75 
78  Fw::InputPortBase(),
79  m_func(nullptr)
80  {
81 
82  }
83 
84  // ----------------------------------------------------------------------
85  // Public member functions for InputDpResponsePort
86  // ----------------------------------------------------------------------
87 
90  {
92  }
93 
96  Fw::PassiveComponentBase* callComp,
97  CompFuncPtr funcPtr
98  )
99  {
100  FW_ASSERT(callComp != nullptr);
101  FW_ASSERT(funcPtr != nullptr);
102 
103  this->m_comp = callComp;
104  this->m_func = funcPtr;
105  this->m_connObj = callComp;
106  }
107 
110  FwDpIdType id,
111  const Fw::Buffer& buffer,
112  const Fw::Success& status
113  )
114  {
115 #if FW_PORT_TRACING == 1
116  this->trace();
117 #endif
118 
119  FW_ASSERT(this->m_comp != nullptr);
120  FW_ASSERT(this->m_func != nullptr);
121 
122  return this->m_func(this->m_comp, this->m_portNum, id, buffer, status);
123  }
124 
125  // ----------------------------------------------------------------------
126  // Private member functions for InputDpResponsePort
127  // ----------------------------------------------------------------------
128 
129 #if FW_PORT_SERIALIZATION == 1
130 
131  Fw::SerializeStatus InputDpResponsePort ::
132  invokeSerial(Fw::LinearBufferBase& _buffer)
133  {
134 #if FW_PORT_TRACING == 1
135  this->trace();
136 #endif
137 
138  FW_ASSERT(this->m_comp != nullptr);
139  FW_ASSERT(this->m_func != nullptr);
140 
141  DpResponsePortSerializer _serializer;
142  Fw::SerializeStatus _status = _serializer.deserializePortArgs(_buffer);
143  if (_status != Fw::FW_SERIALIZE_OK) {
144  return _status;
145  }
146 
147  this->m_func(this->m_comp, this->m_portNum, _serializer.m_id, _serializer.m_buffer, _serializer.m_status);
148 
149  return Fw::FW_SERIALIZE_OK;
150  }
151 
152 #endif
153 
154  // ----------------------------------------------------------------------
155  // Public constructors for OutputDpResponsePort
156  // ----------------------------------------------------------------------
157 
160  Fw::OutputPortBase(),
161  m_port(nullptr)
162  {
163 
164  }
165 
166  // ----------------------------------------------------------------------
167  // Public member functions for OutputDpResponsePort
168  // ----------------------------------------------------------------------
169 
172  {
174  }
175 
178  {
179  FW_ASSERT(callPort != nullptr);
180 
181  this->m_port = callPort;
182  this->m_connObj = callPort;
183 
184 #if FW_PORT_SERIALIZATION == 1
185  this->m_serPort = nullptr;
186 #endif
187  }
188 
191  FwDpIdType id,
192  const Fw::Buffer& buffer,
193  const Fw::Success& status
194  ) const
195  {
196 #if FW_PORT_TRACING == 1
197  this->trace();
198 #endif
199 
200 #if FW_PORT_SERIALIZATION
201  FW_ASSERT((this->m_port != nullptr) || (this->m_serPort != nullptr));
202 
203  if (this->m_port != nullptr) {
204  this->m_port->invoke(id, buffer, status);
205  }
206  else {
207  Fw::SerializeStatus _status;
208  DpResponsePortBuffer _buffer;
209 
210  _status = DpResponsePortSerializer::serializePortArgs(id, buffer, status, _buffer);
211  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
212 
213  _status = this->m_serPort->invokeSerial(_buffer);
214  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
215  }
216 #else
217  FW_ASSERT(this->m_port != nullptr);
218  this->m_port->invoke(id, buffer, status);
219 #endif
220  }
221 
222 #endif
223 
224 }
Serialization/Deserialization operation was successful.
InputDpResponsePort()
Constructor.
FwIndexType m_portNum
OutputDpResponsePort()
Constructor.
void addCallPort(InputDpResponsePort *callPort)
Register an input port.
virtual SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)=0
Serialize an 8-bit unsigned integer value.
static Fw::SerializeStatus serializePortArgs(FwDpIdType id, const Fw::Buffer &buffer, const Fw::Success &status, Fw::SerialBufferBase &_buffer)
Serialize port arguments into a buffer.
void invoke(FwDpIdType id, const Fw::Buffer &buffer, const Fw::Success &status) const
Invoke a port connection.
SerializeStatus
forward declaration for string
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
void init()
Initialization function.
Fw::SerializeStatus deserializePortArgs(Fw::SerialBufferBase &_buffer)
Deserialze port arguments into members.
void init() override
void init()
Initialization function.
void invoke(FwDpIdType id, const Fw::Buffer &buffer, const Fw::Success &status)
Invoke a port interface.
FwIdType FwDpIdType
The type of a data product identifier.
PassiveComponentBase * m_comp
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void init() override
Implementation of malloc based allocator.
Fw::ObjBase * m_connObj
Definition: PortBase.hpp:34
#define FW_ASSERT(...)
Definition: Assert.hpp:14
Success/Failure.