ControlTaskProxy Class Reference
[Component IDL and Corba Setup]

#include </home/sspr/src/www/orocos-1.0/export/build/orocos-rtt-1.2.2/build/rtt/corba/ControlTaskProxy.hpp>

Inheritance diagram for ControlTaskProxy:

TaskContext ApplicationServer OperationInterface TaskCore List of all members.

Detailed Description

This class manages the access of remote TaskContext Corba Servers and a Corba Object Request Broker (Orb) which connects to these servers.


Public Types

typedef std::map< ControlTaskProxy *,
Corba::ControlTask_ptr > 
PMap
typedef std::vector< std::string > PeerList
 A list of Peer TaskContext names.
typedef std::vector< std::string > ObjectList
 A list of all child objects of this interface.
enum  TaskState { Init, PreOperational, Stopped, Running }
 Describes the different states a component can have. More...

Public Member Functions

Corba::ControlTask_ptr server () const
 Get the Corba Object of the ControlTask.
virtual bool start ()
 This method starts the execution engine of this component.
virtual bool stop ()
 This method stops the execution engine of this component.
virtual bool isRunning () const
 Inspect if the component is in the Running 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 isConfigured () const
 Inspect if the component is configured, i.e.
virtual TaskState getTaskState () const
 Returns the current state of the TaskContext.
virtual bool executeCommand (CommandInterface *c)
virtual int queueCommand (CommandInterface *c)
virtual void setName (const std::string &n)
 Change the name of this TaskCore.
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 TaskContextgetPeer (const std::string &peer_name) const
 Get a pointer to a peer of this task.
CosPropertyService::PropertySet_ptr propertySet ()
 Returns the properties of this Task as a PropertySet.
virtual const std::string & getName () const
 Returns the name of this interface.
virtual const std::string & getDescription () const
 Returns the description of this interface.
virtual void setDescription (const std::string &descr)
virtual OperationInterfacegetParent ()
 Returns the parent OperationInterface in which this TaskObject lives.
virtual void setParent (OperationInterface *)
 This method is ignored by the TaskContext.
virtual void setEngine (ExecutionEngine *)
 This method is ignored by the TaskContext.
void exportPorts ()
 Call this function to force a TaskContext to export its Data Flow ports as scripting objects.
virtual bool connectPorts (TaskContext *peer)
 Add a data flow connection from this task's ports to a peer's ports.
virtual void disconnect ()
 Disconnect this TaskContext from it's peers.
virtual void reconnect ()
 Reconnect the data ports of this task, without removing the peer relationship.
virtual bool addObject (OperationInterface *obj)
 Add a new TaskObject to this TaskContext.
void clear ()
 Clear the complete interface of this Component.
ScriptingAccessscripting ()
 Get access to high level controls for programs, state machines and scripting statements.
const ScriptingAccessscripting () const
 Get access to high level controls for programs, state machines and scripting statements.
ExecutionAccessexecution ()
 Get access to high level controls for controlling programs and state machines.
const ExecutionAccessexecution () const
 Get access to high level controls for controlling programs and state machines.
MarshallingAccessmarshalling ()
 Get access to high level controls for (de)serializing properties to/from an XML format.
const MarshallingAccessmarshalling () const
 Get access to high level controls for (de)serializing properties to/from an XML format.
PropertyBagproperties ()
 The properties of this TaskContext.
const PropertyBagproperties () const
 The properties of this TaskContext.
DataFlowInterfaceports ()
 Get the Data flow ports of this task.
const DataFlowInterfaceports () const
 Get the Data flow ports of this task.
CommandRepositorycommands ()
 Returns the commands of this interface.
const CommandRepositorycommands () const
MethodRepositorymethods ()
 Returns the methods of this interface.
const MethodRepositorymethods () const
EventServiceevents ()
 The task-local events ( 'signals' ) of this TaskContext.
const EventServiceevents () const
 The task-local events ( 'signals' ) of this TaskContext.
AttributeRepositoryattributes ()
 Returns the attributes of this interface.
const AttributeRepositoryattributes () const
virtual OperationInterfacegetObject (const std::string &obj_name)
 Get a pointer to a previously added TaskObject.
virtual ObjectList getObjectList () const
 Get a list of all the object names of this interface.
virtual bool removeObject (const std::string &obj_name)
 Remove and delete a previously added TaskObject.
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 bool startup ()
 Function where the user must insert his 'startup' code.
virtual void updateHook ()
 Function where the user must insert his 'application' code.
virtual void update ()
 Function where the user must insert his 'application' code.
virtual void stopHook ()
 Implement this method such that it contains the code which will be executed when stop() is called.
virtual void shutdown ()
 Function where the user must insert his 'shutdown' code.
void setExecutionEngine (ExecutionEngine *engine)
 Use this method to re-set the execution engine of this task core.
const ExecutionEngineengine () const
 Get a const pointer to the ExecutionEngine of this Task.
