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