From 63cdceba115f02c779d9f22bebedc7ab1fa16006 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Mon, 22 Jul 2024 18:20:38 +0100 Subject: [PATCH 1/2] Double speed of thaw --- src/mx_bluesky/i04/__init__.py | 3 +++ src/mx_bluesky/i04/thawing_plan.py | 8 +++++--- tests/i04/test_thawing.py | 13 +++++++------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/mx_bluesky/i04/__init__.py b/src/mx_bluesky/i04/__init__.py index e69de29bb..674407e94 100644 --- a/src/mx_bluesky/i04/__init__.py +++ b/src/mx_bluesky/i04/__init__.py @@ -0,0 +1,3 @@ +from mx_bluesky.i04.thawing_plan import thaw + +__all__ = ["thaw"] \ No newline at end of file diff --git a/src/mx_bluesky/i04/thawing_plan.py b/src/mx_bluesky/i04/thawing_plan.py index ce504b885..f040196a9 100644 --- a/src/mx_bluesky/i04/thawing_plan.py +++ b/src/mx_bluesky/i04/thawing_plan.py @@ -1,6 +1,7 @@ import bluesky.plan_stubs as bps import bluesky.preprocessors as bpp -from dodal.common import MsgGenerator, inject +from dodal.common import inject +from dls_bluesky_core.core import MsgGenerator from dodal.devices.smargon import Smargon from dodal.devices.thawer import Thawer, ThawerStates @@ -22,12 +23,13 @@ def thaw( Defaults to inject("smargon") """ inital_velocity = yield from bps.rd(smargon.omega.velocity) - new_velocity = abs(rotation / time_to_thaw) + new_velocity = abs(rotation / time_to_thaw) * 2.0 def do_thaw(): yield from bps.abs_set(smargon.omega.velocity, new_velocity, wait=True) yield from bps.abs_set(thawer.control, ThawerStates.ON, wait=True) yield from bps.rel_set(smargon.omega, rotation, wait=True) + yield from bps.rel_set(smargon.omega, -rotation, wait=True) def cleanup(): yield from bps.abs_set(smargon.omega.velocity, inital_velocity, wait=True) @@ -37,4 +39,4 @@ def cleanup(): yield from bpp.contingency_wrapper( do_thaw(), final_plan=cleanup, - ) + ) \ No newline at end of file diff --git a/tests/i04/test_thawing.py b/tests/i04/test_thawing.py index b4feb8aad..ad09dfda7 100644 --- a/tests/i04/test_thawing.py +++ b/tests/i04/test_thawing.py @@ -86,9 +86,9 @@ def do_thaw_func(): @pytest.mark.parametrize( "time, rotation, expected_speed", [ - (10, 360, 36), - (3.5, 100, pytest.approx(28.5714285)), - (50, -100, 2), + (10, 360, 72), + (3.5, 100, pytest.approx(57.142857)), + (50, -100, 4), ], ) def test_given_different_rotations_and_times_then_velocity_correct( @@ -114,6 +114,7 @@ def test_given_different_rotations_then_motor_moved_relative( set_mock_value(smargon.omega.user_readback, start_pos) RE = RunEngine() RE(thaw(10, rotation, thawer=thawer, smargon=smargon)) - get_mock_put(smargon.omega.user_setpoint).assert_called_with( - expected_end, wait=ANY, timeout=ANY - ) + assert get_mock_put(smargon.omega.user_setpoint).call_args_list == [ + call(expected_end, wait=ANY, timeout=ANY), + call(start_pos, wait=ANY, timeout=ANY), + ] From a17bcaf832f1f06370761747d47bb4d27a4167bf Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Tue, 23 Jul 2024 11:29:57 +0100 Subject: [PATCH 2/2] Fix ruff linting --- src/mx_bluesky/i04/__init__.py | 2 +- src/mx_bluesky/i04/thawing_plan.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mx_bluesky/i04/__init__.py b/src/mx_bluesky/i04/__init__.py index 674407e94..ad869ba61 100644 --- a/src/mx_bluesky/i04/__init__.py +++ b/src/mx_bluesky/i04/__init__.py @@ -1,3 +1,3 @@ from mx_bluesky.i04.thawing_plan import thaw -__all__ = ["thaw"] \ No newline at end of file +__all__ = ["thaw"] diff --git a/src/mx_bluesky/i04/thawing_plan.py b/src/mx_bluesky/i04/thawing_plan.py index f040196a9..1908ebe33 100644 --- a/src/mx_bluesky/i04/thawing_plan.py +++ b/src/mx_bluesky/i04/thawing_plan.py @@ -1,7 +1,7 @@ import bluesky.plan_stubs as bps import bluesky.preprocessors as bpp -from dodal.common import inject from dls_bluesky_core.core import MsgGenerator +from dodal.common import inject from dodal.devices.smargon import Smargon from dodal.devices.thawer import Thawer, ThawerStates @@ -39,4 +39,4 @@ def cleanup(): yield from bpp.contingency_wrapper( do_thaw(), final_plan=cleanup, - ) \ No newline at end of file + )