Tango Core Classes Reference  9.2.5
Tango::Connection Class Referenceabstract

Base class for Tango device access. More...

#include "tango.h"

Inheritance diagram for Tango::Connection:

Public Member Functions

Miscellaneous methods
virtual void set_timeout_millis (int timeout)
 Set device timeout. More...
 
virtual int get_timeout_millis ()
 Get device timeout. More...
 
int get_idl_version ()
 Get device IDL version. More...
 
virtual Tango::DevSource get_source ()
 Get device source. More...
 
virtual void set_source (Tango::DevSource sou)
 Set device source. More...
 
virtual void set_transparency_reconnection (bool val)
 Set device transparency (reconnection) mode. More...
 
virtual bool get_transparency_reconnection ()
 Get device transparency (reconnection) mode. More...
 
Synchronous command oriented methods
virtual DeviceData command_inout (string &cmd_name)
 Execute a command (without input data) More...
 
virtual DeviceData command_inout (const char *cmd_name)
 Execute a command (without input data) More...
 
virtual DeviceData command_inout (string &cmd_name, DeviceData &d_in)
 Execute a command (with input data) More...
 
virtual DeviceData command_inout (const char *cmd_name, DeviceData &d_in)
 Execute a command (with input data) More...
 
Aynchronous command oriented methods
virtual long command_inout_asynch (const char *cmd_name, DeviceData &argin, bool forget=false)
 Execute a command asynchronously (with input argument) More...
 
virtual long command_inout_asynch (string &cmd_name, DeviceData &argin, bool forget=false)
 Execute a command asynchronously (with input argument) More...
 
virtual long command_inout_asynch (const char *cmd_name, bool forget=false)
 Execute a command asynchronously. More...
 
virtual long command_inout_asynch (string &cmd_name, bool forget=false)
 Execute a command asynchronously. More...
 
virtual DeviceData command_inout_reply (long id)
 Check an asynchronous command_inout answer is arrived. More...
 
virtual DeviceData command_inout_reply (long id, long timeout)
 Check an asynchronous command_inout answer is arrived with timeout. More...
 
virtual void command_inout_asynch (string &cmd_name, CallBack &cb)
 Execute a command asynchronously with callback. More...
 
virtual void command_inout_asynch (const char *cmd_name, CallBack &cb)
 Execute a command asynchronously with callback. More...
 
virtual void command_inout_asynch (string &cmd_name, DeviceData &argin, CallBack &cb)
 Execute a command asynchronously with input value and callback. More...
 
virtual void command_inout_asynch (const char *cmd_name, DeviceData &argin, CallBack &cb)
 Execute a command asynchronously with input value and callback. More...
 
Asynchronous attribute related methods
virtual void get_asynch_replies ()
 Fire callback methods. More...
 
virtual void get_asynch_replies (long timeout)
 Fire callback methds with timeout. More...
 
virtual void cancel_asynch_request (long id)
 Cancel a pending asynchronous request. More...
 
virtual void cancel_all_polling_asynch_request ()
 Cancel all pending asynchronous request. More...
 

Detailed Description

Base class for Tango device access.

Base class for Tango device access. This class is pure virtual and can be instanciated as is.

Author
taurel
Revision
1

Member Function Documentation

virtual void Tango::Connection::cancel_all_polling_asynch_request ( )
virtual

Cancel all pending asynchronous request.

Cancel all pending polling asynchronous requests. This is a call local to the client. It simply allows the caller not to get the answers of the asynchronous requests. It does not interrupt the call execution on the remote devices.

virtual void Tango::Connection::cancel_asynch_request ( long  id)
virtual

Cancel a pending asynchronous request.

Cancel a pending asynchronous request. id is the asynchronous call identifier. This is a call local to the client. It simply allows the caller not to get the answer of the asynchronous request. It does not interrupt the call execution on the remote device.

Parameters
[in]idThe call identifier
Exceptions
AsynCall
virtual DeviceData Tango::Connection::command_inout ( string &  cmd_name)
virtual

Execute a command (without input data)

