ESRF Logo

Elettra Logo

Soleil Logo

Alba Logo

Desy Logo

MAX-lab Logo

FRM2 Logo


SYNCHROTRON ALBA --- SYNCHROTRON ELETTRA

EUROPEAN SYNCHROTRON RADIATION FACILITY --- SYNCHROTRON PETRA III

SYNCHROTRON SOLEIL --- SYNCHROTRON MAX 4

NEUTRON SOURCE FRM 2

Tango::Util Class Reference

This class is a used to store TANGO device server process data and to provide the user with a set of utilities method. More...

#include <utils.h>

List of all members.

Public Member Functions

Destructor
Only one destructor is defined for this class

 ~Util ()
 The class destructor.
Get/Set instance data
CORBA::ORB_ptr get_orb ()
 Get a reference to the CORBA ORB.
PortableServer::POA_ptr get_poa ()
 Get a reference to the CORBA Portable Object Adapter (POA).
void set_trace_level (int level)
 Set the process trace level.
int get_trace_level ()
 Get the process trace level.
string & get_ds_inst_name ()
 Get the device server instance name.
string & get_ds_exec_name ()
 Get the device server executable name.
string & get_ds_name ()
 Get the device server name.
string & get_host_name ()
 Get the host name where the device server process is running.
string & get_pid_str ()
 Get the device server process identifier as a String.
TangoSys_Pid get_pid ()
 Get the device server process identifier.
long get_tango_lib_release ()
 Get the TANGO library version number.
string & get_version_str ()
 Get the IDL TANGO version.
string & get_server_version ()
 Get the device server version.
void set_server_version (const char *vers)
 Set the device server version.
void set_class_list (vector< DeviceClass * > *list)
 Set the DeviceClass list pointer.
void add_class_to_list (DeviceClass *cl)
 Add a DeviceClass to the DeviceClass list pointer.
const vector< DeviceClass * > * get_class_list ()
 Get the DeviceClass list pointer.
void set_serial_model (SerialModel ser)
 Set the serialization model.
SerialModel get_serial_model ()
 Get the serialization model.
EventSupplier * get_event_supplier ()
 Get a reference to the TANGO EventSupplier object.
Database related methods
void connect_db ()
 Connect the process to the TANGO database.
void reset_filedatabase ()
 Reread the file database.
Database * get_database ()
 Get a reference to the TANGO database object.
void unregister_server ()
 Unregister a device server process from the TANGO database.
Device reference related methods
vector< DeviceImpl * > & get_device_list_by_class (const string &class_name)
 Get the list of device references for a given TANGO class.
vector< DeviceImpl * > & get_device_list_by_class (const char *class_name)
 Get the list of device references for a given TANGO class.
DeviceImplget_device_by_name (const string &dev_name)
 Get a device reference from its name.
DeviceImplget_device_by_name (const char *dev_name)
 Get a device reference from its name.
DServer * get_dserver_device ()
 Get a reference to the dserver device attached to the device server process.
vector< DeviceImpl * > get_device_list (const string &name)
 Get DeviceList from name.
Device pattern related methods
void server_init (bool with_window=false)
 Initialise all the device server pattern(s) embedded in a device server process.
void server_run ()
 Run the CORBA event loop.
void server_cleanup ()
 Cleanup a Tango device server process before exit.
void server_set_event_loop (bool(*f_ptr)())
 Set the server event loop.
Polling related methods
void trigger_cmd_polling (DeviceImpl *dev, const string &name)
 Trigger polling for polled command.
void trigger_attr_polling (DeviceImpl *dev, const string &name)
 Trigger polling for polled attribute.
template<typename T >
void fill_attr_polling_buffer (DeviceImpl *dev, string &att_name, AttrHistoryStack< T > &data)
 Fill polling buffer for polled attribute.
template<typename T >
void fill_cmd_polling_buffer (DeviceImpl *dev, string &cmd_name, CmdHistoryStack< T > &data)
 Fill polling buffer for polled command.
