This commit is contained in:
2025-06-17 11:01:53 +02:00
parent 058de83fbe
commit 5699363acf

View File

@@ -1,6 +1,7 @@
from __future__ import annotations
import os
from collections import deque
from typing import TYPE_CHECKING, Literal, cast
import numpy as np
@@ -123,6 +124,7 @@ class PcoEdge5M(PSIDeviceBase, PcoEdgeBase):
self.backend = StdDaqClient(parent=self, ws_url=std_daq_ws, rest_url=std_daq_rest)
self.backend.add_count_callback(self._on_count_update)
self.live_preview = None
self.converted_files = deque(maxlen=100) # Store the last 10 converted files
self.acq_configs = {}
if std_daq_live is not None:
self.live_preview = StdDaqPreview(url=std_daq_live, cb=self._on_preview_update)
@@ -539,6 +541,12 @@ class PcoEdge5M(PSIDeviceBase, PcoEdgeBase):
"""Called to inquire if a device has completed a scans."""
def _create_dataset(_status: DeviceStatus):
if self.target_file in self.converted_files:
logger.info(
f"File {self.target_file} already exists in the converted files list. "
"Skipping dataset creation."
)
return
self.backend.create_virtual_datasets(
self.file_path.get(), file_prefix=self.file_prefix.get() # type: ignore
)
@@ -547,8 +555,9 @@ class PcoEdge5M(PSIDeviceBase, PcoEdgeBase):
file_path=self.target_file,
done=True,
successful=True,
hinted_location={"data": "data"},
hinted_location={"data": "tomcat-pco/data"},
)
self.converted_files.append(self.target_file)
logger.info(f"Finished writing to {self.target_file}")
status = self.acq_done()