ExecutionEngineengine ()
 Get a pointer to the ExecutionEngine of this Task.
Script Methods
These TaskCore functions are exported in a TaskContext as script methods and are for configuration, starting and stopping its ExecutionEngine.

virtual bool doUpdate ()
 Invoke this method to execute the ExecutionEngine and the update() method.
virtual bool doTrigger ()
 Invoke this method to trigger the thread of this TaskContext to execute its ExecutionEngine and the update() method.

Static Public Member Functions

static bool InitOrb (int argc, char *argv[])
 Invoke this method once to initialise the Orb which will connect to the task servers.
static void DestroyOrb ()
 Invoke this method once to cleanup the orb.
static ControlTaskProxyCreate (std::string name, bool is_ior=false)
 Factory method: create a CORBA connection to an existing ControlTaskServer.
static ControlTaskProxyCreate (::RTT::Corba::ControlTask_ptr task)
 Factory method: create a CORBA connection to an existing ControlTaskServer.
static PortableServer::POA_ptr ProxyPOA ()
 Returns the default POA for all proxies.

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 Types

typedef std::map< std::string,
TaskContext * > 
PeerMap
typedef std::vector< TaskContext * > Users
typedef std::vector< OperationInterface * > Objects

Protected Member Functions

 ControlTaskProxy (std::string location, bool is_ior)
 Private constructor which creates a new connection to a stringified ior or taskname in NameServer.
 ControlTaskProxy (::RTT::Corba::ControlTask_ptr t)
 Private constructor which creates a new connection to a corba object.
void synchronize ()
void fetchObjects (OperationInterface *parent, ControlObject_ptr mtask)
void addUser (TaskContext *user)
 Inform this TaskContext that user is using our services.
void removeUser (TaskContext *user)
 Inform this TaskContext that user is no longer using our services.
void setup ()

Protected Attributes

Corba::ControlTask_var mtask
std::string mdescription
PeerMap _task_map
 map of the tasks we are using
Users musers
 map of the tasks that are using us.
Objects mobjects
 the TaskObjects.
ScriptingAccessmscriptAcc
ExecutionAccessmengAcc
MarshallingAccessmarshAcc
CommandRepository mcommands
MethodRepository mmethods
AttributeRepository mattributes
std::string mtask_name
ExecutionEngineee
 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 ExecutionEngine


Member Enumeration Documentation

enum 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.

In order to check if these transitions are allowed, hook functions are executed, which can be filled in by the component builder.

Enumerator:
PreOperational  The state during component construction.
Stopped  The state indicating additional configuration is required.
Running  The state indicating the component is running.


Member Function Documentation

static ControlTaskProxy* Create ( std::string  name,
bool  is_ior = false 
) [static]

Factory method: create a CORBA connection to an existing ControlTaskServer.

Parameters:
name The name of the ControlTaskServer 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.
Return values:
0 if the ORB is not initialised
Returns:
A new or previously created CORBA proxy for name.

static ControlTaskProxy* Create ( ::RTT::Corba::ControlTask_ptr  task  )  [static]

Factory method: create a CORBA connection to an existing ControlTaskServer.

Parameters:
task The Object to connect to.
Return values:
0 if the ORB is not initialised
Returns:
A new or previously created CORBA proxy for task.

Corba::ControlTask_ptr server (  )  const

Get the Corba Object of the ControlTask.

This object universally identifies the remote ControlTaskServer and can be used to tell other (remote) objects where to find it.

virtual bool start (  )  [virtual]

This method starts the execution engine of this component.

This function calls startHook(), which must return true in order to allow this component to run. You can override this method to do something else or in addition to starting the ExecutionEngine.

Returns:
false if the engine was not assigned to an ActivityInterface or if startHook() returned false or it was already started.

Reimplemented from TaskCore.

virtual bool stop (  )  [virtual]

This method stops the execution engine of this component.

You can override this method to do something else or in addition to stopping the engine. This function calls cleanupHook() as well.

Returns:
false if the engine was not running.

Reimplemented from TaskCore.

