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