refactor: mcs_cSAXS complies with psi_detector_base

This commit is contained in:
appel_c 2023-11-21 12:33:08 +01:00
parent e7f7f9d665
commit 8bd65b7d67

View File

@ -61,6 +61,7 @@ class MCSSetup(CustomDetectorMixin):
"""Setup mixin class for the MCS card""" """Setup mixin class for the MCS card"""
def __init__(self, *args, parent: Device = None, **kwargs) -> None: def __init__(self, *args, parent: Device = None, **kwargs) -> None:
super().__init__(*args, parent=parent, **kwargs)
self._lock = threading.RLock() self._lock = threading.RLock()
self._stream_ttl = 1800 self._stream_ttl = 1800
self.acquisition_done = False self.acquisition_done = False
@ -70,7 +71,6 @@ class MCSSetup(CustomDetectorMixin):
signal for signal in self.parent.component_names if signal.startswith("mca") signal for signal in self.parent.component_names if signal.startswith("mca")
] ]
self.mca_data = defaultdict(lambda: []) self.mca_data = defaultdict(lambda: [])
super().__init__(*args, parent=parent, **kwargs)
def initialize_detector(self) -> None: def initialize_detector(self) -> None:
"""Initialize detector""" """Initialize detector"""
@ -88,7 +88,7 @@ class MCSSetup(CustomDetectorMixin):
self.parent.output_polarity.set(1) self.parent.output_polarity.set(1)
# do not start counting on start # do not start counting on start
self.parent.count_on_start.set(0) self.parent.count_on_start.set(0)
self.parent.stop_all.set(1) self.stop_detector()
def initialize_detector_backend(self) -> None: def initialize_detector_backend(self) -> None:
"""Initialize detector backend""" """Initialize detector backend"""
@ -107,7 +107,8 @@ class MCSSetup(CustomDetectorMixin):
sub_type=self.parent.SUB_PROGRESS, sub_type=self.parent.SUB_PROGRESS,
value=self.counter * int(self.parent.scaninfo.num_points / num_lines) + value, value=self.counter * int(self.parent.scaninfo.num_points / num_lines) + value,
max_value=max_value, max_value=max_value,
done=bool(max_value == self.counter), # TODO check if that is correct with
done=bool(max_value == value), # == self.counter),
) )
@threadlocked @threadlocked
@ -182,7 +183,7 @@ class MCSSetup(CustomDetectorMixin):
"""Check if acquisition is finished, if not successful, rais MCSTimeoutError""" """Check if acquisition is finished, if not successful, rais MCSTimeoutError"""
signal_conditions = [ signal_conditions = [
( (
self.acquisition_done, lambda: self.acquisition_done,
True, True,
), ),
( (
@ -197,7 +198,7 @@ class MCSSetup(CustomDetectorMixin):
all_signals=True, all_signals=True,
): ):
total_frames = self.counter * int( total_frames = self.counter * int(
self.parent.scaninfo.num_points / self.num_lines.get() self.parent.scaninfo.num_points / self.parent.num_lines.get()
) + max(self.parent.current_channel.get(), 0) ) + max(self.parent.current_channel.get(), 0)
raise MCSTimeoutError( raise MCSTimeoutError(
f"Reached timeout with mcs in state {self.parent.acquiring.get()} and" f"Reached timeout with mcs in state {self.parent.acquiring.get()} and"
@ -215,6 +216,10 @@ class MCSSetup(CustomDetectorMixin):
self.acquisition_done = True self.acquisition_done = True
class SIS38XX(Device):
"""SIS38XX card for access to EPICs PVs at cSAXS beamline"""
class MCScSAXS(PSIDetectorBase): class MCScSAXS(PSIDetectorBase):
"""MCS card for cSAXS for implementation at cSAXS beamline""" """MCS card for cSAXS for implementation at cSAXS beamline"""
@ -226,25 +231,19 @@ class MCScSAXS(PSIDetectorBase):
# specify Setup class # specify Setup class
custom_prepare_cls = MCSSetup custom_prepare_cls = MCSSetup
# specify minimum readout time for detector # specify minimum readout time for detector
MIN_READOUT = 3e-3 MIN_READOUT = 0
# PV access to MCA signals
mca1 = Cpt(EpicsSignalRO, "mca1.VAL", auto_monitor=True)
mca3 = Cpt(EpicsSignalRO, "mca3.VAL", auto_monitor=True)
mca4 = Cpt(EpicsSignalRO, "mca4.VAL", auto_monitor=True)
current_channel = Cpt(EpicsSignalRO, "CurrentChannel", auto_monitor=True)
# PV access to SISS38XX card # PV access to SISS38XX card
# Acquisition # Acquisition
erase_all = Cpt(EpicsSignal, "EraseAll") erase_all = Cpt(EpicsSignal, "EraseAll")
erase_start = Cpt(EpicsSignal, "EraseStart", trigger_value=1) erase_start = Cpt(EpicsSignal, "EraseStart") # ,trigger_value=1
start_all = Cpt(EpicsSignal, "StartAll") start_all = Cpt(EpicsSignal, "StartAll")
stop_all = Cpt(EpicsSignal, "StopAll") stop_all = Cpt(EpicsSignal, "StopAll")
acquiring = Cpt(EpicsSignal, "Acquiring") acquiring = Cpt(EpicsSignal, "Acquiring")
preset_real = Cpt(EpicsSignal, "PresetReal") preset_real = Cpt(EpicsSignal, "PresetReal")
elapsed_real = Cpt(EpicsSignal, "ElapsedReal") elapsed_real = Cpt(EpicsSignal, "ElapsedReal")
read_mode = Cpt(EpicsSignal, "ReadAll.SCAN") read_mode = Cpt(EpicsSignal, "ReadAll.SCAN")
read_all = Cpt(EpicsSignal, "DoReadAll.VAL", trigger_value=1) read_all = Cpt(EpicsSignal, "DoReadAll.VAL") # ,trigger_value=1
num_use_all = Cpt(EpicsSignal, "NuseAll") num_use_all = Cpt(EpicsSignal, "NuseAll")
current_channel = Cpt(EpicsSignal, "CurrentChannel") current_channel = Cpt(EpicsSignal, "CurrentChannel")
dwell = Cpt(EpicsSignal, "Dwell") dwell = Cpt(EpicsSignal, "Dwell")
@ -266,6 +265,12 @@ class MCScSAXS(PSIDetectorBase):
firmware = Cpt(EpicsSignalRO, "Firmware") firmware = Cpt(EpicsSignalRO, "Firmware")
max_channels = Cpt(EpicsSignalRO, "MaxChannels") max_channels = Cpt(EpicsSignalRO, "MaxChannels")
# PV access to MCA signals
mca1 = Cpt(EpicsSignalRO, "mca1.VAL", auto_monitor=True)
mca3 = Cpt(EpicsSignalRO, "mca3.VAL", auto_monitor=True)
mca4 = Cpt(EpicsSignalRO, "mca4.VAL", auto_monitor=True)
current_channel = Cpt(EpicsSignalRO, "CurrentChannel", auto_monitor=True)
# Custom signal readout from device config # Custom signal readout from device config
num_lines = Cpt( num_lines = Cpt(
bec_utils.ConfigSignal, bec_utils.ConfigSignal,