Orocos Real-Time Toolkit  2.8.3
TaskCore.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: FMTC do nov 2 13:06:07 CET 2006 TaskCore.hpp
3 
4  TaskCore.hpp - description
5  -------------------
6  begin : do november 02 2006
7  copyright : (C) 2006 FMTC
8  email : peter.soetens@fmtc.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 
39 #ifndef ORO_TASK_CORE_HPP
40 #define ORO_TASK_CORE_HPP
41 
42 #include <string>
43 #include "../rtt-fwd.hpp"
44 #include "../rtt-config.h"
45 #include "../Time.hpp"
46 
47 namespace RTT
48 { namespace base {
49 
55  {
56  public:
99  enum TaskState {
100  Init
101  ,PreOperational
102  ,FatalError
103  ,Exception
104  ,Stopped
105  ,Running
106  ,RunTimeError
107  };
108 
116  TaskCore( TaskState initial_state = Stopped );
117 
126  TaskCore( ExecutionEngine* parent, TaskState initial_state = Stopped );
127 
128  virtual ~TaskCore();
129 
138  virtual TaskState getTaskState() const;
139 
153  virtual TaskState getTargetState() const;
154 
168  virtual bool configure();
169 
177  virtual bool activate();
178 
188  virtual bool start();
189 
196  virtual bool stop();
197 
203  virtual bool cleanup();
204 
209  virtual bool isConfigured() const;
210 
216  virtual bool isActive() const;
217 
224  virtual bool isRunning() const;
225 
236  virtual Seconds getPeriod() const;
237 
244  virtual bool setPeriod(Seconds s);
245 
250  virtual unsigned getCpuAffinity() const;
251 
257  virtual bool setCpuAffinity(unsigned cpu);
258 
264  virtual bool inFatalError() const;
265 
269  virtual bool inException() const;
270 
274  virtual bool inRunTimeError() const;
275 
282  virtual bool update();
283 
290  virtual bool trigger();
291 
298  virtual void error();
299 
307  virtual bool recover();
308 
322  void setExecutionEngine(ExecutionEngine* engine);
323 
327  const ExecutionEngine* engine() const
328  {
329  return ee;
330  }
331 
336  {
337  return ee;
338  }
339 
340  protected:
351  virtual bool configureHook();
352 
358  virtual void cleanupHook();
359 
369  virtual bool startHook();
370 
382  virtual void updateHook();
383 
392  virtual bool breakUpdateHook();
393 
401  virtual void errorHook();
402 
410  virtual void exceptionHook();
411 
412 
418  virtual void stopHook();
419 
426  virtual void fatal();
427 
436  virtual void exception();
437 
438  // Required to set mTaskState to Running, Stopped or Exception.
439  // As an alternative, one could query the EE.
440  friend class ::RTT::ExecutionEngine;
441 
447 
449 
450  private:
455  TaskState const mInitialState;
460  TaskState mTargetState;
461  // non copyable
462  TaskCore( TaskCore& );
463 
464  friend class TaskContext;
471  virtual void prepareUpdateHook();
472  };
473 }}
474 
475 #endif
double Seconds
Seconds are stored as a double precision float.
Definition: Time.hpp:53
The minimal Orocos task.
Definition: TaskCore.hpp:54
ExecutionEngine * engine()
Get a pointer to the ExecutionEngine of this Task.
Definition: TaskCore.hpp:335
TaskState mTaskState
Definition: TaskCore.hpp:448
#define RTT_API
Definition: rtt-config.h:97
An execution engine serialises (executes one after the other) the execution of all commands...
TaskState
Describes the different states a component can have.
Definition: TaskCore.hpp:99
The TaskContext is the C++ representation of an Orocos component.
Definition: TaskContext.hpp:93
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:51
ExecutionEngine * ee
The execution engine which calls update() and processes our commands, events etc. ...
Definition: TaskCore.hpp:446
const ExecutionEngine * engine() const
Get a const pointer to the ExecutionEngine of this Task.
Definition: TaskCore.hpp:327