F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
PolyPortAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title PolyPortAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for Poly 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 PolyPortBuffer : 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::PolyDbCfg::PolyDbEntry& entry,
78  Svc::MeasurementStatus& status,
79  Fw::Time& time,
80  Fw::PolyType& val
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, entry, status, time, val);
91  }
92 
93 #if FW_PORT_SERIALIZATION == 1
94 
95  Fw::SerializeStatus InputPolyPort ::
96  invokeSerial(Fw::SerializeBufferBase& _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 
108  _status = _buffer.deserialize(entry);
109  if (_status != Fw::FW_SERIALIZE_OK) {
110  return _status;
111  }
112 
113  Svc::MeasurementStatus status;
114  _status = _buffer.deserialize(status);
115  if (_status != Fw::FW_SERIALIZE_OK) {
116  return _status;
117  }
118 
119  Fw::Time time;
120  _status = _buffer.deserialize(time);
121  if (_status != Fw::FW_SERIALIZE_OK) {
122  return _status;
123  }
124 
125  Fw::PolyType val;
126  _status = _buffer.deserialize(val);
127  if (_status != Fw::FW_SERIALIZE_OK) {
128  return _status;
129  }
130 
131  this->m_func(this->m_comp, this->m_portNum, entry, status, time, val);
132 
133  return Fw::FW_SERIALIZE_OK;
134  }
135 
136 #endif
137 
138  // ----------------------------------------------------------------------
139  // Output Port Member functions
140  // ----------------------------------------------------------------------
141 
143  OutputPolyPort() :
144  Fw::OutputPortBase(),
145  m_port(nullptr)
146  {
147 
148  }
149 
151  init()
152  {
154  }
155 
157  addCallPort(InputPolyPort* callPort)
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(
171  const Svc::PolyDbCfg::PolyDbEntry& entry,
172  Svc::MeasurementStatus& status,
173  Fw::Time& time,
174  Fw::PolyType& val
175  )
176  {
177 #if FW_PORT_TRACING == 1
178  this->trace();
179 #endif
180 
181 #if FW_PORT_SERIALIZATION
182  FW_ASSERT((this->m_port != nullptr) || (this->m_serPort != nullptr));
183 
184  if (this->m_port != nullptr) {
185  this->m_port->invoke(entry, status, time, val);
186  }
187  else {
188  Fw::SerializeStatus _status;
189  PolyPortBuffer _buffer;
190 
191  _status = _buffer.serialize(entry);
192  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
193 
194  _status = _buffer.serialize(status);
195  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
196 
197  _status = _buffer.serialize(time);
198  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
199 
200  _status = _buffer.serialize(val);
201  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
202 
203  _status = this->m_serPort->invokeSerial(_buffer);
204  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
205  }
206 #else
207  FW_ASSERT(this->m_port != nullptr);
208  this->m_port->invoke(entry, status, time, val);
209 #endif
210  }
211 
212 }
#define FW_ASSERT(...)
Definition: Assert.hpp:14
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:30
PlatformAssertArgType FwAssertArgType
Definition: FpConfig.h:39
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
Definition: Time.hpp:9
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: PolyPortAc.cpp:62
void init()
Initialization function.
Definition: PolyPortAc.cpp:56
InputPolyPort()
Constructor.
Definition: PolyPortAc.cpp:48
void invoke(const Svc::PolyDbCfg::PolyDbEntry &entry, Svc::MeasurementStatus &status, Fw::Time &time, Fw::PolyType &val)
Invoke a port interface.
Definition: PolyPortAc.cpp:76
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition: PolyPortAc.hpp:40
An enumeration for measurement status.
void addCallPort(InputPolyPort *callPort)
Register an input port.
Definition: PolyPortAc.cpp:157
OutputPolyPort()
Constructor.
Definition: PolyPortAc.cpp:143
void init()
Initialization function.
Definition: PolyPortAc.cpp:151
void invoke(const Svc::PolyDbCfg::PolyDbEntry &entry, Svc::MeasurementStatus &status, Fw::Time &time, Fw::PolyType &val)
Invoke a port interface.
Definition: PolyPortAc.cpp:170
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.