F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
PortBase.cpp
Go to the documentation of this file.
2#include <FpConfig.hpp>
4#include <cstdio>
5#include "Fw/Types/Assert.hpp"
6
7#if FW_PORT_TRACING
8void setConnTrace(bool trace) {
9 Fw::PortBase::setTrace(trace);
10}
11
12namespace Fw {
13 bool PortBase::s_trace = false;
14}
15
16#endif // FW_PORT_TRACING
17
18namespace Fw {
19
21 :
22 Fw::ObjBase(nullptr),
23 m_connObj(nullptr)
24#if FW_PORT_TRACING == 1
25 ,m_trace(false),
26 m_ovr_trace(false)
27#endif
28 {
29
30 }
31
33
34 }
35
38
39 }
40
42 return m_connObj == nullptr?false:true;
43 }
44
45#if FW_PORT_TRACING == 1
46
47 void PortBase::trace() {
48 bool do_trace = false;
49
50 if (this->m_ovr_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", reinterpret_cast<POINTER_CAST>(this->m_objName), 0, 0, 0, 0, 0);
61#else
62 Fw::Logger::logMsg("Trace: %p\n", reinterpret_cast<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::ovrTrace(bool ovr, bool trace) {
72 this->m_ovr_trace = ovr;
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
#define FW_ASSERT(...)
Definition Assert.hpp:7
PlatformPointerCastType POINTER_CAST
Definition BasicTypes.h:53
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
#define FW_PORT_TRACING
Indicates whether port calls are traced (more code, more visibility into execution)
Definition FpConfig.h:125
C++-compatible configuration header for fprime configuration.
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
Brief class description.
Definition ObjBase.hpp:32
void init()
Object initializer.
Definition ObjBase.cpp:27
virtual void init()
Definition PortBase.cpp:36
bool isConnected()
Definition PortBase.cpp:41
virtual ~PortBase()
Definition PortBase.cpp:32
Fw::ObjBase * m_connObj
Definition PortBase.hpp:33
Definition Buffer.cpp:21