refactor: eiger, add trigger function

This commit is contained in:
Christian Appel
2023-10-24 10:55:09 +02:00
parent 78765100ba
commit e6d05c9d02

View File

@ -23,12 +23,14 @@ logger = bec_logger.logger
class EigerError(Exception): class EigerError(Exception):
'''Base class for exceptions in this module.''' """Base class for exceptions in this module."""
pass pass
class EigerTimeoutError(Exception): class EigerTimeoutError(Exception):
'''Raised when the Eiger does not respond in time during unstage.''' """Raised when the Eiger does not respond in time during unstage."""
pass pass
@ -37,6 +39,7 @@ class SlsDetectorCam(Device):
Base class to map EPICS PVs to ophyd signals. Base class to map EPICS PVs to ophyd signals.
""" """
threshold_energy = ADCpt(EpicsSignalWithRBV, "ThresholdEnergy") threshold_energy = ADCpt(EpicsSignalWithRBV, "ThresholdEnergy")
beam_energy = ADCpt(EpicsSignalWithRBV, "BeamEnergy") beam_energy = ADCpt(EpicsSignalWithRBV, "BeamEnergy")
bit_depth = ADCpt(EpicsSignalWithRBV, "BitDepth") bit_depth = ADCpt(EpicsSignalWithRBV, "BitDepth")
@ -50,6 +53,7 @@ class SlsDetectorCam(Device):
class TriggerSource(int, enum.Enum): class TriggerSource(int, enum.Enum):
"""Trigger signals for Eiger9M detector""" """Trigger signals for Eiger9M detector"""
AUTO = 0 AUTO = 0
TRIGGER = 1 TRIGGER = 1
GATING = 2 GATING = 2
@ -58,6 +62,7 @@ class TriggerSource(int, enum.Enum):
class DetectorState(int, enum.Enum): class DetectorState(int, enum.Enum):
"""Detector states for Eiger9M detector""" """Detector states for Eiger9M detector"""
IDLE = 0 IDLE = 0
ERROR = 1 ERROR = 1
WAITING = 2 WAITING = 2
@ -155,8 +160,7 @@ class Eiger9mCsaxs(DetectorBase):
# TODO function for abstract class? # TODO function for abstract class?
def _init(self) -> None: def _init(self) -> None:
"""Initialize detector, filewriter and set default parameters """Initialize detector, filewriter and set default parameters"""
"""
self._default_parameter() self._default_parameter()
self._init_detector() self._init_detector()
self._init_filewriter() self._init_filewriter()
@ -316,6 +320,7 @@ class Eiger9mCsaxs(DetectorBase):
self.cam.num_images.put(int(self.scaninfo.num_points * self.scaninfo.frames_per_trigger)) self.cam.num_images.put(int(self.scaninfo.num_points * self.scaninfo.frames_per_trigger))
self.cam.num_frames.put(1) self.cam.num_frames.put(1)
# TODO function for abstract class? + call it for each scan??
def _set_trigger(self, trigger_source: TriggerSource) -> None: def _set_trigger(self, trigger_source: TriggerSource) -> None:
"""Set trigger source for the detector. """Set trigger source for the detector.
Check the TriggerSource enum for possible values Check the TriggerSource enum for possible values
@ -339,8 +344,7 @@ class Eiger9mCsaxs(DetectorBase):
) )
def arm_acquisition(self) -> None: def arm_acquisition(self) -> None:
"""Arm detector for acquisition """Arm detector for acquisition"""
"""
self.cam.acquire.put(1) self.cam.acquire.put(1)
logger.info("Waiting for Eiger9m to be armed") logger.info("Waiting for Eiger9m to be armed")
# TODO add here timeout? # TODO add here timeout?
@ -353,7 +357,12 @@ class Eiger9mCsaxs(DetectorBase):
time.sleep(0.005) time.sleep(0.005)
logger.info("Eiger9m is armed") logger.info("Eiger9m is armed")
#TODO needed? if yes why only for the eiger9m? # TODO is this correct? -> for hardware triggering, nothing should happen upon trigger signal
# Comment this otherwise!
def trigger(self) -> DeviceStatus:
return super().trigger()
# TODO threadlocked needed? if yes why only for the eiger9m?
@threadlocked @threadlocked
def unstage(self) -> List[object]: def unstage(self) -> List[object]:
"""unstage the detector and file writer""" """unstage the detector and file writer"""