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, RunnableInterface* r, const std::string& name )
00071         : ActivityInterface(r), os::Thread(scheduler, priority, 0.0, 0, name )
00072     {
00073     }
00074 
00075     Activity::Activity(int scheduler, int priority, Seconds period, RunnableInterface* r, const std::string& name )
00076         : ActivityInterface(r), os::Thread(scheduler, priority, period, 0, name )
00077     {
00078     }
00079 
00080     Activity::Activity(int scheduler, int priority, Seconds period, unsigned cpu_affinity, RunnableInterface* r, const std::string& name )
00081     : ActivityInterface(r), os::Thread(scheduler, priority, period, cpu_affinity, name )
00082     {
00083     }
00084 
00085     Activity::~Activity()
00086     {
00087         stop();
00088     }
00089 
00090     os::ThreadInterface* Activity::thread() {
00091         return this;
00092     }
00093 
00094     bool Activity::initialize() {
00095         if ( runner )
00096             return runner->initialize();
00097         return true;
00098     }
00099 
00100     void Activity::step() {
00101         if ( runner )
00102             runner->step();
00103     }
00104 
00105     void Activity::loop() {
00106         if ( runner )
00107             runner->loop();
00108         else
00109             this->step();
00110     }
00111 
00112     bool Activity::breakLoop() {
00113         if ( runner )
00114             return runner->breakLoop();
00115         return false;
00116     }
00117 
00118     void Activity::finalize() {
00119         if ( runner )
00120             runner->finalize();
00121     }
00122 
00123 
00124     bool Activity::start() {
00125         return Thread::start();
00126     }
00127 
00128     bool Activity::stop() {
00129         return Thread::stop();
00130     }
00131 
00132     bool Activity::trigger() {
00133         return Thread::isActive() ? Thread::start() : false;
00134     }
00135 
00136     bool Activity::execute() {
00137         return false;
00138     }
00139 
00140     bool Activity::isRunning() const {
00141         return Thread::isRunning();
00142     }
00143 
00144     bool Activity::isActive() const {
00145         return Thread::isActive();
00146     }
00147 
00148     Seconds Activity::getPeriod() const
00149     {
00150         return Thread::getPeriod();
00151     }
00152 
00153     bool Activity::setPeriod(Seconds period)
00154     {
00155         return Thread::setPeriod(period);
00156     }
00157 
00158 
00159     bool Activity::isPeriodic() const {
00160         return Thread::isPeriodic();
00161     }
00162 
00163     unsigned Activity::getCpuAffinity() const
00164     {
00165         return Thread::getCpuAffinity();
00166     }
00167 
00168     bool Activity::setCpuAffinity(unsigned cpu)
00169     {
00170         return Thread::setCpuAffinity(cpu);
00171     }
00172 
00173 }


rtt
Author(s): RTT Developers
autogenerated on Fri Sep 9 2016 04:01:50