mx-bluesky 0.0.1__py3-none-any.whl → 0.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mx_bluesky/__main__.py +1 -2
- mx_bluesky/_version.py +14 -2
- mx_bluesky/example.py +4 -4
- mx_bluesky/i04/__init__.py +3 -0
- mx_bluesky/i04/callbacks/murko_callback.py +45 -0
- mx_bluesky/i04/thawing_plan.py +84 -0
- mx_bluesky/i24/serial/__init__.py +49 -0
- mx_bluesky/i24/serial/blueapi_config.yaml +12 -0
- mx_bluesky/{I24 → i24}/serial/dcid.py +53 -41
- mx_bluesky/{I24 → i24}/serial/extruder/EX-gui-edm/DetStage.edl +1 -2
- mx_bluesky/{I24 → i24}/serial/extruder/EX-gui-edm/DiamondExtruder-I24-py3v1.edl +28 -32
- mx_bluesky/{I24 → i24}/serial/extruder/EX-gui-edm/microdrop_alignment.edl +0 -1
- mx_bluesky/i24/serial/extruder/i24ssx_Extruder_Collect_py3v2.py +513 -0
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/CustomChip_py3v1.edl +1 -2
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/DetStage.edl +1 -2
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/DiamondChipI24-py3v1.edl +46 -41
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/ME14E-GeneralPurpose.edl +0 -1
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/MappingLite-oxford_py3v1.edl +10 -11
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/PMAC_Command.edl +0 -1
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/Shutter_Control.edl +0 -1
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/microdrop_alignment.edl +0 -1
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/nudgechip.edl +0 -1
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/pumpprobe-py3v1.edl +300 -119
- mx_bluesky/i24/serial/fixed_target/FT-gui-edm/short1-laser.png +0 -0
- mx_bluesky/i24/serial/fixed_target/FT-gui-edm/short2-laser.png +0 -0
- mx_bluesky/{I24 → i24}/serial/fixed_target/ft_utils.py +24 -1
- mx_bluesky/i24/serial/fixed_target/i24ssx_Chip_Collect_py3v1.py +798 -0
- mx_bluesky/{I24 → i24}/serial/fixed_target/i24ssx_Chip_Manager_py3v1.py +374 -408
- mx_bluesky/{I24 → i24}/serial/fixed_target/i24ssx_Chip_Mapping_py3v1.py +34 -40
- mx_bluesky/i24/serial/fixed_target/i24ssx_Chip_StartUp_py3v1.py +325 -0
- mx_bluesky/{I24 → i24}/serial/fixed_target/i24ssx_moveonclick.py +40 -45
- mx_bluesky/i24/serial/log.py +156 -0
- mx_bluesky/i24/serial/parameters/__init__.py +15 -0
- mx_bluesky/i24/serial/parameters/constants.py +47 -0
- mx_bluesky/i24/serial/parameters/experiment_parameters.py +124 -0
- mx_bluesky/i24/serial/parameters/fixed_target/cs/cs_maker.json +9 -0
- mx_bluesky/{I24 → i24}/serial/parameters/fixed_target/cs/motor_direction.txt +1 -1
- mx_bluesky/{I24 → i24}/serial/parameters/fixed_target/pvar_files/minichip-oxford.pvar +1 -1
- mx_bluesky/i24/serial/parameters/utils.py +40 -0
- mx_bluesky/i24/serial/run_extruder.sh +19 -0
- mx_bluesky/i24/serial/run_fixed_target.sh +22 -0
- mx_bluesky/i24/serial/run_serial.py +36 -0
- mx_bluesky/{I24 → i24}/serial/set_visit_directory.sh +6 -1
- mx_bluesky/{I24 → i24}/serial/setup_beamline/pv.py +1 -62
- mx_bluesky/{I24 → i24}/serial/setup_beamline/pv_abstract.py +6 -7
- mx_bluesky/{I24 → i24}/serial/setup_beamline/setup_beamline.py +90 -269
- mx_bluesky/{I24 → i24}/serial/setup_beamline/setup_detector.py +47 -40
- mx_bluesky/i24/serial/setup_beamline/setup_zebra_plans.py +459 -0
- mx_bluesky/i24/serial/start_blueapi.sh +28 -0
- mx_bluesky/i24/serial/write_nexus.py +102 -0
- mx_bluesky/parameters/__init__.py +31 -0
- mx_bluesky/parameters/components.py +200 -0
- {mx_bluesky-0.0.1.dist-info → mx_bluesky-0.3.1.dist-info}/METADATA +37 -26
- mx_bluesky-0.3.1.dist-info/RECORD +67 -0
- {mx_bluesky-0.0.1.dist-info → mx_bluesky-0.3.1.dist-info}/WHEEL +1 -1
- mx_bluesky-0.3.1.dist-info/entry_points.txt +4 -0
- mx_bluesky/I24/serial/extruder/i24ssx_Extruder_Collect_py3v2.py +0 -476
- mx_bluesky/I24/serial/fixed_target/FT-gui-edm/ME14E-motors.edl +0 -1874
- mx_bluesky/I24/serial/fixed_target/__init__.py +0 -0
- mx_bluesky/I24/serial/fixed_target/i24ssx_Chip_Collect_py3v1.py +0 -695
- mx_bluesky/I24/serial/fixed_target/i24ssx_Chip_StartUp_py3v1.py +0 -463
- mx_bluesky/I24/serial/log.py +0 -101
- mx_bluesky/I24/serial/parameters/__init__.py +0 -5
- mx_bluesky/I24/serial/parameters/constants.py +0 -39
- mx_bluesky/I24/serial/parameters/fixed_target/cs/cs_maker.json +0 -9
- mx_bluesky/I24/serial/parameters/fixed_target/cs/fiducial_1.txt +0 -4
- mx_bluesky/I24/serial/parameters/fixed_target/cs/fiducial_2.txt +0 -4
- mx_bluesky/I24/serial/parameters/fixed_target/litemaps/currentchip.map +0 -81
- mx_bluesky/I24/serial/parameters/fixed_target/parameters.txt +0 -13
- mx_bluesky/I24/serial/run_serial.py +0 -52
- mx_bluesky/I24/serial/write_nexus.py +0 -113
- mx_bluesky-0.0.1.dist-info/RECORD +0 -58
- mx_bluesky-0.0.1.dist-info/entry_points.txt +0 -4
- /mx_bluesky/{I24 → i24}/__init__.py +0 -0
- /mx_bluesky/{I24/serial → i24/serial/extruder}/__init__.py +0 -0
- /mx_bluesky/{I24/serial/extruder → i24/serial/fixed_target}/__init__.py +0 -0
- /mx_bluesky/{I24 → i24}/serial/parameters/fixed_target/pvar_files/oxford.pvar +0 -0
- /mx_bluesky/{I24 → i24}/serial/run_ssx.sh +0 -0
- /mx_bluesky/{I24 → i24}/serial/setup_beamline/__init__.py +0 -0
- /mx_bluesky/{I24 → i24}/serial/setup_beamline/ca.py +0 -0
- {mx_bluesky-0.0.1.dist-info → mx_bluesky-0.3.1.dist-info}/LICENSE +0 -0
- {mx_bluesky-0.0.1.dist-info → mx_bluesky-0.3.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,798 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Fixed target data collection
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
import shutil
|
|
7
|
+
import time
|
|
8
|
+
from datetime import datetime
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from time import sleep
|
|
11
|
+
|
|
12
|
+
import bluesky.plan_stubs as bps
|
|
13
|
+
import bluesky.preprocessors as bpp
|
|
14
|
+
import numpy as np
|
|
15
|
+
from blueapi.core import MsgGenerator
|
|
16
|
+
from dodal.common import inject
|
|
17
|
+
from dodal.devices.hutch_shutter import HutchShutter, ShutterDemand
|
|
18
|
+
from dodal.devices.i24.aperture import Aperture
|
|
19
|
+
from dodal.devices.i24.beamstop import Beamstop
|
|
20
|
+
from dodal.devices.i24.dcm import DCM
|
|
21
|
+
from dodal.devices.i24.dual_backlight import DualBacklight
|
|
22
|
+
from dodal.devices.i24.i24_detector_motion import DetectorMotion
|
|
23
|
+
from dodal.devices.i24.pmac import PMAC
|
|
24
|
+
from dodal.devices.zebra import Zebra
|
|
25
|
+
|
|
26
|
+
from mx_bluesky.i24.serial import log
|
|
27
|
+
from mx_bluesky.i24.serial.dcid import DCID
|
|
28
|
+
from mx_bluesky.i24.serial.fixed_target.ft_utils import (
|
|
29
|
+
ChipType,
|
|
30
|
+
MappingType,
|
|
31
|
+
PumpProbeSetting,
|
|
32
|
+
)
|
|
33
|
+
from mx_bluesky.i24.serial.parameters import (
|
|
34
|
+
ChipDescription,
|
|
35
|
+
FixedTargetParameters,
|
|
36
|
+
SSXType,
|
|
37
|
+
)
|
|
38
|
+
from mx_bluesky.i24.serial.parameters.constants import (
|
|
39
|
+
LITEMAP_PATH,
|
|
40
|
+
PARAM_FILE_NAME,
|
|
41
|
+
PARAM_FILE_PATH_FT,
|
|
42
|
+
)
|
|
43
|
+
from mx_bluesky.i24.serial.setup_beamline import caget, cagetstring, caput, pv
|
|
44
|
+
from mx_bluesky.i24.serial.setup_beamline import setup_beamline as sup
|
|
45
|
+
from mx_bluesky.i24.serial.setup_beamline.setup_zebra_plans import (
|
|
46
|
+
SHUTTER_OPEN_TIME,
|
|
47
|
+
arm_zebra,
|
|
48
|
+
close_fast_shutter,
|
|
49
|
+
open_fast_shutter,
|
|
50
|
+
open_fast_shutter_at_each_position_plan,
|
|
51
|
+
reset_zebra_when_collection_done_plan,
|
|
52
|
+
setup_zebra_for_fastchip_plan,
|
|
53
|
+
)
|
|
54
|
+
from mx_bluesky.i24.serial.write_nexus import call_nexgen
|
|
55
|
+
|
|
56
|
+
ABORTED = False
|
|
57
|
+
|
|
58
|
+
logger = logging.getLogger("I24ssx.fixed_target")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def setup_logging():
|
|
62
|
+
# Log should now change name daily.
|
|
63
|
+
logfile = time.strftime("i24fixedtarget_%d%B%y.log").lower()
|
|
64
|
+
log.config(logfile)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def calculate_collection_timeout(parameters: FixedTargetParameters) -> float:
|
|
68
|
+
"""Give an estimation of the time the plan should wait for the data collection \
|
|
69
|
+
to be finished.
|
|
70
|
+
|
|
71
|
+
For non-pump probe collections and collection with short delays, it should be \
|
|
72
|
+
enough to use the collection time plus a genereous 30s buffer.
|
|
73
|
+
For EAVA (Excite and visit again) collections instead, the laser dwell and laser \
|
|
74
|
+
delay times should be included in the calculation. For long dalays between pump \
|
|
75
|
+
and probe, the shutter opening time will also need to be taken into account.
|
|
76
|
+
For more details on the dynamics see
|
|
77
|
+
https://confluence.diamond.ac.uk/display/MXTech/Dynamics+and+fixed+targets.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
parameters (FixedTargerParameters): The collection paramelters
|
|
81
|
+
"""
|
|
82
|
+
buffer = 30
|
|
83
|
+
pump_setting = parameters.pump_repeat
|
|
84
|
+
collection_time = parameters.total_num_images * parameters.exposure_time_s
|
|
85
|
+
if pump_setting in [
|
|
86
|
+
PumpProbeSetting.NoPP,
|
|
87
|
+
PumpProbeSetting.Short1,
|
|
88
|
+
PumpProbeSetting.Short2,
|
|
89
|
+
]:
|
|
90
|
+
timeout = collection_time + buffer
|
|
91
|
+
else:
|
|
92
|
+
# EAVA: Excite and visit again
|
|
93
|
+
num_windows = parameters.total_num_images / parameters.num_exposures
|
|
94
|
+
timeout = (
|
|
95
|
+
collection_time
|
|
96
|
+
+ parameters.laser_dwell_s * num_windows # type: ignore
|
|
97
|
+
+ parameters.laser_delay_s
|
|
98
|
+
+ buffer
|
|
99
|
+
)
|
|
100
|
+
if pump_setting == PumpProbeSetting.Medium1:
|
|
101
|
+
# Long delay between pump and probe, with fast shutter opening and closing.
|
|
102
|
+
timeout = timeout + SHUTTER_OPEN_TIME
|
|
103
|
+
return timeout
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def copy_files_to_data_location(
|
|
107
|
+
dest_dir: Path | str,
|
|
108
|
+
param_path: Path = PARAM_FILE_PATH_FT,
|
|
109
|
+
map_file: Path = LITEMAP_PATH,
|
|
110
|
+
map_type: MappingType = MappingType.Lite,
|
|
111
|
+
):
|
|
112
|
+
if not isinstance(dest_dir, Path):
|
|
113
|
+
dest_dir = Path(dest_dir)
|
|
114
|
+
shutil.copy2(param_path / "parameters.txt", dest_dir / "parameters.txt")
|
|
115
|
+
if map_type == MappingType.Lite:
|
|
116
|
+
shutil.copy2(map_file / "currentchip.map", dest_dir / "currentchip.map")
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def write_userlog(
|
|
120
|
+
parameters: FixedTargetParameters,
|
|
121
|
+
filename: str,
|
|
122
|
+
transmission: float,
|
|
123
|
+
wavelength: float,
|
|
124
|
+
):
|
|
125
|
+
# Write a record of what was collected to the processing directory
|
|
126
|
+
userlog_path = Path(parameters.visit) / f"processing/{parameters.directory}"
|
|
127
|
+
userlog_fid = f"{filename}_parameters.txt"
|
|
128
|
+
logger.debug(f"Write a user log in {userlog_path}")
|
|
129
|
+
|
|
130
|
+
userlog_path.mkdir(parents=True, exist_ok=True)
|
|
131
|
+
|
|
132
|
+
text = f"""
|
|
133
|
+
Fixed Target Data Collection Parameters\n
|
|
134
|
+
Data directory \t{parameters.collection_directory.as_posix()}\n
|
|
135
|
+
Filename \t{filename}\n
|
|
136
|
+
Shots per pos \t{parameters.num_exposures}\n
|
|
137
|
+
Total N images \t{parameters.total_num_images}\n
|
|
138
|
+
Exposure time \t{parameters.exposure_time_s}\n
|
|
139
|
+
Det distance \t{parameters.detector_distance_mm}\n
|
|
140
|
+
Transmission \t{transmission}\n
|
|
141
|
+
Wavelength \t{wavelength}\n
|
|
142
|
+
Detector type \t{parameters.detector_name}\n
|
|
143
|
+
Pump status \t{parameters.pump_repeat}\n
|
|
144
|
+
Pump exp time \t{parameters.laser_dwell_s}\n
|
|
145
|
+
Pump delay \t{parameters.laser_delay_s}\n
|
|
146
|
+
"""
|
|
147
|
+
with open(userlog_path / userlog_fid, "w") as f:
|
|
148
|
+
f.write(text)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
@log.log_on_entry
|
|
152
|
+
def get_chip_prog_values(
|
|
153
|
+
parameters: FixedTargetParameters,
|
|
154
|
+
):
|
|
155
|
+
# this is where p variables for fast laser expts will be set
|
|
156
|
+
if parameters.pump_repeat in [
|
|
157
|
+
PumpProbeSetting.NoPP,
|
|
158
|
+
PumpProbeSetting.Short1,
|
|
159
|
+
PumpProbeSetting.Short2,
|
|
160
|
+
PumpProbeSetting.Medium1,
|
|
161
|
+
]:
|
|
162
|
+
pump_repeat_pvar = 0
|
|
163
|
+
elif parameters.pump_repeat == PumpProbeSetting.Repeat1:
|
|
164
|
+
pump_repeat_pvar = 1
|
|
165
|
+
elif parameters.pump_repeat == PumpProbeSetting.Repeat2:
|
|
166
|
+
pump_repeat_pvar = 2
|
|
167
|
+
elif parameters.pump_repeat == PumpProbeSetting.Repeat3:
|
|
168
|
+
pump_repeat_pvar = 3
|
|
169
|
+
elif parameters.pump_repeat == PumpProbeSetting.Repeat5:
|
|
170
|
+
pump_repeat_pvar = 5
|
|
171
|
+
elif parameters.pump_repeat == PumpProbeSetting.Repeat10:
|
|
172
|
+
pump_repeat_pvar = 10
|
|
173
|
+
else:
|
|
174
|
+
raise ValueError(f"Unknown pump_repeat, pump_repeat = {parameters.pump_repeat}")
|
|
175
|
+
|
|
176
|
+
logger.info(
|
|
177
|
+
f"Pump repeat is {str(parameters.pump_repeat)}, PVAR set to {pump_repeat_pvar}"
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
if parameters.pump_repeat == PumpProbeSetting.Short2:
|
|
181
|
+
pump_in_probe = 1
|
|
182
|
+
else:
|
|
183
|
+
pump_in_probe = 0
|
|
184
|
+
|
|
185
|
+
logger.info(f"pump_in_probe set to {pump_in_probe}")
|
|
186
|
+
|
|
187
|
+
chip_dict: dict[str, list] = {
|
|
188
|
+
"X_NUM_STEPS": [11, parameters.chip.x_num_steps],
|
|
189
|
+
"Y_NUM_STEPS": [12, parameters.chip.y_num_steps],
|
|
190
|
+
"X_STEP_SIZE": [13, parameters.chip.x_step_size],
|
|
191
|
+
"Y_STEP_SIZE": [14, parameters.chip.y_step_size],
|
|
192
|
+
"DWELL_TIME": [15, parameters.exposure_time_s],
|
|
193
|
+
"X_START": [16, 0],
|
|
194
|
+
"Y_START": [17, 0],
|
|
195
|
+
"Z_START": [18, 0],
|
|
196
|
+
"X_NUM_BLOCKS": [20, parameters.chip.x_blocks],
|
|
197
|
+
"Y_NUM_BLOCKS": [21, parameters.chip.y_blocks],
|
|
198
|
+
"X_BLOCK_SIZE": [24, parameters.chip.x_block_size],
|
|
199
|
+
"Y_BLOCK_SIZE": [25, parameters.chip.y_block_size],
|
|
200
|
+
"COLTYPE": [26, 41],
|
|
201
|
+
"N_EXPOSURES": [30, parameters.num_exposures],
|
|
202
|
+
"PUMP_REPEAT": [32, pump_repeat_pvar],
|
|
203
|
+
"LASER_DWELL": [34, parameters.laser_dwell_s],
|
|
204
|
+
"LASERTWO_DWELL": [35, parameters.pre_pump_exposure_s],
|
|
205
|
+
"LASER_DELAY": [37, parameters.laser_delay_s],
|
|
206
|
+
"PUMP_IN_PROBE": [38, pump_in_probe],
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
chip_dict["DWELL_TIME"][1] = 1000 * parameters.exposure_time_s
|
|
210
|
+
chip_dict["LASER_DWELL"][1] = (
|
|
211
|
+
1000 * parameters.laser_dwell_s if parameters.laser_dwell_s else 0
|
|
212
|
+
)
|
|
213
|
+
chip_dict["LASERTWO_DWELL"][1] = (
|
|
214
|
+
1000 * parameters.pre_pump_exposure_s if parameters.pre_pump_exposure_s else 0
|
|
215
|
+
)
|
|
216
|
+
chip_dict["LASER_DELAY"][1] = (
|
|
217
|
+
1000 * parameters.laser_delay_s if parameters.laser_delay_s else 0
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
return chip_dict
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
@log.log_on_entry
|
|
224
|
+
def load_motion_program_data(
|
|
225
|
+
pmac: PMAC,
|
|
226
|
+
motion_program_dict: dict[str, list],
|
|
227
|
+
map_type: int,
|
|
228
|
+
pump_repeat: int,
|
|
229
|
+
checker_pattern: bool,
|
|
230
|
+
):
|
|
231
|
+
logger.info("Loading motion program data for chip.")
|
|
232
|
+
logger.info(f"Pump_repeat is {PumpProbeSetting(pump_repeat)}")
|
|
233
|
+
if pump_repeat == PumpProbeSetting.NoPP:
|
|
234
|
+
if map_type == MappingType.NoMap:
|
|
235
|
+
prefix = 11
|
|
236
|
+
logger.info(f"Map type is None, setting program prefix to {prefix}")
|
|
237
|
+
elif map_type == MappingType.Lite:
|
|
238
|
+
prefix = 12
|
|
239
|
+
elif map_type == MappingType.Full:
|
|
240
|
+
prefix = 13
|
|
241
|
+
else:
|
|
242
|
+
logger.warning(f"Unknown Map Type, map_type = {map_type}")
|
|
243
|
+
return
|
|
244
|
+
elif pump_repeat in [pp.value for pp in PumpProbeSetting if pp != 0]:
|
|
245
|
+
# Pump setting chosen
|
|
246
|
+
prefix = 14
|
|
247
|
+
logger.info(f"Setting program prefix to {prefix}")
|
|
248
|
+
yield from bps.abs_set(pmac.pmac_string, "P1439=0", wait=True)
|
|
249
|
+
if checker_pattern:
|
|
250
|
+
logger.info("Checker pattern setting enabled.")
|
|
251
|
+
yield from bps.abs_set(pmac.pmac_string, "P1439=1", wait=True)
|
|
252
|
+
if pump_repeat == PumpProbeSetting.Medium1:
|
|
253
|
+
# Medium1 has time delays (Fast shutter opening time in ms)
|
|
254
|
+
yield from bps.abs_set(pmac.pmac_string, "P1441=50", wait=True)
|
|
255
|
+
else:
|
|
256
|
+
yield from bps.abs_set(pmac.pmac_string, "P1441=0", wait=True)
|
|
257
|
+
else:
|
|
258
|
+
logger.warning(f"Unknown Pump repeat, pump_repeat = {pump_repeat}")
|
|
259
|
+
return
|
|
260
|
+
|
|
261
|
+
logger.info("Set PMAC_STRING pv.")
|
|
262
|
+
for key in sorted(motion_program_dict.keys()):
|
|
263
|
+
v = motion_program_dict[key]
|
|
264
|
+
pvar_base = prefix * 100
|
|
265
|
+
pvar = pvar_base + v[0]
|
|
266
|
+
value = str(v[1])
|
|
267
|
+
s = f"P{pvar}={value}"
|
|
268
|
+
logger.info(f"{key} \t {s}")
|
|
269
|
+
yield from bps.abs_set(pmac.pmac_string, s, wait=True)
|
|
270
|
+
yield from bps.sleep(0.02)
|
|
271
|
+
yield from bps.sleep(0.2)
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
@log.log_on_entry
|
|
275
|
+
def get_prog_num(
|
|
276
|
+
chip_type: ChipType, map_type: MappingType, pump_repeat: PumpProbeSetting
|
|
277
|
+
) -> int:
|
|
278
|
+
logger.info("Get Program Number")
|
|
279
|
+
if pump_repeat == PumpProbeSetting.NoPP:
|
|
280
|
+
if chip_type in [ChipType.Oxford, ChipType.OxfordInner]:
|
|
281
|
+
logger.info(
|
|
282
|
+
f"Pump_repeat: {str(pump_repeat)} \tOxford Chip: {str(chip_type)}"
|
|
283
|
+
)
|
|
284
|
+
if map_type == MappingType.NoMap:
|
|
285
|
+
logger.info("Map type 0 = None")
|
|
286
|
+
logger.info("Program number: 11")
|
|
287
|
+
return 11
|
|
288
|
+
elif map_type == MappingType.Lite:
|
|
289
|
+
logger.info("Map type 1 = Mapping Lite")
|
|
290
|
+
logger.info("Program number: 12")
|
|
291
|
+
return 12
|
|
292
|
+
elif map_type == MappingType.Full:
|
|
293
|
+
logger.info("Map type 2 = Full Mapping")
|
|
294
|
+
logger.info("Program number: 13") # once fixed return 13
|
|
295
|
+
msg = "Mapping Type FULL is broken as of 11.09.17"
|
|
296
|
+
logger.error(msg)
|
|
297
|
+
raise ValueError(msg)
|
|
298
|
+
else:
|
|
299
|
+
logger.debug(f"Unknown Mapping Type; map_type = {map_type}")
|
|
300
|
+
return 0
|
|
301
|
+
elif chip_type == ChipType.Custom:
|
|
302
|
+
logger.info(
|
|
303
|
+
f"Pump_repeat: {str(pump_repeat)} \tCustom Chip: {str(chip_type)}"
|
|
304
|
+
)
|
|
305
|
+
logger.info("Program number: 11")
|
|
306
|
+
return 11
|
|
307
|
+
elif chip_type == ChipType.Minichip:
|
|
308
|
+
logger.info(
|
|
309
|
+
f"Pump_repeat: {str(pump_repeat)} \tMini Oxford Chip: {str(chip_type)}"
|
|
310
|
+
)
|
|
311
|
+
logger.info("Program number: 11")
|
|
312
|
+
return 11
|
|
313
|
+
else:
|
|
314
|
+
logger.debug(f"Unknown chip_type, chip_tpe = {chip_type}")
|
|
315
|
+
return 0
|
|
316
|
+
elif pump_repeat in [
|
|
317
|
+
pp.value for pp in PumpProbeSetting if pp != PumpProbeSetting.NoPP
|
|
318
|
+
]:
|
|
319
|
+
logger.info(f"Pump_repeat: {str(pump_repeat)} \t Chip Type: {str(chip_type)}")
|
|
320
|
+
logger.info("Map Type = Mapping Lite with Pump Probe")
|
|
321
|
+
logger.info("Program number: 14")
|
|
322
|
+
return 14
|
|
323
|
+
else:
|
|
324
|
+
logger.warning(f"Unknown pump_repeat, pump_repeat = {pump_repeat}")
|
|
325
|
+
return 0
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
@log.log_on_entry
|
|
329
|
+
def datasetsizei24(
|
|
330
|
+
n_exposures: int,
|
|
331
|
+
chip_params: ChipDescription,
|
|
332
|
+
map_type: MappingType,
|
|
333
|
+
) -> int:
|
|
334
|
+
# Calculates how many images will be collected based on map type and N repeats
|
|
335
|
+
logger.info("Calculate total number of images expected in data collection.")
|
|
336
|
+
|
|
337
|
+
if map_type == MappingType.NoMap:
|
|
338
|
+
if chip_params.chip_type == ChipType.Custom:
|
|
339
|
+
total_numb_imgs = chip_params.x_num_steps * chip_params.y_num_steps
|
|
340
|
+
logger.info(
|
|
341
|
+
f"Map type: None \tCustom chip \tNumber of images {total_numb_imgs}"
|
|
342
|
+
)
|
|
343
|
+
else:
|
|
344
|
+
chip_format = chip_params.chip_format[:4]
|
|
345
|
+
total_numb_imgs = int(np.prod(chip_format))
|
|
346
|
+
logger.info(
|
|
347
|
+
f"""Map type: None \tOxford chip {chip_params.chip_type} \t \
|
|
348
|
+
Number of images {total_numb_imgs}"""
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
elif map_type == MappingType.Lite:
|
|
352
|
+
logger.info(f"Using Mapping Lite on chip type {chip_params.chip_type}")
|
|
353
|
+
chip_format = chip_params.chip_format[2:4]
|
|
354
|
+
block_count = 0
|
|
355
|
+
with open(LITEMAP_PATH / "currentchip.map") as f:
|
|
356
|
+
for line in f.readlines():
|
|
357
|
+
entry = line.split()
|
|
358
|
+
if entry[2] == "1":
|
|
359
|
+
block_count += 1
|
|
360
|
+
|
|
361
|
+
logger.info(f"Block count={block_count}")
|
|
362
|
+
logger.info(f"Chip format={chip_format}")
|
|
363
|
+
|
|
364
|
+
logger.info(f"Number of exposures={n_exposures}")
|
|
365
|
+
|
|
366
|
+
total_numb_imgs = int(np.prod(chip_format) * block_count * n_exposures)
|
|
367
|
+
logger.info(f"Calculated number of images: {total_numb_imgs}")
|
|
368
|
+
|
|
369
|
+
elif map_type == MappingType.Full:
|
|
370
|
+
logger.error("Not Set Up For Full Mapping")
|
|
371
|
+
raise ValueError("The beamline is currently not set for Full Mapping.")
|
|
372
|
+
|
|
373
|
+
else:
|
|
374
|
+
logger.warning(f"Unknown Map Type, map_type = {str(map_type)}")
|
|
375
|
+
raise ValueError("Unknown map type")
|
|
376
|
+
|
|
377
|
+
logger.info("Set PV to calculated number of images.")
|
|
378
|
+
caput(pv.me14e_gp10, int(total_numb_imgs))
|
|
379
|
+
|
|
380
|
+
return int(total_numb_imgs)
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
@log.log_on_entry
|
|
384
|
+
def start_i24(
|
|
385
|
+
zebra: Zebra,
|
|
386
|
+
aperture: Aperture,
|
|
387
|
+
backlight: DualBacklight,
|
|
388
|
+
beamstop: Beamstop,
|
|
389
|
+
detector_stage: DetectorMotion,
|
|
390
|
+
shutter: HutchShutter,
|
|
391
|
+
parameters: FixedTargetParameters,
|
|
392
|
+
dcid: DCID,
|
|
393
|
+
):
|
|
394
|
+
"""Set up for I24 fixed target data collection, trigger the detector and open \
|
|
395
|
+
the hutch shutter.
|
|
396
|
+
Returns the start_time.
|
|
397
|
+
"""
|
|
398
|
+
|
|
399
|
+
logger.info("Start I24 data collection.")
|
|
400
|
+
start_time = datetime.now()
|
|
401
|
+
logger.info(f"Collection start time {start_time.ctime()}")
|
|
402
|
+
|
|
403
|
+
logger.debug("Set up beamline")
|
|
404
|
+
yield from sup.setup_beamline_for_collection_plan(
|
|
405
|
+
aperture, backlight, beamstop, wait=True
|
|
406
|
+
)
|
|
407
|
+
|
|
408
|
+
yield from sup.move_detector_stage_to_position_plan(
|
|
409
|
+
detector_stage, parameters.detector_distance_mm
|
|
410
|
+
)
|
|
411
|
+
|
|
412
|
+
logger.debug("Set up beamline DONE")
|
|
413
|
+
|
|
414
|
+
filepath = parameters.collection_directory.as_posix()
|
|
415
|
+
filename = parameters.filename
|
|
416
|
+
|
|
417
|
+
logger.debug("Acquire Region")
|
|
418
|
+
|
|
419
|
+
num_gates = parameters.total_num_images // parameters.num_exposures
|
|
420
|
+
|
|
421
|
+
logger.info(f"Total number of images: {parameters.total_num_images}")
|
|
422
|
+
logger.info(f"Number of exposures: {parameters.num_exposures}")
|
|
423
|
+
logger.info(f"Number of gates (=Total images/N exposures): {num_gates:.4f}")
|
|
424
|
+
|
|
425
|
+
if parameters.detector_name == "pilatus":
|
|
426
|
+
logger.info("Using Pilatus detector")
|
|
427
|
+
logger.info(f"Fastchip Pilatus setup: filepath {filepath}")
|
|
428
|
+
logger.info(f"Fastchip Pilatus setup: filename {filename}")
|
|
429
|
+
logger.info(
|
|
430
|
+
f"Fastchip Pilatus setup: number of images {parameters.total_num_images}"
|
|
431
|
+
)
|
|
432
|
+
logger.info(
|
|
433
|
+
f"Fastchip Pilatus setup: exposure time {parameters.exposure_time_s}"
|
|
434
|
+
)
|
|
435
|
+
|
|
436
|
+
sup.pilatus(
|
|
437
|
+
"fastchip",
|
|
438
|
+
[
|
|
439
|
+
filepath,
|
|
440
|
+
filename,
|
|
441
|
+
parameters.total_num_images,
|
|
442
|
+
parameters.exposure_time_s,
|
|
443
|
+
],
|
|
444
|
+
)
|
|
445
|
+
|
|
446
|
+
# DCID process depends on detector PVs being set up already
|
|
447
|
+
logger.debug("Start DCID process")
|
|
448
|
+
dcid.generate_dcid(
|
|
449
|
+
visit=parameters.visit.name,
|
|
450
|
+
image_dir=filepath,
|
|
451
|
+
start_time=start_time,
|
|
452
|
+
num_images=parameters.total_num_images,
|
|
453
|
+
exposure_time=parameters.exposure_time_s,
|
|
454
|
+
shots_per_position=parameters.num_exposures,
|
|
455
|
+
pump_exposure_time=parameters.laser_dwell_s,
|
|
456
|
+
pump_delay=parameters.laser_delay_s or 0,
|
|
457
|
+
pump_status=parameters.pump_repeat.value,
|
|
458
|
+
)
|
|
459
|
+
|
|
460
|
+
logger.debug("Arm Pilatus. Arm Zebra.")
|
|
461
|
+
shutter_time_offset = SHUTTER_OPEN_TIME if PumpProbeSetting.Medium1 else 0.0
|
|
462
|
+
yield from setup_zebra_for_fastchip_plan(
|
|
463
|
+
zebra,
|
|
464
|
+
parameters.detector_name,
|
|
465
|
+
num_gates,
|
|
466
|
+
parameters.num_exposures,
|
|
467
|
+
parameters.exposure_time_s,
|
|
468
|
+
shutter_time_offset,
|
|
469
|
+
wait=True,
|
|
470
|
+
)
|
|
471
|
+
if parameters.pump_repeat == PumpProbeSetting.Medium1:
|
|
472
|
+
yield from open_fast_shutter_at_each_position_plan(
|
|
473
|
+
zebra, parameters.num_exposures, parameters.exposure_time_s
|
|
474
|
+
)
|
|
475
|
+
caput(pv.pilat_acquire, "1") # Arm pilatus
|
|
476
|
+
yield from arm_zebra(zebra)
|
|
477
|
+
caput(pv.pilat_filename, filename)
|
|
478
|
+
time.sleep(1.5)
|
|
479
|
+
|
|
480
|
+
elif parameters.detector_name == "eiger":
|
|
481
|
+
logger.info("Using Eiger detector")
|
|
482
|
+
|
|
483
|
+
logger.warning(
|
|
484
|
+
"""TEMPORARY HACK!
|
|
485
|
+
Running a Single image pilatus data collection to create directory."""
|
|
486
|
+
)
|
|
487
|
+
num_imgs = 1
|
|
488
|
+
sup.pilatus(
|
|
489
|
+
"quickshot-internaltrig",
|
|
490
|
+
[filepath, filename, num_imgs, parameters.exposure_time_s],
|
|
491
|
+
)
|
|
492
|
+
logger.debug("Sleep 2s waiting for pilatus to arm")
|
|
493
|
+
sleep(2)
|
|
494
|
+
sleep(0.5)
|
|
495
|
+
caput(pv.pilat_acquire, "0") # Disarm pilatus
|
|
496
|
+
sleep(0.5)
|
|
497
|
+
caput(pv.pilat_acquire, "1") # Arm pilatus
|
|
498
|
+
logger.debug("Pilatus data collection DONE")
|
|
499
|
+
sup.pilatus("return to normal", None)
|
|
500
|
+
logger.info("Pilatus back to normal. Single image pilatus data collection DONE")
|
|
501
|
+
|
|
502
|
+
logger.info(f"Triggered Eiger setup: filepath {filepath}")
|
|
503
|
+
logger.info(f"Triggered Eiger setup: filename {filename}")
|
|
504
|
+
logger.info(
|
|
505
|
+
f"Triggered Eiger setup: number of images {parameters.total_num_images}"
|
|
506
|
+
)
|
|
507
|
+
logger.info(
|
|
508
|
+
f"Triggered Eiger setup: exposure time {parameters.exposure_time_s}"
|
|
509
|
+
)
|
|
510
|
+
|
|
511
|
+
sup.eiger(
|
|
512
|
+
"triggered",
|
|
513
|
+
[
|
|
514
|
+
filepath,
|
|
515
|
+
filename,
|
|
516
|
+
parameters.total_num_images,
|
|
517
|
+
parameters.exposure_time_s,
|
|
518
|
+
],
|
|
519
|
+
)
|
|
520
|
+
|
|
521
|
+
# DCID process depends on detector PVs being set up already
|
|
522
|
+
logger.debug("Start DCID process")
|
|
523
|
+
dcid.generate_dcid(
|
|
524
|
+
visit=parameters.visit.name,
|
|
525
|
+
image_dir=filepath,
|
|
526
|
+
start_time=start_time,
|
|
527
|
+
num_images=parameters.total_num_images,
|
|
528
|
+
exposure_time=parameters.exposure_time_s,
|
|
529
|
+
shots_per_position=parameters.num_exposures,
|
|
530
|
+
pump_exposure_time=parameters.laser_dwell_s,
|
|
531
|
+
pump_delay=parameters.laser_delay_s or 0,
|
|
532
|
+
pump_status=parameters.pump_repeat.value,
|
|
533
|
+
)
|
|
534
|
+
|
|
535
|
+
logger.debug("Arm Zebra.")
|
|
536
|
+
shutter_time_offset = SHUTTER_OPEN_TIME if PumpProbeSetting.Medium1 else 0.0
|
|
537
|
+
yield from setup_zebra_for_fastchip_plan(
|
|
538
|
+
zebra,
|
|
539
|
+
parameters.detector_name,
|
|
540
|
+
num_gates,
|
|
541
|
+
parameters.num_exposures,
|
|
542
|
+
parameters.exposure_time_s,
|
|
543
|
+
shutter_time_offset,
|
|
544
|
+
wait=True,
|
|
545
|
+
)
|
|
546
|
+
if parameters.pump_repeat == PumpProbeSetting.Medium1:
|
|
547
|
+
yield from open_fast_shutter_at_each_position_plan(
|
|
548
|
+
zebra, parameters.num_exposures, parameters.exposure_time_s
|
|
549
|
+
)
|
|
550
|
+
yield from arm_zebra(zebra)
|
|
551
|
+
|
|
552
|
+
time.sleep(1.5)
|
|
553
|
+
|
|
554
|
+
else:
|
|
555
|
+
msg = f"Unknown Detector Type, det_type = {parameters.detector_name}"
|
|
556
|
+
logger.error(msg)
|
|
557
|
+
raise ValueError(msg)
|
|
558
|
+
|
|
559
|
+
# Open the hutch shutter
|
|
560
|
+
yield from bps.abs_set(shutter, ShutterDemand.OPEN, wait=True)
|
|
561
|
+
|
|
562
|
+
return start_time
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
@log.log_on_entry
|
|
566
|
+
def finish_i24(
|
|
567
|
+
zebra: Zebra,
|
|
568
|
+
pmac: PMAC,
|
|
569
|
+
shutter: HutchShutter,
|
|
570
|
+
dcm: DCM,
|
|
571
|
+
parameters: FixedTargetParameters,
|
|
572
|
+
):
|
|
573
|
+
logger.info(f"Finish I24 data collection with {parameters.detector_name} detector.")
|
|
574
|
+
|
|
575
|
+
complete_filename: str
|
|
576
|
+
transmission = float(caget(pv.pilat_filtertrasm))
|
|
577
|
+
wavelength = yield from bps.rd(dcm.wavelength_in_a)
|
|
578
|
+
|
|
579
|
+
if parameters.detector_name == "pilatus":
|
|
580
|
+
logger.debug("Finish I24 Pilatus")
|
|
581
|
+
complete_filename = f"{parameters.filename}_{caget(pv.pilat_filenum)}"
|
|
582
|
+
yield from reset_zebra_when_collection_done_plan(zebra)
|
|
583
|
+
sup.pilatus("return-to-normal", None)
|
|
584
|
+
sleep(0.2)
|
|
585
|
+
elif parameters.detector_name == "eiger":
|
|
586
|
+
logger.debug("Finish I24 Eiger")
|
|
587
|
+
yield from reset_zebra_when_collection_done_plan(zebra)
|
|
588
|
+
sup.eiger("return-to-normal", None)
|
|
589
|
+
complete_filename = cagetstring(pv.eiger_ODfilenameRBV) # type: ignore
|
|
590
|
+
else:
|
|
591
|
+
raise ValueError(f"{parameters.detector_name=} unrecognised")
|
|
592
|
+
|
|
593
|
+
# Detector independent moves
|
|
594
|
+
logger.info("Move chip back to home position by setting PMAC_STRING pv.")
|
|
595
|
+
yield from bps.trigger(pmac.to_xyz_zero)
|
|
596
|
+
logger.info("Closing shutter")
|
|
597
|
+
yield from bps.abs_set(shutter, ShutterDemand.CLOSE, wait=True)
|
|
598
|
+
|
|
599
|
+
# Write a record of what was collected to the processing directory
|
|
600
|
+
write_userlog(parameters, complete_filename, transmission, wavelength)
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
def run_aborted_plan(pmac: PMAC, dcid: DCID):
|
|
604
|
+
"""Plan to send pmac_strings to tell the PMAC when a collection has been aborted, \
|
|
605
|
+
either by pressing the Abort button or because of a timeout, and to reset the \
|
|
606
|
+
P variable.
|
|
607
|
+
"""
|
|
608
|
+
logger.warning("Data Collection Aborted")
|
|
609
|
+
yield from bps.abs_set(pmac.pmac_string, "A", wait=True)
|
|
610
|
+
yield from bps.sleep(1.0)
|
|
611
|
+
yield from bps.abs_set(pmac.pmac_string, "P2401=0", wait=True)
|
|
612
|
+
|
|
613
|
+
end_time = datetime.now()
|
|
614
|
+
dcid.collection_complete(end_time, aborted=True)
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
@log.log_on_entry
|
|
618
|
+
def main_fixed_target_plan(
|
|
619
|
+
zebra: Zebra,
|
|
620
|
+
pmac: PMAC,
|
|
621
|
+
aperture: Aperture,
|
|
622
|
+
backlight: DualBacklight,
|
|
623
|
+
beamstop: Beamstop,
|
|
624
|
+
detector_stage: DetectorMotion,
|
|
625
|
+
shutter: HutchShutter,
|
|
626
|
+
dcm: DCM,
|
|
627
|
+
parameters: FixedTargetParameters,
|
|
628
|
+
dcid: DCID,
|
|
629
|
+
) -> MsgGenerator:
|
|
630
|
+
logger.info("Running a chip collection on I24")
|
|
631
|
+
|
|
632
|
+
logger.info("Getting Program Dictionary")
|
|
633
|
+
|
|
634
|
+
# If alignment type is Oxford inner it is still an Oxford type chip
|
|
635
|
+
if parameters.chip.chip_type == ChipType.OxfordInner:
|
|
636
|
+
logger.debug("Change chip type Oxford Inner to Oxford.")
|
|
637
|
+
parameters.chip.chip_type = ChipType.Oxford
|
|
638
|
+
|
|
639
|
+
chip_prog_dict = get_chip_prog_values(parameters)
|
|
640
|
+
logger.info("Loading Motion Program Data")
|
|
641
|
+
yield from load_motion_program_data(
|
|
642
|
+
pmac,
|
|
643
|
+
chip_prog_dict,
|
|
644
|
+
parameters.map_type,
|
|
645
|
+
parameters.pump_repeat,
|
|
646
|
+
parameters.checker_pattern,
|
|
647
|
+
)
|
|
648
|
+
|
|
649
|
+
parameters.total_num_images = datasetsizei24(
|
|
650
|
+
parameters.num_exposures, parameters.chip, parameters.map_type
|
|
651
|
+
)
|
|
652
|
+
|
|
653
|
+
start_time = yield from start_i24(
|
|
654
|
+
zebra, aperture, backlight, beamstop, detector_stage, shutter, parameters, dcid
|
|
655
|
+
)
|
|
656
|
+
|
|
657
|
+
logger.info("Moving to Start")
|
|
658
|
+
yield from bps.trigger(pmac.to_xyz_zero)
|
|
659
|
+
sleep(2.0)
|
|
660
|
+
|
|
661
|
+
prog_num = get_prog_num(
|
|
662
|
+
parameters.chip.chip_type, parameters.map_type, parameters.pump_repeat
|
|
663
|
+
)
|
|
664
|
+
|
|
665
|
+
# Now ready for data collection. Open fast shutter (zebra gate)
|
|
666
|
+
logger.info("Opening fast shutter.")
|
|
667
|
+
yield from open_fast_shutter(zebra)
|
|
668
|
+
|
|
669
|
+
# Kick off the StartOfCollect script
|
|
670
|
+
logger.debug("Notify DCID of the start of the collection.")
|
|
671
|
+
dcid.notify_start()
|
|
672
|
+
|
|
673
|
+
wavelength = yield from bps.rd(dcm.wavelength_in_a)
|
|
674
|
+
if parameters.detector_name == "eiger":
|
|
675
|
+
logger.debug("Start nexus writing service.")
|
|
676
|
+
call_nexgen(
|
|
677
|
+
chip_prog_dict,
|
|
678
|
+
start_time,
|
|
679
|
+
parameters,
|
|
680
|
+
wavelength,
|
|
681
|
+
)
|
|
682
|
+
|
|
683
|
+
timeout_time = calculate_collection_timeout(parameters)
|
|
684
|
+
logger.info(f"Run PMAC with program number {prog_num}")
|
|
685
|
+
yield from bps.abs_set(pmac.run_program, prog_num, timeout_time, wait=True)
|
|
686
|
+
|
|
687
|
+
logger.debug("Collection completed without errors.")
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
@log.log_on_entry
|
|
691
|
+
def collection_complete_plan(
|
|
692
|
+
dcid: DCID, collection_directory: Path, map_type: MappingType
|
|
693
|
+
) -> MsgGenerator:
|
|
694
|
+
end_time = datetime.now()
|
|
695
|
+
logger.debug(f"Collection end time {end_time}")
|
|
696
|
+
dcid.collection_complete(end_time, aborted=False)
|
|
697
|
+
|
|
698
|
+
# Copy parameter file and eventual chip map to collection directory
|
|
699
|
+
copy_files_to_data_location(collection_directory, map_type=map_type)
|
|
700
|
+
yield from bps.null()
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
@log.log_on_entry
|
|
704
|
+
def tidy_up_after_collection_plan(
|
|
705
|
+
zebra: Zebra,
|
|
706
|
+
pmac: PMAC,
|
|
707
|
+
shutter: HutchShutter,
|
|
708
|
+
dcm: DCM,
|
|
709
|
+
parameters: FixedTargetParameters,
|
|
710
|
+
dcid: DCID,
|
|
711
|
+
) -> MsgGenerator:
|
|
712
|
+
"""A plan to be run to tidy things up at the end af a fixed target collection, \
|
|
713
|
+
both successful or aborted.
|
|
714
|
+
"""
|
|
715
|
+
logger.info("Closing fast shutter")
|
|
716
|
+
yield from close_fast_shutter(zebra)
|
|
717
|
+
sleep(2.0)
|
|
718
|
+
|
|
719
|
+
# This probably should go in main then
|
|
720
|
+
if parameters.detector_name == "pilatus":
|
|
721
|
+
logger.debug("Pilatus Acquire STOP")
|
|
722
|
+
caput(pv.pilat_acquire, 0)
|
|
723
|
+
elif parameters.detector_name == "eiger":
|
|
724
|
+
logger.debug("Eiger Acquire STOP")
|
|
725
|
+
caput(pv.eiger_acquire, 0)
|
|
726
|
+
caput(pv.eiger_ODcapture, "Done")
|
|
727
|
+
sleep(0.5)
|
|
728
|
+
|
|
729
|
+
yield from finish_i24(zebra, pmac, shutter, dcm, parameters)
|
|
730
|
+
|
|
731
|
+
logger.debug("Notify DCID of end of collection.")
|
|
732
|
+
dcid.notify_end()
|
|
733
|
+
|
|
734
|
+
logger.debug("Quick summary of settings")
|
|
735
|
+
logger.debug(f"Chip name = {parameters.filename} sub_dir = {parameters.directory}")
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
def run_fixed_target_plan(
|
|
739
|
+
zebra: Zebra = inject("zebra"),
|
|
740
|
+
pmac: PMAC = inject("pmac"),
|
|
741
|
+
aperture: Aperture = inject("aperture"),
|
|
742
|
+
backlight: DualBacklight = inject("backlight"),
|
|
743
|
+
beamstop: Beamstop = inject("beamstop"),
|
|
744
|
+
detector_stage: DetectorMotion = inject("detector_motion"),
|
|
745
|
+
shutter: HutchShutter = inject("shutter"),
|
|
746
|
+
dcm: DCM = inject("dcm"),
|
|
747
|
+
) -> MsgGenerator:
|
|
748
|
+
setup_logging()
|
|
749
|
+
|
|
750
|
+
logger.info("Getting parameters from file.")
|
|
751
|
+
parameters = FixedTargetParameters.from_file(PARAM_FILE_PATH_FT / PARAM_FILE_NAME)
|
|
752
|
+
|
|
753
|
+
log_msg = f"""
|
|
754
|
+
Parameters for I24 serial collection: \n
|
|
755
|
+
Chip name is {parameters.filename}
|
|
756
|
+
visit = {parameters.visit}
|
|
757
|
+
sub_dir = {parameters.directory}
|
|
758
|
+
n_exposures = {parameters.num_exposures}
|
|
759
|
+
chip_type = {str(parameters.chip.chip_type)}
|
|
760
|
+
map_type = {str(parameters.map_type)}
|
|
761
|
+
dcdetdist = {parameters.detector_distance_mm}
|
|
762
|
+
exptime = {parameters.exposure_time_s}
|
|
763
|
+
det_type = {parameters.detector_name}
|
|
764
|
+
pump_repeat = {str(parameters.pump_repeat)}
|
|
765
|
+
pumpexptime = {parameters.laser_dwell_s}
|
|
766
|
+
pumpdelay = {parameters.laser_delay_s}
|
|
767
|
+
prepumpexptime = {parameters.pre_pump_exposure_s}
|
|
768
|
+
"""
|
|
769
|
+
logger.info(log_msg)
|
|
770
|
+
|
|
771
|
+
# DCID instance - do not create yet
|
|
772
|
+
dcid = DCID(
|
|
773
|
+
emit_errors=False,
|
|
774
|
+
ssx_type=SSXType.FIXED,
|
|
775
|
+
detector=parameters.detector_name,
|
|
776
|
+
)
|
|
777
|
+
|
|
778
|
+
yield from bpp.contingency_wrapper(
|
|
779
|
+
main_fixed_target_plan(
|
|
780
|
+
zebra,
|
|
781
|
+
pmac,
|
|
782
|
+
aperture,
|
|
783
|
+
backlight,
|
|
784
|
+
beamstop,
|
|
785
|
+
detector_stage,
|
|
786
|
+
shutter,
|
|
787
|
+
dcm,
|
|
788
|
+
parameters,
|
|
789
|
+
dcid,
|
|
790
|
+
),
|
|
791
|
+
except_plan=lambda e: (yield from run_aborted_plan(pmac, dcid)),
|
|
792
|
+
final_plan=lambda: (
|
|
793
|
+
yield from tidy_up_after_collection_plan(
|
|
794
|
+
zebra, pmac, shutter, dcm, parameters, dcid
|
|
795
|
+
)
|
|
796
|
+
),
|
|
797
|
+
auto_raise=False,
|
|
798
|
+
)
|