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 #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 {
00100 Init
00101 ,PreOperational
00102 ,FatalError
00103 ,Exception
00104 ,Stopped
00105 ,Running
00106 ,RunTimeError
00107 };
00108
00116 TaskCore( TaskState initial_state = Stopped );
00117
00126 TaskCore( ExecutionEngine* parent, TaskState initial_state = Stopped );
00127
00128 virtual ~TaskCore();
00129
00138 virtual TaskState getTaskState() const;
00139
00153 virtual TaskState getTargetState() const;
00154
00168 virtual bool configure();
00169
00177 virtual bool activate();
00178
00188 virtual bool start();
00189
00196 virtual bool stop();
00197
00203 virtual bool cleanup();
00204
00209 virtual bool isConfigured() const;
00210
00216 virtual bool isActive() const;
00217
00224 virtual bool isRunning() const;
00225
00236 virtual Seconds getPeriod() const;
00237
00244 virtual bool setPeriod(Seconds s);
00245
00250 virtual unsigned getCpuAffinity() const;
00251
00257 virtual bool setCpuAffinity(unsigned cpu);
00258
00264 virtual bool inFatalError() const;
00265
00269 virtual bool inException() const;
00270
00274 virtual bool inRunTimeError() const;
00275
00282 virtual bool update();
00283
00290 virtual bool trigger();
00291
00298 virtual void error();
00299
00307 virtual bool recover();
00308
00322 void setExecutionEngine(ExecutionEngine* engine);
00323
00327 const ExecutionEngine* engine() const
00328 {
00329 return ee;
00330 }
00331
00335 ExecutionEngine* engine()
00336 {
00337 return ee;
00338 }
00339
00340 protected:
00351 virtual bool configureHook();
00352
00358 virtual void cleanupHook();
00359
00369 virtual bool startHook();
00370
00382 virtual void updateHook();
00383
00392 virtual bool breakUpdateHook();
00393
00401 virtual void errorHook();
00402
00410 virtual void exceptionHook();
00411
00412
00418 virtual void stopHook();
00419
00426 virtual void fatal();
00427
00436 virtual void exception();
00437
00438
00439
00440 friend class ::RTT::ExecutionEngine;
00441
00446 ExecutionEngine* ee;
00447
00448 TaskState mTaskState;
00449
00450 private:
00455 TaskState const mInitialState;
00460 TaskState mTargetState;
00461
00462 TaskCore( TaskCore& );
00463
00464 friend class TaskContext;
00471 virtual void prepareUpdateHook();
00472 };
00473 }}
00474
00475 #endif