idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
20,000
public synchronized void startAttributePolling ( final AttributeImpl attr ) throws DevFailed { addAttributePolling ( attr ) ; LOGGER . debug ( "starting attribute {} for polling on device {}" , attr . getName ( ) , deviceName ) ; if ( attr . getPollingPeriod ( ) != 0 ) { attributeCacheMap . get ( attr ) . startRefresh ( POLLING_POOL ) ; } }
Start attribute polling
20,001
private void addAttributePolling ( final AttributeImpl attr ) throws DevFailed { if ( MANAGER == null ) { startCache ( ) ; } removeAttributePolling ( attr ) ; final AttributeCache cache = new AttributeCache ( MANAGER , attr , deviceName , deviceLock , aroundInvoke ) ; if ( attr . getPollingPeriod ( ) == 0 ) { extTrigAttributeCacheMap . put ( attr , cache ) ; } else { attributeCacheMap . put ( attr , cache ) ; } updatePoolConf ( ) ; }
Add attribute as polled
20,002
public synchronized void removeAttributePolling ( final AttributeImpl attr ) throws DevFailed { if ( attributeCacheMap . containsKey ( attr ) ) { final AttributeCache cache = attributeCacheMap . get ( attr ) ; cache . stopRefresh ( ) ; attributeCacheMap . remove ( attr ) ; } else if ( extTrigAttributeCacheMap . containsKey ( attr ) ) { extTrigAttributeCacheMap . remove ( attr ) ; } else if ( attr . getName ( ) . equalsIgnoreCase ( DeviceImpl . STATE_NAME ) && stateCache != null ) { stateCache . stopRefresh ( ) ; stateCache = null ; } else if ( attr . getName ( ) . equalsIgnoreCase ( DeviceImpl . STATUS_NAME ) && statusCache != null ) { statusCache . stopRefresh ( ) ; statusCache = null ; } }
Remove polling of an attribute
20,003
public synchronized void removeAll ( ) { for ( final AttributeCache cache : attributeCacheMap . values ( ) ) { cache . stopRefresh ( ) ; } attributeCacheMap . clear ( ) ; extTrigAttributeCacheMap . clear ( ) ; for ( final CommandCache cache : commandCacheMap . values ( ) ) { cache . stopRefresh ( ) ; } commandCacheMap . clear ( ) ; extTrigCommandCacheMap . clear ( ) ; if ( stateCache != null ) { stateCache . stopRefresh ( ) ; stateCache = null ; } if ( statusCache != null ) { statusCache . stopRefresh ( ) ; statusCache = null ; } cacheList . remove ( deviceName ) ; }
Remove all polling
20,004
public synchronized void removeCommandPolling ( final CommandImpl command ) throws DevFailed { if ( commandCacheMap . containsKey ( command ) ) { final CommandCache cache = commandCacheMap . get ( command ) ; cache . stopRefresh ( ) ; commandCacheMap . remove ( command ) ; } else if ( extTrigCommandCacheMap . containsKey ( command ) ) { extTrigCommandCacheMap . remove ( command ) ; } else if ( command . getName ( ) . equalsIgnoreCase ( DeviceImpl . STATE_NAME ) && stateCache != null ) { stateCache . stopRefresh ( ) ; stateCache = null ; } else if ( command . getName ( ) . equalsIgnoreCase ( DeviceImpl . STATUS_NAME ) && statusCache != null ) { statusCache . stopRefresh ( ) ; statusCache = null ; } }
Remove polling of a command
20,005
public synchronized void start ( ) { for ( final AttributeCache cache : attributeCacheMap . values ( ) ) { cache . startRefresh ( POLLING_POOL ) ; } for ( final CommandCache cache : commandCacheMap . values ( ) ) { cache . startRefresh ( POLLING_POOL ) ; } if ( stateCache != null ) { stateCache . startRefresh ( POLLING_POOL ) ; } if ( statusCache != null ) { statusCache . startRefresh ( POLLING_POOL ) ; } }
Start all polling
20,006
public synchronized void stop ( ) { for ( final AttributeCache cache : attributeCacheMap . values ( ) ) { cache . stopRefresh ( ) ; } for ( final CommandCache cache : commandCacheMap . values ( ) ) { cache . stopRefresh ( ) ; } if ( stateCache != null ) { stateCache . stopRefresh ( ) ; } if ( statusCache != null ) { statusCache . stopRefresh ( ) ; } if ( POLLING_POOL != null ) { POLLING_POOL . shutdownNow ( ) ; POLLING_POOL = new ScheduledThreadPoolExecutor ( poolSize , new TangoCacheThreadFactory ( ) ) ; } }
Stop all polling
20,007
public synchronized SelfPopulatingCache getAttributeCache ( final AttributeImpl attr ) throws NoCacheFoundException { if ( attr . getName ( ) . equalsIgnoreCase ( DeviceImpl . STATE_NAME ) ) { return stateCache . getCache ( ) ; } else if ( attr . getName ( ) . equalsIgnoreCase ( DeviceImpl . STATUS_NAME ) ) { return statusCache . getCache ( ) ; } else { return tryGetAttributeCache ( attr ) ; } }
Get cache of an attribute
20,008
public synchronized SelfPopulatingCache getCommandCache ( final CommandImpl cmd ) { SelfPopulatingCache cache = null ; if ( cmd . getName ( ) . equalsIgnoreCase ( DeviceImpl . STATE_NAME ) ) { cache = stateCache . getCache ( ) ; } else if ( cmd . getName ( ) . equalsIgnoreCase ( DeviceImpl . STATUS_NAME ) ) { cache = statusCache . getCache ( ) ; } else { CommandCache cmdCache = commandCacheMap . get ( cmd ) ; if ( cmdCache == null ) { cmdCache = extTrigCommandCacheMap . get ( cmd ) ; } cache = cmdCache . getCache ( ) ; } return cache ; }
Get cache of a command
20,009
public boolean isOver ( ) { if ( ! isOver ) { final long now = System . currentTimeMillis ( ) ; isOver = now - startTime >= duration ; } return isOver ; }
Check if the started duration is over
20,010
public String getAttributePropertyFromDB ( final String attributeName , final String propertyName ) throws DevFailed { xlogger . entry ( propertyName ) ; String [ ] result = new String [ ] { } ; final Map < String , String [ ] > prop = DatabaseFactory . getDatabase ( ) . getAttributeProperties ( deviceName , attributeName ) ; if ( prop . get ( propertyName ) != null ) { result = prop . get ( propertyName ) ; logger . debug ( attributeName + " property {} is {}" , propertyName , Arrays . toString ( result ) ) ; } xlogger . exit ( ) ; String single = "" ; if ( result . length == 1 && ! result [ 0 ] . isEmpty ( ) ) { single = result [ 0 ] ; } return single ; }
Get an attribute property from tango db
20,011
public void setAttributePropertyInDB ( final String attributeName , final String propertyName , final String value ) throws DevFailed { xlogger . entry ( propertyName ) ; logger . debug ( "update in DB {}, property {}= {}" , new Object [ ] { attributeName , propertyName , value } ) ; final Map < String , String [ ] > propInsert = new HashMap < String , String [ ] > ( ) ; propInsert . put ( propertyName , new String [ ] { value } ) ; DatabaseFactory . getDatabase ( ) . setAttributeProperties ( deviceName , attributeName , propInsert ) ; xlogger . exit ( ) ; }
Set attribute property in tango db
20,012
public void setAttributePropertiesInDB ( final String attributeName , final Map < String , String [ ] > properties ) throws DevFailed { xlogger . entry ( properties ) ; final Map < String , String > currentValues = getAttributePropertiesFromDBSingle ( attributeName ) ; final Map < String , String [ ] > propInsert = new HashMap < String , String [ ] > ( ) ; for ( final Entry < String , String [ ] > entry : properties . entrySet ( ) ) { final String propertyName = entry . getKey ( ) ; final String [ ] valueArray = entry . getValue ( ) ; if ( valueArray . length == 1 ) { final String value = valueArray [ 0 ] ; final String presentValue = currentValues . get ( propertyName ) ; boolean isADefaultValue = false ; if ( presentValue != null ) { isADefaultValue = presentValue . isEmpty ( ) && ( value . equalsIgnoreCase ( Constants . NOT_SPECIFIED ) || value . equalsIgnoreCase ( Constants . NO_DIPLAY_UNIT ) || value . equalsIgnoreCase ( Constants . NO_UNIT ) || value . equalsIgnoreCase ( Constants . NO_STD_UNIT ) ) ; } if ( ! isADefaultValue ) { if ( presentValue == null ) { propInsert . put ( propertyName , valueArray ) ; } else if ( ! presentValue . equals ( value ) && ! value . isEmpty ( ) && ! value . equals ( "NaN" ) ) { propInsert . put ( propertyName , valueArray ) ; } } } else { propInsert . put ( propertyName , valueArray ) ; } } logger . debug ( "update attribute {} properties {} in DB " , attributeName , properties . keySet ( ) ) ; DatabaseFactory . getDatabase ( ) . setAttributeProperties ( deviceName , attributeName , propInsert ) ; xlogger . exit ( ) ; }
Set attribute properties in tango db
20,013
private static Properties getPropertiesFile ( ) { try { final InputStream stream = TangoFactory . class . getClassLoader ( ) . getResourceAsStream ( FACTORY_PROPERTIES ) ; final Properties properties = new Properties ( ) ; if ( stream != null ) { final BufferedInputStream bufStream = new BufferedInputStream ( stream ) ; properties . clear ( ) ; properties . load ( bufStream ) ; } return properties ; } catch ( final Exception e ) { e . printStackTrace ( ) ; return null ; } }
We get the properties file which contains default properties
20,014
private static Object getObject ( final String className ) { try { final Class < ? > clazz = Class . forName ( className ) ; final Constructor < ? > contructor = clazz . getConstructor ( new Class [ ] { } ) ; return contructor . newInstance ( new Object [ ] { } ) ; } catch ( final Exception e ) { e . printStackTrace ( ) ; } return null ; }
We instanciate the Component
20,015
private void initTangoFactory ( ) { final Properties properties = getPropertiesFile ( ) ; String factoryClassName = properties . getProperty ( TANGO_FACTORY ) ; if ( factoryClassName == null ) { factoryClassName = "fr.esrf.TangoApi.factory.DefaultTangoFactoryImpl" ; } tangoFactory = ( ITangoFactory ) getObject ( factoryClassName ) ; isDefaultFactory = false ; }
Load properties with impl specification and create instances
20,016
public static void logDevFailed ( final DevFailed e , final Logger logger ) { if ( e . errors != null ) { for ( int i = 0 ; i < e . errors . length ; i ++ ) { logger . error ( "Error Level {} :" , i ) ; logger . error ( "\t - desc: {}" , e . errors [ i ] . desc ) ; logger . error ( "\t - origin: {}" , e . errors [ i ] . origin ) ; logger . error ( "\t - reason: {}" , e . errors [ i ] . reason ) ; String sev = "" ; if ( e . errors [ i ] . severity . value ( ) == ErrSeverity . ERR . value ( ) ) { sev = "ERROR" ; } else if ( e . errors [ i ] . severity . value ( ) == ErrSeverity . PANIC . value ( ) ) { sev = "PANIC" ; } else if ( e . errors [ i ] . severity . value ( ) == ErrSeverity . WARN . value ( ) ) { sev = "WARN" ; } logger . error ( "\t - severity: {}" , sev ) ; } } else { logger . error ( "EMPTY DevFailed" ) ; } }
Convert a DevFailed to a String
20,017
public void get_properties ( AttributeConfig conf ) { conf . writable = writable ; conf . data_format = data_format ; conf . max_dim_x = max_x ; conf . max_dim_y = max_y ; conf . data_type = data_type ; conf . name = name ; conf . label = label ; conf . description = description ; conf . unit = unit ; conf . standard_unit = standard_unit ; conf . display_unit = display_unit ; conf . format = format ; conf . writable_attr_name = writable_attr_name ; conf . min_alarm = min_alarm_str ; conf . max_alarm = max_alarm_str ; conf . min_value = min_value_str ; conf . max_value = max_value_str ; conf . extensions = new String [ 0 ] ; }
Get attribute properties .
20,018
private String formatValue ( String [ ] value ) { String ret = "" ; for ( int i = 0 ; i < value . length ; i ++ ) { ret += value [ i ] ; if ( i < value . length - 1 ) ret += "\n" ; } return ret ; }
Format the value in one string by adding \ n after each string .
20,019
public Object execute ( final Object arg ) throws DevFailed { errorReportMap . clear ( ) ; String tmpReplyName = "" ; boolean hasFailed = false ; final List < DevError [ ] > errors = new ArrayList < DevError [ ] > ( ) ; int size = 0 ; final DeviceData argin = new DeviceData ( ) ; InsertExtractUtils . insert ( argin , config . getInTangoType ( ) , arg ) ; final GroupCmdReplyList tmpReplyList = group . command_inout ( name , argin , true ) ; for ( final Object tmpReply : tmpReplyList ) { tmpReplyName = ( ( GroupReply ) tmpReply ) . dev_name ( ) ; LOGGER . debug ( "getting answer for {}" , tmpReplyName ) ; try { ( ( GroupCmdReply ) tmpReply ) . get_data ( ) ; } catch ( final DevFailed e ) { LOGGER . error ( "command failed on {}/{} - {}" , new Object [ ] { tmpReplyName , name , DevFailedUtils . toString ( e ) } ) ; hasFailed = true ; errors . add ( e . errors ) ; size = + e . errors . length ; errorReportMap . put ( tmpReplyName , dateFormat . format ( new Date ( ) ) + " : " + name + " result " + DevFailedUtils . toString ( e ) ) ; } } if ( hasFailed ) { final DevError [ ] totalErrors = new DevError [ errors . size ( ) * size + 1 ] ; totalErrors [ 0 ] = new DevError ( "CONNECTION_ERROR" , ErrSeverity . ERR , "cannot execute command " , this . getClass ( ) . getCanonicalName ( ) + ".executeCommand(" + name + ")" ) ; int i = 1 ; for ( final DevError [ ] devErrors : errors ) { for ( final DevError devError : devErrors ) { totalErrors [ i ++ ] = devError ; } } throw new DevFailed ( totalErrors ) ; } return null ; }
execute all commands and read back all errors
20,020
static byte [ ] cppAlignmentAdd8 ( final byte [ ] data ) { XLOGGER . entry ( ) ; final byte [ ] buffer = new byte [ data . length + 8 ] ; buffer [ 0 ] = ( byte ) 0xc0 ; buffer [ 1 ] = ( byte ) 0xde ; buffer [ 2 ] = ( byte ) 0xc0 ; buffer [ 3 ] = ( byte ) 0xde ; buffer [ 4 ] = ( byte ) 0xc0 ; buffer [ 5 ] = ( byte ) 0xde ; buffer [ 6 ] = ( byte ) 0xc0 ; buffer [ 7 ] = ( byte ) 0xde ; System . arraycopy ( data , 0 , buffer , 8 , data . length ) ; XLOGGER . exit ( ) ; return buffer ; }
Add 8 bytes at beginning for C ++ alignment
20,021
static byte [ ] marshall ( final DevFailed devFailed ) throws DevFailed { XLOGGER . entry ( ) ; final CDROutputStream os = new CDROutputStream ( ) ; try { DevErrorListHelper . write ( os , devFailed . errors ) ; XLOGGER . exit ( ) ; return cppAlignment ( os . getBufferCopy ( ) ) ; } finally { os . close ( ) ; } }
Marshall the attribute with a DevFailed object
20,022
static byte [ ] marshall ( final int counter , final boolean isException ) throws DevFailed { XLOGGER . entry ( ) ; final ZmqCallInfo zmqCallInfo = new ZmqCallInfo ( EventConstants . ZMQ_RELEASE , counter , EventConstants . EXECUTE_METHOD , EventConstants . OBJECT_IDENTIFIER , isException ) ; final CDROutputStream os = new CDROutputStream ( ) ; try { ZmqCallInfoHelper . write ( os , zmqCallInfo ) ; XLOGGER . exit ( ) ; return os . getBufferCopy ( ) ; } finally { os . close ( ) ; } }
Marshall the ZmqCallInfo object
20,023
static double getZmqVersion ( ) { XLOGGER . entry ( ) ; if ( zmqVersion < 0.0 ) { zmqVersion = 0.0 ; try { String strVersion = org . zeromq . ZMQ . getVersionString ( ) ; final StringTokenizer stk = new StringTokenizer ( strVersion , "." ) ; final ArrayList < String > list = new ArrayList < String > ( ) ; while ( stk . hasMoreTokens ( ) ) { list . add ( stk . nextToken ( ) ) ; } strVersion = list . get ( 0 ) + "." + list . get ( 1 ) ; if ( list . size ( ) > 2 ) { strVersion += list . get ( 2 ) ; } try { zmqVersion = Double . parseDouble ( strVersion ) ; } catch ( final NumberFormatException e ) { } } catch ( final Exception e ) { } catch ( final Error e ) { } } XLOGGER . exit ( ) ; return zmqVersion ; }
Return the zmq version as a double like 3 . 22 for 3 . 2 . 2 or 0 . 0 if zmq not available
20,024
public static Object get ( final AttrValUnion union , final AttrDataFormat format ) throws DevFailed { Object result = null ; if ( union != null ) { final AttributeDataType discriminator = union . discriminator ( ) ; if ( discriminator . value ( ) == AttributeDataType . _ATT_NO_DATA ) { throw DevFailedUtils . newDevFailed ( "there is not data" ) ; } try { final Method method = union . getClass ( ) . getMethod ( METHOD_MAP . get ( discriminator ) ) ; result = method . invoke ( union ) ; } catch ( final IllegalArgumentException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } 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 ) ; } if ( format . equals ( AttrDataFormat . SCALAR ) && ! discriminator . equals ( AttributeDataType . DEVICE_STATE ) ) { result = Array . get ( result , 0 ) ; } } return result ; }
Get value from an AttrValUnion
20,025
public static AttrValUnion set ( final int tangoType , final Object value ) throws DevFailed { final AttributeDataType discriminator = AttributeTangoType . getTypeFromTango ( tangoType ) . getAttributeDataType ( ) ; final AttrValUnion union = new AttrValUnion ( ) ; Object array = null ; if ( value . getClass ( ) . isArray ( ) ) { array = org . tango . utils . ArrayUtils . toPrimitiveArray ( value ) ; } else { array = Array . newInstance ( AttributeTangoType . getTypeFromTango ( tangoType ) . getType ( ) , 1 ) ; try { Array . set ( array , 0 , value ) ; } catch ( final IllegalArgumentException e ) { throw DevFailedUtils . newDevFailed ( ExceptionMessages . ATTR_OPT_PROP , value . getClass ( ) . getCanonicalName ( ) + " is not of the good type" ) ; } } try { final Method method = union . getClass ( ) . getMethod ( METHOD_MAP . get ( discriminator ) , PARAM_MAP . get ( discriminator ) ) ; method . invoke ( union , array ) ; } catch ( final IllegalArgumentException e ) { throw DevFailedUtils . newDevFailed ( ExceptionMessages . ATTR_OPT_PROP , value . getClass ( ) . getCanonicalName ( ) + " is not of the good type" ) ; } 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 union ; }
Set a value into an AttrValUnion
20,026
public void triggerPolling ( final String objectName ) throws DevFailed { boolean isACommand = false ; CommandImpl cmd = null ; try { cmd = CommandGetter . getCommand ( objectName , commandList ) ; isACommand = true ; } catch ( final DevFailed e ) { } if ( ! isACommand ) { AttributeImpl att = null ; try { att = AttributeGetterSetter . getAttribute ( objectName , attributeList ) ; } catch ( final DevFailed e ) { logger . error ( Constants . POLLED_OBJECT + objectName + " not found" ) ; throw DevFailedUtils . newDevFailed ( ExceptionMessages . POLL_OBJ_NOT_FOUND , Constants . POLLED_OBJECT + objectName + " not found" ) ; } checkPolling ( objectName , att ) ; try { cacheManager . getAttributeCache ( att ) . refresh ( att . getName ( ) ) ; } catch ( final CacheException e ) { if ( e . getCause ( ) instanceof DevFailed ) { throw ( DevFailed ) e . getCause ( ) ; } else { throw DevFailedUtils . newDevFailed ( e . getCause ( ) ) ; } } catch ( final NoCacheFoundException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } } else { checkPolling ( objectName , cmd ) ; try { cacheManager . getCommandCache ( cmd ) . refresh ( cmd . getName ( ) ) ; } catch ( final CacheException e ) { if ( e . getCause ( ) instanceof DevFailed ) { throw ( DevFailed ) e . getCause ( ) ; } else { throw DevFailedUtils . newDevFailed ( e . getCause ( ) ) ; } } } }
Update polling cache
20,027
public void addCommandPolling ( final String commandName , final int pollingPeriod ) throws DevFailed { checkPollingLimits ( commandName , pollingPeriod , minCommandPolling ) ; final CommandImpl command = CommandGetter . getCommand ( commandName , commandList ) ; if ( ! command . getName ( ) . equals ( DeviceImpl . INIT_CMD ) && command . getInType ( ) . equals ( CommandTangoType . VOID ) ) { command . configurePolling ( pollingPeriod ) ; if ( command . getName ( ) . equals ( DeviceImpl . STATE_NAME ) || command . getName ( ) . equals ( DeviceImpl . STATUS_NAME ) ) { final AttributeImpl attribute = AttributeGetterSetter . getAttribute ( command . getName ( ) , attributeList ) ; attribute . configurePolling ( pollingPeriod ) ; pollAttributes . put ( attribute . getName ( ) . toLowerCase ( Locale . ENGLISH ) , pollingPeriod ) ; cacheManager . startStateStatusPolling ( command , attribute ) ; pollAttributes . put ( attribute . getName ( ) . toLowerCase ( Locale . ENGLISH ) , pollingPeriod ) ; savePollingConfig ( ) ; } else { cacheManager . startCommandPolling ( command ) ; } } }
Add command polling . Init command cannot be polled . Only command with parameter void can be polled
20,028
public void addAttributePolling ( final String attributeName , final int pollingPeriod ) throws DevFailed { logger . debug ( "add {} polling with period {}" , attributeName , pollingPeriod ) ; checkPollingLimits ( attributeName , pollingPeriod , minAttributePolling ) ; final AttributeImpl attribute = AttributeGetterSetter . getAttribute ( attributeName , attributeList ) ; if ( attribute . getBehavior ( ) instanceof ForwardedAttribute ) { throw DevFailedUtils . newDevFailed ( attributeName + " not pollable because it is a forwarded attribute" ) ; } attribute . configurePolling ( pollingPeriod ) ; if ( attribute . getName ( ) . equals ( DeviceImpl . STATE_NAME ) || attribute . getName ( ) . equals ( DeviceImpl . STATUS_NAME ) ) { final CommandImpl cmd = CommandGetter . getCommand ( attribute . getName ( ) , commandList ) ; cmd . configurePolling ( pollingPeriod ) ; cacheManager . startStateStatusPolling ( cmd , attribute ) ; } else { cacheManager . startAttributePolling ( attribute ) ; } pollAttributes . put ( attributeName . toLowerCase ( Locale . ENGLISH ) , pollingPeriod ) ; savePollingConfig ( ) ; }
Add attribute polling
20,029
public void removeAttributePolling ( final String attributeName ) throws DevFailed { final AttributeImpl attribute = AttributeGetterSetter . getAttribute ( attributeName , attributeList ) ; attribute . resetPolling ( ) ; cacheManager . removeAttributePolling ( attribute ) ; pollAttributes . remove ( attributeName . toLowerCase ( Locale . ENGLISH ) ) ; if ( attribute . getName ( ) . equals ( DeviceImpl . STATE_NAME ) || attribute . getName ( ) . equals ( DeviceImpl . STATUS_NAME ) ) { final CommandImpl cmd = CommandGetter . getCommand ( attribute . getName ( ) , commandList ) ; cmd . resetPolling ( ) ; cacheManager . removeCommandPolling ( cmd ) ; } savePollingConfig ( ) ; }
Remove attribute polling
20,030
public void removeCommandPolling ( final String commandName ) throws DevFailed { final CommandImpl command = CommandGetter . getCommand ( commandName , commandList ) ; command . resetPolling ( ) ; cacheManager . removeCommandPolling ( command ) ; if ( command . getName ( ) . equals ( DeviceImpl . STATE_NAME ) || command . getName ( ) . equals ( DeviceImpl . STATUS_NAME ) ) { final AttributeImpl attribute = AttributeGetterSetter . getAttribute ( command . getName ( ) , attributeList ) ; attribute . resetPolling ( ) ; cacheManager . removeAttributePolling ( attribute ) ; pollAttributes . remove ( command . getName ( ) . toLowerCase ( Locale . ENGLISH ) ) ; savePollingConfig ( ) ; } }
Remove command polling
20,031
public void start ( final AttributeGroupReader valueReader , final long readingPeriod ) { this . valueReader = valueReader ; this . readingPeriod = readingPeriod ; executor = Executors . newScheduledThreadPool ( 1 ) ; future = executor . scheduleAtFixedRate ( valueReader , 0L , readingPeriod , TimeUnit . MILLISECONDS ) ; }
Start the periodic update
20,032
public void stop ( ) { if ( future != null ) { future . cancel ( true ) ; } if ( executor != null ) { executor . shutdownNow ( ) ; } }
Stop the refresh
20,033
public void updateAttributeGroup ( final TangoGroupAttribute attributeGroup ) { stop ( ) ; final AttributeGroupReader newValueReader = new AttributeGroupReader ( valueReader . getAttributeGroupListener ( ) , attributeGroup , valueReader . isReadWriteValue ( ) , valueReader . isReadQuality ( ) , valueReader . isReadAttributeInfo ( ) ) ; start ( newValueReader , readingPeriod ) ; }
Update the group of attributes
20,034
public static void insert ( final Object value , final DeviceAttribute deviceAttributeWritten , final int dimX , final int dimY ) throws DevFailed { if ( value instanceof Short ) { AttributeHelper . insertFromShort ( ( Short ) value , deviceAttributeWritten ) ; } else if ( value instanceof String ) { AttributeHelper . insertFromString ( ( String ) value , deviceAttributeWritten ) ; } else if ( value instanceof Integer ) { AttributeHelper . insertFromInteger ( ( Integer ) value , deviceAttributeWritten ) ; } else if ( value instanceof Long ) { AttributeHelper . insertFromLong ( ( Long ) value , deviceAttributeWritten ) ; } else if ( value instanceof Float ) { AttributeHelper . insertFromFloat ( ( Float ) value , deviceAttributeWritten ) ; } else if ( value instanceof Boolean ) { AttributeHelper . insertFromBoolean ( ( Boolean ) value , deviceAttributeWritten ) ; } else if ( value instanceof Double ) { AttributeHelper . insertFromDouble ( ( Double ) value , deviceAttributeWritten ) ; } else if ( value instanceof DevState ) { AttributeHelper . insertFromDevState ( ( DevState ) value , deviceAttributeWritten ) ; } else if ( value instanceof WAttribute ) { AttributeHelper . insertFromWAttribute ( ( WAttribute ) value , deviceAttributeWritten ) ; } else if ( value instanceof Vector ) { AttributeHelper . insertFromArray ( ( ( Vector ) value ) . toArray ( ) , deviceAttributeWritten , dimX , dimY ) ; } else { Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type " + value . getClass ( ) + " not supported" , "AttributeHelper.insert(Object value,deviceAttributeWritten)" ) ; } }
Insert data in DeviceAttribute from an Object
20,035
public static Object extract ( final DeviceAttribute deviceAttributeRead ) throws DevFailed { Object argout = null ; if ( deviceAttributeRead . getDimX ( ) != 1 || deviceAttributeRead . getDimY ( ) != 0 ) { argout = extractArray ( deviceAttributeRead ) ; } else { switch ( deviceAttributeRead . getType ( ) ) { case TangoConst . Tango_DEV_SHORT : argout = Short . valueOf ( deviceAttributeRead . extractShort ( ) ) ; break ; case TangoConst . Tango_DEV_USHORT : argout = Integer . valueOf ( deviceAttributeRead . extractUShort ( ) ) . shortValue ( ) ; break ; case TangoConst . Tango_DEV_CHAR : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "out type Tango_DEV_CHAR not supported" , "AttributeHelper.extract(deviceAttributeWritten)" ) ; break ; case TangoConst . Tango_DEV_UCHAR : argout = Short . valueOf ( deviceAttributeRead . extractUChar ( ) ) . shortValue ( ) ; break ; case TangoConst . Tango_DEV_LONG : argout = Integer . valueOf ( deviceAttributeRead . extractLong ( ) ) ; break ; case TangoConst . Tango_DEV_ULONG : argout = Long . valueOf ( deviceAttributeRead . extractULong ( ) ) ; break ; case TangoConst . Tango_DEV_LONG64 : argout = Long . valueOf ( deviceAttributeRead . extractLong64 ( ) ) ; break ; case TangoConst . Tango_DEV_ULONG64 : argout = Long . valueOf ( deviceAttributeRead . extractULong64 ( ) ) ; break ; case TangoConst . Tango_DEV_INT : argout = Integer . valueOf ( deviceAttributeRead . extractLong ( ) ) ; break ; case TangoConst . Tango_DEV_FLOAT : argout = Float . valueOf ( deviceAttributeRead . extractFloat ( ) ) ; break ; case TangoConst . Tango_DEV_DOUBLE : argout = Double . valueOf ( deviceAttributeRead . extractDouble ( ) ) ; break ; case TangoConst . Tango_DEV_STRING : argout = deviceAttributeRead . extractString ( ) ; break ; case TangoConst . Tango_DEV_BOOLEAN : argout = Boolean . valueOf ( deviceAttributeRead . extractBoolean ( ) ) ; break ; case TangoConst . Tango_DEV_STATE : argout = deviceAttributeRead . extractDevState ( ) ; break ; default : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "output type " + deviceAttributeRead . getType ( ) + " not supported" , "AttributeHelper.extract(Short value,deviceAttributeWritten)" ) ; break ; } } return argout ; }
Extract data from DeviceAttribute to an Object
20,036
public static Short extractToShort ( final DeviceAttribute deviceAttributeRead ) throws DevFailed { final Object value = AttributeHelper . extract ( deviceAttributeRead ) ; Short argout = null ; if ( value instanceof Short ) { argout = ( Short ) value ; } else if ( value instanceof String ) { try { argout = Short . valueOf ( ( String ) value ) ; } catch ( final Exception e ) { Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "output type " + value + " is not a numerical" , "AttributeHelper.extractToShort(deviceAttributeWritten)" ) ; } } else if ( value instanceof Integer ) { argout = Short . valueOf ( ( ( Integer ) value ) . shortValue ( ) ) ; } else if ( value instanceof Long ) { argout = Short . valueOf ( ( ( Long ) value ) . shortValue ( ) ) ; } else if ( value instanceof Float ) { argout = Short . valueOf ( ( ( Float ) value ) . shortValue ( ) ) ; } else if ( value instanceof Boolean ) { if ( ( ( Boolean ) value ) . booleanValue ( ) ) { argout = Short . valueOf ( ( short ) 1 ) ; } else { argout = Short . valueOf ( ( short ) 0 ) ; } } else if ( value instanceof Double ) { argout = Short . valueOf ( ( ( Double ) value ) . shortValue ( ) ) ; } else if ( value instanceof DevState ) { argout = Short . valueOf ( Integer . valueOf ( ( ( DevState ) value ) . value ( ) ) . shortValue ( ) ) ; } else { Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "output type " + value . getClass ( ) + " not supported" , "AttributeHelper.extractToShort(Object value,deviceAttributeWritten)" ) ; } return argout ; }
Extract data from DeviceAttribute to a Short
20,037
public static String extractToString ( final DeviceAttribute deviceAttributeRead ) throws DevFailed { final Object value = AttributeHelper . extract ( deviceAttributeRead ) ; String argout = null ; if ( value instanceof Short ) { argout = ( ( Short ) value ) . toString ( ) ; } else if ( value instanceof String ) { argout = ( String ) value ; } else if ( value instanceof Integer ) { argout = ( ( Integer ) value ) . toString ( ) ; } else if ( value instanceof Long ) { argout = ( ( Long ) value ) . toString ( ) ; } else if ( value instanceof Float ) { argout = ( ( Float ) value ) . toString ( ) ; } else if ( value instanceof Boolean ) { argout = ( ( Boolean ) value ) . toString ( ) ; } else if ( value instanceof Double ) { argout = ( ( Double ) value ) . toString ( ) ; } else if ( value instanceof DevState ) { argout = StateUtilities . getNameForState ( ( DevState ) value ) ; } else { Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "output type " + value . getClass ( ) + " not supported" , "AttributeHelper.extractToString(Object value,deviceAttributeWritten)" ) ; } return argout ; }
Extract data from DeviceAttribute to a String
20,038
public static Integer extractToInteger ( final DeviceAttribute deviceAttributeRead ) throws DevFailed { final Object value = AttributeHelper . extract ( deviceAttributeRead ) ; Integer argout = null ; if ( value instanceof Short ) { argout = Integer . valueOf ( ( ( Short ) value ) . intValue ( ) ) ; } else if ( value instanceof String ) { try { argout = Integer . valueOf ( ( String ) value ) ; } catch ( final Exception e ) { Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "output type " + value + " is not a numerical" , "AttributeHelper.extractToInteger(deviceAttributeWritten)" ) ; } } else if ( value instanceof Integer ) { argout = ( Integer ) value ; } else if ( value instanceof Long ) { argout = Integer . valueOf ( ( ( Long ) value ) . intValue ( ) ) ; } else if ( value instanceof Float ) { argout = Integer . valueOf ( ( ( Float ) value ) . intValue ( ) ) ; } else if ( value instanceof Boolean ) { if ( ( ( Boolean ) value ) . booleanValue ( ) ) { argout = Integer . valueOf ( 1 ) ; } else { argout = Integer . valueOf ( 0 ) ; } } else if ( value instanceof Double ) { argout = Integer . valueOf ( ( ( Double ) value ) . intValue ( ) ) ; } else if ( value instanceof DevState ) { argout = Integer . valueOf ( ( ( DevState ) value ) . value ( ) ) ; } else { Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "output type " + value . getClass ( ) + " not supported" , "AttributeHelper.extractToInteger(Object value,deviceAttributeWritten)" ) ; } return argout ; }
Extract data from DeviceAttribute to an Integer
20,039
public static Long extractToLong ( final DeviceAttribute deviceAttributeRead ) throws DevFailed { final Object value = AttributeHelper . extract ( deviceAttributeRead ) ; Long argout = null ; if ( value instanceof Short ) { argout = Long . valueOf ( ( ( Short ) value ) . longValue ( ) ) ; } else if ( value instanceof String ) { try { argout = Long . valueOf ( ( String ) value ) ; } catch ( final Exception e ) { Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "output type " + value + " is not a numerical" , "AttributeHelper.extractToLong(deviceAttributeWritten)" ) ; } } else if ( value instanceof Integer ) { argout = Long . valueOf ( ( ( Integer ) value ) . longValue ( ) ) ; } else if ( value instanceof Long ) { argout = Long . valueOf ( ( ( Long ) value ) . longValue ( ) ) ; } else if ( value instanceof Float ) { argout = Long . valueOf ( ( ( Float ) value ) . longValue ( ) ) ; } else if ( value instanceof Boolean ) { if ( ( ( Boolean ) value ) . booleanValue ( ) ) { argout = Long . valueOf ( 1 ) ; } else { argout = Long . valueOf ( 0 ) ; } } else if ( value instanceof Double ) { argout = Long . valueOf ( ( ( Double ) value ) . longValue ( ) ) ; } else if ( value instanceof DevState ) { argout = Long . valueOf ( Integer . valueOf ( ( ( DevState ) value ) . value ( ) ) . longValue ( ) ) ; } else { Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "output type " + value . getClass ( ) + " not supported" , "AttributeHelper.extractToLong(Object value,deviceAttributeWritten)" ) ; } return argout ; }
Extract data from DeviceAttribute to a Long
20,040
public static Float extractToFloat ( final DeviceAttribute deviceAttributeRead ) throws DevFailed { final Object value = AttributeHelper . extract ( deviceAttributeRead ) ; Float argout = null ; if ( value instanceof Short ) { argout = Float . valueOf ( ( ( Short ) value ) . floatValue ( ) ) ; } else if ( value instanceof String ) { try { argout = Float . valueOf ( ( String ) value ) ; } catch ( final Exception e ) { Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "output type " + value + " is not a numerical" , "AttributeHelper.extractToFloat(deviceAttributeWritten)" ) ; } } else if ( value instanceof Integer ) { argout = Float . valueOf ( ( ( Integer ) value ) . floatValue ( ) ) ; } else if ( value instanceof Long ) { argout = Float . valueOf ( ( ( Long ) value ) . floatValue ( ) ) ; } else if ( value instanceof Float ) { argout = Float . valueOf ( ( ( Float ) value ) . floatValue ( ) ) ; } else if ( value instanceof Boolean ) { if ( ( ( Boolean ) value ) . booleanValue ( ) ) { argout = Float . valueOf ( 1 ) ; } else { argout = Float . valueOf ( 0 ) ; } } else if ( value instanceof Double ) { argout = Float . valueOf ( ( ( Double ) value ) . floatValue ( ) ) ; } else if ( value instanceof DevState ) { argout = Float . valueOf ( Integer . valueOf ( ( ( DevState ) value ) . value ( ) ) . floatValue ( ) ) ; } else { Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "output type " + value . getClass ( ) + " not supported" , "AttributeHelper.extractToFloat(Object value,deviceAttributeWritten)" ) ; } return argout ; }
Extract data from DeviceAttribute to a Float
20,041
public static Boolean extractToBoolean ( final DeviceAttribute deviceAttributeRead ) throws DevFailed { final Object value = AttributeHelper . extract ( deviceAttributeRead ) ; int boolValue = 0 ; Boolean argout = Boolean . FALSE ; ; if ( value instanceof Short ) { boolValue = ( ( Short ) value ) . intValue ( ) ; } else if ( value instanceof String ) { try { if ( Boolean . getBoolean ( ( String ) value ) ) { boolValue = 1 ; } } catch ( final Exception e ) { Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "output type " + value + " is not a boolean" , "AttributeHelper.extractToBoolean(deviceAttributeWritten)" ) ; } } else if ( value instanceof Integer ) { boolValue = ( ( Integer ) value ) . intValue ( ) ; } else if ( value instanceof Long ) { boolValue = ( ( Long ) value ) . intValue ( ) ; } else if ( value instanceof Float ) { boolValue = ( ( Float ) value ) . intValue ( ) ; } else if ( value instanceof Boolean ) { if ( ( ( Boolean ) value ) . booleanValue ( ) ) { boolValue = 1 ; } } else if ( value instanceof Double ) { boolValue = ( ( Double ) value ) . intValue ( ) ; } else if ( value instanceof DevState ) { boolValue = ( ( DevState ) value ) . value ( ) ; } else { Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "output type " + value . getClass ( ) + " not supported" , "AttributeHelper.extractToBoolean(Object value,deviceAttributeWritten)" ) ; } if ( boolValue == 1 ) { argout = Boolean . TRUE ; } return argout ; }
Extract data from DeviceAttribute to a Boolean .
20,042
public static Double extractToDouble ( final DeviceAttribute deviceAttributeRead ) throws DevFailed { final Object value = AttributeHelper . extract ( deviceAttributeRead ) ; Double argout = null ; if ( value instanceof Short ) { argout = Double . valueOf ( ( ( Short ) value ) . doubleValue ( ) ) ; } else if ( value instanceof String ) { try { argout = Double . valueOf ( ( String ) value ) ; } catch ( final Exception e ) { Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "output type " + value + " is not a numerical" , "AttributeHelper.extractToFloat(deviceAttributeWritten)" ) ; } } else if ( value instanceof Integer ) { argout = Double . valueOf ( ( ( Integer ) value ) . doubleValue ( ) ) ; } else if ( value instanceof Long ) { argout = Double . valueOf ( ( ( Long ) value ) . doubleValue ( ) ) ; } else if ( value instanceof Float ) { argout = Double . valueOf ( ( ( Float ) value ) . doubleValue ( ) ) ; } else if ( value instanceof Boolean ) { if ( ( ( Boolean ) value ) . booleanValue ( ) ) { argout = Double . valueOf ( 1 ) ; } else { argout = Double . valueOf ( 0 ) ; } } else if ( value instanceof Double ) { argout = ( Double ) value ; } else if ( value instanceof DevState ) { argout = Double . valueOf ( Integer . valueOf ( ( ( DevState ) value ) . value ( ) ) . doubleValue ( ) ) ; } else { Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "output type " + value . getClass ( ) + " not supported" , "AttributeHelper.extractToFloat(Object value,deviceAttributeWritten)" ) ; } return argout ; }
Extract data from DeviceAttribute to a Double .
20,043
public static void insertFromInteger ( final Integer integerValue , final DeviceAttribute deviceAttributeWritten ) throws DevFailed { switch ( deviceAttributeWritten . getType ( ) ) { case TangoConst . Tango_DEV_SHORT : deviceAttributeWritten . insert ( integerValue . shortValue ( ) ) ; break ; case TangoConst . Tango_DEV_USHORT : deviceAttributeWritten . insert_us ( integerValue . shortValue ( ) ) ; break ; case TangoConst . Tango_DEV_CHAR : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type Tango_DEV_CHAR not supported" , "AttributeHelper.insertFromInteger(Integer value,deviceAttributeWritten)" ) ; break ; case TangoConst . Tango_DEV_UCHAR : deviceAttributeWritten . insert_uc ( integerValue . shortValue ( ) ) ; break ; case TangoConst . Tango_DEV_LONG : deviceAttributeWritten . insert ( integerValue . intValue ( ) ) ; break ; case TangoConst . Tango_DEV_ULONG : deviceAttributeWritten . insert_ul ( integerValue . longValue ( ) ) ; break ; case TangoConst . Tango_DEV_LONG64 : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type Tango_DEV_LONG64 not supported" , "AttributeHelper.insertFromInteger(Integer value,deviceAttributeWritten)" ) ; break ; case TangoConst . Tango_DEV_ULONG64 : deviceAttributeWritten . insert_u64 ( integerValue . longValue ( ) ) ; break ; case TangoConst . Tango_DEV_INT : deviceAttributeWritten . insert ( integerValue . intValue ( ) ) ; break ; case TangoConst . Tango_DEV_FLOAT : deviceAttributeWritten . insert ( integerValue . floatValue ( ) ) ; break ; case TangoConst . Tango_DEV_DOUBLE : deviceAttributeWritten . insert ( integerValue . doubleValue ( ) ) ; break ; case TangoConst . Tango_DEV_STRING : deviceAttributeWritten . insert ( integerValue . toString ( ) ) ; break ; case TangoConst . Tango_DEV_BOOLEAN : if ( integerValue . doubleValue ( ) == 1 ) { deviceAttributeWritten . insert ( true ) ; } else { deviceAttributeWritten . insert ( false ) ; } break ; case TangoConst . Tango_DEV_STATE : try { deviceAttributeWritten . insert ( DevState . from_int ( integerValue . intValue ( ) ) ) ; } catch ( final org . omg . CORBA . BAD_PARAM badParam ) { Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "Cannot sent" + integerValue . intValue ( ) + "for input Tango_DEV_STATE type" , "AttributeHelper.insertFromInteger(Integer value,deviceAttributeWritten)" ) ; } break ; default : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type " + deviceAttributeWritten . getType ( ) + " not supported" , "AttributeHelper.insertFromInteger(Integer value,deviceAttributeWritten)" ) ; break ; } }
Insert data in DeviceAttribute from a Integer .
20,044
public static void insertFromBoolean ( final Boolean booleanValue , final DeviceAttribute deviceAttributeWritten ) throws DevFailed { Integer integerValue = 0 ; if ( booleanValue . booleanValue ( ) ) { integerValue = 1 ; } switch ( deviceAttributeWritten . getType ( ) ) { case TangoConst . Tango_DEV_SHORT : deviceAttributeWritten . insert ( integerValue . shortValue ( ) ) ; break ; case TangoConst . Tango_DEV_USHORT : deviceAttributeWritten . insert_us ( integerValue . shortValue ( ) ) ; break ; case TangoConst . Tango_DEV_CHAR : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type Tango_DEV_CHAR not supported" , "AttributeHelper.insertFromBoolean(Boolean value,deviceAttributeWritten)" ) ; break ; case TangoConst . Tango_DEV_UCHAR : deviceAttributeWritten . insert_uc ( integerValue . shortValue ( ) ) ; break ; case TangoConst . Tango_DEV_LONG : deviceAttributeWritten . insert ( integerValue . intValue ( ) ) ; break ; case TangoConst . Tango_DEV_ULONG : deviceAttributeWritten . insert_ul ( integerValue . longValue ( ) ) ; break ; case TangoConst . Tango_DEV_LONG64 : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type Tango_DEV_LONG64 not supported" , "AttributeHelper.insertFromBoolean(Boolean value,deviceAttributeWritten)" ) ; break ; case TangoConst . Tango_DEV_ULONG64 : deviceAttributeWritten . insert_u64 ( integerValue . longValue ( ) ) ; break ; case TangoConst . Tango_DEV_INT : deviceAttributeWritten . insert ( integerValue . intValue ( ) ) ; break ; case TangoConst . Tango_DEV_FLOAT : deviceAttributeWritten . insert ( integerValue . floatValue ( ) ) ; break ; case TangoConst . Tango_DEV_DOUBLE : deviceAttributeWritten . insert ( integerValue . doubleValue ( ) ) ; break ; case TangoConst . Tango_DEV_STRING : deviceAttributeWritten . insert ( Boolean . toString ( booleanValue . booleanValue ( ) ) ) ; break ; case TangoConst . Tango_DEV_BOOLEAN : deviceAttributeWritten . insert ( booleanValue . booleanValue ( ) ) ; break ; case TangoConst . Tango_DEV_STATE : deviceAttributeWritten . insert ( DevState . from_int ( integerValue . intValue ( ) ) ) ; break ; default : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type " + deviceAttributeWritten . getType ( ) + " not supported" , "AttributeHelper.insertFromBoolean(Boolean value,deviceAttributeWritten)" ) ; break ; } }
Insert data in DeviceAttribute from a Boolean .
20,045
public static void insertFromWAttribute ( final WAttribute wAttributeValue , final DeviceAttribute deviceAttributeWritten ) throws DevFailed { Object value = null ; switch ( wAttributeValue . get_data_type ( ) ) { case TangoConst . Tango_DEV_SHORT : value = Short . valueOf ( wAttributeValue . getShortWriteValue ( ) ) ; break ; case TangoConst . Tango_DEV_USHORT : value = Integer . valueOf ( wAttributeValue . getUShortWriteValue ( ) ) ; break ; case TangoConst . Tango_DEV_CHAR : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type Tango_DEV_CHAR not supported" , "AttributeHelper.insertFromWAttribute(WAttribute wAttributeValue,deviceAttributeWritten)" ) ; break ; case TangoConst . Tango_DEV_UCHAR : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type Tango_DEV_UCHAR not supported" , "AttributeHelper.insertFromWAttribute(WAttribute wAttributeValue,deviceAttributeWritten)" ) ; break ; case TangoConst . Tango_DEV_LONG : value = Integer . valueOf ( wAttributeValue . getLongWriteValue ( ) ) ; break ; case TangoConst . Tango_DEV_ULONG : value = Long . valueOf ( wAttributeValue . getULongWriteValue ( ) ) ; break ; case TangoConst . Tango_DEV_LONG64 : value = Long . valueOf ( wAttributeValue . getLong64WriteValue ( ) ) ; break ; case TangoConst . Tango_DEV_ULONG64 : value = Long . valueOf ( wAttributeValue . getULong64WriteValue ( ) ) ; break ; case TangoConst . Tango_DEV_INT : value = Integer . valueOf ( wAttributeValue . getLongWriteValue ( ) ) ; break ; case TangoConst . Tango_DEV_FLOAT : value = Float . valueOf ( Double . valueOf ( wAttributeValue . getDoubleWriteValue ( ) ) . floatValue ( ) ) ; break ; case TangoConst . Tango_DEV_DOUBLE : value = Double . valueOf ( wAttributeValue . getDoubleWriteValue ( ) ) ; break ; case TangoConst . Tango_DEV_STRING : value = wAttributeValue . getStringWriteValue ( ) ; break ; case TangoConst . Tango_DEV_BOOLEAN : value = Boolean . valueOf ( wAttributeValue . getBooleanWriteValue ( ) ) ; break ; case TangoConst . Tango_DEV_STATE : value = wAttributeValue . getStateWriteValue ( ) ; break ; default : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type " + deviceAttributeWritten . getType ( ) + " not supported" , "AttributeHelper.insertFromDouble(Double value,deviceAttributeWritten)" ) ; break ; } insert ( value , deviceAttributeWritten ) ; }
Insert data in DeviceAttribute from a WAttribute .
20,046
public static void insertFromDevState ( final DevState devStateValue , final DeviceAttribute deviceAttributeWritten ) throws DevFailed { final Integer integerValue = Integer . valueOf ( devStateValue . value ( ) ) ; switch ( deviceAttributeWritten . getType ( ) ) { case TangoConst . Tango_DEV_SHORT : deviceAttributeWritten . insert ( integerValue . shortValue ( ) ) ; break ; case TangoConst . Tango_DEV_USHORT : deviceAttributeWritten . insert_us ( integerValue . shortValue ( ) ) ; break ; case TangoConst . Tango_DEV_CHAR : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type Tango_DEV_CHAR not supported" , "AttributeHelper.insertFromDevState(DevState value,deviceAttributeWritten)" ) ; break ; case TangoConst . Tango_DEV_UCHAR : deviceAttributeWritten . insert_uc ( integerValue . shortValue ( ) ) ; break ; case TangoConst . Tango_DEV_LONG : deviceAttributeWritten . insert ( integerValue . intValue ( ) ) ; break ; case TangoConst . Tango_DEV_ULONG : deviceAttributeWritten . insert_ul ( integerValue . longValue ( ) ) ; break ; case TangoConst . Tango_DEV_LONG64 : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type Tango_DEV_LONG64 not supported" , "AttributeHelper.insertFromDevState(DevState value,deviceAttributeWritten)" ) ; break ; case TangoConst . Tango_DEV_ULONG64 : deviceAttributeWritten . insert_u64 ( integerValue . longValue ( ) ) ; break ; case TangoConst . Tango_DEV_INT : deviceAttributeWritten . insert ( integerValue . intValue ( ) ) ; break ; case TangoConst . Tango_DEV_FLOAT : deviceAttributeWritten . insert ( integerValue . floatValue ( ) ) ; break ; case TangoConst . Tango_DEV_DOUBLE : deviceAttributeWritten . insert ( integerValue . doubleValue ( ) ) ; break ; case TangoConst . Tango_DEV_STRING : deviceAttributeWritten . insert ( integerValue . toString ( ) ) ; break ; case TangoConst . Tango_DEV_BOOLEAN : if ( integerValue . doubleValue ( ) == 1 ) { deviceAttributeWritten . insert ( true ) ; } else { deviceAttributeWritten . insert ( false ) ; } break ; case TangoConst . Tango_DEV_STATE : deviceAttributeWritten . insert ( devStateValue ) ; break ; default : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type " + deviceAttributeWritten . getType ( ) + " not supported" , "AttributeHelper.insertFromDevState(DevState value,deviceAttributeWritten)" ) ; break ; } }
Insert data in DeviceAttribute from a DevState .
20,047
public final static void fillDbDatumFromDeviceAttribute ( final DbDatum dbDatum , final DeviceAttribute deviceAttribute ) throws DevFailed { switch ( deviceAttribute . getType ( ) ) { case TangoConst . Tango_DEV_VOID : break ; case TangoConst . Tango_DEV_BOOLEAN : dbDatum . insert ( deviceAttribute . extractBoolean ( ) ) ; break ; case TangoConst . Tango_DEV_SHORT : dbDatum . insert ( deviceAttribute . extractShort ( ) ) ; break ; case TangoConst . Tango_DEV_USHORT : dbDatum . insert ( deviceAttribute . extractUShort ( ) ) ; break ; case TangoConst . Tango_DEV_FLOAT : dbDatum . insert ( deviceAttribute . extractFloat ( ) ) ; break ; case TangoConst . Tango_DEV_DOUBLE : dbDatum . insert ( deviceAttribute . extractDouble ( ) ) ; break ; case TangoConst . Tango_DEV_STRING : dbDatum . insert ( deviceAttribute . extractString ( ) ) ; break ; case TangoConst . Tango_DEVVAR_SHORTARRAY : dbDatum . insert ( deviceAttribute . extractShortArray ( ) ) ; break ; case TangoConst . Tango_DEVVAR_USHORTARRAY : dbDatum . insert ( deviceAttribute . extractUShortArray ( ) ) ; break ; case TangoConst . Tango_DEVVAR_LONGARRAY : dbDatum . insert ( deviceAttribute . extractLongArray ( ) ) ; break ; case TangoConst . Tango_DEVVAR_FLOATARRAY : dbDatum . insert ( deviceAttribute . extractFloatArray ( ) ) ; break ; case TangoConst . Tango_DEVVAR_DOUBLEARRAY : dbDatum . insert ( deviceAttribute . extractDoubleArray ( ) ) ; break ; case TangoConst . Tango_DEVVAR_STRINGARRAY : dbDatum . insert ( deviceAttribute . extractStringArray ( ) ) ; break ; case TangoConst . Tango_DEVVAR_LONGSTRINGARRAY : dbDatum . insert ( deviceAttribute . extractLongArray ( ) ) ; dbDatum . insert ( deviceAttribute . extractStringArray ( ) ) ; break ; case TangoConst . Tango_DEVVAR_DOUBLESTRINGARRAY : dbDatum . insert ( deviceAttribute . extractDoubleArray ( ) ) ; dbDatum . insert ( deviceAttribute . extractStringArray ( ) ) ; break ; case TangoConst . Tango_DEVVAR_CHARARRAY : case TangoConst . Tango_DEVVAR_ULONGARRAY : case TangoConst . Tango_DEV_LONG : case TangoConst . Tango_DEV_ULONG : default : throw new UnsupportedOperationException ( "Tango_DEVVAR_CHARARRAY, Tango_DEVVAR_ULONGARRAY, Tango_DEV_LONG, Tango_DEV_ULONG are not supported by DbDatum or DeviceAttribute" ) ; } }
Fill DbDatum from value of deviceAttribute
20,048
public void aroundInvoke ( final InvocationContext ctx ) throws DevFailed { xlogger . entry ( ) ; if ( aroundInvokeMethod != null ) { try { aroundInvokeMethod . invoke ( businessObject , ctx ) ; } 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 ( ) ) ; } } } xlogger . exit ( ) ; }
Call aroundInvoke implementation
20,049
static void checkStatic ( final Field field ) throws DevFailed { if ( Modifier . isStatic ( field . getModifiers ( ) ) ) { throw DevFailedUtils . newDevFailed ( DevFailedUtils . TANGO_BUILD_FAILED , field + MUST_NOT_BE_STATIC ) ; } }
Check if a field is static
20,050
static AttributePropertiesImpl setEnumLabelProperty ( final Class < ? > type , final AttributePropertiesImpl props ) throws DevFailed { if ( AttributeTangoType . getTypeFromClass ( type ) . equals ( AttributeTangoType . DEVENUM ) ) { final Object [ ] enumValues = type . getEnumConstants ( ) ; final String [ ] enumLabels = new String [ enumValues . length ] ; for ( int i = 0 ; i < enumLabels . length ; i ++ ) { enumLabels [ i ] = enumValues [ i ] . toString ( ) ; } props . setEnumLabels ( enumLabels , false ) ; } return props ; }
Set enum label for Enum types
20,051
public DevState updateState ( ) throws DevFailed { xlogger . entry ( ) ; Object getState ; if ( getStateMethod != null ) { try { getState = getStateMethod . invoke ( businessObject ) ; if ( getState != null ) { if ( getState instanceof DeviceState ) { state = ( ( DeviceState ) getState ) . getDevState ( ) ; } else { state = ( DevState ) getState ; } } } 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 ( ) ) ; } } } xlogger . exit ( ) ; return state ; }
get the state from the device
20,052
public synchronized void stateMachine ( final DeviceState state ) throws DevFailed { if ( state != null ) { this . state = state . getDevState ( ) ; if ( setStateMethod != null ) { logger . debug ( "Changing state to {}" , state ) ; try { if ( setStateMethod . getParameterTypes ( ) [ 0 ] . equals ( DeviceState . class ) ) { setStateMethod . invoke ( businessObject , state ) ; } else { setStateMethod . invoke ( businessObject , this . state ) ; } } 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 state of the device
20,053
public synchronized void connect_db ( ) { if ( _daemon == true ) { boolean connected = false ; while ( connected == false ) { try { db = ApiUtil . get_db_obj ( ) ; if ( db == null ) { Util . out4 . println ( "Can't contact db server, will try later" ) ; try { wait ( _sleep_between_connect * 1000 ) ; } catch ( final InterruptedException ex ) { } } else { connected = true ; } } catch ( final Exception e ) { Util . out4 . println ( "Can't contact db server, will try later" ) ; try { wait ( _sleep_between_connect * 1000 ) ; } catch ( final InterruptedException ex ) { } } } } else { try { db = ApiUtil . get_db_obj ( ) ; if ( db == null ) { System . err . println ( "Can't build connection to TANGO database server, exiting" ) ; System . err . println ( "DB server host = " + db_host ) ; System . exit ( - 1 ) ; } } catch ( final Exception ex ) { System . err . println ( "Can't build connection to TANGO database server, exiting" ) ; System . err . println ( "DB server host = " + db_host ) ; System . exit ( - 1 ) ; } } Util . out4 . println ( "Connected to database" ) ; }
Connect the process to the TANGO database .
20,054
public Vector get_device_list ( String pattern ) { final Vector dl = new Vector ( ) ; if ( pattern . indexOf ( '*' ) == - 1 ) { DeviceImpl dev = null ; try { dev = get_device_by_name ( pattern ) ; } catch ( final DevFailed df ) { } if ( dev != null ) { dl . add ( dev ) ; return dl ; } } final Vector dcl = get_class_list ( ) ; Vector temp_dl ; if ( pattern . equals ( "*" ) ) { for ( int i = 0 ; i < dcl . size ( ) ; i ++ ) { temp_dl = ( ( DeviceClass ) dcl . elementAt ( i ) ) . get_device_list ( ) ; for ( final Object aTemp_dl : temp_dl ) { final DeviceImpl dev = ( DeviceImpl ) aTemp_dl ; dl . add ( dev ) ; } } return dl ; } Iterator dl_it ; String dev_name ; DeviceImpl dev ; final Iterator dcl_it = dcl . iterator ( ) ; pattern = pattern . replace ( '*' , '.' ) ; final Pattern p = Pattern . compile ( pattern ) ; while ( dcl_it . hasNext ( ) ) { temp_dl = ( ( DeviceClass ) dcl_it . next ( ) ) . get_device_list ( ) ; dl_it = temp_dl . iterator ( ) ; while ( dl_it . hasNext ( ) ) { dev = ( DeviceImpl ) dl_it . next ( ) ; dev_name = dev . get_name ( ) . toLowerCase ( ) ; if ( p . matcher ( dev_name ) . matches ( ) ) { dl . add ( dev ) ; } } } return dl ; }
Get the list of device references which name name match the specified pattern Returns a null vector in case there is no device matching the pattern
20,055
public Vector get_device_list_by_class ( final String class_name ) throws DevFailed { final Vector cl_list = class_list ; final int nb_class = cl_list . size ( ) ; int i ; for ( i = 0 ; i < nb_class ; i ++ ) { if ( ( ( DeviceClass ) cl_list . elementAt ( i ) ) . get_name ( ) . equals ( class_name ) == true ) { break ; } } if ( i == nb_class ) { final StringBuffer o = new StringBuffer ( "Class " ) ; o . append ( class_name ) ; o . append ( " not found" ) ; Except . throw_exception ( "API_ClassNotFound" , o . toString ( ) , "Util::get_device_list_by_class()" ) ; } return ( ( DeviceClass ) cl_list . elementAt ( i ) ) . get_device_list ( ) ; }
Get the list of device references for a given TANGO class .
20,056
public DeviceImpl get_device_by_name ( String dev_name ) throws DevFailed { final Vector cl_list = class_list ; dev_name = dev_name . toLowerCase ( ) ; Vector dev_list = get_device_list_by_class ( ( ( DeviceClass ) cl_list . elementAt ( 0 ) ) . get_name ( ) ) ; final int nb_class = cl_list . size ( ) ; int i , j , nb_dev ; j = nb_dev = 0 ; boolean found = false ; for ( i = 0 ; i < nb_class ; i ++ ) { dev_list = get_device_list_by_class ( ( ( DeviceClass ) cl_list . elementAt ( i ) ) . get_name ( ) ) ; nb_dev = dev_list . size ( ) ; for ( j = 0 ; j < nb_dev ; j ++ ) { if ( ( ( DeviceImpl ) dev_list . elementAt ( j ) ) . get_name ( ) . toLowerCase ( ) . equals ( dev_name ) == true ) { found = true ; break ; } } if ( found == true ) { break ; } } if ( found == false ) { final DServerClass ds_class = DServerClass . instance ( ) ; dev_list = ds_class . get_device_list ( ) ; final String name = ( ( DeviceImpl ) dev_list . elementAt ( 0 ) ) . get_name ( ) ; if ( name . compareToIgnoreCase ( dev_name ) == 0 ) { j = 0 ; } } if ( i == nb_class && j == nb_dev ) { final StringBuffer o = new StringBuffer ( "Device " ) ; o . append ( dev_name ) ; o . append ( " not found" ) ; Except . throw_exception ( "API_DeviceNotFound" , o . toString ( ) , "Util::get_device_by_name()" ) ; } return ( DeviceImpl ) dev_list . elementAt ( j ) ; }
Get a device reference from its name
20,057
public void unregister_server ( ) { Util . out4 . println ( "Entering Tango::unregister_server method" ) ; if ( Util . _UseDb == true ) { try { db . unexport_server ( ds_name . toString ( ) ) ; } catch ( final SystemException e ) { Except . print_exception ( e ) ; System . exit ( - 1 ) ; } catch ( final DevFailed e ) { Except . print_exception ( e ) ; System . exit ( - 1 ) ; } catch ( final UserException e ) { Except . print_exception ( e ) ; System . exit ( - 1 ) ; } } Util . out4 . println ( "Leaving Tango::unregister_server method" ) ; }
Unregister a device server process from the TANGO database .
20,058
public synchronized void execute ( final StateImpl stateImpl , final StatusImpl statusImpl ) { if ( isLazy && ! isInitInProgress ( ) ) { final Callable < Void > initRunnable = new Callable < Void > ( ) { public Void call ( ) throws DevFailed { logger . debug ( "Lazy init in" ) ; MDC . setContextMap ( contextMap ) ; doInit ( stateImpl , statusImpl ) ; logger . debug ( "Lazy init out" ) ; return null ; } } ; future = executor . submit ( initRunnable ) ; } else { doInit ( stateImpl , statusImpl ) ; } }
Execute the init
20,059
public PipeBlobBuilder add ( String name , Object value ) { elements . add ( PipeDataElement . newInstance ( name , value ) ) ; return this ; }
Adds a generic array to this PipeBlob
20,060
public static final Entry < String , String > splitDeviceEntity ( final String entityName ) throws DevFailed { Entry < String , String > result = null ; final Matcher matcher = ENTITY_SPLIT_PATTERN . matcher ( entityName . trim ( ) ) ; if ( matcher . matches ( ) ) { String device = null ; String entity = null ; final String prefixGroup = matcher . group ( PREFIX_INDEX ) ; final boolean noDb = matcher . group ( NO_DB_INDEX ) != null ; if ( noDb ) { if ( matcher . group ( DEVICE_NAME_INDEX ) != null && matcher . group ( ENTITY_INDEX ) != null ) { final String deviceNameGroup = matcher . group ( DEVICE_NAME_INDEX ) ; final String entityGroup = matcher . group ( ENTITY_INDEX ) ; device = prefixGroup + deviceNameGroup ; entity = entityGroup ; } } else { if ( matcher . group ( ATTRIBUTE_ALIAS_INDEX ) != null ) { final String attributeAliasGroup = matcher . group ( ATTRIBUTE_ALIAS_INDEX ) ; final String fullAttributeName = ApiUtil . get_db_obj ( ) . get_attribute_from_alias ( attributeAliasGroup ) ; final int lastIndexOf = fullAttributeName . lastIndexOf ( DEVICE_SEPARATOR ) ; device = prefixGroup + fullAttributeName . substring ( 0 , lastIndexOf ) ; entity = fullAttributeName . substring ( lastIndexOf + 1 ) ; } else if ( matcher . group ( DEVICE_ALIAS_INDEX ) != null ) { final String deviceAliasGroup = matcher . group ( DEVICE_ALIAS_INDEX ) ; final String entityGroup = matcher . group ( ENTITY_INDEX ) ; final String fullDeviceName = ApiUtil . get_db_obj ( ) . get_device_from_alias ( deviceAliasGroup ) ; device = prefixGroup + fullDeviceName ; entity = entityGroup ; } else { final String deviceNameGroup = matcher . group ( DEVICE_NAME_INDEX ) ; final String entityGroup = matcher . group ( ENTITY_INDEX ) ; device = prefixGroup + deviceNameGroup ; entity = entityGroup ; } } if ( device != null && entity != null ) { result = new SimpleEntry < String , String > ( device , entity ) ; } } return result ; }
Splits an entity name into full device name and attribute name . Aliases will be resolved against tango db first .
20,061
public static Map < String , Collection < String > > splitDeviceEntities ( final Collection < String > entityNames ) { final Map < String , Collection < String > > result = new HashMap < String , Collection < String > > ( ) ; String device ; String entity ; for ( final String entityName : entityNames ) { try { final Entry < String , String > deviceEntity = splitDeviceEntity ( entityName ) ; if ( deviceEntity != null ) { device = deviceEntity . getKey ( ) ; entity = deviceEntity . getValue ( ) ; if ( device != null && entity != null ) { Collection < String > attributes = result . get ( device ) ; if ( attributes == null ) { attributes = new HashSet < String > ( ) ; result . put ( device , attributes ) ; } attributes . add ( entity ) ; } } } catch ( final DevFailed e ) { } } return result ; }
Splits a collection of entity names and group attributes by device .
20,062
public static GoogleCredential getApplicationDefaultCredential ( ) { try { GoogleCredential credential = GoogleCredential . getApplicationDefault ( ) ; if ( credential . createScopedRequired ( ) ) { credential = credential . createScoped ( Arrays . asList ( "https://www.googleapis.com/auth/genomics" ) ) ; } return credential ; } catch ( IOException e ) { throw new RuntimeException ( MISSING_ADC_EXCEPTION_MESSAGE , e ) ; } }
Obtain the Application Default com . google . api . client . auth . oauth2 . Credential
20,063
public static Credential getCredentialFromClientSecrets ( String clientSecretsFile , String credentialId ) { Preconditions . checkArgument ( clientSecretsFile != null ) ; Preconditions . checkArgument ( credentialId != null ) ; HttpTransport httpTransport ; try { httpTransport = GoogleNetHttpTransport . newTrustedTransport ( ) ; } catch ( IOException | GeneralSecurityException e ) { throw new RuntimeException ( "Could not create HTTPS transport for use in credential creation" , e ) ; } JsonFactory jsonFactory = JacksonFactory . getDefaultInstance ( ) ; GoogleClientSecrets clientSecrets ; try { clientSecrets = GoogleClientSecrets . load ( jsonFactory , new FileReader ( clientSecretsFile ) ) ; } catch ( IOException e ) { throw new RuntimeException ( "Could not read the client secrets from file: " + clientSecretsFile , e ) ; } FileDataStoreFactory dataStoreFactory ; try { dataStoreFactory = new FileDataStoreFactory ( CREDENTIAL_STORE ) ; } catch ( IOException e ) { throw new RuntimeException ( "Could not create persisten credential store " + CREDENTIAL_STORE , e ) ; } GoogleAuthorizationCodeFlow flow ; try { flow = new GoogleAuthorizationCodeFlow . Builder ( httpTransport , jsonFactory , clientSecrets , SCOPES ) . setDataStoreFactory ( dataStoreFactory ) . build ( ) ; } catch ( IOException e ) { throw new RuntimeException ( "Could not build credential authorization flow" , e ) ; } Credential credential ; try { credential = new AuthorizationCodeInstalledApp ( flow , new PromptReceiver ( ) ) . authorize ( credentialId ) ; } catch ( IOException e ) { throw new RuntimeException ( "Could not perform credential authorization flow" , e ) ; } return credential ; }
Creates an OAuth2 credential from client secrets which may require an interactive authorization prompt .
20,064
public static boolean isOverlapping ( Variant blockRecord , Variant . Builder variant ) { return blockRecord . getStart ( ) <= variant . getStart ( ) && blockRecord . getEnd ( ) >= variant . getStart ( ) + 1 ; }
Determine whether the first variant overlaps the second variant .
20,065
public static final boolean isSameVariantSite ( Variant . Builder variant1 , Variant variant2 ) { return variant1 . getReferenceName ( ) . equals ( variant2 . getReferenceName ( ) ) && variant1 . getReferenceBases ( ) . equals ( variant2 . getReferenceBases ( ) ) && variant1 . getStart ( ) == variant2 . getStart ( ) ; }
Determine whether two variants occur at the same site in the genome where site is defined by reference name start position and reference bases .
20,066
public static ManagedChannel fromCreds ( GoogleCredentials creds , String fields ) throws SSLException { List < ClientInterceptor > interceptors = new ArrayList ( ) ; interceptors . add ( new ClientAuthInterceptor ( creds . createScoped ( Arrays . asList ( GENOMICS_SCOPE ) ) , Executors . newSingleThreadExecutor ( ) ) ) ; if ( ! Strings . isNullOrEmpty ( fields ) ) { Metadata headers = new Metadata ( ) ; Metadata . Key < String > partialResponseHeader = Metadata . Key . of ( PARTIAL_RESPONSE_HEADER , Metadata . ASCII_STRING_MARSHALLER ) ; headers . put ( partialResponseHeader , fields ) ; interceptors . add ( MetadataUtils . newAttachHeadersInterceptor ( headers ) ) ; } return getGenomicsManagedChannel ( interceptors ) ; }
Create a new gRPC channel to the Google Genomics API using the provided credentials for auth .
20,067
public static ManagedChannel fromDefaultCreds ( String fields ) throws SSLException , IOException { return fromCreds ( CredentialFactory . getApplicationDefaultCredentials ( ) , fields ) ; }
Create a new gRPC channel to the Google Genomics API using the application default credentials for auth .
20,068
public static ManagedChannel fromOfflineAuth ( OfflineAuth auth , String fields ) throws IOException , GeneralSecurityException { return fromCreds ( auth . getCredentials ( ) , fields ) ; }
Create a new gRPC channel to the Google Genomics API using either OfflineAuth or the application default credentials .
20,069
public static List < String > getReadGroupSetIds ( String datasetId , OfflineAuth auth ) throws IOException { List < String > output = Lists . newArrayList ( ) ; Genomics genomics = GenomicsFactory . builder ( ) . build ( ) . fromOfflineAuth ( auth ) ; Iterable < ReadGroupSet > rgs = Paginator . ReadGroupSets . create ( genomics ) . search ( new SearchReadGroupSetsRequest ( ) . setDatasetIds ( Lists . newArrayList ( datasetId ) ) , "readGroupSets(id),nextPageToken" ) ; for ( ReadGroupSet r : rgs ) { output . add ( r . getId ( ) ) ; } if ( output . isEmpty ( ) ) { throw new IOException ( "Dataset " + datasetId + " does not contain any ReadGroupSets" ) ; } return output ; }
Gets ReadGroupSetIds from a given datasetId using the Genomics API .
20,070
public static String getReferenceSetId ( String readGroupSetId , OfflineAuth auth ) throws IOException { Genomics genomics = GenomicsFactory . builder ( ) . build ( ) . fromOfflineAuth ( auth ) ; ReadGroupSet readGroupSet = genomics . readgroupsets ( ) . get ( readGroupSetId ) . setFields ( "referenceSetId" ) . execute ( ) ; return readGroupSet . getReferenceSetId ( ) ; }
Gets the ReferenceSetId for a given readGroupSetId using the Genomics API .
20,071
public static List < CoverageBucket > getCoverageBuckets ( String readGroupSetId , OfflineAuth auth ) throws IOException { Genomics genomics = GenomicsFactory . builder ( ) . build ( ) . fromOfflineAuth ( auth ) ; ListCoverageBucketsResponse response = genomics . readgroupsets ( ) . coveragebuckets ( ) . list ( readGroupSetId ) . execute ( ) ; if ( ! Strings . isNullOrEmpty ( response . getNextPageToken ( ) ) ) { throw new IllegalArgumentException ( "Read group set " + readGroupSetId + " has more Coverage Buckets than the default page size for the CoverageBuckets list operation." ) ; } return response . getCoverageBuckets ( ) ; }
Gets the CoverageBuckets for a given readGroupSetId using the Genomics API .
20,072
public static Iterable < Reference > getReferences ( String referenceSetId , OfflineAuth auth ) throws IOException { Genomics genomics = GenomicsFactory . builder ( ) . build ( ) . fromOfflineAuth ( auth ) ; return Paginator . References . create ( genomics ) . search ( new SearchReferencesRequest ( ) . setReferenceSetId ( referenceSetId ) ) ; }
Gets the references for a given referenceSetId using the Genomics API .
20,073
public static List < String > getVariantSetIds ( String datasetId , OfflineAuth auth ) throws IOException { List < String > output = Lists . newArrayList ( ) ; Genomics genomics = GenomicsFactory . builder ( ) . build ( ) . fromOfflineAuth ( auth ) ; Iterable < VariantSet > vs = Paginator . Variantsets . create ( genomics ) . search ( new SearchVariantSetsRequest ( ) . setDatasetIds ( Lists . newArrayList ( datasetId ) ) , "variantSets(id),nextPageToken" ) ; for ( VariantSet v : vs ) { output . add ( v . getId ( ) ) ; } if ( output . isEmpty ( ) ) { throw new IOException ( "Dataset " + datasetId + " does not contain any VariantSets" ) ; } return output ; }
Gets VariantSetIds from a given datasetId using the Genomics API .
20,074
public static Iterable < CallSet > getCallSets ( String variantSetId , OfflineAuth auth ) throws IOException { Genomics genomics = GenomicsFactory . builder ( ) . build ( ) . fromOfflineAuth ( auth ) ; return Paginator . Callsets . create ( genomics ) . search ( new SearchCallSetsRequest ( ) . setVariantSetIds ( Lists . newArrayList ( variantSetId ) ) , "callSets,nextPageToken" ) ; }
Gets CallSets for a given variantSetId using the Genomics API .
20,075
public static List < String > getCallSetsNames ( String variantSetId , OfflineAuth auth ) throws IOException { List < String > output = Lists . newArrayList ( ) ; Genomics genomics = GenomicsFactory . builder ( ) . build ( ) . fromOfflineAuth ( auth ) ; Iterable < CallSet > cs = Paginator . Callsets . create ( genomics ) . search ( new SearchCallSetsRequest ( ) . setVariantSetIds ( Lists . newArrayList ( variantSetId ) ) , "callSets(name),nextPageToken" ) ; for ( CallSet c : cs ) { output . add ( c . getName ( ) ) ; } if ( output . isEmpty ( ) ) { throw new IOException ( "VariantSet " + variantSetId + " does not contain any CallSets" ) ; } return output ; }
Gets CallSets Names for a given variantSetId using the Genomics API .
20,076
public static List < ReferenceBound > getReferenceBounds ( String variantSetId , OfflineAuth auth ) throws IOException { Genomics genomics = GenomicsFactory . builder ( ) . build ( ) . fromOfflineAuth ( auth ) ; VariantSet variantSet = genomics . variantsets ( ) . get ( variantSetId ) . execute ( ) ; return variantSet . getReferenceBounds ( ) ; }
Gets the ReferenceBounds for a given variantSetId using the Genomics API .
20,077
public static Iterable < Contig > parseContigsFromCommandLine ( String contigsArgument ) { return Iterables . transform ( Splitter . on ( "," ) . split ( contigsArgument ) , new Function < String , Contig > ( ) { public Contig apply ( String contigString ) { ArrayList < String > contigInfo = newArrayList ( Splitter . on ( ":" ) . split ( contigString ) ) ; Long start = Long . valueOf ( contigInfo . get ( 1 ) ) ; Long end = Long . valueOf ( contigInfo . get ( 2 ) ) ; Preconditions . checkArgument ( start <= end , "Contig coordinates are incorrectly specified: start " + start + " is greater than end " + end ) ; return new Contig ( contigInfo . get ( 0 ) , start , end ) ; } } ) ; }
Parse the list of Contigs expressed in the string argument .
20,078
List < Contig > getShards ( long numberOfBasesPerShard ) { double shardCount = ( end - start ) / ( double ) numberOfBasesPerShard ; List < Contig > shards = Lists . newArrayList ( ) ; for ( int i = 0 ; i < shardCount ; i ++ ) { long shardStart = start + ( i * numberOfBasesPerShard ) ; long shardEnd = Math . min ( end , shardStart + numberOfBasesPerShard ) ; shards . add ( new Contig ( referenceName , shardStart , shardEnd ) ) ; } return shards ; }
being returned to clients .
20,079
public StreamVariantsRequest getStreamVariantsRequest ( String variantSetId ) { return StreamVariantsRequest . newBuilder ( ) . setVariantSetId ( variantSetId ) . setReferenceName ( referenceName ) . setStart ( start ) . setEnd ( end ) . build ( ) ; }
Construct a StreamVariantsRequest for the Contig .
20,080
public StreamReadsRequest getStreamReadsRequest ( String readGroupSetId ) { return StreamReadsRequest . newBuilder ( ) . setReadGroupSetId ( readGroupSetId ) . setReferenceName ( referenceName ) . setStart ( start ) . setEnd ( end ) . build ( ) ; }
Construct a StreamReadsRequest for the Contig .
20,081
public StreamVariantsRequest getStreamVariantsRequest ( StreamVariantsRequest prototype ) { return StreamVariantsRequest . newBuilder ( prototype ) . setReferenceName ( referenceName ) . setStart ( start ) . setEnd ( end ) . build ( ) ; }
Construct a StreamVariantsRequest for the Contig using a prototype using a prototype request .
20,082
public StreamReadsRequest getStreamReadsRequest ( StreamReadsRequest prototype ) { return StreamReadsRequest . newBuilder ( prototype ) . setReferenceName ( referenceName ) . setStart ( start ) . setEnd ( end ) . build ( ) ; }
Construct a StreamReadsRequest for the Contig using a prototype request .
20,083
public Credential getCredential ( ) { if ( hasStoredCredential ( ) ) { HttpTransport httpTransport ; try { httpTransport = GoogleNetHttpTransport . newTrustedTransport ( ) ; } catch ( IOException | GeneralSecurityException e ) { throw new RuntimeException ( "Could not create HTTPS transport for use in credential creation" , e ) ; } return new GoogleCredential . Builder ( ) . setJsonFactory ( JacksonFactory . getDefaultInstance ( ) ) . setTransport ( httpTransport ) . setClientSecrets ( getClientId ( ) , getClientSecret ( ) ) . build ( ) . setRefreshToken ( getRefreshToken ( ) ) ; } return CredentialFactory . getApplicationDefaultCredential ( ) ; }
Return the stored user credential if applicable or fall back to the Application Default Credential .
20,084
public < T extends AbstractGoogleJsonClient . Builder > T fromApiKey ( T builder , String apiKey ) { Preconditions . checkNotNull ( builder ) ; Preconditions . checkNotNull ( apiKey ) ; return prepareBuilder ( builder , null , new CommonGoogleClientRequestInitializer ( apiKey ) ) ; }
Prepare an AbstractGoogleJsonClient . Builder using an API key .
20,085
public < T extends AbstractGoogleJsonClient . Builder > T fromCredential ( T builder , Credential credential ) { Preconditions . checkNotNull ( builder ) ; Preconditions . checkNotNull ( credential ) ; return prepareBuilder ( builder , credential , null ) ; }
Prepare an AbstractGoogleJsonClient . Builder using a credential .
20,086
public < T extends AbstractGoogleJsonClient . Builder > T fromApplicationDefaultCredential ( T builder ) { Preconditions . checkNotNull ( builder ) ; return fromCredential ( builder , CredentialFactory . getApplicationDefaultCredential ( ) ) ; }
Prepare an AbstractGoogleJsonClient . Builder using the Application Default Credential .
20,087
public Genomics fromOfflineAuth ( OfflineAuth auth ) { Preconditions . checkNotNull ( auth ) ; return fromOfflineAuth ( getGenomicsBuilder ( ) , auth ) . build ( ) ; }
Create a new genomics stub from the given OfflineAuth object .
20,088
public < T extends AbstractGoogleJsonClient . Builder > T fromOfflineAuth ( T builder , OfflineAuth auth ) { Preconditions . checkNotNull ( builder ) ; Preconditions . checkNotNull ( auth ) ; if ( auth . hasApiKey ( ) ) { return fromApiKey ( builder , auth . getApiKey ( ) ) ; } return fromCredential ( builder , auth . getCredential ( ) ) ; }
Prepare an AbstractGoogleJsonClient . Builder with the given OfflineAuth object .
20,089
public static final BiMap < String , String > getCallSetNameMapping ( Iterable < CallSet > callSets ) { BiMap < String , String > idToName = HashBiMap . create ( ) ; for ( CallSet callSet : callSets ) { idToName . put ( callSet . getId ( ) , callSet . getName ( ) ) ; } return idToName . inverse ( ) ; }
Create a bi - directional map of names to ids for a collection of callsets .
20,090
public final Iterable < ItemT > search ( final RequestT request ) { return search ( request , DEFAULT_INITIALIZER , RetryPolicy . defaultPolicy ( ) ) ; }
Search for objects .
20,091
public final < F > F search ( RequestT request , GenomicsRequestInitializer < ? super RequestSubT > initializer , Callback < ItemT , ? extends F > callback , RetryPolicy retryPolicy ) throws IOException { try { return callback . consumeResponses ( search ( request , initializer , retryPolicy ) ) ; } catch ( SearchException e ) { throw e . getCause ( ) ; } }
An exception safe way of consuming search results . Client code supplies a callback which is used to consume the result stream and accumulate a value which becomes the value returned from this method .
20,092
public final Iterable < ItemT > search ( final RequestT request , final String fields ) { return search ( request , setFieldsInitializer ( fields ) , RetryPolicy . defaultPolicy ( ) ) ; }
Search for objects with a partial response .
20,093
public static ImmutableList < StreamReadsRequest > getReadRequests ( final StreamReadsRequest prototype , SexChromosomeFilter sexChromosomeFilter , long numberOfBasesPerShard , OfflineAuth auth ) throws IOException { Iterable < Contig > shards = getAllShardsInReadGroupSet ( prototype . getReadGroupSetId ( ) , sexChromosomeFilter , numberOfBasesPerShard , auth ) ; return FluentIterable . from ( shards ) . transform ( new Function < Contig , StreamReadsRequest > ( ) { public StreamReadsRequest apply ( Contig shard ) { return shard . getStreamReadsRequest ( prototype ) ; } } ) . toList ( ) ; }
Constructs sharded StreamReadsRequest for the all references in the readGroupSet .
20,094
public static ImmutableList < StreamVariantsRequest > getVariantRequests ( final String variantSetId , SexChromosomeFilter sexChromosomeFilter , long numberOfBasesPerShard , OfflineAuth auth ) throws IOException { Iterable < Contig > shards = getAllShardsInVariantSet ( variantSetId , sexChromosomeFilter , numberOfBasesPerShard , auth ) ; return FluentIterable . from ( shards ) . transform ( new Function < Contig , StreamVariantsRequest > ( ) { public StreamVariantsRequest apply ( Contig shard ) { return shard . getStreamVariantsRequest ( variantSetId ) ; } } ) . toList ( ) ; }
Constructs sharded StreamVariantsRequests for the all references in the variantSet .
20,095
public static Predicate < Variant > getStrictVariantPredicate ( final long start , String fields ) { Preconditions . checkArgument ( Strings . isNullOrEmpty ( fields ) || VARIANT_FIELD_PATTERN . matcher ( fields ) . matches ( ) , "Insufficient fields requested in partial response. At a minimum " + "include 'variants(start)' to enforce a strict shard boundary." ) ; return new Predicate < Variant > ( ) { public boolean apply ( Variant variant ) { return variant . getStart ( ) >= start ; } } ; }
Predicate expressing the logic for which variants should and should not be included in the shard .
20,096
public static Predicate < Read > getStrictReadPredicate ( final long start , final String fields ) { Preconditions . checkArgument ( Strings . isNullOrEmpty ( fields ) || READ_FIELD_PATTERN . matcher ( fields ) . matches ( ) , "Insufficient fields requested in partial response. At a minimum " + "include 'alignments(alignment)' to enforce a strict shard boundary." ) ; return new Predicate < Read > ( ) { public boolean apply ( Read read ) { return read . getAlignment ( ) . getPosition ( ) . getPosition ( ) >= start ; } } ; }
Predicate expressing the logic for which reads should and should not be included in the shard .
20,097
private static AmazonWebServiceRequest generateRequest ( ActionContext context , Class < ? > type , RequestModel model , AmazonWebServiceRequest request , Object token ) throws InstantiationException , IllegalAccessException { if ( request == null ) { request = ( AmazonWebServiceRequest ) type . newInstance ( ) ; } request . getRequestClientOptions ( ) . appendUserAgent ( USER_AGENT ) ; for ( PathTargetMapping mapping : model . getIdentifierMappings ( ) ) { Object value = context . getIdentifier ( mapping . getSource ( ) ) ; if ( value == null ) { throw new IllegalStateException ( "Action has a mapping for identifier " + mapping . getSource ( ) + ", but the target has no " + "identifier of that name!" ) ; } ReflectionUtils . setByPath ( request , value , mapping . getTarget ( ) ) ; } for ( PathTargetMapping mapping : model . getAttributeMappings ( ) ) { Object value = context . getAttribute ( mapping . getSource ( ) ) ; if ( value == null ) { throw new IllegalStateException ( "Action has a mapping for attribute " + mapping . getSource ( ) + ", but the target has no " + "attribute of that name!" ) ; } ReflectionUtils . setByPath ( request , value , mapping . getTarget ( ) ) ; } for ( PathTargetMapping mapping : model . getConstantMappings ( ) ) { ReflectionUtils . setByPath ( request , mapping . getSource ( ) , mapping . getTarget ( ) ) ; } if ( token != null ) { List < String > tokenPath = model . getTokenPath ( ) ; if ( tokenPath == null ) { throw new IllegalArgumentException ( "Cannot pass a token with a null token path" ) ; } ReflectionUtils . setByPath ( request , token , tokenPath ) ; } return request ; }
Generates a client - level request by extracting the user parameters ( if
20,098
public static Object getByPath ( Object target , List < String > path ) { Object obj = target ; for ( String field : path ) { if ( obj == null ) { return null ; } obj = evaluate ( obj , trimType ( field ) ) ; } return obj ; }
Evaluates the given path expression on the given object and returns the object found .
20,099
public static List < Object > getAllByPath ( Object target , List < String > path ) { List < Object > results = new LinkedList < > ( ) ; getAllByPath ( target , path , 0 , results ) ; return results ; }
Evaluates the given path expression and returns the list of all matching objects . If the path expression does not contain any wildcards this will return a list of at most one item . If the path contains one or more wildcards the returned list will include the full set of values obtained by evaluating the expression with all legal value for the given wildcard .