Skip to content

Commit 039ed51

Browse files
authored
If scintillator is already out do nothing when moved out (#1625)
* If scintillator is already out do nothing when moved out * Fix tests * Address review comment
1 parent fae6079 commit 039ed51

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/dodal/devices/scintillator.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ def _get_selected_position(self, y: float, z: float) -> InOut:
6969
async def _set_selected_position(self, position: InOut) -> None:
7070
match position:
7171
case InOut.OUT:
72+
current_y = await self.y_mm.user_readback.get_value()
73+
current_z = await self.z_mm.user_readback.get_value()
74+
if self._get_selected_position(current_y, current_z) == InOut.OUT:
75+
return
7276
if (
7377
self._aperture_scatterguard().selected_aperture.get_value()
7478
!= ApertureValue.PARKED

tests/devices/test_scintillator.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import pytest
66
from ophyd_async.core import init_devices
7+
from ophyd_async.testing import get_mock_put
78

89
from dodal.common.beamlines.beamline_parameters import GDABeamlineParameters
910
from dodal.devices.aperturescatterguard import ApertureScatterguard, ApertureValue
@@ -40,6 +41,8 @@ async def scintillator_and_ap_sg(
4041
with ExitStack() as motor_patch_stack:
4142
for motor in [scintillator.y_mm, scintillator.z_mm]:
4243
motor_patch_stack.enter_context(patch_motor(motor))
44+
await scintillator.y_mm.set(5)
45+
await scintillator.z_mm.set(5)
4346
yield scintillator, mock_ap_sg
4447

4548

@@ -95,3 +98,20 @@ async def test_given_aperture_scatterguard_not_parked_when_set_to_out_position_t
9598

9699
with pytest.raises(ValueError):
97100
await scintillator.selected_pos.set(InOut.OUT)
101+
102+
103+
async def test_given_scintillator_already_out_when_moved_out_then_does_nothing(
104+
scintillator_and_ap_sg: tuple[Scintillator, ApertureScatterguard],
105+
):
106+
scintillator, ap_sg = scintillator_and_ap_sg
107+
await scintillator.y_mm.set(0)
108+
await scintillator.z_mm.set(0)
109+
110+
get_mock_put(scintillator.y_mm.user_setpoint).reset_mock()
111+
get_mock_put(scintillator.z_mm.user_setpoint).reset_mock()
112+
113+
ap_sg.return_value.selected_aperture.get_value.return_value = ApertureValue.LARGE # type: ignore
114+
await scintillator.selected_pos.set(InOut.OUT)
115+
116+
get_mock_put(scintillator.y_mm.user_setpoint).assert_not_called()
117+
get_mock_put(scintillator.z_mm.user_setpoint).assert_not_called()

0 commit comments

Comments
 (0)