Tango Core Classes Reference  9.3.3
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 "tango.h"

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. More...
 
PortableServer::POA_ptr get_poa ()
 Get a reference to the CORBA Portable Object Adapter (POA) More...
 
void set_trace_level (int level)
 Set the process trace level. More...
 
int get_trace_level ()
 Get the process trace level. More...
 
string & get_ds_inst_name ()
 Get the device server instance name. More...
 
string & get_ds_exec_name ()
 Get the device server executable name. More...
 
string & get_ds_name ()
 Get the device server name. More...
 
string & get_host_name ()
 Get the host name where the device server process is running. More...
 
string & get_pid_str ()
 Get the device server process identifier as a String. More...
 
TangoSys_Pid get_pid ()
 Get the device server process identifier. More...
 
long get_tango_lib_release ()
 Get the TANGO library version number. More...
 
string & get_version_str ()
 Get the IDL TANGO version. More...
 
string & get_server_version ()
 Get the device server version. More...
 
void set_server_version (const char *vers)
 Set the device server version. More...
 
void set_class_list (vector< DeviceClass * > *list)
 Set the DeviceClass list pointer. More...
 
void add_class_to_list (DeviceClass *cl)
 Add a DeviceClass to the DeviceClass list pointer. More...
 
const vector< DeviceClass * > * get_class_list ()
 Get the DeviceClass list pointer. More...
 
void set_serial_model (SerialModel ser)
 Set the serialization model. More...
 
SerialModel get_serial_model ()
 Get the serialization model. More...
 
NotifdEventSupplier * get_notifd_event_supplier ()
 Get a reference to the notifd TANGO EventSupplier object. More...
 
ZmqEventSupplier * get_zmq_event_supplier ()
 Get a reference to the ZMQ TANGO EventSupplier object. More...
 
void set_ds_event_buffer_hwm (DevLong val)
 Set device server process event buffer high water mark (HWM) More...
 
Polling related methods
void trigger_cmd_polling (DeviceImpl *dev, const string &name)
 Trigger polling for polled command. More...
 
void trigger_attr_polling (DeviceImpl *dev, const string &name)
 Trigger polling for polled attribute. More...
 
template<typename T >
void fill_attr_polling_buffer (DeviceImpl *dev, string &att_name, AttrHistoryStack< T > &data)
 Fill polling buffer for polled attribute. More...
 
template<typename T >
void fill_cmd_polling_buffer (DeviceImpl *dev, string &cmd_name, CmdHistoryStack< T > &data)
 Fill polling buffer for polled command. More...
 
void set_polling_threads_pool_size (unsigned long thread_nb)
 Set the polling threads pool size. More...
 
unsigned long get_polling_threads_pool_size ()
 Get the polling threads pool size. More...
 
void set_polling_before_9 (bool val)
 Set the polling thread algorithm to the algorithum used before Tango 9. More...
 
Miscellaneous methods
bool is_svr_starting ()
 Check if the device server process is in its starting phase. More...
 
bool is_svr_shutting_down ()
 Check if the device server process is in its shutting down sequence. More...
 
bool is_device_restarting (string &d_name)
 Check if the device is actually restarted by the device server process admin device with its DevRestart command. More...
 
Database related methods
void connect_db ()
 Connect the process to the TANGO database. More...
 
void reset_filedatabase ()
 Reread the file database.
 
Databaseget_database ()
 Get a reference to the TANGO database object. More...
 
void unregister_server ()
 Unregister a device server process from the TANGO database. More...
 
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. More...
 
vector< DeviceImpl * > & get_device_list_by_class (const char *class_name)
 Get the list of device references for a given TANGO class. More...
 
DeviceImplget_device_by_name (const string &dev_name)
 Get a device reference from its name. More...
 
DeviceImplget_device_by_name (const char *dev_name)
 Get a device reference from its name. More...
 
DServer * get_dserver_device ()
 Get a reference to the dserver device attached to the device server process. More...
 
vector< DeviceImpl * > get_device_list (const string &name)
 Get DeviceList from name. More...
 
Device pattern related methods
void server_init (bool with_window=false)
 Initialise all the device server pattern(s) embedded in a device server process. More...
 
void server_run ()
 Run the CORBA event loop. More...
 
void server_cleanup ()
 Cleanup a Tango device server process before exit. More...
 
void server_set_event_loop (bool(*f_ptr)())
 Set the server event loop. More...
 

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. More...
 
static TANGO_IMP_EXP Utilinstance (bool exit=true)
 Get the singleton object reference. More...
 

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). More...
 
static TANGO_IMP bool _daemon
 A daemon process flag. More...
 
static TANGO_IMP long _sleep_between_connect
 The loop sleeping time in case of the _daemon flag set to true. More...
 

Protected Member Functions

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

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$ $Revision$

Constructor & Destructor Documentation

◆ Util()

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

Constructs a newly allocated Util object.

This constructor is protected following the singleton pattern

Parameters
argcThe process command line argument number
argvThe process commandline arguments

Member Function Documentation

◆ add_class_to_list()

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

Add a DeviceClass to the DeviceClass list pointer.

Parameters
clThe DeviceClass ptr

◆ connect_db()

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

