Orocos Real-Time Toolkit  2.9.0
PeriodicActivity.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Mon Jan 19 14:11:19 CET 2004 PeriodicActivity.hpp
3 
4  PeriodicActivity.hpp - description
5  -------------------
6  begin : Mon January 19 2004
7  copyright : (C) 2004 Peter Soetens
8  email : peter.soetens@mech.kuleuven.ac.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 #ifndef ORO_PERIODIC_ACTIVITY_HPP
39 #define ORO_PERIODIC_ACTIVITY_HPP
40 
41 #include "../base/RunnableInterface.hpp"
42 
43 #include "../Time.hpp"
44 #include "../base/ActivityInterface.hpp"
45 #include "TimerThread.hpp"
46 
47 #ifdef ORO_PRAGMA_INTERFACE
48 #pragma interface
49 #endif
50 
51 namespace RTT
52 { namespace extras {
53 
54 
72  {
73  public:
74 
88  PeriodicActivity(int priority, Seconds period, base::RunnableInterface* r=0 );
89 
105  PeriodicActivity(int scheduler, int priority, Seconds period, base::RunnableInterface* r=0 );
106 
124  PeriodicActivity(int scheduler, int priority, Seconds period, unsigned cpu_affinity, base::RunnableInterface* r=0 );
125 
126 
137 
150 
165 
169  virtual ~PeriodicActivity();
170 
171  virtual bool start();
172 
173  virtual bool execute();
174 
175  virtual bool trigger();
176 
177  virtual bool timeout();
178 
179  virtual bool stop();
180 
181  virtual bool isRunning() const;
182 
183  virtual bool isActive() const;
184 
185  virtual bool isPeriodic() const;
186 
187  virtual Seconds getPeriod() const;
188 
189  virtual bool setPeriod(Seconds s);
190 
191  virtual unsigned getCpuAffinity() const;
192 
193  virtual bool setCpuAffinity(unsigned cpu);
194 
195  virtual os::ThreadInterface* thread();
196 
200  virtual bool initialize();
201 
205  virtual void step();
206 
210  virtual void work(base::RunnableInterface::WorkReason reason);
211 
215  virtual void finalize();
216 
217  protected:
218  void init();
219 
223  bool running;
224 
228  bool active;
229 
234  };
235 
236 }}
237 
238 #endif
double Seconds
Seconds are stored as a double precision float.
Definition: Time.hpp:53
A class for running a certain piece of code in a thread.
long secs
seconds as a signed long.
Definition: Time.hpp:57
#define RTT_API
Definition: rtt-config.h:97
boost::shared_ptr< TimerThread > TimerThreadPtr
TimerThread objects are reference counted such that when the last PeriodicActivity which uses it is d...
Definition: TimerThread.hpp:61
TimerThreadPtr thread_
The thread which runs this activity.
A thread which is being run.
Interface to start/stop and query a Activity.
A PeriodicActivity is the general implementation of a Activity which has (realtime) periodic constrai...
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:52
long long nsecs
nanoseconds as a signed long long.
Definition: Time.hpp:69