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 
54  class RTT_API TaskCore
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, const std::string& name = std::string() );
117 
118  virtual ~TaskCore();
119 
128  virtual TaskState getTaskState() const;
129 
143  virtual TaskState getTargetState() const;
144 
158  virtual bool configure();
159 
167  virtual bool activate();
168 
178  virtual bool start();
179 
186  virtual bool stop();
187 
193  virtual bool cleanup();
194 
199  virtual bool isConfigured() const;
200 
206  virtual bool isActive() const;
207 
214  virtual bool isRunning() const;
215 
226  virtual Seconds getPeriod() const;
227 
234  virtual bool setPeriod(Seconds s);
235 
240  virtual unsigned getCpuAffinity() const;
241 
247  virtual bool setCpuAffinity(unsigned cpu);
248 
254  virtual bool inFatalError() const;
255 
259  virtual bool inException() const;
260 
264  virtual bool inRunTimeError() const;
265 
272  virtual bool update();
273 
280  virtual bool trigger();
281 
288  virtual void error();
289 
297  virtual bool recover();
298 
306  const ExecutionEngine* engine() const
307  {
308  return ee;
309  }
310 
315  {
316  return ee;
317  }
318 
324  unsigned int getCycleCounter() const { return mCycleCounter; }
328  unsigned int getTriggerCounter() const { return mTriggerCounter; }
332  unsigned int getIOCounter() const { return mIOCounter; }
336  unsigned int getTimeOutCounter() const { return mTimeOutCounter; }
337 
338  protected:
349  virtual bool configureHook();
350 
356  virtual void cleanupHook();
357 
367  virtual bool startHook();
368 
380  virtual void updateHook();
381 
390  virtual bool breakUpdateHook();
391 
399  virtual void errorHook();
400 
408  virtual void exceptionHook();
409 
410 
416  virtual void stopHook();
417 
424  virtual void fatal();
425 
434  virtual void exception();
435 
436  // Required to set mTaskState to Running, Stopped or Exception.
437  // As an alternative, one could query the EE.
438  friend class ::RTT::ExecutionEngine;
439 
445 
447 
448  private:
459 
460  // non copyable
461  TaskCore( TaskCore& );
462 
463  friend class TaskContext;
464 
465  protected:
470 
476  unsigned int mCycleCounter;
480  unsigned int mIOCounter;
484  unsigned int mTimeOutCounter;
488  unsigned int mTriggerCounter;
489 
493  std::string mName;
494  };
495 }}
496 
497 #endif
double Seconds
Definition: os/Time.hpp:53
ExecutionEngine * engine()
Definition: TaskCore.hpp:314
TaskState const mInitialState
Definition: TaskCore.hpp:453
TaskState mTaskState
Definition: TaskCore.hpp:446
unsigned int mCycleCounter
Definition: TaskCore.hpp:476
unsigned int mIOCounter
Definition: TaskCore.hpp:480
unsigned int getCycleCounter() const
Definition: TaskCore.hpp:324
unsigned int mTimeOutCounter
Definition: TaskCore.hpp:484
static RTT_UNUSED bool setCpuAffinity(ThreadInterface *thread, const std::bitset< 16 > &cpu_affinity)
std::string mName
Definition: TaskCore.hpp:493
unsigned int getTimeOutCounter() const
Definition: TaskCore.hpp:336
static std::bitset< 16 > getCpuAffinity(ThreadInterface *thread)
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
TaskState mTargetState
Definition: TaskCore.hpp:458
ExecutionEngine * ee
Definition: TaskCore.hpp:444
unsigned int getIOCounter() const
Definition: TaskCore.hpp:332
unsigned int getTriggerCounter() const
Definition: TaskCore.hpp:328
unsigned int mTriggerCounter
Definition: TaskCore.hpp:488
const ExecutionEngine * engine() const
Definition: TaskCore.hpp:306
static bool update(TaskContext *tc)
static bool trigger(TaskContext *tc)


rtt
Author(s): RTT Developers
autogenerated on Tue Jun 25 2019 19:33:37