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
CyclePortAc.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 CyclePortBuffer : 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 InputCyclePort::init(void) {
40  }
41 
42  void InputCyclePort::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
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, cycleStart);
60  }
61 
62 #if FW_PORT_SERIALIZATION == 1
63  Fw::SerializeStatus InputCyclePort::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  Svc::TimerVal cycleStart;
73  _status = buffer.deserialize(cycleStart);
74  if (Fw::FW_SERIALIZE_OK != _status) {
75  return _status;
76  }
77 
78  this->m_func(this->m_comp, this->m_portNum, cycleStart);
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 
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(cycleStart);
116 #if FW_PORT_SERIALIZATION
117  } else if (this->m_serPort) {
118 
119  Fw::SerializeStatus status;
120 
121  CyclePortBuffer _buffer;
122  status = _buffer.serialize(cycleStart);
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 OutputCyclePort::invoke(...)
133 
134 } // end namespace Svc
Fw::InputPortBase::m_portNum
NATIVE_INT_TYPE m_portNum
Definition: InputPortBase.hpp:29
Svc::OutputCyclePort::init
void init(void)
Definition: CyclePortAc.cpp:89
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::InputCyclePort::InputCyclePort
InputCyclePort(void)
constructor
Definition: CyclePortAc.cpp:33
Assert.hpp
Fw::FW_SERIALIZE_OK
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
Definition: Serializable.hpp:15
Svc::OutputCyclePort::OutputCyclePort
OutputCyclePort(void)
Definition: CyclePortAc.cpp:84
Svc::InputCyclePort
Definition: CyclePortAc.hpp:28
Fw::PassiveComponentBase
Definition: PassiveComponentBase.hpp:10
Svc::TimerVal
Serializable class for carrying timer values.
Definition: TimerVal.hpp:22
Svc::OutputCyclePort::invoke
void invoke(Svc::TimerVal &cycleStart)
Definition: CyclePortAc.cpp:103
NATIVE_UINT_TYPE
unsigned int NATIVE_UINT_TYPE
native unsigned integer type declaration
Definition: BasicTypes.hpp:30
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:9
Svc::OutputCyclePort::addCallPort
void addCallPort(InputCyclePort *callPort)
Definition: CyclePortAc.cpp:93
CyclePortAc.hpp
Svc::InputCyclePort::SERIALIZED_SIZE
@ SERIALIZED_SIZE
serialized size of port arguments
Definition: CyclePortAc.hpp:31
Fw::SerializeBufferBase::deserialize
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
Definition: Serializable.cpp:292
FpConfig.hpp
ISF configuration file.
Svc::InputCyclePort::init
void init(void)
initialization function
Definition: CyclePortAc.cpp:38
Svc
Definition: ActiveLoggerComponentAc.cpp:22
Svc::InputCyclePort::addCallComp
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
call to register a component
Definition: CyclePortAc.cpp:42
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::InputCyclePort::invoke
void invoke(Svc::TimerVal &cycleStart)
invoke port interface
Definition: CyclePortAc.cpp:52