fipa_services
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
fipa_services::MessageTransportTask Class Reference

The task context provides and requires services. It uses an ExecutionEngine to perform its functions. Essential interfaces are operations, data flow ports and properties. These interfaces have been defined using the oroGen specification. In order to modify the interfaces you should (re)use oroGen and rely on the associated workflow. More...

#include <MessageTransportTask.hpp>

Inheritance diagram for fipa_services::MessageTransportTask:

Public Member Functions

 MessageTransportTask (std::string const &name="fipa_services::MessageTransportTask")
 
 MessageTransportTask (std::string const &name, RTT::ExecutionEngine *engine)
 
 ~MessageTransportTask ()
 
bool configureHook ()
 
bool startHook ()
 
void updateHook ()
 
void errorHook ()
 
void stopHook ()
 
void cleanupHook ()
 

Protected Types

typedef std::map< std::string, RTT::base::OutputPortInterface * > ReceiverPorts
 

Protected Member Functions

virtual bool addReceiver (::std::string const &receiver, bool is_local=false)
 
virtual ::std::vector< ::std::string > getReceivers ()
 
virtual bool removeReceiver (::std::string const &receiver)
 
bool addReceiverPort (RTT::base::OutputPortInterface *outputPort, const std::string &name)
 
bool removeReceiverPort (const std::string &name)
 
void registerService (std::string receiver)
 
void deregisterService (std::string receiver)
 
void serviceAdded (servicediscovery::avahi::ServiceEvent event)
 
void serviceRemoved (servicediscovery::avahi::ServiceEvent event)
 
void connectToMTS (const std::string &serviceName, const std::string &ior)
 
bool deliverLetterLocally (const std::string &receiverName, const fipa::acl::Letter &letter)
 
void initializeMessageTransport ()
 

Protected Attributes

boost::mutex mConnectToMTSMutex
 
boost::shared_mutex mServiceChangeMutex
 
fipa::services::message_transport::MessageTransport * mMessageTransport
 Prevents a simulatenous change of the service. More...
 
std::string mInterface
 
std::string mClientServiceType
 
std::vector< fipa::services::ServiceDirectoryEntry > mExtraServiceDirectoryEntries
 
ReceiverPorts mReceivers
 

Friends

class MessageTransportTaskBase
 

Detailed Description

The task context provides and requires services. It uses an ExecutionEngine to perform its functions. Essential interfaces are operations, data flow ports and properties. These interfaces have been defined using the oroGen specification. In order to modify the interfaces you should (re)use oroGen and rely on the associated workflow.

This oroGen task represents a message transport task to allow to allow for inter-robot communication in a p2p communication network.

Typically this instance will be controlled from the ruby layer (refer to bindings)

Calling the operation 'addReceiver' will trigger the creation of an output port of a predefined name, e.g. 'agent_0'

The client can then connect to this output port and any message addressed to 'agent_0' will be delivered to this port. This agent name

include <fipa_acl/fipa_acl.h>

fipa::acl::ACLMessage message; message.setPerformative(AclMessage::REQUEST); ... fipa::acl::Letter letter(message, representation::BITEFFICIENT); fipa::SerializedLetter serializedLetter(letter, representation::BITEFFICIENT);

The name of a TaskContext is primarily defined via:

deployment 'deployment_name'
    task('custom_task_name','fipa_services::MessageTransportTask')
end

It can be dynamically adapted when the deployment is called with a prefix argument.

Member Typedef Documentation

typedef std::map<std::string, RTT::base::OutputPortInterface*> fipa_services::MessageTransportTask::ReceiverPorts
protected

Constructor & Destructor Documentation

fipa_services::MessageTransportTask::MessageTransportTask ( std::string const &  name = "fipa_services::MessageTransportTask")

TaskContext constructor for MessageTransportTask

Parameters
nameName of the task. This name needs to be unique to make it identifiable via nameservices.
initial_stateThe initial TaskState of the TaskContext. Default is Stopped state.
fipa_services::MessageTransportTask::MessageTransportTask ( std::string const &  name,
RTT::ExecutionEngine *  engine 
)

TaskContext constructor for MessageTransportTask

Parameters
nameName of the task. This name needs to be unique to make it identifiable for nameservices.
engineThe RTT Execution engine to be used for this task, which serialises the execution of all commands, programs, state machines and incoming events for a task.
fipa_services::MessageTransportTask::~MessageTransportTask ( )