Execute a command on a device which takes no input arguments (void). The result is returned in a DeviceData object

Parameters
[in]cmd_nameThe command name
Returns
The command result
Exceptions
ConnectionFailed,CommunicationFailed,DeviceUnlocked,DevFailedfrom device
virtual DeviceData Tango::Connection::command_inout ( const char *  cmd_name)
inlinevirtual

Execute a command (without input data)

Execute a command on a device which takes no input arguments (void). The result is returned in a DeviceData object

Parameters
[in]cmd_nameThe command name
Returns
The command result
Exceptions
ConnectionFailed,CommunicationFailed,DeviceUnlocked,DevFailedfrom device
virtual DeviceData Tango::Connection::command_inout ( string &  cmd_name,
DeviceData d_in 
)
virtual

Execute a command (with input data)

Execute a command on a device. Input arguments are passed in a DeviceData object, output is returned as a DeviceData object.

Parameters
[in]cmd_nameThe command name
[in]d_inCommand input data
Returns
The command result
Exceptions
ConnectionFailed,CommunicationFailed,DeviceUnlocked,DevFailedfrom device
virtual DeviceData Tango::Connection::command_inout ( const char *  cmd_name,
DeviceData d_in 
)
inlinevirtual

Execute a command (with input data)

Execute a command on a device. Input arguments are passed in a DeviceData object, output is returned as a DeviceData object.

Parameters
[in]cmd_nameThe command name
[in]d_inCommand input data
Returns
The command result
Exceptions
ConnectionFailed,CommunicationFailed,DeviceUnlocked,DevFailedfrom device
virtual long Tango::Connection::command_inout_asynch ( const char *  cmd_name,
DeviceData argin,
bool  forget = false 
)
virtual

Execute a command asynchronously (with input argument)

Execute asynchronously (polling model) a command on a device. Input arguments are passed in a DeviceData object (see following chapters on how to insert data into DeviceData object). The last argument is a fire and forget flag. If this flag is set to true, this means that the client does not care at all about the server answer and will even not try to get it. A false default value is provided. Please, note that device re-connection will not take place (in case it is needed) if the fire and forget mode is used. Therefore, an application using only fire and forget requests is not able to automatically re-connnect to device. This call returns an asynchronous call identifier which is needed to get the command result.

Parameters
[in]cmd_nameThe command name
[in]arginCommand input data
[in]forgetFire and forget flag
Returns
The call identifier
Exceptions
ConnectionFailed
virtual long Tango::Connection::command_inout_asynch ( string &  cmd_name,
DeviceData argin,
bool  forget = false 
)
virtual

Execute a command asynchronously (with input argument)

Execute asynchronously (polling model) a command on a device. Input arguments are passed in a DeviceData object (see following chapters on how to insert data into DeviceData object). The last argument is a fire and forget flag. If this flag is set to true, this means that the client does not care at all about the server answer and will even not try to get it. A false default value is provided. Please, note that device re-connection will not take place (in case it is needed) if the fire and forget mode is used. Therefore, an application using only fire and forget requests is not able to automatically re-connnect to device. This call returns an asynchronous call identifier which is needed to get the command result.

Parameters
[in]cmd_nameThe command name
[in]arginCommand input data
[in]forgetFire and forget flag
Returns
The call identifier
Exceptions
ConnectionFailed
virtual long Tango::Connection::command_inout_asynch ( const char *  cmd_name,
bool  forget = false 
)
virtual

Execute a command asynchronously.

Execute asynchronously (polling model) a command on a device which takes no input argument. The last argument is a fire and forget flag. If this flag is set to true, this means that the client does not care at all about the server answer and will even not try to get it. A false default value is provided. Please, note that device re-connection will not take place (in case it is needed) if the fire and forget mode is used. Therefore, an application using only fire and forget requests is not able to automatically re-connnect to device. This call returns an asynchronous call identifier which is needed to get the command result.

Parameters
[in]cmd_nameThe command name
[in]forgetFire and forget flag
Returns
The call identifier
Exceptions
ConnectionFailed
virtual long Tango::Connection::command_inout_asynch ( string &  cmd_name,
bool  forget = false 
)
virtual

