F´ Flight Software - C/C++ Documentation
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
35
38
39 }
40
41 bool PortBase::isConnected() const {
42 return m_connObj == nullptr?false:true;
43 }
44
45#if FW_PORT_TRACING == 1
46
47 void PortBase::trace() const {
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::log("Trace: %s\n", this->m_objName.toChar());
61#else
62 Fw::Logger::log("Trace: %p\n", this);
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, static_cast<size_t>(size), "Port: %s %s->(%s)", this->m_objName.toChar(), 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:14
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:55
#define FW_PORT_TRACING
Indicates whether port calls are traced (more code, more visibility into execution)
Definition FpConfig.h:199
C++-compatible configuration header for fprime configuration.
static void log(const char *format,...)
log a formated string with supplied arguments
Definition Logger.cpp:21
Brief class description.
Definition ObjBase.hpp:35
void init()
Object initializer.
Definition ObjBase.cpp:27
virtual void init()
Definition PortBase.cpp:36
virtual ~PortBase()
Definition PortBase.cpp:32
bool isConnected() const
Definition PortBase.cpp:41
Fw::ObjBase * m_connObj
Definition PortBase.hpp:33