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