RTT::ExecutionEngine Class Reference
[Execution Engine]

An execution engine serialises (executes one after the other) the execution of all commands, programs, state machines and incomming events for a task. More...

#include <rtt/ExecutionEngine.hpp>

Inheritance diagram for RTT::ExecutionEngine:
RTT::RunnableInterface RTT::OS::RunnableInterface

List of all members.

Public Member Functions

 ExecutionEngine (TaskCore *owner=0)
 Create an execution engine with a CommandProcessor, ProgramProcessor and StateMachineProcessor.
bool activate ()
 Run the Execution Engine's processors, but not the updateHook() functions of the TaskCores.
bool start ()
 Run the Execution Engine's processors and the updateHook() functions of the TaskCores.
bool stop ()
 Stop the processors and all TaskCores.
virtual bool initialize ()
 The method that will be called before the first periodical execution of step() ( or non periodical execution of loop() ), when the thread is started.
virtual void step ()
 Executes (in that order) programs, state machines, commands, events and the TaskCore's update() function.
virtual bool breakLoop ()
 This method is called by the framework to break out of the loop() method.
virtual void finalize ()
 The method that will be called after the last periodical execution of step() ( or non periodical execution of loop() ), when the RunnableInterface is stopped.
virtual void setActivity (ActivityInterface *t)
 Set the task this interface is run in.
virtual bool hasWork ()
 This method is for 'intelligent' activity implementations that wish to see if it is required to call step() (again).
TaskCoregetParent ()
 The TaskCore which created this ExecutionEngine.
virtual void addChild (TaskCore *tc)
 Add a TaskCore to execute.
virtual void removeChild (TaskCore *tc)
 Remove a TaskCore from execution.
TaskCoregetTaskCore () const
 Returns the owner of this execution engine.
CommandProcessorcommands () const
 Return the CommandProcessor of this engine.
ProgramProcessorprograms () const
 Return the ProgramProcessor of this engine.
StateMachineProcessorstates () const
 Return the StateMachineProcessor of this engine.
EventProcessorevents () const
 Return the EventProcessor of this engine.
virtual void setCommandProcessor (CommandProcessor *c)
 Install a new CommandProcessor.
virtual void setProgramProcessor (ProgramProcessor *p)
 Install a new ProgramProcessor.
virtual void setStateMachineProcessor (StateMachineProcessor *s)
 Install a new StateMachineProcessor.
virtual void setEventProcessor (EventProcessor *e)
 Install a new EventProcessor.
ActivityInterfacegetActivity () const
 Query for the task this interface is run in.
virtual OS::ThreadInterfacegetThread () const
 Get the thread this object is run in.
virtual void loop ()
 The method that will be executed once when this class RTT_API is run in a non periodic thread.
virtual void setThread (ThreadInterface *t)
 Set the thread this object will be run in.

Protected Types

enum  EngineState { Stopped, Activating, Active, Running }

Protected Member Functions

void setup ()
 Install new Processors.
bool startContexts ()
 Call all necessary hook functions of parent and children TaskContexts.

Protected Attributes

TaskCoretaskc
 The parent or 'owner' of this ExecutionEngine, may be null.
EngineState estate
 The ExecutionEngine keeps a state of its own which is synchronised with the parent and child TaskCore states.
RunnableInterfacecproc
 We store the Processors as RunnableInterface pointers, and dynamic_cast them back to the correct type.
RunnableInterfacepproc
RunnableInterfacesmproc
RunnableInterfaceeproc
std::vector< TaskCore * > children
 All tasks which execute in this ExecutionEngine.

Detailed Description

An execution engine serialises (executes one after the other) the execution of all commands, programs, state machines and incomming events for a task.

Any function executing in the same execution engine is guaranteed to be thread-safe with respect to other functions executing in the same execution engine.

The ExecutionEngine bundles a CommandProcessor, ProgramProcessor, StateMachineProcessor and EventProcessor.

Changing the Execution Policy
One can subclass this class in order to change the run-time behaviour. Use TaskCore::setExecutionEngine in order to install a new ExecutionEngine in a component. All Members of this class are protected and thus accessible in a subclass.

Definition at line 86 of file ExecutionEngine.hpp.


Constructor & Destructor Documentation

RTT::ExecutionEngine::ExecutionEngine ( TaskCore owner = 0  ) 

Create an execution engine with a CommandProcessor, ProgramProcessor and StateMachineProcessor.

Parameters:
owner The TaskCore in which this execution engine executes. It may be null, in that case no TaskCore owns this execution engine.

Member Function Documentation

virtual bool RTT::ExecutionEngine::breakLoop (  )  [virtual]

This method is called by the framework to break out of the loop() method.

Reimplement this method to signal loop() to return and return true on success. When this method is not reimplemented by you, it will always return false, denoting that the loop can not be broken. If breakLoop() returns true, the caller will wait until loop() returns.

Returns:
true if the loop could be notified to return.

Reimplemented from RTT::OS::RunnableInterface.

ActivityInterface * RTT::RunnableInterface::getActivity (  )  const [inline, inherited]

Query for the task this interface is run in.

Zero denotes that no task is present to run it, and hence no detailed information is available.

Returns:
The Activity which runs this RunnableInterface.

Definition at line 106 of file RunnableInterface.hpp.

virtual OS::ThreadInterface* RTT::RunnableInterface::getThread (  )  const [virtual, inherited]

Get the thread this object is run in.

Returns:
a pointer to the thread or 0 if not run by a thread.

Reimplemented from RTT::OS::RunnableInterface.

virtual bool RTT::ExecutionEngine::hasWork (  )  [virtual]

This method is for 'intelligent' activity implementations that wish to see if it is required to call step() (again).

By default, false is returned. You should only return true in case there is a temporary reason to (re-)run step.

Returns:
true if this object should be run.
See also:
SequentialActivity implementation to see how this can be of use.

Reimplemented from RTT::RunnableInterface.

virtual void RTT::OS::RunnableInterface::loop (  )  [virtual, inherited]

The method that will be executed once when this class RTT_API is run in a non periodic thread.

The default implementation calls step() once.

Reimplemented in RTT::Timer.

virtual void RTT::ExecutionEngine::setActivity ( ActivityInterface task  )  [virtual]

Set the task this interface is run in.

A Zero means no task is running it.

Parameters:
task The ActivityInterface running this interface.

Reimplemented from RTT::RunnableInterface.

virtual void RTT::ExecutionEngine::setCommandProcessor ( CommandProcessor c  )  [virtual]

Install a new CommandProcessor.

Parameters:
c becomes owned by this object and is returned in commands().
virtual void RTT::ExecutionEngine::setEventProcessor ( EventProcessor e  )  [virtual]

Install a new EventProcessor.

Parameters:
e becomes owned by this object and is returned in events().
virtual void RTT::ExecutionEngine::setProgramProcessor ( ProgramProcessor p  )  [virtual]

Install a new ProgramProcessor.

Parameters:
p becomes owned by this object and is returned in programs().
virtual void RTT::ExecutionEngine::setStateMachineProcessor ( StateMachineProcessor s  )  [virtual]

Install a new StateMachineProcessor.

Parameters:
s becomes owned by this object and is returned in states().

The documentation for this class was generated from the following file:
Generated on Thu Dec 23 13:22:43 2010 for Orocos Real-Time Toolkit by  doxygen 1.6.3