Data Structures | Public Member Functions | Protected Member Functions | Protected Attributes

vislab::yarp::util::AbstractRFModule Class Reference

#include <AbstractRFModule.h>

Inheritance diagram for vislab::yarp::util::AbstractRFModule:
vislab::yarp::util::ThreadedRFModule vislab::yarp::util::RFModule2

Data Structures

class  AbstractWorkerThread

Public Member Functions

 AbstractRFModule (::yarp::os::ConstString name)
 The constructor.
virtual ~AbstractRFModule ()
 The destructor.
virtual bool interruptModule ()
virtual bool configure (::yarp::os::ResourceFinder &rf)
void setName (const char *name)
bool isHandlerAvailable ()
 Returns an indicator of if the handler port is available/ opened.
virtual bool close ()
virtual bool respond (const ::yarp::os::Bottle &command,::yarp::os::Bottle &reply)
virtual double getPeriod ()
virtual bool updateModule ()

Protected Member Functions

virtual bool startThread ()
virtual ::yarp::os::Thread * createWorkerThread ()=0
void addRemoteCommand (Command *cmd)
 Adds a new Command for the module's RPC communication.
void addModuleOption (Option *o)
 Adds a new Option with can be altered by the module's RPC communication port.
void init (const char *name, bool handlerPortAutomation, double period)

Protected Attributes

::yarp::os::Thread * workerThread
double period
 The interval in which the module's updateModule() functions gets called.
::yarp::os::ConstString prefix
 The "standard" prefix for YARP ports "/".
::yarp::os::ConstString moduleName
 The module's name.
::yarp::os::ConstString robotName
 The name of the robot to be used.
Contactables dataPorts
 The ports to be used by the module.
::yarp::os::Port handlerPort
 The RPC communication port of the module.
CommandManager remoteCommands
 The RPC commands of the module.
OptionManager moduleOptions
 A std::map of module options stored as key value pairs.

Detailed Description

Deprecated:
Author:
Christian Wressnegger
Date:
2009

Definition at line 47 of file AbstractRFModule.h.


Constructor & Destructor Documentation

vislab::yarp::util::AbstractRFModule::AbstractRFModule ( ::yarp::os::ConstString  name  ) 

The constructor.

Parameters:
name The modules name.

Member Function Documentation

void vislab::yarp::util::RFModule2::addModuleOption ( Option o  )  [protected, inherited]

Adds a new Option with can be altered by the module's RPC communication port.

Parameters:
o The Option to be added.

Definition at line 91 of file RFModule2.cpp.

References vislab::yarp::util::RFModule2::moduleOptions.

                                         {
        moduleOptions.add(o);
}

void vislab::yarp::util::RFModule2::addRemoteCommand ( Command cmd  )  [protected, inherited]

Adds a new Command for the module's RPC communication.

Parameters:
cmd The Command to be added.

Definition at line 87 of file RFModule2.cpp.

References vislab::yarp::util::SynchronizedNameMap< T >::add(), and vislab::yarp::util::RFModule2::remoteCommands.

                                             {
        remoteCommands.add(cmd);
}

bool vislab::yarp::util::RFModule2::close ( void   )  [virtual, inherited]
See also:
yarp::os::RFModule::close()

Reimplemented in vislab::control::HandModule, and vislab::control::HandCtrl.

Definition at line 149 of file RFModule2.cpp.

References vislab::yarp::util::Contactables::close(), vislab::yarp::util::RFModule2::dataPorts, and vislab::yarp::util::RFModule2::handlerPort.

                      {
        dataPorts.close();
        handlerPort.close();
        return true;
}

virtual bool vislab::yarp::util::RFModule2::configure ( ::yarp::os::ResourceFinder &  rf  )  [virtual, inherited]
See also:
yarp::os::RFModule::configure(yarp::os::ResourceFinder)

Reimplemented in vislab::control::HandModule, vislab::control::HandCtrl, vislab::math::Eye2world, vislab::control::GloveCtrl, and vislab::demo::My2ndModule.

double vislab::yarp::util::RFModule2::getPeriod ( void   )  [virtual, inherited]
See also:
yarp::os::RFModule::getPeriod()

