rec::robotino::api2 C++ interface
Public Member Functions | List of all members
rec::robotino::api2::Com Class Reference

Represents a communication device. More...

#include <Com.h>

Public Member Functions

 Com ()
 
 Com (const char *name)
 
 Com (const char *name, bool multiThreadedSerialization)
 
 Com (const char *name, bool multiThreadedSerialization, bool localIPCEnabled)
 
virtual ~Com ()
 
ComId id () const
 
void connectToServer (bool isBlocking=true)
 
void disconnectFromServer ()
 
bool isConnected () const
 
void setAutoReconnectEnabled (bool enable)
 
void setAddress (const char *address)
 
const char * address () const
 
void setName (const char *name)
 
void setMultiThreadedSerializationEnabled (bool enabled)
 
bool isLocalConnection () const
 
unsigned int msecsElapsed () const
 
void processEvents ()
 
void processComEvents ()
 
void processChargerEvents ()
 
void processPowerButtonEvents ()
 
void processFactory4Events ()
 
virtual void errorEvent (const char *errorString)
 
virtual void connectedEvent ()
 
virtual void connectionClosedEvent ()
 
virtual void logEvent (const char *message, int level)
 

Detailed Description

Represents a communication device.

Constructor & Destructor Documentation

rec::robotino::api2::Com::Com ( )

Construct the Com object.

Exceptions
nothing
rec::robotino::api2::Com::Com ( const char *  name)

Construct the Com object.

Parameters
nameA custom name for the client. If NULL, a default name will be used.
Exceptions
nothing
rec::robotino::api2::Com::Com ( const char *  name,
bool  multiThreadedSerialization 
)

Construct the Com object.

Parameters
nameA custom name for the client. If NULL, a default name will be used.
multiThreadedSerializationIf true, (de)serialization tasks will be performed by multiple threads. This should perform better on multi core CPUs.
Exceptions
nothing
rec::robotino::api2::Com::Com ( const char *  name,
bool  multiThreadedSerialization,
bool  localIPCEnabled 
)

Construct the Com object.

Parameters
nameA custom name for the client. If NULL, a default name will be used.
multiThreadedSerializationIf true, (de)serialization tasks will be performed by multiple threads. This should perform better on multi core CPUs.
localIPCEnabledIf true, local sockets and shared memory is used for communication. This can lead to problems due to different privileges of the server and the client. But is of course much faster than TCP sockets. If false TCP sockets are used only.
Exceptions
nothing
virtual rec::robotino::api2::Com::~Com ( )
virtual
Exceptions
nothing

Member Function Documentation

const char* rec::robotino::api2::Com::address ( ) const

Returns the currently active server address.

Returns
Address set with setAddress
See also
setAddress
Exceptions
nothing.
Remarks
This function is thread save
virtual void rec::robotino::api2::Com::connectedEvent ( )
virtual

This function is called if a connection to Robotino has been established. Note: This function is called from outside the applications main thread. This is extremely important particularly with regard to GUI applications.

Exceptions
nothing.
Remarks
This function is called from the thread in which Com::processEvents() is called.
See also
processEvents
virtual void rec::robotino::api2::Com::connectionClosedEvent ( )
virtual

This function is called when a connection is closed. Note: This function is called from outside the applications main thread. This is extremely important particularly with regard to GUI applications.

Exceptions
nothing.
Remarks
This function is called from the thread in which Com::processEvents() is called.
See also
processEvents
void rec::robotino::api2::Com::connectToServer ( bool  isBlocking = true)

Connects to the server. This function blocks until the connection is established or an error occurs.

Parameters
isBlockingIf true, this function blocks until the connection is established or an error occurs. Otherwise the function is non blocking and you have to wait for error or connected callbacks.
Exceptions
Inblocking mode a ComException is thrown if the client couldn't connect. In non blocking mode throws nothing.
Remarks
This function is thread save
void rec::robotino::api2::Com::disconnectFromServer ( )

Disconnects from the server and disables autoupdating.

