idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
19,900 | public int log4j_to_tango_level ( Level level ) { if ( level . equals ( Level . OFF ) ) { return LOGGING_OFF ; } if ( level . equals ( Level . FATAL ) ) { return LOGGING_FATAL ; } if ( level . equals ( Level . ERROR ) ) { return LOGGING_ERROR ; } if ( level . equals ( Level . WARN ) ) { return LOGGING_WARN ; } if ( level . equals ( Level . INFO ) ) { return LOGGING_INFO ; } return LOGGING_DEBUG ; } | Given to log4j logging level converts it to TANGO level |
19,901 | public void set_rolling_file_threshold ( Logger logger , long rft ) { if ( logger == null ) { return ; } if ( rft < LOGGING_MIN_RFT ) { rft = LOGGING_MIN_RFT ; } else if ( rft > LOGGING_MAX_RFT ) { rft = LOGGING_MAX_RFT ; } String prefix = LOGGING_FILE_TARGET + LOGGING_SEPARATOR ; Enumeration all_appenders = logger . getAllAppenders ( ) ; while ( all_appenders . hasMoreElements ( ) ) { Appender appender = ( Appender ) all_appenders . nextElement ( ) ; if ( appender . getName ( ) . indexOf ( prefix ) != - 1 ) { TangoRollingFileAppender trfa = ( TangoRollingFileAppender ) appender ; trfa . setMaximumFileSize ( rft * 1024 ) ; } } } | Set the specified logger s rolling threshold |
19,902 | public void addAttribute ( final IAttributeBehavior behavior ) throws DevFailed { final AttributeConfiguration configuration = behavior . getConfiguration ( ) ; final String attributeName = configuration . getName ( ) ; xlogger . entry ( "adding dynamic attribute {}" , attributeName ) ; if ( behavior instanceof ForwardedAttribute ) { final ForwardedAttribute att = ( ForwardedAttribute ) behavior ; final String deviceName = deviceImpl . getName ( ) ; final String rootAttributeName = behavior . getConfiguration ( ) . getAttributeProperties ( ) . loadAttributeRootName ( deviceName , attributeName ) ; if ( rootAttributeName == null || rootAttributeName . isEmpty ( ) || rootAttributeName . equalsIgnoreCase ( Constants . NOT_SPECIFIED ) ) { att . init ( deviceName ) ; behavior . getConfiguration ( ) . getAttributeProperties ( ) . persistAttributeRootName ( deviceName , attributeName ) ; } else { att . init ( deviceName , rootAttributeName ) ; } final String lower = att . getRootName ( ) . toLowerCase ( Locale . ENGLISH ) ; if ( forwardedAttributes . contains ( lower ) ) { throw DevFailedUtils . newDevFailed ( ExceptionMessages . FWD_DOUBLE_USED , "root attribute already used in this device" ) ; } else { forwardedAttributes . add ( lower ) ; } } else { final AttributePropertiesImpl prop = configuration . getAttributeProperties ( ) ; if ( prop . getLabel ( ) . isEmpty ( ) ) { prop . setLabel ( configuration . getName ( ) ) ; } if ( prop . getFormat ( ) . equals ( Constants . NOT_SPECIFIED ) ) { prop . setDefaultFormat ( configuration . getScalarType ( ) ) ; } } final AttributeImpl attrImpl = new AttributeImpl ( behavior , deviceImpl . getName ( ) ) ; attrImpl . setStateMachine ( behavior . getStateMachine ( ) ) ; deviceImpl . addAttribute ( attrImpl ) ; dynamicAttributes . put ( attributeName . toLowerCase ( Locale . ENGLISH ) , attrImpl ) ; deviceImpl . pushInterfaceChangeEvent ( false ) ; if ( configuration . isPolled ( ) && configuration . getPollingPeriod ( ) > 0 ) { deviceImpl . addAttributePolling ( attributeName , configuration . getPollingPeriod ( ) ) ; } xlogger . exit ( ) ; } | Add attribute . Only if not already exists on device . |
19,903 | public void clearAttributesWithExclude ( final String ... exclude ) throws DevFailed { final String [ ] toExclude = new String [ exclude . length ] ; for ( int i = 0 ; i < toExclude . length ; i ++ ) { toExclude [ i ] = exclude [ i ] . toLowerCase ( Locale . ENGLISH ) ; } for ( final String attributeName : dynamicAttributes . keySet ( ) ) { if ( ! ArrayUtils . contains ( toExclude , attributeName ) ) { removeAttribute ( attributeName ) ; } } } | Remove all dynamic attributes with exceptions |
19,904 | public void clearAttributes ( ) throws DevFailed { for ( final AttributeImpl attributeImpl : dynamicAttributes . values ( ) ) { deviceImpl . removeAttribute ( attributeImpl ) ; } forwardedAttributes . clear ( ) ; dynamicAttributes . clear ( ) ; } | Remove all dynamic attributes |
19,905 | public List < IAttributeBehavior > getDynamicAttributes ( ) { final List < IAttributeBehavior > result = new ArrayList < IAttributeBehavior > ( ) ; for ( final AttributeImpl attributeImpl : dynamicAttributes . values ( ) ) { result . add ( attributeImpl . getBehavior ( ) ) ; } return result ; } | Retrieve all dynamic attributes |
19,906 | public IAttributeBehavior getAttribute ( final String attributeName ) { AttributeImpl attr = dynamicAttributes . get ( attributeName . toLowerCase ( Locale . ENGLISH ) ) ; if ( attr == null ) return null ; else return attr . getBehavior ( ) ; } | Get a dynamic attribute |
19,907 | public void addCommand ( final ICommandBehavior behavior ) throws DevFailed { final String cmdName = behavior . getConfiguration ( ) . getName ( ) ; xlogger . entry ( "adding dynamic command {}" , cmdName ) ; final CommandImpl commandImpl = new CommandImpl ( behavior , deviceImpl . getName ( ) ) ; commandImpl . setStateMachine ( behavior . getStateMachine ( ) ) ; deviceImpl . addCommand ( commandImpl ) ; dynamicCommands . put ( cmdName . toLowerCase ( Locale . ENGLISH ) , commandImpl ) ; deviceImpl . pushInterfaceChangeEvent ( false ) ; xlogger . exit ( ) ; } | Add command . Only if not already exists on device |
19,908 | public ICommandBehavior getCommand ( final String commandName ) { return dynamicCommands . get ( commandName . toLowerCase ( Locale . ENGLISH ) ) . getBehavior ( ) ; } | Get a dynamic command |
19,909 | public void clearCommands ( ) throws DevFailed { for ( final CommandImpl cmdImpl : dynamicCommands . values ( ) ) { deviceImpl . removeCommand ( cmdImpl ) ; } dynamicCommands . clear ( ) ; } | Remove all dynamic commands |
19,910 | public void clearCommandsWithExclude ( final String ... exclude ) throws DevFailed { final String [ ] toExclude = new String [ exclude . length ] ; for ( int i = 0 ; i < toExclude . length ; i ++ ) { toExclude [ i ] = exclude [ i ] . toLowerCase ( Locale . ENGLISH ) ; } for ( final String cmdName : dynamicCommands . keySet ( ) ) { if ( ! ArrayUtils . contains ( toExclude , cmdName ) ) { removeCommand ( cmdName ) ; } } } | Remove all dynamic command with exceptions |
19,911 | public List < ICommandBehavior > getDynamicCommands ( ) { final List < ICommandBehavior > result = new ArrayList < ICommandBehavior > ( ) ; for ( final CommandImpl cmdImpl : dynamicCommands . values ( ) ) { result . add ( cmdImpl . getBehavior ( ) ) ; } return result ; } | Retrieve all dynamic commands |
19,912 | public void write ( final Object value ) throws DevFailed { initDeviceAttributes ( ) ; for ( final DeviceAttribute deviceAttribute : deviceAttributes ) { if ( deviceAttribute != null ) { InsertExtractUtils . insert ( deviceAttribute , value ) ; } } group . write ( deviceAttributes ) ; } | Write a value on several attributes |
19,913 | public Object [ ] readExtract ( ) throws DevFailed { final DeviceAttribute [ ] da = read ( ) ; final Object [ ] results = extract ( da ) ; return results ; } | Read attributes and extract their values |
19,914 | public static synchronized ITangoDB getDatabase ( final String host , final String port ) throws DevFailed { final ITangoDB dbase ; if ( useDb ) { final String tangoHost = host + ":" + port ; if ( databaseMap . containsKey ( tangoHost ) ) { return databaseMap . get ( tangoHost ) ; } dbase = new Database ( host , port ) ; databaseMap . put ( tangoHost , dbase ) ; } else { dbase = fileDatabase ; } return dbase ; } | Get the database object created for specified host and port . |
19,915 | public static synchronized ITangoDB getDatabase ( ) throws DevFailed { ITangoDB tangoDb = null ; if ( useDb ) { final String tangoHost = TangoHostManager . getFirstTangoHost ( ) ; if ( databaseMap . containsKey ( tangoHost ) ) { tangoDb = databaseMap . get ( tangoHost ) ; } else { DevFailed lastError = null ; final Map < String , String > tangoHostMap = TangoHostManager . getTangoHostPortMap ( ) ; for ( final Entry < String , String > entry : tangoHostMap . entrySet ( ) ) { try { lastError = null ; tangoDb = new Database ( entry . getKey ( ) , entry . getValue ( ) ) ; databaseMap . put ( tangoHost , tangoDb ) ; break ; } catch ( final DevFailed e ) { lastError = e ; } } if ( lastError != null ) { throw lastError ; } } } else { tangoDb = fileDatabase ; } return tangoDb ; } | Get the database object using tango_host system property . |
19,916 | public static void setDbFile ( final File dbFile , final String [ ] devices , final String className ) throws DevFailed { DatabaseFactory . useDb = false ; DatabaseFactory . fileDatabase = new FileTangoDB ( dbFile , Arrays . copyOf ( devices , devices . length ) , className ) ; } | Build a mock tango db with a file containing the properties |
19,917 | public static void setNoDbDevices ( final String [ ] devices , final String className ) { DatabaseFactory . useDb = false ; DatabaseFactory . fileDatabase = new FileTangoDB ( Arrays . copyOf ( devices , devices . length ) , className ) ; } | Build a mock tango db |
19,918 | public static Object extract ( final DeviceAttribute da ) throws DevFailed { if ( da == null ) { throw DevFailedUtils . newDevFailed ( ERROR_MSG_DA ) ; } return InsertExtractFactory . getAttributeExtractor ( da . getType ( ) ) . extract ( da ) ; } | Extract read and write part values to an object for SCALAR SPECTRUM and IMAGE |
19,919 | public static Object extractRead ( final DeviceAttribute da , final AttrDataFormat format ) throws DevFailed { if ( da == null ) { throw DevFailedUtils . newDevFailed ( ERROR_MSG_DA ) ; } return InsertExtractFactory . getAttributeExtractor ( da . getType ( ) ) . extractRead ( da , format ) ; } | Extract read values to an object for SCALAR SPECTRUM and IMAGE |
19,920 | public static Object extractWriteArray ( final DeviceAttribute da , final AttrWriteType writeType , final AttrDataFormat format ) throws DevFailed { if ( da == null ) { throw DevFailedUtils . newDevFailed ( ERROR_MSG_DA ) ; } return InsertExtractFactory . getAttributeExtractor ( da . getType ( ) ) . extractWriteArray ( da , writeType , format ) ; } | Extract write values to an object for SCALAR SPECTRUM and IMAGE |
19,921 | public static < T > T extract ( final DeviceAttribute da , final Class < T > type ) throws DevFailed { if ( da == null ) { throw DevFailedUtils . newDevFailed ( ERROR_MSG_DA ) ; } return TypeConversionUtil . castToType ( type , extract ( da ) ) ; } | Extract read and write part values to an object for SCALAR SPECTRUM and IMAGE to the requested type |
19,922 | public static < T > T extractRead ( final DeviceAttribute da , final AttrDataFormat format , final Class < T > type ) throws DevFailed { if ( da == null ) { throw DevFailedUtils . newDevFailed ( ERROR_MSG_DA ) ; } return TypeConversionUtil . castToType ( type , extractRead ( da , format ) ) ; } | Extract read part values to an object for SCALAR SPECTRUM and IMAGE to the requested type |
19,923 | public static < T > T extractWrite ( final DeviceAttribute da , final AttrDataFormat format , final AttrWriteType writeType , final Class < T > type ) throws DevFailed { if ( da == null ) { throw DevFailedUtils . newDevFailed ( ERROR_MSG_DA ) ; } return TypeConversionUtil . castToType ( type , extractWrite ( da , writeType , format ) ) ; } | Extract write part values to an object for SCALAR SPECTRUM and IMAGE to the requested type |
19,924 | public static DServerClass instance ( ) { if ( _instance == null ) { System . err . println ( "DServerClass is not initialised !!!" ) ; System . err . println ( "Exiting" ) ; System . exit ( - 1 ) ; } return _instance ; } | Get the singleton object reference . |
19,925 | public void command_factory ( ) { command_list . addElement ( new DevRestartCmd ( "DevRestart" , Tango_DEV_STRING , Tango_DEV_VOID , "Device name" ) ) ; command_list . addElement ( new RestartServerCmd ( "RestartServer" , Tango_DEV_VOID , Tango_DEV_VOID ) ) ; command_list . addElement ( new QueryClassCmd ( "QueryClass" , Tango_DEV_VOID , Tango_DEVVAR_STRINGARRAY , "Device server class(es) list" ) ) ; command_list . addElement ( new QueryDeviceCmd ( "QueryDevice" , Tango_DEV_VOID , Tango_DEVVAR_STRINGARRAY , "Device server device(s) list" ) ) ; command_list . addElement ( new KillCmd ( "Kill" , Tango_DEV_VOID , Tango_DEV_VOID ) ) ; command_list . addElement ( new AddLoggingTargetCmd ( "AddLoggingTarget" , Tango_DEVVAR_STRINGARRAY , Tango_DEV_VOID , "Str[i]=Device-name - Str[i+1]=target_type::target_name" ) ) ; command_list . addElement ( new RemoveLoggingTargetCmd ( "RemoveLoggingTarget" , Tango_DEVVAR_STRINGARRAY , Tango_DEV_VOID , "Str[i]=Device-name - Str[i+1]=target_type::target_name" ) ) ; command_list . addElement ( new GetLoggingTargetCmd ( "GetLoggingTarget" , Tango_DEV_STRING , Tango_DEVVAR_STRINGARRAY , "Device name" , "Logging target list" ) ) ; command_list . addElement ( new SetLoggingLevelCmd ( "SetLoggingLevel" , Tango_DEVVAR_LONGSTRINGARRAY , Tango_DEV_VOID , "Lg[i]=Logging level. Str[i]=Device name." ) ) ; command_list . addElement ( new GetLoggingLevelCmd ( "GetLoggingLevel" , Tango_DEVVAR_STRINGARRAY , Tango_DEVVAR_LONGSTRINGARRAY , "Device list" , "Lg[i]=Logging level. Str[i]=Device name." ) ) ; command_list . addElement ( new StopLoggingCmd ( "StopLogging" , Tango_DEV_VOID , Tango_DEV_VOID ) ) ; command_list . addElement ( new StartLoggingCmd ( "StartLogging" , Tango_DEV_VOID , Tango_DEV_VOID ) ) ; command_list . addElement ( new PolledDeviceCmd ( "PolledDevice" , Tango_DEV_VOID , Tango_DEVVAR_STRINGARRAY , "Polled device name list" ) ) ; command_list . addElement ( new DevPollStatusCmd ( "DevPollStatus" , Tango_DEV_STRING , Tango_DEVVAR_STRINGARRAY , "Device name" , "Device polling status" ) ) ; String msg = "Lg[0]=Upd period. Str[0]=Device name. Str[1]=Object type. Str[2]=Object name" ; command_list . addElement ( new AddObjPollingCmd ( "AddObjPolling" , Tango_DEVVAR_LONGSTRINGARRAY , Tango_DEV_VOID , msg ) ) ; command_list . addElement ( new UpdObjPollingPeriodCmd ( "UpdObjPollingPeriod" , Tango_DEVVAR_LONGSTRINGARRAY , Tango_DEV_VOID , msg ) ) ; msg = "Lg[0]=Upd period. Str[0]=Device name. Str[1]=Object type. Str[2]=Object name" ; command_list . addElement ( new RemObjPollingCmd ( "RemObjPolling" , Tango_DEVVAR_STRINGARRAY , Tango_DEV_VOID , msg ) ) ; command_list . addElement ( new StopPollingCmd ( "StopPolling" , Tango_DEV_VOID , Tango_DEV_VOID ) ) ; command_list . addElement ( new StartPollingCmd ( "StartPolling" , Tango_DEV_VOID , Tango_DEV_VOID ) ) ; } | Create DServerClass commands . |
19,926 | public void device_factory ( String [ ] devlist ) throws DevFailed { Util . out4 . println ( "DServerClass::device_factory() arrived" ) ; for ( int i = 0 ; i < devlist . length ; i ++ ) { Util . out4 . println ( "Device name : " + devlist [ i ] ) ; device_list . addElement ( new DServer ( this , devlist [ i ] , "A device server device !!" , DevState . ON , "The device is ON" ) ) ; Util . out4 . println ( "Util._UseDb = " + Util . _UseDb ) ; if ( Util . _UseDb == true ) export_device ( ( ( DeviceImpl ) ( device_list . elementAt ( i ) ) ) ) ; else export_device ( ( ( DeviceImpl ) ( device_list . elementAt ( i ) ) ) , devlist [ i ] ) ; } } | Create and export device of the DServer class . |
19,927 | public String [ ] getDeviceList ( final String serverName , final String className ) { String [ ] result = new String [ 0 ] ; final Server server = servers . get ( serverName ) ; if ( server != null ) { final String [ ] devices = server . getDevices ( className ) ; if ( devices != null ) { result = Arrays . copyOf ( devices , devices . length ) ; } } return result ; } | Get devices of a server |
19,928 | public void build ( final Class < ? > clazz , final Field field , final DeviceImpl device , final Object businessObject ) throws DevFailed { xlogger . entry ( ) ; BuilderUtils . checkStatic ( field ) ; Method getter ; final String stateName = field . getName ( ) ; final String getterName = BuilderUtils . GET + stateName . substring ( 0 , 1 ) . toUpperCase ( Locale . ENGLISH ) + stateName . substring ( 1 ) ; try { getter = clazz . getMethod ( getterName ) ; } catch ( final NoSuchMethodException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } if ( getter . getParameterTypes ( ) . length != 0 ) { throw DevFailedUtils . newDevFailed ( DevFailedUtils . TANGO_BUILD_FAILED , getter + " must not have a parameter" ) ; } logger . debug ( "Has an state : {}" , field . getName ( ) ) ; if ( getter . getReturnType ( ) != DeviceState . class && getter . getReturnType ( ) != DevState . class ) { throw DevFailedUtils . newDevFailed ( DevFailedUtils . TANGO_BUILD_FAILED , getter + " must have a return type of " + DeviceState . class . getCanonicalName ( ) + " or " + DevState . class . getCanonicalName ( ) ) ; } Method setter ; final String setterName = BuilderUtils . SET + stateName . substring ( 0 , 1 ) . toUpperCase ( Locale . ENGLISH ) + stateName . substring ( 1 ) ; try { setter = clazz . getMethod ( setterName , DeviceState . class ) ; } catch ( final NoSuchMethodException e ) { try { setter = clazz . getMethod ( setterName , DevState . class ) ; } catch ( final NoSuchMethodException e1 ) { throw DevFailedUtils . newDevFailed ( e1 ) ; } } device . setStateImpl ( new StateImpl ( businessObject , getter , setter ) ) ; final State annot = field . getAnnotation ( State . class ) ; if ( annot . isPolled ( ) ) { device . addAttributePolling ( DeviceImpl . STATE_NAME , annot . pollingPeriod ( ) ) ; } xlogger . exit ( ) ; } | Create a state |
19,929 | public AttributePropertiesImpl getAttributeProperties ( final String attributeName ) throws DevFailed { final AttributeImpl attr = AttributeGetterSetter . getAttribute ( attributeName , device . getAttributeList ( ) ) ; return attr . getProperties ( ) ; } | Get an attribute s properties |
19,930 | public void setAttributeProperties ( final String attributeName , final AttributePropertiesImpl properties ) throws DevFailed { final AttributeImpl attr = AttributeGetterSetter . getAttribute ( attributeName , device . getAttributeList ( ) ) ; attr . setProperties ( properties ) ; } | Configure an attribute s properties |
19,931 | public void removeAttributeProperties ( final String attributeName ) throws DevFailed { final AttributeImpl attr = AttributeGetterSetter . getAttribute ( attributeName , device . getAttributeList ( ) ) ; attr . removeProperties ( ) ; } | Remove an attribute s properties |
19,932 | public boolean isPolled ( final String polledObject ) throws DevFailed { try { return AttributeGetterSetter . getAttribute ( polledObject , device . getAttributeList ( ) ) . isPolled ( ) ; } catch ( final DevFailed e ) { return device . getCommand ( polledObject ) . isPolled ( ) ; } } | Check if an attribute or an command is polled |
19,933 | public int getPollingPeriod ( final String polledObject ) throws DevFailed { try { return AttributeGetterSetter . getAttribute ( polledObject , device . getAttributeList ( ) ) . getPollingPeriod ( ) ; } catch ( final DevFailed e ) { return device . getCommand ( polledObject ) . getPollingPeriod ( ) ; } } | Get polling period of an attribute or a command |
19,934 | public void startPolling ( final String polledObject , final int pollingPeriod ) throws DevFailed { try { final AttributeImpl attr = AttributeGetterSetter . getAttribute ( polledObject , device . getAttributeList ( ) ) ; attr . configurePolling ( pollingPeriod ) ; device . startPolling ( attr ) ; } catch ( final DevFailed e ) { if ( polledObject . equalsIgnoreCase ( DeviceImpl . STATE_NAME ) || polledObject . equalsIgnoreCase ( DeviceImpl . STATUS_NAME ) ) { final CommandImpl cmd = device . getCommand ( polledObject ) ; cmd . configurePolling ( pollingPeriod ) ; device . startPolling ( cmd ) ; } else { throw e ; } } } | Configure polling of an attribute or a command and start it |
19,935 | public void pushEvent ( final String attributeName , final AttributeValue value , final EventType eventType ) throws DevFailed { switch ( eventType ) { case CHANGE_EVENT : case ARCHIVE_EVENT : case USER_EVENT : final AttributeImpl attribute = AttributeGetterSetter . getAttribute ( attributeName , device . getAttributeList ( ) ) ; attribute . lock ( ) ; try { attribute . updateValue ( value ) ; EventManager . getInstance ( ) . pushAttributeValueEvent ( name , attributeName , eventType ) ; } catch ( final DevFailed e ) { EventManager . getInstance ( ) . pushAttributeErrorEvent ( name , attributeName , e ) ; } finally { attribute . unlock ( ) ; } break ; default : throw DevFailedUtils . newDevFailed ( "Only USER, ARCHIVE or CHANGE event can be send" ) ; } } | Push an event if some client had register it . |
19,936 | public void pushDataReadyEvent ( final String attributeName , final int counter ) throws DevFailed { EventManager . getInstance ( ) . pushAttributeDataReadyEvent ( name , attributeName , counter ) ; } | Push a DATA_READY event if some client had registered it |
19,937 | public void pushPipeEvent ( final String pipeName , final PipeValue blob ) throws DevFailed { final PipeImpl pipe = DeviceImpl . getPipe ( pipeName , device . getPipeList ( ) ) ; try { pipe . updateValue ( blob ) ; EventManager . getInstance ( ) . pushPipeEvent ( name , pipeName , blob ) ; } catch ( final DevFailed e ) { EventManager . getInstance ( ) . pushPipeEvent ( name , pipeName , e ) ; } } | Push a PIPE EVENT event if some client had registered it |
19,938 | public void execute ( ) throws DevFailed { GroupCmdReplyList replies ; if ( isArginVoid ( ) ) { replies = group . command_inout ( commandName , true ) ; } else { replies = group . command_inout ( commandName , inData , true ) ; } if ( replies . has_failed ( ) ) { for ( final Object obj : replies ) { ( ( GroupCmdReply ) obj ) . get_data ( ) ; } } } | Execute the command on a single device or on a group If group is used the return data is not managed for the moment . |
19,939 | public void insert ( final Object value ) throws DevFailed { for ( int i = 0 ; i < group . get_size ( true ) ; i ++ ) { final int arginType = group . get_device ( i + 1 ) . command_query ( commandName ) . in_type ; InsertExtractUtils . insert ( inData [ i ] , arginType , value ) ; } } | insert a single value for all commands |
19,940 | public void insert ( final Object ... value ) throws DevFailed { if ( value . length == 1 ) { for ( int i = 0 ; i < group . get_size ( true ) ; i ++ ) { final int arginType = group . get_device ( i + 1 ) . command_query ( commandName ) . in_type ; InsertExtractUtils . insert ( inData [ i ] , arginType , value ) ; } } else { if ( value . length != group . get_size ( true ) ) { throw DevFailedUtils . newDevFailed ( TANGO_WRONG_DATA_ERROR , group . get_size ( true ) + " values must be provided" ) ; } for ( int i = 0 ; i < group . get_size ( true ) ; i ++ ) { final int arginType = group . get_device ( i + 1 ) . command_query ( commandName ) . in_type ; InsertExtractUtils . insert ( inData [ i ] , arginType , value [ i ] ) ; } } } | insert a value per command |
19,941 | public static CommandImpl getCommand ( final String name , final List < CommandImpl > commandList ) throws DevFailed { CommandImpl result = null ; for ( final CommandImpl command : commandList ) { if ( command . getName ( ) . equalsIgnoreCase ( name ) ) { result = command ; break ; } } if ( result == null ) { throw DevFailedUtils . newDevFailed ( ExceptionMessages . COMMAND_NOT_FOUND , "Command " + name + " not found" ) ; } return result ; } | Get a command |
19,942 | public void set_default_properties ( UserDefaultAttrProp prop_list ) { if ( prop_list . label != null ) user_default_properties . addElement ( new AttrProperty ( "label" , prop_list . label ) ) ; if ( prop_list . description != null ) user_default_properties . addElement ( new AttrProperty ( "description" , prop_list . description ) ) ; if ( prop_list . unit != null ) user_default_properties . addElement ( new AttrProperty ( "unit" , prop_list . unit ) ) ; if ( prop_list . standard_unit != null ) user_default_properties . addElement ( new AttrProperty ( "standard_unit" , prop_list . standard_unit ) ) ; if ( prop_list . display_unit != null ) user_default_properties . addElement ( new AttrProperty ( "display_unit" , prop_list . display_unit ) ) ; if ( prop_list . format != null ) user_default_properties . addElement ( new AttrProperty ( "format" , prop_list . format ) ) ; if ( prop_list . min_value != null ) user_default_properties . addElement ( new AttrProperty ( "min_value" , prop_list . min_value ) ) ; if ( prop_list . max_value != null ) user_default_properties . addElement ( new AttrProperty ( "max_value" , prop_list . max_value ) ) ; if ( prop_list . min_alarm != null ) user_default_properties . addElement ( new AttrProperty ( "min_alarm" , prop_list . min_alarm ) ) ; if ( prop_list . max_alarm != null ) user_default_properties . addElement ( new AttrProperty ( "max_alarm" , prop_list . max_alarm ) ) ; } | Set the attribute user default properties . |
19,943 | public T execute ( final Task < T > taskToWrap ) throws DevFailed { int triesLeft = tries ; do { try { return taskToWrap . call ( ) ; } catch ( final DevFailed e ) { triesLeft -- ; if ( triesLeft <= 0 ) { logger . error ( "Caught exception, all retries done for error: {}" , DevFailedUtils . toString ( e ) ) ; throw e ; } logger . info ( "Caught exception, retrying... Error was: {}" + DevFailedUtils . toString ( e ) ) ; try { Thread . sleep ( delay ) ; } catch ( final InterruptedException e1 ) { } } } while ( triesLeft > 0 ) ; return null ; } | Invokes the wrapped Callable s call method optionally retrying if an exception occurs . See class documentation for more detail . |
19,944 | public static void updatePollingConfigFromDB ( final PolledObjectConfig config , final AttributePropertiesManager attributePropertiesManager ) throws DevFailed { final String isPolledProp = attributePropertiesManager . getAttributePropertyFromDB ( config . getName ( ) , Constants . IS_POLLED ) ; if ( ! isPolledProp . isEmpty ( ) ) { config . setPolled ( Boolean . valueOf ( isPolledProp ) ) ; final String periodProp = attributePropertiesManager . getAttributePropertyFromDB ( config . getName ( ) , Constants . POLLING_PERIOD ) ; if ( ! periodProp . isEmpty ( ) ) { config . setPollingPeriod ( Integer . valueOf ( periodProp ) ) ; } } } | Update polling config in tango db |
19,945 | public void updateValue ( ) throws DevFailed { xlogger . entry ( getName ( ) ) ; if ( ! config . getWritable ( ) . equals ( AttrWriteType . READ ) && behavior instanceof ISetValueUpdater ) { try { final AttributeValue setValue = ( ( ISetValueUpdater ) behavior ) . getSetValue ( ) ; if ( setValue != null ) { writeValue = ( AttributeValue ) ( ( ISetValueUpdater ) behavior ) . getSetValue ( ) . clone ( ) ; writeValue . setValueWithoutDim ( ArrayUtils . from2DArrayToArray ( writeValue . getValue ( ) ) ) ; } else { writeValue = null ; } } catch ( final CloneNotSupportedException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } } if ( config . getWritable ( ) . equals ( AttrWriteType . WRITE ) ) { if ( writeValue == null ) { readValue = new AttributeValue ( ) ; readValue . setValue ( AttributeTangoType . getDefaultValue ( config . getType ( ) ) ) ; } else { readValue = writeValue ; } } else { final AttributeValue returnedValue = behavior . getValue ( ) ; this . updateValue ( returnedValue ) ; } xlogger . exit ( getName ( ) ) ; } | read attribute on device |
19,946 | public void updateValue ( final AttributeValue inValue ) throws DevFailed { xlogger . entry ( getName ( ) ) ; if ( inValue == null ) { throw DevFailedUtils . newDevFailed ( ExceptionMessages . ATTR_VALUE_NOT_SET , name + " read value has not been updated" ) ; } try { readValue = ( AttributeValue ) inValue . clone ( ) ; } catch ( final CloneNotSupportedException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } if ( readValue . getValue ( ) != null && ! readValue . getQuality ( ) . equals ( AttrQuality . ATTR_INVALID ) ) { updateQuality ( readValue ) ; } try { if ( readValue . getValue ( ) != null ) { checkUpdateErrors ( readValue ) ; readValue . setValueWithoutDim ( ArrayUtils . from2DArrayToArray ( readValue . getValue ( ) ) ) ; TangoIDLAttributeUtil . toAttributeValue5 ( this , readValue , null ) ; } else { throw DevFailedUtils . newDevFailed ( ExceptionMessages . ATTR_VALUE_NOT_SET , name + " read value has not been updated" ) ; } updateDefaultWritePart ( ) ; } catch ( final DevFailed e ) { readValue . setXDim ( 0 ) ; readValue . setYDim ( 0 ) ; lastError = e ; throw e ; } xlogger . exit ( getName ( ) ) ; } | set the read value |
19,947 | public void setProperties ( final AttributePropertiesImpl properties ) throws DevFailed { if ( isMemorized ( ) ) { Object memorizedValue = getMemorizedValue ( ) ; if ( memorizedValue != null && memorizedValue . getClass ( ) . isAssignableFrom ( Number . class ) ) { final double memoValue = Double . parseDouble ( memorizedValue . toString ( ) ) ; if ( properties . getMaxValueDouble ( ) < memoValue || properties . getMinValueDouble ( ) > memoValue ) { throw DevFailedUtils . newDevFailed ( "min or max value not possible for current memorized value" ) ; } } } config . setAttributeProperties ( properties ) ; if ( isFwdAttribute ) { final ForwardedAttribute fwdAttr = ( ForwardedAttribute ) behavior ; properties . setRootAttribute ( fwdAttr . getRootName ( ) ) ; fwdAttr . setAttributeConfiguration ( config ) ; } config . persist ( deviceName ) ; EventManager . getInstance ( ) . pushAttributeConfigEvent ( deviceName , name ) ; } | Set the attribute properties . |
19,948 | private Map < String , String [ ] > extractArgout ( final String [ ] result , final int startingPoint ) { final Map < String , String [ ] > map = new CaseInsensitiveMap < String [ ] > ( ) ; if ( result . length > 4 ) { int i = startingPoint ; int nextSize = Integer . valueOf ( result [ i + 1 ] ) ; while ( i < result . length ) { if ( nextSize > 0 ) { final String name = result [ i ] . toLowerCase ( Locale . ENGLISH ) ; final String [ ] propValues = Arrays . copyOfRange ( result , i + 2 , nextSize + i + 2 ) ; map . put ( name , propValues ) ; } final int idxNextPropSize ; if ( nextSize == 0 ) { idxNextPropSize = i + 4 ; i = i + 3 ; } else { idxNextPropSize = nextSize + i + 3 ; i = nextSize + i + 2 ; } if ( idxNextPropSize >= result . length ) { break ; } nextSize = Integer . valueOf ( result [ idxNextPropSize ] ) ; } } return map ; } | Return a map of properties with name as key and value as entry |
19,949 | public Any execute ( DeviceImpl device , Any in_any ) throws DevFailed { Util . out4 . println ( "RemoveLoggingTargetCmd::execute(): arrived" ) ; String [ ] dvsa = null ; try { dvsa = extract_DevVarStringArray ( in_any ) ; } catch ( DevFailed df ) { Util . out3 . println ( "RemoveLoggingTargetCmd::execute() ) ; Except . re_throw_exception ( df , "API_IncompatibleCmdArgumentType" , "Imcompatible command argument type, expected type is : DevVarStringArray" , "RemoveLoggingTargetCmd.execute" ) ; } Logging . instance ( ) . remove_logging_target ( dvsa ) ; return Util . return_empty_any ( "RemoveLoggingTarget" ) ; } | Executes the RemoveLoggingTargetCmd TANGO command |
19,950 | static String [ ] getProp ( final Map < String , String [ ] > prop , final String propertyName ) { String [ ] result = null ; if ( prop != null ) { for ( final Entry < String , String [ ] > entry : prop . entrySet ( ) ) { if ( entry . getKey ( ) . equalsIgnoreCase ( propertyName ) ) { result = entry . getValue ( ) ; } } } return result ; } | Ignore case on property name |
19,951 | public static void setDevicePipePropertiesInDB ( final String deviceName , final String pipeName , final Map < String , String [ ] > properties ) throws DevFailed { LOGGER . debug ( "update pipe {} device properties {} in DB " , pipeName , properties . keySet ( ) ) ; DatabaseFactory . getDatabase ( ) . setDevicePipeProperties ( deviceName , pipeName , properties ) ; } | Set pipe device properties in db |
19,952 | public Any execute ( DeviceImpl device , Any in_any ) throws DevFailed { Util . out4 . println ( "StartLoggingCmd::execute(): arrived" ) ; Logging . instance ( ) . start_logging ( ) ; Util . out4 . println ( "Leaving StartLoggingCmd.execute()" ) ; return Util . return_empty_any ( "StartLogging" ) ; } | Executes the StartLoggingCmd TANGO command |
19,953 | @ StateMachine ( endState = DeviceState . ON ) public void init ( ) throws DevFailed { xlogger . entry ( ) ; TangoCacheManager . setPollSize ( pollingThreadsPoolSize ) ; status = "The device is ON\nThe polling is ON" ; tangoStats = TangoStats . getInstance ( ) ; xlogger . exit ( ) ; } | Init the device |
19,954 | @ Command ( name = "DevPollStatus" , inTypeDesc = DEVICE_NAME , outTypeDesc = "Device polling status" ) public String [ ] getPollStatus ( final String deviceName ) throws DevFailed { xlogger . entry ( deviceName ) ; String [ ] ret = new PollStatusCommand ( deviceName , classList ) . call ( ) ; xlogger . exit ( ret ) ; return ret ; } | get the polling status |
19,955 | @ Command ( name = "RestartServer" ) public void restartServer ( ) throws DevFailed { xlogger . entry ( ) ; tangoExporter . unexportAll ( ) ; tangoExporter . exportAll ( ) ; xlogger . exit ( ) ; } | Restart the whole server and its devices . |
19,956 | @ Command ( name = "Kill" ) public void kill ( ) throws DevFailed { xlogger . entry ( ) ; new Thread ( ) { public void run ( ) { logger . error ( "kill server" ) ; try { tangoExporter . unexportAll ( ) ; } catch ( final DevFailed e ) { } finally { ORBManager . shutdown ( ) ; System . exit ( - 1 ) ; } logger . error ( "everything has been shutdown normally" ) ; } } . start ( ) ; xlogger . exit ( ) ; } | Unexport everything and kill it self |
19,957 | @ Command ( name = "AddLoggingTarget" , inTypeDesc = "Str[i]=Device-name. Str[i+1]=Target-type::Target-name" ) public void addLoggingTarget ( final String [ ] argin ) throws DevFailed { if ( argin . length % 2 != 0 ) { throw DevFailedUtils . newDevFailed ( INPUT_ERROR , "argin must be of even size" ) ; } for ( int i = 0 ; i < argin . length - 1 ; i = i + 2 ) { final String deviceName = argin [ i ] ; final String [ ] config = argin [ i + 1 ] . split ( LoggingManager . LOGGING_TARGET_SEPARATOR ) ; if ( config . length != 2 ) { throw DevFailedUtils . newDevFailed ( INPUT_ERROR , "config must be of size 2: targetType::targetName" ) ; } if ( config [ 0 ] . equalsIgnoreCase ( LoggingManager . LOGGING_TARGET_DEVICE ) ) { Class < ? > className = null ; for ( final DeviceClassBuilder deviceClass : classList ) { if ( deviceClass . containsDevice ( deviceName ) ) { className = deviceClass . getDeviceClass ( ) ; break ; } } if ( className != null ) { LoggingManager . getInstance ( ) . addDeviceAppender ( config [ 1 ] , className , deviceName ) ; } } else { LoggingManager . getInstance ( ) . addFileAppender ( config [ 1 ] , deviceName ) ; } } } | Send logs to a device |
19,958 | @ Command ( name = "RemoveLoggingTarget" , inTypeDesc = "Str[i]=Device-name. Str[i+1]=Target-type::Target-name" ) public void removeLoggingTarget ( final String [ ] argin ) throws DevFailed { if ( argin . length % 2 != 0 ) { throw DevFailedUtils . newDevFailed ( INPUT_ERROR , "argin must be of even size" ) ; } for ( int i = 0 ; i < argin . length - 1 ; i = i + 2 ) { final String deviceName = argin [ i ] ; final String [ ] config = argin [ i + 1 ] . split ( LoggingManager . LOGGING_TARGET_SEPARATOR ) ; if ( config . length != 2 ) { throw DevFailedUtils . newDevFailed ( INPUT_ERROR , "config must be of size 2: targetType::targetName" ) ; } LoggingManager . getInstance ( ) . removeAppender ( deviceName , config [ 0 ] ) ; } } | remove logging to a device |
19,959 | @ Command ( name = "GetLoggingLevel" , inTypeDesc = "Device list" , outTypeDesc = "Lg[i]=Logging Level. Str[i]=Device name." ) public DevVarLongStringArray getLoggingLevel ( final String [ ] deviceNames ) { final int [ ] levels = new int [ deviceNames . length ] ; for ( int i = 0 ; i < levels . length ; i ++ ) { levels [ i ] = LoggingManager . getInstance ( ) . getLoggingLevel ( deviceNames [ i ] ) ; } return new DevVarLongStringArray ( levels , deviceNames ) ; } | Get the logging level |
19,960 | @ Command ( name = "GetLoggingTarget" , inTypeDesc = DEVICE_NAME , outTypeDesc = "Logging target list" ) public String [ ] getLoggingTarget ( final String deviceName ) throws DevFailed { return LoggingManager . getInstance ( ) . getLoggingTarget ( deviceName ) ; } | Get logging target |
19,961 | @ Command ( name = "SetLoggingLevel" , inTypeDesc = "Lg[i]=Logging Level. Str[i]=Device name." ) public void setLoggingLevel ( final DevVarLongStringArray dvlsa ) throws DevFailed { final int [ ] levels = dvlsa . lvalue ; final String [ ] deviceNames = dvlsa . svalue ; if ( deviceNames . length != levels . length ) { throw DevFailedUtils . newDevFailed ( INPUT_ERROR , "argin must be of same size for string and long " ) ; } for ( int i = 0 ; i < levels . length ; i ++ ) { LoggingManager . getInstance ( ) . setLoggingLevel ( deviceNames [ i ] , levels [ i ] ) ; } } | Set logging level |
19,962 | @ Command ( name = "QueryWizardClassProperty" , inTypeDesc = "Class name" , outTypeDesc = "Class property list (name - description and default value)" ) public String [ ] queryClassProp ( final String className ) throws DevFailed { xlogger . entry ( ) ; final List < String > names = new ArrayList < String > ( ) ; for ( final DeviceClassBuilder deviceClass : classList ) { if ( deviceClass . getClassName ( ) . equalsIgnoreCase ( className ) ) { final List < DeviceImpl > devices = deviceClass . getDeviceImplList ( ) ; if ( devices . size ( ) > 0 ) { final DeviceImpl dev = devices . get ( 0 ) ; final List < ClassPropertyImpl > props = dev . getClassPropertyList ( ) ; for ( final ClassPropertyImpl prop : props ) { names . add ( prop . getName ( ) ) ; names . add ( prop . getDescription ( ) ) ; names . add ( "" ) ; } } break ; } } xlogger . exit ( ) ; return names . toArray ( new String [ names . size ( ) ] ) ; } | Get class properties |
19,963 | @ Command ( name = "QueryWizardDevProperty" , inTypeDesc = "Class name" , outTypeDesc = "Device property list (name - description and default value)" ) public String [ ] queryDevProp ( final String className ) { xlogger . entry ( ) ; final List < String > names = new ArrayList < String > ( ) ; for ( final DeviceClassBuilder deviceClass : classList ) { if ( deviceClass . getClassName ( ) . equalsIgnoreCase ( className ) ) { final List < DeviceImpl > devices = deviceClass . getDeviceImplList ( ) ; if ( devices . size ( ) > 0 ) { final DeviceImpl dev = devices . get ( 0 ) ; final List < DevicePropertyImpl > props = dev . getDevicePropertyList ( ) ; for ( final DevicePropertyImpl prop : props ) { names . add ( prop . getName ( ) ) ; names . add ( prop . getDescription ( ) ) ; if ( prop . getDefaultValue ( ) . length == 0 ) { names . add ( "" ) ; } else { names . add ( prop . getDefaultValue ( ) [ 0 ] ) ; } } } break ; } } xlogger . exit ( names ) ; return names . toArray ( new String [ names . size ( ) ] ) ; } | Get device properties |
19,964 | private DevVarLongStringArray subcribeIDLInEventString ( final String eventTypeAndIDL , final String deviceName , final String objName ) throws DevFailed { String event = eventTypeAndIDL ; int idlversion = EventManager . MINIMUM_IDL_VERSION ; if ( eventTypeAndIDL . contains ( EventManager . IDL_LATEST ) ) { idlversion = DeviceImpl . SERVER_VERSION ; event = eventTypeAndIDL . substring ( eventTypeAndIDL . indexOf ( "_" ) + 1 , eventTypeAndIDL . length ( ) ) ; } final EventType eventType = EventType . getEvent ( event ) ; logger . debug ( "event subscription/confirmation for {}, attribute/pipe {} with type {} and IDL {}" , new Object [ ] { deviceName , objName , eventType , idlversion } ) ; final Pair < PipeImpl , AttributeImpl > result = findSubscribers ( eventType , deviceName , objName ) ; return subscribeEvent ( eventType , deviceName , idlversion , result . getRight ( ) , result . getLeft ( ) ) ; } | Manage event subcription with event name like idl5_archive or archive |
19,965 | public Any execute ( DeviceImpl device , Any in_any ) throws DevFailed { Util . out4 . println ( "GetLoggingTargetCmd::execute(): arrived" ) ; String string = null ; try { string = extract_DevString ( in_any ) ; } catch ( DevFailed df ) { Util . out3 . println ( "GetLoggingTargetCmd::execute() ) ; Except . re_throw_exception ( df , "API_IncompatibleCmdArgumentType" , "Imcompatible command argument type, expected type is : DevVarStringArray" , "GetLoggingTargetCmd.execute" ) ; } Any out_any = insert ( Logging . instance ( ) . get_logging_target ( string ) ) ; Util . out4 . println ( "Leaving GetLoggingTargetCmd.execute()" ) ; return out_any ; } | Executes the GetLoggingTargetCmd TANGO command |
19,966 | public static synchronized void init ( final boolean useDb , final String adminDeviceName ) throws DevFailed { final Properties props = System . getProperties ( ) ; props . put ( "org.omg.CORBA.ORBClass" , "org.jacorb.orb.ORB" ) ; props . put ( "org.omg.CORBA.ORBSingletonClass" , "org.jacorb.orb.ORBSingleton" ) ; props . put ( "org.omg.PortableInterceptor.ORBInitializerClass.ForwardInit" , InterceptorInitializer . class . getCanonicalName ( ) ) ; props . put ( "jacorb.retries" , "0" ) ; props . put ( "jacorb.retry_interval" , "100" ) ; props . put ( "jacorb.codeset" , true ) ; props . put ( "jacorb.connection.client.connect_timeout" , "5000" ) ; final String str = checkORBgiopMaxMsgSize ( ) ; props . put ( "jacorb.maxManagedBufSize" , str ) ; props . put ( "jacorb.config.log.verbosity" , "0" ) ; props . setProperty ( "jacorb.implname" , SERVER_IMPL_NAME ) ; orb = ORB . init ( new String [ ] { } , props ) ; try { poa = POAHelper . narrow ( orb . resolve_initial_references ( "RootPOA" ) ) ; } catch ( final InvalidName e ) { throw DevFailedUtils . newDevFailed ( e ) ; } catch ( final INITIALIZE e ) { if ( ! useDb ) { throw DevFailedUtils . newDevFailed ( e ) ; } } try { if ( ! useDb ) { final org . omg . CORBA . Policy [ ] policies = new org . omg . CORBA . Policy [ 2 ] ; policies [ 0 ] = poa . create_id_assignment_policy ( IdAssignmentPolicyValue . USER_ID ) ; policies [ 1 ] = poa . create_lifespan_policy ( LifespanPolicyValue . PERSISTENT ) ; final org . omg . PortableServer . POAManager manager = poa . the_POAManager ( ) ; poa = poa . create_POA ( NODB_POA , manager , policies ) ; } } catch ( final org . omg . PortableServer . POAPackage . AdapterAlreadyExists e ) { throw DevFailedUtils . newDevFailed ( e ) ; } catch ( final org . omg . PortableServer . POAPackage . InvalidPolicy e ) { throw DevFailedUtils . newDevFailed ( e ) ; } final POAManager manager = poa . the_POAManager ( ) ; try { manager . activate ( ) ; } catch ( final org . omg . PortableServer . POAManagerPackage . AdapterInactive ex ) { throw DevFailedUtils . newDevFailed ( "API_CantActivatePOAManager" , "The POA activate method throws an exception" ) ; } if ( useDb ) { final DeviceImportInfo importInfo = DatabaseFactory . getDatabase ( ) . importDevice ( adminDeviceName ) ; if ( importInfo . isExported ( ) ) { LOGGER . debug ( "{} is set as exported in tango db - checking if it is already running" , adminDeviceName ) ; ORBManager . checkServerRunning ( importInfo , adminDeviceName ) ; } } } | Initialise the ORB |
19,967 | private static void checkServerRunning ( final DeviceImportInfo importInfo , final String toBeImported ) throws DevFailed { XLOGGER . entry ( ) ; Device_5 devIDL5 = null ; Device_4 devIDL4 = null ; Device_3 devIDL3 = null ; Device_2 devIDL2 = null ; Device devIDL1 = null ; try { try { devIDL5 = narrowIDL5 ( importInfo ) ; } catch ( final BAD_PARAM e ) { try { devIDL4 = narrowIDL4 ( importInfo ) ; } catch ( final BAD_PARAM e4 ) { try { devIDL3 = narrowIDL3 ( importInfo ) ; } catch ( final BAD_PARAM e1 ) { try { devIDL2 = narrowIDL2 ( importInfo ) ; } catch ( final BAD_PARAM e2 ) { try { devIDL1 = narrowIDL1 ( importInfo ) ; } catch ( final BAD_PARAM e3 ) { throw DevFailedUtils . newDevFailed ( e ) ; } } } } } if ( devIDL5 == null && devIDL4 == null && devIDL3 == null && devIDL2 == null && devIDL1 == null ) { LOGGER . debug ( "out, device is not running" ) ; } else { checkDeviceName ( toBeImported , devIDL5 , devIDL4 , devIDL3 , devIDL2 , devIDL1 ) ; } } catch ( final org . omg . CORBA . TIMEOUT e ) { LOGGER . debug ( "out on TIMEOUT" ) ; } catch ( final BAD_OPERATION e ) { throw DevFailedUtils . newDevFailed ( e ) ; } catch ( final TRANSIENT e ) { LOGGER . debug ( "out on TRANSIENT, device is not running" ) ; } catch ( final OBJECT_NOT_EXIST e ) { LOGGER . debug ( "out on OBJECT_NOT_EXIST, device is not running" ) ; } catch ( final COMM_FAILURE e ) { LOGGER . debug ( "out on COMM_FAILURE,, device is not running" ) ; } catch ( final BAD_INV_ORDER e ) { LOGGER . debug ( "out on BAD_INV_ORDER,, device is not running" ) ; } XLOGGER . exit ( ) ; } | Check the server is already running |
19,968 | public static void startDetached ( ) { orbStart = Executors . newSingleThreadExecutor ( new ThreadFactory ( ) { public Thread newThread ( final Runnable r ) { return new Thread ( r , "ORB run" ) ; } } ) ; orbStart . submit ( new StartTask ( ) ) ; LOGGER . debug ( "ORB started" ) ; } | Start the ORB . non blocking . |
19,969 | private static String checkORBgiopMaxMsgSize ( ) { String str = "20" ; final String tmp = System . getProperty ( "ORBgiopMaxMsgSize" ) ; if ( tmp != null && checkBufferSize ( tmp ) != null ) { str = tmp ; } return str ; } | Check if the checkORBgiopMaxMsgSize has been set . This environment variable should be set in Mega bytes . |
19,970 | public static void shutdown ( ) { if ( orbStart != null ) { orbStart . shutdown ( ) ; } if ( orb != null ) { orb . shutdown ( true ) ; LOGGER . debug ( "ORB shutdown" ) ; } } | Shutdown the ORB |
19,971 | public boolean isAllowed ( final DeviceState state ) { boolean isAllowed = true ; if ( deniedStates . contains ( state ) ) { isAllowed = false ; } return isAllowed ; } | Check if a state is allowed |
19,972 | public void build ( final Class < ? > clazz , final Field field , final DeviceImpl device , final Object businessObject ) throws DevFailed { xlogger . entry ( ) ; BuilderUtils . checkStatic ( field ) ; Method getter ; final String stateName = field . getName ( ) ; final String getterName = BuilderUtils . GET + stateName . substring ( 0 , 1 ) . toUpperCase ( Locale . ENGLISH ) + stateName . substring ( 1 ) ; try { getter = clazz . getMethod ( getterName ) ; } catch ( final NoSuchMethodException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } if ( getter . getParameterTypes ( ) . length != 0 ) { throw DevFailedUtils . newDevFailed ( DevFailedUtils . TANGO_BUILD_FAILED , getter + " must not have a parameter" ) ; } logger . debug ( "Has an status : {}" , field . getName ( ) ) ; if ( getter . getReturnType ( ) != String . class ) { throw DevFailedUtils . newDevFailed ( DevFailedUtils . TANGO_BUILD_FAILED , getter + " must have a return type of " + String . class ) ; } Method setter ; final String setterName = BuilderUtils . SET + stateName . substring ( 0 , 1 ) . toUpperCase ( Locale . ENGLISH ) + stateName . substring ( 1 ) ; try { setter = clazz . getMethod ( setterName , String . class ) ; } catch ( final NoSuchMethodException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } device . setStatusImpl ( new StatusImpl ( businessObject , getter , setter ) ) ; final Status annot = field . getAnnotation ( Status . class ) ; if ( annot . isPolled ( ) ) { device . addAttributePolling ( DeviceImpl . STATUS_NAME , annot . pollingPeriod ( ) ) ; } xlogger . exit ( ) ; } | Create a status |
19,973 | public static void waitForState ( final DeviceProxy proxy , final DevState waitState , final long timeout ) throws DevFailed , TimeoutException { waitForState ( proxy , waitState , timeout , 300 ) ; } | Wait for waitState |
19,974 | public static void failIfWrongStateAfterWhileState ( final DeviceProxy deviceProxy , final DevState expected , final DevState waitState , final long timeout , final long polling ) throws DevFailed , TimeoutException { waitWhileState ( deviceProxy , waitState , timeout , polling ) ; if ( ! expected . equals ( deviceProxy . state ( ) ) ) { throw DevFailedUtils . newDevFailed ( "State not reach" , "fail to reach state " + TangoConst . Tango_DevStateName [ expected . value ( ) ] + " after wait " + TangoConst . Tango_DevStateName [ waitState . value ( ) ] ) ; } } | Wait while waitState does not change and check the final finale |
19,975 | public static String getfullAttributeNameForAttribute ( final String attributeName ) throws DevFailed { String result ; final String [ ] fields = attributeName . split ( "/" ) ; final Database db = ApiUtil . get_db_obj ( ) ; if ( attributeName . contains ( DBASE_NO ) ) { result = attributeName ; } else if ( fields . length == 1 ) { result = db . get_attribute_from_alias ( fields [ 0 ] ) ; } else if ( fields . length == 2 ) { result = db . get_device_from_alias ( fields [ 0 ] ) + "/" + fields [ 1 ] ; } else { result = attributeName ; } return result ; } | Get the full attribute name |
19,976 | public static String [ ] getDevicesForPattern ( final String deviceNamePattern ) throws DevFailed { String [ ] devices ; if ( ! deviceNamePattern . contains ( "*" ) ) { devices = new String [ 1 ] ; devices [ 0 ] = TangoUtil . getfullNameForDevice ( deviceNamePattern ) ; } else { final Database db = ApiUtil . get_db_obj ( ) ; devices = db . get_device_exported ( deviceNamePattern ) ; } return devices ; } | Get the list of device names which matches the pattern p |
19,977 | public static String getAttributeName ( final String fullname ) throws DevFailed { final String s = TangoUtil . getfullAttributeNameForAttribute ( fullname ) ; return s . substring ( s . lastIndexOf ( '/' ) + 1 ) ; } | Return the attribute name part without device name It is able to resolve attribute alias before |
19,978 | protected boolean name_matches ( String pattern ) { pattern = pattern . toLowerCase ( ) . replaceAll ( "[*]{1}" , ".*?" ) ; return name . toLowerCase ( ) . matches ( pattern ) || get_fully_qualified_name ( ) . toLowerCase ( ) . matches ( pattern ) ; } | Returns true if name matches pattern |
19,979 | public void post_init ( final ORBInitInfo info ) { try { info . add_server_request_interceptor ( ServerRequestInterceptor . getInstance ( ) ) ; } catch ( final Exception e ) { logger . error ( "error registering server interceptor" , e ) ; } } | This method resolves the NameService and registers the interceptor . |
19,980 | public final static Object toPrimitiveArray ( final Object array ) { if ( ! array . getClass ( ) . isArray ( ) ) { return array ; } final Class < ? > clazz = OBJ_TO_PRIMITIVE . get ( array . getClass ( ) . getComponentType ( ) ) ; return setArray ( clazz , array ) ; } | Convert an array of Objects to primitives if possible . Return input otherwise |
19,981 | public final static Object toObjectArray ( final Object array ) { if ( ! array . getClass ( ) . isArray ( ) ) { return array ; } final Class < ? > clazz = PRIMITIVE_TO_OBJ . get ( array . getClass ( ) . getComponentType ( ) ) ; return setArray ( clazz , array ) ; } | Convert an array of primitives to Objects if possible . Return input otherwise |
19,982 | public static String [ ] toStringArray ( final Object array ) { final int length = Array . getLength ( array ) ; final String [ ] result = new String [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { result [ i ] = Array . get ( array , i ) . toString ( ) ; } return result ; } | Convert an array of any type to an array of strings |
19,983 | public static Object addAll ( final Object array1 , final Object array2 ) { Object joinedArray ; if ( array1 == null ) { if ( array2 . getClass ( ) . isArray ( ) ) { joinedArray = array2 ; } else { joinedArray = Array . newInstance ( array2 . getClass ( ) , 1 ) ; Array . set ( joinedArray , 0 , array2 ) ; } } else if ( array2 == null ) { if ( array1 . getClass ( ) . isArray ( ) ) { joinedArray = array1 ; } else { joinedArray = Array . newInstance ( array1 . getClass ( ) , 1 ) ; Array . set ( joinedArray , 0 , array1 ) ; } } else { int length1 = 1 ; if ( array1 . getClass ( ) . isArray ( ) ) { length1 = Array . getLength ( array1 ) ; } int length2 = 1 ; if ( array2 . getClass ( ) . isArray ( ) ) { length2 = Array . getLength ( array2 ) ; } if ( array1 . getClass ( ) . isArray ( ) ) { joinedArray = Array . newInstance ( array1 . getClass ( ) . getComponentType ( ) , length1 + length2 ) ; } else { joinedArray = Array . newInstance ( array1 . getClass ( ) , length1 + length2 ) ; } if ( array1 . getClass ( ) . isArray ( ) ) { System . arraycopy ( array1 , 0 , joinedArray , 0 , length1 ) ; } else { Array . set ( joinedArray , 0 , array1 ) ; } if ( array2 . getClass ( ) . isArray ( ) ) { System . arraycopy ( array2 , 0 , joinedArray , length1 , length2 ) ; } else { Array . set ( joinedArray , length1 , array2 ) ; } } return joinedArray ; } | Add 2 arrays |
19,984 | public static Object from2DArrayToArray ( final Object array2D ) { Object array = null ; if ( array2D . getClass ( ) . isArray ( ) ) { final int lengthY = Array . getLength ( array2D ) ; if ( Array . getLength ( array2D ) > 0 ) { final Object firstLine = Array . get ( array2D , 0 ) ; int lengthLineX ; if ( firstLine . getClass ( ) . isArray ( ) ) { lengthLineX = Array . getLength ( firstLine ) ; final Class < ? > compType = firstLine . getClass ( ) . getComponentType ( ) ; array = Array . newInstance ( compType , lengthY * lengthLineX ) ; if ( lengthLineX > 0 && lengthY > 0 ) { for ( int y = 0 ; y < lengthY ; y ++ ) { final Object line = Array . get ( array2D , y ) ; System . arraycopy ( line , 0 , array , lengthLineX * y , lengthLineX ) ; } } } else { array = Array . newInstance ( array2D . getClass ( ) . getComponentType ( ) , Array . getLength ( array2D ) ) ; System . arraycopy ( array2D , 0 , array , 0 , Array . getLength ( array2D ) ) ; } } else { if ( array2D . getClass ( ) . getComponentType ( ) . isArray ( ) ) { array = Array . newInstance ( array2D . getClass ( ) . getComponentType ( ) . getComponentType ( ) , Array . getLength ( array2D ) ) ; } else { array = Array . newInstance ( array2D . getClass ( ) . getComponentType ( ) , Array . getLength ( array2D ) ) ; } } } else { array = array2D ; } return array ; } | Convert a 2D array to a 1D array |
19,985 | public static boolean checkDimensions ( final Object object , final int dimX , final int dimY ) { boolean hasGoodDimensions = false ; if ( object != null ) { if ( object . getClass ( ) . isArray ( ) ) { if ( Array . getLength ( object ) == 0 && dimX == 0 ) { hasGoodDimensions = true ; } else if ( object . getClass ( ) . getComponentType ( ) . isArray ( ) ) { final Object line = Array . get ( object , 0 ) ; if ( dimX * dimY == Array . getLength ( object ) * Array . getLength ( line ) ) { hasGoodDimensions = true ; } } else { final int length = Array . getLength ( object ) ; if ( dimX == length && dimY == 0 ) { hasGoodDimensions = true ; } else if ( dimX * dimY == length ) { hasGoodDimensions = true ; } } } else { if ( dimX == 1 && dimY == 0 ) { hasGoodDimensions = true ; } } } return hasGoodDimensions ; } | Check of size corresponds to given dimensions |
19,986 | public static Object fromArrayTo2DArray ( final Object array , final int dimX , final int dimY ) throws DevFailed { Object array2D = null ; if ( array . getClass ( ) . isArray ( ) ) { if ( dimY > 0 ) { array2D = Array . newInstance ( array . getClass ( ) . getComponentType ( ) , dimY , dimX ) ; for ( int y = 0 ; y < dimY ; y ++ ) { final Object line = Array . get ( array2D , y ) ; System . arraycopy ( array , y * dimX , line , 0 , Array . getLength ( line ) ) ; } } else { array2D = Array . newInstance ( array . getClass ( ) . getComponentType ( ) , Array . getLength ( array ) ) ; System . arraycopy ( array , 0 , array2D , 0 , Array . getLength ( array ) ) ; } } else { array2D = array ; } return array2D ; } | Convert an array to a 2D array |
19,987 | public String [ ] getDeviceStateArray ( ) { final String [ ] array = new String [ deviceStateMap . size ( ) ] ; int i = 0 ; for ( final Map . Entry < String , DevState > deviceStateEntry : deviceStateMap . entrySet ( ) ) { final String deviceName = deviceStateEntry . getKey ( ) ; final DevState deviceState = deviceStateEntry . getValue ( ) ; array [ i ++ ] = deviceName + " - " + StateUtilities . getNameForState ( deviceState ) ; } return array ; } | return an array of String which contains deviceName and his state . |
19,988 | public short [ ] getDeviceStateNumberArray ( ) { final short [ ] array = new short [ deviceStateMap . size ( ) ] ; int i = 0 ; for ( final Map . Entry < String , DevState > deviceStateEntry : deviceStateMap . entrySet ( ) ) { final DevState deviceState = deviceStateEntry . getValue ( ) ; array [ i ++ ] = ( short ) getPriorityForState ( deviceState ) ; } return array ; } | return an array of short which contains the priority of state of monitored devices . |
19,989 | public < T > T read ( final Class < T > type ) throws DevFailed { update ( ) ; return extract ( type ) ; } | Read the tango attribute with SCALAR format and convert it |
19,990 | public < T > Object readArray ( final Class < T > type ) throws DevFailed { update ( ) ; return extractArray ( type ) ; } | Read attribute and return result as array . |
19,991 | public < T > T readWritten ( final Class < T > type ) throws DevFailed { update ( ) ; return extractWritten ( type ) ; } | Read written value of attribute |
19,992 | public < T > T [ ] readSpecOrImage ( final Class < T > type ) throws DevFailed { update ( ) ; return extractSpecOrImage ( type ) ; } | Read attribute with format SPECTRUM or IMAGE |
19,993 | public String readAsString ( final String separator , final String endSeparator ) throws DevFailed { update ( ) ; return extractToString ( separator , endSeparator ) ; } | Read attribute and convert it to a String with separators |
19,994 | public void insert ( final Object value ) throws DevFailed { logger . debug ( LOG_INSERTING , this ) ; attributeImpl . insert ( value ) ; } | Insert scalar spectrum or image . spectrum can be arrays of Objects or primitives . image can be 2D arrays of Objects or primitives |
19,995 | public Number extractNumber ( ) throws DevFailed { logger . debug ( LOG_EXTRACTING , this ) ; final Object result = attributeImpl . extract ( ) ; if ( ! Number . class . isAssignableFrom ( result . getClass ( ) ) ) { throw DevFailedUtils . newDevFailed ( TANGO_WRONG_DATA_ERROR , THIS_ATTRIBUTE_MUST_BE_A_JAVA_LANG_NUMBER ) ; } return ( Number ) result ; } | Extract value in a Number without conversion |
19,996 | public static void initPoolConf ( ) throws DevFailed { polledDevices . clear ( ) ; final Map < String , String [ ] > prop = PropertiesUtils . getDeviceProperties ( ServerManager . getInstance ( ) . getAdminDeviceName ( ) ) ; if ( prop . containsKey ( POLLING_THREADS_POOL_CONF ) ) { final String [ ] pollingThreadsPoolConf = prop . get ( POLLING_THREADS_POOL_CONF ) ; for ( int i = 0 ; i < pollingThreadsPoolConf . length ; i ++ ) { if ( cacheList . containsKey ( pollingThreadsPoolConf [ i ] ) && ! pollingThreadsPoolConf [ i ] . isEmpty ( ) && ! polledDevices . contains ( pollingThreadsPoolConf [ i ] ) ) { polledDevices . add ( pollingThreadsPoolConf [ i ] ) ; } } } } | Retrieve the ordered list of polled devices |
19,997 | private void updatePoolConf ( ) throws DevFailed { if ( ! polledDevices . contains ( deviceName ) ) { polledDevices . add ( deviceName ) ; final Map < String , String [ ] > properties = new HashMap < String , String [ ] > ( ) ; properties . put ( POLLING_THREADS_POOL_CONF , polledDevices . toArray ( new String [ 0 ] ) ) ; DatabaseFactory . getDatabase ( ) . setDeviceProperties ( ServerManager . getInstance ( ) . getAdminDeviceName ( ) , properties ) ; } } | Add the current device in polled list and persist it as device property of admin device . This property is not used . Just here to have the same behavior as C ++ Tango API . |
19,998 | public synchronized void startCommandPolling ( final CommandImpl command ) throws DevFailed { addCommandPolling ( command ) ; LOGGER . debug ( "starting command {} for polling on device {}" , command . getName ( ) , deviceName ) ; if ( command . getPollingPeriod ( ) != 0 ) { commandCacheMap . get ( command ) . startRefresh ( POLLING_POOL ) ; } } | Start command polling |
19,999 | private void addCommandPolling ( final CommandImpl command ) throws DevFailed { if ( MANAGER == null ) { startCache ( ) ; } removeCommandPolling ( command ) ; final CommandCache cache = new CommandCache ( MANAGER , command , deviceName , deviceLock , aroundInvoke ) ; if ( command . getPollingPeriod ( ) == 0 ) { extTrigCommandCacheMap . put ( command , cache ) ; } else { commandCacheMap . put ( command , cache ) ; } updatePoolConf ( ) ; } | Add command as polled |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.