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
LinuxTimerComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title LinuxTimerComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for LinuxTimer 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 LinuxTimerComponentBase ::
22 init(NATIVE_INT_TYPE instance)
23 {
24 // Initialize base class
26
27 // Connect output port CycleOut
28 for (
29 PlatformIntType port = 0;
30 port < static_cast<PlatformIntType>(this->getNum_CycleOut_OutputPorts());
31 port++
32 ) {
33 this->m_CycleOut_OutputPort[port].init();
34
35#if FW_OBJECT_NAMES == 1
36 // The port name consists of this->m_objName and some extra info.
37 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
38 // However, the compiler may assume that this->m_objName fills
39 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
40 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
41 // bytes to cover the extra info.
42 char portName[2*FW_OBJ_NAME_MAX_SIZE];
43 (void) snprintf(
44 portName,
45 sizeof(portName),
46 "%s_CycleOut_OutputPort[%" PRI_PlatformIntType "]",
47 this->m_objName,
48 port
49 );
50 this->m_CycleOut_OutputPort[port].setObjName(portName);
51#endif
52 }
53 }
54
55 // ----------------------------------------------------------------------
56 // Connect typed input ports to typed output ports
57 // ----------------------------------------------------------------------
58
59 void LinuxTimerComponentBase ::
60 set_CycleOut_OutputPort(
61 NATIVE_INT_TYPE portNum,
63 )
64 {
66 portNum < this->getNum_CycleOut_OutputPorts(),
67 static_cast<FwAssertArgType>(portNum)
68 );
69
70 this->m_CycleOut_OutputPort[portNum].addCallPort(port);
71 }
72
73#if FW_PORT_SERIALIZATION
74
75 // ----------------------------------------------------------------------
76 // Connect serial input ports to typed output ports
77 // ----------------------------------------------------------------------
78
79 void LinuxTimerComponentBase ::
80 set_CycleOut_OutputPort(
81 NATIVE_INT_TYPE portNum,
82 Fw::InputSerializePort* port
83 )
84 {
86 portNum < this->getNum_CycleOut_OutputPorts(),
87 static_cast<FwAssertArgType>(portNum)
88 );
89
90 this->m_CycleOut_OutputPort[portNum].registerSerialPort(port);
91 }
92
93#endif
94
95 // ----------------------------------------------------------------------
96 // Component construction and destruction
97 // ----------------------------------------------------------------------
98
99 LinuxTimerComponentBase ::
100 LinuxTimerComponentBase(const char* compName) :
101 Fw::PassiveComponentBase(compName)
102 {
103
104 }
105
106 LinuxTimerComponentBase ::
107 ~LinuxTimerComponentBase()
108 {
109
110 }
111
112 // ----------------------------------------------------------------------
113 // Getters for numbers of typed output ports
114 // ----------------------------------------------------------------------
115
116 NATIVE_INT_TYPE LinuxTimerComponentBase ::
117 getNum_CycleOut_OutputPorts() const
118 {
119 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_CycleOut_OutputPort));
120 }
121
122 // ----------------------------------------------------------------------
123 // Connection status queries for typed output ports
124 // ----------------------------------------------------------------------
125
126 bool LinuxTimerComponentBase ::
127 isConnected_CycleOut_OutputPort(NATIVE_INT_TYPE portNum)
128 {
129 FW_ASSERT(
130 portNum < this->getNum_CycleOut_OutputPorts(),
131 static_cast<FwAssertArgType>(portNum)
132 );
133
134 return this->m_CycleOut_OutputPort[portNum].isConnected();
135 }
136
137 // ----------------------------------------------------------------------
138 // Invocation functions for typed output ports
139 // ----------------------------------------------------------------------
140
141 void LinuxTimerComponentBase ::
142 CycleOut_out(
143 NATIVE_INT_TYPE portNum,
144 Svc::TimerVal& cycleStart
145 )
146 {
147 FW_ASSERT(
148 portNum < this->getNum_CycleOut_OutputPorts(),
149 static_cast<FwAssertArgType>(portNum)
150 );
151 this->m_CycleOut_OutputPort[portNum].invoke(
152 cycleStart
153 );
154 }
155
156}
#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
Serializable class for carrying timer values.
Definition TimerVal.hpp:22