Default deconstructor of MessageTransportTask

Member Function Documentation

bool fipa_services::MessageTransportTask::addReceiver ( ::std::string const &  receiver,
bool  is_local = false 
)
protectedvirtual
bool fipa_services::MessageTransportTask::addReceiverPort ( RTT::base::OutputPortInterface *  outputPort,
const std::string &  name 
)
protected

Add an output port for a specific receiver, portname and receivername will be identical

Returns
true on success, false otherwise
void fipa_services::MessageTransportTask::cleanupHook ( )

This hook is called by Orocos when the state machine transitions from Stopped to PreOperational, requiring the call to configureHook() before calling start() again.

bool fipa_services::MessageTransportTask::configureHook ( )

This hook is called by Orocos when the state machine transitions from PreOperational to Stopped. If it returns false, then the component will stay in PreOperational. Otherwise, it goes into Stopped.

It is meaningful only if the #needs_configuration has been specified in the task context definition with (for example):

task_context "TaskName" do
  needs_configuration
  ...
end
void fipa_services::MessageTransportTask::connectToMTS ( const std::string &  serviceName,
const std::string &  ior 
)
protected

Connect to another MTS using a known ior

bool fipa_services::MessageTransportTask::deliverLetterLocally ( const std::string &  receiverName,
const fipa::acl::Letter &  letter 
)
protected
void fipa_services::MessageTransportTask::deregisterService ( std::string  receiver)
protected

Deregister a service (a receiver) with the distributed service directory.

void fipa_services::MessageTransportTask::errorHook ( )

This hook is called by Orocos when the component is in the RunTimeError state, at each activity step. See the discussion in updateHook() about triggering options.

Call recover() to go back in the Runtime state.

std::vector< std::string > fipa_services::MessageTransportTask::getReceivers ( )
protected
void fipa_services::MessageTransportTask::initializeMessageTransport ( )
protected

Initialize the message transport

void fipa_services::MessageTransportTask::registerService ( std::string  receiver)
protected

Register a service (a receiver) with the distributed service directory.

bool fipa_services::MessageTransportTask::removeReceiver ( ::std::string const &  receiver)
protectedvirtual
bool fipa_services::MessageTransportTask::removeReceiverPort ( const std::string &  name)
protected

Remove the output port for a specific receiver

Returns
true on success, false otherwise
void fipa_services::MessageTransportTask::serviceAdded ( servicediscovery::avahi::ServiceEvent  event)
protected

Service added callback handler

void fipa_services::MessageTransportTask::serviceRemoved ( servicediscovery::avahi::ServiceEvent  event)
protected

Service removed callback handler

bool fipa_services::MessageTransportTask::startHook ( )

This hook is called by Orocos when the state machine transitions from Stopped to Running. If it returns false, then the component will stay in Stopped. Otherwise, it goes into Running and updateHook() will be called.

void fipa_services::MessageTransportTask::stopHook ( )

This hook is called by Orocos when the state machine transitions from Running to Stopped after stop() has been called.

void fipa_services::MessageTransportTask::updateHook ( )

This hook is called by Orocos when the component is in the Running state, at each activity step. Here, the activity gives the "ticks" when the hook should be called.

The error(), exception() and fatal() calls, when called in this hook, allow to get into the associated RunTimeError, Exception and FatalError states.

In the first case, updateHook() is still called, and recover() allows you to go back into the Running state. In the second case, the errorHook() will be called instead of updateHook(). In Exception, the component is stopped and recover() needs to be called before starting it again. Finally, FatalError cannot be recovered.

Friends And Related Function Documentation

friend class MessageTransportTaskBase
friend

Member Data Documentation

std::string fipa_services::MessageTransportTask::mClientServiceType
protected
boost::mutex fipa_services::MessageTransportTask::mConnectToMTSMutex
mutableprotected
std::vector<fipa::services::ServiceDirectoryEntry> fipa_services::MessageTransportTask::mExtraServiceDirectoryEntries
protected
std::string fipa_services::MessageTransportTask::mInterface
protected
fipa::services::message_transport::MessageTransport* fipa_services::MessageTransportTask::mMessageTransport
protected

Prevents a simulatenous change of the service.

ReceiverPorts fipa_services::MessageTransportTask::mReceivers
protected
boost::shared_mutex fipa_services::MessageTransportTask::mServiceChangeMutex
mutableprotected

The documentation for this class was generated from the following files: