Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

846 convert i23 to use device factory #987

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/dodal/beamlines/i23.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from dodal.common.beamlines.beamline_utils import device_instantiation
from dodal.common.beamlines.beamline_utils import device_factory
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.devices.oav.pin_image_recognition import PinTipDetection
from dodal.log import set_beamline as set_log_beamline
from dodal.utils import get_beamline_name, get_hostname, skip_device
from dodal.utils import BeamlinePrefix, get_beamline_name, get_hostname

BL = get_beamline_name("i23")
set_log_beamline(BL)
set_utils_beamline(BL)

PREFIX = BeamlinePrefix(BL)


def _is_i23_machine():
"""
Expand All @@ -18,16 +20,11 @@ def _is_i23_machine():
return hostname.startswith("i23-ws") or hostname.startswith("i23-control")


@skip_device(lambda: not _is_i23_machine())
def oav_pin_tip_detection(
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False
) -> PinTipDetection:
@device_factory(skip=lambda: not _is_i23_machine())
def oav_pin_tip_detection() -> PinTipDetection:
"""Get the i23 OAV pin-tip detection device"""

return device_instantiation(
PinTipDetection,
return PinTipDetection(
f"{PREFIX.beamline_prefix}-DI-OAV-01:",
"pin_tip_detection",
"-DI-OAV-01:",
wait_for_connection,
fake_with_ophyd_sim,
)
7 changes: 1 addition & 6 deletions src/dodal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
Any,
Generic,
Protocol,
TypeAlias,
TypeGuard,
TypeVar,
runtime_checkable,
Expand Down Expand Up @@ -43,12 +44,6 @@

import dodal.log

try:
from typing import TypeAlias
except ImportError:
from typing import TypeAlias


#: Protocols defining interface to hardware
BLUESKY_PROTOCOLS = [
Checkable,
Expand Down
Loading