void set_polling_threads_pool_size (long thread_nb)
 Set the polling threads pool size.
long get_polling_threads_pool_size ()
 Get the polling threads pool size.

Static Public Member Functions

Singleton related methods
These methods follow the singleton design pattern (only one instance of a class)

static Utilinit (int argc, char *argv[])
 Create and get the singleton object reference.
static TANGO_IMP_EXP Utilinstance (bool exit=true)
 Get the singleton object reference.

Static Public Attributes

Class data members
static int _tracelevel
 The process trace level.
static TANGO_IMP bool _UseDb
 The database use flag (Use with extreme care).
static TANGO_IMP bool _FileDb
static TANGO_IMP bool _daemon
 A daemon process flag.
static TANGO_IMP long _sleep_between_connect
 The loop sleeping time in case of the _daemon flag set to true.

Protected Member Functions

 Util (int argc, char *argv[])
 Constructs a newly allocated Util object.


Detailed Description

This class is a used to store TANGO device server process data and to provide the user with a set of utilities method.

This class is implemented using the singleton design pattern. Therefore a device server process can have only one instance of this class and its constructor is not public.

Author
taurel
Revision
15556

Constructor & Destructor Documentation

Tango::Util::Util ( int  argc,
char *  argv[] 
) [protected]

Constructs a newly allocated Util object.

This constructor is protected following the singleton pattern

Parameters:
argc The process command line argument number
argv The process commandline arguments


Member Function Documentation

void Tango::Util::add_class_to_list ( DeviceClass cl  )  [inline]

Add a DeviceClass to the DeviceClass list pointer.

Parameters:
cl The DeviceClass ptr

void Tango::Util::connect_db (  ) 

Connect the process to the TANGO database.

If the connection to the database failed, a message is displayed on the screen and the process is aborted

template<typename T >
void Tango::Util::fill_attr_polling_buffer ( DeviceImpl dev,
string &  att_name,
AttrHistoryStack< T > &  data 
) [inline]

Fill polling buffer for polled attribute.

This method fills the polling buffer for one polled attribute registered with an update period defined as "externally triggerred" (polling period set to 0)

Parameters:
dev The TANGO device
att_name The attribute name which must be polled
data The data stack with one element for each history element
Exceptions:
DevFailed If the call failed Click here to read DevFailed exception specification

template<typename T >
void Tango::Util::fill_cmd_polling_buffer ( DeviceImpl dev,
string &  cmd_name,
CmdHistoryStack< T > &  data 
) [inline]

Fill polling buffer for polled command.

This method fills the polling buffer for one polled command registered with an update period defined as "externally triggerred" (polling period set to 0)

Parameters:
dev The TANGO device
cmd_name The command name which must be polled
data The data stack with one element for each history element
Exceptions:
DevFailed If the call failed Click here to read DevFailed exception specification

const vector<DeviceClass *>* Tango::Util::get_class_list (  )  [inline]

Get the DeviceClass list pointer.

Returns:
The DeviceClass ptr vector address

Database* Tango::Util::get_database (  )  [inline]

Get a reference to the TANGO database object.

Returns:
The database object

DeviceImpl* Tango::Util::get_device_by_name ( const char *  dev_name  ) 

Get a device reference from its name.

Parameters:
dev_name The TANGO device name
Returns:
The device reference
Exceptions:
DevFailed If in the device is not served by one device pattern implemented in this process. Click here to read DevFailed exception specification

DeviceImpl* Tango::Util::get_device_by_name ( const string &  dev_name  ) 

Get a device reference from its name.

Parameters:
dev_name The TANGO device name
Returns:
The device reference
Exceptions:
DevFailed If in the device is not served by one device pattern implemented in this process. Click here to read DevFailed exception specification

vector<DeviceImpl *> Tango::Util::get_device_list ( const string &  name  ) 

Get DeviceList from name.

It is possible to use a wild card ('*') in the name parameter (e.g. "*", "/tango/tangotest/n*", ...)