Execute a command asynchronously.

Execute asynchronously (polling model) a command on a device which takes no input argument. The last argument is a fire and forget flag. If this flag is set to true, this means that the client does not care at all about the server answer and will even not try to get it. A false default value is provided. Please, note that device re-connection will not take place (in case it is needed) if the fire and forget mode is used. Therefore, an application using only fire and forget requests is not able to automatically re-connnect to device. This call returns an asynchronous call identifier which is needed to get the command result.

Parameters
[in]cmd_nameThe command name
[in]forgetFire and forget flag
Returns
The call identifier
Exceptions
ConnectionFailed
virtual void Tango::Connection::command_inout_asynch ( string &  cmd_name,
CallBack cb 
)
virtual

Execute a command asynchronously with callback.

Execute asynchronously (callback model) a command on a device which takes no input argument. The last argument is a reference to a callback object. This callback object should be an instance of a user class inheriting from the Tango::CallBack class with the cmd_ended() method overloaded.

Parameters
[in]cmd_nameThe command name
[in]cbThe call-back object
Exceptions
ConnectionFailed
virtual void Tango::Connection::command_inout_asynch ( const char *  cmd_name,
CallBack cb 
)
virtual

Execute a command asynchronously with callback.

Execute asynchronously (callback model) a command on a device which takes no input argument. The last argument is a reference to a callback object. This callback object should be an instance of a user class inheriting from the Tango::CallBack class with the cmd_ended() method overloaded.

Parameters
[in]cmd_nameThe command name
[in]cbThe call-back object
Exceptions
ConnectionFailed
virtual void Tango::Connection::command_inout_asynch ( string &  cmd_name,
DeviceData argin,
CallBack cb 
)
virtual

Execute a command asynchronously with input value and callback.

Execute asynchronously (callback model) a command on a device. Input arguments are passed in a DeviceData object (see following chapters on how to insert data into DeviceData object). The last argument is a reference to a callback object. This callback object should be an instance of a user class inheriting from the Tango::CallBack class with the cmd_ended() method overloaded.

Parameters
[in]cmd_nameThe command name
[in]arginThe command input data
[in]cbThe call-back object
Exceptions
ConnectionFailed
virtual void Tango::Connection::command_inout_asynch ( const char *  cmd_name,
DeviceData argin,
CallBack cb 
)
virtual

Execute a command asynchronously with input value and callback.

Execute asynchronously (callback model) a command on a device. Input arguments are passed in a DeviceData object (see following chapters on how to insert data into DeviceData object). The last argument is a reference to a callback object. This callback object should be an instance of a user class inheriting from the Tango::CallBack class with the cmd_ended() method overloaded.

Parameters
[in]cmd_nameThe command name
[in]arginThe command input data
[in]cbThe call-back object
Exceptions
ConnectionFailed
virtual DeviceData Tango::Connection::command_inout_reply ( long  id)
virtual

Check an asynchronous command_inout answer is arrived.

Check if the answer of an asynchronous command_inout is arrived (polling model). id is the asynchronous call identifier. If the reply is arrived and if it is a valid reply, it is returned to the caller in a DeviceData object. If the reply is an exception, it is re-thrown by this call. An exception is also thrown in case of the reply is not yet arrived. Example :

Tango::DeviceProxy dev("...");
long asyn_id;
asyn_id = dev.command_inout_asynch("MyCmd");
...
...
...
Tango::DeviceData arg;
try
{
arg = dev.command_inout_reply(asyn_id);
}
catch(Tango::AsynReplyNotArrived)
{
cerr << "Command not arrived !" << endl;
}
catch (Tango::DevFailed &e)
{
}
Parameters
[in]idThe call identifier
Returns
The command result
Exceptions
AsynCall,AsynReplyNotArrived,CommunicationFailed,DevFailedfrom device
virtual DeviceData Tango::Connection::command_inout_reply ( long  id,
long  timeout 
)
virtual

Check an asynchronous command_inout answer is arrived with timeout.

