diff --git a/src/ophyd_async/epics/areadetector/aravis.py b/src/ophyd_async/epics/areadetector/aravis.py index a2edbed8b0..b6d2ab79f8 100644 --- a/src/ophyd_async/epics/areadetector/aravis.py +++ b/src/ophyd_async/epics/areadetector/aravis.py @@ -1,6 +1,7 @@ from typing import get_args from bluesky.protocols import HasHints, Hints + from ophyd_async.core import ( DirectoryProvider, StandardDetector, @@ -52,7 +53,7 @@ def __init__( ) async def _prepare(self, value: TriggerInfo) -> None: - await self.drv._fetch_deadtime() + await self.drv.fetch_deadtime() await super()._prepare(value) def get_external_trigger_gpio(self): diff --git a/src/ophyd_async/epics/areadetector/drivers/aravis_driver.py b/src/ophyd_async/epics/areadetector/drivers/aravis_driver.py index 9b3a9fa6de..d083bf49f6 100644 --- a/src/ophyd_async/epics/areadetector/drivers/aravis_driver.py +++ b/src/ophyd_async/epics/areadetector/drivers/aravis_driver.py @@ -33,12 +33,14 @@ class ADAravisTriggerSource(str, Enum): line_4 = "Line4" -def _reverse_lookup(model_deadtimes: Dict[float, Tuple[str, ...]]) -> Callable[[str], float]: +def _reverse_lookup( + model_deadtimes: Dict[float, Tuple[str, ...]], +) -> Callable[[str], float]: def inner(pixel_format: str) -> float: for deadtime, pixel_formats in model_deadtimes.items(): if pixel_format in pixel_formats: return deadtime - return nan + None return inner @@ -150,8 +152,15 @@ def __init__(self, prefix: str, name: str = "") -> None: self.dead_time: Optional[float] = None super().__init__(prefix, name=name) - async def _fetch_deadtime(self) -> float: + async def fetch_deadtime(self) -> float: # All known in-use version B/C have same deadtime as non-B/C model: str = (await self.model.get_value()).removesuffix("B").removesuffix("C") pixel_format: str = await self.pixel_format.get_value() - self.dead_time = _deadtimes.get(model, lambda _: nan)(pixel_format) + if model not in _deadtimes: + raise ValueError(f"Aravis model {model} deadtimes not known") + deadtime = _deadtimes[model](pixel_format) + if deadtime is None: + raise ValueError( + f"Aravis model {model} deadtime not known for pixel_format {pixel_format}" + ) + self.dead_time = deadtime diff --git a/src/ophyd_async/panda/__init__.py b/src/ophyd_async/panda/__init__.py index 4007412f87..ede0115bf8 100644 --- a/src/ophyd_async/panda/__init__.py +++ b/src/ophyd_async/panda/__init__.py @@ -1,7 +1,6 @@ from .panda import PandA, PcapBlock, PulseBlock, SeqBlock, SeqTable, TimeUnits from .panda_controller import PandaPcapController from .table import ( - SeqTable, SeqTableRow, SeqTrigger, seq_table_from_arrays, diff --git a/tests/epics/areadetector/test_aravis.py b/tests/epics/areadetector/test_aravis.py index aded79ac21..3d1d8b1c42 100644 --- a/tests/epics/areadetector/test_aravis.py +++ b/tests/epics/areadetector/test_aravis.py @@ -77,12 +77,33 @@ async def test_deadtime_read_from_file( set_sim_value(adaravis.drv.model, model) set_sim_value(adaravis.drv.pixel_format, pixel_format) - await adaravis.drv._fetch_deadtime() + await adaravis.drv.fetch_deadtime() # deadtime invariant with exposure time assert adaravis.controller.get_deadtime(0) == deadtime assert adaravis.controller.get_deadtime(500) == deadtime +@pytest.mark.parametrize( + "model,pixel_format", + [("UnknownCamera", None), ("Mako G-040", "UnknownFormat")], +) +async def test_unknown_deadtime_read_from_file( + model: str, + pixel_format: str, + adaravis: ADAravisDetector, +): + set_sim_value(adaravis.drv.model, model) + set_sim_value(adaravis.drv.pixel_format, pixel_format) + expected_error = ( + f"Aravis model {model} deadtimes not known" + if pixel_format is None + else f"Aravis model {model} deadtime not known for pixel_format {pixel_format}" + ) + + with pytest.raises(ValueError, match=expected_error): + await adaravis.drv.fetch_deadtime() + + async def test_trigger_source_set_to_gpio_line(adaravis: ADAravisDetector): async def trigger_and_complete(): await adaravis.controller.arm(num=1, trigger=DetectorTrigger.edge_trigger)