Definition at line 164 of file RFModule2.cpp.

References vislab::yarp::util::RFModule2::period.

                            {
        return period;
}

bool vislab::yarp::util::ThreadedRFModule::interruptModule ( void   )  [virtual, inherited]
See also:
RFModule2::interruptModule()

Reimplemented from vislab::yarp::util::RFModule2.

Definition at line 52 of file ThreadedRFModule.cpp.

                                       {
        // Since derived classes are supposed to create the Thread object,
        // we cannot rely on its existence.
        bool b = (workerThread != NULL ? workerThread->stop() : true);
        return RFModule2::interruptModule() && b;
}

bool vislab::yarp::util::RFModule2::isHandlerAvailable (  )  [inherited]

Returns an indicator of if the handler port is available/ opened.

Returns:
An indicator of if the handler port is available/ opened.

Definition at line 139 of file RFModule2.cpp.

References vislab::yarp::util::RFModule2::handlerPort.

Referenced by vislab::yarp::util::RFModule2::setName().

                                   {
        return createHandlerPort ? handlerPort.where().isValid() : false;
}

virtual bool vislab::yarp::util::RFModule2::respond ( const ::yarp::os::Bottle &  command,
::yarp::os::Bottle &  reply 
) [virtual, inherited]
See also:
yarp::os::RFModule::respond(yarp::os::Bottle, yarp::os::Bottle)
void vislab::yarp::util::RFModule2::setName ( const char *  name  )  [inherited]
See also:
yarp::os::RFModule::configure(const char*)

Definition at line 114 of file RFModule2.cpp.

References vislab::yarp::util::RFModule2::handlerPort, vislab::yarp::util::RFModule2::isHandlerAvailable(), and vislab::yarp::util::RFModule2::prefix.

                                        {
        RFModule::setName(name);

        if (createHandlerPort) {
                // Ensure that the RPC port is named after the latest module name.
                if (isHandlerAvailable()) {
                        handlerPort.interrupt();
                        handlerPort.close();
                        //detachTerminal();
                }

                // attach a port of the same name as the module (prefixed with a /) to the module
                // so that messages received from the port are redirected to the respond method
                if (handlerPort.open(prefix + getName())) {
                        attach(handlerPort);
#ifndef __unix__
                        // TODO: Hmmm, the warning actually appears on windows and unix systems
                        attachTerminal();
#endif
                } else {
                        cout << getName() << ": unable to open port " << handlerPort.getName() << endl;
                }
        }
}

bool vislab::yarp::util::RFModule2::updateModule ( void   )  [virtual, inherited]
See also:
yarp::os::RFModule::updateModule()

Reimplemented in vislab::control::HandCtrl, and vislab::demo::My2ndModule.

Definition at line 160 of file RFModule2.cpp.

                             {
        return true;
}


Field Documentation

::yarp::os::ConstString vislab::yarp::util::RFModule2::moduleName [protected, inherited]

The module's name.

Definition at line 116 of file RFModule2.h.

OptionManager vislab::yarp::util::RFModule2::moduleOptions [protected, inherited]

A std::map of module options stored as key value pairs.

Definition at line 128 of file RFModule2.h.

Referenced by vislab::yarp::util::RFModule2::addModuleOption().

double vislab::yarp::util::RFModule2::period [protected, inherited]

The interval in which the module's updateModule() functions gets called.

Definition at line 112 of file RFModule2.h.

Referenced by vislab::yarp::util::RFModule2::getPeriod().

::yarp::os::ConstString vislab::yarp::util::RFModule2::prefix [protected, inherited]

The "standard" prefix for YARP ports "/".

Definition at line 114 of file RFModule2.h.

Referenced by vislab::yarp::util::RFModule2::setName().

The RPC commands of the module.

Definition at line 126 of file RFModule2.h.

Referenced by vislab::yarp::util::RFModule2::addRemoteCommand().

::yarp::os::ConstString vislab::yarp::util::RFModule2::robotName [protected, inherited]

The name of the robot to be used.

Definition at line 118 of file RFModule2.h.


The documentation for this class was generated from the following files:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Friends Defines