forked from DiamondLightSource/dodal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Vertical Goniometer of i24 (DiamondLightSource#891)
* Convert to ophyd_async, remove old axes and rename * Rename * Add a couple of small tests * Update beamlines test * Fix linting
- Loading branch information
1 parent
bcd40a3
commit c5b9bc6
Showing
5 changed files
with
64 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from ophyd_async.core import StandardReadable | ||
from ophyd_async.epics.motor import Motor | ||
|
||
|
||
class VerticalGoniometer(StandardReadable): | ||
def __init__(self, prefix: str, name: str = "") -> None: | ||
self.x = Motor(prefix + "PINX") | ||
self.z = Motor(prefix + "PINZ") | ||
self.yh = Motor(prefix + "PINYH") | ||
self.omega = Motor(prefix + "OMEGA") | ||
|
||
self.real_x = Motor(prefix + "PINXS") | ||
self.real_z = Motor(prefix + "PINZS") | ||
self.fast_y = Motor(prefix + "PINYS") | ||
|
||
super().__init__(name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,27 @@ | ||
import pytest | ||
|
||
from dodal.devices.i24.i24_vgonio import VGonio | ||
from dodal.beamlines import i24 | ||
from dodal.common.beamlines import beamline_utils | ||
from dodal.devices.i24.vgonio import VerticalGoniometer | ||
|
||
|
||
def test_list(): | ||
beamline_utils.clear_devices() | ||
i24.zebra(wait_for_connection=False, fake_with_ophyd_sim=True) | ||
i24.pmac(wait_for_connection=False, fake_with_ophyd_sim=True) | ||
i24.vgonio(wait_for_connection=False, fake_with_ophyd_sim=True) | ||
assert beamline_utils.list_active_devices() == [ | ||
"zebra", | ||
"pmac", | ||
"vgonio", | ||
] | ||
|
||
|
||
@pytest.mark.parametrize("module_and_devices_for_beamline", ["i24"], indirect=True) | ||
def test_device_creation(RE, module_and_devices_for_beamline): | ||
_, devices, exceptions = module_and_devices_for_beamline | ||
assert not exceptions | ||
vgonio: VGonio = devices["vgonio"] # type: ignore | ||
assert vgonio.prefix == "BL24I-MO-VGON-01:" | ||
assert vgonio.kappa.prefix == "BL24I-MO-VGON-01:KAPPA" | ||
vgonio: VerticalGoniometer = devices["vgonio"] # type: ignore | ||
|
||
assert vgonio._name == "vgonio" | ||
assert vgonio.omega._name == "vgonio-omega" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import bluesky.plan_stubs as bps | ||
import pytest | ||
|
||
from dodal.devices.i24.vgonio import VerticalGoniometer | ||
from dodal.devices.util.test_utils import patch_motor | ||
|
||
|
||
@pytest.fixture | ||
async def vgonio(RE): | ||
vgonio = VerticalGoniometer("", name="fake_vgonio") | ||
await vgonio.connect(mock=True) | ||
with patch_motor(vgonio.x), patch_motor(vgonio.yh), patch_motor(vgonio.z): | ||
yield vgonio | ||
|
||
|
||
def test_vertical_gonio_device_can_be_created(vgonio: VerticalGoniometer): | ||
assert isinstance(vgonio, VerticalGoniometer) | ||
|
||
|
||
async def test_vgonio_motor_move(vgonio: VerticalGoniometer, RE): | ||
pos = (1.0, 1.5) | ||
RE(bps.mv(vgonio.x, pos[0], vgonio.yh, pos[1])) # type:ignore | ||
|
||
assert await vgonio.x.user_readback.get_value() == 1.0 | ||
assert await vgonio.yh.user_readback.get_value() == 1.5 |