Skip to content

Commit 0bc3a29

Browse files
authored
Add i21 and i09 Apple2 (#1647)
* add i21 Apple2 * Added i09 id * correct pv * punctuation * Rename function id to jid in i09.py * move jid to i09-2 * make apple2 take reference
1 parent d13dc42 commit 0bc3a29

File tree

7 files changed

+225
-102
lines changed

7 files changed

+225
-102
lines changed

src/dodal/beamlines/i09_2.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
device_factory,
33
)
44
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
5+
from dodal.devices.apple2_undulator import (
6+
Apple2,
7+
UndulatorGap,
8+
UndulatorPhaseAxes,
9+
)
510
from dodal.devices.i09.enums import Grating
611
from dodal.devices.pgm import PGM
712
from dodal.devices.synchrotron import Synchrotron
@@ -22,3 +27,28 @@ def synchrotron() -> Synchrotron:
2227
@device_factory()
2328
def pgm() -> PGM:
2429
return PGM(prefix=f"{PREFIX.beamline_prefix}-MO-PGM-01:", grating=Grating)
30+
31+
32+
@device_factory()
33+
def jid_gap() -> UndulatorGap:
34+
return UndulatorGap(prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:")
35+
36+
37+
@device_factory()
38+
def jid_phase() -> UndulatorPhaseAxes:
39+
return UndulatorPhaseAxes(
40+
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:",
41+
top_outer="PUO",
42+
top_inner="PUI",
43+
btm_inner="PLI",
44+
btm_outer="PLO",
45+
)
46+
47+
48+
@device_factory()
49+
def jid() -> Apple2:
50+
"""I09 soft x-ray insertion device."""
51+
return Apple2(
52+
id_gap=jid_gap(),
53+
id_phase=jid_phase(),
54+
)

src/dodal/beamlines/i10_optics.py

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,35 @@ def switching_mirror() -> PiezoMirror:
8080
LOOK_UPTABLE_DIR = "/dls_sw/i10/software/gda/workspace_git/gda-diamond.git/configurations/i10-shared/lookupTables/"
8181

8282

83+
@device_factory()
84+
def idd_gap() -> UndulatorGap:
85+
return UndulatorGap(prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:")
86+
87+
88+
@device_factory()
89+
def idd_phase() -> UndulatorPhaseAxes:
90+
return UndulatorPhaseAxes(
91+
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:",
92+
top_outer="RPQ1",
93+
top_inner="RPQ2",
94+
btm_inner="RPQ3",
95+
btm_outer="RPQ4",
96+
)
97+
98+
99+
@device_factory()
100+
def idd_jaw_phase() -> UndulatorJawPhase:
101+
return UndulatorJawPhase(
102+
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:",
103+
move_pv="RPQ1",
104+
)
105+
106+
83107
@device_factory()
84108
def idd() -> I10Apple2:
85109
"""i10 downstream insertion device:"""
86110
return I10Apple2(
87-
id_gap=UndulatorGap(prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:"),
88-
id_phase=UndulatorPhaseAxes(
89-
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:",
90-
top_outer="RPQ1",
91-
top_inner="RPQ2",
92-
btm_inner="RPQ3",
93-
btm_outer="RPQ4",
94-
),
95-
id_jaw_phase=UndulatorJawPhase(
96-
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:",
97-
move_pv="RPQ1",
98-
),
111+
id_gap=idd_gap(), id_phase=idd_phase(), id_jaw_phase=idd_jaw_phase()
99112
)
100113

101114

@@ -131,22 +144,35 @@ def energy_dd() -> BeamEnergy:
131144
return BeamEnergy(id_energy=idd_energy(), mono=pgm().energy)
132145

133146

147+
@device_factory()
148+
def idu_gap() -> UndulatorGap:
149+
return UndulatorGap(prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-21:")
150+
151+
152+
@device_factory()
153+
def idu_phase() -> UndulatorPhaseAxes:
154+
return UndulatorPhaseAxes(
155+
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-21:",
156+
top_outer="RPQ1",
157+
top_inner="RPQ2",
158+
btm_inner="RPQ3",
159+
btm_outer="RPQ4",
160+
)
161+
162+
163+
@device_factory()
164+
def idu_jaw_phase() -> UndulatorJawPhase:
165+
return UndulatorJawPhase(
166+
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-21:",
167+
move_pv="RPQ1",
168+
)
169+
170+
134171
@device_factory()
135172
def idu() -> I10Apple2:
136173
"""i10 upstream insertion device"""
137174
return I10Apple2(
138-
id_gap=UndulatorGap(prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-21:"),
139-
id_phase=UndulatorPhaseAxes(
140-
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-21:",
141-
top_outer="RPQ1",
142-
top_inner="RPQ2",
143-
btm_inner="RPQ3",
144-
btm_outer="RPQ4",
145-
),
146-
id_jaw_phase=UndulatorJawPhase(
147-
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-21:",
148-
move_pv="RPQ1",
149-
),
175+
id_gap=idu_gap(), id_phase=idu_phase(), id_jaw_phase=idu_jaw_phase()
150176
)
151177

152178

src/dodal/beamlines/i17.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,28 @@ def pgm() -> PGM:
4747
)
4848

4949

50+
@device_factory()
51+
def id_gap() -> UndulatorGap:
52+
return UndulatorGap(prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:")
53+
54+
55+
@device_factory()
56+
def id_phase() -> UndulatorPhaseAxes:
57+
return UndulatorPhaseAxes(
58+
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:",
59+
top_outer="RPQ1",
60+
top_inner="RPQ2",
61+
btm_inner="RPQ3",
62+
btm_outer="RPQ4",
63+
)
64+
65+
5066
@device_factory(skip=True)
5167
def id() -> Apple2:
5268
"""I17 insertion device:"""
5369
return Apple2(
54-
id_gap=UndulatorGap(prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:"),
55-
id_phase=UndulatorPhaseAxes(
56-
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:",
57-
top_outer="RPQ1",
58-
top_inner="RPQ2",
59-
btm_inner="RPQ3",
60-
btm_outer="RPQ4",
61-
),
70+
id_gap=id_gap(),
71+
id_phase=id_phase(),
6272
)
6373

6474

src/dodal/beamlines/i21.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
device_factory,
33
)
44
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
5+
from dodal.devices.apple2_undulator import (
6+
Apple2,
7+
UndulatorGap,
8+
UndulatorPhaseAxes,
9+
)
510
from dodal.devices.i21 import Grating
611
from dodal.devices.pgm import PGM
712
from dodal.devices.synchrotron import Synchrotron
813
from dodal.log import set_beamline as set_log_beamline
914
from dodal.utils import BeamlinePrefix, get_beamline_name
1015

1116
BL = get_beamline_name("i21")
12-
PREFIX = BeamlinePrefix(BL, suffix="I")
17+
PREFIX = BeamlinePrefix(BL)
1318
set_log_beamline(BL)
1419
set_utils_beamline(BL)
1520

@@ -25,3 +30,28 @@ def pgm() -> PGM:
2530
prefix=f"{PREFIX.beamline_prefix}-OP-PGM-01:",
2631
grating=Grating,
2732
)
33+
34+
35+
@device_factory()
36+
def id_gap() -> UndulatorGap:
37+
return UndulatorGap(prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:")
38+
39+
40+
@device_factory()
41+
def id_phase() -> UndulatorPhaseAxes:
42+
return UndulatorPhaseAxes(
43+
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:",
44+
top_outer="PUO",
45+
top_inner="PUI",
46+
btm_inner="PLI",
47+
btm_outer="PLO",
48+
)
49+
50+
51+
@device_factory()
52+
def id() -> Apple2:
53+
"""I21 insertion device."""
54+
return Apple2(
55+
id_gap=id_gap(),
56+
id_phase=id_phase(),
57+
)

src/dodal/devices/apple2_undulator.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ def __init__(self, id_gap: UndulatorGap, id_phase: UndulatorPhaseAxes, name=""):
326326
Name of the device.
327327
"""
328328
with self.add_children_as_readables():
329-
self.gap = id_gap
330-
self.phase = id_phase
329+
self.gap = Reference(id_gap)
330+
self.phase = Reference(id_phase)
331331
super().__init__(name=name)
332332

333333
@AsyncStatus.wrap
@@ -338,25 +338,27 @@ async def set(self, id_motor_values: Apple2Val) -> None:
338338
"""
339339

340340
# Only need to check gap as the phase motors share both fault and gate with gap.
341-
await self.gap.raise_if_cannot_move()
341+
await self.gap().raise_if_cannot_move()
342342
await asyncio.gather(
343-
self.phase.top_outer.user_setpoint.set(value=id_motor_values.top_outer),
344-
self.phase.top_inner.user_setpoint.set(value=id_motor_values.top_inner),
345-
self.phase.btm_inner.user_setpoint.set(value=id_motor_values.btm_inner),
346-
self.phase.btm_outer.user_setpoint.set(value=id_motor_values.btm_outer),
347-
self.gap.user_setpoint.set(value=id_motor_values.gap),
343+
self.phase().top_outer.user_setpoint.set(value=id_motor_values.top_outer),
344+
self.phase().top_inner.user_setpoint.set(value=id_motor_values.top_inner),
345+
self.phase().btm_inner.user_setpoint.set(value=id_motor_values.btm_inner),
346+
self.phase().btm_outer.user_setpoint.set(value=id_motor_values.btm_outer),
347+
self.gap().user_setpoint.set(value=id_motor_values.gap),
348348
)
349349
timeout = np.max(
350-
await asyncio.gather(self.gap.get_timeout(), self.phase.get_timeout())
350+
await asyncio.gather(self.gap().get_timeout(), self.phase().get_timeout())
351351
)
352352
LOGGER.info(
353353
f"Moving f{self.name} apple2 motors to {id_motor_values}, timeout = {timeout}"
354354
)
355355
await asyncio.gather(
356-
self.gap.set_move.set(value=1, wait=False, timeout=timeout),
357-
self.phase.set_move.set(value=1, wait=False, timeout=timeout),
356+
self.gap().set_move.set(value=1, wait=False, timeout=timeout),
357+
self.phase().set_move.set(value=1, wait=False, timeout=timeout),
358+
)
359+
await wait_for_value(
360+
self.gap().gate, UndulatorGateStatus.CLOSE, timeout=timeout
358361
)
359-
await wait_for_value(self.gap.gate, UndulatorGateStatus.CLOSE, timeout=timeout)
360362

361363

362364
class EnergyMotorConvertor(Protocol):
@@ -448,11 +450,11 @@ def __init__(
448450
raw_to_derived=self._read_pol,
449451
set_derived=self._set_pol,
450452
pol=self.polarisation_setpoint,
451-
top_outer=self.apple2().phase.top_outer.user_readback,
452-
top_inner=self.apple2().phase.top_inner.user_readback,
453-
btm_inner=self.apple2().phase.btm_inner.user_readback,
454-
btm_outer=self.apple2().phase.btm_outer.user_readback,
455-
gap=self.apple2().gap.user_readback,
453+
top_outer=self.apple2().phase().top_outer.user_readback,
454+
top_inner=self.apple2().phase().top_inner.user_readback,
455+
btm_inner=self.apple2().phase().btm_inner.user_readback,
456+
btm_outer=self.apple2().phase().btm_outer.user_readback,
457+
gap=self.apple2().gap().user_readback,
456458
)
457459
super().__init__(name)
458460

src/dodal/devices/i10/i10_apple2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def __init__(
340340
The name of the device, by default "".
341341
"""
342342
with self.add_children_as_readables():
343-
self.jaw_phase = id_jaw_phase
343+
self.jaw_phase = Reference(id_jaw_phase)
344344
super().__init__(id_gap=id_gap, id_phase=id_phase, name=name)
345345

346346

@@ -425,7 +425,7 @@ async def _set_linear_arbitrary_angle(self, pol_angle: float) -> None:
425425
f"jaw_phase position for angle ({pol_angle}) is outside permitted range"
426426
f" [-{self.jaw_phase_limit}, {self.jaw_phase_limit}]"
427427
)
428-
await self.apple2().jaw_phase.set(jaw_phase)
428+
await self.apple2().jaw_phase().set(jaw_phase)
429429
await self._linear_arbitrary_angle.set(pol_angle)
430430

431431
async def _set_motors_from_energy(self, value: float) -> None:
@@ -447,8 +447,8 @@ async def _set_motors_from_energy(self, value: float) -> None:
447447
LOGGER.info(f"Setting polarisation to {pol}, with values: {id_set_val}")
448448
await self.apple2().set(id_motor_values=id_set_val)
449449
if pol != Pol.LA:
450-
await self.apple2().jaw_phase.set(0)
451-
await self.apple2().jaw_phase.set_move.set(1)
450+
await self.apple2().jaw_phase().set(0)
451+
await self.apple2().jaw_phase().set_move.set(1)
452452

453453
def _raise_if_not_la(self, pol: Pol) -> None:
454454
if pol != Pol.LA:

0 commit comments

Comments
 (0)