diff --git a/tomcat_bec/scans/simple_scans.py b/tomcat_bec/scans/simple_scans.py index 06a9358..ad22654 100644 --- a/tomcat_bec/scans/simple_scans.py +++ b/tomcat_bec/scans/simple_scans.py @@ -70,7 +70,7 @@ class TomoComponents: for cam in self.cameras: yield from self.stubs.send_rpc_and_wait( device=cam, func_name="restore_config", name=name - ) + ) def update_live_processing_references(self, ref_type: Literal["dark", "flat"]): """ @@ -143,6 +143,43 @@ class TomoComponents: yield from self.acquire_flat(num_flats, exposure_time=exp_time, name=name) +class AcquireDark(ScanBase): + scan_name = "acquire_dark" + + def __init__(self, exp_time: float, frames_per_trigger: int = 1, **kwargs): + """ + Acquire dark images. + + Args: + num_images (int): Number of dark images to acquire. + exposure_time (float): Exposure time for each dark image in seconds. + name (str): Name for the dark image acquisition. Default: "dark" + + Returns: + ScanReport + """ + super().__init__(frames_per_trigger=frames_per_trigger, exp_time=exp_time, **kwargs) + self.components = TomoComponents(self) + + def scan_report_instructions(self): + """ + Generate scan report instructions for the dark image acquisition. + This method provides the necessary instructions to listen to the camera progress during the scan. + """ + if not self.components.cameras: + yield from super().scan_report_instructions() + return + + # Use the first camera or "gfcam" if available for reporting + report_camera = ( + "gfcam" if "gfcam" in self.components.cameras else self.components.cameras[0] + ) + yield from self.stubs.scan_report_instruction({"device_progress": [report_camera]}) + + def scan_core(self): + yield from self.components.acquire_dark(self.frames_per_trigger, self.exp_time, name="dark") + + class TomoScan(LineScan): scan_name = "tomo_line_scan"