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 "OperationInterface.hpp"
00043 #include <string>
00044
00045 namespace RTT
00046 {
00047 class ExecutionEngine;
00048
00056 class TaskCore
00057 {
00058 public:
00131 enum TaskState { Init,
00132 PreOperational,
00133 FatalError,
00134 Stopped,
00135 Active,
00136 Running,
00137 RunTimeWarning,
00138 RunTimeError
00139 };
00140
00149 TaskCore( const std::string& name, TaskState initial_state = Stopped );
00150
00160 TaskCore(const std::string& name, ExecutionEngine* parent, TaskState initial_state = Stopped );
00161
00162 virtual ~TaskCore();
00163
00167 TaskState getTaskState() const;
00168
00173 int getWarningCount() const;
00174
00179 int getErrorCount() const;
00180
00194 virtual bool configure();
00195
00208 virtual bool activate();
00209
00221 virtual bool start();
00222
00229 virtual bool stop();
00230
00237 virtual bool cleanup();
00238
00249 virtual bool resetError();
00250
00255 virtual bool isConfigured() const;
00256
00261 virtual bool isActive() const;
00262
00270 virtual bool isRunning() const;
00271
00282 virtual double getPeriod() const;
00283
00287 virtual bool inFatalError() const;
00288
00292 virtual bool inRunTimeWarning() const;
00293
00297 virtual bool inRunTimeError() const;
00298
00306 virtual bool doUpdate();
00307
00315 virtual bool doTrigger();
00323 const std::string& getName() const
00324 {
00325 return mtask_name;
00326 }
00327
00331 void setName(const std::string& n)
00332 {
00333 mtask_name = n;
00334 }
00335
00345 void setExecutionEngine(ExecutionEngine* engine);
00346
00350 const ExecutionEngine* engine() const
00351 {
00352 return ee;
00353 }
00354
00358 ExecutionEngine* engine()
00359 {
00360 return ee;
00361 }
00362
00363 protected:
00374 virtual bool configureHook();
00375
00381 virtual void cleanupHook();
00382
00388 virtual bool activateHook();
00389
00399 virtual bool startHook();
00400
00409 virtual bool startup();
00410
00422 virtual void updateHook();
00423
00431 virtual void errorHook();
00432
00445 virtual void update();
00446
00452 virtual void stopHook();
00453
00461 virtual void shutdown();
00462
00469 virtual bool resetHook();
00470
00476 virtual void warning();
00477
00484 virtual void error();
00485
00492 virtual void fatal();
00493
00500 virtual void recovered();
00501
00502
00503
00504 friend class ExecutionEngine;
00505
00506 std::string mtask_name;
00507
00512 ExecutionEngine* ee;
00513
00514 TaskState mTaskState;
00515
00516 int runtime_warnings;
00517 int runtime_errors;
00518 private:
00519
00520 TaskCore( TaskCore& );
00521 };
00522 }
00523
00524 #endif