Exceptions
nothing.
Remarks
This function is thread save
virtual void rec::robotino::api2::Com::errorEvent ( const char *  errorString)
virtual

This function is called on errors.

Parameters
errorStringA human readable error description.
Exceptions
nothing.
Remarks
This function is called from the thread in which Com::processEvents() is called.
See also
processEvents
ComId rec::robotino::api2::Com::id ( ) const

The unique identifier of this communication object.

Returns
The identifier.
Exceptions
nothing.
bool rec::robotino::api2::Com::isConnected ( ) const

Test wether the client is connected to the server.

Returns
TRUE if connected, FALSE otherwise.
Exceptions
nothing.
Remarks
This function is thread save
bool rec::robotino::api2::Com::isLocalConnection ( ) const
Returns
Returns true if the connection is a local connection. Otherwise returns false.
virtual void rec::robotino::api2::Com::logEvent ( const char *  message,
int  level 
)
virtual

This function is called when a log message is posted. Note: This function is called from outside the applications main thread. This is extremely important particularly with regard to GUI applications.

Parameters
messageThe log message.
levelThe log level.
Exceptions
nothing.
Remarks
This function is called from the thread in which Com::processEvents() is called.
See also
processEvents
unsigned int rec::robotino::api2::Com::msecsElapsed ( ) const
Returns
Milliseconds since connection to server had ben established.
void rec::robotino::api2::Com::processChargerEvents ( )

Call this function from your main thread to get the virtual Charger functions called. The virtual functions are called directly by a call of this function

Exceptions
nothing
See also
Com::processEvents
void rec::robotino::api2::Com::processComEvents ( )

Call this function from your main thread to get the virtual functions of this Com object called. The virtual functions are called directly by a call of this function.

Exceptions
nothing
Remarks
This function needn't be called if processEvents() is called.
void rec::robotino::api2::Com::processEvents ( )

Call this function from your main thread to get the virtual functions of all ComObjects called. The virtual functions are called directly by a call of this function.

Exceptions
nothing
Remarks
This function should be called as fast as possible in order to get readings from sensors quickly, e.g. in the main event loop of GUI applications.
void rec::robotino::api2::Com::processFactory4Events ( )

Call this function from your main thread to get the virtual Factory4 functions called. The virtual functions are called directly by a call of this function

Exceptions
nothing
See also
Com::processEvents
void rec::robotino::api2::Com::processPowerButtonEvents ( )

Call this function from your main thread to get the virtual PowerButton functions called. The virtual functions are called directly by a call of this function

Exceptions
nothing
See also
Com::processEvents
void rec::robotino::api2::Com::setAddress ( const char *  address)

Sets the address of the server.

Parameters
addressThe address of the server e.g. "172.26.1.1" or "127.0.0.1" To connect to Robotino Sim you also have to specify the server port. The first simulated Robotino listens at port 8080. The address is then "127.0.0.1:8080". Without port specification port 80 (Robotino's default port) is used.
See also
address
Exceptions
nothing.
Remarks
This function is thread save
void rec::robotino::api2::Com::setAutoReconnectEnabled ( bool  enable)

Enable/disable automatic reconnection

When enabled the client tries to reconnect automatically after the specified number of milliseconds.

Parameters
enableIf true the automatic reconnect will be enabled. If false the client does not reconnect to the server automatically.
See also
connected(), disconnected(), disconnectFromServer()
void rec::robotino::api2::Com::setMultiThreadedSerializationEnabled ( bool  enabled)

Enable/disable multi-threaded serialization. Disabled by default.

Parameters
enabledIf true, (de)serialization tasks will be performed by multiple threads. This should perform better on multi core CPUs.
Exceptions
nothing
Remarks
The client has to be disconnected and reconnected for the change to take effekt.
void rec::robotino::api2::Com::setName ( const char *  name)

Set the client's name

Parameters
nameA custom name for the client. If NULL, a default name will be used.
Exceptions
nothing
Remarks
The client has to be disconnected and reconnected for the change to take effekt.

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