Orocos Real-Time Toolkit
2.6.0
|
This class manages the access of remote TaskContext Corba Servers and a Corba Object Request Broker (Orb) which connects to these servers. More...
#include <rtt/transports/corba/TaskContextProxy.hpp>
Public Types | |
typedef std::map < TaskContextProxy *, corba::CTaskContext_ptr > | PMap |
typedef std::vector< std::string > | PeerList |
A list of Peer TaskContext names. | |
enum | TaskState { Init, PreOperational, FatalError, Exception, Stopped, Running, RunTimeError } |
Describes the different states a component can have. More... | |
Public Member Functions | |
corba::CTaskContext_ptr | server () const |
Get the Corba Object of the CTaskContext. | |
virtual bool | activate () |
This method starts the ExecutionEngine of this component in case it was not running. | |
virtual bool | start () |
This method starts the execution of the updateHook() with each trigger or period. | |
virtual bool | stop () |
This method stops the execution of updateHook() of this component. | |
virtual bool | isRunning () const |
Inspect if the component is in the Running or RunTimeError state. | |
virtual bool | configure () |
This method instructs the component to (re-)read configuration data and try to enter the Stopped state. | |
virtual bool | cleanup () |
This method instructs a stopped component to enter the pre-operational state again. | |
virtual bool | isActive () const |
Inspect if the component's ExecutionEngine is processing requests. | |
virtual bool | isConfigured () const |
Inspect if the component is configured, i.e. | |
virtual bool | inFatalError () const |
Inspect if the component is in the FatalError state. | |
virtual bool | inRunTimeError () const |
Inspect if the component is in the RunTimeError state. | |
virtual TaskState | getTaskState () const |
Returns the current state of the TaskCore. | |
virtual void | setName (const std::string &n) |
virtual bool | addPeer (TaskContext *peer, std::string alias="") |
Add a one-way connection from this task to a peer task. | |
virtual void | removePeer (const std::string &name) |
Remove a one-way connection from this task to a peer task. | |
virtual void | removePeer (TaskContext *peer) |
Remove a one-way connection from this task to a peer task. | |
virtual bool | connectPeers (TaskContext *peer) |
Add a two-way connection from this task to a peer task. | |
virtual void | disconnectPeers (const std::string &name) |
Remove a two-way connection from this task to a peer task. | |
virtual PeerList | getPeerList () const |
Return a standard container which contains all the Peer names of this TaskContext. | |
virtual bool | hasPeer (const std::string &peer_name) const |
Return true if it knows a peer by that name. | |
virtual TaskContext * | getPeer (const std::string &peer_name) const |
Get a pointer to a peer of this task. | |
virtual bool | connectPorts (TaskContext *peer) |
Add a data flow connection from this task's ports to a peer's ports. | |
virtual bool | connectServices (TaskContext *peer) |
Connects all requires/provides services of this component to these of a peer. | |
virtual bool | ready () |
Checks the validity of this TaskContext. | |
virtual const std::string & | getName () |
Returns the name of this TaskContext. | |
bool | setActivity (base::ActivityInterface *new_act) |
Sets the activity of this TaskContext. | |
base::ActivityInterface * | getActivity () |
Get a pointer to the activity running this component. | |
template<typename T > | |
T * | getActivity () |
Get a pointer to the activity running this component. | |
virtual void | clear () |
Clear the complete interface of this Component. | |
virtual TaskState | getTargetState () const |
Returns the state this TaskCore is going to, or in case no transition is taking place, returns getTaskState(). | |
void | setExecutionEngine (ExecutionEngine *engine) |
Use this method to re-set the execution engine of this task core. | |
const ExecutionEngine * | engine () const |
Get a const pointer to the ExecutionEngine of this Task. | |
ExecutionEngine * | engine () |
Get a pointer to the ExecutionEngine of this Task. | |
Peer-to-Peer functions | |
These functions are used to setup and manage peer-to-peer networks of TaskContext objects. | |
virtual void | disconnect () |
Disconnect this TaskContext from it's peers and ports. | |
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. | |
Service::shared_ptr | provides (const std::string &service_name) |
Returns a sub-Service which resorts under this Service. | |
ServiceRequester * | requires () |
Returns the object that manages which methods this Task requires to be implemented by another task. | |
ServiceRequester * | requires (const std::string &service_name) |
Returns the object that manages which methods this Task requires to be implemented by another service. | |
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. | |
bool | loadService (const std::string &service_name) |
Use this method to load a service known to RTT into this component. | |
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. | |
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. | |
template<class Signature > | |
Operation< Signature > & | addOperation (const std::string name, Signature *func, ExecutionThread et=ClientThread) |
Adds a C function as an operation. | |
OperationInterfacePart * | getOperation (std::string name) |
Get a previously added operation for use in a C++ OperationCaller object. | |
OperationInterface * | operations () |
Returns the operations of this TaskContext as an OperationInterface. | |
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. | |
bool | addAttribute (base::AttributeBase &a) |
Add an base::AttributeBase which remains owned by the user. | |
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. | |
base::AttributeBase * | getAttribute (const std::string &name) const |
Adds a variable of any type as read/write attribute to the attribute interface. | |
ConfigurationInterface * | attributes () |
Returns the attributes of this TaskContext as an ConfigurationInterface. | |
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. | |
bool | addProperty (base::PropertyBase &pb) |
Add an base::PropertyBase as a property. | |
base::PropertyBase * | getProperty (const std::string &name) const |
Get a Property with name name. | |
PropertyBag * | properties () |
Returns the properties of this TaskContext as a PropertyBag. | |
Operations | |
These TaskCore functions are exported in a TaskContext as script methods and are for configuration, starting and stopping its ExecutionEngine. | |
virtual Seconds | getPeriod () const |
Get the configured execution period of this component. | |
virtual bool | setPeriod (Seconds s) |
Sets the period of this component. | |
virtual unsigned | getCpuAffinity () const |
Get the configured cpu affinity of this component. | |
virtual bool | setCpuAffinity (unsigned cpu) |
Sets the cpu affinity of this component. | |
virtual bool | inException () const |
Inspect if the component is in the Exception state. | |
virtual bool | update () |
Invoke this method to execute the ExecutionEngine and the update() method. | |
virtual bool | trigger () |
Invoke this method to trigger the thread of this TaskContext to execute its ExecutionEngine and the update() method. | |
virtual void | error () |
Call this method in a Running state to indicate a run-time error condition. | |
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. | |
Static Public Member Functions | |
static void | DestroyOrb () |
Invoke this method once to cleanup the orb. | |
static TaskContextProxy * | Create (std::string name, bool is_ior=false) |
Factory method: create a CORBA Proxy for an existing TaskContextServer. | |
static TaskContextProxy * | CreateFromFile (std::string filename) |
Factory method: create a CORBA Proxy for an existing TaskContextServer. | |
static TaskContext * | Create (::RTT::corba::CTaskContext_ptr task, bool force_remote=false) |
Factory method: create a CORBA Proxy for an existing TaskContextServer. | |
static PortableServer::POA_ptr | ProxyPOA () |
Returns the default POA for all proxies. | |
static RTT_CORBA_API bool | InitOrb (int argc, char *argv[], Seconds orb_timeout=0) |
Invoke this method once to initialise the Orb which will run the task servers. | |
Static Public Attributes | |
static PMap | proxies |
static CORBA::ORB_var | orb |
The orb of this process. | |
static PortableServer::POA_var | rootPOA |
The root POA of this process. | |
Protected Member Functions | |
TaskContextProxy (std::string location, bool is_ior) | |
Private constructor which creates a new connection to a stringified ior or taskname in NameServer. | |
TaskContextProxy (::RTT::corba::CTaskContext_ptr t) | |
Private constructor which creates a new connection to a corba object. | |
void | synchronize () |
void | fetchRequesters (ServiceRequester *parent, CServiceRequester_ptr csrq) |
void | fetchServices (Service::shared_ptr parent, CService_ptr mtask) |
void | forceActivity (base::ActivityInterface *new_act) |
Forces the current activity to become new_act, even if this TaskContext is still running. | |
virtual bool | configureHook () |
Implement this method such that it contains the code which will be executed when configure() is called. | |
virtual void | cleanupHook () |
Implement this method such that it contains the code which will be executed when cleanup() is called. | |
virtual bool | startHook () |
Implement this method such that it contains the code which will be executed when start() is called. | |
virtual void | updateHook () |
Function where the user must insert his 'application' code. | |
virtual bool | breakUpdateHook () |
Implement this function if your code might block for long times inside the updateHook() function. | |
virtual void | errorHook () |
Implement this method to contain code that must be executed in the RunTimeError state, instead of updateHook(). | |
virtual void | exceptionHook () |
Implement this method to contain code that must be executed when transitioning to the Exception state. | |
virtual void | stopHook () |
Implement this method such that it contains the code which will be executed when stop() is called. | |
virtual void | fatal () |
Call this method from any place to indicate that this component encountered a fatal error. | |
virtual void | exception () |
Call this method to indicate a run-time exception happend. | |
Protected Attributes | |
std::list< base::PortInterface * > | port_proxies |
CDataFlowInterface does not delete ports automatically, because they can then be defined as members of the TaskContext classes. | |
corba::CTaskContext_var | mtask |
ExecutionEngine * | ee |
The execution engine which calls update() and processes our commands, events etc. | |
TaskState | mTaskState |
Static Protected Attributes | |
static PortableServer::POA_var | proxy_poa |
For now one POA handles all proxies. | |
Friends | |
class | ::RTT::ExecutionEngine |
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. | |
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. | |
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. | |
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. | |
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. | |
base::PortInterface * | getPort (const std::string &name) const |
Get a port of this Component. | |
DataFlowInterface * | ports () |
Get the Data flow ports of this task. | |
const DataFlowInterface * | ports () const |
Get the Data flow ports of this task. |
This class manages the access of remote TaskContext Corba Servers and a Corba Object Request Broker (Orb) which connects to these servers.
Definition at line 82 of file TaskContextProxy.hpp.
typedef boost::function<void(base::PortInterface*) RTT::TaskContext::SlotFunction) [inherited] |
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 537 of file TaskContext.hpp.
enum RTT::base::TaskCore::TaskState [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.
bool RTT::corba::TaskContextProxy::activate | ( | void | ) | [virtual] |
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 from RTT::base::TaskCore.
Definition at line 481 of file TaskContextProxy.cpp.
References RTT::TaskContext::clear().
bool RTT::TaskContext::addAttribute | ( | const std::string & | name, |
T & | attr | ||
) | [inline, inherited] |
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 411 of file TaskContext.hpp.
bool RTT::TaskContext::addAttribute | ( | base::AttributeBase & | a | ) | [inline, inherited] |
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 437 of file TaskContext.hpp.
bool RTT::TaskContext::addConstant | ( | const std::string & | name, |
const T & | attr | ||
) | [inline, inherited] |
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 424 of file TaskContext.hpp.
base::InputPortInterface& RTT::TaskContext::addEventPort | ( | const std::string & | name, |
base::InputPortInterface & | port, | ||
SlotFunction | callback = SlotFunction() |
||
) | [inline, inherited] |
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 547 of file TaskContext.hpp.
References RTT::base::PortInterface::setName().
base::InputPortInterface& RTT::TaskContext::addEventPort | ( | base::InputPortInterface & | port, |
SlotFunction | callback = SlotFunction() |
||
) | [inline, inherited] |
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 560 of file TaskContext.hpp.
Operation<Signature>& RTT::TaskContext::addOperation | ( | Operation< Signature > & | op | ) | [inline, inherited] |
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 347 of file TaskContext.hpp.
Operation< typename internal::GetSignature<Func>::Signature >& RTT::TaskContext::addOperation | ( | const std::string | name, |
Func | func, | ||
Service * | serv, | ||
ExecutionThread | et = ClientThread |
||
) | [inline, inherited] |
Adds a C++ function as an operation.
Definition at line 358 of file TaskContext.hpp.
Operation< Signature >& RTT::TaskContext::addOperation | ( | const std::string | name, |
Signature * | func, | ||
ExecutionThread | et = ClientThread |
||
) | [inline, inherited] |
Adds a C function as an operation.
Definition at line 369 of file TaskContext.hpp.
bool RTT::corba::TaskContextProxy::addPeer | ( | TaskContext * | peer, |
std::string | alias = "" |
||
) | [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 from RTT::TaskContext.
Definition at line 582 of file TaskContextProxy.cpp.
References RTT::TaskContext::clear(), Create(), server(), and RTT::corba::TaskContextServer::server().
base::PortInterface& RTT::TaskContext::addPort | ( | const std::string & | name, |
base::PortInterface & | port | ||
) | [inline, inherited] |
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 523 of file TaskContext.hpp.
References RTT::base::PortInterface::setName().
base::PortInterface& RTT::TaskContext::addPort | ( | base::PortInterface & | port | ) | [inline, inherited] |
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 533 of file TaskContext.hpp.
Property<T>& RTT::TaskContext::addProperty | ( | const std::string & | name, |
T & | attr | ||
) | [inline, inherited] |
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 479 of file TaskContext.hpp.
bool RTT::TaskContext::addProperty | ( | base::PropertyBase & | pb | ) | [inline, inherited] |
Add an base::PropertyBase as a property.
Definition at line 487 of file TaskContext.hpp.
bool RTT::TaskCore::breakUpdateHook | ( | ) | [protected, virtual, inherited] |
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 311 of file TaskCore.cpp.
Referenced by RTT::ExecutionEngine::breakLoop().
bool RTT::corba::TaskContextProxy::cleanup | ( | void | ) | [virtual] |
This method instructs a stopped component to enter the pre-operational state again.
It calls cleanupHook().
Reimplemented from RTT::base::TaskCore.
Definition at line 525 of file TaskContextProxy.cpp.
References RTT::TaskContext::clear().
void RTT::TaskCore::cleanupHook | ( | ) | [protected, virtual, inherited] |
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 244 of file TaskCore.cpp.
Referenced by RTT::base::TaskCore::cleanup(), and RTT::base::TaskCore::exception().
void RTT::TaskContext::clear | ( | ) | [virtual, inherited] |
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 380 of file TaskContext.cpp.
Referenced by activate(), addPeer(), cleanup(), configure(), connectPeers(), connectPorts(), connectServices(), disconnectPeers(), ready(), removePeer(), start(), stop(), and TaskContextProxy().
bool RTT::corba::TaskContextProxy::configure | ( | void | ) | [virtual] |
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 from RTT::base::TaskCore.
Definition at line 513 of file TaskContextProxy.cpp.
References RTT::TaskContext::clear().
bool RTT::TaskCore::configureHook | ( | ) | [protected, virtual, inherited] |
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 292 of file TaskCore.cpp.
Referenced by RTT::base::TaskCore::configure().
TaskContextProxy * RTT::corba::TaskContextProxy::Create | ( | std::string | name, |
bool | is_ior = false |
||
) | [static] |
Factory method: create a CORBA Proxy for an existing TaskContextServer.
name | The name of the TaskContextServer to connect to or the Object Reference of the object to connect to |
is_ior | set to true if name is an IOR. Defaults to false. |
0 | if the ORB is not initialised |
Definition at line 379 of file TaskContextProxy.cpp.
References RTT::os::endl(), RTT::corba::ApplicationServer::orb, and TaskContextProxy().
Referenced by addPeer(), connectPeers(), connectPorts(), connectServices(), RTT::corba::TaskContextFactory::Create(), CreateFromFile(), and getPeer().
TaskContext * RTT::corba::TaskContextProxy::Create | ( | ::RTT::corba::CTaskContext_ptr | task, |
bool | force_remote = false |
||
) | [static] |
Factory method: create a CORBA Proxy for an existing TaskContextServer.
This method may in fact return the real TaskContext in case the servant of task is in the same process.
task | The Object to create a proxy for. |
0 | if the ORB is not initialised |
Definition at line 416 of file TaskContextProxy.cpp.
References RTT::os::endl(), RTT::corba::ApplicationServer::orb, and TaskContextProxy().
TaskContextProxy * RTT::corba::TaskContextProxy::CreateFromFile | ( | std::string | filename | ) | [static] |
Factory method: create a CORBA Proxy for an existing TaskContextServer.
filename | A file containing an IOR which refers to the existing TaskContextServer. |
0 | if the ORB is not initialised |
Definition at line 399 of file TaskContextProxy.cpp.
References Create(), and RTT::corba::ApplicationServer::orb.
Referenced by RTT::corba::TaskContextFactory::CreateFromFile().
void RTT::TaskContext::disconnect | ( | ) | [virtual, inherited] |
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 292 of file TaskContext.cpp.
References RTT::TaskContext::getName(), RTT::DataFlowInterface::getPorts(), and RTT::TaskContext::ports().
void RTT::TaskCore::error | ( | ) | [virtual, inherited] |
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 151 of file TaskCore.cpp.
References RTT::base::TaskCore::Running, and RTT::base::TaskCore::RunTimeError.
void RTT::TaskCore::errorHook | ( | ) | [protected, virtual, inherited] |
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 301 of file TaskCore.cpp.
void RTT::TaskCore::exception | ( | ) | [protected, virtual, inherited] |
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 158 of file TaskCore.cpp.
References RTT::base::TaskCore::cleanupHook(), RTT::base::TaskCore::Exception, RTT::base::TaskCore::exceptionHook(), RTT::base::TaskCore::fatal(), RTT::base::TaskCore::PreOperational, RTT::base::TaskCore::Running, RTT::base::TaskCore::stopHook(), and RTT::base::TaskCore::Stopped.
Referenced by RTT::base::TaskCore::cleanup(), RTT::base::TaskCore::configure(), RTT::ExecutionEngine::setExceptionTask(), RTT::base::TaskCore::start(), and RTT::base::TaskCore::stop().
void RTT::TaskCore::exceptionHook | ( | ) | [protected, virtual, inherited] |
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 316 of file TaskCore.cpp.
Referenced by RTT::base::TaskCore::exception().
void RTT::TaskCore::fatal | ( | ) | [protected, virtual, inherited] |
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 145 of file TaskCore.cpp.
References RTT::base::TaskCore::engine(), RTT::base::TaskCore::FatalError, RTT::base::RunnableInterface::getActivity(), and RTT::base::ActivityInterface::stop().
Referenced by RTT::base::TaskCore::exception().
void RTT::TaskContext::forceActivity | ( | base::ActivityInterface * | new_act | ) | [protected, inherited] |
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 TaskContextProxy().
ActivityInterface * RTT::TaskContext::getActivity | ( | ) | [inherited] |
Get a pointer to the activity running this component.
Definition at line 373 of file TaskContext.cpp.
References RTT::base::TaskCore::engine(), and RTT::base::RunnableInterface::getActivity().
T* RTT::TaskContext::getActivity | ( | ) | [inline, inherited] |
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 173 of file TaskContext.hpp.
References RTT::TaskContext::getActivity().
Referenced by RTT::TaskContext::getActivity().
base::AttributeBase* RTT::TaskContext::getAttribute | ( | const std::string & | name | ) | const [inline, inherited] |
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 450 of file TaskContext.hpp.
unsigned RTT::TaskCore::getCpuAffinity | ( | ) | const [virtual, inherited] |
Get the configured cpu affinity of this component.
Definition at line 282 of file TaskCore.cpp.
References RTT::base::TaskCore::engine(), RTT::base::RunnableInterface::getActivity(), and RTT::base::ActivityInterface::getCpuAffinity().
OperationInterfacePart* RTT::TaskContext::getOperation | ( | std::string | name | ) | [inline, inherited] |
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 383 of file TaskContext.hpp.
TaskContext * RTT::corba::TaskContextProxy::getPeer | ( | const std::string & | peer_name | ) | const [virtual] |
Get a pointer to a peer of this task.
Reimplemented from RTT::TaskContext.
Definition at line 691 of file TaskContextProxy.cpp.
References Create().
Seconds RTT::TaskCore::getPeriod | ( | ) | const [virtual, inherited] |
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 272 of file TaskCore.cpp.
References RTT::base::TaskCore::engine(), RTT::base::RunnableInterface::getActivity(), and RTT::base::ActivityInterface::getPeriod().
base::PortInterface* RTT::TaskContext::getPort | ( | const std::string & | name | ) | const [inline, inherited] |
Get a port of this Component.
name | The port name |
Definition at line 569 of file TaskContext.hpp.
base::PropertyBase* RTT::TaskContext::getProperty | ( | const std::string & | name | ) | const [inline, inherited] |
Get a Property with name name.
name | The name of the property to search for. |
Definition at line 498 of file TaskContext.hpp.
boost::shared_ptr<ServiceType> RTT::TaskContext::getProvider | ( | const std::string & | name | ) | [inline, inherited] |
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 309 of file TaskContext.hpp.
TaskCore::TaskState RTT::TaskCore::getTargetState | ( | ) | const [virtual, inherited] |
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 85 of file TaskCore.cpp.
TaskContext::TaskState RTT::corba::TaskContextProxy::getTaskState | ( | void | ) | const [virtual] |
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 from RTT::base::TaskCore.
Definition at line 567 of file TaskContextProxy.cpp.
References RTT::base::TaskCore::Init.
bool RTT::corba::TaskContextProxy::inFatalError | ( | void | ) | const [virtual] |
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 from RTT::base::TaskCore.
Definition at line 547 of file TaskContextProxy.cpp.
RTT_CORBA_API bool RTT::corba::ApplicationServer::InitOrb | ( | int | argc, |
char * | argv[], | ||
Seconds | orb_timeout = 0 |
||
) | [static, inherited] |
Invoke this method once to initialise the Orb which will run the task servers.
orb_timeout | timeout value for each remote call, expressed in seconds. The resolution is up to 100 nano seconds. Anything smaller will be interpreted as a zero. |
Definition at line 55 of file ApplicationServer.cpp.
References RTT::Logger::log(), RTT::Logger::nl(), RTT::corba::ApplicationServer::orb, and RTT::corba::ApplicationServer::rootPOA.
bool RTT::corba::TaskContextProxy::isActive | ( | void | ) | const [virtual] |
Inspect if the component's ExecutionEngine is processing requests.
Normally this is always the case, but user code could stop the ExecutionEngine manually.
Reimplemented from RTT::base::TaskCore.
Definition at line 493 of file TaskContextProxy.cpp.
bool RTT::corba::TaskContextProxy::isConfigured | ( | void | ) | const [virtual] |
Inspect if the component is configured, i.e.
in the Stopped, Active or Running state.
Reimplemented from RTT::base::TaskCore.
Definition at line 537 of file TaskContextProxy.cpp.
bool RTT::corba::TaskContextProxy::isRunning | ( | void | ) | const [virtual] |
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 from RTT::base::TaskCore.
Definition at line 503 of file TaskContextProxy.cpp.
bool RTT::TaskContext::loadService | ( | const std::string & | service_name | ) | [inherited] |
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 233 of file TaskContext.cpp.
References RTT::plugin::PluginLoader::Instance(), and RTT::TaskContext::provides().
Service::shared_ptr RTT::TaskContext::provides | ( | ) | [inline, inherited] |
Returns this Service.
Definition at line 268 of file TaskContext.hpp.
Referenced by RTT::TaskContext::connectServices(), RTT::marsh::MarshallingService::Create(), RTT::scripting::ScriptingService::Create(), RTT::Service::Create(), RTT::TaskContext::loadService(), RTT::scripting::Parser::parseValueStatement(), RTT::scripting::PeerParser::reset(), and TaskContextProxy().
Service::shared_ptr RTT::TaskContext::provides | ( | const std::string & | service_name | ) | [inline, inherited] |
Returns a sub-Service which resorts under this Service.
service_name | The name of the sub-service. |
Definition at line 275 of file TaskContext.hpp.
bool RTT::corba::TaskContextProxy::ready | ( | void | ) | [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 from RTT::TaskContext.
Definition at line 736 of file TaskContextProxy.cpp.
References RTT::TaskContext::clear().
bool RTT::TaskCore::recover | ( | ) | [virtual, inherited] |
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.
Definition at line 180 of file TaskCore.cpp.
References RTT::base::TaskCore::Exception, RTT::base::TaskCore::Running, and RTT::base::TaskCore::RunTimeError.
corba::CTaskContext_ptr RTT::corba::TaskContextProxy::server | ( | ) | const |
Get the Corba Object of the CTaskContext.
You need to duplicate this object reference in case you wish to keep a reference to it. This object universally identifies the remote TaskContextServer and can be used to tell other (remote) objects where to find it.
Definition at line 753 of file TaskContextProxy.cpp.
Referenced by addPeer().
bool RTT::TaskContext::setActivity | ( | base::ActivityInterface * | new_act | ) | [inherited] |
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 343 of file TaskContext.cpp.
References RTT::base::TaskCore::engine(), RTT::base::TaskCore::isRunning(), RTT::base::ActivityInterface::run(), and RTT::base::ActivityInterface::stop().
Referenced by TaskContextProxy().
bool RTT::TaskCore::setCpuAffinity | ( | unsigned | cpu | ) | [virtual, inherited] |
Sets the cpu affinity of this component.
Definition at line 287 of file TaskCore.cpp.
References RTT::base::TaskCore::engine(), RTT::base::RunnableInterface::getActivity(), and RTT::base::ActivityInterface::setCpuAffinity().
void RTT::TaskCore::setExecutionEngine | ( | ExecutionEngine * | engine | ) | [inherited] |
Use this method to re-set the execution engine of this task core.
engine | The new execution engine which will execute this TaskCore or null if a new execution engine must be created (the old is deleted in that case). |
Definition at line 323 of file TaskCore.cpp.
References RTT::ExecutionEngine::addChild(), RTT::base::TaskCore::ee, RTT::base::TaskCore::engine(), RTT::ExecutionEngine::getParent(), and RTT::ExecutionEngine::removeChild().
bool RTT::TaskCore::setPeriod | ( | Seconds | s | ) | [virtual, inherited] |
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 277 of file TaskCore.cpp.
References RTT::base::TaskCore::engine(), RTT::base::RunnableInterface::getActivity(), and RTT::base::ActivityInterface::setPeriod().
bool RTT::corba::TaskContextProxy::start | ( | void | ) | [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::TaskContext.
Definition at line 457 of file TaskContextProxy.cpp.
References RTT::TaskContext::clear().
bool RTT::TaskCore::startHook | ( | ) | [protected, virtual, inherited] |
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 296 of file TaskCore.cpp.
Referenced by RTT::base::TaskCore::start().
bool RTT::corba::TaskContextProxy::stop | ( | void | ) | [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::TaskContext.
Definition at line 469 of file TaskContextProxy.cpp.
References RTT::TaskContext::clear().
void RTT::TaskCore::stopHook | ( | ) | [protected, virtual, inherited] |
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 319 of file TaskCore.cpp.
Referenced by RTT::base::TaskCore::exception(), and RTT::base::TaskCore::stop().
bool RTT::TaskCore::trigger | ( | ) | [virtual, inherited] |
Invoke this method to trigger the thread of this TaskContext to execute its ExecutionEngine and the update() method.
Definition at line 96 of file TaskCore.cpp.
References RTT::base::TaskCore::engine(), RTT::base::RunnableInterface::getActivity(), and RTT::base::ActivityInterface::trigger().
Referenced by RTT::base::TaskCore::start().
bool RTT::TaskCore::update | ( | ) | [virtual, inherited] |
Invoke this method to execute the ExecutionEngine and the update() method.
false | if this->engine()->getActivity()->execute() == false |
true | otherwise. |
Definition at line 89 of file TaskCore.cpp.
References RTT::base::TaskCore::engine(), RTT::base::ActivityInterface::execute(), and RTT::base::RunnableInterface::getActivity().
void RTT::TaskCore::updateHook | ( | ) | [protected, virtual, inherited] |
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 307 of file TaskCore.cpp.
std::list<base::PortInterface*> RTT::corba::TaskContextProxy::port_proxies [protected] |
CDataFlowInterface does not delete ports automatically, because they can then be defined as members of the TaskContext classes.
We must therefore delete in the proxy destructor the ones we are adding through synchronization
Definition at line 109 of file TaskContextProxy.hpp.