Skip to content
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
15 changes: 15 additions & 0 deletions src/mx_bluesky/beamlines/i24/web_gui_plans/oav_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,18 @@ def focus_on_oav_view(
magnitude = -magnitude

yield from bps.abs_set(pmac.z, magnitude, wait=True)


def move_on_oav_view_click(
Comment thread
adaudon marked this conversation as resolved.
position: tuple[int, int], oav=inject("oav"), pmac: PMAC = inject("pmac")
) -> MsgGenerator:
x = position[0]
y = position[1]

x_microns_per_pixel = yield from bps.rd(oav.microns_per_pixel_x)
y_microns_per_pixel = yield from bps.rd(oav.microns_per_pixel_y)

x_mm = (x * x_microns_per_pixel) / 1000
y_mm = (y * y_microns_per_pixel) / 1000

yield from bps.mv(pmac.x, x_mm, pmac.y, y_mm, wait=True)
28 changes: 28 additions & 0 deletions tests/unit_tests/beamlines/i24/web_gui/test_oav_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
focus_on_oav_view,
move_block_on_arrow_click,
move_nudge_on_arrow_click,
move_on_oav_view_click,
move_window_on_arrow_click,
)

Expand Down Expand Up @@ -103,3 +104,30 @@ async def test_focus_on_oav_view(
):
run_engine(focus_on_oav_view(FocusDirection(direction), MoveSize(move_size), pmac))
assert await pmac.z.user_readback.get_value() == expected_value


@pytest.mark.parametrize(
"coordinates, expected_x, expected_y",
[
((568, 321), 0.568, 0.321),
((123, 789), 0.123, 0.789),
],
)
def test_move_on_oav_view_click(
coordinates, expected_x, expected_y, oav, pmac, run_engine
):
def fake_rd(_signal):
return 1.0
yield

with (
patch(
"mx_bluesky.beamlines.i24.web_gui_plans.oav_plans.bps.mv",
) as mock_bps_mv,
patch(
"mx_bluesky.beamlines.i24.web_gui_plans.oav_plans.bps.rd",
side_effect=fake_rd,
),
):
run_engine(move_on_oav_view_click(coordinates, oav, pmac))
mock_bps_mv.assert_any_call(pmac.x, expected_x, pmac.y, expected_y, wait=True)
4 changes: 2 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading