Skip to content

Commit

Permalink
Change DetectorControl to DetectorController
Browse files Browse the repository at this point in the history
  • Loading branch information
abbiemery committed Sep 13, 2024
1 parent 5b67581 commit 75b49a9
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 44 deletions.
4 changes: 2 additions & 2 deletions docs/examples/foo_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from ophyd_async.core import (
AsyncStatus,
DetectorControl,
DetectorController,
DetectorTrigger,
PathProvider,
StandardDetector,
Expand All @@ -20,7 +20,7 @@ def __init__(self, prefix: str, name: str = "") -> None:
super().__init__(prefix, name)


class FooController(DetectorControl):
class FooController(DetectorController):
def __init__(self, driver: FooDriver) -> None:
self._drv = driver

Expand Down
2 changes: 1 addition & 1 deletion docs/explanations/decisions/0007-subpackage-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ There will be a flat public namespace under core, with contents reimported from
- `_signal.py` for `Signal`, `SignalBackend`, `observe_signal`, etc.
- `_mock.py` for `MockSignalBackend`, `get_mock_put`, etc.
- `_readable.py` for `StandardReadable`, `ConfigSignal`, `HintedSignal`, etc.
- `_detector.py` for `StandardDetector`, `DetectorWriter`, `DetectorControl`, `TriggerInfo`, etc.
- `_detector.py` for `StandardDetector`, `DetectorWriter`, `DetectorController`, `TriggerInfo`, etc.
- `_flyer.py` for `StandardFlyer`, `FlyerControl`, etc.

There are some renames that will be required, e.g. `HardwareTriggeredFlyable` -> `StandardFlyer`
Expand Down
10 changes: 5 additions & 5 deletions docs/how-to/make-a-standard-detector.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Make a StandardDetector
The `StandardDetector` is a simple compound device, with 2 standard components:

- `DetectorWriter` to handle data persistence, i/o and pass information about data to the RunEngine (usually an instance of :py:class:`ADHDFWriter`)
- `DetectorControl` with logic for arming and disarming the detector. This will be unique to the StandardDetector implementation.
- `DetectorController` with logic for arming and disarming the detector. This will be unique to the StandardDetector implementation.

Writing an AreaDetector StandardDetector
----------------------------------------
Expand All @@ -28,9 +28,9 @@ Enumeration fields should be named to prevent namespace collision, i.e. for a Si
:language: python
:pyobject: FooDriver

Define a :py:class:`FooController` with handling for converting the standard pattern of :py:meth:`ophyd_async.core.DetectorControl.arm` and :py:meth:`ophyd_async.core.DetectorControl.disarm` to required state of :py:class:`FooDriver` e.g. setting a compatible "FooTriggerSource" for a given `DetectorTrigger`, or raising an exception if incompatible with the `DetectorTrigger`.
Define a :py:class:`FooController` with handling for converting the standard pattern of :py:meth:`ophyd_async.core.DetectorController.arm` and :py:meth:`ophyd_async.core.DetectorController.disarm` to required state of :py:class:`FooDriver` e.g. setting a compatible "FooTriggerSource" for a given `DetectorTrigger`, or raising an exception if incompatible with the `DetectorTrigger`.

The :py:meth:`ophyd_async.core.DetectorControl.get_deadtime` method is used when constructing sequence tables for hardware controlled scanning. Details on how to calculate the deadtime may be only available from technical manuals or otherwise complex. **If it requires fetching from signals, it is recommended to cache the value during the StandardDetector `prepare` method.**
The :py:meth:`ophyd_async.core.DetectorController.get_deadtime` method is used when constructing sequence tables for hardware controlled scanning. Details on how to calculate the deadtime may be only available from technical manuals or otherwise complex. **If it requires fetching from signals, it is recommended to cache the value during the StandardDetector `prepare` method.**

.. literalinclude:: ../examples/foo_detector.py
:pyobject: FooController
Expand All @@ -47,8 +47,8 @@ If the :py:class:`FooDriver` signals that should be read as configuration, they
Writing a non-AreaDetector StandardDetector
-------------------------------------------

A non-AreaDetector `StandardDetector` should implement `DetectorControl` and `DetectorWriter` directly.
Here we construct a `DetectorControl` that co-ordinates signals on a PandA PositionCapture block - a child device "pcap" of the `StandardDetector` implementation, analogous to the :py:class:`FooDriver`.
A non-AreaDetector `StandardDetector` should implement `DetectorController` and `DetectorWriter` directly.
Here we construct a `DetectorController` that co-ordinates signals on a PandA PositionCapture block - a child device "pcap" of the `StandardDetector` implementation, analogous to the :py:class:`FooDriver`.

.. literalinclude:: ../../src/ophyd_async/fastcs/panda/_control.py
:pyobject: PandaPcapController
Expand Down
4 changes: 2 additions & 2 deletions src/ophyd_async/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ._detector import (
DetectorControl,
DetectorController,
DetectorTrigger,
DetectorWriter,
StandardDetector,
Expand Down Expand Up @@ -84,7 +84,7 @@
)

__all__ = [
"DetectorControl",
"DetectorController",
"DetectorTrigger",
"DetectorWriter",
"StandardDetector",
Expand Down
6 changes: 3 additions & 3 deletions src/ophyd_async/core/_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class TriggerInfo(BaseModel):
iteration: int = 1


class DetectorControl(ABC):
class DetectorController(ABC):
"""
Classes implementing this interface should hold the logic for
arming and disarming a detector
Expand Down Expand Up @@ -172,7 +172,7 @@ class StandardDetector(

def __init__(
self,
controller: DetectorControl,
controller: DetectorController,
writer: DetectorWriter,
config_sigs: Sequence[AsyncReadable] = (),
name: str = "",
Expand Down Expand Up @@ -204,7 +204,7 @@ def __init__(
super().__init__(name)

@property
def controller(self) -> DetectorControl:
def controller(self) -> DetectorController:
return self._controller

@property
Expand Down
4 changes: 2 additions & 2 deletions src/ophyd_async/epics/adaravis/_aravis_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Literal, Tuple

from ophyd_async.core import (
DetectorControl,
DetectorController,
DetectorTrigger,
TriggerInfo,
set_and_wait_for_value,
Expand All @@ -18,7 +18,7 @@
_HIGHEST_POSSIBLE_DEADTIME = 1961e-6


class AravisController(DetectorControl):
class AravisController(DetectorController):
GPIO_NUMBER = Literal[1, 2, 3, 4]

def __init__(self, driver: AravisDriverIO, gpio_number: GPIO_NUMBER) -> None:
Expand Down
4 changes: 2 additions & 2 deletions src/ophyd_async/epics/adcore/_core_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
DEFAULT_TIMEOUT,
AsyncStatus,
DatasetDescriber,
DetectorControl,
DetectorController,
set_and_wait_for_value,
)
from ophyd_async.epics.adcore._utils import convert_ad_dtype_to_np
Expand Down Expand Up @@ -35,7 +35,7 @@ async def shape(self) -> tuple[int, int]:


async def set_exposure_time_and_acquire_period_if_supplied(
controller: DetectorControl,
controller: DetectorController,
driver: ADBaseIO,
exposure: float | None = None,
timeout: float = DEFAULT_TIMEOUT,
Expand Down
4 changes: 2 additions & 2 deletions src/ophyd_async/epics/adkinetix/_kinetix_controller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import asyncio

from ophyd_async.core import DetectorControl, DetectorTrigger
from ophyd_async.core import DetectorController, DetectorTrigger
from ophyd_async.core._detector import TriggerInfo
from ophyd_async.core._status import AsyncStatus
from ophyd_async.epics import adcore
Expand All @@ -15,7 +15,7 @@
}


class KinetixController(DetectorControl):
class KinetixController(DetectorController):
def __init__(
self,
driver: KinetixDriverIO,
Expand Down
4 changes: 2 additions & 2 deletions src/ophyd_async/epics/adpilatus/_pilatus_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from ophyd_async.core import (
DEFAULT_TIMEOUT,
DetectorControl,
DetectorController,
DetectorTrigger,
wait_for_value,
)
Expand All @@ -13,7 +13,7 @@
from ._pilatus_io import PilatusDriverIO, PilatusTriggerMode


class PilatusController(DetectorControl):
class PilatusController(DetectorController):
_supported_trigger_types = {
DetectorTrigger.internal: PilatusTriggerMode.internal,
DetectorTrigger.constant_gate: PilatusTriggerMode.ext_enable,
Expand Down
4 changes: 2 additions & 2 deletions src/ophyd_async/epics/adsimdetector/_sim_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

from ophyd_async.core import (
DEFAULT_TIMEOUT,
DetectorControl,
DetectorController,
DetectorTrigger,
)
from ophyd_async.core._detector import TriggerInfo
from ophyd_async.core._status import AsyncStatus
from ophyd_async.epics import adcore


class SimController(DetectorControl):
class SimController(DetectorController):
def __init__(
self,
driver: adcore.ADBaseIO,
Expand Down
4 changes: 2 additions & 2 deletions src/ophyd_async/epics/advimba/_vimba_controller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import asyncio

from ophyd_async.core import DetectorControl, DetectorTrigger
from ophyd_async.core import DetectorController, DetectorTrigger
from ophyd_async.core._detector import TriggerInfo
from ophyd_async.core._status import AsyncStatus
from ophyd_async.epics import adcore
Expand All @@ -22,7 +22,7 @@
}


class VimbaController(DetectorControl):
class VimbaController(DetectorController):
def __init__(
self,
driver: VimbaDriverIO,
Expand Down
4 changes: 2 additions & 2 deletions src/ophyd_async/epics/eiger/_eiger_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from ophyd_async.core import (
DEFAULT_TIMEOUT,
DetectorControl,
DetectorController,
DetectorTrigger,
set_and_wait_for_other_value,
)
Expand All @@ -18,7 +18,7 @@
}


class EigerController(DetectorControl):
class EigerController(DetectorController):
def __init__(
self,
driver: EigerDriverIO,
Expand Down
4 changes: 2 additions & 2 deletions src/ophyd_async/fastcs/panda/_control.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio

from ophyd_async.core import (
DetectorControl,
DetectorController,
DetectorTrigger,
wait_for_value,
)
Expand All @@ -11,7 +11,7 @@
from ._block import PcapBlock


class PandaPcapController(DetectorControl):
class PandaPcapController(DetectorController):
def __init__(self, pcap: PcapBlock) -> None:
self.pcap = pcap
self._arm_status: AsyncStatus | None = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

from pydantic import Field

from ophyd_async.core import DetectorControl, PathProvider
from ophyd_async.core import DetectorController, PathProvider
from ophyd_async.core._detector import TriggerInfo

from ._pattern_generator import PatternGenerator


class PatternDetectorController(DetectorControl):
class PatternDetectorController(DetectorController):
def __init__(
self,
pattern_generator: PatternGenerator,
Expand Down
6 changes: 3 additions & 3 deletions tests/core/test_flyer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from ophyd_async.core import (
DEFAULT_TIMEOUT,
DetectorControl,
DetectorController,
DetectorTrigger,
DetectorWriter,
StandardDetector,
Expand Down Expand Up @@ -124,12 +124,12 @@ async def dummy_arm_2(self=None, trigger=None, num=0, exposure=None):
return writers[1].dummy_signal.set(1)

detector_1: StandardDetector[Any] = StandardDetector(
Mock(spec=DetectorControl, get_deadtime=lambda num: num, arm=dummy_arm_1),
Mock(spec=DetectorController, get_deadtime=lambda num: num, arm=dummy_arm_1),
writers[0],
name="detector_1",
)
detector_2: StandardDetector[Any] = StandardDetector(
Mock(spec=DetectorControl, get_deadtime=lambda num: num, arm=dummy_arm_2),
Mock(spec=DetectorController, get_deadtime=lambda num: num, arm=dummy_arm_2),
writers[1],
name="detector_2",
)
Expand Down
8 changes: 4 additions & 4 deletions tests/epics/adcore/test_drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest

from ophyd_async.core import (
DetectorControl,
DetectorController,
DeviceCollector,
get_mock_put,
set_mock_value,
Expand All @@ -23,13 +23,13 @@ def driver(RE) -> adcore.ADBaseIO:

@pytest.fixture
async def controller(RE, driver: adcore.ADBaseIO) -> Mock:
controller = Mock(spec=DetectorControl)
controller = Mock(spec=DetectorController)
controller.get_deadtime.return_value = TEST_DEADTIME
return controller


async def test_set_exposure_time_and_acquire_period_if_supplied_is_a_noop_if_no_exposure_supplied( # noqa: E501
controller: DetectorControl,
controller: DetectorController,
driver: adcore.ADBaseIO,
):
put_exposure = get_mock_put(driver.acquire_time)
Expand All @@ -50,7 +50,7 @@ async def test_set_exposure_time_and_acquire_period_if_supplied_is_a_noop_if_no_
],
)
async def test_set_exposure_time_and_acquire_period_if_supplied_uses_deadtime(
controller: DetectorControl,
controller: DetectorController,
driver: adcore.ADBaseIO,
exposure: float,
expected_exposure: float,
Expand Down
4 changes: 2 additions & 2 deletions tests/epics/adcore/test_scans.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from ophyd_async.core import (
AsyncStatus,
DetectorControl,
DetectorController,
DetectorTrigger,
DeviceCollector,
StandardDetector,
Expand All @@ -35,7 +35,7 @@ async def complete(self): ...
async def stop(self): ...


class DummyController(DetectorControl):
class DummyController(DetectorController):
def __init__(self) -> None: ...
async def prepare(self, trigger_info: TriggerInfo):
return AsyncStatus(asyncio.sleep(0.01))
Expand Down
8 changes: 4 additions & 4 deletions tests/plan_stubs/test_fly.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
DEFAULT_TIMEOUT,
AsyncReadable,
AsyncStatus,
DetectorControl,
DetectorController,
DetectorWriter,
DeviceCollector,
SignalR,
Expand Down Expand Up @@ -106,7 +106,7 @@ def increment_index(self) -> None:
class MockDetector(StandardDetector):
def __init__(
self,
controller: DetectorControl,
controller: DetectorController,
writer: DetectorWriter,
config_sigs: Sequence[AsyncReadable] = [],
name: str = "",
Expand Down Expand Up @@ -151,12 +151,12 @@ def dummy_arm_2(self=None):
return writers[1].dummy_signal.set(1)

detector_1 = MockDetector(
Mock(spec=DetectorControl, get_deadtime=lambda num: num, arm=dummy_arm_1),
Mock(spec=DetectorController, get_deadtime=lambda num: num, arm=dummy_arm_1),
writers[0],
name="detector_1",
)
detector_2 = MockDetector(
Mock(spec=DetectorControl, get_deadtime=lambda num: num, arm=dummy_arm_2),
Mock(spec=DetectorController, get_deadtime=lambda num: num, arm=dummy_arm_2),
writers[1],
name="detector_2",
)
Expand Down

0 comments on commit 75b49a9

Please sign in to comment.