From 507a941459be74314969d59d60dcb9aa60c3f27b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Kr=C3=BCger?= Date: Thu, 27 Apr 2023 16:45:12 +0200 Subject: [PATCH] MLZ/Entangle: Add unit init in AnalogOutput The init of the units in AnalogOutput should follow the same algorithm as the AnalogInput branch Change-Id: Ica5349f389d28fef2c97037d2b61266bc395b2f7 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30969 Reviewed-by: Markus Zolliker Tested-by: Jenkins Automated Tests Reviewed-by: Enrico Faulhaber Reviewed-by: Jens Krueger --- frappy_mlz/entangle.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/frappy_mlz/entangle.py b/frappy_mlz/entangle.py index 432c26ba..10f47ce3 100644 --- a/frappy_mlz/entangle.py +++ b/frappy_mlz/entangle.py @@ -460,6 +460,12 @@ class AnalogOutput(PyTangoDevice, Drivable): _history = () _timeout = None _moving = False + __main_unit = None + + def applyMainUnit(self, mainunit): + # called from __init__ method + # replacement of '$' by main unit must be done later + self.__main_unit = mainunit def initModule(self): super().initModule() @@ -469,12 +475,18 @@ class AnalogOutput(PyTangoDevice, Drivable): def startModule(self, start_events): super().startModule(start_events) - # query unit from tango and update value property - attrInfo = self._dev.attribute_query('value') - # prefer configured unit if nothing is set on the Tango device, else - # update - if attrInfo.unit != 'No unit': - self.accessibles['value'].datatype.setProperty('unit', attrInfo.unit) + try: + # query unit from tango and update value property + attrInfo = self._dev.attribute_query('value') + # prefer configured unit if nothing is set on the Tango device, else + # update + if attrInfo.unit != 'No unit': + self.accessibles['value'].datatype.setProperty('unit', attrInfo.unit) + self.__main_unit = attrInfo.unit + except Exception as e: + self.log.error(e) + if self.__main_unit: + super().applyMainUnit(self.__main_unit) def doPoll(self): super().doPoll()