Orocos Real-Time Toolkit  2.6.0
PeriodicActivity.hpp
00001 /***************************************************************************
00002   tag: Peter Soetens  Mon Jan 19 14:11:19 CET 2004  PeriodicActivity.hpp
00003 
00004                         PeriodicActivity.hpp -  description
00005                            -------------------
00006     begin                : Mon January 19 2004
00007     copyright            : (C) 2004 Peter Soetens
00008     email                : peter.soetens@mech.kuleuven.ac.be
00009 
00010  ***************************************************************************
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU General Public                   *
00013  *   License as published by the Free Software Foundation;                 *
00014  *   version 2 of the License.                                             *
00015  *                                                                         *
00016  *   As a special exception, you may use this file as part of a free       *
00017  *   software library without restriction.  Specifically, if other files   *
00018  *   instantiate templates or use macros or inline functions from this     *
00019  *   file, or you compile this file and link it with other files to        *
00020  *   produce an executable, this file does not by itself cause the         *
00021  *   resulting executable to be covered by the GNU General Public          *
00022  *   License.  This exception does not however invalidate any other        *
00023  *   reasons why the executable file might be covered by the GNU General   *
00024  *   Public License.                                                       *
00025  *                                                                         *
00026  *   This library is distributed in the hope that it will be useful,       *
00027  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00028  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00029  *   Lesser General Public License for more details.                       *
00030  *                                                                         *
00031  *   You should have received a copy of the GNU General Public             *
00032  *   License along with this library; if not, write to the Free Software   *
00033  *   Foundation, Inc., 59 Temple Place,                                    *
00034  *   Suite 330, Boston, MA  02111-1307  USA                                *
00035  *                                                                         *
00036  ***************************************************************************/
00037 
00038 #ifndef ORO_PERIODIC_ACTIVITY_HPP
00039 #define ORO_PERIODIC_ACTIVITY_HPP
00040 
00041 #include "../base/RunnableInterface.hpp"
00042 
00043 #include "../Time.hpp"
00044 #include "../base/ActivityInterface.hpp"
00045 #include "TimerThread.hpp"
00046 
00047 #ifdef ORO_PRAGMA_INTERFACE
00048 #pragma interface
00049 #endif
00050 
00051 namespace RTT
00052 { namespace extras {
00053 
00054 
00070     class RTT_API PeriodicActivity
00071         : public base::ActivityInterface
00072     {
00073     public:
00074 
00088         PeriodicActivity(int priority, Seconds period, base::RunnableInterface* r=0 );
00089 
00105         PeriodicActivity(int scheduler, int priority, Seconds period, base::RunnableInterface* r=0 );
00106 
00124         PeriodicActivity(int scheduler, int priority, Seconds period, unsigned cpu_affinity, base::RunnableInterface* r=0 );
00125 
00126 
00136         PeriodicActivity(TimerThreadPtr thread, base::RunnableInterface* r=0);
00137 
00149         PeriodicActivity(Seconds period, TimerThreadPtr thread, base::RunnableInterface* r=0 );
00150 
00164         PeriodicActivity(secs sec, nsecs nsec, TimerThreadPtr thread, base::RunnableInterface* r=0 );
00165 
00169         virtual ~PeriodicActivity();
00170 
00171         virtual bool start();
00172 
00173         virtual bool execute();
00174 
00175         virtual bool trigger();
00176 
00177         virtual bool stop();
00178 
00179         virtual bool isRunning() const;
00180 
00181         virtual bool isActive() const;
00182 
00183         virtual bool isPeriodic() const;
00184 
00185         virtual Seconds getPeriod() const;
00186 
00187         virtual bool setPeriod(Seconds s);
00188 
00189         virtual unsigned getCpuAffinity() const;
00190 
00191         virtual bool setCpuAffinity(unsigned cpu);
00192 
00193         virtual os::ThreadInterface* thread();
00194 
00198         virtual bool initialize();
00199 
00203         virtual void step();
00204 
00208         virtual void finalize();
00209 
00210     protected:
00211         void init();
00212 
00216         bool running;
00217 
00221         bool active;
00222 
00226         TimerThreadPtr thread_;
00227     };
00228 
00229 }}
00230 
00231 #endif