TANGO Java API
( TangORB-7.3.3.jar)

fr.esrf.TangoDs
Class Util

java.lang.Object
  extended by fr.esrf.TangoDs.Util
All Implemented Interfaces:
TangoConst

public class Util
extends java.lang.Object
implements TangoConst

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.

Version:
$Revision: 1.9 $
Author:
$Author: abeilleg $

Field Summary
static boolean _daemon
           
static int _sleep_between_connect
           
static boolean _UseDb
           
static UtilPrint out1
          The UtilPrint object used for level 1 printing
static UtilPrint out2
          The UtilPrint object used for level 2 printing
static UtilPrint out3
          The UtilPrint object used for level 3 printing
static UtilPrint out4
          The UtilPrint object used for level 4 printing
static UtilPrint out5
          The UtilPrint object used for level 5 printing
 
Fields inherited from interface fr.esrf.TangoDs.TangoConst
ACCESS_READ, ACCESS_SERVICE, ACCESS_WRITE, ARCHIVE_EVENT, ATT_CONF_EVENT, Attr_AdmName, Attr_Description, Attr_Name, Attr_State, Attr_Status, Attr_Unknown, ATTRIBUTE, BY_CLASS, BY_DEVICE, BY_PROCESS, CHANGE_EVENT, COMMAND, CONTROL_SYSTEM, DATA_READY_EVENT, DEFAULT_LOCK_VALIDITY, eventNames, LOGGING_CONSOLE_TARGET, LOGGING_CONSOLE_TARGET_ID, LOGGING_DEBUG, LOGGING_DEF_RFT, LOGGING_DEVICE_TARGET, LOGGING_DEVICE_TARGET_ID, LOGGING_ERROR, LOGGING_FATAL, LOGGING_FILE_TARGET, LOGGING_FILE_TARGET_ID, LOGGING_INFO, LOGGING_LEVELS, LOGGING_MAX_RFT, LOGGING_MIN_RFT, LOGGING_OFF, LOGGING_SEPARATOR, LOGGING_UNKNOWN_TARGET_ID, LOGGING_WARN, NO_SYNC, NOT_STATELESS, NotANumber, Op_BlackBox, Op_Command, Op_Command_2, Op_Command_inout, Op_Command_inout_2, Op_Command_inout_history_2, Op_Command_list, Op_Command_list_2, Op_Get_Attr_Config, Op_Get_Attr_Config_2, Op_Info, Op_Ping, Op_Read_Attr, Op_Read_Attr_2, Op_Read_Attr_history_2, Op_Set_Attr_Config, Op_Unknown, Op_Write_Attr, PERIODIC_EVENT, QUALITY_EVENT, Req_Attribute, Req_Operation, Req_Unknown, SERVICE_PROP_NAME, STATELESS, Tango_AllAttr, Tango_AllAttr_3, Tango_AlrmValueNotSpec, Tango_AssocWritNotSpec, Tango_AttrDataFormatName, Tango_CLNT_TIMEOUT, Tango_CmdArgTypeName, Tango_CONST_DEV_STRING, Tango_DbObjName, Tango_DEFAULT_POLL_OLD_FACTOR, Tango_DEFAULT_TIMEOUT, Tango_DEFAULT_TIMEOUT_SEC, Tango_DefaultBlackBoxDepth, Tango_DefaultDocUrl, Tango_DefaultPollRingDepth, Tango_DefaultWritableProp, Tango_DELTA_T, Tango_DescNotSet, Tango_DescNotSpec, Tango_DEV_BOOLEAN, Tango_DEV_CHAR, Tango_DEV_DOUBLE, Tango_DEV_ENCODED, Tango_DEV_FLOAT, Tango_DEV_INT, Tango_DEV_LONG, Tango_DEV_LONG64, Tango_DEV_SHORT, Tango_DEV_STATE, Tango_DEV_STRING, Tango_DEV_UCHAR, Tango_DEV_ULONG, Tango_DEV_ULONG64, Tango_DEV_USHORT, Tango_DEV_VOID, Tango_DevStateName, Tango_DEVVAR_CHARARRAY, Tango_DEVVAR_DOUBLEARRAY, Tango_DEVVAR_DOUBLESTRINGARRAY, Tango_DEVVAR_FLOATARRAY, Tango_DEVVAR_LONG64ARRAY, Tango_DEVVAR_LONGARRAY, Tango_DEVVAR_LONGSTRINGARRAY, Tango_DEVVAR_SHORTARRAY, Tango_DEVVAR_STRINGARRAY, Tango_DEVVAR_ULONG64ARRAY, Tango_DEVVAR_ULONGARRAY, Tango_DEVVAR_USHORTARRAY, Tango_DevVersion, Tango_DISCARD_THRESHOLD, Tango_DispUnitNotSpec, Tango_DSDeviceDomain, Tango_EXPERT_ATTR, Tango_EXPERT_CMD, Tango_FormatNotSpec, Tango_InitialOutput, Tango_LabelNotSpec, TANGO_LOG_PATH, Tango_MAX_TRANSFER_SIZE, Tango_MaxServerNameLength, Tango_MIN_POLL_PERIOD, Tango_OPERATOR_ATTR, Tango_OPERATOR_CMD, Tango_POLL_ADD_OBJ, Tango_POLL_ATTR, Tango_POLL_CMD, Tango_POLL_REM_DEV, Tango_POLL_REM_OBJ, Tango_POLL_START, Tango_POLL_STOP, Tango_POLL_UPD_PERIOD, Tango_PollAttribute, Tango_PollCommand, Tango_QualityName, Tango_REL_1, Tango_REL_2, Tango_ResNotDefined, Tango_StdUnitNotSpec, Tango_SysProperty, Tango_TG_IMP_MINOR_DEVFAILED, Tango_TG_IMP_MINOR_NON_DEVFAILED, Tango_TG_IMP_MINOR_TO, Tango_TgLibVers, Tango_UnitNotSpec, USER_EVENT
 
