mercury, ips, sea, triton, convergence

after gerrit

Change-Id: Iff14047ecc476589aef10c96fae9970133b8bd14
This commit is contained in:
2023-05-09 14:57:34 +02:00
parent 750b5a7794
commit 8039351395
12 changed files with 426 additions and 357 deletions

View File

@ -20,14 +20,13 @@
# *****************************************************************************
"""oxford instruments triton (kelvinoxjt dil)"""
from math import sqrt, log10
from math import sqrt
from frappy.core import Writable, Parameter, Readable, Drivable, IDLE, WARN, BUSY, ERROR, \
Done, Property
from frappy.datatypes import EnumType, FloatRange, StringType
from frappy.lib.enum import Enum
from frappy_psi.mercury import MercuryChannel, Mapped, off_on, HasInput, SELF
from frappy.lib import clamp
import frappy_psi.mercury as mercury
from frappy_psi import mercury
actions = Enum(none=0, condense=1, circulate=2, collect=3)
open_close = Mapped(CLOSE=0, OPEN=1)
@ -36,7 +35,7 @@ actions_map.mapping['NONE'] = actions.none # when writing, STOP is used instead
class Action(MercuryChannel, Writable):
channel_type = 'ACTN'
kind = 'ACTN'
cooldown_channel = Property('cool down channel', StringType(), 'T5')
mix_channel = Property('mix channel', StringType(), 'T5')
value = Parameter('running action', EnumType(actions))
@ -72,7 +71,7 @@ class Action(MercuryChannel, Writable):
class Valve(MercuryChannel, Drivable):
channel_type = 'VALV'
kind = 'VALV'
value = Parameter('valve state', EnumType(closed=0, opened=1))
target = Parameter('valve target', EnumType(close=0, open=1))
@ -82,7 +81,7 @@ class Valve(MercuryChannel, Drivable):
self.read_status()
def read_value(self):
return self.query('VALV:SIG:STATE', open_close)
return self.query('DEV::VALV:SIG:STATE', open_close)
def read_status(self):
pos = self.read_value()
@ -92,41 +91,41 @@ class Valve(MercuryChannel, Drivable):
# success
if self._try_count:
# make sure last sent command was not opposite
self.change('VALV:SIG:STATE', self.target, open_close)
self.change('DEV::VALV:SIG:STATE', self.target, open_close)
self._try_count = None
self.setFastPoll(False)
return IDLE, ''
self._try_count += 1
if self._try_count % 4 == 0:
# send to opposite position in order to unblock
self.change('VALV:SIG:STATE', pos, open_close)
self.change('DEV::VALV:SIG:STATE', pos, open_close)
return BUSY, 'unblock'
if self._try_count > 9:
# make sure system does not toggle later
self.change('VALV:SIG:STATE', pos, open_close)
self.change('DEV::VALV:SIG:STATE', pos, open_close)
return ERROR, 'can not %s valve' % self.target.name
self.change('VALV:SIG:STATE', self.target, open_close)
self.change('DEV::VALV:SIG:STATE', self.target, open_close)
return BUSY, 'waiting'
def write_target(self, value):
if value != self.read_value():
self._try_count = 0
self.setFastPoll(True, 0.25)
self.change('VALV:SIG:STATE', value, open_close)
self.change('DEV::VALV:SIG:STATE', value, open_close)
self.status = BUSY, self.target.name
return value
class Pump(MercuryChannel, Writable):
channel_type = 'PUMP'
kind = 'PUMP'
value = Parameter('pump state', EnumType(off=0, on=1))
target = Parameter('pump target', EnumType(off=0, on=1))
def read_value(self):
return self.query('PUMP:SIG:STATE', off_on)
return self.query('DEV::PUMP:SIG:STATE', off_on)
def write_target(self, value):
return self.change('PUMP:SIG:STATE', value, off_on)
return self.change('DEV::PUMP:SIG:STATE', value, off_on)
def read_status(self):
return IDLE, ''
@ -142,35 +141,35 @@ class TurboPump(Pump):
electronics_temp = Parameter('temperature of electronics', FloatRange(unit='K'))
def read_status(self):
status = self.query('PUMP:STATUS', str)
status = self.query('DEV::PUMP:STATUS', str)
if status == 'OK':
return IDLE, ''
return WARN, status
def read_power(self):
return self.query('PUMP:SIG:POWR')
return self.query('DEV::PUMP:SIG:POWR')
def read_freq(self):
return self.query('PUMP:SIG:SPD')
return self.query('DEV::PUMP:SIG:SPD')
def read_powerstage_temp(self):
return self.query('PUMP:SIG:PST')
return self.query('DEV::PUMP:SIG:PST')
def read_motor_temp(self):
return self.query('PUMP:SIG:MT')
return self.query('DEV::PUMP:SIG:MT')
def read_bearing_temp(self):
return self.query('PUMP:SIG:BT')
return self.query('DEV::PUMP:SIG:BT')
def read_pumpbase_temp(self):
return self.query('PUMP:SIG:PBT')
return self.query('DEV::PUMP:SIG:PBT')
def read_electronics_temp(self):
return self.query('PUMP:SIG:ET')
return self.query('DEV::PUMP:SIG:ET')
# class PulseTubeCompressor(MercuryChannel, Writable):
# channel_type = 'PTC'
# kind = 'PTC'
# value = Parameter('compressor state', EnumType(closed=0, opened=1))
# target = Parameter('compressor target', EnumType(close=0, open=1))
# water_in_temp = Parameter('temperature of water inlet', FloatRange(unit='K'))
@ -181,42 +180,42 @@ class TurboPump(Pump):
# motor_current = Parameter('motor current', FloatRange(unit='A'))
#
# def read_value(self):
# return self.query('PTC:SIG:STATE', off_on)
# return self.query('DEV::PTC:SIG:STATE', off_on)
#
# def write_target(self, value):
# return self.change('PTC:SIG:STATE', value, off_on)
# return self.change('DEV::PTC:SIG:STATE', value, off_on)
#
# def read_status(self):
# # TODO: check possible status values
# return self.WARN, self.query('PTC:SIG:STATUS')
# return self.WARN, self.query('DEV::PTC:SIG:STATUS')
#
# def read_water_in_temp(self):
# return self.query('PTC:SIG:WIT')
# return self.query('DEV::PTC:SIG:WIT')
#
# def read_water_out_temp(self):
# return self.query('PTC:SIG:WOT')
# return self.query('DEV::PTC:SIG:WOT')
#
# def read_helium_temp(self):
# return self.query('PTC:SIG:HT')
# return self.query('DEV::PTC:SIG:HT')
#
# def read_helium_low_pressure(self):
# return self.query('PTC:SIG:HLP')
# return self.query('DEV::PTC:SIG:HLP')
#
# def read_helium_high_pressure(self):
# return self.query('PTC:SIG:HHP')
# return self.query('DEV::PTC:SIG:HHP')
#
# def read_motor_current(self):
# return self.query('PTC:SIG:MCUR')
# return self.query('DEV::PTC:SIG:MCUR')
class FlowMeter(MercuryChannel, Readable):
channel_type = 'FLOW'
kind = 'FLOW'
def read_value(self):
return self.query('FLOW:SIG:FLOW')
return self.query('DEV::FLOW:SIG:FLOW')
class ScannerChannel:
class ScannerChannel(MercuryChannel):
# TODO: excitation, enable
# TODO: switch on/off filter, check
filter_time = Parameter('filter time', FloatRange(1, 200, unit='sec'), readonly=False)
@ -224,24 +223,24 @@ class ScannerChannel:
pause_time = Parameter('pause time', FloatRange(3, 200, unit='sec'), readonly=False)
def read_filter_time(self):
return self.query('TEMP:FILT:TIME')
return self.query('DEV::TEMP:FILT:TIME')
def write_filter_time(self, value):
self.change('TEMP:FILT:WIN', 80)
return self.change('TEMP:FILT:TIME', value)
self.change('DEV::TEMP:FILT:WIN', 80)
return self.change('DEV::TEMP:FILT:TIME', value)
def read_dwell_time(self):
return self.query('TEMP:MEAS:DWEL')
return self.query('DEV::TEMP:MEAS:DWEL')
def write_dwell_time(self, value):
self.change('TEMP:FILT:WIN', 80)
return self.change('TEMP:MEAS:DWEL', value)
self.change('DEV::TEMP:FILT:WIN', 80)
return self.change('DEV::TEMP:MEAS:DWEL', value)
def read_pause_time(self):
return self.query('TEMP:MEAS:PAUS')
return self.query('DEV::TEMP:MEAS:PAUS')
def write_pause_time(self, value):
return self.change('TEMP:MEAS:PAUS', value)
return self.change('DEV::TEMP:MEAS:PAUS', value)
class TemperatureSensor(ScannerChannel, mercury.TemperatureSensor):
@ -261,7 +260,7 @@ class TemperatureLoop(ScannerChannel, mercury.TemperatureLoop):
if self.system_channel:
self.change('SYS:DR:CHAN:%s' % self.system_channel, self.slot.split(',')[0], str)
if value:
self.change('TEMP:LOOP:FILT:ENAB', 'ON', str)
self.change('DEV::TEMP:LOOP:FILT:ENAB', 'ON', str)
if self.output_module:
limit = self.output_module.read_limit() or None # None: max. limit
self.output_module.write_limit(limit)
@ -270,16 +269,16 @@ class TemperatureLoop(ScannerChannel, mercury.TemperatureLoop):
class HeaterOutput(HasInput, MercuryChannel, Writable):
"""heater output"""
channel_type = 'HTR'
kind = 'HTR'
value = Parameter('heater output', FloatRange(unit='uW'))
target = Parameter('heater output', FloatRange(0, unit='$'), readonly=False)
resistivity = Parameter('heater resistivity', FloatRange(unit='Ohm'))
def read_resistivity(self):
return self.query('HTR:RES')
return self.query('DEV::HTR:RES')
def read_value(self):
return round(self.query('HTR:SIG:POWR'), 3)
return round(self.query('DEV::HTR:SIG:POWR'), 3)
def read_target(self):
if self.controlled_by != 0:
@ -291,17 +290,17 @@ class HeaterOutput(HasInput, MercuryChannel, Writable):
if self.resistivity:
# round to the next voltage step
value = round(sqrt(value * self.resistivity)) ** 2 / self.resistivity
return round(self.change('HTR:SIG:POWR', value), 3)
return round(self.change('DEV::HTR:SIG:POWR', value), 3)
class HeaterOutputWithRange(HeaterOutput):
"""heater output with heater range"""
channel_type = 'HTR,TEMP'
kind = 'HTR,TEMP'
limit = Parameter('max. heater power', FloatRange(unit='uW'), readonly=False)
def read_limit(self):
maxcur = self.query('TEMP:LOOP:RANGE') # mA
maxcur = self.query('DEV::TEMP:LOOP:RANGE') # mA
return self.read_resistivity() * maxcur ** 2 # uW
def write_limit(self, value):
@ -315,6 +314,5 @@ class HeaterOutputWithRange(HeaterOutput):
break
else:
maxcur = cur
self.change('TEMP:LOOP:RANGE', maxcur)
self.change('DEV::TEMP:LOOP:RANGE', maxcur)
return self.read_limit()