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 <markus.zolliker@psi.ch>
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Jens Krueger <jens.krueger@frm2.tum.de>
This commit is contained in:
Jens Krüger
2023-04-27 16:45:12 +02:00
committed by Jens Krueger
parent 02c20f5296
commit 507a941459

View File

@ -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()