TaskCore.hpp
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 RTT_API 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 virtual TaskState getTaskState() const;
00168
00173 virtual int getWarningCount() const;
00174
00179 virtual 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 virtual const std::string& getName() const
00324 {
00325 return mtask_name;
00326 }
00327
00331 virtual 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
00432 virtual bool breakUpdateHook();
00433
00441 virtual void errorHook();
00442
00455 virtual void update();
00456
00462 virtual void stopHook();
00463
00471 virtual void shutdown();
00472
00479 virtual bool resetHook();
00480
00486 virtual void warning();
00487
00494 virtual void error();
00495
00502 virtual void fatal();
00503
00510 virtual void recovered();
00511
00512
00513
00514 friend class ExecutionEngine;
00515
00516 std::string mtask_name;
00517
00522 ExecutionEngine* ee;
00523
00524 TaskState mTaskState;
00525
00526 int runtime_warnings;
00527 int runtime_errors;
00528 private:
00529
00530 TaskCore( TaskCore& );
00531 };
00532 }
00533
00534 #endif