From 78ab28c6d3e2da697a63f189e57cf8e0363728fb Mon Sep 17 00:00:00 2001 From: Alexander Zaft Date: Wed, 22 Mar 2023 10:13:51 +0100 Subject: [PATCH] Fix entangle integration bugs found during ccr-box adaption * missing param description DigitalOutput * missing Writable baseclass in DigitalOutput * rework ccr config file Change-Id: Ie40f875caacd374b02e6f6175b5fb003619c5f4e Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30743 Tested-by: Jenkins Automated Tests Reviewed-by: Alexander Zaft --- cfg/ccr_cfg.py | 125 +++++++++++++++++++---------------------- frappy_mlz/entangle.py | 24 ++++---- 2 files changed, 69 insertions(+), 80 deletions(-) diff --git a/cfg/ccr_cfg.py b/cfg/ccr_cfg.py index dafff5e5..e23f1f84 100644 --- a/cfg/ccr_cfg.py +++ b/cfg/ccr_cfg.py @@ -1,9 +1,10 @@ -Node('MLZ_ccr12', - 'CCR box of MLZ Sample environment group\n' - '\n' - 'Contains a Lakeshore 336 and an PLC controlling the compressor\n' - 'and some valves.', - 'localhost:10767', +desc = '''CCR box of MLZ Sample environment group + + Contains a Lakeshore 336 and an PLC controlling the compressor + and some valves.''' +Node('MLZ_ccr', + desc, + 'tcp://10767', ) Mod('automatik', @@ -12,14 +13,14 @@ Mod('automatik', '\n' 'selects between off, regulate on p1 or regulate on p2 sensor', tangodevice = 'tango://localhost:10000/box/plc/_automatik', - mapping={'Off':0,'p1':1,'p2':2}, + mapping="{'Off':0,'p1':1,'p2':2}", ) Mod('compressor', 'frappy_mlz.entangle.NamedDigitalOutput', 'control the compressor (on/off)', tangodevice = 'tango://localhost:10000/box/plc/_cooler_onoff', - mapping={'Off':0,'On':1}, + mapping="{'Off':0,'On':1}", ) Mod('gas', @@ -30,7 +31,7 @@ Mod('gas', 'note: activation de-activates the vacuum inlet\n' 'note: if the pressure regulation is active, it enslave this device', tangodevice = 'tango://localhost:10000/box/plc/_gas_onoff', - mapping={'Off':0,'On':1}, + mapping="{'Off':0,'On':1}", ) Mod('vacuum', @@ -39,8 +40,8 @@ Mod('vacuum', '\n' 'note: activation de-activates the gas inlet\n' 'note: if the pressure regulation is active, it enslave this device', - tangodevice = 'tango://localhost:10000/box/plc/_vacuum_Onoff', - mapping={'Off':0,'On':1}, + tangodevice = 'tango://localhost:10000/box/plc/_vacuum_onoff', + mapping="{'Off':0,'On':1}", ) Mod('p1', @@ -72,88 +73,76 @@ Mod('curve_p2', 'CMR364':24, 'CMR365':25}", ) -# sensors +Mod('T_tube_regulation', + 'frappy_mlz.entangle.TemperatureController', + 'regulation of tube temperature', + tangodevice = 'tango://localhost:10000/box/tube/control1', + value = Param(unit = 'K'), + heateroutput = 0, + ramp = 6, + speed = 0.1, + setpoint = 0, + pid = (40, 10, 1), + p = 40, + i = 10, + d = 1, + abslimits = (0, 500), +) + +Mod('T_stick_regulation', + 'frappy_mlz.entangle.TemperatureController', + 'regualtion of stick temperature', + tangodevice = 'tango://localhost:10000/box/stick/control2', + value = Param(unit = 'K'), + heateroutput = 0, + ramp = 6, + speed = 0.1, + setpoint = 0, + pid = (40, 10, 1), + p = 40, + i = 10, + d = 1, + abslimits = (0, 500), +) Mod('T_sample', 'frappy_mlz.entangle.Sensor', 'sample temperature', tangodevice = 'tango://localhost:10000/box/sample/sensora', - value = Param(unit='K'), + value = Param(unit = 'K'), ) Mod('T_stick', 'frappy_mlz.entangle.Sensor', 'temperature at bottom of sample stick', tangodevice = 'tango://localhost:10000/box/stick/sensorb', - value = Param(unit='K'), + value = Param(unit = 'K'), ) Mod('T_coldhead', 'frappy_mlz.entangle.Sensor', 'temperature at coldhead', - tangodevice = 'tango://localhost:10000/box/stick/sensorc', - value = Param(unit='K'), + tangodevice = 'tango://localhost:10000/box/coldhead/sensorc', + value = Param(unit = 'K'), ) Mod('T_tube', 'frappy_mlz.entangle.Sensor', 'temperature at thermal coupling tube <-> stick', tangodevice = 'tango://localhost:10000/box/tube/sensord', - value = Param(unit='K'), + value = Param(unit = 'K'), ) -# regulations - -Mod('T_stick_regulation', - 'frappy_mlz.entangle.TemperatureController', - 'regulation of stick temperature', - tangodevice = 'tango://localhost:10000/box/stick/control2', - heateroutput = 0, - ramp = 6, - speed = 0.1, - setpoint = 0, - pid = (40,10,1), - p = 40, - i = 10, - d = 1, - abslimits = (0,500), - value = Param(unit='K'), -) - -# OMG! a NamedDigitalOutput, but with float'ints' 0..3 -Mod('T_stick_regulation_heaterrange', - 'frappy_mlz.entangle.AnalogOutput', - 'heaterrange for stick regulation', - tangodevice = 'tango://localhost:10000/box/stick/range2', - precision = 1, - abslimits = (0,3), -) - -Mod('module T_tube_regulation', - 'frappy_mlz.entangle.TemperatureController', - 'regulation of tube temperature', - tangodevice = 'tango://localhost:10000/box/tube/control1', - heateroutput = 0, - ramp = 6, - speed = 0.1, - setpoint = 0, - pid = (40,10,1), - p = 40, - i = 10, - d = 1, - abslimits = (0,500), - value = Param(unit='K'), -) - -# OMG! a NamedDigitalOutput, but with float'ints' 0..3 -#[module T_tube_regulation_heaterrange] -#class=frappy_mlz.entangle.AnalogOutput -#tangodevice=tango://localhost:10000/box/tube/range1 -#precision.default=1 -#abslimits=(0,3) - +# THIS IS A HACK: due to entangle (in controller) Mod('T_tube_regulation_heaterrange', 'frappy_mlz.entangle.NamedDigitalOutput', 'heaterrange for tube regulation', 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', + 'frappy_mlz.entangle.NamedDigitalOutput', + 'heaterrange for stick regulation', + tangodevice = 'tango://localhost:10000/box/stick/range2', + mapping="{'Off':0,'Low':1,'Medium':2, 'High':3}", ) diff --git a/frappy_mlz/entangle.py b/frappy_mlz/entangle.py index 0a79f290..a542d7b3 100644 --- a/frappy_mlz/entangle.py +++ b/frappy_mlz/entangle.py @@ -32,17 +32,17 @@ MLZ TANGO interface for the respective device classes. import re import threading -from time import sleep -from time import time as currenttime +from time import sleep, time as currenttime import PyTango -from frappy.datatypes import ArrayOf, EnumType, FloatRange, \ - IntRange, LimitsType, StringType, TupleOf -from frappy.errors import CommunicationFailedError, \ - ConfigError, HardwareError, ProgrammingError + +from frappy.datatypes import ArrayOf, EnumType, FloatRange, IntRange, \ + LimitsType, StringType, TupleOf +from frappy.errors import CommunicationFailedError, ConfigError, \ + HardwareError, ProgrammingError from frappy.lib import lazy_property -from frappy.modules import Command, StatusType, \ - Drivable, Module, Parameter, Readable +from frappy.modules import Command, Drivable, Module, Parameter, Readable, \ + StatusType, Writable ##### @@ -860,20 +860,20 @@ class PartialDigitalInput(NamedDigitalInput): return value # mapping is done by datatype upon export() -class DigitalOutput(PyTangoDevice): +class DigitalOutput(PyTangoDevice, Writable): """A device that can set and read a digital value corresponding to a bitfield. """ # overrides - value = Parameter(datatype=IntRange()) - target = Parameter(datatype=IntRange()) + value = Parameter('current value', datatype=IntRange()) + target = Parameter('target value', datatype=IntRange()) def read_value(self): return self._dev.value # mapping is done by datatype upon export() def read_status(self): - status = self.read_status() + status = super().read_status() self.setFastPoll(self.isBusy(status)) return status