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

Double speed of thaw #131

Merged
merged 2 commits into from
Jul 23, 2024
Merged
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
3 changes: 3 additions & 0 deletions src/mx_bluesky/i04/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from mx_bluesky.i04.thawing_plan import thaw

__all__ = ["thaw"]
6 changes: 4 additions & 2 deletions src/mx_bluesky/i04/thawing_plan.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import bluesky.plan_stubs as bps
import bluesky.preprocessors as bpp
from dodal.common import MsgGenerator, 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

Expand All @@ -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)
Expand Down
13 changes: 7 additions & 6 deletions tests/i04/test_thawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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),
]
Loading