idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
19,800
public Any insert ( int data ) throws DevFailed { Any out_any = alloc_any ( ) ; out_any . insert_long ( data ) ; return out_any ; }
Create a CORBA Any object and insert an int data in it .
19,801
public Any insert ( float data ) throws DevFailed { Any out_any = alloc_any ( ) ; out_any . insert_float ( data ) ; return out_any ; }
Create a CORBA Any object and insert a float data in it .
19,802
public Any insert ( double data ) throws DevFailed { Any out_any = alloc_any ( ) ; out_any . insert_double ( data ) ; return out_any ; }
Create a CORBA Any object and insert a double data in it .
19,803
public Any insert ( String data ) throws DevFailed { Any out_any = alloc_any ( ) ; out_any . insert_string ( data ) ; return out_any ; }
Create a CORBA Any object and insert a String in it .
19,804
public Any insert ( byte [ ] data ) throws DevFailed { Any out_any = alloc_any ( ) ; DevVarCharArrayHelper . insert ( out_any , data ) ; return out_any ; }
Create a CORBA Any object and insert a byte array in it .
19,805
public Any insert ( short [ ] data ) throws DevFailed { Any out_any = alloc_any ( ) ; DevVarShortArrayHelper . insert ( out_any , data ) ; return out_any ; }
Create a CORBA Any object and insert a short array in it .
19,806
public Any insert ( int [ ] data ) throws DevFailed { Any out_any = alloc_any ( ) ; DevVarLongArrayHelper . insert ( out_any , data ) ; return out_any ; }
Create a CORBA Any object and insert a int array in it .
19,807
public Any insert ( float [ ] data ) throws DevFailed { Any out_any = alloc_any ( ) ; DevVarFloatArrayHelper . insert ( out_any , data ) ; return out_any ; }
Create a CORBA Any object and insert a float array in it .
19,808
public Any insert ( double [ ] data ) throws DevFailed { Any out_any = alloc_any ( ) ; DevVarDoubleArrayHelper . insert ( out_any , data ) ; return out_any ; }
Create a CORBA Any object and insert a double array in it .
19,809
public Any insert ( String [ ] data ) throws DevFailed { Any out_any = alloc_any ( ) ; DevVarStringArrayHelper . insert ( out_any , data ) ; return out_any ; }
Create a CORBA Any object and insert a String array in it .
19,810
public Any insert ( DevVarLongStringArray data ) throws DevFailed { Any out_any = alloc_any ( ) ; DevVarLongStringArrayHelper . insert ( out_any , data ) ; return out_any ; }
Create a CORBA Any object and insert a DevVarLongStringArray type in it .
19,811
public Any insert ( DevVarDoubleStringArray data ) throws DevFailed { Any out_any = alloc_any ( ) ; DevVarDoubleStringArrayHelper . insert ( out_any , data ) ; return out_any ; }
Create a CORBA Any object and insert a DevVarDoubleStringArray type in it .
19,812
public Any insert ( DevState data ) throws DevFailed { Any out_any = alloc_any ( ) ; DevStateHelper . insert ( out_any , data ) ; return out_any ; }
Create a CORBA Any object and insert a device state in it .
19,813
public boolean extract_DevBoolean ( Any in ) throws DevFailed { boolean data = false ; try { data = in . extract_boolean ( ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevBoolean" ) ; } return data ; }
Extract a boolean data from a CORBA Any object .
19,814
public short extract_DevShort ( Any in ) throws DevFailed { short data = 0 ; try { data = in . extract_short ( ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevShort" ) ; } return data ; }
Extract a short data from a CORBA Any object .
19,815
public float extract_DevFloat ( Any in ) throws DevFailed { float data = 0 ; try { data = in . extract_float ( ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevFloat" ) ; } return data ; }
Extract a float data from a CORBA Any object .
19,816
public double extract_DevDouble ( Any in ) throws DevFailed { double data = 0 ; try { data = in . extract_double ( ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevDouble" ) ; } return data ; }
Extract a double data from a CORBA Any object .
19,817
public String extract_DevString ( Any in ) throws DevFailed { String data = null ; try { data = DevStringHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevString" ) ; } return data ; }
Extract a String from a CORBA Any object .
19,818
public short extract_DevUShort ( Any in ) throws DevFailed { short data = 0 ; try { data = in . extract_ushort ( ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevUShort" ) ; } return data ; }
Extract a DevUShort data from a CORBA Any object .
19,819
public byte [ ] extract_DevVarCharArray ( Any in ) throws DevFailed { byte [ ] data = null ; try { data = DevVarCharArrayHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevVarCharArray" ) ; } return data ; }
Extract a byte array from a CORBA Any object .
19,820
public short [ ] extract_DevVarShortArray ( Any in ) throws DevFailed { short [ ] data = null ; try { data = DevVarShortArrayHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevVarShortArray" ) ; } return data ; }
Extract a short array from a CORBA Any object .
19,821
public float [ ] extract_DevVarFloatArray ( Any in ) throws DevFailed { float [ ] data = null ; try { data = DevVarFloatArrayHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevVarFloatArray" ) ; } return data ; }
Extract a float array from a CORBA Any object .
19,822
public double [ ] extract_DevVarDoubleArray ( Any in ) throws DevFailed { double [ ] data = null ; try { data = DevVarDoubleArrayHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevVarDoubleArray" ) ; } return data ; }
Extract a double array from a CORBA Any object .
19,823
public short [ ] extract_DevVarUShortArray ( Any in ) throws DevFailed { short [ ] data = null ; try { data = DevVarUShortArrayHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevVarUShortArray" ) ; } return data ; }
Extract a DevVarUShortArray type from a CORBA Any object .
19,824
public String [ ] extract_DevVarStringArray ( Any in ) throws DevFailed { String [ ] data = null ; try { data = DevVarStringArrayHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevVarStringArray" ) ; } return data ; }
Extract a DevVarStringArray type from a CORBA Any object .
19,825
public DevVarLongStringArray extract_DevVarLongStringArray ( Any in ) throws DevFailed { DevVarLongStringArray data = null ; try { data = DevVarLongStringArrayHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevVarLongStringArray" ) ; } return data ; }
Extract a DevVarLongStringArray type from a CORBA Any object .
19,826
public DevVarDoubleStringArray extract_DevVarDoubleStringArray ( Any in ) throws DevFailed { DevVarDoubleStringArray data = null ; try { data = DevVarDoubleStringArrayHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevVarDoubleStringArray" ) ; } return data ; }
Extract a DevVarDoubleStringArray type from a CORBA Any object .
19,827
public DevState extract_DevState ( Any in ) throws DevFailed { DevState data = null ; try { data = DevStateHelper . extract ( in ) ; } catch ( BAD_OPERATION ex ) { throw_bad_type ( "DevState" ) ; } return data ; }
Extract a DevState type from a CORBA Any object .
19,828
protected void pushAttributeValueEvent ( ZMQ . Socket eventSocket ) throws DevFailed { xlogger . entry ( ) ; eventTrigger . setError ( null ) ; eventTrigger . updateProperties ( ) ; if ( isSendEvent ( ) ) { sendAttributeValueEvent ( eventSocket ) ; } xlogger . exit ( ) ; }
Fire an event containing a value is condition is valid .
19,829
protected void pushAttributeDataReadyEvent ( final int counter , ZMQ . Socket eventSocket ) throws DevFailed { xlogger . entry ( ) ; try { final AttDataReady dataReady = new AttDataReady ( attribute . getName ( ) , attribute . getTangoType ( ) , counter ) ; synchronized ( eventSocket ) { EventUtilities . sendToSocket ( eventSocket , fullName , counter , EventUtilities . marshall ( dataReady ) ) ; } } catch ( final org . zeromq . ZMQException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } xlogger . exit ( ) ; }
Send a data ready event
19,830
protected void pushDevFailedEvent ( final DevFailed devFailed , ZMQ . Socket eventSocket ) throws DevFailed { xlogger . entry ( ) ; eventTrigger . updateProperties ( ) ; eventTrigger . setError ( devFailed ) ; if ( isSendEvent ( ) ) { try { synchronized ( eventSocket ) { EventUtilities . sendToSocket ( eventSocket , fullName , counter ++ , true , EventUtilities . marshall ( devFailed ) ) ; } } catch ( final org . zeromq . ZMQException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } } xlogger . exit ( ) ; }
Fire an event containing a DevFailed .
19,831
private boolean isSendEvent ( ) throws DevFailed { boolean send = false ; if ( ( eventTrigger . doCheck ( ) && eventTrigger . isSendEvent ( ) ) || ! eventTrigger . doCheck ( ) ) { send = true ; } return send ; }
check if send event
19,832
public Any execute ( DeviceImpl device , Any in_any ) throws DevFailed { Util . out4 . println ( "SetLoggingLevelCmd::execute(): arrived" ) ; DevVarLongStringArray dvlsa = null ; try { dvlsa = extract_DevVarLongStringArray ( in_any ) ; } catch ( DevFailed df ) { Util . out3 . println ( "SetLoggingLevelCmd::execute() ) ; Except . re_throw_exception ( df , "API_IncompatibleCmdArgumentType" , "Imcompatible command argument type, expected type is : DevVarLongStringArray" , "SetLoggingLevelCmd.execute" ) ; } Logging . instance ( ) . set_logging_level ( dvlsa ) ; return Util . return_empty_any ( "SetLoggingLevel" ) ; }
Executes the SetLoggingLevelCmd TANGO command
19,833
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
19,834
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
19,835
public void addClass ( final String tangoClass , final Class < ? > deviceClass ) { lastClass = tangoClass ; tangoClasses . put ( tangoClass , deviceClass ) ; }
Add a class to the server .
19,836
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
19,837
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" ) ) { System . out . println ( "instance list for server " + execName + ": " + Arrays . toString ( DatabaseFactory . getDatabase ( ) . getInstanceNameList ( execName ) ) ) ; } else if ( arg . startsWith ( "-v" ) ) { try { final int level = Integer . parseInt ( arg . substring ( arg . lastIndexOf ( 'v' ) + 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 .
19,838
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
19,839
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
19,840
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
19,841
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 .
19,842
public synchronized void addAttribute ( final AttributeImpl attribute ) throws DevFailed { AttributeImpl result = null ; for ( final AttributeImpl attr : attributeList ) { if ( attr . getName ( ) . equalsIgnoreCase ( attribute . getName ( ) ) ) { result = attribute ; break ; } } if ( result == null ) { attributeList . add ( attribute ) ; 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
19,843
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
19,844
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
19,845
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
19,846
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
19,847
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
19,848
public String [ ] black_box ( final int maxSize ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; 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
19,849
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
19,850
public String name ( ) { MDC . setContextMap ( contextMap ) ; deviceMonitoring . startRequest ( "Device name" ) ; xlogger . entry ( ) ; return name ; }
Get the name of the device
19,851
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" ) ; return new DevAttrHistory [ 0 ] ; }
read an attribute history . IDL 2 version . The history is filled only be attribute polling
19,852
public DevAttrHistory_3 [ ] read_attribute_history_3 ( final String attributeName , final int maxSize ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; 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
19,853
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 { throw DevFailedUtils . newDevFailed ( e ) ; } } return result ; }
read an attribute history . IDL 4 version . The history is filled only be attribute polling
19,854
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 { throw DevFailedUtils . newDevFailed ( e ) ; } } return result ; }
Read some attributes . IDL 1 version .
19,855
public AttributeValue_4 [ ] read_attributes_4 ( final String [ ] names , final DevSource source , final ClntIdent clIdent ) throws DevFailed { 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 { throw DevFailedUtils . newDevFailed ( e ) ; } } xlogger . exit ( ) ; return result ; }
Read some attributes . IDL 4 version .
19,856
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 { throw DevFailedUtils . newDevFailed ( e ) ; } } xlogger . exit ( ) ; }
Write some attributes . IDL 1 version
19,857
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 { throw DevFailedUtils . newDevFailed ( e ) ; } } xlogger . exit ( ) ; }
Write some attributes . IDL 4 version
19,858
public DevCmdInfo [ ] command_list_query ( ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; deviceMonitoring . startRequest ( "command_list_query" ) ; 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
19,859
public DevCmdInfo command_query ( final String commandName ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; 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 .
19,860
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 { throw DevFailedUtils . newDevFailed ( e ) ; } } finally { deviceMonitoring . endRequest ( request ) ; } xlogger . exit ( ) ; return argout ; }
Execute a command . IDL 1 version
19,861
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 { throw DevFailedUtils . newDevFailed ( e ) ; } } finally { deviceMonitoring . endRequest ( request ) ; } xlogger . exit ( ) ; return argout ; }
Execute a command . IDL 4 version
19,862
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 ) ; return new DevCmdHistory [ ] { } ; }
Command history . IDL 2 version .
19,863
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 { throw DevFailedUtils . newDevFailed ( e ) ; } } finally { deviceMonitoring . endRequest ( request ) ; } return history ; }
Command history . IDL 4 version .
19,864
public AttributeConfig_5 [ ] get_attribute_config_5 ( final String [ ] attributeNames ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( Arrays . toString ( attributeNames ) ) ; deviceMonitoring . startRequest ( "get_attribute_config_5 " + Arrays . toString ( attributeNames ) ) ; 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 ( ) ; 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
19,865
public AttributeConfig [ ] get_attribute_config ( final String [ ] attributeNames ) throws DevFailed { MDC . setContextMap ( contextMap ) ; xlogger . entry ( ) ; deviceMonitoring . startRequest ( "get_attribute_config " + Arrays . toString ( attributeNames ) ) ; 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
19,866
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
19,867
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
19,868
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
19,869
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 ) ; if ( cmdPollRingDepth . containsKey ( command . getName ( ) . toLowerCase ( Locale . ENGLISH ) ) ) { command . setPollRingDepth ( cmdPollRingDepth . get ( command . getName ( ) . toLowerCase ( Locale . ENGLISH ) ) ) ; } else { command . setPollRingDepth ( pollRingDepth ) ; } } }
add a command
19,870
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 { throw DevFailedUtils . newDevFailed ( e ) ; } } return result ; }
read an attribute history . IDL 5 version . The history is filled only be attribute polling
19,871
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
19,872
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 ( ) ) ; 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
19,873
private EventImpl getEventImpl ( final String fullName ) { if ( ! isInitialized ) { return null ; } EventImpl eventImpl = eventImplMap . get ( fullName ) ; if ( eventImpl != null && ! eventImpl . isStillSubscribed ( ) ) { logger . debug ( "{} not subscribed any more" , fullName ) ; eventImplMap . remove ( fullName ) ; if ( eventImplMap . isEmpty ( ) ) { logger . debug ( "no subscribers on server, closing resources" ) ; close ( ) ; } eventImpl = null ; } return eventImpl ; }
Search the specified EventImpl object
19,874
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 ) { context . destroy ( ) ; } eventImplMap . clear ( ) ; isInitialized = false ; logger . debug ( "all event resources closed" ) ; xlogger . exit ( ) ; }
Close all zmq resources
19,875
public DevVarLongStringArray getInfo ( ) { final DevVarLongStringArray longStringArray = new DevVarLongStringArray ( ) ; 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 .
19,876
public DevVarLongStringArray subscribe ( final String deviceName ) throws DevFailed { xlogger . entry ( ) ; if ( ! isInitialized ) { initialize ( ) ; } final String fullName = EventUtilities . buildDeviceEventName ( deviceName , EventType . INTERFACE_CHANGE_EVENT ) ; EventImpl eventImpl = eventImplMap . get ( fullName ) ; if ( eventImpl == null ) { 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 .
19,877
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
19,878
public void configurePriorities ( final String [ ] priorities ) { int priority ; for ( final String state : priorities ) { final StringTokenizer tmpPriorityTokens = new StringTokenizer ( state . trim ( ) , "," ) ; if ( tmpPriorityTokens . countTokens ( ) == 2 ) { final String tmpState = tmpPriorityTokens . nextToken ( ) . trim ( ) . toUpperCase ( ) ; 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
19,879
public Any command_inout ( final String in_cmd , final Any in_any ) throws DevFailed { Util . out4 . println ( "DeviceImpl.command_inout(): command received : " + in_cmd ) ; blackbox . insert_cmd ( in_cmd , 1 ) ; Any out_any = null ; try { 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 : 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 ( ) ; Util . out4 . println ( "DeviceImpl.command_inout(): leaving method for command " + in_cmd ) ; return out_any ; }
Execute a command .
19,880
public String name ( ) { Util . out4 . println ( "DeviceImpl.name() arrived" ) ; blackbox . insert_attr ( Attr_Name ) ; Util . out4 . println ( "Leaving DeviceImpl.name()" ) ; return device_name ; }
Get device name .
19,881
public String adm_name ( ) { Util . out4 . println ( "DeviceImpl.adm_name() arrived" ) ; blackbox . insert_attr ( Attr_AdmName ) ; Util . out4 . println ( "Leaving DeviceImpl.adm_name()" ) ; return adm_device_name ; }
Get administration device name .
19,882
public String description ( ) { Util . out4 . println ( "DeviceImpl.description() arrived" ) ; blackbox . insert_attr ( Attr_Description ) ; Util . out4 . println ( "Leaving DeviceImpl.description()" ) ; return desc ; }
Get device description .
19,883
public String [ ] black_box ( final int n ) throws DevFailed { Util . out4 . println ( "DeviceImpl.black_box() arrived" ) ; final String [ ] ret = blackbox . read ( n ) ; blackbox . insert_op ( Op_BlackBox ) ; Util . out4 . println ( "Leaving DeviceImpl.black_box()" ) ; return ret ; }
Get device black box .
19,884
public DevCmdInfo [ ] command_list_query ( ) { Util . out4 . println ( "DeviceImpl.command_list_query() arrived" ) ; 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 ( ) ; } 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 ; } } blackbox . insert_op ( Op_Command_list ) ; Util . out4 . println ( "Leaving DeviceImpl.command_list_query()" ) ; return back ; }
Get device command list .
19,885
public DevCmdInfo command_query ( final String command ) throws DevFailed { Util . out4 . println ( "DeviceImpl.command_query() arrived" ) ; final DevCmdInfo back = new DevCmdInfo ( ) ; 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" ) ; Except . throw_exception ( "API_CommandNotFound" , "Command " + command + " not found" , "DeviceImpl.command_query()" ) ; } blackbox . insert_op ( Op_Command ) ; Util . out4 . println ( "Leaving DeviceImpl.command_query()" ) ; return back ; }
Get command info .
19,886
public DevInfo info ( ) { Util . out4 . println ( "DeviceImpl.info() arrived" ) ; final DevInfo back = new DevInfo ( ) ; final Util tg = Util . instance ( ) ; back . server_host = tg . get_host_name ( ) ; 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 ( ) ; blackbox . insert_op ( Op_Info ) ; Util . out4 . println ( "Leaving DeviceImpl.info()" ) ; return back ; }
Get device info .
19,887
public void ping ( ) { Util . out4 . println ( "DeviceImpl.ping() arrived" ) ; blackbox . insert_op ( Op_Ping ) ; Util . out4 . println ( "Leaving DeviceImpl.ping()" ) ; }
Ping the device to check if it is still alive .
19,888
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 ( ) ; 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 ; } 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 ) ; device_class . get_class_attr ( ) . init_class_attribute ( device_class . get_name ( ) , old_attr_nb ) ; } dev_attr . add_attribute ( device_name , device_class , i ) ; }
Add a new attribute to the device attribute list .
19,889
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
19,890
@ SuppressWarnings ( { "NestedTryStatement" } ) public void init_logger ( ) { try { Util . out4 . println ( "Initializing logging for " + get_name ( ) ) ; final Util util = Util . instance ( ) ; final int trace_level = util . get_trace_level ( ) ; Level cmd_line_level ; 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 ; } if ( level_set_from_cmd_line ) { try { Logging . instance ( ) . add_logging_target ( get_logger ( ) , LOGGING_CONSOLE_TARGET ) ; } catch ( final DevFailed df ) { } } if ( ! Util . _UseDb ) { Util . out4 . println ( "Not using the database. Logging Intialization complete" ) ; return ; } 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 ; } 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 ) ; } last_level = get_logger ( ) . getLevel ( ) ; if ( rft != properties . logging_rft ) { rft = properties . logging_rft ; Util . out4 . println ( "Rolling threshold changed to " + String . valueOf ( rft ) ) ; } 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 ) { } } } Logging . instance ( ) . set_rolling_file_threshold ( get_logger ( ) , rft ) ; } catch ( final Exception e ) { } }
Initialize the logging for this device
19,891
public static void checkEventCriteria ( final AttributeImpl attribute ) throws DevFailed { if ( attribute . isState ( ) || attribute . isString ( ) ) { return ; } 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
19,892
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 ) { } } lc_dev_proxy = null ; dev_name = null ; }
Release any resources allocated within the appender .
19,893
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 .
19,894
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 ( ) ) { array = org . tango . utils . ArrayUtils . toPrimitiveArray ( value ) ; } else { 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
19,895
public LoggingProperties get_logging_properties ( Logger logger , Database db ) { LoggingProperties properties = new LoggingProperties ( ) ; if ( logger == null ) { return properties ; } try { if ( db == null ) { return properties ; } String [ ] prop_names = new String [ 4 ] ; prop_names [ 0 ] = "logging_path" ; prop_names [ 1 ] = "logging_rft" ; prop_names [ 2 ] = "logging_level" ; prop_names [ 3 ] = "logging_target" ; DbDatum [ ] db_data = db . get_device_property ( logger . getName ( ) , prop_names ) ; if ( db_data [ 0 ] . is_empty ( ) == false ) { properties . logging_path = db_data [ 0 ] . extractString ( ) ; } 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 ; if ( db_data [ 2 ] . is_empty ( ) == false ) { String level_str = db_data [ 2 ] . extractString ( ) ; properties . logging_level = tango_to_log4j_level ( level_str ) ; } if ( db_data [ 3 ] . is_empty ( ) == false ) { properties . logging_targets = db_data [ 3 ] . extractStringArray ( ) ; } } catch ( java . lang . Exception e ) { e . printStackTrace ( ) ; } return properties ; }
Reads logging properties from TANGO database
19,896
public void set_logging_level ( DevVarLongStringArray dvlsa ) throws DevFailed { 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 ( int i = 0 ; i < dvlsa . svalue . length ; i ++ ) { Level level = tango_to_log4j_level ( dvlsa . lvalue [ i ] ) ; String pattern = dvlsa . svalue [ i ] . toLowerCase ( ) ; Vector dl = Util . instance ( ) . get_device_list ( pattern ) ; 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" ) ; } logger . setLevel ( level ) ; Util . out4 . println ( "Logging level set to " + level . toString ( ) + " for device " + logger . getName ( ) ) ; } } }
Set logging level for the specified devices
19,897
public DevVarLongStringArray get_logging_level ( String [ ] dvsa ) throws DevFailed { int i ; Iterator it ; Vector tmp_name = new Vector ( ) ; Vector tmp_level = new Vector ( ) ; for ( i = 0 ; i < dvsa . length ; i ++ ) { Vector dl = Util . instance ( ) . get_device_list ( dvsa [ i ] . toLowerCase ( ) ) ; it = dl . iterator ( ) ; while ( it . hasNext ( ) ) { DeviceImpl dev = ( DeviceImpl ) it . next ( ) ; tmp_name . addElement ( dev . get_name ( ) ) ; tmp_level . addElement ( dev . get_logger ( ) . getLevel ( ) ) ; } } 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
19,898
public String [ ] get_logging_target ( String dev_name ) throws DevFailed { DeviceImpl dev = Util . instance ( ) . get_device_by_name ( dev_name ) ; Enumeration all_appenders = dev . get_logger ( ) . getAllAppenders ( ) ; 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 ] ; 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
19,899
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