|
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 | +""" |
2 | 8 |
|
3 | | -from dodal.common.beamlines.beamline_utils import device_factory, device_instantiation |
| 9 | +from dodal.common.beamlines.beamline_utils import device_factory |
4 | 10 | 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 | | -) |
10 | 11 | from dodal.devices.current_amplifiers import CurrentAmpDet |
11 | 12 | from dodal.devices.i10.diagnostics import I10Diagnostic, I10Diagnostic5ADet |
12 | 13 | from dodal.devices.i10.i10_apple2 import ( |
13 | | - I10Apple2, |
14 | | - I10Apple2PGM, |
15 | | - I10Apple2Pol, |
16 | | - LinearArbitraryAngle, |
| 14 | + I10Id, |
17 | 15 | ) |
18 | 16 | from dodal.devices.i10.i10_setting_data import I10Grating |
19 | 17 | from dodal.devices.i10.mirrors import PiezoMirror |
|
37 | 35 | PREFIX = BeamlinePrefix(BL) |
38 | 36 |
|
39 | 37 |
|
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/" |
137 | 39 |
|
138 | 40 |
|
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:", |
144 | 46 | grating=I10Grating, |
145 | 47 | 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, |
170 | 48 | ) |
171 | 49 |
|
172 | 50 |
|
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, |
187 | 63 | source=("Source", "idd"), |
188 | | - name="idd_gap_phase", |
189 | | - prefix="", |
190 | | - wait=wait_for_connection, |
191 | | - fake=fake_with_ophyd_sim, |
192 | 64 | ) |
193 | 65 |
|
194 | 66 |
|
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"), |
272 | 80 | ) |
273 | 81 |
|
274 | 82 |
|
@@ -342,7 +150,7 @@ def pa_stage() -> PaStage: |
342 | 150 |
|
343 | 151 |
|
344 | 152 | @device_factory() |
345 | | -def simple_stage() -> XYZPositioner: |
| 153 | +def sample_stage() -> XYZPositioner: |
346 | 154 | return XYZPositioner(prefix="ME01D-MO-CRYO-01:") |
347 | 155 |
|
348 | 156 |
|
|
0 commit comments