idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
19,900
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
164
12
19,901
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 : // set attribute value final AttributeImpl attribute = AttributeGetterSetter . getAttribute ( attributeName , device . getAttributeList ( ) ) ; attribute . lock ( ) ; try { attribute . updateValue ( value ) ; // push the event 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 .
206
10
19,902
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
44
13
19,903
public void pushPipeEvent ( final String pipeName , final PipeValue blob ) throws DevFailed { // set attribute value final PipeImpl pipe = DeviceImpl . getPipe ( pipeName , device . getPipeList ( ) ) ; try { pipe . updateValue ( blob ) ; // push the event 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
119
13
19,904
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 ( ) ) { // get data to throw e 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 .
108
26
19,905
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
87
7
19,906
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
234
5
19,907
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
116
3
19,908
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 .
421
7
19,909
public T execute ( final Task < T > taskToWrap ) throws DevFailed { int triesLeft = tries ; do { try { return taskToWrap . call ( ) ; } catch ( final DevFailed e ) { triesLeft -- ; // Are we allowed to try again? if ( triesLeft <= 0 ) { // No -- throw logger . error ( "Caught exception, all retries done for error: {}" , DevFailedUtils . toString ( e ) ) ; throw e ; } // Yes -- log and allow to loop 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 .
183
24
19,910
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
168
7
19,911
@ Override public void updateValue ( ) throws DevFailed { xlogger . entry ( getName ( ) ) ; // invoke on device // final Profiler profilerPeriod = new Profiler("read attribute " + name); // profilerPeriod.start("invoke"); if ( ! config . getWritable ( ) . equals ( AttrWriteType . READ ) && behavior instanceof ISetValueUpdater ) { // write value is managed by the user try { final AttributeValue setValue = ( ( ISetValueUpdater ) behavior ) . getSetValue ( ) ; if ( setValue != null ) { writeValue = ( AttributeValue ) ( ( ISetValueUpdater ) behavior ) . getSetValue ( ) . clone ( ) ; // get as array if necessary (for image) 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 { // attribute with a read part final AttributeValue returnedValue = behavior . getValue ( ) ; this . updateValue ( returnedValue ) ; } // profilerPeriod.stop().print(); xlogger . exit ( getName ( ) ) ; }
read attribute on device
370
4
19,912
@ Override public void updateValue ( final AttributeValue inValue ) throws DevFailed { xlogger . entry ( getName ( ) ) ; // final Profiler profilerPeriod = new Profiler("read attribute " + name); // profilerPeriod.start("in"); if ( inValue == null ) { throw DevFailedUtils . newDevFailed ( ExceptionMessages . ATTR_VALUE_NOT_SET , name + " read value has not been updated" ) ; } try { // copy value readValue = ( AttributeValue ) inValue . clone ( ) ; } catch ( final CloneNotSupportedException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } // update quality if necessary if ( readValue . getValue ( ) != null && ! readValue . getQuality ( ) . equals ( AttrQuality . ATTR_INVALID ) ) { updateQuality ( readValue ) ; } // profilerPeriod.start("clone"); // profilerPeriod.stop().print(); try { if ( readValue . getValue ( ) != null ) { // profilerPeriod.start("checkUpdateErrors"); checkUpdateErrors ( readValue ) ; // profilerPeriod.start("from2DArrayToArray"); // get as array if necessary (for image) readValue . setValueWithoutDim ( ArrayUtils . from2DArrayToArray ( readValue . getValue ( ) ) ) ; // force conversion to check types // profilerPeriod.start("toAttributeValue5"); TangoIDLAttributeUtil . toAttributeValue5 ( this , readValue , null ) ; } else { throw DevFailedUtils . newDevFailed ( ExceptionMessages . ATTR_VALUE_NOT_SET , name + " read value has not been updated" ) ; } // profilerPeriod.start("updateDefaultWritePart"); updateDefaultWritePart ( ) ; // profilerPeriod.stop().print(); } catch ( final DevFailed e ) { // readValue.setQuality(AttrQuality.ATTR_INVALID); readValue . setXDim ( 0 ) ; readValue . setYDim ( 0 ) ; lastError = e ; throw e ; } xlogger . exit ( getName ( ) ) ; }
set the read value
495
4
19,913
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 ) { // set config on forwarded attribute final ForwardedAttribute fwdAttr = ( ForwardedAttribute ) behavior ; properties . setRootAttribute ( fwdAttr . getRootName ( ) ) ; fwdAttr . setAttributeConfiguration ( config ) ; } config . persist ( deviceName ) ; EventManager . getInstance ( ) . pushAttributeConfigEvent ( deviceName , name ) ; }
Set the attribute properties .
247
5
19,914
private Map < String , String [ ] > extractArgout ( final String [ ] result , final int startingPoint ) { final Map < String , String [ ] > map = new CaseInsensitiveMap < String [ ] > ( ) ; if ( result . length > 4 ) { // System.out.println(result[0]);// device name // System.out.println(Integer.valueOf(result[1]));// prop size // System.out.println(result[2]);// prop name int i = startingPoint ; int nextSize = Integer . valueOf ( result [ i + 1 ] ) ; while ( i < result . length ) { // System.out.println("i " + i); 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 ) ; // System.out.println("name " + name); // System.out.println("prop1 " + Arrays.toString(propValues)); } final int idxNextPropSize ; if ( nextSize == 0 ) { // System.out.println("zero"); idxNextPropSize = i + 4 ; i = i + 3 ; } else { idxNextPropSize = nextSize + i + 3 ; i = nextSize + i + 2 ; } // System.out.println("idxNextPropSize " + idxNextPropSize); if ( idxNextPropSize >= result . length ) { break ; } // System.out.println("idxNextPropSize value " + // result[idxNextPropSize]); nextSize = Integer . valueOf ( result [ idxNextPropSize ] ) ; // System.out.println("nextSize " + nextSize); } } return map ; }
Return a map of properties with name as key and value as entry
415
13
19,915
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() --> Wrong argument type" ) ; 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
188
12
19,916
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
94
6
19,917
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
90
6
19,918
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
91
11
19,919
@ Init @ StateMachine ( endState = DeviceState . ON ) public void init ( ) throws DevFailed { xlogger . entry ( ) ; TangoCacheManager . setPollSize ( pollingThreadsPoolSize ) ; // logger.debug("init admin device with quartzThreadsPoolSize = {}", // quartzThreadsPoolSize); status = "The device is ON\nThe polling is ON" ; tangoStats = TangoStats . getInstance ( ) ; xlogger . exit ( ) ; }
Init the device
109
3
19,920
@ 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
92
4
19,921
@ Command ( name = "RestartServer" ) public void restartServer ( ) throws DevFailed { xlogger . entry ( ) ; tangoExporter . unexportAll ( ) ; tangoExporter . exportAll ( ) ; xlogger . exit ( ) ; }
Restart the whole server and its devices .
60
9
19,922
@ Command ( name = "Kill" ) public void kill ( ) throws DevFailed { xlogger . entry ( ) ; // do it in a thread to avoid throwing error to client new Thread ( ) { @ Override 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
135
8
19,923
@ 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
352
5
19,924
@ 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
233
5
19,925
@ 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
136
4
19,926
@ 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
71
3
19,927
@ 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
176
3
19,928
@ 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 ( "" ) ; // default value } } break ; } } xlogger . exit ( ) ; return names . toArray ( new String [ names . size ( ) ] ) ; }
Get class properties
251
3
19,929
@ 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 ( ) ) ; // default value 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
283
3
19,930
private DevVarLongStringArray subcribeIDLInEventString ( final String eventTypeAndIDL , final String deviceName , final String objName ) throws DevFailed { // event name like "idl5_archive" or "archive" 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
269
16
19,931
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() --> Wrong argument type" ) ; 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
195
12
19,932
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 IDL5 try { devIDL5 = narrowIDL5 ( importInfo ) ; } catch ( final BAD_PARAM e ) { // try IDL4 try { devIDL4 = narrowIDL4 ( importInfo ) ; } catch ( final BAD_PARAM e4 ) { // maybe another IDL is currently running // try IDL3 try { devIDL3 = narrowIDL3 ( importInfo ) ; } catch ( final BAD_PARAM e1 ) { // maybe another IDL is currently running // try IDL2 try { devIDL2 = narrowIDL2 ( importInfo ) ; } catch ( final BAD_PARAM e2 ) { // maybe another IDL is currently running // try IDL1 try { devIDL1 = narrowIDL1 ( importInfo ) ; } catch ( final BAD_PARAM e3 ) { // may not occur, unknown CORBA server 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 ) { // Receive a Timeout exception ---> It is not running !!!! LOGGER . debug ( "out on TIMEOUT" ) ; } catch ( final BAD_OPERATION e ) { // System.err.println("Can't pack/unpack data sent to/from database in/to Any object"); 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
635
6
19,933
public static void startDetached ( ) { orbStart = Executors . newSingleThreadExecutor ( new ThreadFactory ( ) { @ Override 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 .
85
8
19,934
private static String checkORBgiopMaxMsgSize ( ) { /* * JacORB definition (see jacorb.properties file): * * This is NOT the maximum buffer size that can be used, but just the * largest size of buffers that will be kept and managed. This value * will be added to an internal constant of 5, so the real value in * bytes is 2**(5+maxManagedBufSize-1). You only need to increase this * value if you are dealing with LOTS of LARGE data structures. You may * decrease it to make the buffer manager release large buffers * immediately rather than keeping them for later reuse. */ String str = "20" ; // Set to 16 Mbytes // Check if environment ask for bigger size. 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 .
205
25
19,935
public static void shutdown ( ) { if ( orbStart != null ) { orbStart . shutdown ( ) ; } if ( orb != null ) { orb . shutdown ( true ) ; LOGGER . debug ( "ORB shutdown" ) ; } }
Shutdown the ORB
51
5
19,936
public boolean isAllowed ( final DeviceState state ) { boolean isAllowed = true ; if ( deniedStates . contains ( state ) ) { isAllowed = false ; } return isAllowed ; }
Check if a state is allowed
43
6
19,937
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
471
3
19,938
public static void waitForState ( final DeviceProxy proxy , final DevState waitState , final long timeout ) throws DevFailed , TimeoutException { waitForState ( proxy , waitState , timeout , 300 ) ; }
Wait for waitState
46
4
19,939
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
147
12
19,940
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
153
5
19,941
public static String [ ] getDevicesForPattern ( final String deviceNamePattern ) throws DevFailed { String [ ] devices ; // is p a device name or a device name pattern ? if ( ! deviceNamePattern . contains ( "*" ) ) { // p is a pure device name devices = new String [ 1 ] ; devices [ 0 ] = TangoUtil . getfullNameForDevice ( deviceNamePattern ) ; } else { // ask the db the list of device matching pattern p 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
142
11
19,942
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
57
16
19,943
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
72
6
19,944
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 .
63
12
19,945
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
79
15
19,946
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
78
15
19,947
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
77
12
19,948
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
412
3
19,949
public static Object from2DArrayToArray ( final Object array2D ) { // final Profiler profilerPeriod = new Profiler("from2DArrayToArray"); // profilerPeriod.start("from2DArrayToArray"); 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 { // is not a 2D array array = Array . newInstance ( array2D . getClass ( ) . getComponentType ( ) , Array . getLength ( array2D ) ) ; System . arraycopy ( array2D , 0 , array , 0 , Array . getLength ( array2D ) ) ; } } else { // empty array 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 { // is not an array array = array2D ; } // profilerPeriod.stop().print(); return array ; }
Convert a 2D array to a 1D array
468
11
19,950
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 ) { // is a 0D Array hasGoodDimensions = true ; } else if ( object . getClass ( ) . getComponentType ( ) . isArray ( ) ) { // is a 2D Array final Object line = Array . get ( object , 0 ) ; if ( dimX * dimY == Array . getLength ( object ) * Array . getLength ( line ) ) { hasGoodDimensions = true ; } } else { // 1 D array final int length = Array . getLength ( object ) ; if ( dimX == length && dimY == 0 ) { hasGoodDimensions = true ; } else if ( dimX * dimY == length ) { hasGoodDimensions = true ; } } } else { // not an array if ( dimX == 1 && dimY == 0 ) { hasGoodDimensions = true ; } } } return hasGoodDimensions ; }
Check of size corresponds to given dimensions
256
7
19,951
public static Object fromArrayTo2DArray ( final Object array , final int dimX , final int dimY ) throws DevFailed { Object array2D = null ; // final Profiler profilerPeriod = new Profiler("fromArrayTo2DArray"); // profilerPeriod.start("fromArrayTo2DArray"); if ( array . getClass ( ) . isArray ( ) ) { if ( dimY > 0 ) { // to a 2D Array 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 ; } // profilerPeriod.stop().print(); return array2D ; }
Convert an array to a 2D array
271
9
19,952
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 .
120
13
19,953
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 .
100
15
19,954
public < T > T read ( final Class < T > type ) throws DevFailed { update ( ) ; return extract ( type ) ; }
Read the tango attribute with SCALAR format and convert it
30
13
19,955
public < T > Object readArray ( final Class < T > type ) throws DevFailed { update ( ) ; return extractArray ( type ) ; }
Read attribute and return result as array .
32
8
19,956
public < T > T readWritten ( final Class < T > type ) throws DevFailed { update ( ) ; return extractWritten ( type ) ; }
Read written value of attribute
32
5
19,957
public < T > T [ ] readSpecOrImage ( final Class < T > type ) throws DevFailed { update ( ) ; return extractSpecOrImage ( type ) ; }
Read attribute with format SPECTRUM or IMAGE
38
10
19,958
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
42
11
19,959
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
35
28
19,960
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
114
8
19,961
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
201
8
19,962
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 .
126
37
19,963
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
91
3
19,964
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
117
4
19,965
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
97
3
19,966
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
126
4
19,967
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
193
5
19,968
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
153
3
19,969
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
183
5
19,970
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
119
3
19,971
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
148
3
19,972
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
107
5
19,973
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
149
5
19,974
public boolean isOver ( ) { if ( ! isOver ) { final long now = System . currentTimeMillis ( ) ; isOver = now - startTime >= duration ; } return isOver ; }
Check if the started duration is over
43
7
19,975
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 ) { // get value 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
175
8
19,976
public void setAttributePropertyInDB ( final String attributeName , final String propertyName , final String value ) throws DevFailed { xlogger . entry ( propertyName ) ; // insert value in db only if input value is different and not a // default value // if (checkCurrentValue) { // final String presentValue = getAttributePropertyFromDB(attributeName, propertyName); // final boolean isADefaultValue = presentValue.isEmpty() // && (value.equalsIgnoreCase(AttributePropertiesImpl.NOT_SPECIFIED) // || value.equalsIgnoreCase(AttributePropertiesImpl.NO_DIPLAY_UNIT) // || value.equalsIgnoreCase(AttributePropertiesImpl.NO_UNIT) || value // .equalsIgnoreCase(AttributePropertiesImpl.NO_STD_UNIT)); // if (!isADefaultValue && !presentValue.equals(value) && !value.isEmpty() && !value.equals("NaN")) { // 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); // } // } else { 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
418
7
19,977
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 ( ) ; // insert value in db only if input value is different and not a // default value 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 { // do not check if not a single value 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
450
7
19,978
private static Properties getPropertiesFile ( ) { try { // We use the class loader to load the properties file. // This compatible with unix and windows. final InputStream stream = TangoFactory . class . getClassLoader ( ) . getResourceAsStream ( FACTORY_PROPERTIES ) ; final Properties properties = new Properties ( ) ; // We read the data in the properties file. if ( stream != null ) { // We need to use a Buffered Input Stream to load the datas 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
162
9
19,979
private static Object getObject ( final String className ) { try { // we get the class coresponding to the life cycle name final Class < ? > clazz = Class . forName ( className ) ; // we get the default constructor (with no parameter) final Constructor < ? > contructor = clazz . getConstructor ( new Class [ ] { } ) ; // we create an instance of the class using the constructor return contructor . newInstance ( new Object [ ] { } ) ; } catch ( final Exception e ) { e . printStackTrace ( ) ; } return null ; }
We instanciate the Component
129
7
19,980
private void initTangoFactory ( ) { // we get the properties with instance of objects final Properties properties = getPropertiesFile ( ) ; // if(properties == null || properties.size() == 0 || // !properties.containsKey(TANGO_FACTORY)) // { // //tangoFactory = new DefaultTangoFactoryImpl(); // //TANGO_FACTORY = fr.esrf.TangoApi.factory.WebTangoFactoryImpl // // tangoFactory = (ITangoFactory)getObject(""); // isDefaultFactory = false; // } // else // { String factoryClassName = properties . getProperty ( TANGO_FACTORY ) ; if ( factoryClassName == null ) { factoryClassName = "fr.esrf.TangoApi.factory.DefaultTangoFactoryImpl" ; } //System.out.println("TANGO_FACTORY " + factoryClassName); tangoFactory = ( ITangoFactory ) getObject ( factoryClassName ) ; isDefaultFactory = false ; // } }
Load properties with impl specification and create instances
230
8
19,981
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
280
9
19,982
public void get_properties ( AttributeConfig conf ) { // // Copy mandatory properties // 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 ; // // Copy optional properties // 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 ; // // No extension nowdays // conf . extensions = new String [ 0 ] ; }
Get attribute properties .
212
4
19,983
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 .
61
14
19,984
@ Override 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
465
8
19,985
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
168
9
19,986
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
95
10
19,987
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 ( ) ; // EventManager.dump(os.getBufferCopy()); return os . getBufferCopy ( ) ; } finally { os . close ( ) ; } }
Marshall the ZmqCallInfo object
160
9
19,988
static double getZmqVersion ( ) { XLOGGER . entry ( ) ; if ( zmqVersion < 0.0 ) { // Not already checked. 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 ) { /*System.err.println(e);*/ } catch ( final Error e ) { /*System.err.println(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
250
29
19,989
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 ) ) { // for scalar except state, get only first value result = Array . get ( result , 0 ) ; } } return result ; }
Get value from an AttrValUnion
326
8
19,990
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 ( ) ) { // convert to array of primitives if necessary array = org . tango . utils . ArrayUtils . toPrimitiveArray ( value ) ; } else { // put in an array before inserting for scalars array = Array . newInstance ( AttributeTangoType . getTypeFromTango ( tangoType ) . getType ( ) , 1 ) ; 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
462
9
19,991
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 ) { // polled object is not a command. May be an attribute 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
414
3
19,992
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 ) ) { // command is also set as polled 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
293
18
19,993
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 ) ) { // command is also set as polled 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
283
3
19,994
public void removeAttributePolling ( final String attributeName ) throws DevFailed { // jive sends value with lower case, so manage it 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 ) ) { // command is also set as polled final CommandImpl cmd = CommandGetter . getCommand ( attribute . getName ( ) , commandList ) ; cmd . resetPolling ( ) ; cacheManager . removeCommandPolling ( cmd ) ; } savePollingConfig ( ) ; }
Remove attribute polling
188
3
19,995
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 ) ) { // attribute is also set as polled final AttributeImpl attribute = AttributeGetterSetter . getAttribute ( command . getName ( ) , attributeList ) ; attribute . resetPolling ( ) ; cacheManager . removeAttributePolling ( attribute ) ; pollAttributes . remove ( command . getName ( ) . toLowerCase ( Locale . ENGLISH ) ) ; savePollingConfig ( ) ; } }
Remove command polling
180
3
19,996
public void start ( final AttributeGroupReader valueReader , final long readingPeriod ) { this . valueReader = valueReader ; this . readingPeriod = readingPeriod ; // create a timer to read attributes executor = Executors . newScheduledThreadPool ( 1 ) ; future = executor . scheduleAtFixedRate ( valueReader , 0L , readingPeriod , TimeUnit . MILLISECONDS ) ; }
Start the periodic update
92
4
19,997
public void stop ( ) { if ( future != null ) { future . cancel ( true ) ; } if ( executor != null ) { executor . shutdownNow ( ) ; } }
Stop the refresh
39
3
19,998
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
89
5
19,999
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
386
8