fixes on 2023-11-27

- ls372 autorange: wait one sec. more for switching
- keep only one channel, even after target is reached
- intermediate target only when T is raise, but not when lowered
This commit is contained in:
l_samenv
2023-11-28 10:12:27 +01:00
parent c80b4ac5fb
commit 5b0da3ba98
3 changed files with 27 additions and 17 deletions

View File

@ -22,7 +22,7 @@
"""modules to access parameters"""
from frappy.core import Drivable, EnumType, IDLE, Attached, StringType, Property, \
Parameter, FloatRange, Readable, ERROR
Parameter, FloatRange, BoolType, Readable, ERROR
from frappy.errors import ConfigError
from frappy_psi.convergence import HasConvergence
from frappy_psi.mixins import HasRamp
@ -148,6 +148,7 @@ class SwitchDriv(HasConvergence, Drivable):
max_low = Parameter('maximum low target', FloatRange(unit='$'), readonly=False)
# disable_other = Parameter('whether to disable unused channel', BoolType(), readonly=False)
selected = Parameter('selected module', EnumType(low=LOW, high=HIGH), readonly=False, default=0)
autoswitch = Parameter('switch sensor automatically', BoolType(), readonly=False, default=True)
_switch_target = None # if not None, switch to selection mhen mid range is reached
# TODO: copy units from attached module
@ -165,13 +166,13 @@ class SwitchDriv(HasConvergence, Drivable):
self.write_target(self.target)
return
else:
high = get_value(self.high, mid) # return mid then high is invalid
high = get_value(self.high, mid) # return mid when high is invalid
if high < mid:
self.value = self.high.value
self._switch_target = None
self.write_target(self.target)
return
if not self.isBusy():
if not self.isBusy() and self.autoswitch:
low = get_value(self.low, self.max_low)
high = get_value(self.high, self.min_high)
low_valid = low < self.max_low
@ -184,8 +185,9 @@ class SwitchDriv(HasConvergence, Drivable):
if not high_valid and not self.high.control_active:
set_enabled(self.high, False)
return
set_enabled(self.low, True)
set_enabled(self.high, True)
# keep only one channel on
#set_enabled(self.low, True)
#set_enabled(self.high, True)
def get_selected(self):
low = get_value(self.low, self.max_low)
@ -219,13 +221,13 @@ class SwitchDriv(HasConvergence, Drivable):
this, other = other, this
selected = HIGH
elif target < self.min_high * 0.75 + self.max_low * 0.25:
if self.value > self.max_low:
target1 = max(self.min_high, target)
self._switch_target = LOW
this, other = other, this
selected = HIGH
else:
selected = LOW
#if self.value > self.max_low:
# target1 = max(self.min_high, target)
# self._switch_target = LOW
# this, other = other, this
# selected = HIGH
#else:
selected = LOW
elif self.selected == HIGH:
this, other = other, this
if hasattr(other, 'control_off'):