F´ Flight Software - C/C++ Documentation  NASA-v2.1.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
PortBase.cpp
Go to the documentation of this file.
1 #include <Fw/Port/PortBase.hpp>
3 #include <Fw/Logger/Logger.hpp>
4 #include "Fw/Types/Assert.hpp"
5 #include <stdio.h>
6 
7 #if FW_PORT_TRACING
8 void setConnTrace(bool trace) {
9  Fw::PortBase::setTrace(trace);
10 }
11 
12 namespace Fw {
13  bool PortBase::s_trace = false;
14 }
15 
16 #endif // FW_PORT_TRACING
17 
18 namespace Fw {
19 
21  :
22  Fw::ObjBase(0),
23  m_connObj(0)
24 #if FW_PORT_TRACING == 1
25  ,m_trace(false),
26  m_override_trace(false)
27 #endif
28  {
29 
30  }
31 
33 
34  }
35 
36  void PortBase::init(void) {
37  ObjBase::init();
38 
39  }
40 
41  bool PortBase::isConnected(void) {
42  return m_connObj == 0?false:true;
43  }
44 
45 #if FW_PORT_TRACING == 1
46 
47  void PortBase::trace(void) {
48  bool do_trace = false;
49 
50  if (this->m_override_trace) {
51  if (this->m_trace) {
52  do_trace = true;
53  }
54  } else if (PortBase::s_trace) {
55  do_trace = true;
56  }
57 
58  if (do_trace) {
59 #if FW_OBJECT_NAMES == 1
60  Fw::Logger::logMsg("Trace: %s\n", (POINTER_CAST)this->m_objName, 0, 0, 0, 0, 0);
61 #else
62  Fw::Logger::logMsg("Trace: %p\n", (POINTER_CAST)this, 0, 0, 0, 0, 0);
63 #endif
64  }
65  }
66 
67  void PortBase::setTrace(bool trace) {
68  PortBase::s_trace = trace;
69  }
70 
71  void PortBase::overrideTrace(bool override, bool trace) {
72  this->m_override_trace = override;
73  this->m_trace = trace;
74  }
75 
76 #endif // FW_PORT_TRACING
77 
78 #if FW_OBJECT_NAMES == 1
79 #if FW_OBJECT_TO_STRING == 1
80  void PortBase::toString(char* buffer, NATIVE_INT_TYPE size) {
81  FW_ASSERT(size > 0);
82  if (snprintf(buffer, size, "Port: %s %s->(%s)", this->m_objName, this->m_connObj ? "C" : "NC",
83  this->m_connObj ? this->m_connObj->getObjName() : "None") < 0) {
84  buffer[0] = 0;
85  }
86  }
87 #endif // FW_OBJECT_TO_STRING
88 #endif // FW_OBJECT_NAMES
89 
90 
91 }
92 
Fw::ObjBase
Brief class description.
Definition: ObjBase.hpp:33
Fw::PortBase::init
virtual void init(void)
Definition: PortBase.cpp:36
Fw::PortBase::isConnected
bool isConnected(void)
Definition: PortBase.cpp:41
Fw::PortBase::PortBase
PortBase()
Definition: PortBase.cpp:20
Assert.hpp
Fw::ObjBase::init
void init(void)
Object initializer.
Definition: ObjBase.cpp:27
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:9
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:32
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:134
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:29
Logger.hpp
Fw
Definition: Buffer.cpp:21