Activity.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   tag: Peter Soetens  Thu Oct 22 11:59:07 CEST 2009  Activity.cpp
00003 
00004                         Activity.cpp -  description
00005                            -------------------
00006     begin                : Thu October 22 2009
00007     copyright            : (C) 2009 Peter Soetens
00008     email                : peter@thesourcworks.com
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 
00039 
00040 #ifdef ORO_PRAGMA_INTERFACE
00041 #pragma implementation
00042 #endif
00043 #include "Time.hpp"
00044 #include "Activity.hpp"
00045 #include "os/MutexLock.hpp"
00046 #include "Logger.hpp"
00047 #include "rtt-fwd.hpp"
00048 
00049 #include <cmath>
00050 
00051 namespace RTT
00052 {
00053     using namespace detail;
00054 
00055     Activity::Activity(RunnableInterface* _r, const std::string& name )
00056         : ActivityInterface(_r), os::Thread(ORO_SCHED_OTHER, RTT::os::LowestPriority, 0.0, 0, name )
00057     {
00058     }
00059 
00060     Activity::Activity(int priority, RunnableInterface* r, const std::string& name )
00061         : ActivityInterface(r), os::Thread(ORO_SCHED_RT, priority, 0.0, 0, name )
00062     {
00063     }
00064 
00065     Activity::Activity(int priority, Seconds period, RunnableInterface* r, const std::string& name )
00066         : ActivityInterface(r), os::Thread(ORO_SCHED_RT, priority, period, 0, name )
00067     {
00068     }
00069 
00070      Activity::Activity(int scheduler, int priority, Seconds period, RunnableInterface* r, const std::string& name )
00071          : ActivityInterface(r), os::Thread(scheduler, priority, period, 0, name )
00072      {
00073      }
00074 
00075      Activity::Activity(int scheduler, int priority, Seconds period, unsigned cpu_affinity, RunnableInterface* r, const std::string& name )
00076      : ActivityInterface(r), os::Thread(scheduler, priority, period, cpu_affinity, name )
00077      {
00078      }
00079 
00080     Activity::~Activity()
00081     {
00082         stop();
00083     }
00084 
00085     os::ThreadInterface* Activity::thread() {
00086         return this;
00087     }
00088 
00089     bool Activity::initialize() {
00090         if ( runner )
00091             return runner->initialize();
00092         return true;
00093     }
00094 
00095     void Activity::step() {
00096         if ( runner )
00097             runner->step();
00098     }
00099 
00100     void Activity::loop() {
00101         if ( runner )
00102             runner->loop();
00103         else
00104             this->step();
00105     }
00106 
00107     bool Activity::breakLoop() {
00108         if ( runner )
00109             return runner->breakLoop();
00110         return false;
00111     }
00112 
00113     void Activity::finalize() {
00114         if ( runner )
00115             runner->finalize();
00116     }
00117 
00118 
00119     bool Activity::start() {
00120         return Thread::start();
00121     }
00122 
00123     bool Activity::stop() {
00124         return Thread::stop();
00125     }
00126 
00127     bool Activity::trigger() {
00128         return Thread::isActive() ? Thread::start() : false;
00129     }
00130 
00131     bool Activity::execute() {
00132         return false;
00133     }
00134 
00135     bool Activity::isRunning() const {
00136         return Thread::isRunning();
00137     }
00138 
00139     bool Activity::isActive() const {
00140         return Thread::isActive();
00141     }
00142 
00143     Seconds Activity::getPeriod() const
00144     {
00145         return Thread::getPeriod();
00146     }
00147 
00148     bool Activity::setPeriod(Seconds period)
00149     {
00150         return Thread::setPeriod(period);
00151     }
00152 
00153 
00154     bool Activity::isPeriodic() const {
00155         return Thread::isPeriodic();
00156     }
00157 
00158     unsigned Activity::getCpuAffinity() const
00159     {
00160         return Thread::getCpuAffinity();
00161     }
00162 
00163     bool Activity::setCpuAffinity(unsigned cpu)
00164     {
00165         return Thread::setCpuAffinity(cpu);
00166     }
00167 
00168 }


rtt
Author(s): RTT Developers
autogenerated on Wed Aug 26 2015 16:15:45