improve lakeshore demo
use super call for read_status TODO: update tutorial! Change-Id: I2dd5631908dc370c6e6286587099e25a0e5ee867
This commit is contained in:
parent
5b9e36180e
commit
e8ec9b415a
@ -69,14 +69,16 @@ class TemperatureLoop(TemperatureSensor, Drivable):
|
|||||||
# lakeshore loop number to be used for this module
|
# lakeshore loop number to be used for this module
|
||||||
loop = Property('lakeshore loop', IntRange(1, 2), default=1)
|
loop = Property('lakeshore loop', IntRange(1, 2), default=1)
|
||||||
target = Parameter(datatype=FloatRange(unit='K', min=0, max=1500))
|
target = Parameter(datatype=FloatRange(unit='K', min=0, max=1500))
|
||||||
heater_range = Property('heater power range', IntRange(0, 5)) # max. 3 on LakeShore 336
|
heater_range = Property('heater power range', IntRange(0, 3), readonly=False)
|
||||||
tolerance = Parameter('convergence criterion', FloatRange(0), default=0.1, readonly=False)
|
tolerance = Parameter('convergence criterion', FloatRange(0), default=0.1, readonly=False)
|
||||||
_driving = False
|
_driving = False
|
||||||
|
|
||||||
|
def write_heater_range(self, value):
|
||||||
|
self.communicate(f'RANGE {self.loop},{value};RANGE?{self.loop}')
|
||||||
|
|
||||||
def write_target(self, target):
|
def write_target(self, target):
|
||||||
# reactivate heater in case it was switched off
|
# reactivate heater in case it was switched off
|
||||||
# the command has to be changed in case of model 340 to f'RANGE {self.heater_range};RANGE?'
|
self.write_heater_range(self.heater_range)
|
||||||
self.communicate(f'RANGE {self.loop},{self.heater_range};RANGE?{self.loop}')
|
|
||||||
self.communicate(f'SETP {self.loop},{target};*OPC?')
|
self.communicate(f'SETP {self.loop},{target};*OPC?')
|
||||||
self._driving = True
|
self._driving = True
|
||||||
# Setting the status attribute triggers an update message for the SECoP status
|
# Setting the status attribute triggers an update message for the SECoP status
|
||||||
@ -85,23 +87,21 @@ class TemperatureLoop(TemperatureSensor, Drivable):
|
|||||||
return target
|
return target
|
||||||
|
|
||||||
def read_status(self):
|
def read_status(self):
|
||||||
code = int(self.communicate(f'RDGST?{self.channel}'))
|
status = super().read_status()
|
||||||
if code >= 128:
|
if status[0] == ERROR:
|
||||||
text = 'units overrange'
|
return status
|
||||||
elif code >= 64:
|
if abs(self.target - self.value) > self.tolerance:
|
||||||
text = 'units zero'
|
|
||||||
elif code >= 32:
|
|
||||||
text = 'temperature overrange'
|
|
||||||
elif code >= 16:
|
|
||||||
text = 'temperature underrange'
|
|
||||||
elif code % 2:
|
|
||||||
# ignore 'old reading', as this may happen in normal operation
|
|
||||||
text = 'invalid reading'
|
|
||||||
elif abs(self.target - self.value) > self.tolerance:
|
|
||||||
if self._driving:
|
if self._driving:
|
||||||
return BUSY, 'approaching setpoint'
|
return BUSY, 'approaching setpoint'
|
||||||
return WARN, 'temperature out of tolerance'
|
return WARN, 'temperature out of tolerance'
|
||||||
else: # within tolerance: simple convergence criterion
|
# within tolerance: simple convergence criterion
|
||||||
self._driving = False
|
self._driving = False
|
||||||
return IDLE, ''
|
return IDLE, ''
|
||||||
return ERROR, text
|
|
||||||
|
|
||||||
|
class TemperatureLoop340(TemperatureLoop):
|
||||||
|
# slightly different behaviour for model 340
|
||||||
|
heater_range = Property('heater power range', IntRange(0, 5))
|
||||||
|
|
||||||
|
def write_heater_range(self, value):
|
||||||
|
self.communicate(f'RANGE {value};RANGE?')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user