RTT::StateMachineProcessor Class Reference
[Execution Engine]

This class implements a real-time state machine executor. More...

#include <rtt/StateMachineProcessor.hpp>

Inheritance diagram for RTT::StateMachineProcessor:
RTT::RunnableInterface RTT::OS::RunnableInterface

List of all members.

Public Types

typedef StateMachine::Status Status
 The status of a StateMachine.

Public Member Functions

 StateMachineProcessor ()
 Constructs a new StateMachineProcessor.
bool loadStateMachine (StateMachinePtr sc)
 Load a new State Machine and all its children.
bool unloadStateMachine (const std::string &name)
 Unload a deactivated State Machine and all its children.
bool deleteStateMachine (const std::string &name)
 Delete a deactivated State Machine and all its children.
void clear ()
 Stop and unload all programs from the StateMachineProcessor.
Status::StateMachineStatus getStateMachineStatus (const std::string &name) const
 Return the status of a StateMachine.
std::string getStateMachineStatusStr (const std::string &name) const
 Return the status of a StateMachine as a human readable string.
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 ()
 The method that will be periodically executed when this class RTT_API is run in a periodic thread.
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.
std::vector< std::string > getStateMachineList () const
 Get a list of all loaded StateMachines and their children.
const StateMachinePtr getStateMachine (const std::string &name) const
 Get a pointer to a loaded StateMachine.
StateMachinePtr getStateMachine (const std::string &name)
 Get a pointer to a loaded StateMachine.
virtual bool hasWork ()
 This method is for 'intelligent' activity implementations that wish to see if it is required to call step() (again).
ActivityInterfacegetActivity () const
 Query for the task this interface is run in.
virtual void setActivity (ActivityInterface *task)
 Set 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 bool breakLoop ()
 This method is called by the framework to break out of the loop() method.
virtual void setThread (ThreadInterface *t)
 Set the thread this object will be run in.

Protected Types

typedef List< StateMachinePtr > StateMap

Protected Member Functions

void recursiveLoadStateMachine (StateMachinePtr sc)
bool recursiveCheckLoadStateMachine (StateMachinePtr sc)
void recursiveUnloadStateMachine (StateMachinePtr sc)
bool recursiveCheckUnloadStateMachine (StateMachinePtr si)

Protected Attributes

StateMapstates

Detailed Description

This class implements a real-time state machine executor.

Changing the State Machine Processing Policy

The default policy of the StateMachineProcessor is to call StateMachine::execute() of all loaded state machines in each step(). The parent state machines are executed before the children.

If you want to change this policy, subclass the StateMachineProcessor and override the virtual functions, such as step().

Definition at line 68 of file StateMachineProcessor.hpp.


Member Function Documentation

virtual bool RTT::OS::RunnableInterface::breakLoop (  )  [virtual, inherited]

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 in RTT::EventProcessor, RTT::ExecutionEngine, and RTT::Timer.

bool RTT::StateMachineProcessor::deleteStateMachine ( const std::string &  name  ) 

Delete a deactivated State Machine and all its children.

Exceptions:
program_unload_exception if the state machine or one of its children is still active.
Deprecated:
by unloadStateMachine
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::RunnableInterface::hasWork (  )  [virtual, inherited]

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 in RTT::CommandProcessor, RTT::EventProcessor, and RTT::ExecutionEngine.

bool RTT::StateMachineProcessor::loadStateMachine ( StateMachinePtr  sc  ) 

Load a new State Machine and all its children.

Exceptions:
program_load_exception if a state machine with the same name already exists.
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::RunnableInterface::setActivity ( ActivityInterface task  )  [virtual, inherited]

Set the task this interface is run in.

A Zero means no task is running it.

Parameters:
task The ActivityInterface running this interface.

Reimplemented in RTT::ExecutionEngine.

bool RTT::StateMachineProcessor::unloadStateMachine ( const std::string &  name  ) 

Unload a deactivated State Machine and all its children.

Exceptions:
program_unload_exception if the state machine or one of its children is still active.

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