Skip to content

Commit

Permalink
Double speed of thaw (#131)
Browse files Browse the repository at this point in the history
* Double speed of thaw

* Fix ruff linting
  • Loading branch information
DominicOram committed Jul 23, 2024
1 parent 333a3ba commit 0158fbd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
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),
]

0 comments on commit 0158fbd

Please sign in to comment.