F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
EnableSectionPortAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title EnableSectionPortAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for EnableSection port
5 // ======================================================================
6 
7 #include "Fw/Types/Assert.hpp"
9 
10 namespace Svc {
11 
12  // ----------------------------------------------------------------------
13  // Public constructors for EnableSectionPortSerializer
14  // ----------------------------------------------------------------------
15 
18  m_section(),
19  m_enabled()
20  {
21 
22  }
23 
24  // ----------------------------------------------------------------------
25  // Public member functions for EnableSectionPortSerializer
26  // ----------------------------------------------------------------------
27 
30  {
32  if (_status == Fw::FW_SERIALIZE_OK) {
33  _status = _buffer.deserializeTo(m_section);
34  }
35  if (_status == Fw::FW_SERIALIZE_OK) {
36  _status = _buffer.deserializeTo(m_enabled);
37  }
38  return _status;
39  }
40 
41  // ----------------------------------------------------------------------
42  // Public static functions for EnableSectionPortSerializer
43  // ----------------------------------------------------------------------
44 
47  const Svc::TelemetrySection& section,
48  const Fw::Enabled& enabled,
49  Fw::SerialBufferBase& _buffer
50  )
51  {
53  if (_status == Fw::FW_SERIALIZE_OK) {
54  _status = _buffer.serializeFrom(section);
55  }
56  if (_status == Fw::FW_SERIALIZE_OK) {
57  _status = _buffer.serializeFrom(enabled);
58  }
59  return _status;
60  }
61 
62 #if !FW_DIRECT_PORT_CALLS
63 
64  // ----------------------------------------------------------------------
65  // Public constructors for InputEnableSectionPort
66  // ----------------------------------------------------------------------
67 
70  Fw::InputPortBase(),
71  m_func(nullptr)
72  {
73 
74  }
75 
76  // ----------------------------------------------------------------------
77  // Public member functions for InputEnableSectionPort
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 
102  const Svc::TelemetrySection& section,
103  const Fw::Enabled& enabled
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, section, enabled);
114  }
115 
116  // ----------------------------------------------------------------------
117  // Private member functions for InputEnableSectionPort
118  // ----------------------------------------------------------------------
119 
120 #if FW_PORT_SERIALIZATION == 1
121 
122  Fw::SerializeStatus InputEnableSectionPort ::
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  EnableSectionPortSerializer _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_section, _serializer.m_enabled);
139 
140  return Fw::FW_SERIALIZE_OK;
141  }
142 
143 #endif
144 
145  // ----------------------------------------------------------------------
146  // Public constructors for OutputEnableSectionPort
147  // ----------------------------------------------------------------------
148 
151  Fw::OutputPortBase(),
152  m_port(nullptr)
153  {
154 
155  }
156 
157  // ----------------------------------------------------------------------
158  // Public member functions for OutputEnableSectionPort
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  const Svc::TelemetrySection& section,
183  const Fw::Enabled& enabled
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(section, enabled);
195  }
196  else {
197  Fw::SerializeStatus _status;
198  EnableSectionPortBuffer _buffer;
199 
200  _status = EnableSectionPortSerializer::serializePortArgs(section, enabled, _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(section, enabled);
209 #endif
210  }
211 
212 #endif
213 
214 }
Serialization/Deserialization operation was successful.
FwIndexType m_portNum
virtual SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)=0
Serialize an 8-bit unsigned integer value.
static Fw::SerializeStatus serializePortArgs(const Svc::TelemetrySection &section, const Fw::Enabled &enabled, Fw::SerialBufferBase &_buffer)
Serialize port arguments into a buffer.
SerializeStatus
forward declaration for string
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
void init() override
void init()
Initialization function.
Enabled and disabled states.
void init()
Initialization function.
void addCallPort(InputEnableSectionPort *callPort)
Register an input port.
PassiveComponentBase * m_comp
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void invoke(const Svc::TelemetrySection &section, const Fw::Enabled &enabled) const
Invoke a port connection.
void init() override
RateGroupDivider component implementation.
Fw::SerializeStatus deserializePortArgs(Fw::SerialBufferBase &_buffer)
Deserialze port arguments into members.
void invoke(const Svc::TelemetrySection &section, const Fw::Enabled &enabled)
Invoke a port interface.
Implementation of malloc based allocator.
Fw::ObjBase * m_connObj
Definition: PortBase.hpp:34
#define FW_ASSERT(...)
Definition: Assert.hpp:14