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
|
||||
from .epics_motor_ex import EpicsMotorEx
|
||||
from .mcs_csaxs import McsCsaxs
|
||||
from .eiger9m_csaxs import Eiger9mCsaxs
|
||||
from .eiger9m_csaxs import Eiger9McSAXS
|
||||
from .pilatus_csaxs import PilatusCsaxs
|
||||
from .falcon_csaxs import FalconCsaxs
|
||||
from .DelayGeneratorDG645 import DelayGeneratorDG645
|
||||
|
@ -30,13 +30,13 @@ class EigerError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class EigerTimeoutError(Exception):
|
||||
class EigerTimeoutError(EigerError):
|
||||
"""Raised when the Eiger does not respond in time during unstage."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class SlsDetectorCam(Device):
|
||||
class SLSDetectorCam(Device):
|
||||
"""SLS Detector Camera - Eiger 9M
|
||||
|
||||
Base class to map EPICS PVs to ophyd signals.
|
||||
@ -53,7 +53,7 @@ class SlsDetectorCam(Device):
|
||||
detector_state = ADCpt(EpicsSignalRO, "DetectorState_RBV")
|
||||
|
||||
|
||||
class TriggerSource(int, enum.Enum):
|
||||
class TriggerSource(enum.IntEnum):
|
||||
"""Trigger signals for Eiger9M detector"""
|
||||
|
||||
AUTO = 0
|
||||
@ -62,7 +62,7 @@ class TriggerSource(int, enum.Enum):
|
||||
BURST_TRIGGER = 3
|
||||
|
||||
|
||||
class DetectorState(int, enum.Enum):
|
||||
class DetectorState(enum.IntEnum):
|
||||
"""Detector states for Eiger9M detector"""
|
||||
|
||||
IDLE = 0
|
||||
@ -78,7 +78,7 @@ class DetectorState(int, enum.Enum):
|
||||
ABORTED = 10
|
||||
|
||||
|
||||
class Eiger9mCsaxs(DetectorBase):
|
||||
class Eiger9McSAXS(DetectorBase):
|
||||
"""Eiger 9M detector for CSAXS
|
||||
|
||||
Parent class: DetectorBase
|
||||
@ -95,7 +95,7 @@ class Eiger9mCsaxs(DetectorBase):
|
||||
"describe",
|
||||
]
|
||||
|
||||
cam = ADCpt(SlsDetectorCam, "cam1:")
|
||||
cam = ADCpt(SLSDetectorCam, "cam1:")
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@ -132,7 +132,9 @@ class Eiger9mCsaxs(DetectorBase):
|
||||
**kwargs,
|
||||
)
|
||||
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
|
||||
# TODO check if threadlock is needed for unstage
|
||||
self._lock = threading.RLock()
|
||||
@ -142,6 +144,9 @@ class Eiger9mCsaxs(DetectorBase):
|
||||
self.std_client = None
|
||||
self.scaninfo = 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)
|
||||
if not sim_mode:
|
||||
self._update_service_config()
|
||||
@ -199,7 +204,6 @@ class Eiger9mCsaxs(DetectorBase):
|
||||
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.
|
||||
"""
|
||||
self.std_rest_server_url = "http://xbl-daq-29:5000"
|
||||
self.std_client = StdDaqClient(url_base=self.std_rest_server_url)
|
||||
self.std_client.stop_writer()
|
||||
timeout = 0
|
||||
@ -360,7 +364,7 @@ class Eiger9mCsaxs(DetectorBase):
|
||||
trigger_source (TriggerSource): Trigger source for the detector
|
||||
|
||||
"""
|
||||
value = int(trigger_source)
|
||||
value = trigger_source
|
||||
self.cam.trigger_mode.put(value)
|
||||
|
||||
def _publish_file_location(self, done: bool = False, successful: bool = None) -> None:
|
||||
@ -394,7 +398,7 @@ class Eiger9mCsaxs(DetectorBase):
|
||||
self.cam.acquire.put(1)
|
||||
while True:
|
||||
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
|
||||
if self._stopped == True:
|
||||
break
|
||||
@ -493,7 +497,7 @@ class Eiger9mCsaxs(DetectorBase):
|
||||
# Check status
|
||||
while True:
|
||||
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
|
||||
if self._stopped == True:
|
||||
break
|
||||
@ -515,4 +519,4 @@ class Eiger9mCsaxs(DetectorBase):
|
||||
|
||||
|
||||
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(
|
||||
"ophyd.EpicsSignalRO", 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
|
||||
@ -98,12 +98,12 @@ def mock_det():
|
||||
# dm.add_device("mokev", value=12.4)
|
||||
with mock.patch.object(dm, "producer"):
|
||||
with mock.patch.object(
|
||||
Eiger9mCsaxs, "_update_service_config"
|
||||
Eiger9McSAXS, "_update_service_config"
|
||||
) as mock_update_service_config, mock.patch(
|
||||
"ophyd_devices.epics.devices.eiger9m_csaxs.FileWriterMixin"
|
||||
) as filemixin:
|
||||
with mock.patch.object(Eiger9mCsaxs, "_init"):
|
||||
yield Eiger9mCsaxs(name=name, prefix=prefix, device_manager=dm, sim_mode=sim_mode)
|
||||
with mock.patch.object(Eiger9McSAXS, "_init"):
|
||||
yield Eiger9McSAXS(name=name, prefix=prefix, device_manager=dm, sim_mode=sim_mode)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@ -178,15 +178,15 @@ def test_init(
|
||||
sim_mode = sim_mode
|
||||
dm = DMMock()
|
||||
with mock.patch.object(dm, "producer") as producer, mock.patch.object(
|
||||
Eiger9mCsaxs, "_init_filewriter"
|
||||
Eiger9McSAXS, "_init_filewriter"
|
||||
) as mock_init_fw, mock.patch.object(
|
||||
Eiger9mCsaxs, "_update_scaninfo"
|
||||
Eiger9McSAXS, "_update_scaninfo"
|
||||
) as mock_update_scaninfo, mock.patch.object(
|
||||
Eiger9mCsaxs, "_update_filewriter"
|
||||
Eiger9McSAXS, "_update_filewriter"
|
||||
) as mock_update_filewriter, mock.patch.object(
|
||||
Eiger9mCsaxs, "_update_service_config"
|
||||
Eiger9McSAXS, "_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)
|
||||
if expected_exception:
|
||||
with pytest.raises(Exception):
|
||||
@ -326,7 +326,7 @@ def test_stage(
|
||||
expected_exception,
|
||||
):
|
||||
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:
|
||||
mock_std_daq.stop_writer.return_value = None
|
||||
mock_std_daq.get_status.return_value = daq_status
|
||||
|
Loading…
x
Reference in New Issue
Block a user