refactor: class renaming and minor changes in variable names
This commit is contained in:
parent
256aa41690
commit
5d02a13ad0
@ -25,7 +25,7 @@ from ophyd.quadem import QuadEM
|
|||||||
# cSAXS
|
# cSAXS
|
||||||
from .epics_motor_ex import EpicsMotorEx
|
from .epics_motor_ex import EpicsMotorEx
|
||||||
from .mcs_csaxs import McsCsaxs
|
from .mcs_csaxs import McsCsaxs
|
||||||
from .eiger9m_csaxs import Eiger9mCsaxs
|
from .eiger9m_csaxs import Eiger9McSAXS
|
||||||
from .pilatus_csaxs import PilatusCsaxs
|
from .pilatus_csaxs import PilatusCsaxs
|
||||||
from .falcon_csaxs import FalconCsaxs
|
from .falcon_csaxs import FalconCsaxs
|
||||||
from .DelayGeneratorDG645 import DelayGeneratorDG645
|
from .DelayGeneratorDG645 import DelayGeneratorDG645
|
||||||
|
@ -30,13 +30,13 @@ class EigerError(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class EigerTimeoutError(Exception):
|
class EigerTimeoutError(EigerError):
|
||||||
"""Raised when the Eiger does not respond in time during unstage."""
|
"""Raised when the Eiger does not respond in time during unstage."""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class SlsDetectorCam(Device):
|
class SLSDetectorCam(Device):
|
||||||
"""SLS Detector Camera - Eiger 9M
|
"""SLS Detector Camera - Eiger 9M
|
||||||
|
|
||||||
Base class to map EPICS PVs to ophyd signals.
|
Base class to map EPICS PVs to ophyd signals.
|
||||||
@ -53,7 +53,7 @@ class SlsDetectorCam(Device):
|
|||||||
detector_state = ADCpt(EpicsSignalRO, "DetectorState_RBV")
|
detector_state = ADCpt(EpicsSignalRO, "DetectorState_RBV")
|
||||||
|
|
||||||
|
|
||||||
class TriggerSource(int, enum.Enum):
|
class TriggerSource(enum.IntEnum):
|
||||||
"""Trigger signals for Eiger9M detector"""
|
"""Trigger signals for Eiger9M detector"""
|
||||||
|
|
||||||
AUTO = 0
|
AUTO = 0
|
||||||
@ -62,7 +62,7 @@ class TriggerSource(int, enum.Enum):
|
|||||||
BURST_TRIGGER = 3
|
BURST_TRIGGER = 3
|
||||||
|
|
||||||
|
|
||||||
class DetectorState(int, enum.Enum):
|
class DetectorState(enum.IntEnum):
|
||||||
"""Detector states for Eiger9M detector"""
|
"""Detector states for Eiger9M detector"""
|
||||||
|
|
||||||
IDLE = 0
|
IDLE = 0
|
||||||
@ -78,7 +78,7 @@ class DetectorState(int, enum.Enum):
|
|||||||
ABORTED = 10
|
ABORTED = 10
|
||||||
|
|
||||||
|
|
||||||
class Eiger9mCsaxs(DetectorBase):
|
class Eiger9McSAXS(DetectorBase):
|
||||||
"""Eiger 9M detector for CSAXS
|
"""Eiger 9M detector for CSAXS
|
||||||
|
|
||||||
Parent class: DetectorBase
|
Parent class: DetectorBase
|
||||||
@ -95,7 +95,7 @@ class Eiger9mCsaxs(DetectorBase):
|
|||||||
"describe",
|
"describe",
|
||||||
]
|
]
|
||||||
|
|
||||||
cam = ADCpt(SlsDetectorCam, "cam1:")
|
cam = ADCpt(SLSDetectorCam, "cam1:")
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -132,7 +132,9 @@ class Eiger9mCsaxs(DetectorBase):
|
|||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
if device_manager is None and not sim_mode:
|
if device_manager is None and not sim_mode:
|
||||||
raise EigerError("Add DeviceManager to initialization or init with sim_mode=True")
|
raise Exception(
|
||||||
|
f"No device manager for device: {name}, and not started sim_mode: {sim_mode}. Add DeviceManager to initialization or init with sim_mode=True"
|
||||||
|
)
|
||||||
self.sim_mode = sim_mode
|
self.sim_mode = sim_mode
|
||||||
# TODO check if threadlock is needed for unstage
|
# TODO check if threadlock is needed for unstage
|
||||||
self._lock = threading.RLock()
|
self._lock = threading.RLock()
|
||||||
@ -142,6 +144,9 @@ class Eiger9mCsaxs(DetectorBase):
|
|||||||
self.std_client = None
|
self.std_client = None
|
||||||
self.scaninfo = None
|
self.scaninfo = None
|
||||||
self.filewriter = None
|
self.filewriter = None
|
||||||
|
self.std_rest_server_url = (
|
||||||
|
kwargs["file_writer_url"] if "file_writer_url" in kwargs else "http://xbl-daq-29:5000"
|
||||||
|
)
|
||||||
self.wait_for_connection(all_signals=True)
|
self.wait_for_connection(all_signals=True)
|
||||||
if not sim_mode:
|
if not sim_mode:
|
||||||
self._update_service_config()
|
self._update_service_config()
|
||||||
@ -199,7 +204,6 @@ class Eiger9mCsaxs(DetectorBase):
|
|||||||
For the Eiger9M, the data backend is std_daq client.
|
For the Eiger9M, the data backend is std_daq client.
|
||||||
Setting up these parameters depends on the backend, and would need to change upon changes in the backend.
|
Setting up these parameters depends on the backend, and would need to change upon changes in the backend.
|
||||||
"""
|
"""
|
||||||
self.std_rest_server_url = "http://xbl-daq-29:5000"
|
|
||||||
self.std_client = StdDaqClient(url_base=self.std_rest_server_url)
|
self.std_client = StdDaqClient(url_base=self.std_rest_server_url)
|
||||||
self.std_client.stop_writer()
|
self.std_client.stop_writer()
|
||||||
timeout = 0
|
timeout = 0
|
||||||
@ -360,7 +364,7 @@ class Eiger9mCsaxs(DetectorBase):
|
|||||||
trigger_source (TriggerSource): Trigger source for the detector
|
trigger_source (TriggerSource): Trigger source for the detector
|
||||||
|
|
||||||
"""
|
"""
|
||||||
value = int(trigger_source)
|
value = trigger_source
|
||||||
self.cam.trigger_mode.put(value)
|
self.cam.trigger_mode.put(value)
|
||||||
|
|
||||||
def _publish_file_location(self, done: bool = False, successful: bool = None) -> None:
|
def _publish_file_location(self, done: bool = False, successful: bool = None) -> None:
|
||||||
@ -394,7 +398,7 @@ class Eiger9mCsaxs(DetectorBase):
|
|||||||
self.cam.acquire.put(1)
|
self.cam.acquire.put(1)
|
||||||
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 == DetectorState.RUNNING:
|
||||||
break
|
break
|
||||||
if self._stopped == True:
|
if self._stopped == True:
|
||||||
break
|
break
|
||||||
@ -493,7 +497,7 @@ class Eiger9mCsaxs(DetectorBase):
|
|||||||
# Check status
|
# Check status
|
||||||
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.IDLE):
|
if det_ctrl == DetectorState.IDLE:
|
||||||
break
|
break
|
||||||
if self._stopped == True:
|
if self._stopped == True:
|
||||||
break
|
break
|
||||||
@ -515,4 +519,4 @@ class Eiger9mCsaxs(DetectorBase):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
eiger = Eiger9mCsaxs(name="eiger", prefix="X12SA-ES-EIGER9M:", sim_mode=True)
|
eiger = Eiger9McSAXS(name="eiger", prefix="X12SA-ES-EIGER9M:", sim_mode=True)
|
||||||
|
@ -31,7 +31,7 @@ class MockSignal(Signal):
|
|||||||
with mock.patch("ophyd.EpicsSignal", new=MockSignal), mock.patch(
|
with mock.patch("ophyd.EpicsSignal", new=MockSignal), mock.patch(
|
||||||
"ophyd.EpicsSignalRO", new=MockSignal
|
"ophyd.EpicsSignalRO", new=MockSignal
|
||||||
), mock.patch("ophyd.EpicsSignalWithRBV", new=MockSignal):
|
), mock.patch("ophyd.EpicsSignalWithRBV", new=MockSignal):
|
||||||
from ophyd_devices.epics.devices.eiger9m_csaxs import Eiger9mCsaxs
|
from ophyd_devices.epics.devices.eiger9m_csaxs import Eiger9McSAXS
|
||||||
|
|
||||||
|
|
||||||
# TODO maybe specify here that this DeviceMock is for usage in the DeviceServer
|
# TODO maybe specify here that this DeviceMock is for usage in the DeviceServer
|
||||||
@ -98,12 +98,12 @@ def mock_det():
|
|||||||
# dm.add_device("mokev", value=12.4)
|
# dm.add_device("mokev", value=12.4)
|
||||||
with mock.patch.object(dm, "producer"):
|
with mock.patch.object(dm, "producer"):
|
||||||
with mock.patch.object(
|
with mock.patch.object(
|
||||||
Eiger9mCsaxs, "_update_service_config"
|
Eiger9McSAXS, "_update_service_config"
|
||||||
) as mock_update_service_config, mock.patch(
|
) as mock_update_service_config, mock.patch(
|
||||||
"ophyd_devices.epics.devices.eiger9m_csaxs.FileWriterMixin"
|
"ophyd_devices.epics.devices.eiger9m_csaxs.FileWriterMixin"
|
||||||
) as filemixin:
|
) as filemixin:
|
||||||
with mock.patch.object(Eiger9mCsaxs, "_init"):
|
with mock.patch.object(Eiger9McSAXS, "_init"):
|
||||||
yield Eiger9mCsaxs(name=name, prefix=prefix, device_manager=dm, sim_mode=sim_mode)
|
yield Eiger9McSAXS(name=name, prefix=prefix, device_manager=dm, sim_mode=sim_mode)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
@ -178,15 +178,15 @@ def test_init(
|
|||||||
sim_mode = sim_mode
|
sim_mode = sim_mode
|
||||||
dm = DMMock()
|
dm = DMMock()
|
||||||
with mock.patch.object(dm, "producer") as producer, mock.patch.object(
|
with mock.patch.object(dm, "producer") as producer, mock.patch.object(
|
||||||
Eiger9mCsaxs, "_init_filewriter"
|
Eiger9McSAXS, "_init_filewriter"
|
||||||
) as mock_init_fw, mock.patch.object(
|
) as mock_init_fw, mock.patch.object(
|
||||||
Eiger9mCsaxs, "_update_scaninfo"
|
Eiger9McSAXS, "_update_scaninfo"
|
||||||
) as mock_update_scaninfo, mock.patch.object(
|
) as mock_update_scaninfo, mock.patch.object(
|
||||||
Eiger9mCsaxs, "_update_filewriter"
|
Eiger9McSAXS, "_update_filewriter"
|
||||||
) as mock_update_filewriter, mock.patch.object(
|
) as mock_update_filewriter, mock.patch.object(
|
||||||
Eiger9mCsaxs, "_update_service_config"
|
Eiger9McSAXS, "_update_service_config"
|
||||||
) as mock_update_service_config:
|
) as mock_update_service_config:
|
||||||
mock_det = Eiger9mCsaxs(name=name, prefix=prefix, device_manager=dm, sim_mode=sim_mode)
|
mock_det = Eiger9McSAXS(name=name, prefix=prefix, device_manager=dm, sim_mode=sim_mode)
|
||||||
mock_det.cam.detector_state.put(detector_state)
|
mock_det.cam.detector_state.put(detector_state)
|
||||||
if expected_exception:
|
if expected_exception:
|
||||||
with pytest.raises(Exception):
|
with pytest.raises(Exception):
|
||||||
@ -326,7 +326,7 @@ def test_stage(
|
|||||||
expected_exception,
|
expected_exception,
|
||||||
):
|
):
|
||||||
with mock.patch.object(mock_det, "std_client") as mock_std_daq, mock.patch.object(
|
with mock.patch.object(mock_det, "std_client") as mock_std_daq, mock.patch.object(
|
||||||
Eiger9mCsaxs, "_publish_file_location"
|
Eiger9McSAXS, "_publish_file_location"
|
||||||
) as mock_publish_file_location:
|
) as mock_publish_file_location:
|
||||||
mock_std_daq.stop_writer.return_value = None
|
mock_std_daq.stop_writer.return_value = None
|
||||||
mock_std_daq.get_status.return_value = daq_status
|
mock_std_daq.get_status.return_value = daq_status
|
||||||
|
Loading…
x
Reference in New Issue
Block a user