This commit is contained in:
gac-x02da
2025-06-17 10:35:29 +02:00
parent 11251841c3
commit ab57c48250
2 changed files with 26 additions and 18 deletions
+10 -3
View File
@@ -245,7 +245,8 @@ class PcoEdge5M(PSIDeviceBase, PcoEdgeBase):
self, self,
name: str, name: str,
file_path: str = "", file_path: str = "",
file_prefix: str = "", file_name: str | None = None,
file_suffix:str = "",
num_images: int | None = None, num_images: int | None = None,
frames_per_trigger: int | None = None, frames_per_trigger: int | None = None,
) -> StatusBase: ) -> StatusBase:
@@ -263,14 +264,20 @@ class PcoEdge5M(PSIDeviceBase, PcoEdgeBase):
Returns: Returns:
DeviceStatus: The status of the restart operation. It resolves when the camera is ready to receive the first image. DeviceStatus: The status of the restart operation. It resolves when the camera is ready to receive the first image.
""" """
if file_name is not None and file_suffix:
raise ValueError("Both file_name and file_suffix are specified. Please choose one.")
self.acq_configs[name] = {} self.acq_configs[name] = {}
conf = {} conf = {}
if file_path: if file_path:
self.acq_configs[name]["file_path"] = self.file_path.get() self.acq_configs[name]["file_path"] = self.file_path.get()
conf["file_path"] = file_path conf["file_path"] = file_path
if file_prefix: if file_suffix:
self.acq_configs[name]["file_prefix"] = self.file_prefix.get() self.acq_configs[name]["file_prefix"] = self.file_prefix.get()
conf["file_prefix"] = file_prefix conf["file_prefix"] = "_".join([self.file_prefix.get(), file_suffix])
if file_name:
self.acq_configs[name]["file_prefix"] = self.file_prefix.get()
conf["file_prefix"] = file_name
if num_images is not None: if num_images is not None:
self.acq_configs[name]["num_images"] = self.num_images.get() self.acq_configs[name]["num_images"] = self.num_images.get()
conf["num_images"] = num_images conf["num_images"] = num_images
+16 -15
View File
@@ -45,7 +45,7 @@ class TomoComponents:
self, self,
name: str, name: str,
num_images: int, num_images: int,
prefix: str = "", file_suffix: str = "",
file_path: str = "", file_path: str = "",
frames_per_trigger: int = 1, frames_per_trigger: int = 1,
): ):
@@ -55,18 +55,16 @@ class TomoComponents:
Args: Args:
name (str): Name of the configuration to restart with. name (str): Name of the configuration to restart with.
num_images (int): Number of images to acquire. num_images (int): Number of images to acquire.
prefix (str): Prefix for the file names. file_suffix (str): Suffix for the file names.
file_path (str): Path where the files will be saved. file_path (str): Path where the files will be saved.
frames_per_trigger (int): Number of frames to acquire per trigger. frames_per_trigger (int): Number of frames to acquire per trigger.
""" """
if not prefix:
return
for cam in self.cameras: for cam in self.cameras:
yield from self.stubs.send_rpc_and_wait( yield from self.stubs.send_rpc_and_wait(
device=cam, device=cam,
func_name="restart_with_new_config", func_name="restart_with_new_config",
name=name, name=name,
file_prefix=prefix, file_suffix=file_suffix,
file_path=file_path, file_path=file_path,
num_images=num_images, num_images=num_images,
frames_per_trigger=frames_per_trigger, frames_per_trigger=frames_per_trigger,
@@ -121,7 +119,7 @@ class TomoComponents:
device=cam, func_name="update_live_processing_reference", reference_type=ref_type device=cam, func_name="update_live_processing_reference", reference_type=ref_type
) )
def acquire_dark(self, num_images: int, exposure_time: float, name="dark", restart=True): def acquire_dark(self, num_images: int, exposure_time: float, name="dark", restart=True, restore=True):
""" """
Acquire dark images. Acquire dark images.
@@ -136,20 +134,20 @@ class TomoComponents:
if restart: if restart:
yield from self.restart_cameras( yield from self.restart_cameras(
name=name, prefix=name, num_images=num_images, frames_per_trigger=num_images name=name, file_suffix=name, num_images=num_images, frames_per_trigger=num_images
) )
# yield from self.close_shutter() # yield from self.close_shutter()
yield from self.stubs.trigger(min_wait=exposure_time * num_images) yield from self.stubs.trigger(min_wait=exposure_time * num_images)
yield from self.complete() yield from self.complete()
yield from self.update_live_processing_references(ref_type="dark") yield from self.update_live_processing_references(ref_type="dark")
if restart: if restore:
yield from self.restore_configs(name=name) yield from self.restore_configs(name=name)
# yield from self.open_shutter() # yield from self.open_shutter()
self.connector.send_client_info("") self.connector.send_client_info("")
logger.info("Dark image acquisition complete.") logger.info("Dark image acquisition complete.")
def acquire_flat(self, num_images: int, exposure_time: float, name="flat", restart=True): def acquire_flat(self, num_images: int, exposure_time: float, name="flat", restart=True, restore=True):
""" """
Acquire flat images. Acquire flat images.
@@ -164,21 +162,21 @@ class TomoComponents:
if restart: if restart:
yield from self.restart_cameras( yield from self.restart_cameras(
name=name, prefix=name, num_images=num_images, frames_per_trigger=num_images name=name, file_suffix=name, num_images=num_images, frames_per_trigger=num_images
) )
# yield from self.open_shutter() # yield from self.open_shutter()
yield from self.stubs.trigger(min_wait=exposure_time * num_images) yield from self.stubs.trigger(min_wait=exposure_time * num_images)
yield from self.complete() yield from self.complete()
yield from self.update_live_processing_references(ref_type="flat") yield from self.update_live_processing_references(ref_type="flat")
if restart: if restore:
yield from self.restore_configs(name=name) yield from self.restore_configs(name=name)
logger.info("Flat image acquisition complete.") logger.info("Flat image acquisition complete.")
self.connector.send_client_info("") self.connector.send_client_info("")
def acquire_references(self, num_darks: int, num_flats: int, exp_time: float, restart=True): def acquire_references(self, num_darks: int, num_flats: int, exp_time: float, restart=True, restore=True):
yield from self.acquire_dark(num_darks, exposure_time=exp_time, restart=restart) yield from self.acquire_dark(num_darks, exposure_time=exp_time, restart=restart, restore=restore)
yield from self.acquire_flat(num_flats, exposure_time=exp_time, restart=restart) yield from self.acquire_flat(num_flats, exposure_time=exp_time, restart=restart, restore=restore)
class AcquireDark(ScanBase): class AcquireDark(ScanBase):
@@ -263,8 +261,11 @@ class AcquireReferences(ScanBase):
def scan_report_instructions(self): def scan_report_instructions(self):
yield from self.components.scan_report_instructions() yield from self.components.scan_report_instructions()
def pre_scan(self):
yield from self.components.acquire_references(self.num_darks, self.num_flats, self.exp_time, restart=True, restore=False)
def scan_core(self): def scan_core(self):
yield from self.components.acquire_references(self.num_darks, self.num_flats, self.exp_time) pass
class TomoScan(LineScan): class TomoScan(LineScan):