Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
rtt
extras
FileDescriptorSimulationActivity.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
3
***************************************************************************
4
* This library is free software; you can redistribute it and/or *
5
* modify it under the terms of the GNU General Public *
6
* License as published by the Free Software Foundation; *
7
* version 2 of the License. *
8
* *
9
* As a special exception, you may use this file as part of a free *
10
* software library without restriction. Specifically, if other files *
11
* instantiate templates or use macros or inline functions from this *
12
* file, or you compile this file and link it with other files to *
13
* produce an executable, this file does not by itself cause the *
14
* resulting executable to be covered by the GNU General Public *
15
* License. This exception does not however invalidate any other *
16
* reasons why the executable file might be covered by the GNU General *
17
* Public License. *
18
* *
19
* This library is distributed in the hope that it will be useful, *
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22
* Lesser General Public License for more details. *
23
* *
24
* You should have received a copy of the GNU General Public *
25
* License along with this library; if not, write to the Free Software *
26
* Foundation, Inc., 59 Temple Place, *
27
* Suite 330, Boston, MA 02111-1307 USA *
28
* *
29
***************************************************************************/
30
31
#include "
FileDescriptorSimulationActivity.hpp
"
32
#include "
os/MainThread.hpp
"
33
34
using namespace
RTT
;
35
using namespace
extras;
36
37
FileDescriptorSimulationActivity::FileDescriptorSimulationActivity
(
int
priority,
38
base::RunnableInterface
* _r,
39
const
std::string& name) :
40
base
::
ActivityInterface
(_r),
41
period(0),
42
running(false),
43
lastReason(
base
::
RunnableInterface
::TimeOut)
44
{
45
// prevent compiler warnings
46
(void)priority;
47
(void)name;
48
}
49
50
FileDescriptorSimulationActivity::FileDescriptorSimulationActivity
(
int
scheduler,
51
int
priority,
52
base::RunnableInterface
* _r,
53
const
std::string& name) :
54
base
::
ActivityInterface
(_r),
55
period
(0),
56
running
(false),
57
lastReason
(
base
::
RunnableInterface
::TimeOut)
58
{
59
// prevent compiler warnings
60
(void)priority;
61
(void)name;
62
}
63
64
FileDescriptorSimulationActivity::FileDescriptorSimulationActivity
(
int
scheduler,
65
int
priority,
66
Seconds
_p,
67
base::RunnableInterface
* _r,
68
const
std::string& name) :
69
base
::
ActivityInterface
(_r),
70
period
(_p >= 0.0 ? _p : 0.0),
71
running
(false),
72
lastReason
(
base
::
RunnableInterface
::TimeOut)
73
{
74
// prevent compiler warnings
75
(void)scheduler;
76
(void)priority;
77
(void)name;
78
}
79
80
FileDescriptorSimulationActivity::FileDescriptorSimulationActivity
(
int
scheduler,
81
int
priority,
82
Seconds
_p,
83
unsigned
cpu_affinity,
84
base::RunnableInterface
* _r,
85
const
std::string& name) :
86
base
::
ActivityInterface
(_r),
87
period
(_p >= 0.0 ? _p : 0.0),
88
running
(false),
89
lastReason
(
base
::
RunnableInterface
::TimeOut)
90
{
91
// prevent compiler warnings
92
(void)scheduler;
93
(void)priority;
94
(void)cpu_affinity;
95
(void)name;
96
}
97
98
FileDescriptorSimulationActivity::~FileDescriptorSimulationActivity
()
99
{
100
stop
();
101
}
102
103
/***************************************************************************
104
* FDAInterface functions
105
***************************************************************************/
106
107
void
FileDescriptorSimulationActivity::watch
(
int
fd)
108
{
109
(void)fd;
// prevent compiler warning
110
}
111
112
void
FileDescriptorSimulationActivity::unwatch
(
int
fd)
113
{
114
(void)fd;
// prevent compiler warning
115
}
116
117
void
FileDescriptorSimulationActivity::clearAllWatches
()
118
{
119
}
120
121
bool
FileDescriptorSimulationActivity::isWatched
(
int
fd)
const
122
{
123
(void)fd;
// prevent compiler warning
124
return
false
;
125
}
126
127
bool
FileDescriptorSimulationActivity::isUpdated
(
int
fd)
const
128
{
129
return
(
base::RunnableInterface::IOReady
==
lastReason
);
130
}
131
132
bool
FileDescriptorSimulationActivity::hasTimeout
()
const
133
{
134
return
(
base::RunnableInterface::TimeOut
==
lastReason
);
135
}
136
137
bool
FileDescriptorSimulationActivity::hasError
()
const
138
{
139
return
false
;
140
}
141
142
void
FileDescriptorSimulationActivity::setTimeout
(
int
timeout
)
143
{
144
(void)timeout;
// prevent compiler warning
145
}
146
147
void
FileDescriptorSimulationActivity::setTimeout_us
(
int
timeout_us)
148
{
149
(void)timeout_us;
// prevent compiler warning
150
}
151
152
int
FileDescriptorSimulationActivity::getTimeout
()
const
153
{
154
return
0;
155
}
156
157
int
FileDescriptorSimulationActivity::getTimeout_us
()
const
158
{
159
return
0;
160
}
161
162
/***************************************************************************
163
* ActivityInterface functions
164
***************************************************************************/
165
166
167
bool
FileDescriptorSimulationActivity::start
()
168
{
169
if
(
running
) {
170
return
false
;
171
}
172
running
=
true
;
173
return
true
;
174
}
175
176
bool
FileDescriptorSimulationActivity::stop
()
177
{
178
if
(!
running
) {
179
return
false
;
180
}
181
running
=
false
;
182
return
true
;
183
}
184
185
bool
FileDescriptorSimulationActivity::isRunning
()
const
186
{
187
return
running
;
188
}
189
190
bool
FileDescriptorSimulationActivity::isActive
()
const
191
{
192
return
running
;
193
}
194
195
Seconds
FileDescriptorSimulationActivity::getPeriod
()
const
196
{
197
return
period
;
198
}
199
200
bool
FileDescriptorSimulationActivity::isPeriodic
()
const
201
{
202
return
(0 !=
period
);
203
}
204
205
bool
FileDescriptorSimulationActivity::setPeriod
(
Seconds
s)
206
{
207
if
(s < 0) {
208
return
false
;
209
}
210
period
= s;
211
return
true
;
212
}
213
214
unsigned
FileDescriptorSimulationActivity::getCpuAffinity
()
const
215
{
216
return
0;
217
}
218
219
bool
FileDescriptorSimulationActivity::setCpuAffinity
(
unsigned
cpu)
220
{
221
(void)cpu;
// prevent compiler warning
222
return
true
;
223
}
224
225
bool
FileDescriptorSimulationActivity::execute
()
226
{
227
return
true
;
228
}
229
230
bool
FileDescriptorSimulationActivity::trigger
()
231
{
232
return
true
;
233
}
234
235
bool
FileDescriptorSimulationActivity::timeout
()
236
{
237
return
true
;
238
}
239
240
os::ThreadInterface
*
FileDescriptorSimulationActivity::thread
()
241
{
242
return
os::MainThread::Instance
();
243
}
244
245
void
FileDescriptorSimulationActivity::work
(
base::RunnableInterface::WorkReason
reason)
246
{
247
if
(0 !=
runner
) {
248
runner
->
work
(reason);
249
lastReason
= reason;
250
}
251
}
RTT::base::RunnableInterface::work
virtual void work(WorkReason reason)
Definition:
CoreRunnableInterface.cpp:71
RTT::extras::FileDescriptorSimulationActivity::FileDescriptorSimulationActivity
FileDescriptorSimulationActivity(int priority, base::RunnableInterface *_r=0, const std::string &name="FileDescriptorSimulationActivity")
Definition:
FileDescriptorSimulationActivity.cpp:37
RTT::extras::FileDescriptorSimulationActivity::thread
virtual os::ThreadInterface * thread()
Returns os::MainThread::Instance()
Definition:
FileDescriptorSimulationActivity.cpp:240
RTT::Seconds
double Seconds
Definition:
os/Time.hpp:53
RTT::os::MainThread::Instance
static ThreadInterface * Instance()
Definition:
MainThread.cpp:58
RTT::extras::FileDescriptorSimulationActivity::setPeriod
virtual bool setPeriod(Seconds s)
If s>0 then returns true and period == s, otherwise returns false.
Definition:
FileDescriptorSimulationActivity.cpp:205
RTT::extras::FileDescriptorSimulationActivity::getPeriod
virtual Seconds getPeriod() const
Returns period.
Definition:
FileDescriptorSimulationActivity.cpp:195
RTT::extras::FileDescriptorSimulationActivity::watch
void watch(int fd)
Does nothing.
Definition:
FileDescriptorSimulationActivity.cpp:107
RTT::base::RunnableInterface
A class for running a certain piece of code in a thread.
Definition:
RunnableInterface.hpp:69
RTT::extras::FileDescriptorSimulationActivity::isUpdated
bool isUpdated(int fd) const
Definition:
FileDescriptorSimulationActivity.cpp:127
RTT::extras::FileDescriptorSimulationActivity::trigger
virtual bool trigger()
Returns true.
Definition:
FileDescriptorSimulationActivity.cpp:230
RTT::extras::FileDescriptorSimulationActivity::getCpuAffinity
virtual unsigned getCpuAffinity() const
Returns 0.
Definition:
FileDescriptorSimulationActivity.cpp:214
FileDescriptorSimulationActivity.hpp
RTT::base::RunnableInterface::WorkReason
WorkReason
Definition:
RunnableInterface.hpp:76
RTT::extras::FileDescriptorSimulationActivity::running
bool running
Definition:
FileDescriptorSimulationActivity.hpp:169
RTT::base::ActivityInterface::runner
RunnableInterface * runner
Definition:
ActivityInterface.hpp:65
RTT::os::ThreadInterface
Definition:
ThreadInterface.hpp:56
RTT::extras::FileDescriptorSimulationActivity::hasTimeout
bool hasTimeout() const
Definition:
FileDescriptorSimulationActivity.cpp:132
RTT::base::RunnableInterface::IOReady
Definition:
RunnableInterface.hpp:76
RTT::extras::FileDescriptorSimulationActivity::unwatch
void unwatch(int fd)
Does nothing.
Definition:
FileDescriptorSimulationActivity.cpp:112
RTT::extras::FileDescriptorSimulationActivity::setCpuAffinity
virtual bool setCpuAffinity(unsigned cpu)
Returns true.
Definition:
FileDescriptorSimulationActivity.cpp:219
MainThread.hpp
RTT::extras::FileDescriptorSimulationActivity::isRunning
virtual bool isRunning() const
Returns true.
Definition:
FileDescriptorSimulationActivity.cpp:185
RTT::base::ActivityInterface
Interface to start/stop and query a Activity.
Definition:
ActivityInterface.hpp:62
RTT::extras::FileDescriptorSimulationActivity::getTimeout
int getTimeout() const
Return 0.
Definition:
FileDescriptorSimulationActivity.cpp:152
RTT::extras::FileDescriptorSimulationActivity::isWatched
bool isWatched(int fd) const
Returns false always.
Definition:
FileDescriptorSimulationActivity.cpp:121
RTT::extras::FileDescriptorSimulationActivity::~FileDescriptorSimulationActivity
virtual ~FileDescriptorSimulationActivity()
Definition:
FileDescriptorSimulationActivity.cpp:98
RTT::extras::FileDescriptorSimulationActivity::isActive
virtual bool isActive() const
Returns true.
Definition:
FileDescriptorSimulationActivity.cpp:190
RTT::extras::FileDescriptorSimulationActivity::timeout
virtual bool timeout()
Returns true.
Definition:
FileDescriptorSimulationActivity.cpp:235
RTT::extras::FileDescriptorSimulationActivity::hasError
bool hasError() const
Definition:
FileDescriptorSimulationActivity.cpp:137
base
RTT::extras::FileDescriptorSimulationActivity::stop
virtual bool stop()
Returns true.
Definition:
FileDescriptorSimulationActivity.cpp:176
RTT::extras::FileDescriptorSimulationActivity::setTimeout_us
void setTimeout_us(int timeout_us)
Does nothing.
Definition:
FileDescriptorSimulationActivity.cpp:147
RTT::extras::FileDescriptorSimulationActivity::getTimeout_us
int getTimeout_us() const
Returns 0.
Definition:
FileDescriptorSimulationActivity.cpp:157
RTT::extras::FileDescriptorSimulationActivity::period
Seconds period
Definition:
FileDescriptorSimulationActivity.hpp:167
RTT::extras::FileDescriptorSimulationActivity::execute
virtual bool execute()
Returns true.
Definition:
FileDescriptorSimulationActivity.cpp:225
RTT::base::RunnableInterface::TimeOut
Definition:
RunnableInterface.hpp:76
RTT
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition:
Activity.cpp:53
RTT::extras::FileDescriptorSimulationActivity::isPeriodic
virtual bool isPeriodic() const
Returns true iff (0 != period)
Definition:
FileDescriptorSimulationActivity.cpp:200
RTT::extras::FileDescriptorSimulationActivity::lastReason
base::RunnableInterface::WorkReason lastReason
Definition:
FileDescriptorSimulationActivity.hpp:172
RTT::extras::FileDescriptorSimulationActivity::work
virtual void work(base::RunnableInterface::WorkReason reason)
If have a runner then pass the reason to the runner and store in lastReason.
Definition:
FileDescriptorSimulationActivity.cpp:245
RTT::extras::FileDescriptorSimulationActivity::setTimeout
void setTimeout(int timeout)
Does nothing.
Definition:
FileDescriptorSimulationActivity.cpp:142
RTT::extras::FileDescriptorSimulationActivity::start
virtual bool start()
Returns true.
Definition:
FileDescriptorSimulationActivity.cpp:167
RTT::extras::FileDescriptorSimulationActivity::clearAllWatches
void clearAllWatches()
Does nothing.
Definition:
FileDescriptorSimulationActivity.cpp:117
rtt
Author(s): RTT Developers
autogenerated on Fri Oct 25 2019 03:59:33