Tango Core Classes Reference  9.3.3
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

◆ cancel_all_polling_asynch_request()

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.

◆ cancel_asynch_request()

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

◆ command_inout() [1/4]

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

◆ command_inout() [2/4]

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

◆ command_inout() [3/4]

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

◆ command_inout() [4/4]

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

◆ command_inout_asynch() [1/8]

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

◆ command_inout_asynch() [2/8]

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

◆ command_inout_asynch() [3/8]

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

◆ command_inout_asynch() [4/8]

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

◆ command_inout_asynch() [5/8]

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

◆ command_inout_asynch() [6/8]

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

◆ command_inout_asynch() [7/8]

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

◆ command_inout_asynch() [8/8]

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

◆ command_inout_reply() [1/2]

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

◆ command_inout_reply() [2/2]

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

◆ get_asynch_replies() [1/2]

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();
...
...
}

◆ get_asynch_replies() [2/2]

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

◆ get_idl_version()

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

◆ get_source()

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

◆ get_timeout_millis()

virtual int Tango::Connection::get_timeout_millis ( )
virtual

Get device timeout.

Get the client side timeout in milliseconds.

Returns
The device timeout (in mS)

◆ get_transparency_reconnection()

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

◆ set_source()

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

◆ set_timeout_millis()

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

◆ set_transparency_reconnection()

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:
Tango::Except::print_error_stack
static void print_error_stack(const Tango::DevErrorList &ex)
Print a TANGO error stack.
Tango::DeviceProxy
High level class which provides the client with an easy-to-use interface to TANGO devices.
Definition: devapi.h:56
Tango::Except::print_exception
static void print_exception(const CORBA::Exception &ex)
Print a TANGO exception.
Tango::CallBack
Event and asynchronous (callback model) calls base class.
Definition: devasyn.h:234
Tango::CmdDoneEvent
Asynchronous command execution callback data.
Definition: devasyn.h:76