Check if the answer of an asynchronous command_inout is arrived (polling model). id is the asynchronous call identifier. If the reply is arrived and if it is a valid reply, it is returned to the caller in a DeviceData object. If the reply is an exception, it is re-thrown by this call. If the reply is not yet arrived, the call will wait (blocking the process) for the time specified in timeout. If after timeout milliseconds, the reply is still not there, an exception is thrown. If timeout is set to 0, the call waits until the reply arrived.

Parameters
[in]idThe call identifier 8
[in]timeoutThe timeout value
Returns
The command result
Exceptions
AsynCall,AsynReplyNotArrived,CommunicationFailed,DevFailedfrom device
virtual void Tango::Connection::get_asynch_replies ( )
virtual

Fire callback methods.

Fire callback methods for device asynchronous requests with already arrived replied. Returns immediately if there is no replies already arrived or if there is no asynchronous request for the device. Example :

class MyCallBack: Tango::CallBack
{
public:
MyCallback(double d):data(d) {};
virtual void cmd_ended(Tango::CmdDoneEvent *);
private:
double data;
};
void MyCallBack::cmd_ended(Tango CmdDoneEvent *cmd)
{
if (cmd->err == true)
else
{
short cmd_result;
cmd->argout >> cmd_result;
cout << "Command result = " << cmd_result << endl;
cout << "Callback personal data = " << data << endl;
}
}
int main(int argc, char *argv[])
{
....
....
Tango::DeviceProxy dev("...");
double my_data = ...;
MyCallBack cb(my_data);
...
dev.command_inout_asynch("MyCmd",cb);
...
...
...
dev.get_asynch_replies();
...
...
}
virtual void Tango::Connection::get_asynch_replies ( long  timeout)
virtual

Fire callback methds with timeout.

Fire callback methods for device asynchronous requests (command and attributes) with already arrived replied. Wait and block the caller for timeout milliseconds if they are some device asynchronous requests which are not yet arrived. Returns immediately if there is no asynchronous request for the device. If timeout is set to 0, the call waits until all the asynchronous requests sent to the device has received a reply.

Parameters
[in]timeoutThe timeout value
int Tango::Connection::get_idl_version ( )
inline

Get device IDL version.

Get the version of the Tango Device IDL interface implemented by the device

Returns
The device IDL version
virtual Tango::DevSource Tango::Connection::get_source ( )
virtual

Get device source.

Get the device data source used by command_inout or read_attribute methods. The DevSource is an enumerated type which can be one of {DEV, CACHE, CACHE_DEV}. See chapter on Advanced Feature in Tango book for all details regarding polling.

Returns
The device source flag
virtual int Tango::Connection::get_timeout_millis ( )
virtual

Get device timeout.

Get the client side timeout in milliseconds.

Returns
The device timeout (in mS)
virtual bool Tango::Connection::get_transparency_reconnection ( )
inlinevirtual

Get device transparency (reconnection) mode.

Returns the transparency reconnection flag. See Reconnection and exception for more details on reconnection and exception

Returns
The device transparency flag
virtual void Tango::Connection::set_source ( Tango::DevSource  sou)
virtual

Set device source.

Set the data source (device, polling buffer, polling buffer than device) for command_inout and read_attribute methods. The DevSource is an enumerated type which can be one of {DEV, CACHE, CACHE_DEV}. The default value is CACHE_DEV. See chapter on Advanced Feature for all details regarding polling

Parameters
[in]souThe device source
virtual void Tango::Connection::set_timeout_millis ( int  timeout)
virtual

Set device timeout.

Set client side timeout for device in milliseconds. Any method which takes longer than this time to execute will throw an exception.

Parameters
[in]timeoutThe timeout value in mS
virtual void Tango::Connection::set_transparency_reconnection ( bool  val)
inlinevirtual

Set device transparency (reconnection) mode.

If flag is true, no exception will be thrown in case of network communication error between client and server. The API will try to re-build the network connection between client and server as soon as an error is detected. See Reconnection and exception for more details on reconnection and exception

Parameters
[in]valThe device transparency flag

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