F´ Flight Software - C/C++ Documentation  NASA-v1.5.0
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PingPortAc.cpp
Go to the documentation of this file.
1 #include <FpConfig.hpp>
2 #include <Fw/Types/Assert.hpp>
4 
6 namespace Svc {
7 
8 
9  namespace {
10 
11  class PingPortBuffer : public Fw::SerializeBufferBase {
12 
13  public:
14  NATIVE_UINT_TYPE getBuffCapacity(void) const {
15  return sizeof(m_buff);
16  }
17 
18  U8* getBuffAddr(void) {
19  return m_buff;
20  }
21 
22  const U8* getBuffAddr(void) const {
23  return m_buff;
24  }
25 
26  private:
27 
29 
30  };
31 
32  }
34  Fw::InputPortBase(),
35  m_func(0) {
36  }
37 
38  void InputPingPort::init(void) {
40  }
41 
42  void InputPingPort::addCallComp(Fw::PassiveComponentBase* callComp, CompFuncPtr funcPtr) {
43  FW_ASSERT(callComp);
44  FW_ASSERT(funcPtr);
45 
46  this->m_comp = callComp;
47  this->m_func = funcPtr;
48  this->m_connObj = callComp;
49  }
50 
51  // call virtual logging function for component
52  void InputPingPort::invoke(U32 key) {
53 
54 #if FW_PORT_TRACING == 1
55  this->trace();
56 #endif
57  FW_ASSERT(this->m_comp);
58  FW_ASSERT(this->m_func);
59  this->m_func(this->m_comp, this->m_portNum, key);
60  }
61 
62 #if FW_PORT_SERIALIZATION == 1
63  Fw::SerializeStatus InputPingPort::invokeSerial(Fw::SerializeBufferBase &buffer) {
64  Fw::SerializeStatus _status;
65 #if FW_PORT_TRACING == 1
66  this->trace();
67 #endif
68  FW_ASSERT(this->m_comp);
69  FW_ASSERT(this->m_func);
70 
71 
72  U32 key;
73  _status = buffer.deserialize(key);
74  if (Fw::FW_SERIALIZE_OK != _status) {
75  return _status;
76  }
77 
78  this->m_func(this->m_comp, this->m_portNum, key);
79 
80  return Fw::FW_SERIALIZE_OK;
81  }
82 #endif
83 
85  Fw::OutputPortBase(),
86  m_port(0) {
87 }
88 
91 }
92 
94  FW_ASSERT(callPort);
95 
96  this->m_port = callPort;
97  this->m_connObj = callPort;
98 #if FW_PORT_SERIALIZATION == 1
99  this->m_serPort = 0;
100 #endif
101 }
102 
103 void OutputPingPort::invoke(U32 key) {
104 #if FW_PORT_TRACING == 1
105  this->trace();
106 #endif
107 
108 #if FW_PORT_SERIALIZATION
109  FW_ASSERT(this->m_port||this->m_serPort);
110 #else
111  FW_ASSERT(this->m_port);
112 #endif
113 
114  if (this->m_port) {
115  this->m_port->invoke(key);
116 #if FW_PORT_SERIALIZATION
117  } else if (this->m_serPort) {
118 
119  Fw::SerializeStatus status;
120 
121  PingPortBuffer _buffer;
122  status = _buffer.serialize(key);
123  FW_ASSERT(Fw::FW_SERIALIZE_OK == status,static_cast<AssertArg>(status));
124 
125  status = this->m_serPort->invokeSerial(_buffer);
126  FW_ASSERT(Fw::FW_SERIALIZE_OK == status,static_cast<AssertArg>(status));
127  }
128 #else
129  }
130 #endif
131 
132 } // end OutputPingPort::invoke(...)
133 
134 } // end namespace Svc
Svc::InputPingPort::SERIALIZED_SIZE
@ SERIALIZED_SIZE
serialized size of port arguments
Definition: PingPortAc.hpp:30
Fw::InputPortBase::m_portNum
NATIVE_INT_TYPE m_portNum
Definition: InputPortBase.hpp:29
Svc::InputPingPort::invoke
void invoke(U32 key)
invoke port interface
Definition: PingPortAc.cpp:52
Fw::SerializeBufferBase
Definition: Serializable.hpp:43
Fw::SerializeStatus
SerializeStatus
forward declaration for string
Definition: Serializable.hpp:14
Serializable.hpp
Fw::OutputPortBase::init
virtual void init(void)
Definition: OutputPortBase.cpp:23
U8
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.hpp:76
Svc::InputPingPort::init
void init(void)
initialization function
Definition: PingPortAc.cpp:38
Svc::OutputPingPort::init
void init(void)
Definition: PingPortAc.cpp:89
Svc::OutputPingPort::invoke
void invoke(U32 key)
Definition: PingPortAc.cpp:103
Assert.hpp
Fw::FW_SERIALIZE_OK
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
Definition: Serializable.hpp:15
Svc::OutputPingPort::addCallPort
void addCallPort(InputPingPort *callPort)
Definition: PingPortAc.cpp:93
Fw::PassiveComponentBase
Definition: PassiveComponentBase.hpp:10
Svc::InputPingPort
Definition: PingPortAc.hpp:27
Svc::OutputPingPort::OutputPingPort
OutputPingPort(void)
Definition: PingPortAc.cpp:84
Svc::InputPingPort::InputPingPort
InputPingPort(void)
constructor
Definition: PingPortAc.cpp:33
NATIVE_UINT_TYPE
unsigned int NATIVE_UINT_TYPE
native unsigned integer type declaration
Definition: BasicTypes.hpp:30
PingPortAc.hpp
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:9
Fw::SerializeBufferBase::deserialize
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
Definition: Serializable.cpp:292
FpConfig.hpp
ISF configuration file.
Svc
Definition: ActiveLoggerComponentAc.cpp:22
Fw::InputPortBase::m_comp
PassiveComponentBase * m_comp
Definition: InputPortBase.hpp:28
Fw::InputPortBase::init
virtual void init(void)
Definition: InputPortBase.cpp:20
Fw::PortBase::m_connObj
Fw::ObjBase * m_connObj
Definition: PortBase.hpp:33
AssertArg
#define AssertArg
Definition: FpConfig.hpp:51
Fw
Definition: BufferGetPortAc.cpp:6
Svc::InputPingPort::addCallComp
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
call to register a component
Definition: PingPortAc.cpp:42