fix: Adapt to FileWriter refactoring
This commit is contained in:
parent
32b6d476ca
commit
e9c626a7c8
@ -205,7 +205,7 @@ class Eiger9MSetup(CustomDetectorMixin):
|
|||||||
def prepare_data_backend(self) -> None:
|
def prepare_data_backend(self) -> None:
|
||||||
"""Prepare the data backend for the scan"""
|
"""Prepare the data backend for the scan"""
|
||||||
self.parent.filepath = self.parent.filewriter.compile_full_filename(
|
self.parent.filepath = self.parent.filewriter.compile_full_filename(
|
||||||
self.parent.scaninfo.scan_number, f"{self.parent.name}.h5", 1000, 5, True
|
f"{self.parent.name}.h5"
|
||||||
)
|
)
|
||||||
self.filepath_exists(self.parent.filepath)
|
self.filepath_exists(self.parent.filepath)
|
||||||
self.stop_detector_backend()
|
self.stop_detector_backend()
|
||||||
|
@ -184,7 +184,7 @@ class FalconSetup(CustomDetectorMixin):
|
|||||||
def prepare_data_backend(self) -> None:
|
def prepare_data_backend(self) -> None:
|
||||||
"""Prepare data backend for acquisition"""
|
"""Prepare data backend for acquisition"""
|
||||||
self.parent.filepath = self.parent.filewriter.compile_full_filename(
|
self.parent.filepath = self.parent.filewriter.compile_full_filename(
|
||||||
self.parent.scaninfo.scan_number, f"{self.parent.name}.h5", 1000, 5, True
|
f"{self.parent.name}.h5"
|
||||||
)
|
)
|
||||||
file_path, file_name = os.path.split(self.parent.filepath)
|
file_path, file_name = os.path.split(self.parent.filepath)
|
||||||
self.parent.hdf5.file_path.put(file_path)
|
self.parent.hdf5.file_path.put(file_path)
|
||||||
|
@ -188,9 +188,7 @@ class PilatusSetup(CustomDetectorMixin):
|
|||||||
|
|
||||||
self.stop_detector_backend()
|
self.stop_detector_backend()
|
||||||
|
|
||||||
self.parent.filepath = self.parent.filewriter.compile_full_filename(
|
self.parent.filepath = self.parent.filewriter.compile_full_filename("pilatus_2.h5")
|
||||||
self.parent.scaninfo.scan_number, "pilatus_2.h5", 1000, 5, True
|
|
||||||
)
|
|
||||||
self.parent.cam.file_path.put("/dev/shm/zmq/")
|
self.parent.cam.file_path.put("/dev/shm/zmq/")
|
||||||
self.parent.cam.file_name.put(
|
self.parent.cam.file_name.put(
|
||||||
f"{self.parent.scaninfo.username}_2_{self.parent.scaninfo.scan_number:05d}"
|
f"{self.parent.scaninfo.username}_2_{self.parent.scaninfo.scan_number:05d}"
|
||||||
|
@ -2,7 +2,7 @@ import os
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from bec_lib.device import DeviceStatus
|
from bec_lib.device import DeviceStatus
|
||||||
from bec_lib.file_utils import FileWriterMixin
|
from bec_lib.file_utils import FileWriter
|
||||||
from ophyd import Device
|
from ophyd import Device
|
||||||
from ophyd.device import Staged
|
from ophyd.device import Staged
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ class PSIDetectorBase(Device):
|
|||||||
|
|
||||||
def _update_filewriter(self) -> None:
|
def _update_filewriter(self) -> None:
|
||||||
"""Update filewriter with service config"""
|
"""Update filewriter with service config"""
|
||||||
self.filewriter = FileWriterMixin(self.service_cfg)
|
self.filewriter = FileWriter(service_config=self.service_cfg, connector=self.connector)
|
||||||
|
|
||||||
def _update_scaninfo(self) -> None:
|
def _update_scaninfo(self) -> None:
|
||||||
"""Update scaninfo from BecScaninfoMixing
|
"""Update scaninfo from BecScaninfoMixing
|
||||||
|
@ -18,7 +18,7 @@ Flyers in addition, also implement the BECFlyerProtocol. Similarly, positioners
|
|||||||
|
|
||||||
from typing import Protocol, runtime_checkable
|
from typing import Protocol, runtime_checkable
|
||||||
|
|
||||||
from bec_lib.file_utils import FileWriterMixin
|
from bec_lib.file_utils import FileWriter
|
||||||
from ophyd import Component, DeviceStatus, Kind, Staged
|
from ophyd import Component, DeviceStatus, Kind, Staged
|
||||||
|
|
||||||
from ophyd_devices.utils import bec_scaninfo_mixin
|
from ophyd_devices.utils import bec_scaninfo_mixin
|
||||||
@ -47,11 +47,11 @@ class BECDeviceProtocol(Protocol):
|
|||||||
"""kind setter"""
|
"""kind setter"""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def parent(self):
|
def parent(self) -> object:
|
||||||
"""Property to find the parent device"""
|
"""Property to find the parent device"""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def root(self):
|
def root(self) -> object:
|
||||||
"""Property to fint the root device"""
|
"""Property to fint the root device"""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -169,7 +169,7 @@ class BECSignalProtocol(Protocol):
|
|||||||
bool: True if write access is allowed, False otherwise
|
bool: True if write access is allowed, False otherwise
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def check_value(self, value: float):
|
def check_value(self, value: float) -> None:
|
||||||
"""Check whether value is within limits
|
"""Check whether value is within limits
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -230,7 +230,7 @@ class BECScanProtocol(BECDeviceProtocol, Protocol):
|
|||||||
We can further publish the file location for DAQ systems
|
We can further publish the file location for DAQ systems
|
||||||
to BEC and inform BEC's file writer where data will be written to.
|
to BEC and inform BEC's file writer where data will be written to.
|
||||||
|
|
||||||
Stagin is not idempoent. If called twice without an unstage it should raise.
|
Stagin is not idempotent. If called twice without an unstage it should raise.
|
||||||
For ophyd devices, one may used self._staged = True to check if the device is staged.
|
For ophyd devices, one may used self._staged = True to check if the device is staged.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -246,7 +246,7 @@ class BECScanProtocol(BECDeviceProtocol, Protocol):
|
|||||||
inform BEC that the file has been succesfully written, or raise upon receiving
|
inform BEC that the file has been succesfully written, or raise upon receiving
|
||||||
feedback that the scan did not finish successful.
|
feedback that the scan did not finish successful.
|
||||||
|
|
||||||
Unstaging is not idempotent. If called twice without a stage it should raise.
|
Unstaging is not idempotent. If called twice it should simply resolve.
|
||||||
It is recommended to return super().unstage() in the child class, if
|
It is recommended to return super().unstage() in the child class, if
|
||||||
the child class also inherits from ophyd repository.
|
the child class also inherits from ophyd repository.
|
||||||
"""
|
"""
|
||||||
@ -285,7 +285,7 @@ class BECMixinProtocol(Protocol):
|
|||||||
The stop method should set this flag to True, and i.e. stage to set it to False.
|
The stop method should set this flag to True, and i.e. stage to set it to False.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
filewriter: FileWriterMixin
|
filewriter: FileWriter
|
||||||
"""
|
"""
|
||||||
The file writer mixin main purpose is to unify and centralize the creation of
|
The file writer mixin main purpose is to unify and centralize the creation of
|
||||||
file paths within BEC. Therefore, we recommend devices to use the same mixin for creation of paths.
|
file paths within BEC. Therefore, we recommend devices to use the same mixin for creation of paths.
|
||||||
@ -332,7 +332,7 @@ class BECPositionerProtocol(Protocol):
|
|||||||
float: Upper limit
|
float: Upper limit
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def check_value(self, value: float):
|
def check_value(self, value: float) -> None:
|
||||||
"""Check whether value is within limits
|
"""Check whether value is within limits
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -27,9 +27,7 @@ def mock_det():
|
|||||||
sim_mode = False
|
sim_mode = False
|
||||||
dm = DMMock()
|
dm = DMMock()
|
||||||
with mock.patch.object(dm, "connector"):
|
with mock.patch.object(dm, "connector"):
|
||||||
with mock.patch(
|
with mock.patch("ophyd_devices.epics.devices.psi_detector_base.FileWriter"), mock.patch(
|
||||||
"ophyd_devices.epics.devices.psi_detector_base.FileWriterMixin"
|
|
||||||
), mock.patch(
|
|
||||||
"ophyd_devices.epics.devices.psi_detector_base.PSIDetectorBase._update_service_config"
|
"ophyd_devices.epics.devices.psi_detector_base.PSIDetectorBase._update_service_config"
|
||||||
):
|
):
|
||||||
with mock.patch.object(ophyd, "cl") as mock_cl:
|
with mock.patch.object(ophyd, "cl") as mock_cl:
|
||||||
@ -50,9 +48,7 @@ def test_init():
|
|||||||
sim_mode = False
|
sim_mode = False
|
||||||
dm = DMMock()
|
dm = DMMock()
|
||||||
with mock.patch.object(dm, "connector"):
|
with mock.patch.object(dm, "connector"):
|
||||||
with mock.patch(
|
with mock.patch("ophyd_devices.epics.devices.psi_detector_base.FileWriter"), mock.patch(
|
||||||
"ophyd_devices.epics.devices.psi_detector_base.FileWriterMixin"
|
|
||||||
), mock.patch(
|
|
||||||
"ophyd_devices.epics.devices.psi_detector_base.PSIDetectorBase._update_service_config"
|
"ophyd_devices.epics.devices.psi_detector_base.PSIDetectorBase._update_service_config"
|
||||||
):
|
):
|
||||||
with mock.patch.object(ophyd, "cl") as mock_cl:
|
with mock.patch.object(ophyd, "cl") as mock_cl:
|
||||||
|
@ -29,7 +29,7 @@ def mock_det():
|
|||||||
dm = DMMock()
|
dm = DMMock()
|
||||||
with mock.patch.object(dm, "connector"):
|
with mock.patch.object(dm, "connector"):
|
||||||
with mock.patch(
|
with mock.patch(
|
||||||
"ophyd_devices.epics.devices.psi_detector_base.FileWriterMixin"
|
"ophyd_devices.epics.devices.psi_detector_base.FileWriter"
|
||||||
) as filemixin, mock.patch(
|
) as filemixin, mock.patch(
|
||||||
"ophyd_devices.epics.devices.psi_detector_base.PSIDetectorBase._update_service_config"
|
"ophyd_devices.epics.devices.psi_detector_base.PSIDetectorBase._update_service_config"
|
||||||
) as mock_service_config:
|
) as mock_service_config:
|
||||||
|
@ -34,7 +34,7 @@ def mock_det():
|
|||||||
dm = DMMock()
|
dm = DMMock()
|
||||||
with mock.patch.object(dm, "connector"):
|
with mock.patch.object(dm, "connector"):
|
||||||
with mock.patch(
|
with mock.patch(
|
||||||
"ophyd_devices.epics.devices.psi_detector_base.FileWriterMixin"
|
"ophyd_devices.epics.devices.psi_detector_base.FileWriter"
|
||||||
) as filemixin, mock.patch(
|
) as filemixin, mock.patch(
|
||||||
"ophyd_devices.epics.devices.psi_detector_base.PSIDetectorBase._update_service_config"
|
"ophyd_devices.epics.devices.psi_detector_base.PSIDetectorBase._update_service_config"
|
||||||
) as mock_service_config:
|
) as mock_service_config:
|
||||||
@ -54,9 +54,7 @@ def test_init():
|
|||||||
sim_mode = False
|
sim_mode = False
|
||||||
dm = DMMock()
|
dm = DMMock()
|
||||||
with mock.patch.object(dm, "connector"):
|
with mock.patch.object(dm, "connector"):
|
||||||
with mock.patch(
|
with mock.patch("ophyd_devices.epics.devices.psi_detector_base.FileWriter"), mock.patch(
|
||||||
"ophyd_devices.epics.devices.psi_detector_base.FileWriterMixin"
|
|
||||||
), mock.patch(
|
|
||||||
"ophyd_devices.epics.devices.psi_detector_base.PSIDetectorBase._update_service_config"
|
"ophyd_devices.epics.devices.psi_detector_base.PSIDetectorBase._update_service_config"
|
||||||
):
|
):
|
||||||
with mock.patch.object(ophyd, "cl") as mock_cl:
|
with mock.patch.object(ophyd, "cl") as mock_cl:
|
||||||
|
@ -28,9 +28,7 @@ def mock_det():
|
|||||||
sim_mode = False
|
sim_mode = False
|
||||||
dm = DMMock()
|
dm = DMMock()
|
||||||
with mock.patch.object(dm, "connector"):
|
with mock.patch.object(dm, "connector"):
|
||||||
with mock.patch(
|
with mock.patch("ophyd_devices.epics.devices.psi_detector_base.FileWriter"), mock.patch(
|
||||||
"ophyd_devices.epics.devices.psi_detector_base.FileWriterMixin"
|
|
||||||
), mock.patch(
|
|
||||||
"ophyd_devices.epics.devices.psi_detector_base.PSIDetectorBase._update_service_config"
|
"ophyd_devices.epics.devices.psi_detector_base.PSIDetectorBase._update_service_config"
|
||||||
):
|
):
|
||||||
with mock.patch.object(ophyd, "cl") as mock_cl:
|
with mock.patch.object(ophyd, "cl") as mock_cl:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user