fixes in mercury an triton

- Valve is now a drivable, as it will check success, and retry,
  which might take around 1 second
+ some more
This commit is contained in:
2022-06-14 15:07:17 +02:00
parent 54b58f2188
commit dfbc1c757a
3 changed files with 107 additions and 25 deletions

View File

@ -318,8 +318,8 @@ class HeaterOutput(HasInput, MercuryChannel, Writable):
return volt * current
def read_target(self):
if self.controlled_by != 0 and self.target:
return 0
if self.controlled_by != 0:
return Done
if self._last_target is not None:
return Done
self._volt_target = self.query('HTR:SIG:VOLT')
@ -344,25 +344,28 @@ class HeaterOutput(HasInput, MercuryChannel, Writable):
class TemperatureLoop(TemperatureSensor, Loop, Drivable):
channel_type = 'TEMP'
output_module = Attached(HeaterOutput, mandatory=False)
output_module = Attached(HasInput, mandatory=False)
ramp = Parameter('ramp rate', FloatRange(0, unit='K/min'), readonly=False)
enable_ramp = Parameter('enable ramp rate', BoolType(), readonly=False)
setpoint = Parameter('working setpoint (differs from target when ramping)', FloatRange(0, unit='$'))
tolerance = Parameter(default=0.1)
_last_setpoint_change = None
ENABLE = 'TEMP:LOOP:ENAB'
ENABLE_RAMP = 'TEMP:LOOP:RENA'
RAMP_RATE = 'TEMP:LOOP:RSET'
def doPoll(self):
super().doPoll()
self.read_setpoint()
def read_control_active(self):
active = self.query('TEMP:LOOP:ENAB', off_on)
active = self.query(self.ENABLE, off_on)
self.set_output(active)
return active
def write_control_active(self, value):
self.set_output(value)
return self.change('TEMP:LOOP:ENAB', value, off_on)
return self.change(self.ENABLE, value, off_on)
@nopoll # polled by read_setpoint
def read_target(self):
@ -396,10 +399,10 @@ class TemperatureLoop(TemperatureSensor, Loop, Drivable):
return Done
def read_enable_ramp(self):
return self.query('TEMP:LOOP:RENA', off_on)
return self.query(self.ENABLE_RAMP, off_on)
def write_enable_ramp(self, value):
return self.change('TEMP:LOOP:RENA', value, off_on)
return self.change(self.ENABLE_RAMP, value, off_on)
def set_output(self, active):
if active:
@ -413,7 +416,7 @@ class TemperatureLoop(TemperatureSensor, Loop, Drivable):
self.status = status
def read_ramp(self):
result = self.query('TEMP:LOOP:RSET')
result = self.query(self.RAMP_RATE)
return min(9e99, result)
def write_ramp(self, value):
@ -422,11 +425,11 @@ class TemperatureLoop(TemperatureSensor, Loop, Drivable):
self.write_enable_ramp(0)
return 0
if value >= 9e99:
self.change('TEMP:LOOP:RSET', 'inf', as_string)
self.change(self.RAMP_RATE, 'inf', as_string)
self.write_enable_ramp(0)
return 9e99
self.write_enable_ramp(1)
return self.change('TEMP:LOOP:RSET', max(1e-4, value))
return self.change(self.RAMP_RATE, max(1e-4, value))
class PressureSensor(MercuryChannel, Readable):
@ -542,6 +545,7 @@ class HeLevel(MercuryChannel, Readable):
(when filling) and slow (when consuming). We have to handle this by software.
"""
channel_type = 'LVL'
value = Parameter(unit='%')
sample_rate = Parameter('_', EnumType(slow=0, fast=1), readonly=False)
hysteresis = Parameter('hysteresis for detection of increase', FloatRange(0, 100, unit='%'),
default=5, readonly=False)
@ -595,9 +599,7 @@ class HeLevel(MercuryChannel, Readable):
class N2Level(MercuryChannel, Readable):
channel_type = 'LVL'
value = Parameter(unit='%')
def read_value(self):
return self.query('LVL:SIG:NIT:LEV')
# TODO: magnet power supply