MLZ: Fix mapping in NamedDigitalOutput device
Change-Id: Iaef2c4672eb3eceeaba2ec5750f964864ce76aa9 Reviewed-on: https://forge.frm2.tum.de/review/17733 Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de> Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
This commit is contained in:
@ -27,6 +27,7 @@
|
||||
Here we support devices which fulfill the official
|
||||
MLZ TANGO interface for the respective device classes.
|
||||
"""
|
||||
from __future__ import division
|
||||
|
||||
import re
|
||||
from time import sleep, time as currenttime
|
||||
@ -398,8 +399,7 @@ class Sensor(AnalogInput):
|
||||
|
||||
commands = {
|
||||
'setposition': Command('Set the position to the given value.',
|
||||
arguments=[FloatRange()],
|
||||
result=None
|
||||
arguments=[FloatRange()], result=None,
|
||||
),
|
||||
}
|
||||
|
||||
@ -566,8 +566,7 @@ class Actuator(AnalogOutput):
|
||||
|
||||
commands = {
|
||||
'setposition': Command('Set the position to the given value.',
|
||||
arguments=[FloatRange()],
|
||||
result=None
|
||||
arguments=[FloatRange()], result=None,
|
||||
),
|
||||
}
|
||||
|
||||
@ -814,17 +813,20 @@ class NamedDigitalOutput(DigitalOutput):
|
||||
"""A DigitalOutput with numeric values mapped to names.
|
||||
"""
|
||||
|
||||
# parameters = {
|
||||
# 'mapping': Param('A dictionary mapping state names to integers',
|
||||
# datatype=EnumType(), export=False), # XXX: !!!
|
||||
# }
|
||||
#
|
||||
# def init(self):
|
||||
# super(NamedDigitalOutput, self).init()
|
||||
# try: # XXX: !!!
|
||||
# self.parameters['value'].datatype = EnumType(**eval(self.mapping))
|
||||
# except Exception as e:
|
||||
# raise ValueError('Illegal Value for mapping: %r' % e)
|
||||
parameters = {
|
||||
'mapping': Param('A dictionary mapping state names to integers',
|
||||
datatype=StringType(), export=False),
|
||||
}
|
||||
|
||||
def init(self):
|
||||
super(NamedDigitalOutput, self).init()
|
||||
try:
|
||||
# pylint: disable=eval-used
|
||||
self.parameters['value'].datatype = EnumType(**eval(self.mapping))
|
||||
# pylint: disable=eval-used
|
||||
self.parameters['target'].datatype = EnumType(**eval(self.mapping))
|
||||
except Exception as e:
|
||||
raise ValueError('Illegal Value for mapping: %r' % e)
|
||||
|
||||
def write_target(self, value):
|
||||
# map from enum-str to integer value
|
||||
|
Reference in New Issue
Block a user