rework switch timing
- specific things in ips_mercury.py - general things in magfield.py Change-Id: I7c2bae815b9a80a17803b44b8941ef3dea3adb60
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
# *****************************************************************************
|
||||
"""oxford instruments mercury IPS power supply"""
|
||||
|
||||
import time
|
||||
from secop.core import Parameter, EnumType, FloatRange, BoolType
|
||||
from secop.lib.enum import Enum
|
||||
from secop.errors import BadValueError, HardwareError
|
||||
@ -51,6 +52,7 @@ class Field(MercuryChannel, Magfield):
|
||||
nslaves = 3
|
||||
slave_currents = None
|
||||
__init = True
|
||||
__reset_switch_time = False
|
||||
|
||||
def doPoll(self):
|
||||
super().doPoll()
|
||||
@ -62,7 +64,7 @@ class Field(MercuryChannel, Magfield):
|
||||
if self.__init:
|
||||
self.__init = False
|
||||
self.persistent_field = pf
|
||||
if self.switch_heater != 0 or self._field_mismatch is None:
|
||||
if self.switch_heater == self.switch_heater.on or self._field_mismatch is None:
|
||||
self.forced_persistent_field = False
|
||||
self._field_mismatch = False
|
||||
return self.current
|
||||
@ -94,7 +96,18 @@ class Field(MercuryChannel, Magfield):
|
||||
return self.change('PSU:ACTN', value, hold_rtoz_rtos_clmp)
|
||||
|
||||
def read_switch_heater(self):
|
||||
return self.query('PSU:SIG:SWHT', off_on)
|
||||
value = self.query('PSU:SIG:SWHT', off_on)
|
||||
now = time.time()
|
||||
switch_time = self.switch_time[self.switch_heater]
|
||||
if value != self.switch_heater:
|
||||
self.__reset_switch_time = True
|
||||
if now < (switch_time or 0) + 10:
|
||||
# probably switch heater was changed, but IPS reply is not yet updated
|
||||
return self.switch_heater
|
||||
elif self.__reset_switch_time:
|
||||
self.__reset_switch_time = False
|
||||
self.switch_time = [None, None]
|
||||
return value
|
||||
|
||||
def write_switch_heater(self, value):
|
||||
return self.change('PSU:SIG:SWHT', value, off_on)
|
||||
|
Reference in New Issue
Block a user