Parameters:
name The device name
Returns:
The DeviceClass ptr vector address

vector<DeviceImpl *>& Tango::Util::get_device_list_by_class ( const char *  class_name  ) 

Get the list of device references for a given TANGO class.

Return the list of references for all devices served by one implementation of the TANGO device pattern implemented in the process

Parameters:
class_name The TANGO device class name
Returns:
The device reference list
Exceptions:
DevFailed If in the device server process there is no TANGO device pattern implemented the TANGO device class given as parameter Click here to read DevFailed exception specification

vector<DeviceImpl *>& Tango::Util::get_device_list_by_class ( const string &  class_name  ) 

Get the list of device references for a given TANGO class.

Return the list of references for all devices served by one implementation of the TANGO device pattern implemented in the process

Parameters:
class_name The TANGO device class name
Returns:
The device reference list
Exceptions:
DevFailed If in the device server process there is no TANGO device pattern implemented the TANGO device class given as parameter Click here to read DevFailed exception specification

string& Tango::Util::get_ds_exec_name (  )  [inline]

Get the device server executable name.

Returns:
The device server executable name

string& Tango::Util::get_ds_inst_name (  )  [inline]

Get the device server instance name.

Returns:
The device server instance name

string& Tango::Util::get_ds_name (  )  [inline]

Get the device server name.

The device server name is the device server executable name/the device server instance name

Returns:
The device server name

DServer* Tango::Util::get_dserver_device (  ) 

Get a reference to the dserver device attached to the device server process.

Returns:
A reference to the dserver device

EventSupplier* Tango::Util::get_event_supplier (  )  [inline]

Get a reference to the TANGO EventSupplier object.

Returns:
The EventSupplier object

string& Tango::Util::get_host_name (  )  [inline]

Get the host name where the device server process is running.

Returns:
The host name

CORBA::ORB_ptr Tango::Util::get_orb (  )  [inline]

Get a reference to the CORBA ORB.

This is a CORBA _duplicate of the original reference

Returns:
The CORBA ORB

TangoSys_Pid Tango::Util::get_pid (  )  [inline]

Get the device server process identifier.

Returns:
The device server process identifier

string& Tango::Util::get_pid_str (  )  [inline]

Get the device server process identifier as a String.

Returns:
The device server process identifier as a string

PortableServer::POA_ptr Tango::Util::get_poa (  )  [inline]

Get a reference to the CORBA Portable Object Adapter (POA).

This is a CORBA _dupilcate of the original reference to the object POA. For classical device server, thisis the root POA. For no database device server, this is a specific POA with the USER_ID policy.

Returns:
The CORBA root POA

long Tango::Util::get_polling_threads_pool_size (  )  [inline]

Get the polling threads pool size.

Returns:
The maximun number of threads in the polling threads pool

SerialModel Tango::Util::get_serial_model (  )  [inline]

Get the serialization model.

Returns:
The serialization model. This serialization model is one of BY_DEVICE, BY_CLASS, BY_PROCESS or NO_SYNC

string& Tango::Util::get_server_version (  )  [inline]

Get the device server version.

Returns:
The device server version

long Tango::Util::get_tango_lib_release (  ) 

Get the TANGO library version number.

Returns:
The Tango library release number coded in 3 digits (for instance 550,551,552,600,....)

int Tango::Util::get_trace_level (  )  [inline]

Get the process trace level.

Returns:
The process trace level

string& Tango::Util::get_version_str (  )  [inline]

Get the IDL TANGO version.

Returns:
The device server version

static Util* Tango::Util::init ( int  argc,
char *  argv[] 
) [static]

Create and get the singleton object reference.

This method returns a reference to the object of the Util class. If the class singleton object has not been created, it will be instanciated

Parameters:
argc The process command line argument number
argv The process commandline arguments
Returns:
The Util object reference

static TANGO_IMP_EXP Util* Tango::Util::instance ( bool  exit = true  )  [static]

