F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
PrmSetPortAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title PrmSetPortAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for PrmSet port
5 // ======================================================================
6 
8 #include "Fw/Types/Assert.hpp"
9 
10 namespace Fw {
11 
12  // ----------------------------------------------------------------------
13  // Public constructors for PrmSetPortSerializer
14  // ----------------------------------------------------------------------
15 
18  m_id(),
19  m_val()
20  {
21 
22  }
23 
24  // ----------------------------------------------------------------------
25  // Public member functions for PrmSetPortSerializer
26  // ----------------------------------------------------------------------
27 
30  {
32  if (_status == Fw::FW_SERIALIZE_OK) {
33  _status = _buffer.deserializeTo(m_id);
34  }
35  if (_status == Fw::FW_SERIALIZE_OK) {
36  _status = _buffer.deserializeTo(m_val);
37  }
38  return _status;
39  }
40 
41  // ----------------------------------------------------------------------
42  // Public static functions for PrmSetPortSerializer
43  // ----------------------------------------------------------------------
44 
47  FwPrmIdType id,
48  Fw::ParamBuffer& val,
49  Fw::SerialBufferBase& _buffer
50  )
51  {
53  if (_status == Fw::FW_SERIALIZE_OK) {
54  _status = _buffer.serializeFrom(id);
55  }
56  if (_status == Fw::FW_SERIALIZE_OK) {
57  _status = _buffer.serializeFrom(val);
58  }
59  return _status;
60  }
61 
62 #if !FW_DIRECT_PORT_CALLS
63 
64  // ----------------------------------------------------------------------
65  // Public constructors for InputPrmSetPort
66  // ----------------------------------------------------------------------
67 
70  Fw::InputPortBase(),
71  m_func(nullptr)
72  {
73 
74  }
75 
76  // ----------------------------------------------------------------------
77  // Public member functions for InputPrmSetPort
78  // ----------------------------------------------------------------------
79 
82  {
84  }
85 
88  Fw::PassiveComponentBase* callComp,
89  CompFuncPtr funcPtr
90  )
91  {
92  FW_ASSERT(callComp != nullptr);
93  FW_ASSERT(funcPtr != nullptr);
94 
95  this->m_comp = callComp;
96  this->m_func = funcPtr;
97  this->m_connObj = callComp;
98  }
99 
100  void InputPrmSetPort ::
102  FwPrmIdType id,
103  Fw::ParamBuffer& val
104  )
105  {
106 #if FW_PORT_TRACING == 1
107  this->trace();
108 #endif
109 
110  FW_ASSERT(this->m_comp != nullptr);
111  FW_ASSERT(this->m_func != nullptr);
112 
113  return this->m_func(this->m_comp, this->m_portNum, id, val);
114  }
115 
116  // ----------------------------------------------------------------------
117  // Private member functions for InputPrmSetPort
118  // ----------------------------------------------------------------------
119 
120 #if FW_PORT_SERIALIZATION == 1
121 
122  Fw::SerializeStatus InputPrmSetPort ::
123  invokeSerial(Fw::LinearBufferBase& _buffer)
124  {
125 #if FW_PORT_TRACING == 1
126  this->trace();
127 #endif
128 
129  FW_ASSERT(this->m_comp != nullptr);
130  FW_ASSERT(this->m_func != nullptr);
131 
132  PrmSetPortSerializer _serializer;
133  Fw::SerializeStatus _status = _serializer.deserializePortArgs(_buffer);
134  if (_status != Fw::FW_SERIALIZE_OK) {
135  return _status;
136  }
137 
138  this->m_func(this->m_comp, this->m_portNum, _serializer.m_id, _serializer.m_val);
139 
140  return Fw::FW_SERIALIZE_OK;
141  }
142 
143 #endif
144 
145  // ----------------------------------------------------------------------
146  // Public constructors for OutputPrmSetPort
147  // ----------------------------------------------------------------------
148 
151  Fw::OutputPortBase(),
152  m_port(nullptr)
153  {
154 
155  }
156 
157  // ----------------------------------------------------------------------
158  // Public member functions for OutputPrmSetPort
159  // ----------------------------------------------------------------------
160 
163  {
165  }
166 
169  {
170  FW_ASSERT(callPort != nullptr);
171 
172  this->m_port = callPort;
173  this->m_connObj = callPort;
174 
175 #if FW_PORT_SERIALIZATION == 1
176  this->m_serPort = nullptr;
177 #endif
178  }
179 
182  FwPrmIdType id,
183  Fw::ParamBuffer& val
184  ) const
185  {
186 #if FW_PORT_TRACING == 1
187  this->trace();
188 #endif
189 
190 #if FW_PORT_SERIALIZATION
191  FW_ASSERT((this->m_port != nullptr) || (this->m_serPort != nullptr));
192 
193  if (this->m_port != nullptr) {
194  this->m_port->invoke(id, val);
195  }
196  else {
197  Fw::SerializeStatus _status;
198  PrmSetPortBuffer _buffer;
199 
200  _status = PrmSetPortSerializer::serializePortArgs(id, val, _buffer);
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(id, val);
209 #endif
210  }
211 
212 #endif
213 
214 }
Serialization/Deserialization operation was successful.
PrmSetPortSerializer()
Constructor.
FwIndexType m_portNum
FwIdType FwPrmIdType
The type of a parameter identifier.
void addCallPort(InputPrmSetPort *callPort)
Register an input port.
virtual SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)=0
Serialize an 8-bit unsigned integer value.
void init()
Initialization function.
SerializeStatus
forward declaration for string
static Fw::SerializeStatus serializePortArgs(FwPrmIdType id, Fw::ParamBuffer &val, Fw::SerialBufferBase &_buffer)
Serialize port arguments into a buffer.
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
void init() override
InputPrmSetPort()
Constructor.
void invoke(FwPrmIdType id, Fw::ParamBuffer &val)
Invoke a port interface.
PassiveComponentBase * m_comp
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void init() override
void invoke(FwPrmIdType id, Fw::ParamBuffer &val) const
Invoke a port connection.
Implementation of malloc based allocator.
Fw::SerializeStatus deserializePortArgs(Fw::SerialBufferBase &_buffer)
Deserialze port arguments into members.
Fw::ObjBase * m_connObj
Definition: PortBase.hpp:34
#define FW_ASSERT(...)
Definition: Assert.hpp:14
void init()
Initialization function.
OutputPrmSetPort()
Constructor.