Skip to content

Commit 2fe3797

Browse files
committed
make changes to scintillator.py from comments
1 parent 2f1ae6b commit 2fe3797

File tree

1 file changed

+21
-28
lines changed

1 file changed

+21
-28
lines changed

src/dodal/devices/scintillator.py

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,53 +55,46 @@ 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:
88-
if (
89-
self._aperture_scatterguard().selected_aperture.get_value()
90-
!= ApertureValue.PARKED
91-
):
92-
raise ValueError(
93-
"Cannot move scintillator out if aperture/scatterguard is not parked"
94-
)
9595
await self.y_mm.set(self._scintillator_out_yz_mm[0])
9696
await self.z_mm.set(self._scintillator_out_yz_mm[1])
9797
case InOut.IN:
98-
if (
99-
self._aperture_scatterguard().selected_aperture.get_value()
100-
!= ApertureValue.PARKED
101-
):
102-
raise ValueError(
103-
"Cannot move scintillator in if aperture/scatterguard is not parked"
104-
)
10598
await self.z_mm.set(self._scintillator_in_yz_mm[1])
10699
await self.y_mm.set(self._scintillator_in_yz_mm[0])
107100
case _:

0 commit comments

Comments
 (0)