virtual bool configure (  )  [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 TaskCore.

virtual bool cleanup (  )  [virtual]

This method instructs a stopped component to enter the pre-operational state again.

It calls cleanupHook().

Returns:
true if the component was in the stopped state.

Reimplemented from TaskCore.

virtual bool isConfigured (  )  const [virtual]

Inspect if the component is configured, i.e.

in the Stopped or Running state.

Reimplemented from TaskCore.

virtual bool addPeer ( TaskContext peer,
std::string  alias = "" 
) [virtual]

Add a one-way connection from this task to a peer task.

Parameters:
peer The peer to add.
alias An optional alias (another name) for the peer. defaults to peer->getName()

Reimplemented from TaskContext.

virtual TaskContext* getPeer ( const std::string &  peer_name  )  const [virtual]

Get a pointer to a peer of this task.

Returns:
null if no such peer.

Reimplemented from TaskContext.

virtual OperationInterface* getParent (  )  [inline, virtual, inherited]

Returns the parent OperationInterface in which this TaskObject lives.

A TaskObject can have only one parent.

Returns:
null in case no parent is set, the parent otherwise.

Implements OperationInterface.

virtual void setEngine ( ExecutionEngine  )  [inline, virtual, inherited]

This method is ignored by the TaskContext.

See also:
TaskCore::setExecutionEngine for (re-)setting a new ExecutionEngine, which is a base class of TaskContext.

Implements OperationInterface.

void exportPorts (  )  [inherited]

Call this function to force a TaskContext to export its Data Flow ports as scripting objects.

Deprecated:
Do not use this function, it is no longer required.

virtual void disconnect (  )  [virtual, inherited]

Disconnect this TaskContext from it's peers.

All its Data Flow Ports are disconnected from the connections but the connections themselves may continue to exist to serve other TaskContexts. This method invokes removePeer() as well on the peers listed in this->getPeerList().

virtual void reconnect (  )  [virtual, inherited]

Reconnect the data ports of this task, without removing the peer relationship.

Use this if you changed a port name of an already connected task.

virtual bool addObject ( OperationInterface obj  )  [virtual, inherited]

Add a new TaskObject to this TaskContext.

Parameters:
obj This object becomes owned by this TaskContext.
Returns:
true if it cuold be added, false if such object already exists.

Reimplemented from OperationInterface.

void 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.

Reimplemented from OperationInterface.

ExecutionAccess* execution (  )  [inline, inherited]

Get access to high level controls for controlling programs and state machines.

It is the implementation of the 'engine' TaskObject.

const ExecutionAccess* execution (  )  const [inline, inherited]

Get access to high level controls for controlling programs and state machines.

It is the implementation of the 'engine' TaskObject.

virtual OperationInterface* getObject ( const std::string &  obj_name  )  [virtual, inherited]

Get a pointer to a previously added TaskObject.

Parameters:
obj_name The name of the TaskObject
Returns:
the pointer

virtual ObjectList getObjectList (  )  const [virtual, inherited]

Get a list of all the object names of this interface.

Returns:
a list of string names.

virtual bool removeObject ( const std::string &  obj_name  )  [virtual, inherited]

Remove and delete a previously added TaskObject.

Deletion will only occur if obj_name's parent is this. You can avoid deletion by first calling

 this->getObject( obj_name )->setParent(0); 

Parameters:
obj_name The name of the TaskObject to remove
Returns:
true if found and removed, false otherwise.

virtual bool doUpdate (  )  [virtual, inherited]

Invoke this method to execute the ExecutionEngine and the update() method.

This method maps to the 'update()' method in the scripting language.

Return values:
false if this->engine()->getActivity()->execute() == false
true otherwise.

virtual bool doTrigger (  )  [virtual, inherited]

Invoke this method to trigger the thread of this TaskContext to execute its ExecutionEngine and the update() method.

This method maps to the 'trigger()' method in the scripting language.

Return values:
false if this->engine()->getActivity()->trigger() == false
true otherwise.

virtual bool configureHook (  )  [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.

Return values:
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.

virtual void cleanupHook (  )  [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.

virtual bool startHook (  )  [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.

Return values:
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.

virtual bool startup (  )  [virtual, inherited]

Function where the user must insert his 'startup' code.

This function is called by the ExecutionEngine before it starts its processors. If it returns false, the startup of the TaskCore is aborted. The default implementation is an empty function which returns true.

Deprecated:
Use the startHook() function instead.

virtual void updateHook (  )  [virtual, inherited]

Function where the user must insert his 'application' code.

When the ExecutionEngine's Activity is a PeriodicActivity, this function is called by the ExecutionEngine in each periodic step after all command, event,... are processed. When it is executed by a NonPeriodicActivity, this function is called after an Event or Command 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.

virtual void update (  )  [virtual, inherited]

Function where the user must insert his 'application' code.

When the ExecutionEngine's Activity is a PeriodicActivity, this function is called by the ExecutionEngine in each periodic step after all command, event,... processors. When it's Task is a NonPeriodicActivity, this function is called after an Event or Command 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.

Deprecated:
Use the updateHook() function instead.

virtual void stopHook (  )  [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.

virtual void shutdown (  )  [virtual, inherited]

Function where the user must insert his 'shutdown' code.

This function is called by the ExecutionEngine after it stops its processors. The default implementation is an empty function.

Deprecated:
Use the stopHook() function instead.

void setExecutionEngine ( ExecutionEngine engine  )  [inherited]

Use this method to re-set the execution engine of this task core.

Parameters:
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).
Postcondition:
The TaskCore is being run by engine or a new execution engine.


The documentation for this class was generated from the following file:
Generated on Fri Oct 19 16:27:26 2007 for Orocos by  doxygen 1.5.1