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, 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 }