Method Summary
 void add_class(java.lang.String name)
          Add a new class in this device server (For no database device server)
 void connect_db()
          Connect the process to the TANGO database.
static double fabs(double d)
          idem fabs in c libraray.
 void fill_attr_polling_buffer(DeviceImpl dev, java.lang.String att_name, TimedAttrData[] data)
          This method fills the polling buffer for one polled attribute registered with an update period defined as "externally triggerred" (polling period set to 0)
 java.util.Vector get_class_name_list()
          Get the class name list (For no database device server)
 Database get_database()
          Get the TANGO database object reference
 DeviceImpl get_device_by_name(java.lang.String dev_name)
          Get a device reference from its name
 java.util.Vector get_device_list_by_class(java.lang.String class_name)
          Get the list of device references for a given TANGO class.
 java.util.Vector get_device_list(java.lang.String pattern)
          Get the list of device references which name name match the specified pattern Returns a null vector in case there is no device matching the pattern
 java.lang.String get_ds_exec_name()
          Get the device server executable name.
 java.lang.String get_ds_inst_name()
          Get the device server instance name.
 java.lang.String get_ds_name()
          Get the device server name.
 java.lang.String get_ds_real_name()
          Get the real (not only lowercase) server name.
 DServer get_dserver_device()
          Get a reference to the dserver device attached to the device server process
 java.lang.String get_host_name()
          Get the host name where the device server process is running.
 org.omg.CORBA.ORB get_orb()
          Get a reference to the CORBA ORB
 java.lang.String get_pid_str()
          Get the device server process identifier as a String Return 0 as process identifer.
 org.omg.PortableServer.POA get_poa()
          Get a reference to the CORBA Portable Object Adapter (POA).
static int get_serial_model()
          Get the serial model (TangoConst.BY_DEVICE, TangoConst.BY_Class or TangoConst.NO_SYNC)
 int get_trace_level()
          Get the process trace level.
 java.lang.String get_version_str()
          Get the device server TANGO version.
static Util init(java.lang.String[] argv, java.lang.String exec_name)
          Create and get the singleton object reference.
static Util instance()
          Get the singleton object reference.
static org.omg.CORBA.Any return_empty_any(java.lang.String cmd)
          Create and return an empty CORBA Any object.
 void server_init()
          Initialise all the device server pattern(s) embedded in a device server process.
 void server_run()
          Ask a device server to listen for incoming request.
 void set_class_list(java.util.Vector list)
          Set the DeviceClass list vector
static void set_serial_model(int model)
          Set the serial model.
 void set_trace_level(int level)
          Set the process trace level.
 void unregister_server()
          Unregister a device server process from the TANGO database.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

out1

public static UtilPrint out1
The UtilPrint object used for level 1 printing


out2

public static UtilPrint out2
The UtilPrint object used for level 2 printing


out3

public static UtilPrint out3
The UtilPrint object used for level 3 printing


out4

public static UtilPrint out4
The UtilPrint object used for level 4 printing


out5

public static UtilPrint out5
The UtilPrint object used for level 5 printing


_UseDb

