F´ Flight Software - C/C++ Documentation  NASA-v2.0.1
A framework for building embedded system applications to NASA flight quality standards.
PortBase.cpp
Go to the documentation of this file.
1 #include <Fw/Port/PortBase.hpp>
3 #include <Fw/Logger/Logger.hpp>
4 #include <stdio.h>
5 
6 #if FW_PORT_TRACING
7 void setConnTrace(bool trace) {
8  Fw::PortBase::setTrace(trace);
9 }
10 
11 namespace Fw {
12  bool PortBase::s_trace = false;
13 }
14 
15 #endif // FW_PORT_TRACING
16 
17 namespace Fw {
18 
20  :
21  Fw::ObjBase(0),
22  m_connObj(0)
23 #if FW_PORT_TRACING == 1
24  ,m_trace(false),
25  m_override_trace(false)
26 #endif
27  {
28 
29  }
30 
32 
33  }
34 
35  void PortBase::init(void) {
36  ObjBase::init();
37 
38  }
39 
40  bool PortBase::isConnected(void) {
41  return m_connObj == 0?false:true;
42  }
43 
44 #if FW_PORT_TRACING == 1
45 
46  void PortBase::trace(void) {
47  bool do_trace = false;
48 
49  if (this->m_override_trace) {
50  if (this->m_trace) {
51  do_trace = true;
52  }
53  } else if (PortBase::s_trace) {
54  do_trace = true;
55  }
56 
57  if (do_trace) {
58 #if FW_OBJECT_NAMES == 1
59  Fw::Logger::logMsg("Trace: %s\n", (POINTER_CAST)this->m_objName, 0, 0, 0, 0, 0);
60 #else
61  Fw::Logger::logMsg("Trace: %p\n", (POINTER_CAST)this, 0, 0, 0, 0, 0);
62 #endif
63  }
64  }
65 
66  void PortBase::setTrace(bool trace) {
67  PortBase::s_trace = trace;
68  }
69 
70  void PortBase::overrideTrace(bool override, bool trace) {
71  this->m_override_trace = override;
72  this->m_trace = trace;
73  }
74 
75 #endif // FW_PORT_TRACING
76 
77 #if FW_OBJECT_NAMES == 1
78 #if FW_OBJECT_TO_STRING == 1
79  void PortBase::toString(char* buffer, NATIVE_INT_TYPE size) {
80  (void)snprintf(buffer, size, "Port: %s %s->(%s)", this->m_objName, this->m_connObj ? "C" : "NC",
81  this->m_connObj ? this->m_connObj->getObjName() : "None");
82  // NULL terminate
83  buffer[size-1] = 0;
84  }
85 #endif // FW_OBJECT_TO_STRING
86 #endif // FW_OBJECT_NAMES
87 
88 
89 }
90 
Fw::ObjBase
Brief class description.
Definition: ObjBase.hpp:33
Fw::PortBase::init
virtual void init(void)
Definition: PortBase.cpp:35
Fw::PortBase::isConnected
bool isConnected(void)
Definition: PortBase.cpp:40
Fw::PortBase::PortBase
PortBase()
Definition: PortBase.cpp:19
Fw::ObjBase::init
void init(void)
Object initializer.
Definition: ObjBase.cpp:26
PortBase.hpp
Fw::Logger::logMsg
static void logMsg(const char *fmt, POINTER_CAST a0=0, POINTER_CAST a1=0, POINTER_CAST a2=0, POINTER_CAST a3=0, POINTER_CAST a4=0, POINTER_CAST a5=0, POINTER_CAST a6=0, POINTER_CAST a7=0, POINTER_CAST a8=0, POINTER_CAST a9=0)
Definition: Logger.cpp:18
Fw::PortBase::~PortBase
virtual ~PortBase()
Definition: PortBase.cpp:31
BasicTypes.hpp
Declares ISF basic types.
Fw::PortBase::m_connObj
Fw::ObjBase * m_connObj
Definition: PortBase.hpp:33
FW_PORT_TRACING
#define FW_PORT_TRACING
Indicates whether port calls are traced (more code, more visibility into execution)
Definition: FpConfig.hpp:130
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:29
Logger.hpp
Fw
Definition: Buffer.cpp:21