Get the singleton object reference.

This method returns a reference to the object of the Util class. If the class has not been initialised with it's init method, this method print a message and abort the device server process

Returns:
The Util object reference

void Tango::Util::server_cleanup (  ) 

Cleanup a Tango device server process before exit.

This method cleanup a Tango device server and relinquish all computer resources before the process exit

void Tango::Util::server_init ( bool  with_window = false  ) 

Initialise all the device server pattern(s) embedded in a device server process.

Exceptions:
DevFailed If the device pattern initialistaion failed Click here to read DevFailed exception specification

void Tango::Util::server_run (  ) 

Run the CORBA event loop.

This method runs the CORBA event loop. For UNIX or Linux operating system, this method does not return. For Windows in a non-console mode, this method start a thread which enter the CORBA event loop.

void Tango::Util::server_set_event_loop ( bool(*)()  f_ptr  )  [inline]

Set the server event loop.

This method registers an event loop function in a Tango server. This function will be called by the process main thread in an infinite loop The process will not use the classical ORB blocking event loop. It is the user responsability to code this function in a way that it implements some kind of blocking in order not to load the computer CPU

Parameters:
f_ptr The event loop function pointer. This function will not receive any argument. It returns a boolean value. If this boolean is set to true, the device server process exit.

void Tango::Util::set_class_list ( vector< DeviceClass * > *  list  )  [inline]

Set the DeviceClass list pointer.

Parameters:
list The DeviceClass ptr vector address

void Tango::Util::set_polling_threads_pool_size ( long  thread_nb  )  [inline]

Set the polling threads pool size.

Parameters:
thread_nb The maximun number of threads in the polling threads pool

void Tango::Util::set_serial_model ( SerialModel  ser  )  [inline]

Set the serialization model.

Parameters:
ser The new serialization model. The serialization model must be one of BY_DEVICE, BY_CLASS, BY_PROCESS or NO_SYNC

void Tango::Util::set_server_version ( const char *  vers  )  [inline]

Set the device server version.

Parameters:
vers The device server version

void Tango::Util::set_trace_level ( int  level  )  [inline]

Set the process trace level.

Parameters:
level The new process level

void Tango::Util::trigger_attr_polling ( DeviceImpl dev,
const string &  name 
)

Trigger polling for polled attribute.

This method send the order to the polling thread to poll one object registered with an update period defined as "externally triggerred"

Parameters:
dev The TANGO device
name The attribute name which must be polled
Exceptions:
DevFailed If the call failed Click here to read DevFailed exception specification

void Tango::Util::trigger_cmd_polling ( DeviceImpl dev,
const string &  name 
)

Trigger polling for polled command.

This method send the order to the polling thread to poll one object registered with an update period defined as "externally triggerred"

Parameters:
dev The TANGO device
name The command name which must be polled
Exceptions:
DevFailed If the call failed Click here to read DevFailed exception specification

void Tango::Util::unregister_server (  ) 

Unregister a device server process from the TANGO database.

If the database call fails, a message is displayed on the screen and the process is aborted


Member Data Documentation

TANGO_IMP bool Tango::Util::_daemon [static]

A daemon process flag.

If this flag is set to true, the server process will not exit if it not able to connect to the database. Instead, it will loop until the connection suceeds. The default value is false.

TANGO_IMP long Tango::Util::_sleep_between_connect [static]

The loop sleeping time in case of the _daemon flag set to true.

This sleeping time is the number of seconds the process will sleep before it tries again to connect to the database. The default value is 60 seconds.

TANGO_IMP bool Tango::Util::_UseDb [static]

The database use flag (Use with extreme care).

Implemented for device server started without database usage.


The documentation for this class was generated from the following file:
Tango Device Server User's Guide



ALBA - Control Team / DESY - Hasylab Petra III

ELETTRA - Controls and Diagnostics / ESRF - Software Engineering Group

SOLEIL - Controle Commande et Acquisition / MAX-lab - MAX 4

FRM2 - Control group