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 #ifndef ORO_TASK_CORE_HPP
00040 #define ORO_TASK_CORE_HPP
00041
00042 #include <string>
00043 #include "../rtt-fwd.hpp"
00044 #include "../rtt-config.h"
00045 #include "../Time.hpp"
00046
00047 namespace RTT
00048 { namespace base {
00049
00054 class RTT_API TaskCore
00055 {
00056 public:
00099 enum TaskState { Init,
00100 PreOperational,
00101 FatalError,
00102 Exception,
00103 Stopped,
00104 Running,
00105 RunTimeError
00106 };
00107
00115 TaskCore( TaskState initial_state = Stopped );
00116
00125 TaskCore( ExecutionEngine* parent, TaskState initial_state = Stopped );
00126
00127 virtual ~TaskCore();
00128
00137 virtual TaskState getTaskState() const;
00138
00152 virtual TaskState getTargetState() const;
00153
00167 virtual bool configure();
00168
00176 virtual bool activate();
00177
00187 virtual bool start();
00188
00195 virtual bool stop();
00196
00202 virtual bool cleanup();
00203
00208 virtual bool isConfigured() const;
00209
00215 virtual bool isActive() const;
00216
00223 virtual bool isRunning() const;
00224
00235 virtual Seconds getPeriod() const;
00236
00243 virtual bool setPeriod(Seconds s);
00244
00249 virtual unsigned getCpuAffinity() const;
00250
00256 virtual bool setCpuAffinity(unsigned cpu);
00257
00263 virtual bool inFatalError() const;
00264
00268 virtual bool inException() const;
00269
00273 virtual bool inRunTimeError() const;
00274
00281 virtual bool update();
00282
00289 virtual bool trigger();
00290
00297 virtual void error();
00298
00306 virtual bool recover();
00307
00321 void setExecutionEngine(ExecutionEngine* engine);
00322
00326 const ExecutionEngine* engine() const
00327 {
00328 return ee;
00329 }
00330
00334 ExecutionEngine* engine()
00335 {
00336 return ee;
00337 }
00338
00339 protected:
00350 virtual bool configureHook();
00351
00357 virtual void cleanupHook();
00358
00368 virtual bool startHook();
00369
00381 virtual void updateHook();
00382
00391 virtual bool breakUpdateHook();
00392
00400 virtual void errorHook();
00401
00409 virtual void exceptionHook();
00410
00411
00417 virtual void stopHook();
00418
00425 virtual void fatal();
00426
00435 virtual void exception();
00436
00437
00438
00439 friend class ::RTT::ExecutionEngine;
00440
00445 ExecutionEngine* ee;
00446
00447 TaskState mTaskState;
00448
00449 private:
00454 TaskState const mInitialState;
00459 TaskState mTargetState;
00460
00461 TaskCore( TaskCore& );
00462
00463 friend class TaskContext;
00470 virtual void prepareUpdateHook();
00471 };
00472 }}
00473
00474 #endif