Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
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 }