make entangle mapping a dict
Change-Id: I38d863a907469674001f0721140f88c17b53635b Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30911 Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de> Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de> Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
This commit is contained in:
@ -37,12 +37,12 @@ from time import sleep, time as currenttime
|
||||
import PyTango
|
||||
|
||||
from frappy.datatypes import ArrayOf, EnumType, FloatRange, IntRange, \
|
||||
LimitsType, StringType, TupleOf
|
||||
LimitsType, StringType, TupleOf, ValueType
|
||||
from frappy.errors import CommunicationFailedError, ConfigError, \
|
||||
HardwareError, ProgrammingError
|
||||
from frappy.lib import lazy_property
|
||||
from frappy.modules import Command, Drivable, Module, Parameter, Readable, \
|
||||
StatusType, Writable
|
||||
StatusType, Writable, Property
|
||||
|
||||
#####
|
||||
|
||||
@ -812,19 +812,13 @@ class NamedDigitalInput(DigitalInput):
|
||||
"""
|
||||
|
||||
# parameters
|
||||
mapping = Parameter('A dictionary mapping state names to integers',
|
||||
datatype=StringType(), export=False) # XXX:!!!
|
||||
mapping = Property('A dictionary mapping state names to integers',
|
||||
datatype=ValueType(dict))
|
||||
|
||||
def initModule(self):
|
||||
super().initModule()
|
||||
try:
|
||||
mapping = self.mapping
|
||||
if isinstance(mapping, str):
|
||||
# pylint: disable=eval-used
|
||||
mapping = eval(self.mapping.replace('\n', ' '))
|
||||
if isinstance(mapping, str):
|
||||
# pylint: disable=eval-used
|
||||
mapping = eval(mapping)
|
||||
self.accessibles['value'].setProperty('datatype', EnumType('value', **mapping))
|
||||
except Exception as e:
|
||||
raise ValueError(f'Illegal Value for mapping: {self.mapping!r}') from e
|
||||
@ -889,19 +883,13 @@ class NamedDigitalOutput(DigitalOutput):
|
||||
"""
|
||||
|
||||
# parameters
|
||||
mapping = Parameter('A dictionary mapping state names to integers',
|
||||
datatype=StringType(), export=False)
|
||||
mapping = Property('A dictionary mapping state names to integers',
|
||||
datatype=ValueType(dict))
|
||||
|
||||
def initModule(self):
|
||||
super().initModule()
|
||||
try:
|
||||
mapping = self.mapping
|
||||
if isinstance(mapping, str):
|
||||
# pylint: disable=eval-used
|
||||
mapping = eval(self.mapping.replace('\n', ' '))
|
||||
if isinstance(mapping, str):
|
||||
# pylint: disable=eval-used
|
||||
mapping = eval(mapping)
|
||||
self.accessibles['value'].setProperty('datatype', EnumType('value', **mapping))
|
||||
self.accessibles['target'].setProperty('datatype', EnumType('target', **mapping))
|
||||
except Exception as e:
|
||||
|
Reference in New Issue
Block a user