refactor: eiger, small refactoring of docs and names

This commit is contained in:
Christian Appel
2023-10-24 15:25:42 +02:00
parent 583c61ff41
commit 0f5fe04e59

View File

@ -179,7 +179,7 @@ class Eiger9mCsaxs(DetectorBase):
Depends on hardware configuration and delay generators. Depends on hardware configuration and delay generators.
At this point it is set up for gating mode (09/2023). At this point it is set up for gating mode (09/2023).
""" """
self._stop_detector() self._stop_det()
self._set_trigger(TriggerSource.GATING) self._set_trigger(TriggerSource.GATING)
# TODO function for abstract class? # TODO function for abstract class?
@ -239,6 +239,7 @@ class Eiger9mCsaxs(DetectorBase):
The device returns a List[object] from the Ophyd Device class. The device returns a List[object] from the Ophyd Device class.
#TODO make sure this is fullfiled #TODO make sure this is fullfiled
Staging not idempotent and should raise Staging not idempotent and should raise
:obj:`RedundantStaging` if staged twice without an :obj:`RedundantStaging` if staged twice without an
intermediate :meth:`~BlueskyInterface.unstage`. intermediate :meth:`~BlueskyInterface.unstage`.
@ -351,10 +352,8 @@ class Eiger9mCsaxs(DetectorBase):
# TODO function for abstract class? # TODO function for abstract class?
def _arm_acquisition(self) -> None: def _arm_acquisition(self) -> None:
"""Arm detector for acquisition""" """Arm Eiger detector for acquisition"""
self.cam.acquire.put(1) self.cam.acquire.put(1)
logger.info("Waiting for Eiger9m to be armed")
# TODO add here timeout?
while True: while True:
det_ctrl = self.cam.detector_state.read()[self.cam.detector_state.name]["value"] det_ctrl = self.cam.detector_state.read()[self.cam.detector_state.name]["value"]
if det_ctrl == int(DetectorState.RUNNING): if det_ctrl == int(DetectorState.RUNNING):
@ -362,7 +361,6 @@ class Eiger9mCsaxs(DetectorBase):
if self._stopped == True: if self._stopped == True:
break break
time.sleep(0.005) time.sleep(0.005)
logger.info("Eiger9m is armed")
# TODO function for abstract class? # TODO function for abstract class?
def trigger(self) -> DeviceStatus: def trigger(self) -> DeviceStatus:
@ -379,10 +377,14 @@ class Eiger9mCsaxs(DetectorBase):
# TODO threadlocked was attached, in principle unstage needs to be fast and should possibly called multiple times # TODO threadlocked was attached, in principle unstage needs to be fast and should possibly called multiple times
@threadlocked @threadlocked
def unstage(self) -> List[object]: def unstage(self) -> List[object]:
"""Unstage the device, detector and file writer. """Unstage the device.
This method must be idempotent, multiple calls (without a new This method must be idempotent, multiple calls (without a new
call to 'stage') have no effect. call to 'stage') have no effect.
Functions called:
- _finished
- _publish_file_location
""" """
# TODO solution for multiple calls of the function to avoid calling the finished loop. # TODO solution for multiple calls of the function to avoid calling the finished loop.
# Loop to avoid calling the finished loop multiple times # Loop to avoid calling the finished loop multiple times
@ -403,9 +405,14 @@ class Eiger9mCsaxs(DetectorBase):
@threadlocked @threadlocked
def _finished(self): def _finished(self):
"""Check if acquisition is finished. """Check if acquisition is finished.
This function is called from unstage and stop This function is called from unstage and stop
and will check detector and file backend status. and will check detector and file backend status.
Timeouts after given time Timeouts after given time
Functions called:
- _stop_det
- _stop_file_writer
""" """
sleep_time = 0.1 sleep_time = 0.1
timeout = 5 timeout = 5
@ -420,22 +427,22 @@ class Eiger9mCsaxs(DetectorBase):
if det_ctrl == 0 and std_ctrl == "FINISHED" and total_frames == received_frames: if det_ctrl == 0 and std_ctrl == "FINISHED" and total_frames == received_frames:
break break
if self._stopped == True: if self._stopped == True:
self._stop_detector() self._stop_det()
self._stop_file_writer() self._stop_file_writer()
break break
time.sleep(sleep_time) time.sleep(sleep_time)
timer += sleep_time timer += sleep_time
if timer > timeout: if timer > timeout:
self._stopped == True self._stopped == True
self._stop_detector() self._stop_det()
self._stop_file_writer() self._stop_file_writer()
raise EigerTimeoutError( raise EigerTimeoutError(
f"Reached timeout with detector state {det_ctrl}, std_daq state {std_ctrl} and received frames of {received_frames} for the file writer" f"Reached timeout with detector state {det_ctrl}, std_daq state {std_ctrl} and received frames of {received_frames} for the file writer"
) )
self._stop_detector() self._stop_det()
self._stop_file_writer() self._stop_file_writer()
def _stop_detector(self) -> None: def _stop_det(self) -> None:
"""Stop the detector and wait for the proper status message""" """Stop the detector and wait for the proper status message"""
elapsed_time = 0 elapsed_time = 0
sleep_time = 0.01 sleep_time = 0.01
@ -461,7 +468,7 @@ class Eiger9mCsaxs(DetectorBase):
def stop(self, *, success=False) -> None: def stop(self, *, success=False) -> None:
"""Stop the scan, with camera and file writer""" """Stop the scan, with camera and file writer"""
self._stop_detector() self._stop_det()
self._stop_file_writer() self._stop_file_writer()
super().stop(success=success) super().stop(success=success)
self._stopped = True self._stopped = True