F´ Flight Software - C/C++ Documentation devel
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PosixTimeComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title PosixTimeComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for PosixTime 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
15namespace Svc {
16
17 // ----------------------------------------------------------------------
18 // Component initialization
19 // ----------------------------------------------------------------------
20
21 void PosixTimeComponentBase ::
22 init(NATIVE_INT_TYPE instance)
23 {
24 // Initialize base class
26
27 // Connect input port timeGetPort
28 for (
29 PlatformIntType port = 0;
30 port < static_cast<PlatformIntType>(this->getNum_timeGetPort_InputPorts());
31 port++
32 ) {
33 this->m_timeGetPort_InputPort[port].init();
34 this->m_timeGetPort_InputPort[port].addCallComp(
35 this,
36 m_p_timeGetPort_in
37 );
38 this->m_timeGetPort_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_timeGetPort_InputPort[%" PRI_PlatformIntType "]",
52 this->m_objName,
53 port
54 );
55 this->m_timeGetPort_InputPort[port].setObjName(portName);
56#endif
57 }
58 }
59
60 // ----------------------------------------------------------------------
61 // Getters for typed input ports
62 // ----------------------------------------------------------------------
63
64 Fw::InputTimePort* PosixTimeComponentBase ::
65 get_timeGetPort_InputPort(NATIVE_INT_TYPE portNum)
66 {
68 portNum < this->getNum_timeGetPort_InputPorts(),
69 static_cast<FwAssertArgType>(portNum)
70 );
71
72 return &this->m_timeGetPort_InputPort[portNum];
73 }
74
75 // ----------------------------------------------------------------------
76 // Component construction and destruction
77 // ----------------------------------------------------------------------
78
79 PosixTimeComponentBase ::
80 PosixTimeComponentBase(const char* compName) :
81 Fw::PassiveComponentBase(compName)
82 {
83
84 }
85
86 PosixTimeComponentBase ::
87 ~PosixTimeComponentBase()
88 {
89
90 }
91
92 // ----------------------------------------------------------------------
93 // Getters for numbers of typed input ports
94 // ----------------------------------------------------------------------
95
96 NATIVE_INT_TYPE PosixTimeComponentBase ::
97 getNum_timeGetPort_InputPorts() const
98 {
99 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_timeGetPort_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
108 void PosixTimeComponentBase ::
109 timeGetPort_handlerBase(
110 NATIVE_INT_TYPE portNum,
111 Fw::Time& time
112 )
113 {
114 // Make sure port number is valid
115 FW_ASSERT(
116 portNum < this->getNum_timeGetPort_InputPorts(),
117 static_cast<FwAssertArgType>(portNum)
118 );
119
120 // Call handler function
121 this->timeGetPort_handler(
122 portNum,
123 time
124 );
125 }
126
127 // ----------------------------------------------------------------------
128 // Calls for messages received on typed input ports
129 // ----------------------------------------------------------------------
130
131 void PosixTimeComponentBase ::
132 m_p_timeGetPort_in(
133 Fw::PassiveComponentBase* callComp,
134 NATIVE_INT_TYPE portNum,
135 Fw::Time& time
136 )
137 {
138 FW_ASSERT(callComp);
139 PosixTimeComponentBase* compPtr = static_cast<PosixTimeComponentBase*>(callComp);
141 portNum,
142 time
143 );
144 }
145
146}
#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
void init()
Object initializer.
Definition ObjBase.cpp:27
Auto-generated base for PosixTime component.
void timeGetPort_handlerBase(NATIVE_INT_TYPE portNum, Fw::Time &time)
Handler base-class function for input port timeGetPort.