F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
PassiveTextLoggerComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title PassiveTextLoggerComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for PassiveTextLogger component base class
5 // ======================================================================
6 
7 #include <cstdio>
8 
10 #include "Fw/Types/Assert.hpp"
11 #if FW_ENABLE_TEXT_LOGGING
12 #include "Fw/Types/String.hpp"
13 #endif
14 
15 namespace Svc {
16 
17  // ----------------------------------------------------------------------
18  // Component initialization
19  // ----------------------------------------------------------------------
20 
22  init(NATIVE_INT_TYPE instance)
23  {
24  // Initialize base class
26 
27  // Connect input port TextLogger
28  for (
29  PlatformIntType port = 0;
30  port < static_cast<PlatformIntType>(this->getNum_TextLogger_InputPorts());
31  port++
32  ) {
33  this->m_TextLogger_InputPort[port].init();
34  this->m_TextLogger_InputPort[port].addCallComp(
35  this,
36  m_p_TextLogger_in
37  );
38  this->m_TextLogger_InputPort[port].setPortNum(port);
39 
40 #if FW_OBJECT_NAMES == 1
41  // The port name consists of this->m_objName and some extra info.
42  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
43  // However, the compiler may assume that this->m_objName fills
44  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
45  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
46  // bytes to cover the extra info.
47  char portName[2*FW_OBJ_NAME_MAX_SIZE];
48  (void) snprintf(
49  portName,
50  sizeof(portName),
51  "%s_TextLogger_InputPort[%" PRI_PlatformIntType "]",
52  this->m_objName,
53  port
54  );
55  this->m_TextLogger_InputPort[port].setObjName(portName);
56 #endif
57  }
58  }
59 
60  // ----------------------------------------------------------------------
61  // Getters for typed input ports
62  // ----------------------------------------------------------------------
63 
66  {
67  FW_ASSERT(
68  portNum < this->getNum_TextLogger_InputPorts(),
69  static_cast<FwAssertArgType>(portNum)
70  );
71 
72  return &this->m_TextLogger_InputPort[portNum];
73  }
74 
75  // ----------------------------------------------------------------------
76  // Component construction and destruction
77  // ----------------------------------------------------------------------
78 
80  PassiveTextLoggerComponentBase(const char* compName) :
81  Fw::PassiveComponentBase(compName)
82  {
83 
84  }
85 
88  {
89 
90  }
91 
92  // ----------------------------------------------------------------------
93  // Getters for numbers of typed input ports
94  // ----------------------------------------------------------------------
95 
98  {
99  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_TextLogger_InputPort));
100  }
101 
102  // ----------------------------------------------------------------------
103  // Port handler base-class functions for typed input ports
104  //
105  // Call these functions directly to bypass the corresponding ports
106  // ----------------------------------------------------------------------
107 
110  NATIVE_INT_TYPE portNum,
111  FwEventIdType id,
112  Fw::Time& timeTag,
113  const Fw::LogSeverity& severity,
114  Fw::TextLogString& text
115  )
116  {
117  // Make sure port number is valid
118  FW_ASSERT(
119  portNum < this->getNum_TextLogger_InputPorts(),
120  static_cast<FwAssertArgType>(portNum)
121  );
122 
123  // Call handler function
124  this->TextLogger_handler(
125  portNum,
126  id,
127  timeTag,
128  severity,
129  text
130  );
131  }
132 
133  // ----------------------------------------------------------------------
134  // Calls for messages received on typed input ports
135  // ----------------------------------------------------------------------
136 
137  void PassiveTextLoggerComponentBase ::
138  m_p_TextLogger_in(
139  Fw::PassiveComponentBase* callComp,
140  NATIVE_INT_TYPE portNum,
141  FwEventIdType id,
142  Fw::Time& timeTag,
143  const Fw::LogSeverity& severity,
144  Fw::TextLogString& text
145  )
146  {
147  FW_ASSERT(callComp);
148  PassiveTextLoggerComponentBase* compPtr = static_cast<PassiveTextLoggerComponentBase*>(callComp);
149  compPtr->TextLogger_handlerBase(
150  portNum,
151  id,
152  timeTag,
153  severity,
154  text
155  );
156  }
157 
158 }
#define FW_ASSERT(...)
Definition: Assert.hpp:14
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:51
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:66
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
#define PRI_PlatformIntType
PlatformAssertArgType FwAssertArgType
Definition: FpConfig.h:21
U32 FwEventIdType
Definition: FpConfig.h:62
#define FW_OBJ_NAME_MAX_SIZE
Size of object name (if object names enabled). AC Limits to 80, truncation occurs above 80.
Definition: FpConfig.h:184
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void init()
Initialization function.
void setPortNum(NATIVE_INT_TYPE portNum)
Enum representing event severity.
void init()
Object initializer.
Definition: ObjBase.cpp:27
Definition: Time.hpp:9
Auto-generated base for PassiveTextLogger component.
virtual void TextLogger_handler(NATIVE_INT_TYPE portNum, FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::TextLogString &text)=0
Handler for input port TextLogger.
virtual ~PassiveTextLoggerComponentBase()
Destroy PassiveTextLoggerComponentBase object.
Fw::InputLogTextPort * get_TextLogger_InputPort(NATIVE_INT_TYPE portNum)
void TextLogger_handlerBase(NATIVE_INT_TYPE portNum, FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::TextLogString &text)
Handler base-class function for input port TextLogger.
PassiveTextLoggerComponentBase(const char *compName="")
Construct PassiveTextLoggerComponentBase object.