public static boolean _UseDb

_daemon

public static boolean _daemon

_sleep_between_connect

public static int _sleep_between_connect
Method Detail

instance

public static Util instance()
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

init

public static Util init(java.lang.String[] argv,
                        java.lang.String exec_name)
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:
argv - The process argument String array
exec_name - The device server executable name
Returns:
The Util object reference

connect_db

public void 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


server_init

public void server_init()
                 throws DevFailed
Initialise all the device server pattern(s) embedded in a device server process.

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

server_run

public void server_run()
Ask a device server to listen for incoming request. This method does not return.


get_device_list

public java.util.Vector get_device_list(java.lang.String pattern)
Get the list of device references which name name match the specified pattern Returns a null vector in case there is no device matching the pattern

Parameters:
pattern - The device name pattern

get_device_list_by_class

public java.util.Vector get_device_list_by_class(java.lang.String class_name)
                                          throws DevFailed
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
Throws:
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

get_device_by_name

public DeviceImpl get_device_by_name(java.lang.String dev_name)
                              throws DevFailed
Get a device reference from its name

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

get_dserver_device

public DServer get_dserver_device()
Get a reference to the dserver device attached to the device server process

Returns:
A reference to the dserver device

unregister_server

public void 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


return_empty_any

public static org.omg.CORBA.Any return_empty_any(java.lang.String cmd)
                                          throws DevFailed
Create and return an empty CORBA Any object. Create an empty CORBA Any object. Could be used by command which does not return anything to the client. This method also prints a message on screen (level 4) before it returns

Parameters:
cmd - The cmd name which use this empty Any. Only used to create the thrown exception (in case of) and in the displayed message
Returns:
The empty CORBA Any
Throws:
DevFailed - If the Any object creation failed. Click here to read DevFailed exception specification

set_trace_level

public void set_trace_level(int level)
Set the process trace level.

Parameters:
level - The new process level

get_trace_level

public int get_trace_level()
Get the process trace level.

Returns:
The process trace level

get_ds_inst_name

public java.lang.String get_ds_inst_name()
Get the device server instance name.

Returns:
The device server instance name

get_ds_exec_name

public java.lang.String get_ds_exec_name()
Get the device server executable name.

Returns:
The device server executable name

get_ds_name

public java.lang.String get_ds_name()
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_ds_real_name

public java.lang.String get_ds_real_name()
Get the real (not only lowercase) server name. The device server name is the device server executable name/the device server instance name

Returns:
The real server name

get_host_name

public java.lang.String get_host_name()
Get the host name where the device server process is running.

Returns:
The host name

get_version_str

public java.lang.String get_version_str()
Get the device server TANGO version.

Returns:
The device server version

get_database

public Database get_database()
Get the TANGO database object reference

Returns:
The database reference

get_orb

public org.omg.CORBA.ORB get_orb()
Get a reference to the CORBA ORB

Returns:
The CORBA ORB

get_poa

public org.omg.PortableServer.POA get_poa()
Get a reference to the CORBA Portable Object Adapter (POA). For classical device server, this is the root POA. For no database device server, this is a specific POA with the USER_ID policy.

Returns:
The CORBA POA

get_pid_str

public java.lang.String get_pid_str()
Get the device server process identifier as a String Return 0 as process identifer. Is ther any way to know process identifier in a PURE java class ?


set_class_list

public void set_class_list(java.util.Vector list)
Set the DeviceClass list vector

Parameters:
list - The DeviceClass vector reference

add_class

public void add_class(java.lang.String name)
Add a new class in this device server (For no database device server)

Parameters:
name - The class name

get_class_name_list

public java.util.Vector get_class_name_list()
Get the class name list (For no database device server)

Returns:
A string vector. Each element is a class name

fabs

public static double fabs(double d)
idem fabs in c libraray.


fill_attr_polling_buffer

public void fill_attr_polling_buffer(DeviceImpl dev,
                                     java.lang.String att_name,
                                     TimedAttrData[] data)
                              throws DevFailed
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
Throws:
DevFailed - If the call failed

set_serial_model

public static void set_serial_model(int model)
Set the serial model. The default is TangoConst.BY_DEVICE

Parameters:
model - the specified model (TangoConst.BY_DEVICE, TangoConst.BY_Class or TangoConst.NO_SYNC)

get_serial_model

public static int get_serial_model()
Get the serial model (TangoConst.BY_DEVICE, TangoConst.BY_Class or TangoConst.NO_SYNC)


TANGO Java API
( TangORB-7.3.3.jar)