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:
parent
a334cc4f0a
commit
d18e368ab9
@ -13,14 +13,14 @@ Mod('automatik',
|
|||||||
'\n'
|
'\n'
|
||||||
'selects between off, regulate on p1 or regulate on p2 sensor',
|
'selects between off, regulate on p1 or regulate on p2 sensor',
|
||||||
tangodevice = 'tango://localhost:10000/box/plc/_automatik',
|
tangodevice = 'tango://localhost:10000/box/plc/_automatik',
|
||||||
mapping="{'Off':0,'p1':1,'p2':2}",
|
mapping={'Off':0,'p1':1,'p2':2},
|
||||||
)
|
)
|
||||||
|
|
||||||
Mod('compressor',
|
Mod('compressor',
|
||||||
'frappy_mlz.entangle.NamedDigitalOutput',
|
'frappy_mlz.entangle.NamedDigitalOutput',
|
||||||
'control the compressor (on/off)',
|
'control the compressor (on/off)',
|
||||||
tangodevice = 'tango://localhost:10000/box/plc/_cooler_onoff',
|
tangodevice = 'tango://localhost:10000/box/plc/_cooler_onoff',
|
||||||
mapping="{'Off':0,'On':1}",
|
mapping={'Off':0,'On':1},
|
||||||
)
|
)
|
||||||
|
|
||||||
Mod('gas',
|
Mod('gas',
|
||||||
@ -31,7 +31,7 @@ Mod('gas',
|
|||||||
'note: activation de-activates the vacuum inlet\n'
|
'note: activation de-activates the vacuum inlet\n'
|
||||||
'note: if the pressure regulation is active, it enslave this device',
|
'note: if the pressure regulation is active, it enslave this device',
|
||||||
tangodevice = 'tango://localhost:10000/box/plc/_gas_onoff',
|
tangodevice = 'tango://localhost:10000/box/plc/_gas_onoff',
|
||||||
mapping="{'Off':0,'On':1}",
|
mapping={'Off':0,'On':1},
|
||||||
)
|
)
|
||||||
|
|
||||||
Mod('vacuum',
|
Mod('vacuum',
|
||||||
@ -41,7 +41,7 @@ Mod('vacuum',
|
|||||||
'note: activation de-activates the gas inlet\n'
|
'note: activation de-activates the gas inlet\n'
|
||||||
'note: if the pressure regulation is active, it enslave this device',
|
'note: if the pressure regulation is active, it enslave this device',
|
||||||
tangodevice = 'tango://localhost:10000/box/plc/_vacuum_onoff',
|
tangodevice = 'tango://localhost:10000/box/plc/_vacuum_onoff',
|
||||||
mapping="{'Off':0,'On':1}",
|
mapping={'Off':0,'On':1},
|
||||||
)
|
)
|
||||||
|
|
||||||
Mod('p1',
|
Mod('p1',
|
||||||
@ -63,14 +63,14 @@ Mod('curve_p2',
|
|||||||
'calibration curve for pressure sensor 2',
|
'calibration curve for pressure sensor 2',
|
||||||
tangodevice = 'tango://localhost:10000/box/plc/_curve',
|
tangodevice = 'tango://localhost:10000/box/plc/_curve',
|
||||||
value = 0,
|
value = 0,
|
||||||
mapping = "{'0-10V':0, '0-1000mbar':1, '1-9V to 0-1 mbar':2, \
|
mapping = {'0-10V':0, '0-1000mbar':1, '1-9V to 0-1 mbar':2,
|
||||||
'DI200':3, 'DI2000':4, 'TTR100':7, 'PTR90':8, \
|
'DI200':3, 'DI2000':4, 'TTR100':7, 'PTR90':8,
|
||||||
'PTR225/237':9, 'ITR90':10, 'ITR100-D':11, \
|
'PTR225/237':9, 'ITR90':10, 'ITR100-D':11,
|
||||||
'ITR100-2':12, 'ITR100-3':13, 'ITR100-4':14, \
|
'ITR100-2':12, 'ITR100-3':13, 'ITR100-4':14,
|
||||||
'ITR100-5':15, 'ITR100-6':16, 'ITR100-7':17, \
|
'ITR100-5':15, 'ITR100-6':16, 'ITR100-7':17,
|
||||||
'ITR100-8':18, 'ITR100-9':19, 'ITR100-A':20, \
|
'ITR100-8':18, 'ITR100-9':19, 'ITR100-A':20,
|
||||||
'CMR361':21, 'CMR362':22, 'CMR363':23, \
|
'CMR361':21, 'CMR362':22, 'CMR363':23,
|
||||||
'CMR364':24, 'CMR365':25}",
|
'CMR364':24, 'CMR365':25},
|
||||||
)
|
)
|
||||||
|
|
||||||
Mod('T_tube_regulation',
|
Mod('T_tube_regulation',
|
||||||
@ -137,12 +137,12 @@ Mod('T_tube_regulation_heaterrange',
|
|||||||
'frappy_mlz.entangle.NamedDigitalOutput',
|
'frappy_mlz.entangle.NamedDigitalOutput',
|
||||||
'heaterrange for tube regulation',
|
'heaterrange for tube regulation',
|
||||||
tangodevice = 'tango://localhost:10000/box/tube/range1',
|
tangodevice = 'tango://localhost:10000/box/tube/range1',
|
||||||
mapping="{'Off':0,'Low':1,'Medium':2, 'High':3}",
|
mapping={'Off':0,'Low':1,'Medium':2, 'High':3},
|
||||||
)
|
)
|
||||||
|
|
||||||
Mod('T_stick_regulation_heaterrange',
|
Mod('T_stick_regulation_heaterrange',
|
||||||
'frappy_mlz.entangle.NamedDigitalOutput',
|
'frappy_mlz.entangle.NamedDigitalOutput',
|
||||||
'heaterrange for stick regulation',
|
'heaterrange for stick regulation',
|
||||||
tangodevice = 'tango://localhost:10000/box/stick/range2',
|
tangodevice = 'tango://localhost:10000/box/stick/range2',
|
||||||
mapping="{'Off':0,'Low':1,'Medium':2, 'High':3}",
|
mapping={'Off':0,'Low':1,'Medium':2, 'High':3},
|
||||||
)
|
)
|
||||||
|
@ -44,3 +44,10 @@ Mod('Lower',
|
|||||||
'frappy_demo.test.Lower',
|
'frappy_demo.test.Lower',
|
||||||
'something else',
|
'something else',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Mod('Decision',
|
||||||
|
'frappy_demo.test.Mapped',
|
||||||
|
'Random value from configured property choices. Config accepts anything ' \
|
||||||
|
'that can be converted to a list',
|
||||||
|
choices = ['Yes', 'Maybe', 'No'],
|
||||||
|
)
|
||||||
|
@ -23,8 +23,9 @@
|
|||||||
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from frappy.datatypes import FloatRange, StringType
|
from frappy.datatypes import FloatRange, StringType, ValueType
|
||||||
from frappy.modules import Communicator, Drivable, Parameter, Readable
|
from frappy.modules import Communicator, Drivable, Parameter, Property, \
|
||||||
|
Readable
|
||||||
from frappy.params import Command
|
from frappy.params import Command
|
||||||
|
|
||||||
|
|
||||||
@ -93,3 +94,10 @@ class Lower(Communicator):
|
|||||||
def communicate(self, command):
|
def communicate(self, command):
|
||||||
"""lowercase a string"""
|
"""lowercase a string"""
|
||||||
return str(command).lower()
|
return str(command).lower()
|
||||||
|
|
||||||
|
class Mapped(Readable):
|
||||||
|
value = Parameter(datatype=StringType())
|
||||||
|
choices = Property('List of choices',
|
||||||
|
datatype=ValueType(list))
|
||||||
|
def read_value(self):
|
||||||
|
return self.choices[random.randrange(len(self.choices))]
|
||||||
|
@ -37,12 +37,12 @@ from time import sleep, time as currenttime
|
|||||||
import PyTango
|
import PyTango
|
||||||
|
|
||||||
from frappy.datatypes import ArrayOf, EnumType, FloatRange, IntRange, \
|
from frappy.datatypes import ArrayOf, EnumType, FloatRange, IntRange, \
|
||||||
LimitsType, StringType, TupleOf
|
LimitsType, StringType, TupleOf, ValueType
|
||||||
from frappy.errors import CommunicationFailedError, ConfigError, \
|
from frappy.errors import CommunicationFailedError, ConfigError, \
|
||||||
HardwareError, ProgrammingError
|
HardwareError, ProgrammingError
|
||||||
from frappy.lib import lazy_property
|
from frappy.lib import lazy_property
|
||||||
from frappy.modules import Command, Drivable, Module, Parameter, Readable, \
|
from frappy.modules import Command, Drivable, Module, Parameter, Readable, \
|
||||||
StatusType, Writable
|
StatusType, Writable, Property
|
||||||
|
|
||||||
#####
|
#####
|
||||||
|
|
||||||
@ -812,19 +812,13 @@ class NamedDigitalInput(DigitalInput):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# parameters
|
# parameters
|
||||||
mapping = Parameter('A dictionary mapping state names to integers',
|
mapping = Property('A dictionary mapping state names to integers',
|
||||||
datatype=StringType(), export=False) # XXX:!!!
|
datatype=ValueType(dict))
|
||||||
|
|
||||||
def initModule(self):
|
def initModule(self):
|
||||||
super().initModule()
|
super().initModule()
|
||||||
try:
|
try:
|
||||||
mapping = self.mapping
|
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['value'].setProperty('datatype', EnumType('value', **mapping))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ValueError(f'Illegal Value for mapping: {self.mapping!r}') from e
|
raise ValueError(f'Illegal Value for mapping: {self.mapping!r}') from e
|
||||||
@ -889,19 +883,13 @@ class NamedDigitalOutput(DigitalOutput):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# parameters
|
# parameters
|
||||||
mapping = Parameter('A dictionary mapping state names to integers',
|
mapping = Property('A dictionary mapping state names to integers',
|
||||||
datatype=StringType(), export=False)
|
datatype=ValueType(dict))
|
||||||
|
|
||||||
def initModule(self):
|
def initModule(self):
|
||||||
super().initModule()
|
super().initModule()
|
||||||
try:
|
try:
|
||||||
mapping = self.mapping
|
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['value'].setProperty('datatype', EnumType('value', **mapping))
|
||||||
self.accessibles['target'].setProperty('datatype', EnumType('target', **mapping))
|
self.accessibles['target'].setProperty('datatype', EnumType('target', **mapping))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user