diff --git a/sardana_tango/ctrl/TangoAttrCTCtrl.py b/sardana_tango/ctrl/TangoAttrCTCtrl.py index 9ee5dc0..1abe8b5 100755 --- a/sardana_tango/ctrl/TangoAttrCTCtrl.py +++ b/sardana_tango/ctrl/TangoAttrCTCtrl.py @@ -141,11 +141,11 @@ class TangoAttrCTController(ReadTangoAttributes, CounterTimerController): +) TangoAttribute - Tango attribute to retrieve the value of the counter +) Formula - Formula to evaluate using 'VALUE' as the tango attribute value As examples you could have: - ch1.TangoExtraAttribute = 'my/tango/device/attribute1' + ch1.TangoAttribute = 'my/tango/device/attribute1' ch1.Formula = '-1 * VALUE' - ch2.TangoExtraAttribute = 'my/tango/device/attribute2' + ch2.TangoAttribute = 'my/tango/device/attribute2' ch2.Formula = 'math.sqrt(VALUE)' - ch3.TangoExtraAttribute = 'my_other/tango/device/attribute1' + ch3.TangoAttribute = 'my_other/tango/device/attribute1' ch3.Formula = 'math.cos(VALUE)' """ diff --git a/sardana_tango/ctrl/TangoAttrIORCtrl.py b/sardana_tango/ctrl/TangoAttrIORCtrl.py index 4a9cc48..489169e 100644 --- a/sardana_tango/ctrl/TangoAttrIORCtrl.py +++ b/sardana_tango/ctrl/TangoAttrIORCtrl.py @@ -76,9 +76,9 @@ class TangoAttrIORController(IORegisterController): Each IORegisters _MUST_HAVE_ extra attributes: +) TangoAttribute - Tango attribute to retrieve the value of the IORegister As examples you could have: - ch1.TangoExtraAttribute = 'my/tango/device/attribute1' - ch2.TangoExtraAttribute = 'my/tango/device/attribute2' - ch3.TangoExtraAttribute = 'my_other/tango/device/attribute1' + ch1.TangoAttribute = 'my/tango/device/attribute1' + ch2.TangoAttribute = 'my/tango/device/attribute2' + ch3.TangoAttribute = 'my_other/tango/device/attribute1' Each IORegisters _MAY_HAVE_ extra attributes: +) Labels - Human readable tag followed to the corresponding position (integer) value. @@ -169,9 +169,9 @@ def StateOne(self, axis): "Not yet configured the Tango Attribute, " "or cannot proxy it") if not lcalibration == 0 and not llabels == lcalibration: - return(State.Disable, - "Bad configuration of the extra attributes, " - "this cannot be operated") + return (State.Disable, + "Bad configuration of the extra attributes, " + "this cannot be operated") else: dev_state = dev_proxy.state() if readFailed and not dev_state == DevState.MOVING: @@ -211,7 +211,7 @@ def ReadOne(self, axis): try: positions.index(value) except Exception: - raise Exception("Invalid position.") + raise ValueError("Invalid position.") else: return value # case 1+fussy: the read from the attribute must be in one of the @@ -222,17 +222,22 @@ def ReadOne(self, axis): return positions[calibration.index(fussyPos)] # if the loop ends, current value is not in the fussy areas. self.devsExtraAttributes[axis][READFAILED] = True - raise Exception("Invalid position.") + msg = 'Value ({}) out of calibration bounds. ' \ + 'Please review ior calibration or write a valid value ' \ + 'to the underlying tango attribute: {}.{}'.format( + value, self.devsExtraAttributes[axis][DEVICE], attr) + raise ValueError(msg) else: raise Exception( "Bad configuration on optional extra attributes.") - except Exception: + except Exception as e: self._log.error('Exception reading attribute:%s.%s' % (self.devsExtraAttributes[axis][DEVICE], attr)) try: self.devsExtraAttributes[axis][READFAILED] = True except Exception: pass + raise e def WriteOne(self, axis, value): # If Labels is well defined, the write value must be one this struct @@ -256,7 +261,7 @@ def WriteOne(self, axis, value): try: positions.index(value) except Exception: - raise Exception("Invalid position.") + raise ValueError("Invalid position.") dev_proxy.write_attribute(attr, value) # case 1+fussy: the write to the to the IOR is translated to the # central position of the calibration. @@ -265,7 +270,7 @@ def WriteOne(self, axis, value): try: ior_destination = positions.index(value) except Exception: - raise Exception("Invalid position.") + raise ValueError("Invalid position.") self._log.debug("%s ior_destination = %s" % ( dev, ior_destination)) # central element @@ -273,9 +278,10 @@ def WriteOne(self, axis, value): self._log.debug("%s calibrated_position = %s" % ( dev, calibrated_position)) dev_proxy.write_attribute(attr, calibrated_position) - except Exception: + except Exception as e: self._log.error('Exception writing attribute:%s.%s' % (self.devsExtraAttributes[axis][DEVICE], attr)) + raise e # ## # # Auxiliar methods for the extra attributes