diff --git a/ContextSaver.py b/ContextSaver.py index 63c23fbff0f2237b480b6923c6884bcbabe7a570..ca245848bb42ddcf5e3ff08aece9fc1617fe1afa 100644 --- a/ContextSaver.py +++ b/ContextSaver.py @@ -31,27 +31,36 @@ def get_wattr(proxy): logger.debug("Scanning write attribute of device %s"%proxy.name()) config = dict() - # Scan all attributes - for attr in proxy.get_attribute_list(): + # Get all attributes configuration + cattr = proxy.get_attribute_config(proxy.get_attribute_list()) + wattr=[] + for attr in cattr: logger.debug("Analyse attribute '%s' "%( - attr)) + attr.name)) - try: - if proxy.get_attribute_config(attr).writable in [ + if attr.writable in [ tango.AttrWriteType.WRITE, tango.AttrWriteType.READ_WRITE, tango.AttrWriteType.READ_WITH_WRITE]: - v= proxy[attr].value - if type(v) is numpy.ndarray: - v=v.tolist() - config[attr]=v + # attr is writtable, savbing it into list + wattr.append(attr.name) - logger.debug("Detect writtable attribute '%s' = %s"%( - attr, - proxy[attr].value)) - except tango.DevFailed: - logger.warning("Failed to save attribute '%s'"%attr) + logger.debug("Detect writtable attribute '%s'"%( + attr.name)) + + # Read all writtable attributes + rattr = proxy.read_attributes(wattr) + for attr in rattr: + v= attr.value + if type(v) is numpy.ndarray: + v=v.tolist() + + logger.debug("Read writtable attribute '%s' = %s"%( + attr.name, + v)) + + config[attr.name]=v return config