Skip to content

Commit 512a942

Browse files
committed
make changes to scintillator.py from comments
1 parent 05453f9 commit 512a942

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/dodal/devices/scintillator.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,34 +55,41 @@ def __init__(
5555

5656
super().__init__(name)
5757

58-
def _get_selected_position(self, y: float, z: float) -> InOut:
59-
current_pos = [y, z]
60-
if all(
58+
def check_position(
59+
self, current_pos: tuple[float, float], pos_to_check: tuple[float, float]
60+
):
61+
return all(
6162
isclose(axis_pos, axis_in_beam, abs_tol=axis_tolerance)
6263
for axis_pos, axis_in_beam, axis_tolerance in zip(
6364
current_pos,
64-
self._scintillator_out_yz_mm,
65+
pos_to_check,
6566
self._yz_tolerance_mm,
6667
strict=False,
6768
)
68-
):
69+
)
70+
71+
def _get_selected_position(self, y: float, z: float) -> InOut:
72+
current_pos = [y, z]
73+
if self.check_position(current_pos, self._scintillator_out_yz_mm):
6974
return InOut.OUT
7075

71-
elif all(
72-
isclose(axis_pos, axis_in_beam, abs_tol=axis_tolerance)
73-
for axis_pos, axis_in_beam, axis_tolerance in zip(
74-
current_pos,
75-
self._scintillator_in_yz_mm,
76-
self._yz_tolerance_mm,
77-
strict=False,
78-
)
79-
):
76+
elif self.check_position(current_pos, self._scintillator_in_yz_mm):
8077
return InOut.IN
8178

8279
else:
8380
return InOut.UNKNOWN
8481

82+
def check_aperture_parked(self):
83+
if (
84+
self._aperture_scatterguard().selected_aperture.get_value()
85+
!= ApertureValue.PARKED
86+
):
87+
raise ValueError(
88+
"Cannot move scintillator out if aperture/scatterguard is not parked"
89+
)
90+
8591
async def _set_selected_position(self, position: InOut) -> None:
92+
self.check_aperture_parked()
8693
match position:
8794
case InOut.OUT:
8895
current_y = await self.y_mm.user_readback.get_value()
@@ -99,13 +106,6 @@ async def _set_selected_position(self, position: InOut) -> None:
99106
await self.y_mm.set(self._scintillator_out_yz_mm[0])
100107
await self.z_mm.set(self._scintillator_out_yz_mm[1])
101108
case InOut.IN:
102-
if (
103-
self._aperture_scatterguard().selected_aperture.get_value()
104-
!= ApertureValue.PARKED
105-
):
106-
raise ValueError(
107-
"Cannot move scintillator in if aperture/scatterguard is not parked"
108-
)
109109
await self.z_mm.set(self._scintillator_in_yz_mm[1])
110110
await self.y_mm.set(self._scintillator_in_yz_mm[0])
111111
case _:

0 commit comments

Comments
 (0)