idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
19,800
public String updateStatus ( final DeviceState state ) throws DevFailed { xlogger . entry ( ) ; if ( getStatusMethod != null ) { try { status = ( String ) getStatusMethod . invoke ( businessObject ) ; } catch ( final IllegalArgumentException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } catch ( final IllegalAccessException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } catch ( final InvocationTargetException e ) { if ( e . getCause ( ) instanceof DevFailed ) { throw ( DevFailed ) e . getCause ( ) ; } else { throw DevFailedUtils . newDevFailed ( "INVOCATION_ERROR" , ExceptionUtils . getStackTrace ( e . getCause ( ) ) + " InvocationTargetException" ) ; } } } else { if ( status . isEmpty ( ) ) { status = "The device is in " + state + " state." ; } } StringBuilder statusAlarm = new StringBuilder ( ) ; for ( final String string : attributeAlarm . values ( ) ) { statusAlarm = statusAlarm . append ( string ) ; } return status + statusAlarm ; }
Get the status of the device
269
6
19,801
public synchronized void statusMachine ( final String status , final DeviceState state ) throws DevFailed { if ( status != null ) { logger . debug ( "Changing status to: {}" , status ) ; this . status = status ; if ( setStatusMethod != null ) { try { setStatusMethod . invoke ( businessObject , status ) ; } catch ( final IllegalArgumentException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } catch ( final IllegalAccessException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } catch ( final InvocationTargetException e ) { if ( e . getCause ( ) instanceof DevFailed ) { throw ( DevFailed ) e . getCause ( ) ; } else { throw DevFailedUtils . newDevFailed ( e . getCause ( ) ) ; } } } } }
Change status of the device
189
5
19,802
public void addClass ( final String tangoClass , final Class < ? > deviceClass ) { lastClass = tangoClass ; tangoClasses . put ( tangoClass , deviceClass ) ; }
Add a class to the server .
43
7
19,803
public void stop ( ) throws DevFailed { try { if ( isStarted . get ( ) ) { tangoClasses . clear ( ) ; if ( tangoExporter != null ) { tangoExporter . clearClass ( ) ; tangoExporter . unexportAll ( ) ; } TangoCacheManager . shutdown ( ) ; EventManager . getInstance ( ) . close ( ) ; if ( monitoring != null ) { monitoring . stop ( ) ; } } } finally { ORBManager . shutdown ( ) ; logger . info ( "everything has been shutdown normally" ) ; isStarted . set ( false ) ; } }
Stop the server and clear all
135
6
19,804
private void checkArgs ( final String [ ] argv ) throws DevFailed { if ( argv . length < 1 ) { throw DevFailedUtils . newDevFailed ( INIT_ERROR , getUsage ( ) ) ; } instanceName = argv [ 0 ] ; useDb = true ; DatabaseFactory . setUseDb ( true ) ; List < String > noDbDevices = new ArrayList < String > ( ) ; for ( int i = 1 ; i < argv . length ; i ++ ) { final String arg = argv [ i ] ; if ( arg . startsWith ( "-h" ) ) { // trace instance name System . out . println ( "instance list for server " + execName + ": " + Arrays . toString ( DatabaseFactory . getDatabase ( ) . getInstanceNameList ( execName ) ) ) ; } else if ( arg . startsWith ( "-v" ) ) { // logging level try { final int level = Integer . parseInt ( arg . substring ( arg . lastIndexOf ( ' ' ) + 1 ) ) ; LoggingManager . getInstance ( ) . setLoggingLevel ( level , tangoClasses . values ( ) . toArray ( new Class < ? > [ 0 ] ) ) ; } catch ( final NumberFormatException e ) { throw DevFailedUtils . newDevFailed ( "Logging level error. Must be a number" ) ; } } else if ( arg . startsWith ( "-dlist" ) ) { noDbDevices = configureNoDB ( argv , i ) ; useDb = false ; } else if ( arg . startsWith ( "-file" ) ) { configureNoDBFile ( argv , arg , noDbDevices ) ; useDb = false ; } } }
Check the command line arguments . The first one is mandatory and is the server name . A - v option is authorized with an optional argument .
381
28
19,805
public < T > List < T > executeExtractList ( final Class < T > clazz , final Object value ) throws DevFailed { final Object r = command . executeExtract ( value ) ; return extractList ( TypeConversionUtil . castToType ( clazz , r ) ) ; }
Execute a command with argin which is a single value
65
12
19,806
public < T > List < T > executeExtractList ( final Class < T > clazz , final Object ... value ) throws DevFailed { final Object result = command . executeExtract ( value ) ; return extractList ( TypeConversionUtil . castToArray ( clazz , result ) ) ; }
Execute a command with argin which is an array
66
11
19,807
public void setType ( final Class < ? > type ) throws DevFailed { if ( Enum . class . isAssignableFrom ( type ) ) { this . type = AttributeTangoType . getTypeFromClass ( type ) . getType ( ) ; } else { this . type = type ; } enumType = AttributeTangoType . getTypeFromClass ( type ) ; tangoType = enumType . getTangoIDLType ( ) ; if ( type . isArray ( ) ) { if ( type . getComponentType ( ) . isArray ( ) ) { format = AttrDataFormat . IMAGE ; } else { format = AttrDataFormat . SPECTRUM ; maxY = 0 ; } } else { format = AttrDataFormat . SCALAR ; maxX = 1 ; maxY = 0 ; } }
Set the attribute type with Java class . Can be scalar array or matrix
182
15
19,808
public void setTangoType ( final int tangoType , final AttrDataFormat format ) throws DevFailed { setFormat ( format ) ; this . tangoType = tangoType ; enumType = AttributeTangoType . getTypeFromTango ( tangoType ) ; if ( format . equals ( AttrDataFormat . SCALAR ) ) { type = enumType . getType ( ) ; } else if ( format . equals ( AttrDataFormat . SPECTRUM ) ) { type = Array . newInstance ( enumType . getType ( ) , 0 ) . getClass ( ) ; } else { type = Array . newInstance ( enumType . getType ( ) , 0 , 0 ) . getClass ( ) ; } }
Set the attribute type with Tango type .
160
9
19,809
public synchronized void addAttribute ( final AttributeImpl attribute ) throws DevFailed { // add attribute only if it doesn't exists AttributeImpl result = null ; for ( final AttributeImpl attr : attributeList ) { if ( attr . getName ( ) . equalsIgnoreCase ( attribute . getName ( ) ) ) { result = attribute ; break ; } } if ( result == null ) { attributeList . add ( attribute ) ; // set default polling configuration if ( attrPollRingDepth . containsKey ( attribute . getName ( ) . toLowerCase ( Locale . ENGLISH ) ) ) { attribute . setPollRingDepth ( attrPollRingDepth . get ( attribute . getName ( ) . toLowerCase ( Locale . ENGLISH ) ) ) ; } else { attribute . setPollRingDepth ( pollRingDepth ) ; } } }
Add an attribute to the device
184
6
19,810
public synchronized void removeAttribute ( final AttributeImpl attribute ) throws DevFailed { if ( attribute . getName ( ) . equalsIgnoreCase ( STATUS_NAME ) || attribute . getName ( ) . equalsIgnoreCase ( STATE_NAME ) ) { return ; } pollingManager . removeAttributePolling ( attribute . getName ( ) ) ; statusImpl . removeAttributeAlarm ( attribute . getName ( ) ) ; stateImpl . removeAttributeAlarm ( attribute . getName ( ) ) ; attributeList . remove ( attribute ) ; }
remove an attribute of the device . Not possible to remove State or Status
115
14
19,811
private synchronized void checkInitialization ( ) throws DevFailed { if ( initImpl != null ) { isInitializing = initImpl . isInitInProgress ( ) ; } else { isInitializing = false ; } if ( isInitializing ) { throw DevFailedUtils . newDevFailed ( "CONCURRENT_ERROR" , name + " in Init command " ) ; } }
Check if an init is in progress
83
7
19,812
@ Override public DevInfo info ( ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; deviceMonitoring . startRequest ( "Operation info" ) ; final DevInfo info = new DevInfo ( ) ; info . dev_class = className ; info . doc_url = "Doc URL = http://www.tango-controls.org" ; info . server_host = ServerManager . getInstance ( ) . getHostName ( ) ; info . server_id = ServerManager . getInstance ( ) . getServerName ( ) ; info . server_version = SERVER_VERSION ; xlogger . exit ( ) ; return info ; }
Get info of this device in IDL1
152
9
19,813
@ Override public DevInfo_3 info_3 ( ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; deviceMonitoring . startRequest ( "Operation info_3" ) ; final DevInfo_3 info3 = new DevInfo_3 ( ) ; final DevInfo info = info ( ) ; info3 . dev_class = info . dev_class ; info3 . doc_url = info . doc_url ; info3 . server_host = info . server_host ; info3 . server_id = info . server_id ; info3 . server_version = info . server_version ; info3 . dev_type = deviceType ; xlogger . exit ( ) ; return info3 ; }
Get info of this device in IDL3
165
9
19,814
@ Override public void ping ( ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; deviceMonitoring . startRequest ( "Operation ping" ) ; xlogger . exit ( ) ; }
Dummy method to check if this device is responding
54
10
19,815
@ Override public String [ ] black_box ( final int maxSize ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; // deviceMonitoring.addRequest("black_box"); if ( maxSize <= 0 ) { throw DevFailedUtils . newDevFailed ( ExceptionMessages . BLACK_BOX_ARG , maxSize + " is not a good size" ) ; } xlogger . exit ( ) ; return deviceMonitoring . getBlackBox ( maxSize ) ; }
Get the clients requests history
118
5
19,816
@ Override public String description ( ) { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; deviceMonitoring . startRequest ( "Attribute description requested " ) ; String desc = "A TANGO device" ; if ( name . equalsIgnoreCase ( ServerManager . getInstance ( ) . getAdminDeviceName ( ) ) ) { desc = "A device server device !!" ; } return desc ; }
Get a description of this device
94
6
19,817
@ Override public String name ( ) { MDC . setContextMap ( contextMap ) ; deviceMonitoring . startRequest ( "Device name" ) ; xlogger . entry ( ) ; return name ; }
Get the name of the device
45
6
19,818
@ Override public DevAttrHistory [ ] read_attribute_history_2 ( final String attributeName , final int maxSize ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; checkInitialization ( ) ; deviceMonitoring . startRequest ( "read_attribute_history_2" ) ; // TODO read_attribute_history_2 return new DevAttrHistory [ 0 ] ; }
read an attribute history . IDL 2 version . The history is filled only be attribute polling
97
18
19,819
@ Override public DevAttrHistory_3 [ ] read_attribute_history_3 ( final String attributeName , final int maxSize ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; // TODO read_attribute_history_3 checkInitialization ( ) ; deviceMonitoring . startRequest ( "read_attribute_history_3" ) ; return new DevAttrHistory_3 [ 0 ] ; }
read an attribute history . IDL 3 version . The history is filled only be attribute polling
101
18
19,820
@ Override public DevAttrHistory_4 read_attribute_history_4 ( final String attributeName , final int maxSize ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; checkInitialization ( ) ; deviceMonitoring . startRequest ( "read_attribute_history_4" ) ; DevAttrHistory_4 result = null ; try { final AttributeImpl attr = AttributeGetterSetter . getAttribute ( attributeName , attributeList ) ; if ( ! attr . isPolled ( ) ) { throw DevFailedUtils . newDevFailed ( ExceptionMessages . ATTR_NOT_POLLED , attr . getName ( ) + " is not polled" ) ; } result = attr . getHistory ( ) . getAttrHistory4 ( maxSize ) ; } catch ( final Exception e ) { deviceMonitoring . addError ( ) ; if ( e instanceof DevFailed ) { throw ( DevFailed ) e ; } else { // with CORBA, the stack trace is not visible by the client if // not inserted in DevFailed. throw DevFailedUtils . newDevFailed ( e ) ; } } return result ; }
read an attribute history . IDL 4 version . The history is filled only be attribute polling
268
18
19,821
@ Override public AttributeValue [ ] read_attributes ( final String [ ] attributeNames ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; if ( attributeNames . length != 1 || ! attributeNames [ 0 ] . equalsIgnoreCase ( DeviceImpl . STATE_NAME ) && ! attributeNames [ 0 ] . equalsIgnoreCase ( DeviceImpl . STATUS_NAME ) ) { checkInitialization ( ) ; } deviceMonitoring . startRequest ( "read_attributes" ) ; clientIdentity . set ( null ) ; if ( attributeNames . length == 0 ) { throw DevFailedUtils . newDevFailed ( READ_ERROR , READ_ASKED_FOR_0_ATTRIBUTES ) ; } AttributeValue [ ] result = null ; try { result = AttributeGetterSetter . getAttributesValues ( name , attributeNames , pollingManager , attributeList , aroundInvokeImpl , DevSource . CACHE_DEV , deviceLock , null ) ; } catch ( final Exception e ) { deviceMonitoring . addError ( ) ; if ( e instanceof DevFailed ) { throw ( DevFailed ) e ; } else { // with CORBA, the stack trace is not visible by the client if // not inserted in DevFailed. throw DevFailedUtils . newDevFailed ( e ) ; } } return result ; }
Read some attributes . IDL 1 version .
308
9
19,822
@ Override public AttributeValue_4 [ ] read_attributes_4 ( final String [ ] names , final DevSource source , final ClntIdent clIdent ) throws DevFailed { // final Profiler profilerPeriod = new Profiler("period"); // profilerPeriod.start(Arrays.toString(names)); MDC . setContextMap ( contextMap ) ; xlogger . entry ( Arrays . toString ( names ) ) ; if ( names . length != 1 || ! names [ 0 ] . equalsIgnoreCase ( DeviceImpl . STATE_NAME ) && ! names [ 0 ] . equalsIgnoreCase ( DeviceImpl . STATUS_NAME ) ) { checkInitialization ( ) ; } deviceMonitoring . startRequest ( "read_attributes_4 " + Arrays . toString ( names ) , source , clIdent ) ; clientIdentity . set ( clIdent ) ; if ( names . length == 0 ) { throw DevFailedUtils . newDevFailed ( READ_ERROR , READ_ASKED_FOR_0_ATTRIBUTES ) ; } if ( ! name . equalsIgnoreCase ( getAdminDeviceName ( ) ) ) { clientLocking . checkClientLocking ( clIdent , names ) ; } AttributeValue_4 [ ] result = null ; try { result = AttributeGetterSetter . getAttributesValues4 ( name , names , pollingManager , attributeList , aroundInvokeImpl , source , deviceLock , clIdent ) ; } catch ( final Exception e ) { deviceMonitoring . addError ( ) ; if ( e instanceof DevFailed ) { throw ( DevFailed ) e ; } else { // with CORBA, the stack trace is not visible by the client if // not inserted in DevFailed. throw DevFailedUtils . newDevFailed ( e ) ; } } xlogger . exit ( ) ; // profilerPeriod.stop().print(); return result ; }
Read some attributes . IDL 4 version .
424
9
19,823
@ Override public void write_attributes ( final AttributeValue [ ] values ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; checkInitialization ( ) ; deviceMonitoring . startRequest ( "write_attributes" ) ; clientIdentity . set ( null ) ; final String [ ] names = new String [ values . length ] ; for ( int i = 0 ; i < names . length ; i ++ ) { names [ i ] = values [ i ] . name ; logger . debug ( "writing {}" , names [ i ] ) ; } final Object lock = deviceLock . getAttributeLock ( ) ; try { synchronized ( lock != null ? lock : new Object ( ) ) { AttributeGetterSetter . setAttributeValue ( values , attributeList , stateImpl , aroundInvokeImpl , null ) ; } } catch ( final Exception e ) { deviceMonitoring . addError ( ) ; if ( e instanceof DevFailed ) { throw ( DevFailed ) e ; } else { // with CORBA, the stack trace is not visible by the client if // not inserted in DevFailed. throw DevFailedUtils . newDevFailed ( e ) ; } } xlogger . exit ( ) ; }
Write some attributes . IDL 1 version
275
8
19,824
@ Override public void write_attributes_4 ( final AttributeValue_4 [ ] values , final ClntIdent clIdent ) throws MultiDevFailed , DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; checkInitialization ( ) ; final String [ ] names = new String [ values . length ] ; for ( int i = 0 ; i < names . length ; i ++ ) { names [ i ] = values [ i ] . name ; } logger . debug ( "writing {}" , Arrays . toString ( names ) ) ; deviceMonitoring . startRequest ( "write_attributes_4 " + Arrays . toString ( names ) , clIdent ) ; clientIdentity . set ( clIdent ) ; if ( ! name . equalsIgnoreCase ( getAdminDeviceName ( ) ) ) { clientLocking . checkClientLocking ( clIdent , names ) ; } final Object lock = deviceLock . getAttributeLock ( ) ; try { synchronized ( lock != null ? lock : new Object ( ) ) { AttributeGetterSetter . setAttributeValue4 ( values , attributeList , stateImpl , aroundInvokeImpl , clIdent ) ; } } catch ( final Exception e ) { deviceMonitoring . addError ( ) ; if ( e instanceof MultiDevFailed ) { throw ( MultiDevFailed ) e ; } else { // with CORBA, the stack trace is not visible by the client if // not inserted in DevFailed. throw DevFailedUtils . newDevFailed ( e ) ; } } xlogger . exit ( ) ; }
Write some attributes . IDL 4 version
349
8
19,825
@ Override public DevCmdInfo [ ] command_list_query ( ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; // checkInitialization(); deviceMonitoring . startRequest ( "command_list_query" ) ; // Retrieve number of command and allocate memory to send back info final List < CommandImpl > cmdList = getCommandList ( ) ; Collections . sort ( cmdList ) ; final DevCmdInfo [ ] back = new DevCmdInfo [ commandList . size ( ) ] ; int i = 0 ; for ( final CommandImpl cmd : cmdList ) { final DevCmdInfo tmp = new DevCmdInfo ( ) ; tmp . cmd_name = cmd . getName ( ) ; tmp . cmd_tag = cmd . getTag ( ) ; tmp . in_type = cmd . getInType ( ) . getTangoIDLType ( ) ; tmp . out_type = cmd . getOutType ( ) . getTangoIDLType ( ) ; tmp . in_type_desc = cmd . getInTypeDesc ( ) ; tmp . out_type_desc = cmd . getOutTypeDesc ( ) ; back [ i ++ ] = tmp ; } xlogger . exit ( ) ; return back ; }
Query all commands details . IDL 1 version
274
9
19,826
@ Override public DevCmdInfo command_query ( final String commandName ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; // checkInitialization(); deviceMonitoring . startRequest ( "command_query " + commandName ) ; final CommandImpl foundCmd = getCommand ( commandName ) ; final DevCmdInfo tmp = new DevCmdInfo ( ) ; tmp . cmd_name = foundCmd . getName ( ) ; tmp . cmd_tag = foundCmd . getTag ( ) ; tmp . in_type = foundCmd . getInType ( ) . getTangoIDLType ( ) ; tmp . out_type = foundCmd . getOutType ( ) . getTangoIDLType ( ) ; tmp . in_type_desc = foundCmd . getInTypeDesc ( ) ; tmp . out_type_desc = foundCmd . getOutTypeDesc ( ) ; return tmp ; }
Query a command details . IDL 1 version .
204
10
19,827
@ Override public Any command_inout ( final String command , final Any argin ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; if ( ! command . equalsIgnoreCase ( DeviceImpl . STATE_NAME ) && ! command . equalsIgnoreCase ( DeviceImpl . STATUS_NAME ) ) { checkInitialization ( ) ; } final long request = deviceMonitoring . startRequest ( "command_inout " + command ) ; clientIdentity . set ( null ) ; Any argout = null ; try { argout = commandHandler ( command , argin , DevSource . CACHE_DEV , null ) ; } catch ( final Exception e ) { deviceMonitoring . addError ( ) ; if ( e instanceof DevFailed ) { throw ( DevFailed ) e ; } else { // with CORBA, the stack trace is not visible by the client if // not inserted in DevFailed. throw DevFailedUtils . newDevFailed ( e ) ; } } finally { deviceMonitoring . endRequest ( request ) ; } xlogger . exit ( ) ; return argout ; }
Execute a command . IDL 1 version
251
9
19,828
@ Override public Any command_inout_4 ( final String commandName , final Any argin , final DevSource source , final ClntIdent clIdent ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( commandName ) ; if ( ! commandName . equalsIgnoreCase ( DeviceImpl . STATE_NAME ) && ! commandName . equalsIgnoreCase ( DeviceImpl . STATUS_NAME ) ) { checkInitialization ( ) ; } final long request = deviceMonitoring . startRequest ( "Operation command_inout_4 (cmd = " + commandName + ")" , source , clIdent ) ; clientIdentity . set ( clIdent ) ; Any argout = null ; if ( ! name . equalsIgnoreCase ( getAdminDeviceName ( ) ) ) { clientLocking . checkClientLocking ( clIdent , commandName ) ; } try { argout = commandHandler ( commandName , argin , source , clIdent ) ; } catch ( final Exception e ) { deviceMonitoring . addError ( ) ; if ( e instanceof DevFailed ) { throw ( DevFailed ) e ; } else { // with CORBA, the stack trace is not visible by the client if // not inserted in DevFailed. throw DevFailedUtils . newDevFailed ( e ) ; } } finally { deviceMonitoring . endRequest ( request ) ; } xlogger . exit ( ) ; return argout ; }
Execute a command . IDL 4 version
317
9
19,829
@ Override public DevCmdHistory [ ] command_inout_history_2 ( final String commandName , final int maxSize ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; checkInitialization ( ) ; deviceMonitoring . startRequest ( "command_inout_history_2 " + commandName ) ; // TODO command_inout_history_2 // returncommandHistory.get(command).toArray(n) return new DevCmdHistory [ ] { } ; }
Command history . IDL 2 version .
116
8
19,830
@ Override public DevCmdHistory_4 command_inout_history_4 ( final String commandName , final int maxSize ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; checkInitialization ( ) ; final long request = deviceMonitoring . startRequest ( "command_inout_history_4 " + commandName ) ; final CommandImpl command = getCommand ( commandName ) ; DevCmdHistory_4 history = null ; try { history = command . getHistory ( ) . toDevCmdHistory4 ( maxSize ) ; } catch ( final Exception e ) { deviceMonitoring . addError ( ) ; if ( e instanceof DevFailed ) { throw ( DevFailed ) e ; } else { // with CORBA, the stack trace is not visible by the client if // not inserted in DevFailed. throw DevFailedUtils . newDevFailed ( e ) ; } } finally { deviceMonitoring . endRequest ( request ) ; } return history ; }
Command history . IDL 4 version .
221
8
19,831
@ Override public AttributeConfig_5 [ ] get_attribute_config_5 ( final String [ ] attributeNames ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( Arrays . toString ( attributeNames ) ) ; // checkInitialization(); deviceMonitoring . startRequest ( "get_attribute_config_5 " + Arrays . toString ( attributeNames ) ) ; // check if we must retrieve all attributes config final int length = attributeNames . length ; boolean getAllConfig = false ; if ( length == 1 && attributeNames [ 0 ] . contains ( ALL_ATTR ) ) { getAllConfig = true ; } AttributeConfig_5 [ ] result ; if ( getAllConfig ) { logger . debug ( "get All" ) ; final List < AttributeImpl > attrList = getAttributeList ( ) ; // Collections.sort(attrList); result = new AttributeConfig_5 [ attributeList . size ( ) ] ; int i = 0 ; for ( final AttributeImpl attribute : attrList ) { if ( ! attribute . getName ( ) . equals ( STATE_NAME ) && ! attribute . getName ( ) . equals ( STATUS_NAME ) ) { result [ i ++ ] = TangoIDLAttributeUtil . toAttributeConfig5 ( attribute ) ; } } result [ i ++ ] = TangoIDLAttributeUtil . toAttributeConfig5 ( AttributeGetterSetter . getAttribute ( STATE_NAME , attrList ) ) ; result [ i ++ ] = TangoIDLAttributeUtil . toAttributeConfig5 ( AttributeGetterSetter . getAttribute ( STATUS_NAME , attrList ) ) ; } else { result = new AttributeConfig_5 [ attributeNames . length ] ; int i = 0 ; for ( final String attributeName : attributeNames ) { final AttributeImpl attribute = AttributeGetterSetter . getAttribute ( attributeName , attributeList ) ; logger . debug ( "{}:{}" , attributeName , attribute . getProperties ( ) ) ; result [ i ++ ] = TangoIDLAttributeUtil . toAttributeConfig5 ( attribute ) ; } } xlogger . exit ( ) ; return result ; }
Get attributes config . IDL5 version
482
8
19,832
@ Override public AttributeConfig [ ] get_attribute_config ( final String [ ] attributeNames ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; // checkInitialization(); deviceMonitoring . startRequest ( "get_attribute_config " + Arrays . toString ( attributeNames ) ) ; // check if we must retrieve all attributes config final int length = attributeNames . length ; boolean getAllConfig = false ; if ( length == 1 && attributeNames [ 0 ] . contains ( ALL_ATTR ) ) { getAllConfig = true ; } AttributeConfig [ ] result ; if ( getAllConfig ) { final List < AttributeImpl > attrList = getAttributeList ( ) ; Collections . sort ( attrList ) ; result = new AttributeConfig [ attributeList . size ( ) ] ; int i = 0 ; for ( final AttributeImpl attribute : attrList ) { result [ i ++ ] = TangoIDLAttributeUtil . toAttributeConfig ( attribute ) ; } } else { result = new AttributeConfig [ attributeNames . length ] ; int i = 0 ; for ( final String attributeName : attributeNames ) { final AttributeImpl attribute = AttributeGetterSetter . getAttribute ( attributeName , attributeList ) ; result [ i ++ ] = TangoIDLAttributeUtil . toAttributeConfig ( attribute ) ; } } xlogger . exit ( ) ; return result ; }
Get attributes config . IDL1 version
315
8
19,833
@ Override public void set_attribute_config_5 ( final AttributeConfig_5 [ ] newConf , final ClntIdent clIdent ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; checkInitialization ( ) ; clientIdentity . set ( clIdent ) ; if ( ! name . equalsIgnoreCase ( getAdminDeviceName ( ) ) ) { clientLocking . checkClientLocking ( clIdent ) ; } deviceMonitoring . startRequest ( "set_attribute_config_5" , clIdent ) ; for ( final AttributeConfig_5 attributeConfig : newConf ) { final String attributeName = attributeConfig . name ; final AttributeImpl attribute = AttributeGetterSetter . getAttribute ( attributeName , attributeList ) ; if ( attribute . getName ( ) . equals ( STATE_NAME ) || attribute . getName ( ) . equals ( STATUS_NAME ) ) { throw DevFailedUtils . newDevFailed ( "set attribute is not possible for " + attribute . getName ( ) ) ; } if ( ! attribute . getFormat ( ) . equals ( attributeConfig . data_format ) || ! attribute . getWritable ( ) . equals ( attributeConfig . writable ) || ! attribute . getDispLevel ( ) . equals ( attributeConfig . level ) || attribute . getTangoType ( ) != attributeConfig . data_type ) { throw DevFailedUtils . newDevFailed ( ExceptionMessages . ATTR_NOT_ALLOWED , "not a good config" ) ; } final AttributePropertiesImpl props = TangoIDLAttributeUtil . toAttributeProperties ( attributeConfig ) ; logger . debug ( "set_attribute_config_5: {}" , props ) ; if ( ! attribute . getProperties ( ) . isEnumMutable ( ) && ! Arrays . equals ( attribute . getProperties ( ) . getEnumLabels ( ) , props . getEnumLabels ( ) ) ) { throw DevFailedUtils . newDevFailed ( ExceptionMessages . NOT_SUPPORTED_FEATURE , "It's not supported to change enumeration labels number from outside the Tango device class code" ) ; } attribute . setProperties ( props ) ; } xlogger . exit ( ) ; }
Set some attribute configs . IDL5 version
506
10
19,834
@ Override public void set_attribute_config_4 ( final AttributeConfig_3 [ ] newConf , final ClntIdent clIdent ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; checkInitialization ( ) ; clientIdentity . set ( clIdent ) ; if ( ! name . equalsIgnoreCase ( getAdminDeviceName ( ) ) ) { clientLocking . checkClientLocking ( clIdent ) ; } deviceMonitoring . startRequest ( "set_attribute_config_4" , clIdent ) ; set_attribute_config_3 ( newConf ) ; xlogger . exit ( ) ; }
Set some attribute configs . IDL4 version
146
10
19,835
@ Override public void set_attribute_config_3 ( final AttributeConfig_3 [ ] newConf ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; checkInitialization ( ) ; deviceMonitoring . startRequest ( "set_attribute_config_3" ) ; for ( final AttributeConfig_3 attributeConfig : newConf ) { final String attributeName = attributeConfig . name ; final AttributeImpl attribute = AttributeGetterSetter . getAttribute ( attributeName , attributeList ) ; if ( attribute . getName ( ) . equals ( STATE_NAME ) || attribute . getName ( ) . equals ( STATUS_NAME ) ) { throw DevFailedUtils . newDevFailed ( "set attribute is not possible for " + attribute . getName ( ) ) ; } if ( ! attribute . getFormat ( ) . equals ( attributeConfig . data_format ) || ! attribute . getWritable ( ) . equals ( attributeConfig . writable ) || ! attribute . getDispLevel ( ) . equals ( attributeConfig . level ) || attribute . getTangoType ( ) != attributeConfig . data_type ) { throw DevFailedUtils . newDevFailed ( ExceptionMessages . ATTR_NOT_ALLOWED , "not a good config" ) ; } final AttributePropertiesImpl props = TangoIDLAttributeUtil . toAttributeProperties ( attributeConfig ) ; logger . debug ( "set_attribute_config_3: {}" , props ) ; attribute . setProperties ( props ) ; } xlogger . exit ( ) ; }
Set some attribute configs . IDL3 version
352
10
19,836
public synchronized void addCommand ( final CommandImpl command ) throws DevFailed { CommandImpl result = null ; for ( final CommandImpl cmd : commandList ) { if ( command . getName ( ) . equalsIgnoreCase ( cmd . getName ( ) ) ) { result = command ; break ; } } if ( result == null ) { commandList . add ( command ) ; // set default polling configuration if ( cmdPollRingDepth . containsKey ( command . getName ( ) . toLowerCase ( Locale . ENGLISH ) ) ) { command . setPollRingDepth ( cmdPollRingDepth . get ( command . getName ( ) . toLowerCase ( Locale . ENGLISH ) ) ) ; } else { command . setPollRingDepth ( pollRingDepth ) ; } } }
add a command
168
3
19,837
@ Override public DevAttrHistory_5 read_attribute_history_5 ( final String attributeName , final int maxSize ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; checkInitialization ( ) ; deviceMonitoring . startRequest ( "read_attribute_history_5" ) ; DevAttrHistory_5 result = null ; try { final AttributeImpl attr = AttributeGetterSetter . getAttribute ( attributeName , attributeList ) ; if ( attr . getBehavior ( ) instanceof ForwardedAttribute ) { final ForwardedAttribute fwdAttr = ( ForwardedAttribute ) attr . getBehavior ( ) ; result = fwdAttr . getAttributeHistory ( maxSize ) ; } else { if ( ! attr . isPolled ( ) ) { throw DevFailedUtils . newDevFailed ( ExceptionMessages . ATTR_NOT_POLLED , attr . getName ( ) + " is not polled" ) ; } result = attr . getHistory ( ) . getAttrHistory5 ( maxSize ) ; } } catch ( final Exception e ) { deviceMonitoring . addError ( ) ; if ( e instanceof DevFailed ) { throw ( DevFailed ) e ; } else { // with CORBA, the stack trace is not visible by the client if // not inserted in DevFailed. throw DevFailedUtils . newDevFailed ( e ) ; } } return result ; }
read an attribute history . IDL 5 version . The history is filled only be attribute polling
327
18
19,838
public static void checkEventCriteria ( final AttributeImpl attribute , final EventType eventType ) throws DevFailed { switch ( eventType ) { case CHANGE_EVENT : ChangeEventTrigger . checkEventCriteria ( attribute ) ; break ; case ARCHIVE_EVENT : ArchiveEventTrigger . checkEventCriteria ( attribute ) ; break ; default : break ; } }
Check if event criteria are set for change and archive events
80
11
19,839
private void bindEndpoints ( ZMQ . Socket socket , Iterable < String > ipAddresses , Map < String , ZMQ . Socket > endpoints , SocketType socketType ) { xlogger . entry ( ipAddresses , endpoints , socketType ) ; for ( String ipAddress : ipAddresses ) { final StringBuilder endpoint = new StringBuilder ( "tcp://" ) . append ( ipAddress ) . append ( ":*" ) ; int port = socket . bind ( endpoint . toString ( ) ) ; //replace * with actual port endpoint . deleteCharAt ( endpoint . length ( ) - 1 ) . append ( port ) ; endpoints . put ( endpoint . toString ( ) , socket ) ; logger . debug ( "bind ZMQ socket {} for {}" , endpoint . toString ( ) , socketType ) ; } xlogger . exit ( ) ; }
Binds given socket types to the list of addresses
188
10
19,840
private EventImpl getEventImpl ( final String fullName ) { if ( ! isInitialized ) { return null ; } // Check if subscribed EventImpl eventImpl = eventImplMap . get ( fullName ) ; // Check if subscription is out of time if ( eventImpl != null && ! eventImpl . isStillSubscribed ( ) ) { logger . debug ( "{} not subscribed any more" , fullName ) ; // System.out.println(fullName + "Not Subscribed any more"); eventImplMap . remove ( fullName ) ; // if no subscribers, close sockets if ( eventImplMap . isEmpty ( ) ) { logger . debug ( "no subscribers on server, closing resources" ) ; close ( ) ; } eventImpl = null ; } return eventImpl ; }
Search the specified EventImpl object
163
6
19,841
public void close ( ) { xlogger . entry ( ) ; logger . debug ( "closing all event resources" ) ; if ( heartBeatExecutor != null ) { heartBeatExecutor . shutdown ( ) ; try { heartBeatExecutor . awaitTermination ( 1 , TimeUnit . SECONDS ) ; } catch ( final InterruptedException e ) { logger . error ( "could not stop event hearbeat" ) ; Thread . currentThread ( ) . interrupt ( ) ; } } if ( context != null ) { // close all open sockets context . destroy ( ) ; } eventImplMap . clear ( ) ; isInitialized = false ; logger . debug ( "all event resources closed" ) ; xlogger . exit ( ) ; }
Close all zmq resources
157
6
19,842
public DevVarLongStringArray getInfo ( ) { // Build the connection parameters object final DevVarLongStringArray longStringArray = new DevVarLongStringArray ( ) ; // longStringArray.lvalue = new int[0]; longStringArray . lvalue = new int [ ] { EventConstants . TANGO_RELEASE , DeviceImpl . SERVER_VERSION , clientHWN , 0 , 0 , EventConstants . ZMQ_RELEASE } ; if ( heartbeatEndpoints . isEmpty ( ) || eventEndpoints . isEmpty ( ) ) { longStringArray . svalue = new String [ ] { "No ZMQ event yet !" } ; } else { longStringArray . svalue = endpointsAsStringArray ( ) ; } return longStringArray ; }
returns the connection parameters for specified event .
167
9
19,843
public DevVarLongStringArray subscribe ( final String deviceName ) throws DevFailed { xlogger . entry ( ) ; // If first time start the ZMQ management if ( ! isInitialized ) { initialize ( ) ; } // check if event is already subscribed final String fullName = EventUtilities . buildDeviceEventName ( deviceName , EventType . INTERFACE_CHANGE_EVENT ) ; EventImpl eventImpl = eventImplMap . get ( fullName ) ; if ( eventImpl == null ) { // If not already manage, create EventImpl object and add it to the map eventImpl = new EventImpl ( DeviceImpl . SERVER_VERSION , fullName ) ; eventImplMap . put ( fullName , eventImpl ) ; } else { eventImpl . updateSubscribeTime ( ) ; } return buildConnectionParameters ( fullName ) ; }
Initialize ZMQ event system if not already done subscribe to the interface change event end returns the connection parameters .
178
22
19,844
public void pushAttributeDataReadyEvent ( final String deviceName , final String attributeName , final int counter ) throws DevFailed { xlogger . entry ( ) ; final String fullName = EventUtilities . buildEventName ( deviceName , attributeName , EventType . DATA_READY_EVENT ) ; final EventImpl eventImpl = getEventImpl ( fullName ) ; if ( eventImpl != null ) { for ( ZMQ . Socket eventSocket : eventEndpoints . values ( ) ) { eventImpl . pushAttributeDataReadyEvent ( counter , eventSocket ) ; } } xlogger . exit ( ) ; }
fire event with AttDataReady
132
6
19,845
public void configurePriorities ( final String [ ] priorities ) { // Set the non defined state in the property at 0 priority // Enumeration of existing state int priority ; // Get the custom priority for ( final String state : priorities ) { // count the token separated by "," final StringTokenizer tmpPriorityTokens = new StringTokenizer ( state . trim ( ) , "," ) ; if ( tmpPriorityTokens . countTokens ( ) == 2 ) { // To avoid the the pb of case final String tmpState = tmpPriorityTokens . nextToken ( ) . trim ( ) . toUpperCase ( ) ; // If the custom state exist if ( StateUtilities . isStateExist ( tmpState ) ) { try { priority = Integer . valueOf ( tmpPriorityTokens . nextToken ( ) . trim ( ) ) ; } catch ( final NumberFormatException e ) { priority = 0 ; } putStatePriority ( StateUtilities . getStateForName ( tmpState ) , priority ) ; } } } }
Configure the state priorities
217
5
19,846
public Any command_inout ( final String in_cmd , final Any in_any ) throws DevFailed { Util . out4 . println ( "DeviceImpl.command_inout(): command received : " + in_cmd ) ; // // Record operation request in black box // blackbox . insert_cmd ( in_cmd , 1 ) ; // // Execute command // Any out_any = null ; try { // If nb connection is closed to the maximum value, // throw an exception to do not block devices. Util . increaseAccessConter ( ) ; if ( Util . getAccessConter ( ) > Util . getPoaThreadPoolMax ( ) - 2 ) { Util . decreaseAccessConter ( ) ; Except . throw_exception ( "API_MemoryAllocation" , Util . instance ( ) . get_ds_real_name ( ) + ": No thread available to connect device" , "DeviceImpl.write_attributes()" ) ; } switch ( Util . get_serial_model ( ) ) { case BY_CLASS : synchronized ( device_class ) { out_any = device_class . command_handler ( this , in_cmd , in_any ) ; } break ; case BY_DEVICE : synchronized ( this ) { out_any = device_class . command_handler ( this , in_cmd , in_any ) ; } break ; default : // NO_SYNC out_any = device_class . command_handler ( this , in_cmd , in_any ) ; } } catch ( final DevFailed exc ) { Util . decreaseAccessConter ( ) ; throw exc ; } catch ( final Exception exc ) { Util . decreaseAccessConter ( ) ; Except . throw_exception ( "API_ExceptionCatched" , exc . toString ( ) , "DeviceImpl.command_inout" ) ; } Util . decreaseAccessConter ( ) ; // // Return value to the caller // Util . out4 . println ( "DeviceImpl.command_inout(): leaving method for command " + in_cmd ) ; return out_any ; }
Execute a command .
460
5
19,847
public String name ( ) { Util . out4 . println ( "DeviceImpl.name() arrived" ) ; // // Record attribute request in black box // blackbox . insert_attr ( Attr_Name ) ; // // Return data to caller // Util . out4 . println ( "Leaving DeviceImpl.name()" ) ; return device_name ; }
Get device name .
78
4
19,848
public String adm_name ( ) { Util . out4 . println ( "DeviceImpl.adm_name() arrived" ) ; // // Record attribute request in black box // blackbox . insert_attr ( Attr_AdmName ) ; // // Return data to caller // Util . out4 . println ( "Leaving DeviceImpl.adm_name()" ) ; return adm_device_name ; }
Get administration device name .
90
5
19,849
public String description ( ) { Util . out4 . println ( "DeviceImpl.description() arrived" ) ; // // Record attribute request in black box // blackbox . insert_attr ( Attr_Description ) ; // // Return data to caller // Util . out4 . println ( "Leaving DeviceImpl.description()" ) ; return desc ; }
Get device description .
76
4
19,850
public String [ ] black_box ( final int n ) throws DevFailed { Util . out4 . println ( "DeviceImpl.black_box() arrived" ) ; final String [ ] ret = blackbox . read ( n ) ; // // Record operation request in black box // blackbox . insert_op ( Op_BlackBox ) ; Util . out4 . println ( "Leaving DeviceImpl.black_box()" ) ; return ret ; }
Get device black box .
98
5
19,851
public DevCmdInfo [ ] command_list_query ( ) { Util . out4 . println ( "DeviceImpl.command_list_query() arrived" ) ; // // Retrive number of command and allocate memory to send back info // final int nb_cmd = device_class . get_command_list ( ) . size ( ) ; Util . out4 . println ( nb_cmd + " command(s) for device" ) ; final DevCmdInfo [ ] back = new DevCmdInfo [ nb_cmd ] ; for ( int loop = 0 ; loop < nb_cmd ; loop ++ ) { back [ loop ] = new DevCmdInfo ( ) ; } // // Populate the sequence // for ( int i = 0 ; i < nb_cmd ; i ++ ) { back [ i ] . cmd_name = ( ( Command ) device_class . get_command_list ( ) . elementAt ( i ) ) . get_name ( ) ; back [ i ] . cmd_tag = ( ( Command ) device_class . get_command_list ( ) . elementAt ( i ) ) . get_tag ( ) ; back [ i ] . in_type = ( ( Command ) device_class . get_command_list ( ) . elementAt ( i ) ) . get_in_type ( ) ; back [ i ] . out_type = ( ( Command ) device_class . get_command_list ( ) . elementAt ( i ) ) . get_out_type ( ) ; String tmp_desc = ( ( Command ) device_class . get_command_list ( ) . elementAt ( i ) ) . get_in_type_desc ( ) ; if ( tmp_desc == null ) { back [ i ] . in_type_desc = Tango_DescNotSet ; } else { back [ i ] . in_type_desc = tmp_desc ; } tmp_desc = ( ( Command ) device_class . get_command_list ( ) . elementAt ( i ) ) . get_out_type_desc ( ) ; if ( tmp_desc == null ) { back [ i ] . out_type_desc = Tango_DescNotSet ; } else { back [ i ] . out_type_desc = tmp_desc ; } } // // Record operation request in black box // blackbox . insert_op ( Op_Command_list ) ; // // Return to caller // Util . out4 . println ( "Leaving DeviceImpl.command_list_query()" ) ; return back ; }
Get device command list .
552
5
19,852
public DevCmdInfo command_query ( final String command ) throws DevFailed { Util . out4 . println ( "DeviceImpl.command_query() arrived" ) ; final DevCmdInfo back = new DevCmdInfo ( ) ; // // Try to retrieve the command in the command list // final String cmd_name = command . toLowerCase ( ) ; int i ; final int nb_cmd = device_class . get_command_list ( ) . size ( ) ; for ( i = 0 ; i < nb_cmd ; i ++ ) { final Command cmd = ( Command ) device_class . get_command_list ( ) . elementAt ( i ) ; if ( cmd . get_name ( ) . toLowerCase ( ) . equals ( cmd_name ) == true ) { back . cmd_name = command ; back . cmd_tag = cmd . get_tag ( ) ; back . in_type = cmd . get_in_type ( ) ; back . out_type = cmd . get_out_type ( ) ; String tmp_desc = cmd . get_in_type_desc ( ) ; if ( tmp_desc == null ) { back . in_type_desc = Tango_DescNotSet ; } else { back . in_type_desc = tmp_desc ; } tmp_desc = cmd . get_out_type_desc ( ) ; if ( tmp_desc == null ) { back . out_type_desc = Tango_DescNotSet ; } else { back . out_type_desc = tmp_desc ; } break ; } } if ( i == nb_cmd ) { Util . out3 . println ( "DeviceImpl.command_query(): operation " + command + " not found" ) ; // // throw an exception to client // Except . throw_exception ( "API_CommandNotFound" , "Command " + command + " not found" , "DeviceImpl.command_query()" ) ; } // // Record operation request in black box // blackbox . insert_op ( Op_Command ) ; // // Return to caller // Util . out4 . println ( "Leaving DeviceImpl.command_query()" ) ; return back ; }
Get command info .
476
4
19,853
public DevInfo info ( ) { Util . out4 . println ( "DeviceImpl.info() arrived" ) ; final DevInfo back = new DevInfo ( ) ; // // Retrieve server host // final Util tg = Util . instance ( ) ; back . server_host = tg . get_host_name ( ) ; // // Fill-in remaining structure fields // back . dev_class = device_class . get_name ( ) ; back . server_id = tg . get_ds_real_name ( ) ; back . server_version = Tango_DevVersion ; back . doc_url = device_class . get_doc_url ( ) ; // // Record operation request in black box // blackbox . insert_op ( Op_Info ) ; // // Return to caller // Util . out4 . println ( "Leaving DeviceImpl.info()" ) ; return back ; }
Get device info .
197
4
19,854
public void ping ( ) { Util . out4 . println ( "DeviceImpl.ping() arrived" ) ; // // Record operation request in black box // blackbox . insert_op ( Op_Ping ) ; // // Return to caller // Util . out4 . println ( "Leaving DeviceImpl.ping()" ) ; }
Ping the device to check if it is still alive .
71
11
19,855
public void add_attribute ( final Attr new_attr ) throws DevFailed { final Vector attr_list = device_class . get_class_attr ( ) . get_attr_list ( ) ; final int old_attr_nb = attr_list . size ( ) ; // // Check that this attribute is not already defined for this device. // If it is alaredy there, immediately returns. // Trick : If you add an attribute to a device, this attribute will be // inserted in the device class attribute list. Therefore, all devices // created after this attribute addition will also have this attribute. // final String attr_name = new_attr . get_name ( ) ; boolean already_there = true ; try { dev_attr . get_attr_by_name ( attr_name ) ; } catch ( final DevFailed ex ) { already_there = false ; } if ( already_there == true ) { return ; } // // Add this attribute in the MultiClassAttribute attr_list vector if it // does not // already exist // int i ; for ( i = 0 ; i < old_attr_nb ; i ++ ) { if ( ( ( Attr ) attr_list . elementAt ( i ) ) . get_name ( ) . equals ( attr_name ) == true ) { break ; } } if ( i == old_attr_nb ) { attr_list . addElement ( new_attr ) ; // // Get all the properties defined for this attribute at class level // device_class . get_class_attr ( ) . init_class_attribute ( device_class . get_name ( ) , old_attr_nb ) ; } // // Add the attribute to the MultiAttribute object // dev_attr . add_attribute ( device_name , device_class , i ) ; }
Add a new attribute to the device attribute list .
393
10
19,856
public Logger get_logger ( ) { if ( logger == null ) { logger = Logger . getLogger ( get_name ( ) . toLowerCase ( ) ) ; logger . setAdditivity ( false ) ; logger . setLevel ( Level . WARN ) ; last_level = Level . WARN ; } return logger ; }
Returns the device s logger
71
5
19,857
@ SuppressWarnings ( { "NestedTryStatement" } ) public void init_logger ( ) { try { Util . out4 . println ( "Initializing logging for " + get_name ( ) ) ; // - Get Util instance final Util util = Util . instance ( ) ; // - Get cmd line logging level then ... final int trace_level = util . get_trace_level ( ) ; // ... convert it to log4j level Level cmd_line_level ; // does the logging level set from cmd line? boolean level_set_from_cmd_line = true ; if ( trace_level <= 0 ) { level_set_from_cmd_line = false ; cmd_line_level = Level . OFF ; } else if ( trace_level <= 2 ) { cmd_line_level = Level . INFO ; } else { cmd_line_level = Level . DEBUG ; } // - Add a console target if logging level set from cmd line if ( level_set_from_cmd_line ) { // add a console target if logging level set from cmd line try { Logging . instance ( ) . add_logging_target ( get_logger ( ) , LOGGING_CONSOLE_TARGET ) ; } catch ( final DevFailed df ) { /** ignore exception */ } } if ( ! Util . _UseDb ) { // - Done if we are not using the database Util . out4 . println ( "Not using the database. Logging Intialization complete" ) ; return ; } // - Get both logging level and targets from database final Logging . LoggingProperties properties = Logging . instance ( ) . get_logging_properties ( get_logger ( ) , util . get_database ( ) ) ; if ( properties == null ) { Util . out4 . println ( "Failed to obtain logging properties from database" ) ; Util . out4 . println ( "Aborting logging intialization" ) ; get_logger ( ) . setLevel ( cmd_line_level ) ; return ; } // - Set logging level if ( level_set_from_cmd_line == false ) { get_logger ( ) . setLevel ( properties . logging_level ) ; Util . out4 . println ( "Logging level set to " + properties . logging_level . toString ( ) ) ; } else { get_logger ( ) . setLevel ( cmd_line_level ) ; } // - Save current logging level last_level = get_logger ( ) . getLevel ( ) ; // - Get rolling threshold for file targets if ( rft != properties . logging_rft ) { rft = properties . logging_rft ; Util . out4 . println ( "Rolling threshold changed to " + String . valueOf ( rft ) ) ; } // - Set logging targets if ( properties . logging_targets != null ) { Util . out4 . println ( "Adding logging targets (" + properties . logging_targets . length + " entries in db)" ) ; for ( final String logging_target : properties . logging_targets ) { try { Logging . instance ( ) . add_logging_target ( get_logger ( ) , logging_target ) ; } catch ( final DevFailed e ) { /* ignore any exception */ } } } // set rolling file threshold for file targets Logging . instance ( ) . set_rolling_file_threshold ( get_logger ( ) , rft ) ; } catch ( final Exception e ) { // igore any exception } }
Initialize the logging for this device
776
7
19,858
public static void checkEventCriteria ( final AttributeImpl attribute ) throws DevFailed { // Check if value is not numerical (always true for State and String) if ( attribute . isState ( ) || attribute . isString ( ) ) { return ; } // Else check criteria final EventProperties props = attribute . getProperties ( ) . getEventProp ( ) ; if ( props . arch_event . period . equals ( Constants . NOT_SPECIFIED ) && props . arch_event . abs_change . equals ( Constants . NOT_SPECIFIED ) && props . arch_event . rel_change . equals ( Constants . NOT_SPECIFIED ) ) { throw DevFailedUtils . newDevFailed ( ExceptionMessages . EVENT_CRITERIA_NOT_SET , "Archive event properties (archive_abs_change or " + "archive_rel_change or archive_period) for attribute " + attribute . getName ( ) + " are not set" ) ; } }
Check if event criteria are set for specified attribute
214
9
19,859
public void close ( ) { if ( lc_dev_proxy != null ) { try { DeviceData dd = new DeviceData ( ) ; dd . insert ( dev_name ) ; lc_dev_proxy . command_inout_asynch ( "UnRegister" , dd , true ) ; } catch ( DevFailed dv ) { //Ignore: some old LogViewer may not support the Unregister cmd } } lc_dev_proxy = null ; dev_name = null ; }
Release any resources allocated within the appender .
109
9
19,860
public void append ( LoggingEvent evt ) { if ( lc_dev_proxy == null ) { return ; } try { String [ ] dvsa = new String [ 6 ] ; dvsa [ 0 ] = String . valueOf ( evt . timeStamp ) ; dvsa [ 1 ] = evt . getLevel ( ) . toString ( ) ; dvsa [ 2 ] = evt . getLoggerName ( ) ; dvsa [ 3 ] = evt . getRenderedMessage ( ) ; dvsa [ 4 ] = "" ; dvsa [ 5 ] = evt . getThreadName ( ) ; DeviceData dd = new DeviceData ( ) ; dd . insert ( dvsa ) ; lc_dev_proxy . command_inout_asynch ( "Log" , dd , true ) ; } catch ( DevFailed dv ) { close ( ) ; } }
Performs actual logging .
200
5
19,861
public static Any set ( final int tangoType , final Object value ) throws DevFailed { final Any any = ORBManager . createAny ( ) ; if ( value != null ) { Object array = null ; if ( value . getClass ( ) . isArray ( ) ) { // convert to array of primitives if necessary array = org . tango . utils . ArrayUtils . toPrimitiveArray ( value ) ; } else { // put in an array before inserting for scalars array = Array . newInstance ( AttributeTangoType . getTypeFromTango ( tangoType ) . getType ( ) , 1 ) ; Array . set ( array , 0 , value ) ; } Method method = null ; try { final Class < ? > inserterClass = CLASS_MAP . get ( tangoType ) ; method = inserterClass . getMethod ( "insert" , Any . class , PARAM_MAP . get ( tangoType ) ) ; method . invoke ( null , any , array ) ; } catch ( final IllegalArgumentException e ) { throw DevFailedUtils . newDevFailed ( ExceptionMessages . ATTR_OPT_PROP , value . getClass ( ) . getCanonicalName ( ) + " is not of the good type, should be " + method ) ; } catch ( final IllegalAccessException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } catch ( final InvocationTargetException e ) { throw DevFailedUtils . newDevFailed ( e . getCause ( ) ) ; } catch ( final SecurityException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } catch ( final NoSuchMethodException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } } return any ; }
Set a value in an any
396
6
19,862
public LoggingProperties get_logging_properties ( Logger logger , Database db ) { //- Instanciate the returned value LoggingProperties properties = new LoggingProperties ( ) ; //- Check input if ( logger == null ) { return properties ; } try { //- Be sure the specified Database is valid if ( db == null ) { return properties ; } //- Get logging properties from database String [ ] prop_names = new String [ 4 ] ; //- Logging path property (overwrites env. var) prop_names [ 0 ] = "logging_path" ; //- Logging file rolling threshold property prop_names [ 1 ] = "logging_rft" ; //- Logging level property prop_names [ 2 ] = "logging_level" ; //- Logging target property prop_names [ 3 ] = "logging_target" ; //- Get properties from db DbDatum [ ] db_data = db . get_device_property ( logger . getName ( ) , prop_names ) ; //- Set logging path if ( db_data [ 0 ] . is_empty ( ) == false ) { properties . logging_path = db_data [ 0 ] . extractString ( ) ; } //- Set logging rft if ( db_data [ 1 ] . is_empty ( ) == false ) { properties . logging_rft = db_data [ 1 ] . extractLong ( ) ; } if ( properties . logging_rft < LOGGING_MIN_RFT ) properties . logging_rft = LOGGING_MIN_RFT ; else if ( properties . logging_rft > LOGGING_MAX_RFT ) properties . logging_rft = LOGGING_MAX_RFT ; //- Set logging level (if not set from cmd line) if ( db_data [ 2 ] . is_empty ( ) == false ) { String level_str = db_data [ 2 ] . extractString ( ) ; properties . logging_level = tango_to_log4j_level ( level_str ) ; } //- Get logging targets (will be set later) if ( db_data [ 3 ] . is_empty ( ) == false ) { properties . logging_targets = db_data [ 3 ] . extractStringArray ( ) ; } } catch ( java . lang . Exception e ) { //- ignore any exception e . printStackTrace ( ) ; } return properties ; }
Reads logging properties from TANGO database
534
9
19,863
public void set_logging_level ( DevVarLongStringArray dvlsa ) throws DevFailed { //- Check input if ( dvlsa . svalue . length != dvlsa . svalue . length ) { String desc = "Imcompatible command argument type, long and string arrays must have the same length" ; Except . throw_exception ( "API_IncompatibleCmdArgumentType" , desc , "Logging::set_logging_level" ) ; } //- For each entry in dvlsa.svalue for ( int i = 0 ; i < dvlsa . svalue . length ; i ++ ) { //- Check/get logging level (may throw DevFailed) Level level = tango_to_log4j_level ( dvlsa . lvalue [ i ] ) ; //- Get ith wilcard String pattern = dvlsa . svalue [ i ] . toLowerCase ( ) ; //- Get devices which name matches the pattern pattern Vector dl = Util . instance ( ) . get_device_list ( pattern ) ; //- For each device in dl Iterator it = dl . iterator ( ) ; while ( it . hasNext ( ) ) { Logger logger = ( ( DeviceImpl ) it . next ( ) ) . get_logger ( ) ; if ( logger == null ) { String desc = "Internal error. Got invalid logger for device " + logger . getName ( ) ; Except . throw_exception ( "API_InternalError" , desc , "Logging::set_logging_level" ) ; } // set logger's level logger . setLevel ( level ) ; Util . out4 . println ( "Logging level set to " + level . toString ( ) + " for device " + logger . getName ( ) ) ; } // while it.hasNext } // for i }
Set logging level for the specified devices
410
7
19,864
public DevVarLongStringArray get_logging_level ( String [ ] dvsa ) throws DevFailed { //- Temp vector int i ; Iterator it ; Vector tmp_name = new Vector ( ) ; Vector tmp_level = new Vector ( ) ; //- For each entry in dvsa for ( i = 0 ; i < dvsa . length ; i ++ ) { //- Get devices which name matches the pattern pattern Vector dl = Util . instance ( ) . get_device_list ( dvsa [ i ] . toLowerCase ( ) ) ; //- For each device in dl it = dl . iterator ( ) ; while ( it . hasNext ( ) ) { DeviceImpl dev = ( DeviceImpl ) it . next ( ) ; tmp_name . addElement ( dev . get_name ( ) ) ; tmp_level . addElement ( dev . get_logger ( ) . getLevel ( ) ) ; } } //- Instanciate retuned value DevVarLongStringArray dvlsa = new DevVarLongStringArray ( ) ; dvlsa . lvalue = new int [ tmp_level . size ( ) ] ; dvlsa . svalue = new String [ tmp_name . size ( ) ] ; i = 0 ; Iterator name_it = tmp_name . iterator ( ) ; Iterator level_it = tmp_level . iterator ( ) ; while ( name_it . hasNext ( ) && level_it . hasNext ( ) ) { dvlsa . svalue [ i ] = ( String ) name_it . next ( ) ; dvlsa . lvalue [ i ] = log4j_to_tango_level ( ( Level ) level_it . next ( ) ) ; i ++ ; } return dvlsa ; }
Get logging level for the specified devices
393
7
19,865
public String [ ] get_logging_target ( String dev_name ) throws DevFailed { //- Get device by name DeviceImpl dev = Util . instance ( ) . get_device_by_name ( dev_name ) ; //- Get device targets (i.e appenders) Enumeration all_appenders = dev . get_logger ( ) . getAllAppenders ( ) ; //- Instanciate returned value int num_appenders = 0 ; Enumeration a_shame_copy = dev . get_logger ( ) . getAllAppenders ( ) ; while ( a_shame_copy . hasMoreElements ( ) ) { num_appenders ++ ; a_shame_copy . nextElement ( ) ; } String [ ] targets = new String [ num_appenders ] ; //- Populate the returned value num_appenders = 0 ; while ( all_appenders . hasMoreElements ( ) ) { Appender appender = ( Appender ) all_appenders . nextElement ( ) ; targets [ num_appenders ++ ] = appender . getName ( ) ; } return targets ; }
Get logging target for the specified devices
249
7
19,866
public void stop_logging ( ) { Vector dl = Util . instance ( ) . get_device_list ( "*" ) ; for ( Object aDl : dl ) { ( ( DeviceImpl ) aDl ) . stop_logging ( ) ; } }
For each device save its current logging Level then set it to OFF
61
13
19,867
public int log4j_to_tango_level ( Level level ) { if ( level . equals ( Level . OFF ) ) { return LOGGING_OFF ; } if ( level . equals ( Level . FATAL ) ) { return LOGGING_FATAL ; } if ( level . equals ( Level . ERROR ) ) { return LOGGING_ERROR ; } if ( level . equals ( Level . WARN ) ) { return LOGGING_WARN ; } if ( level . equals ( Level . INFO ) ) { return LOGGING_INFO ; } return LOGGING_DEBUG ; }
Given to log4j logging level converts it to TANGO level
128
14
19,868
public void set_rolling_file_threshold ( Logger logger , long rft ) { if ( logger == null ) { return ; } if ( rft < LOGGING_MIN_RFT ) { rft = LOGGING_MIN_RFT ; } else if ( rft > LOGGING_MAX_RFT ) { rft = LOGGING_MAX_RFT ; } String prefix = LOGGING_FILE_TARGET + LOGGING_SEPARATOR ; Enumeration all_appenders = logger . getAllAppenders ( ) ; while ( all_appenders . hasMoreElements ( ) ) { Appender appender = ( Appender ) all_appenders . nextElement ( ) ; if ( appender . getName ( ) . indexOf ( prefix ) != - 1 ) { TangoRollingFileAppender trfa = ( TangoRollingFileAppender ) appender ; trfa . setMaximumFileSize ( rft * 1024 ) ; } } }
Set the specified logger s rolling threshold
217
7
19,869
public void addAttribute ( final IAttributeBehavior behavior ) throws DevFailed { final AttributeConfiguration configuration = behavior . getConfiguration ( ) ; final String attributeName = configuration . getName ( ) ; xlogger . entry ( "adding dynamic attribute {}" , attributeName ) ; if ( behavior instanceof ForwardedAttribute ) { // init attribute with either the attribute property value, or the value defined in its constructor final ForwardedAttribute att = ( ForwardedAttribute ) behavior ; final String deviceName = deviceImpl . getName ( ) ; final String rootAttributeName = behavior . getConfiguration ( ) . getAttributeProperties ( ) . loadAttributeRootName ( deviceName , attributeName ) ; if ( rootAttributeName == null || rootAttributeName . isEmpty ( ) || rootAttributeName . equalsIgnoreCase ( Constants . NOT_SPECIFIED ) ) { att . init ( deviceName ) ; // persist root attribute name in tango db behavior . getConfiguration ( ) . getAttributeProperties ( ) . persistAttributeRootName ( deviceName , attributeName ) ; } else { // use attribute property att . init ( deviceName , rootAttributeName ) ; } // check if this attribute is already created final String lower = att . getRootName ( ) . toLowerCase ( Locale . ENGLISH ) ; if ( forwardedAttributes . contains ( lower ) ) { throw DevFailedUtils . newDevFailed ( ExceptionMessages . FWD_DOUBLE_USED , "root attribute already used in this device" ) ; } else { forwardedAttributes . add ( lower ) ; } } else { // set default properties final AttributePropertiesImpl prop = configuration . getAttributeProperties ( ) ; if ( prop . getLabel ( ) . isEmpty ( ) ) { prop . setLabel ( configuration . getName ( ) ) ; } if ( prop . getFormat ( ) . equals ( Constants . NOT_SPECIFIED ) ) { prop . setDefaultFormat ( configuration . getScalarType ( ) ) ; } } final AttributeImpl attrImpl = new AttributeImpl ( behavior , deviceImpl . getName ( ) ) ; attrImpl . setStateMachine ( behavior . getStateMachine ( ) ) ; deviceImpl . addAttribute ( attrImpl ) ; dynamicAttributes . put ( attributeName . toLowerCase ( Locale . ENGLISH ) , attrImpl ) ; deviceImpl . pushInterfaceChangeEvent ( false ) ; if ( configuration . isPolled ( ) && configuration . getPollingPeriod ( ) > 0 ) { deviceImpl . addAttributePolling ( attributeName , configuration . getPollingPeriod ( ) ) ; } xlogger . exit ( ) ; }
Add attribute . Only if not already exists on device .
571
11
19,870
public void clearAttributesWithExclude ( final String ... exclude ) throws DevFailed { final String [ ] toExclude = new String [ exclude . length ] ; for ( int i = 0 ; i < toExclude . length ; i ++ ) { toExclude [ i ] = exclude [ i ] . toLowerCase ( Locale . ENGLISH ) ; } for ( final String attributeName : dynamicAttributes . keySet ( ) ) { if ( ! ArrayUtils . contains ( toExclude , attributeName ) ) { removeAttribute ( attributeName ) ; } } }
Remove all dynamic attributes with exceptions
122
6
19,871
public void clearAttributes ( ) throws DevFailed { for ( final AttributeImpl attributeImpl : dynamicAttributes . values ( ) ) { deviceImpl . removeAttribute ( attributeImpl ) ; } forwardedAttributes . clear ( ) ; dynamicAttributes . clear ( ) ; }
Remove all dynamic attributes
54
4
19,872
public List < IAttributeBehavior > getDynamicAttributes ( ) { final List < IAttributeBehavior > result = new ArrayList < IAttributeBehavior > ( ) ; for ( final AttributeImpl attributeImpl : dynamicAttributes . values ( ) ) { result . add ( attributeImpl . getBehavior ( ) ) ; } return result ; }
Retrieve all dynamic attributes
72
5
19,873
public IAttributeBehavior getAttribute ( final String attributeName ) { AttributeImpl attr = dynamicAttributes . get ( attributeName . toLowerCase ( Locale . ENGLISH ) ) ; if ( attr == null ) return null ; else return attr . getBehavior ( ) ; }
Get a dynamic attribute
63
4
19,874
public void addCommand ( final ICommandBehavior behavior ) throws DevFailed { final String cmdName = behavior . getConfiguration ( ) . getName ( ) ; xlogger . entry ( "adding dynamic command {}" , cmdName ) ; final CommandImpl commandImpl = new CommandImpl ( behavior , deviceImpl . getName ( ) ) ; commandImpl . setStateMachine ( behavior . getStateMachine ( ) ) ; deviceImpl . addCommand ( commandImpl ) ; dynamicCommands . put ( cmdName . toLowerCase ( Locale . ENGLISH ) , commandImpl ) ; deviceImpl . pushInterfaceChangeEvent ( false ) ; xlogger . exit ( ) ; }
Add command . Only if not already exists on device
143
10
19,875
public ICommandBehavior getCommand ( final String commandName ) { return dynamicCommands . get ( commandName . toLowerCase ( Locale . ENGLISH ) ) . getBehavior ( ) ; }
Get a dynamic command
44
4
19,876
public void clearCommands ( ) throws DevFailed { for ( final CommandImpl cmdImpl : dynamicCommands . values ( ) ) { deviceImpl . removeCommand ( cmdImpl ) ; } dynamicCommands . clear ( ) ; }
Remove all dynamic commands
49
4
19,877
public void clearCommandsWithExclude ( final String ... exclude ) throws DevFailed { final String [ ] toExclude = new String [ exclude . length ] ; for ( int i = 0 ; i < toExclude . length ; i ++ ) { toExclude [ i ] = exclude [ i ] . toLowerCase ( Locale . ENGLISH ) ; } for ( final String cmdName : dynamicCommands . keySet ( ) ) { if ( ! ArrayUtils . contains ( toExclude , cmdName ) ) { removeCommand ( cmdName ) ; } } }
Remove all dynamic command with exceptions
124
6
19,878
public List < ICommandBehavior > getDynamicCommands ( ) { final List < ICommandBehavior > result = new ArrayList < ICommandBehavior > ( ) ; for ( final CommandImpl cmdImpl : dynamicCommands . values ( ) ) { result . add ( cmdImpl . getBehavior ( ) ) ; } return result ; }
Retrieve all dynamic commands
73
5
19,879
public void write ( final Object value ) throws DevFailed { initDeviceAttributes ( ) ; for ( final DeviceAttribute deviceAttribute : deviceAttributes ) { if ( deviceAttribute != null ) { // may be null if read failed and throwExceptions is false InsertExtractUtils . insert ( deviceAttribute , value ) ; } } group . write ( deviceAttributes ) ; }
Write a value on several attributes
77
6
19,880
public Object [ ] readExtract ( ) throws DevFailed { final DeviceAttribute [ ] da = read ( ) ; final Object [ ] results = extract ( da ) ; return results ; }
Read attributes and extract their values
40
6
19,881
public static synchronized ITangoDB getDatabase ( final String host , final String port ) throws DevFailed { final ITangoDB dbase ; if ( useDb ) { final String tangoHost = host + ":" + port ; // Search if database object already created for this host and port if ( databaseMap . containsKey ( tangoHost ) ) { return databaseMap . get ( tangoHost ) ; } // Else, create a new database object dbase = new Database ( host , port ) ; databaseMap . put ( tangoHost , dbase ) ; } else { dbase = fileDatabase ; } return dbase ; }
Get the database object created for specified host and port .
133
11
19,882
public static synchronized ITangoDB getDatabase ( ) throws DevFailed { ITangoDB tangoDb = null ; if ( useDb ) { final String tangoHost = TangoHostManager . getFirstTangoHost ( ) ; // Search if database object already created for this host and port if ( databaseMap . containsKey ( tangoHost ) ) { tangoDb = databaseMap . get ( tangoHost ) ; } else { // Else, create a new database object DevFailed lastError = null ; // try all tango hosts until connection is established final Map < String , String > tangoHostMap = TangoHostManager . getTangoHostPortMap ( ) ; for ( final Entry < String , String > entry : tangoHostMap . entrySet ( ) ) { try { lastError = null ; tangoDb = new Database ( entry . getKey ( ) , entry . getValue ( ) ) ; databaseMap . put ( tangoHost , tangoDb ) ; break ; } catch ( final DevFailed e ) { lastError = e ; } } if ( lastError != null ) { throw lastError ; } } } else { tangoDb = fileDatabase ; } return tangoDb ; }
Get the database object using tango_host system property .
259
12
19,883
public static void setDbFile ( final File dbFile , final String [ ] devices , final String className ) throws DevFailed { DatabaseFactory . useDb = false ; DatabaseFactory . fileDatabase = new FileTangoDB ( dbFile , Arrays . copyOf ( devices , devices . length ) , className ) ; }
Build a mock tango db with a file containing the properties
69
12
19,884
public static void setNoDbDevices ( final String [ ] devices , final String className ) { DatabaseFactory . useDb = false ; DatabaseFactory . fileDatabase = new FileTangoDB ( Arrays . copyOf ( devices , devices . length ) , className ) ; }
Build a mock tango db
59
6
19,885
public static Object extract ( final DeviceAttribute da ) throws DevFailed { if ( da == null ) { throw DevFailedUtils . newDevFailed ( ERROR_MSG_DA ) ; } return InsertExtractFactory . getAttributeExtractor ( da . getType ( ) ) . extract ( da ) ; }
Extract read and write part values to an object for SCALAR SPECTRUM and IMAGE
68
20
19,886
public static Object extractRead ( final DeviceAttribute da , final AttrDataFormat format ) throws DevFailed { if ( da == null ) { throw DevFailedUtils . newDevFailed ( ERROR_MSG_DA ) ; } return InsertExtractFactory . getAttributeExtractor ( da . getType ( ) ) . extractRead ( da , format ) ; }
Extract read values to an object for SCALAR SPECTRUM and IMAGE
79
17
19,887
public static Object extractWriteArray ( final DeviceAttribute da , final AttrWriteType writeType , final AttrDataFormat format ) throws DevFailed { if ( da == null ) { throw DevFailedUtils . newDevFailed ( ERROR_MSG_DA ) ; } return InsertExtractFactory . getAttributeExtractor ( da . getType ( ) ) . extractWriteArray ( da , writeType , format ) ; }
Extract write values to an object for SCALAR SPECTRUM and IMAGE
92
17
19,888
public static < T > T extract ( final DeviceAttribute da , final Class < T > type ) throws DevFailed { if ( da == null ) { throw DevFailedUtils . newDevFailed ( ERROR_MSG_DA ) ; } return TypeConversionUtil . castToType ( type , extract ( da ) ) ; }
Extract read and write part values to an object for SCALAR SPECTRUM and IMAGE to the requested type
73
24
19,889
public static < T > T extractRead ( final DeviceAttribute da , final AttrDataFormat format , final Class < T > type ) throws DevFailed { if ( da == null ) { throw DevFailedUtils . newDevFailed ( ERROR_MSG_DA ) ; } return TypeConversionUtil . castToType ( type , extractRead ( da , format ) ) ; }
Extract read part values to an object for SCALAR SPECTRUM and IMAGE to the requested type
84
22
19,890
public static < T > T extractWrite ( final DeviceAttribute da , final AttrDataFormat format , final AttrWriteType writeType , final Class < T > type ) throws DevFailed { if ( da == null ) { throw DevFailedUtils . newDevFailed ( ERROR_MSG_DA ) ; } return TypeConversionUtil . castToType ( type , extractWrite ( da , writeType , format ) ) ; }
Extract write part values to an object for SCALAR SPECTRUM and IMAGE to the requested type
95
22
19,891
public static DServerClass instance ( ) { if ( _instance == null ) { System . err . println ( "DServerClass is not initialised !!!" ) ; System . err . println ( "Exiting" ) ; System . exit ( - 1 ) ; } return _instance ; }
Get the singleton object reference .
61
7
19,892
public void device_factory ( String [ ] devlist ) throws DevFailed { Util . out4 . println ( "DServerClass::device_factory() arrived" ) ; for ( int i = 0 ; i < devlist . length ; i ++ ) { Util . out4 . println ( "Device name : " + devlist [ i ] ) ; // // Create device and add it into the device list // device_list . addElement ( new DServer ( this , devlist [ i ] , "A device server device !!" , DevState . ON , "The device is ON" ) ) ; // // Export device to the outside world // Util . out4 . println ( "Util._UseDb = " + Util . _UseDb ) ; if ( Util . _UseDb == true ) export_device ( ( ( DeviceImpl ) ( device_list . elementAt ( i ) ) ) ) ; else export_device ( ( ( DeviceImpl ) ( device_list . elementAt ( i ) ) ) , devlist [ i ] ) ; } }
Create and export device of the DServer class .
232
10
19,893
public String [ ] getDeviceList ( final String serverName , final String className ) { String [ ] result = new String [ 0 ] ; final Server server = servers . get ( serverName ) ; if ( server != null ) { final String [ ] devices = server . getDevices ( className ) ; if ( devices != null ) { result = Arrays . copyOf ( devices , devices . length ) ; } } return result ; }
Get devices of a server
93
5
19,894
public void build ( final Class < ? > clazz , final Field field , final DeviceImpl device , final Object businessObject ) throws DevFailed { xlogger . entry ( ) ; BuilderUtils . checkStatic ( field ) ; Method getter ; final String stateName = field . getName ( ) ; final String getterName = BuilderUtils . GET + stateName . substring ( 0 , 1 ) . toUpperCase ( Locale . ENGLISH ) + stateName . substring ( 1 ) ; try { getter = clazz . getMethod ( getterName ) ; } catch ( final NoSuchMethodException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } if ( getter . getParameterTypes ( ) . length != 0 ) { throw DevFailedUtils . newDevFailed ( DevFailedUtils . TANGO_BUILD_FAILED , getter + " must not have a parameter" ) ; } logger . debug ( "Has an state : {}" , field . getName ( ) ) ; if ( getter . getReturnType ( ) != DeviceState . class && getter . getReturnType ( ) != DevState . class ) { throw DevFailedUtils . newDevFailed ( DevFailedUtils . TANGO_BUILD_FAILED , getter + " must have a return type of " + DeviceState . class . getCanonicalName ( ) + " or " + DevState . class . getCanonicalName ( ) ) ; } Method setter ; final String setterName = BuilderUtils . SET + stateName . substring ( 0 , 1 ) . toUpperCase ( Locale . ENGLISH ) + stateName . substring ( 1 ) ; try { setter = clazz . getMethod ( setterName , DeviceState . class ) ; } catch ( final NoSuchMethodException e ) { try { setter = clazz . getMethod ( setterName , DevState . class ) ; } catch ( final NoSuchMethodException e1 ) { throw DevFailedUtils . newDevFailed ( e1 ) ; } } device . setStateImpl ( new StateImpl ( businessObject , getter , setter ) ) ; final State annot = field . getAnnotation ( State . class ) ; if ( annot . isPolled ( ) ) { device . addAttributePolling ( DeviceImpl . STATE_NAME , annot . pollingPeriod ( ) ) ; } xlogger . exit ( ) ; }
Create a state
547
3
19,895
public AttributePropertiesImpl getAttributeProperties ( final String attributeName ) throws DevFailed { final AttributeImpl attr = AttributeGetterSetter . getAttribute ( attributeName , device . getAttributeList ( ) ) ; return attr . getProperties ( ) ; }
Get an attribute s properties
61
5
19,896
public void setAttributeProperties ( final String attributeName , final AttributePropertiesImpl properties ) throws DevFailed { final AttributeImpl attr = AttributeGetterSetter . getAttribute ( attributeName , device . getAttributeList ( ) ) ; attr . setProperties ( properties ) ; }
Configure an attribute s properties
65
6
19,897
public void removeAttributeProperties ( final String attributeName ) throws DevFailed { final AttributeImpl attr = AttributeGetterSetter . getAttribute ( attributeName , device . getAttributeList ( ) ) ; attr . removeProperties ( ) ; }
Remove an attribute s properties
56
5
19,898
public boolean isPolled ( final String polledObject ) throws DevFailed { try { return AttributeGetterSetter . getAttribute ( polledObject , device . getAttributeList ( ) ) . isPolled ( ) ; } catch ( final DevFailed e ) { return device . getCommand ( polledObject ) . isPolled ( ) ; } }
Check if an attribute or an command is polled
75
9
19,899
public int getPollingPeriod ( final String polledObject ) throws DevFailed { try { return AttributeGetterSetter . getAttribute ( polledObject , device . getAttributeList ( ) ) . getPollingPeriod ( ) ; } catch ( final DevFailed e ) { return device . getCommand ( polledObject ) . getPollingPeriod ( ) ; } }
Get polling period of an attribute or a command
81
9