Skip to content

Commit b7c9c51

Browse files
Relm-ArrownyDominicOramolliesilvester
authored
Removes/reduces referenece use on i10 IDs (#1032)
* corrected read so it always read pol from hardware * add uml and correct some docstring * Time out fix * change id to use direved derived_signal_r * make polarisation both read and set. * update lookuptable path for blueapi --------- Co-authored-by: Dominic Oram <dominic.oram@diamond.ac.uk> Co-authored-by: olliesilvester <122091460+olliesilvester@users.noreply.github.com>
1 parent 4aa9d22 commit b7c9c51

File tree

9 files changed

+740
-642
lines changed

9 files changed

+740
-642
lines changed
229 KB
Loading
295 KB
Loading

src/dodal/beamlines/i10.py

Lines changed: 41 additions & 233 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
from pathlib import Path
1+
"""
2+
note:
3+
I10 has two insertion devices one up(idu) and one down stream(idd).
4+
It is worth noting that the downstream device is slightly longer,
5+
so it can reach Mn edge for linear arbitrary.
6+
idd == id1, idu == id2.
7+
"""
28

3-
from dodal.common.beamlines.beamline_utils import device_factory, device_instantiation
9+
from dodal.common.beamlines.beamline_utils import device_factory
410
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
5-
from dodal.devices.apple2_undulator import (
6-
UndulatorGap,
7-
UndulatorJawPhase,
8-
UndulatorPhaseAxes,
9-
)
1011
from dodal.devices.current_amplifiers import CurrentAmpDet
1112
from dodal.devices.i10.diagnostics import I10Diagnostic, I10Diagnostic5ADet
1213
from dodal.devices.i10.i10_apple2 import (
13-
I10Apple2,
14-
I10Apple2PGM,
15-
I10Apple2Pol,
16-
LinearArbitraryAngle,
14+
I10Id,
1715
)
1816
from dodal.devices.i10.i10_setting_data import I10Grating
1917
from dodal.devices.i10.mirrors import PiezoMirror
@@ -37,238 +35,48 @@
3735
PREFIX = BeamlinePrefix(BL)
3836

3937

40-
LOOK_UPTABLE_DIR = "/dls_sw/i10/software/gda/workspace_git/gda-diamond.git/configurations/i10-shared/lookupTables/"
41-
"""
42-
I10 has two insertion devices one up(idu) and one down stream(idd).
43-
It is worth noting that the down stream device is slightly longer,
44-
so it can reach Mn edge for linear arbitrary.
45-
idd == id1
46-
and
47-
idu == id2.
48-
"""
49-
50-
51-
def idd_gap(
52-
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False
53-
) -> UndulatorGap:
54-
return device_instantiation(
55-
device_factory=UndulatorGap,
56-
name="idd_gap",
57-
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:",
58-
wait=wait_for_connection,
59-
fake=fake_with_ophyd_sim,
60-
bl_prefix=False,
61-
)
62-
63-
64-
def idd_phase_axes(
65-
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False
66-
) -> UndulatorPhaseAxes:
67-
return device_instantiation(
68-
device_factory=UndulatorPhaseAxes,
69-
name="idd_phase_axes",
70-
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:",
71-
top_outer="RPQ1",
72-
top_inner="RPQ2",
73-
btm_inner="RPQ3",
74-
btm_outer="RPQ4",
75-
wait=wait_for_connection,
76-
fake=fake_with_ophyd_sim,
77-
bl_prefix=False,
78-
)
79-
80-
81-
def idd_jaw(
82-
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False
83-
) -> UndulatorJawPhase:
84-
return device_instantiation(
85-
device_factory=UndulatorJawPhase,
86-
name="idd_jaw",
87-
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:",
88-
move_pv="RPQ1",
89-
wait=wait_for_connection,
90-
fake=fake_with_ophyd_sim,
91-
bl_prefix=False,
92-
)
93-
94-
95-
def idu_gap(
96-
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False
97-
) -> UndulatorGap:
98-
return device_instantiation(
99-
device_factory=UndulatorGap,
100-
name="idu_gap",
101-
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-21:",
102-
wait=wait_for_connection,
103-
fake=fake_with_ophyd_sim,
104-
bl_prefix=False,
105-
)
106-
107-
108-
def idu_phase_axes(
109-
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False
110-
) -> UndulatorPhaseAxes:
111-
return device_instantiation(
112-
device_factory=UndulatorPhaseAxes,
113-
name="idu_phase_axes",
114-
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-21:",
115-
top_outer="RPQ1",
116-
top_inner="RPQ2",
117-
btm_inner="RPQ3",
118-
btm_outer="RPQ4",
119-
wait=wait_for_connection,
120-
fake=fake_with_ophyd_sim,
121-
bl_prefix=False,
122-
)
123-
124-
125-
def idu_jaw(
126-
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False
127-
) -> UndulatorJawPhase:
128-
return device_instantiation(
129-
device_factory=UndulatorJawPhase,
130-
name="idu_jaw",
131-
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-21:",
132-
move_pv="RPQ1",
133-
wait=wait_for_connection,
134-
fake=fake_with_ophyd_sim,
135-
bl_prefix=False,
136-
)
38+
LOOK_UPTABLE_DIR = "/dls_sw/i10/software/blueapi/scratch/i10-config/lookupTables/"
13739

13840

139-
def pgm(wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False) -> PGM:
140-
return device_instantiation(
141-
device_factory=PGM,
142-
name="pgm",
143-
prefix="-OP-PGM-01:",
41+
@device_factory()
42+
def pgm() -> PGM:
43+
"I10 Plane Grating Monochromator, it can change energy via pgm.energy.set(<energy>)"
44+
return PGM(
45+
prefix=f"{PREFIX.beamline_prefix}-OP-PGM-01:",
14446
grating=I10Grating,
14547
gratingPv="NLINES2",
146-
wait=wait_for_connection,
147-
fake=fake_with_ophyd_sim,
148-
)
149-
150-
151-
def idu_gap_phase(
152-
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False
153-
) -> I10Apple2:
154-
return device_instantiation(
155-
device_factory=I10Apple2,
156-
id_gap=idu_gap(wait_for_connection, fake_with_ophyd_sim),
157-
id_phase=idu_phase_axes(wait_for_connection, fake_with_ophyd_sim),
158-
id_jaw_phase=idu_jaw(wait_for_connection, fake_with_ophyd_sim),
159-
energy_gap_table_path=Path(
160-
LOOK_UPTABLE_DIR + "IDEnergy2GapCalibrations.csv",
161-
),
162-
energy_phase_table_path=Path(
163-
LOOK_UPTABLE_DIR + "IDEnergy2PhaseCalibrations.csv",
164-
),
165-
source=("Source", "idu"),
166-
name="idu_gap_phase",
167-
prefix="",
168-
wait=wait_for_connection,
169-
fake=fake_with_ophyd_sim,
17048
)
17149

17250

173-
def idd_gap_phase(
174-
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False
175-
) -> I10Apple2:
176-
return device_instantiation(
177-
device_factory=I10Apple2,
178-
id_gap=idd_gap(wait_for_connection, fake_with_ophyd_sim),
179-
id_phase=idd_phase_axes(wait_for_connection, fake_with_ophyd_sim),
180-
id_jaw_phase=idd_jaw(wait_for_connection, fake_with_ophyd_sim),
181-
energy_gap_table_path=Path(
182-
LOOK_UPTABLE_DIR + "IDEnergy2GapCalibrations.csv",
183-
),
184-
energy_phase_table_path=Path(
185-
LOOK_UPTABLE_DIR + "IDEnergy2PhaseCalibrations.csv",
186-
),
51+
@device_factory()
52+
def idd() -> I10Id:
53+
"""i10 downstream insertion device:
54+
id.energy.set(<energy>) to change beamline energy.
55+
id.energy.energy_offset.set(<off_set>) to change id energy offset relative to pgm.
56+
id.pol.set(<polarisation>) to change polarisation.
57+
id.laa.set(<linear polarisation angle>) to change polarisation angle, must be in LA mode.
58+
"""
59+
return I10Id(
60+
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:",
61+
pgm=pgm(),
62+
look_up_table_dir=LOOK_UPTABLE_DIR,
18763
source=("Source", "idd"),
188-
name="idd_gap_phase",
189-
prefix="",
190-
wait=wait_for_connection,
191-
fake=fake_with_ophyd_sim,
19264
)
19365

19466

195-
def idu_pol(
196-
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False
197-
) -> I10Apple2Pol:
198-
return device_instantiation(
199-
device_factory=I10Apple2Pol,
200-
prefix="",
201-
id=idu_gap_phase(wait_for_connection, fake_with_ophyd_sim),
202-
name="idu_pol",
203-
wait=wait_for_connection,
204-
fake=fake_with_ophyd_sim,
205-
)
206-
207-
208-
def idd_pol(
209-
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False
210-
) -> I10Apple2Pol:
211-
return device_instantiation(
212-
device_factory=I10Apple2Pol,
213-
prefix="",
214-
id=idd_gap_phase(wait_for_connection, fake_with_ophyd_sim),
215-
name="idd_pol",
216-
wait=wait_for_connection,
217-
fake=fake_with_ophyd_sim,
218-
)
219-
220-
221-
def idu(
222-
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False
223-
) -> I10Apple2PGM:
224-
return device_instantiation(
225-
device_factory=I10Apple2PGM,
226-
prefix="",
227-
id=idu_gap_phase(wait_for_connection, fake_with_ophyd_sim),
228-
pgm=pgm(wait_for_connection, fake_with_ophyd_sim),
229-
name="idu",
230-
wait=wait_for_connection,
231-
fake=fake_with_ophyd_sim,
232-
)
233-
234-
235-
def idd(
236-
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False
237-
) -> I10Apple2PGM:
238-
return device_instantiation(
239-
device_factory=I10Apple2PGM,
240-
prefix="",
241-
id=idd_gap_phase(wait_for_connection, fake_with_ophyd_sim),
242-
pgm=pgm(wait_for_connection, fake_with_ophyd_sim),
243-
name="idd",
244-
wait=wait_for_connection,
245-
fake=fake_with_ophyd_sim,
246-
)
247-
248-
249-
def idu_la_angle(
250-
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False
251-
) -> LinearArbitraryAngle:
252-
return device_instantiation(
253-
device_factory=LinearArbitraryAngle,
254-
prefix="",
255-
id=idu(wait_for_connection, fake_with_ophyd_sim),
256-
name="idu_la_angle",
257-
wait=wait_for_connection,
258-
fake=fake_with_ophyd_sim,
259-
)
260-
261-
262-
def idd_la_angle(
263-
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False
264-
) -> LinearArbitraryAngle:
265-
return device_instantiation(
266-
device_factory=LinearArbitraryAngle,
267-
prefix="",
268-
id=idu(wait_for_connection, fake_with_ophyd_sim),
269-
name="idd_la_angle",
270-
wait=wait_for_connection,
271-
fake=fake_with_ophyd_sim,
67+
@device_factory()
68+
def idu() -> I10Id:
69+
"""i10 upstream insertion device:
70+
id.energy.set(<energy>) to change beamline energy.
71+
id.energy.energy_offset.set(<off_set>) to change id energy offset relative to pgm.
72+
id.pol.set(<polarisation>) to change polarisation.
73+
id.laa.set(<linear polarisation angle>) to change polarisation angle, must be in LA mode.
74+
"""
75+
return I10Id(
76+
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-21:",
77+
pgm=pgm(),
78+
look_up_table_dir=LOOK_UPTABLE_DIR,
79+
source=("Source", "idu"),
27280
)
27381

27482

@@ -342,7 +150,7 @@ def pa_stage() -> PaStage:
342150

343151

344152
@device_factory()
345-
def simple_stage() -> XYZPositioner:
153+
def sample_stage() -> XYZPositioner:
346154
return XYZPositioner(prefix="ME01D-MO-CRYO-01:")
347155

348156

0 commit comments

Comments
 (0)