Orocos Real-Time Toolkit
2.9.0
|
The TaskContext is the C++ representation of an Orocos component. More...
#include <rtt/TaskContext.hpp>
Public Types | |
typedef std::vector< std::string > | PeerList |
A list of Peer TaskContext names. More... | |
enum | TaskState { Init, PreOperational, FatalError, Exception, Stopped, Running, RunTimeError } |
Describes the different states a component can have. More... | |
Public Member Functions | |
TaskContext (const std::string &name, TaskState initial_state=Stopped) | |
Create a TaskContext. More... | |
virtual | ~TaskContext () |
virtual const std::string & | getName () const |
Returns the name of this TaskContext. More... | |
bool | setActivity (base::ActivityInterface *new_act) |
Sets the activity of this TaskContext. More... | |
base::ActivityInterface * | getActivity () |
Get a pointer to the activity running this component. More... | |
template<typename T > | |
T * | getActivity () |
Get a pointer to the activity running this component. More... | |
virtual void | clear () |
Clear the complete interface of this Component. More... | |
virtual bool | ready () |
Checks the validity of this TaskContext. More... | |
virtual bool | start () |
This method starts the execution of the updateHook() with each trigger or period. More... | |
virtual bool | stop () |
This method stops the execution of updateHook() of this component. More... | |
virtual TaskState | getTaskState () const |
Returns the current state of the TaskCore. More... | |
virtual TaskState | getTargetState () const |
Returns the state this TaskCore is going to, or in case no transition is taking place, returns getTaskState(). More... | |
const ExecutionEngine * | engine () const |
Get a const pointer to the ExecutionEngine of this Task. More... | |
ExecutionEngine * | engine () |
Get a pointer to the ExecutionEngine of this Task. More... | |
unsigned int | getCycleCounter () const |
For each update cycle, this counter increments by one. More... | |
unsigned int | getTriggerCounter () const |
Number of cycles that were caused by Trigger triggers. More... | |
unsigned int | getIOCounter () const |
Number of cycles that were caused by IOReady triggers. More... | |
unsigned int | getTimeOutCounter () const |
Number of cycles that were caused by TimeOut triggers. More... | |
Peer-to-Peer functions | |
These functions are used to setup and manage peer-to-peer networks of TaskContext objects. | |
virtual bool | addPeer (TaskContext *peer, std::string alias="") |
Add a one-way connection from this task to a peer task. More... | |
virtual void | removePeer (const std::string &name) |
Remove a one-way connection from this task to a peer task. More... | |
virtual void | removePeer (TaskContext *peer) |
Remove a one-way connection from this task to a peer task. More... | |
virtual bool | connectPeers (TaskContext *peer) |
Add a two-way connection from this task to a peer task. More... | |
virtual void | disconnect () |
Disconnect this TaskContext from it's peers and ports. More... | |
virtual void | disconnectPeers (const std::string &name) |
Remove a two-way connection from this task to a peer task. More... | |
virtual PeerList | getPeerList () const |
Return a standard container which contains all the Peer names of this TaskContext. More... | |
virtual bool | hasPeer (const std::string &peer_name) const |
Return true if it knows a peer by that name. More... | |
virtual TaskContext * | getPeer (const std::string &peer_name) const |
Get a pointer to a peer of this task. More... | |
Services | |
These functions are used to create and manage services. Use provides() or requires() to access the Service or ServiceRequester objects that contain all service related functions. | |
Service::shared_ptr | provides () |
Returns this Service. More... | |
Service::shared_ptr | provides (const std::string &service_name) |
Returns a sub-Service which resorts under this Service. More... | |
ServiceRequester::shared_ptr | requires () |
Returns the object that manages which methods this Task requires to be implemented by another task. More... | |
ServiceRequester::shared_ptr | requires (const std::string &service_name) |
Returns the object that manages which methods this Task requires to be implemented by another service. More... | |
virtual bool | connectServices (TaskContext *peer) |
Connects all requires/provides services of this component to these of a peer. More... | |
template<class ServiceType > | |
boost::shared_ptr< ServiceType > | getProvider (const std::string &name) |
Use this method to be able to make OperationCaller calls to services provided by this component. More... | |
bool | loadService (const std::string &service_name) |
Use this method to load a service known to RTT into this component. More... | |
Operations | |
Adding and getting operations from the TaskContext interface. These functions all forward to the Service representing this TaskContext. Use provides() to access the complete Service interface of this TaskContext. | |
template<class Signature > | |
Operation< Signature > & | addOperation (Operation< Signature > &op) |
Add an operation object to the interface. More... | |
template<class Func , class Service > | |
Operation< typename internal::GetSignature< Func >::Signature > & | addOperation (const std::string name, Func func, Service *serv, ExecutionThread et=ClientThread) |
Adds a C++ function as an operation. More... | |
template<class Signature > | |
Operation< Signature > & | addOperation (const std::string name, Signature *func, ExecutionThread et=ClientThread) |
Adds a C function as an operation. More... | |
OperationInterfacePart * | getOperation (std::string name) |
Get a previously added operation for use in a C++ OperationCaller object. More... | |
OperationInterface * | operations () |
Returns the operations of this TaskContext as an OperationInterface. More... | |
Attributes | |
Adding and getting attributes from the TaskContext interface. These functions all forward to the Service representing this TaskContext. Use attributes() to access the complete ConfigurationInterface interface of this TaskContext. | |
template<class T > | |
bool | addAttribute (const std::string &name, T &attr) |
Adds a variable of any type as read/write attribute to the attribute interface. More... | |
template<class T > | |
bool | addConstant (const std::string &name, const T &attr) |
Adds a variable of any type as read-only attribute to the attribute interface. More... | |
bool | addAttribute (base::AttributeBase &a) |
Add an base::AttributeBase which remains owned by the user. More... | |
base::AttributeBase * | getAttribute (const std::string &name) const |
Adds a variable of any type as read/write attribute to the attribute interface. More... | |
ConfigurationInterface * | attributes () |
Returns the attributes of this TaskContext as an ConfigurationInterface. More... | |
Properties | |
Adding and getting properties from the TaskContext interface. These functions all forward to the Service representing this TaskContext. Use properties() to access the complete PropertyBag interface of this TaskContext. | |
template<class T > | |
Property< T > & | addProperty (const std::string &name, T &attr) |
Adds a variable of any type as a property to the attribute interface. More... | |
bool | addProperty (base::PropertyBase &pb) |
Add an base::PropertyBase as a property. More... | |
base::PropertyBase * | getProperty (const std::string &name) const |
Get a Property with name name. More... | |
PropertyBag * | properties () |
Returns the properties of this TaskContext as a PropertyBag. More... | |
Operations | |
These TaskCore functions are exported in a TaskContext as script methods and are for configuration, starting and stopping its ExecutionEngine. | |
virtual bool | configure () |
This method instructs the component to (re-)read configuration data and try to enter the Stopped state. More... | |
virtual bool | activate () |
This method starts the ExecutionEngine of this component in case it was not running. More... | |
virtual bool | cleanup () |
This method instructs a stopped component to enter the pre-operational state again. More... | |
virtual bool | isConfigured () const |
Inspect if the component is configured, i.e. More... | |
virtual bool | isActive () const |
Inspect if the component's ExecutionEngine is processing requests. More... | |
virtual bool | isRunning () const |
Inspect if the component is in the Running or RunTimeError state. More... | |
virtual Seconds | getPeriod () const |
Get the configured execution period of this component. More... | |
virtual bool | setPeriod (Seconds s) |
Sets the period of this component. More... | |
virtual unsigned | getCpuAffinity () const |
Get the configured cpu affinity of this component. More... | |
virtual bool | setCpuAffinity (unsigned cpu) |
Sets the cpu affinity of this component. More... | |
virtual bool | inFatalError () const |
Inspect if the component is in the FatalError state. More... | |
virtual bool | inException () const |
Inspect if the component is in the Exception state. More... | |
virtual bool | inRunTimeError () const |
Inspect if the component is in the RunTimeError state. More... | |
virtual bool | update () |
Invoke this method to execute the ExecutionEngine and the update() method. More... | |
virtual bool | trigger () |
Invoke this method to trigger the thread of this TaskContext to execute its ExecutionEngine and the update() method. More... | |
virtual void | error () |
Call this method in a Running state to indicate a run-time error condition. More... | |
virtual bool | recover () |
Call this method in a RunTimeError or Exception state to indicate that the run-time error conditions are gone and nominal operation is resumed. More... | |
Protected Member Functions | |
void | forceActivity (base::ActivityInterface *new_act) |
Forces the current activity to become new_act, even if this TaskContext is still running. More... | |
virtual bool | dataOnPortHook (base::PortInterface *port) |
Reimplement this method to influence how writing to event ports is handled by the component. More... | |
virtual void | dataOnPortCallback (base::PortInterface *port) |
This method implements port callbacks. More... | |
virtual bool | configureHook () |
Implement this method such that it contains the code which will be executed when configure() is called. More... | |
virtual void | cleanupHook () |
Implement this method such that it contains the code which will be executed when cleanup() is called. More... | |
virtual bool | startHook () |
Implement this method such that it contains the code which will be executed when start() is called. More... | |
virtual void | updateHook () |
Function where the user must insert his 'application' code. More... | |
virtual bool | breakUpdateHook () |
Implement this function if your code might block for long times inside the updateHook() function. More... | |
virtual void | errorHook () |
Implement this method to contain code that must be executed in the RunTimeError state, instead of updateHook(). More... | |
virtual void | exceptionHook () |
Implement this method to contain code that must be executed when transitioning to the Exception state. More... | |
virtual void | stopHook () |
Implement this method such that it contains the code which will be executed when stop() is called. More... | |
virtual void | fatal () |
Call this method from any place to indicate that this component encountered a fatal error. More... | |
virtual void | exception () |
Call this method to indicate a run-time exception happend. More... | |
Protected Attributes | |
ExecutionEngine * | ee |
The execution engine which calls update() and processes our commands, events etc. More... | |
TaskState | mTaskState |
bool | mTriggerOnStart |
Set to false in order to not trigger() when calling start(). More... | |
unsigned int | mCycleCounter |
For each update cycle, this counter increments by one. More... | |
unsigned int | mIOCounter |
Number of cycles that were caused by IOReady triggers. More... | |
unsigned int | mTimeOutCounter |
Number of cycles that were caused by TimeOut triggers. More... | |
unsigned int | mTriggerCounter |
Number of cycles that were caused by Trigger triggers. More... | |
Friends | |
class | ExecutionEngine |
class | DataFlowInterface |
Ports | |
These functions serve to manage ports and data flow connections. Use ports() to access the complete DataFlowInterface functionality of this TaskContext. | |
typedef boost::function< void(base::PortInterface *)> | SlotFunction |
Name and add a Port to the interface of this task and add a Service with the same name of the port. More... | |
base::PortInterface & | addPort (const std::string &name, base::PortInterface &port) |
Name and add a Port to the interface of this task and add a Service with the same name of the port. More... | |
base::PortInterface & | addPort (base::PortInterface &port) |
Add a Port to the interface of this task and add a Service with the same name of the port. More... | |
base::InputPortInterface & | addEventPort (const std::string &name, base::InputPortInterface &port, SlotFunction callback=SlotFunction()) |
Name and add an Event triggering Port to the interface of this task and add a Service with the same name of the port. More... | |
base::InputPortInterface & | addEventPort (base::InputPortInterface &port, SlotFunction callback=SlotFunction()) |
Add an Event triggering Port to the interface of this task and add a Service with the same name of the port. More... | |
base::PortInterface * | getPort (const std::string &name) const |
Get a port of this Component. More... | |
DataFlowInterface * | ports () |
Get the Data flow ports of this task. More... | |
const DataFlowInterface * | ports () const |
Get the Data flow ports of this task. More... | |
virtual bool | connectPorts (TaskContext *peer) |
Add a data flow connection from this task's ports to a peer's ports. More... | |
The TaskContext is the C++ representation of an Orocos component.
It defines which services it provides and requires and which ports are inputs and outputs. It can be configured through the means of properties.
In day-to-day use, TaskContexts are connected using the OCL::DeploymentComponent and an XML file or script.
Definition at line 93 of file TaskContext.hpp.
typedef std::vector< std::string > RTT::TaskContext::PeerList |
A list of Peer TaskContext names.
Definition at line 100 of file TaskContext.hpp.
typedef boost::function<void(base::PortInterface*)> RTT::TaskContext::SlotFunction |
Name and add a Port to the interface of this task and add a Service with the same name of the port.
name | The name to give to the port. |
port | The port to add. |
Definition at line 526 of file TaskContext.hpp.
|
inherited |
Describes the different states a component can have.
When a TaskContext is being constructed, it is in the Init state. After the construction ends, the component arrives in the PreOperational (additional configuration required) or the Stopped (ready to run) state. Invoking start() will make a transition to the Running state and stop() back to the Stopped state. The Running state executes updateHook(). Finally, there is an FatalError state, in which the component can enter by calling the protected method fatal(). In this state, the ExecutionEngine is stopped and updateHook() is no longer called. The object should then be disposed by a supervision system.
Next to the fatal error, one run-time error level is available in the Running state as well. This level allows 'automatic' recovery by the component in case the problem is temporal. In case of problems, one may call the protected method error() when the component is Running. The component will enter the RunTimeError state and will cause the errorHook() to be called instead of updateHook(). When recover() is called, this run-time error state is left and the nominal Running state is entered again.
In order to check if these transitions are allowed, hook functions are executed, which can be filled in by the component builder.
Definition at line 99 of file TaskCore.hpp.
Create a TaskContext.
It's ExecutionEngine will be newly constructed with private processing of commands, events, programs and state machines.
name | The name of this component. |
initial_state | Provide the PreOperational parameter flag here to force users in calling configure(), before they call start(). |
Definition at line 70 of file TaskContext.cpp.
References RTT::base::TaskCore::activate(), addAttribute(), addOperation(), RTT::base::TaskCore::cleanup(), RTT::ClientThread, RTT::base::TaskCore::configure(), RTT::base::TaskCore::error(), RTT::base::TaskCore::getCpuAffinity(), RTT::base::TaskCore::getPeriod(), RTT::base::TaskCore::inException(), RTT::base::TaskCore::inFatalError(), RTT::base::TaskCore::inRunTimeError(), RTT::base::TaskCore::isActive(), RTT::base::TaskCore::isConfigured(), RTT::base::TaskCore::isRunning(), loadService(), RTT::base::TaskCore::mCycleCounter, RTT::base::TaskCore::mIOCounter, RTT::base::TaskCore::mTimeOutCounter, RTT::base::TaskCore::mTriggerCounter, RTT::base::TaskCore::mTriggerOnStart, provides(), RTT::base::TaskCore::setCpuAffinity(), RTT::base::TaskCore::setPeriod(), start(), stop(), RTT::base::TaskCore::trigger(), and RTT::base::TaskCore::update().
|
virtual |
Definition at line 119 of file TaskContext.cpp.
References clear().
|
virtualinherited |
This method starts the ExecutionEngine of this component in case it was not running.
Normally, it is always running. There is no way to deactivate it from the public interface.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 228 of file TaskCore.cpp.
References RTT::base::TaskCore::engine(), RTT::base::RunnableInterface::getActivity(), RTT::base::TaskCore::isActive(), and RTT::base::ActivityInterface::start().
Referenced by RTT_corba_CTaskContext_i::activate(), and TaskContext().
|
inline |
Adds a variable of any type as read/write attribute to the attribute interface.
An Alias is created which causes contents of the attr variable always to be in sync with the contents of the attribute object in the interface.
name | The name of this attribute |
attr | The variable that will be aliased. |
Definition at line 400 of file TaskContext.hpp.
Referenced by TaskContext().
|
inline |
Add an base::AttributeBase which remains owned by the user.
This is a low-level function that can be used if you already created an Attribute object that does not belong yet to a service.
a | remains owned by the user, and becomes served by the repository. |
Definition at line 426 of file TaskContext.hpp.
|
inline |
Adds a variable of any type as read-only attribute to the attribute interface.
An Alias is created which causes contents of the attribute always to be in sync with the contents of attr, but it can only be read through the interface.
name | The name of this attribute |
attr | The variable that will be aliased. |
Definition at line 413 of file TaskContext.hpp.
|
inline |
Name and add an Event triggering Port to the interface of this task and add a Service with the same name of the port.
name | The name to give to the port. |
port | The port to add. |
callback | (Optional) provide a function which will be called asynchronously when new data arrives on this port. You can add more functions by using the port directly using base::PortInterface::getNewDataOnPort(). |
Definition at line 536 of file TaskContext.hpp.
References RTT::base::PortInterface::setName().
|
inline |
Add an Event triggering Port to the interface of this task and add a Service with the same name of the port.
port | The port to add. |
callback | (Optional) provide a function which will be called asynchronously when new data arrives on this port. You can add more functions by using the port directly using base::PortInterface::getNewDataOnPort(). |
Definition at line 549 of file TaskContext.hpp.
|
inline |
Add an operation object to the interface.
This version of addOperation exports an Operation object to the public interface of this component.
op | The operation object to add. |
Definition at line 336 of file TaskContext.hpp.
Referenced by RTT_corba_CTaskContext_i::RTT_corba_CTaskContext_i(), and TaskContext().
|
inline |
Adds a C++ function as an operation.
Definition at line 347 of file TaskContext.hpp.
|
inline |
Adds a C function as an operation.
Definition at line 358 of file TaskContext.hpp.
|
virtual |
Add a one-way connection from this task to a peer task.
peer | The peer to add. |
alias | An optional alias (another name) for the peer. defaults to peer->getName() |
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 249 of file TaskContext.cpp.
References getName().
Referenced by RTT_corba_CTaskContext_i::addPeer(), and connectPeers().
|
inline |
Name and add a Port to the interface of this task and add a Service with the same name of the port.
name | The name to give to the port. |
port | The port to add. |
Definition at line 512 of file TaskContext.hpp.
References RTT::base::PortInterface::setName().
|
inline |
Add a Port to the interface of this task and add a Service with the same name of the port.
port | The port to add. |
Definition at line 522 of file TaskContext.hpp.
|
inline |
Adds a variable of any type as a property to the attribute interface.
A Property is created which causes contents of the property always to be in sync with the contents of attr.
name | The name of this property |
attr | The variable that will be aliased. |
Definition at line 468 of file TaskContext.hpp.
|
inline |
Add an base::PropertyBase as a property.
Definition at line 476 of file TaskContext.hpp.
|
inline |
Returns the attributes of this TaskContext as an ConfigurationInterface.
Definition at line 447 of file TaskContext.hpp.
Referenced by RTT::scripting::ExpressionParser::getHandle().
|
protectedvirtualinherited |
Implement this function if your code might block for long times inside the updateHook() function.
Insert in this hook the code to wake up that code or signal it otherwise that updateHook() is requested to return (for example by setting a flag). The method returns false by default.
Definition at line 297 of file TaskCore.cpp.
Referenced by RTT::ExecutionEngine::breakLoop().
|
virtualinherited |
This method instructs a stopped component to enter the pre-operational state again.
It calls cleanupHook().
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 116 of file TaskCore.cpp.
References CATCH, CATCH_ALL, RTT::base::TaskCore::cleanupHook(), RTT::Error, RTT::base::TaskCore::exception(), RTT::base::TaskCore::mTaskState, RTT::base::TaskCore::PreOperational, RTT::base::TaskCore::Stopped, and TRY.
Referenced by RTT_corba_CTaskContext_i::cleanup(), and TaskContext().
|
protectedvirtualinherited |
Implement this method such that it contains the code which will be executed when cleanup() is called.
The default implementation is an empty function.
Definition at line 233 of file TaskCore.cpp.
Referenced by RTT::base::TaskCore::cleanup(), and RTT::base::TaskCore::exception().
|
virtual |
Clear the complete interface of this Component.
This method removes all objects and all methods, commands, events, properties and ports from the interface of this TaskContext.
Definition at line 382 of file TaskContext.cpp.
Referenced by RTT::corba::TaskContextProxy::activate(), RTT::corba::TaskContextProxy::addPeer(), RTT::corba::TaskContextProxy::cleanup(), RTT::corba::TaskContextProxy::configure(), RTT::corba::TaskContextProxy::connectPeers(), RTT::corba::TaskContextProxy::connectPorts(), RTT::corba::TaskContextProxy::connectServices(), RTT::corba::TaskContextProxy::disconnectPeers(), RTT::corba::TaskContextProxy::initFromURIOrTaskname(), RTT::corba::TaskContextProxy::ready(), RTT::corba::TaskContextProxy::recover(), RTT::corba::TaskContextProxy::removePeer(), RTT::corba::TaskContextProxy::start(), RTT::corba::TaskContextProxy::stop(), RTT::corba::TaskContextProxy::TaskContextProxy(), and ~TaskContext().
|
virtualinherited |
This method instructs the component to (re-)read configuration data and try to enter the Stopped state.
This can only succeed if the component is not running and configureHook() returns true.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 93 of file TaskCore.cpp.
References CATCH, CATCH_ALL, RTT::base::TaskCore::configureHook(), RTT::Error, RTT::base::TaskCore::exception(), RTT::base::TaskCore::mTaskState, RTT::base::TaskCore::PreOperational, RTT::base::TaskCore::Stopped, and TRY.
Referenced by RTT_corba_CTaskContext_i::configure(), and TaskContext().
|
protectedvirtualinherited |
Implement this method such that it contains the code which will be executed when configure() is called.
The default implementation is an empty function which returns true.
true | to indicate that configuration succeeded and the Stopped state may be entered. |
false | to indicate that configuration failed and the Preoperational state is entered. |
Definition at line 281 of file TaskCore.cpp.
Referenced by RTT::base::TaskCore::configure().
|
virtual |
Add a two-way connection from this task to a peer task.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 279 of file TaskContext.cpp.
References addPeer(), getName(), and hasPeer().
Referenced by RTT_corba_CTaskContext_i::connectPeers(), and RTT::connectPeers().
|
virtual |
Add a data flow connection from this task's ports to a peer's ports.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 151 of file TaskContext.cpp.
References RTT::Debug, RTT::base::PortInterface::getName(), getName(), RTT::DataFlowInterface::getPort(), RTT::DataFlowInterface::getPorts(), and ports().
Referenced by RTT_corba_CTaskContext_i::connectPorts(), and RTT::connectPorts().
|
virtual |
Connects all requires/provides services of this component to these of a peer.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 188 of file TaskContext.cpp.
References RTT::Debug, getName(), RTT::plugin::PluginLoader::Instance(), provides(), and requires().
Referenced by RTT_corba_CTaskContext_i::connectServices().
|
protectedvirtual |
This method implements port callbacks.
It will be called once per sample received on the port and is executed in the component's thread.
The default implementation invokes the user callback if one was given in the addEventPort() call. It can be overwritten in a subclass to react on incoming data for all event ports. This is equivalent to adding this function as a user callback on each of the ports individually.
Definition at line 435 of file TaskContext.cpp.
Referenced by RTT::ExecutionEngine::processPortCallbacks().
|
protectedvirtual |
Reimplement this method to influence how writing to event ports is handled by the component.
This method will be executed in the writer's thread.
The default implementation returns true if and only if the component is running.
true | to indicate that the user callback should be invoked and trigger the component |
false | to ignore the new data and not trigger the component or invoke a user callback |
Definition at line 431 of file TaskContext.cpp.
References RTT::base::TaskCore::isRunning().
Referenced by stop().
|
virtual |
Disconnect this TaskContext from it's peers and ports.
All its Data Flow Ports are disconnected as well. This method invokes removePeer() as well on the peers listed in this->getPeerList().
Definition at line 289 of file TaskContext.cpp.
References getName(), RTT::DataFlowInterface::getPorts(), and ports().
|
virtual |
Remove a two-way connection from this task to a peer task.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 310 of file TaskContext.cpp.
References removePeer().
Referenced by RTT_corba_CTaskContext_i::disconnectPeers().
|
inlineinherited |
Get a const pointer to the ExecutionEngine of this Task.
Definition at line 306 of file TaskCore.hpp.
Referenced by RTT::base::TaskCore::activate(), RTT::Service::addLocalOperation(), RTT::ServiceRequester::connectTo(), RTT::base::TaskCore::fatal(), forceActivity(), getActivity(), RTT::base::TaskCore::getCpuAffinity(), RTT::Service::getOwnerExecutionEngine(), RTT::scripting::StateGraphParser::getParserResult(), RTT::base::TaskCore::getPeriod(), RTT::base::TaskCore::isActive(), RTT::scripting::ScriptingService::loadFunctions(), RTT::scripting::ScriptingService::loadProgram(), RTT::scripting::ScriptingService::loadPrograms(), RTT::scripting::ScriptingService::loadStateMachines(), RTT::scripting::Parser::parseCondition(), RTT::scripting::Parser::parseFunction(), RTT::scripting::Parser::parseProgram(), RTT::scripting::ProgramGraphParser::parserUsed(), RTT::scripting::Parser::parseStateMachine(), RTT::scripting::Parser::parseValueStatement(), RTT::scripting::ScriptingService::recursiveLoadStateMachine(), RTT::scripting::ScriptingService::recursiveUnloadStateMachine(), setActivity(), RTT::base::TaskCore::setCpuAffinity(), RTT::ServiceRequester::setOwner(), RTT::Service::setOwner(), RTT::base::TaskCore::setPeriod(), stop(), RTT::base::TaskCore::stop(), RTT::base::TaskCore::trigger(), RTT::scripting::ScriptingService::unloadProgram(), and RTT::base::TaskCore::update().
|
inlineinherited |
Get a pointer to the ExecutionEngine of this Task.
Definition at line 314 of file TaskCore.hpp.
|
virtualinherited |
Call this method in a Running state to indicate a run-time error condition.
errorHook() will be called instead of updateHook(). If the error condition is solved, call recover().
Definition at line 140 of file TaskCore.cpp.
References RTT::base::TaskCore::mTaskState, RTT::base::TaskCore::Running, and RTT::base::TaskCore::RunTimeError.
Referenced by TaskContext().
|
protectedvirtualinherited |
Implement this method to contain code that must be executed in the RunTimeError state, instead of updateHook().
This allows you to specify the behaviour in an erroneous component. errorHook() is called as long as the component is not recover()'ed. After recover()'ed, the updateHook() is called again.
Definition at line 290 of file TaskCore.cpp.
Referenced by RTT::ExecutionEngine::processHooks().
|
protectedvirtualinherited |
Call this method to indicate a run-time exception happend.
First the TaskState is set to Exception. Next, if the taskstate was >= Running, stopHook() is called. Next, if the taskstate was >= Stopped, cleanupHook() is called. Finally, exceptionHook() is called. If any exception happens in exceptionHook(), fatal() is called.
Definition at line 147 of file TaskCore.cpp.
References CATCH, CATCH_ALL, RTT::base::TaskCore::cleanupHook(), RTT::Error, RTT::base::TaskCore::Exception, RTT::base::TaskCore::exceptionHook(), RTT::base::TaskCore::fatal(), RTT::base::TaskCore::mTaskState, RTT::base::TaskCore::PreOperational, RTT::base::TaskCore::Running, RTT::base::TaskCore::stopHook(), RTT::base::TaskCore::Stopped, and TRY.
Referenced by RTT::base::TaskCore::cleanup(), RTT::base::TaskCore::configure(), RTT::ExecutionEngine::processHooks(), RTT::ExecutionEngine::setExceptionTask(), RTT::base::TaskCore::start(), and RTT::base::TaskCore::stop().
|
protectedvirtualinherited |
Implement this method to contain code that must be executed when transitioning to the Exception state.
This allows you to specify the last actions in an erroneous component, after stopHook() and cleanupHook() were called.
Definition at line 302 of file TaskCore.cpp.
Referenced by RTT::base::TaskCore::exception().
|
protectedvirtualinherited |
Call this method from any place to indicate that this component encountered a fatal error.
It calls no hooks, the ExecutionEngine is stopped and the component waits destruction.
Definition at line 135 of file TaskCore.cpp.
References RTT::base::TaskCore::engine(), RTT::base::TaskCore::FatalError, RTT::base::RunnableInterface::getActivity(), RTT::base::TaskCore::mTaskState, and RTT::base::ActivityInterface::stop().
Referenced by RTT::base::TaskCore::exception().
|
protected |
Forces the current activity to become new_act, even if this TaskContext is still running.
This can be used to bypass the isRunning() check regular setActivity() does.
Definition at line 362 of file TaskContext.cpp.
References RTT::base::TaskCore::engine(), and RTT::base::ActivityInterface::stop().
Referenced by RTT::corba::TaskContextProxy::TaskContextProxy().
ActivityInterface * RTT::TaskContext::getActivity | ( | ) |
Get a pointer to the activity running this component.
Definition at line 375 of file TaskContext.cpp.
References RTT::base::TaskCore::engine(), and RTT::base::RunnableInterface::getActivity().
|
inline |
Get a pointer to the activity running this component.
Unlike the non-template version, it converts it to the activity type provided.
Example usage in a startHook(): RTT::extras::FileDescriptorActivity* fd_activity = getActivity<RTT::extras::FileDescriptorActivity>(); if (fd_activity) { // do specific setup for FDActivity }
Definition at line 162 of file TaskContext.hpp.
References RTT::connectPeers(), and getActivity().
Referenced by getActivity().
|
inline |
Adds a variable of any type as read/write attribute to the attribute interface.
An Alias is created which causes contents of the attr variable always to be in sync with the contents of the attribute object in the interface.
name | The name of this attribute |
attr | The variable that will be aliased. |
Definition at line 439 of file TaskContext.hpp.
|
virtualinherited |
Get the configured cpu affinity of this component.
Definition at line 271 of file TaskCore.cpp.
References RTT::base::TaskCore::engine(), RTT::base::RunnableInterface::getActivity(), and RTT::base::ActivityInterface::getCpuAffinity().
Referenced by TaskContext().
|
inlineinherited |
For each update cycle, this counter increments by one.
You can use this to check across (callback) functions if we're still in the same cycle or in a new one.
Definition at line 324 of file TaskCore.hpp.
|
inlineinherited |
Number of cycles that were caused by IOReady triggers.
Definition at line 332 of file TaskCore.hpp.
|
inlinevirtual |
Returns the name of this TaskContext.
Definition at line 117 of file TaskContext.hpp.
Referenced by addPeer(), RTT::corba::TaskContextServer::CleanupServer(), connectPeers(), connectPorts(), connectServices(), RTT::corba::TaskContextServer::Create(), RTT::corba::TaskContextServer::CreateServer(), RTT::scripting::DataCallParser::DataCallParser(), disconnect(), RTT_corba_CTaskContext_i::getName(), RTT_corba_CTaskContext_i::getProvider(), RTT_corba_CTaskContext_i::getRequester(), RTT::corba::CorbaDispatcher::Instance(), RTT::plugin::PluginLoader::loadService(), RTT::scripting::ProgramGraphParser::parserUsed(), RTT::corba::TaskContextProxy::removePeer(), RTT::ExecutionEngine::setExceptionTask(), RTT::mqueue::MQSendRecv::setupStream(), and RTT::scripting::StateGraphParser::storeOffset().
|
inline |
Get a previously added operation for use in a C++ OperationCaller object.
Store the result of this function in a OperationCaller<Signature> object.
name | The name of the operation to retrieve. |
Definition at line 372 of file TaskContext.hpp.
|
virtual |
Get a pointer to a peer of this task.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 333 of file TaskContext.cpp.
References hasPeer().
Referenced by RTT_corba_CTaskContext_i::getPeer(), and RTT::scripting::PeerParser::reset().
|
virtual |
Return a standard container which contains all the Peer names of this TaskContext.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 319 of file TaskContext.cpp.
Referenced by RTT_corba_CTaskContext_i::getPeerList().
|
virtualinherited |
Get the configured execution period of this component.
Note that this value only is used when the component isActive() or isRunning().
0.0 | if the component is non-periodic (event based). |
a | negative number when the component is not executable. |
a | positive value when the component is periodic. The period is expressed in seconds. |
Definition at line 261 of file TaskCore.cpp.
References RTT::base::TaskCore::engine(), RTT::base::RunnableInterface::getActivity(), and RTT::base::ActivityInterface::getPeriod().
Referenced by TaskContext().
|
inline |
Get a port of this Component.
name | The port name |
Definition at line 558 of file TaskContext.hpp.
|
inline |
Get a Property with name name.
name | The name of the property to search for. |
Definition at line 487 of file TaskContext.hpp.
|
inline |
Use this method to be able to make OperationCaller calls to services provided by this component.
In case the service does not exist in this component, it tries to load the service using the plugin::PluginLoader class. If all fails, a null pointer is returned.
For example: getProvider<Scripting>("scripting")->loadPrograms("file.ops");
name | The name of the service to get, must have been added with addService. |
ServiceType | the ServiceRequester type to use. Must have a constructor that takes TaskContext* as argument. |
Definition at line 298 of file TaskContext.hpp.
|
virtualinherited |
Returns the state this TaskCore is going to, or in case no transition is taking place, returns getTaskState().
For example, before start(), this function returns Stopped. During startHook(), it returns Running and after start() it also returns Running.
If getTaskState() != getTargetState, a transition is taking place.
Definition at line 79 of file TaskCore.cpp.
|
virtualinherited |
Returns the current state of the TaskCore.
For example, before start(), this function returns Stopped. During startHook() it returns Stopped, and after start() it returns Running.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 75 of file TaskCore.cpp.
References RTT::base::TaskCore::mTaskState.
Referenced by RTT_corba_CTaskContext_i::getTaskState(), and RTT_corba_CTaskContext_i::resetException().
|
inlineinherited |
Number of cycles that were caused by TimeOut triggers.
Definition at line 336 of file TaskCore.hpp.
|
inlineinherited |
Number of cycles that were caused by Trigger triggers.
Definition at line 328 of file TaskCore.hpp.
|
virtual |
Return true if it knows a peer by that name.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 328 of file TaskContext.cpp.
Referenced by RTT_corba_CTaskContext_i::addPeer(), connectPeers(), getPeer(), RTT_corba_CTaskContext_i::hasPeer(), and RTT::scripting::PeerParser::reset().
|
virtualinherited |
Inspect if the component is in the Exception state.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 248 of file TaskCore.cpp.
References RTT::base::TaskCore::Exception, and RTT::base::TaskCore::mTaskState.
Referenced by RTT_corba_CTaskContext_i::inException(), and TaskContext().
|
virtualinherited |
Inspect if the component is in the FatalError state.
There is no possibility to recover from this state. You need to destroy and recreate your component.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 244 of file TaskCore.cpp.
References RTT::base::TaskCore::FatalError, and RTT::base::TaskCore::mTaskState.
Referenced by RTT_corba_CTaskContext_i::inFatalError(), and TaskContext().
|
virtualinherited |
Inspect if the component is in the RunTimeError state.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 252 of file TaskCore.cpp.
References RTT::base::TaskCore::mTaskState, and RTT::base::TaskCore::RunTimeError.
Referenced by RTT_corba_CTaskContext_i::inRunTimeError(), and TaskContext().
|
virtualinherited |
Inspect if the component's ExecutionEngine is processing requests.
Normally this is always the case, but user code could stop the ExecutionEngine manually.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 256 of file TaskCore.cpp.
References RTT::base::TaskCore::engine(), RTT::base::RunnableInterface::getActivity(), and RTT::base::ActivityInterface::isActive().
Referenced by RTT::base::TaskCore::activate(), RTT_corba_CTaskContext_i::isActive(), and TaskContext().
|
virtualinherited |
Inspect if the component is configured, i.e.
in the Stopped, Active or Running state.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 240 of file TaskCore.cpp.
References RTT::base::TaskCore::mTaskState, and RTT::base::TaskCore::Stopped.
Referenced by RTT_corba_CTaskContext_i::isConfigured(), and TaskContext().
|
virtualinherited |
Inspect if the component is in the Running or RunTimeError state.
As RunTimeError is a substate of Running, this method also returns true when the component is in one of these states. See inRunTimeError() or testing the run-time error state.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 236 of file TaskCore.cpp.
References RTT::base::TaskCore::mTaskState, and RTT::base::TaskCore::Running.
Referenced by dataOnPortHook(), RTT_corba_CTaskContext_i::isRunning(), setActivity(), start(), stop(), and TaskContext().
bool RTT::TaskContext::loadService | ( | const std::string & | service_name | ) |
Use this method to load a service known to RTT into this component.
service_name | The name with which the service is registered by in the PluginLoader. |
Definition at line 230 of file TaskContext.cpp.
References RTT::plugin::PluginLoader::Instance(), and provides().
Referenced by TaskContext().
|
inline |
Returns the operations of this TaskContext as an OperationInterface.
Definition at line 380 of file TaskContext.hpp.
|
inline |
Get the Data flow ports of this task.
Definition at line 566 of file TaskContext.hpp.
Referenced by connectPorts(), disconnect(), start(), and stop().
|
inline |
Get the Data flow ports of this task.
Definition at line 573 of file TaskContext.hpp.
References RTT::connectPorts().
|
inline |
Returns the properties of this TaskContext as a PropertyBag.
Definition at line 495 of file TaskContext.hpp.
|
inline |
Returns this Service.
Definition at line 257 of file TaskContext.hpp.
Referenced by RTT::corba::TaskContextServer::CleanupServer(), connectServices(), RTT::marsh::MarshallingService::Create(), RTT::scripting::ScriptingService::Create(), RTT::Service::Create(), RTT::StatementProcessor::D::doPrint(), RTT_corba_CTaskContext_i::getDescription(), RTT::scripting::StateGraphParser::getParserResult(), RTT_corba_CTaskContext_i::getProvider(), RTT::corba::TaskContextProxy::initFromURIOrTaskname(), loadService(), RTT::scripting::ProgramGraphParser::parseFunction(), RTT::scripting::ProgramGraphParser::parserUsed(), RTT::scripting::Parser::parseValueStatement(), RTT::scripting::PeerParser::reset(), RTT::scripting::ScriptParser::ScriptParser(), RTT::scripting::StateGraphParser::storeOffset(), RTT::corba::TaskContextProxy::synchronize(), TaskContext(), RTT::corba::TaskContextProxy::TaskContextProxy(), and RTT::scripting::StateGraphParser::~StateGraphParser().
|
inline |
Returns a sub-Service which resorts under this Service.
service_name | The name of the sub-service. |
Definition at line 264 of file TaskContext.hpp.
|
virtual |
Checks the validity of this TaskContext.
When this method returns false, the TaskContext should not be used and various methods may throw exceptions. Use this in case the TaskContext could be a remote object. Will always return true when this TaskContext is local.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 388 of file TaskContext.cpp.
Referenced by RTT::scripting::PeerParser::reset().
|
virtualinherited |
Call this method in a RunTimeError or Exception state to indicate that the run-time error conditions are gone and nominal operation is resumed.
Makes transition to Running or PreOperational, depending on the state it was in.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 168 of file TaskCore.cpp.
References RTT::base::TaskCore::Exception, RTT::base::TaskCore::mTaskState, RTT::base::TaskCore::Running, and RTT::base::TaskCore::RunTimeError.
Referenced by RTT_corba_CTaskContext_i::recover(), and RTT_corba_CTaskContext_i::resetException().
|
virtual |
Remove a one-way connection from this task to a peer task.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 260 of file TaskContext.cpp.
Referenced by disconnectPeers(), and RTT_corba_CTaskContext_i::removePeer().
|
virtual |
Remove a one-way connection from this task to a peer task.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 269 of file TaskContext.cpp.
|
inline |
Returns the object that manages which methods this Task requires to be implemented by another task.
Definition at line 270 of file TaskContext.hpp.
Referenced by connectServices(), RTT_corba_CTaskContext_i::getRequester(), RTT::corba::TaskContextProxy::synchronize(), and RTT::corba::TaskContextProxy::synchronizeRequesters().
|
inline |
Returns the object that manages which methods this Task requires to be implemented by another service.
Definition at line 276 of file TaskContext.hpp.
bool RTT::TaskContext::setActivity | ( | base::ActivityInterface * | new_act | ) |
Sets the activity of this TaskContext.
The activity is owned by the TaskContext and you should not hold a pointer to it after this call. Use getActivity() lateron to retrieve a safe pointer to it.
new_act | The new activity for this TaskContext, which becomes owned by this TaskContext, in case this method returns true. |
Definition at line 340 of file TaskContext.cpp.
References RTT::base::TaskCore::engine(), RTT::base::TaskCore::isRunning(), RTT::base::ActivityInterface::run(), and RTT::base::ActivityInterface::stop().
Referenced by RTT::corba::TaskContextProxy::initFromURIOrTaskname().
|
virtualinherited |
Sets the cpu affinity of this component.
Definition at line 276 of file TaskCore.cpp.
References RTT::base::TaskCore::engine(), RTT::base::RunnableInterface::getActivity(), and RTT::base::ActivityInterface::setCpuAffinity().
Referenced by TaskContext().
|
virtualinherited |
Sets the period of this component.
You may call this at any time, it is simply forwarded to the component's activity object.
Definition at line 266 of file TaskCore.cpp.
References RTT::base::TaskCore::engine(), RTT::base::RunnableInterface::getActivity(), and RTT::base::ActivityInterface::setPeriod().
Referenced by TaskContext().
|
virtual |
This method starts the execution of the updateHook() with each trigger or period.
This function calls the user function startHook(), which must return true in order to allow this component to run.
false |
|
true | if the Running state was entered. |
Reimplemented from RTT::base::TaskCore.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 401 of file TaskContext.cpp.
References RTT::base::TaskCore::isRunning(), ports(), and RTT::base::TaskCore::start().
Referenced by RTT_corba_CTaskContext_i::start(), and TaskContext().
|
protectedvirtualinherited |
Implement this method such that it contains the code which will be executed when start() is called.
The default implementation is an empty function which returns true.
true | to indicate that the component may run and the Running state may be entered. |
false | to indicate that the component may not run and the Stopped state is entered. |
Definition at line 285 of file TaskCore.cpp.
Referenced by RTT::base::TaskCore::start().
|
virtual |
This method stops the execution of updateHook() of this component.
You can override this method to do something else or in addition. This function calls stopHook() as well.
Reimplemented from RTT::base::TaskCore.
Reimplemented in RTT::corba::TaskContextProxy.
Definition at line 411 of file TaskContext.cpp.
References dataOnPortHook(), RTT::base::TaskCore::engine(), RTT::base::TaskCore::isRunning(), ports(), RTT::ExecutionEngine::process(), and RTT::base::TaskCore::stop().
Referenced by RTT_corba_CTaskContext_i::stop(), and TaskContext().
|
protectedvirtualinherited |
Implement this method such that it contains the code which will be executed when stop() is called.
The default implementation is an empty function.
Definition at line 305 of file TaskCore.cpp.
Referenced by RTT::base::TaskCore::exception(), and RTT::base::TaskCore::stop().
|
virtualinherited |
Invoke this method to trigger the thread of this TaskContext to execute its ExecutionEngine and the update() method.
Definition at line 88 of file TaskCore.cpp.
References RTT::base::TaskCore::engine(), RTT::base::RunnableInterface::getActivity(), and RTT::base::ActivityInterface::timeout().
Referenced by RTT::DataFlowInterface::addLocalEventPort(), RTT::base::TaskCore::start(), and TaskContext().
|
virtualinherited |
Invoke this method to execute the ExecutionEngine and the update() method.
false | if this->engine()->getActivity()->execute() == false |
true | otherwise. |
Definition at line 83 of file TaskCore.cpp.
References RTT::base::TaskCore::engine(), RTT::base::ActivityInterface::execute(), and RTT::base::RunnableInterface::getActivity().
Referenced by TaskContext().
|
protectedvirtualinherited |
Function where the user must insert his 'application' code.
When the ExecutionEngine's Activity is a periodic, this function is called by the ExecutionEngine in each periodic step after all messages are processed. When it is executed by a non periodic activity, this function is called after a message is received and executed. It should not loop forever, since no commands or events are processed when this function executes. The default implementation is an empty function.
Definition at line 293 of file TaskCore.cpp.
Referenced by RTT::ExecutionEngine::processHooks().
|
friend |
Definition at line 650 of file TaskContext.hpp.
|
friend |
Definition at line 622 of file TaskContext.hpp.
|
protectedinherited |
The execution engine which calls update() and processes our commands, events etc.
Definition at line 444 of file TaskCore.hpp.
Referenced by RTT::base::TaskCore::~TaskCore().
|
protectedinherited |
For each update cycle, this counter increments by one.
You can use this to check across (callback) functions if we're still in the same cycle or in a new one.
Definition at line 476 of file TaskCore.hpp.
Referenced by TaskContext(), and RTT::ExecutionEngine::work().
|
protectedinherited |
Number of cycles that were caused by IOReady triggers.
Definition at line 480 of file TaskCore.hpp.
Referenced by TaskContext(), and RTT::ExecutionEngine::work().
|
protectedinherited |
Definition at line 446 of file TaskCore.hpp.
Referenced by RTT::base::TaskCore::cleanup(), RTT::base::TaskCore::configure(), RTT::base::TaskCore::error(), RTT::base::TaskCore::exception(), RTT::base::TaskCore::fatal(), RTT::base::TaskCore::getTaskState(), RTT::base::TaskCore::inException(), RTT::base::TaskCore::inFatalError(), RTT::base::TaskCore::inRunTimeError(), RTT::base::TaskCore::isConfigured(), RTT::base::TaskCore::isRunning(), RTT::ExecutionEngine::process(), RTT::ExecutionEngine::processHooks(), RTT::base::TaskCore::recover(), RTT::ExecutionEngine::runFunction(), RTT::base::TaskCore::start(), and RTT::base::TaskCore::stop().
|
protectedinherited |
Number of cycles that were caused by TimeOut triggers.
Definition at line 484 of file TaskCore.hpp.
Referenced by TaskContext(), and RTT::ExecutionEngine::work().
|
protectedinherited |
Number of cycles that were caused by Trigger triggers.
Definition at line 488 of file TaskCore.hpp.
Referenced by TaskContext(), and RTT::ExecutionEngine::work().
|
protectedinherited |
Set to false in order to not trigger() when calling start().
Definition at line 469 of file TaskCore.hpp.
Referenced by RTT::base::TaskCore::start(), and TaskContext().