Source code for ophyd_async.core._flyer
from abc import ABC, abstractmethod
from typing import Any, Generic
from bluesky.protocols import Flyable, Preparable, Stageable
from ._device import Device
from ._status import AsyncStatus
from ._utils import T
[docs]
class FlyerController(ABC, Generic[T]):
"""Base class for controlling 'flyable' devices.
[`bluesky.protocols.Flyable`](#bluesky.protocols.Flyable).
"""
[docs]
@abstractmethod
async def prepare(self, value: T) -> Any:
"""Move to the start of the flyscan."""
[docs]
@abstractmethod
async def kickoff(self):
"""Start the flyscan."""
[docs]
@abstractmethod
async def complete(self):
"""Block until the flyscan is done."""
[docs]
@abstractmethod
async def stop(self):
"""Stop flying and wait everything to be stopped."""
[docs]
class StandardFlyer(
Device,
Stageable,
Preparable,
Flyable,
Generic[T],
):
"""Base class for 'flyable' devices.
[`bluesky.protocols.Flyable`](#bluesky.protocols.Flyable).
"""
def __init__(
self,
trigger_logic: FlyerController[T],
name: str = "",
):
self._trigger_logic = trigger_logic
super().__init__(name=name)
@property
def trigger_logic(self) -> FlyerController[T]:
return self._trigger_logic
[docs]
@AsyncStatus.wrap
async def stage(self) -> None:
await self.unstage()
[docs]
@AsyncStatus.wrap
async def unstage(self) -> None:
await self._trigger_logic.stop()
[docs]
def prepare(self, value: T) -> AsyncStatus:
return AsyncStatus(self._prepare(value))
async def _prepare(self, value: T) -> None:
# Move to start and setup the flyscan
await self._trigger_logic.prepare(value)
[docs]
@AsyncStatus.wrap
async def kickoff(self) -> None:
await self._trigger_logic.kickoff()
[docs]
@AsyncStatus.wrap
async def complete(self) -> None:
await self._trigger_logic.complete()