◆ fill_attr_polling_buffer()

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

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
devThe TANGO device
att_nameThe attribute name which must be polled
dataThe data stack with one element for each history element
Exceptions
DevFailedIf the call failed Click here to read DevFailed exception specification

◆ fill_cmd_polling_buffer()

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

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
devThe TANGO device
cmd_nameThe command name which must be polled
dataThe data stack with one element for each history element
Exceptions
DevFailedIf the call failed Click here to read DevFailed exception specification

◆ get_class_list()

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

Get the DeviceClass list pointer.

Returns
The DeviceClass ptr vector address

◆ get_database()

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

Get a reference to the TANGO database object.

Returns
The database object

◆ get_device_by_name() [1/2]

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

Get a device reference from its name.

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

◆ get_device_by_name() [2/2]

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

Get a device reference from its name.

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

◆ get_device_list()

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
nameThe device name
Returns
The DeviceClass ptr vector address

◆ get_device_list_by_class() [1/2]

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_nameThe TANGO device class name
Returns
The device reference list
Exceptions
DevFailedIf 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

◆ get_device_list_by_class() [2/2]

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_nameThe TANGO device class name
Returns
The device reference list
Exceptions
DevFailedIf 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

◆ get_ds_exec_name()

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

Get the device server executable name.

Returns
The device server executable name

◆ get_ds_inst_name()

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

Get the device server instance name.

Returns
The device server instance name

◆ get_ds_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

◆ get_dserver_device()

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

◆ get_host_name()

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

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

Returns
The host name

◆ get_notifd_event_supplier()

NotifdEventSupplier* Tango::Util::get_notifd_event_supplier ( )
inline

Get a reference to the notifd TANGO EventSupplier object.

Returns
The notifd EventSupplier object

◆ get_orb()

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

◆ get_pid()

TangoSys_Pid Tango::Util::get_pid ( )
inline

Get the device server process identifier.

Returns
The device server process identifier

◆ get_pid_str()

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

◆ get_poa()

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

◆ get_polling_threads_pool_size()

unsigned 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

◆ get_serial_model()

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

◆ get_server_version()

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

Get the device server version.

Returns
The device server version

◆ get_tango_lib_release()

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,....)

◆ get_trace_level()

int Tango::Util::get_trace_level ( )
inline

Get the process trace level.

Returns
The process trace level

References _tracelevel.

◆ get_version_str()

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

Get the IDL TANGO version.

Returns
The device server version

◆ get_zmq_event_supplier()

ZmqEventSupplier* Tango::Util::get_zmq_event_supplier ( )
inline

Get a reference to the ZMQ TANGO EventSupplier object.

Returns
The zmq EventSupplier object

◆ init()

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
argcThe process command line argument number
argvThe process commandline arguments
Returns
The Util object reference

◆ instance()

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

◆ is_device_restarting()

bool Tango::Util::is_device_restarting ( string &  d_name)
inline

Check if the device is actually restarted by the device server process admin device with its DevRestart command.

Returns
A boolean set to true if the device is restarting.

◆ is_svr_shutting_down()

bool Tango::Util::is_svr_shutting_down ( )
inline

Check if the device server process is in its shutting down sequence.

Returns
A boolean set to true if the server is in its shutting down phase.

◆ is_svr_starting()

bool Tango::Util::is_svr_starting ( )
inline

Check if the device server process is in its starting phase.

Returns
A boolean set to true if the server is in its starting phase.

◆ server_cleanup()

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

◆ server_init()

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

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

Exceptions
DevFailedIf the device pattern initialisation failed Click here to read DevFailed exception specification

◆ server_run()

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.

◆ server_set_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_ptrThe 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.

◆ set_class_list()

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

Set the DeviceClass list pointer.

Parameters
listThe DeviceClass ptr vector address

◆ set_ds_event_buffer_hwm()

void Tango::Util::set_ds_event_buffer_hwm ( DevLong  val)
inline

Set device server process event buffer high water mark (HWM)

Parameters
valThe new event buffer high water mark in number of events

◆ set_polling_before_9()

void Tango::Util::set_polling_before_9 ( bool  val)
inline

Set the polling thread algorithm to the algorithum used before Tango 9.

Parameters
valPolling algorithm flag

◆ set_polling_threads_pool_size()

void Tango::Util::set_polling_threads_pool_size ( unsigned long  thread_nb)
inline

Set the polling threads pool size.

Parameters
thread_nbThe maximun number of threads in the polling threads pool

◆ set_serial_model()

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

Set the serialization model.

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

◆ set_server_version()

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

Set the device server version.

Parameters
versThe device server version

◆ set_trace_level()

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

Set the process trace level.

Parameters
levelThe new process level

References _tracelevel.

◆ trigger_attr_polling()

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
devThe TANGO device
nameThe attribute name which must be polled
Exceptions
DevFailedIf the call failed Click here to read DevFailed exception specification

◆ trigger_cmd_polling()

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
devThe TANGO device
nameThe command name which must be polled
Exceptions
DevFailedIf the call failed Click here to read DevFailed exception specification

◆ unregister_server()

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

◆ _daemon

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.

◆ _sleep_between_connect

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.

◆ _UseDb

TANGO_IMP bool Tango::Util::_UseDb
static

The database use flag (Use with extreme care).

Implemented for device server started without database usage.

Referenced by Tango::DeviceImpl::get_db_device().


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