Skip to content

Commit

Permalink
Rename core classes (bluesky#577)
Browse files Browse the repository at this point in the history
Rename DetectorControl to DetectorController and rename TriggerLogic to FlyerController
  • Loading branch information
abbiemery authored Oct 3, 2024
1 parent ef2a116 commit e291396
Show file tree
Hide file tree
Showing 20 changed files with 58 additions and 58 deletions.
4 changes: 2 additions & 2 deletions docs/examples/foo_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from ophyd_async.core import (
AsyncStatus,
DetectorControl,
DetectorController,
DetectorTrigger,
PathProvider,
StandardDetector,
Expand All @@ -19,7 +19,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
8 changes: 4 additions & 4 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 All @@ -16,7 +16,7 @@
set_signal_values,
walk_rw_signals,
)
from ._flyer import StandardFlyer, TriggerLogic
from ._flyer import FlyerController, StandardFlyer
from ._hdf_dataset import HDFDataset, HDFFile
from ._log import config_ophyd_async_logging
from ._mock_signal_backend import MockSignalBackend
Expand Down Expand Up @@ -85,7 +85,7 @@
)

__all__ = [
"DetectorControl",
"DetectorController",
"DetectorTrigger",
"DetectorWriter",
"StandardDetector",
Expand All @@ -102,7 +102,7 @@
"set_signal_values",
"walk_rw_signals",
"StandardFlyer",
"TriggerLogic",
"FlyerController",
"HDFDataset",
"HDFFile",
"config_ophyd_async_logging",
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 @@ -80,7 +80,7 @@ def total_number_of_triggers(self) -> int:
)


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

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

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

@property
Expand Down
6 changes: 3 additions & 3 deletions src/ophyd_async/core/_flyer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ._utils import T


class TriggerLogic(ABC, Generic[T]):
class FlyerController(ABC, Generic[T]):
@abstractmethod
async def prepare(self, value: T):
"""Move to the start of the flyscan"""
Expand All @@ -35,14 +35,14 @@ class StandardFlyer(
):
def __init__(
self,
trigger_logic: TriggerLogic[T],
trigger_logic: FlyerController[T],
name: str = "",
):
self._trigger_logic = trigger_logic
super().__init__(name=name)

@property
def trigger_logic(self) -> TriggerLogic[T]:
def trigger_logic(self) -> FlyerController[T]:
return self._trigger_logic

@AsyncStatus.wrap
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

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 @@ -4,7 +4,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 @@ -34,7 +34,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 @@ -2,15 +2,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
6 changes: 3 additions & 3 deletions src/ophyd_async/fastcs/panda/_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from pydantic import BaseModel, Field

from ophyd_async.core import TriggerLogic, wait_for_value
from ophyd_async.core import FlyerController, wait_for_value

from ._block import PcompBlock, PcompDirectionOptions, SeqBlock, TimeUnits
from ._table import SeqTable
Expand All @@ -14,7 +14,7 @@ class SeqTableInfo(BaseModel):
prescale_as_us: float = Field(default=1, ge=0) # microseconds


class StaticSeqTableTriggerLogic(TriggerLogic[SeqTableInfo]):
class StaticSeqTableTriggerLogic(FlyerController[SeqTableInfo]):
def __init__(self, seq: SeqBlock) -> None:
self.seq = seq

Expand Down Expand Up @@ -63,7 +63,7 @@ class PcompInfo(BaseModel):
)


class StaticPcompTriggerLogic(TriggerLogic[PcompInfo]):
class StaticPcompTriggerLogic(FlyerController[PcompInfo]):
def __init__(self, pcomp: PcompBlock) -> None:
self.pcomp = pcomp

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import asyncio

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
10 changes: 5 additions & 5 deletions tests/core/test_flyer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

from ophyd_async.core import (
DEFAULT_TIMEOUT,
DetectorControl,
DetectorController,
DetectorTrigger,
DetectorWriter,
FlyerController,
StandardDetector,
StandardFlyer,
TriggerInfo,
TriggerLogic,
observe_value,
)
from ophyd_async.core._signal import assert_emitted
Expand All @@ -33,7 +33,7 @@ class TriggerState(str, Enum):
stopping = "stopping"


class DummyTriggerLogic(TriggerLogic[int]):
class DummyTriggerLogic(FlyerController[int]):
def __init__(self):
self.state = TriggerState.null

Expand Down Expand Up @@ -126,12 +126,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
Loading

0 comments on commit e291396

Please sign in to comment.