mx-bluesky 1.2.0__py3-none-any.whl → 1.4.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/__init__.py +8 -3
- mx_bluesky/__main__.py +12 -7
- mx_bluesky/_version.py +2 -2
- mx_bluesky/beamlines/i04/callbacks/murko_callback.py +14 -4
- mx_bluesky/beamlines/i04/redis_to_murko_forwarder.py +178 -0
- mx_bluesky/beamlines/i04/thawing_plan.py +49 -11
- mx_bluesky/beamlines/i24/serial/__init__.py +3 -0
- mx_bluesky/beamlines/i24/serial/dcid.py +143 -171
- mx_bluesky/beamlines/i24/serial/extruder/EX-gui-edm/DiamondExtruder-I24-py3v1.edl +1 -1
- mx_bluesky/beamlines/i24/serial/extruder/i24ssx_Extruder_Collect_py3v2.py +121 -110
- mx_bluesky/beamlines/i24/serial/fixed_target/FT-gui-edm/DiamondChipI24-py3v1.edl +3 -6
- mx_bluesky/beamlines/i24/serial/fixed_target/ft_utils.py +0 -1
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Collect_py3v1.py +164 -169
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Manager_py3v1.py +149 -225
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_StartUp_py3v1.py +7 -216
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_moveonclick.py +18 -17
- mx_bluesky/beamlines/i24/serial/log.py +58 -49
- mx_bluesky/beamlines/i24/serial/parameters/__init__.py +4 -0
- mx_bluesky/beamlines/i24/serial/parameters/constants.py +6 -1
- mx_bluesky/beamlines/i24/serial/parameters/experiment_parameters.py +42 -15
- mx_bluesky/beamlines/i24/serial/parameters/fixed_target/cs/cs_maker.json +3 -3
- mx_bluesky/beamlines/i24/serial/run_extruder.sh +30 -5
- mx_bluesky/beamlines/i24/serial/run_fixed_target.sh +30 -5
- mx_bluesky/beamlines/i24/serial/run_serial.py +24 -8
- mx_bluesky/beamlines/i24/serial/setup_beamline/ca.py +0 -2
- mx_bluesky/beamlines/i24/serial/setup_beamline/pv.py +2 -0
- mx_bluesky/beamlines/i24/serial/setup_beamline/setup_beamline.py +104 -82
- mx_bluesky/beamlines/i24/serial/setup_beamline/setup_detector.py +9 -20
- mx_bluesky/beamlines/i24/serial/setup_beamline/setup_zebra_plans.py +26 -28
- mx_bluesky/beamlines/i24/serial/write_nexus.py +74 -72
- mx_bluesky/common/__init__.py +0 -0
- mx_bluesky/common/device_setup_plans/read_hardware_for_setup.py +14 -0
- mx_bluesky/common/external_interaction/config_server.py +46 -0
- mx_bluesky/common/parameters/components.py +258 -0
- mx_bluesky/common/parameters/constants.py +143 -0
- mx_bluesky/common/parameters/gridscan.py +94 -0
- mx_bluesky/common/parameters/robot_load.py +16 -0
- mx_bluesky/common/plans/__init__.py +1 -0
- mx_bluesky/common/plans/do_fgs.py +121 -0
- mx_bluesky/common/utils/log.py +118 -0
- mx_bluesky/{hyperion → common/utils}/tracing.py +2 -2
- mx_bluesky/hyperion/__main__.py +13 -10
- mx_bluesky/hyperion/device_setup_plans/dcm_pitch_roll_mirror_adjuster.py +47 -52
- mx_bluesky/hyperion/device_setup_plans/read_hardware_for_setup.py +6 -12
- mx_bluesky/hyperion/device_setup_plans/setup_oav.py +6 -12
- mx_bluesky/hyperion/device_setup_plans/setup_panda.py +5 -6
- mx_bluesky/hyperion/device_setup_plans/setup_zebra.py +49 -18
- mx_bluesky/hyperion/device_setup_plans/smargon.py +9 -9
- mx_bluesky/hyperion/device_setup_plans/utils.py +2 -2
- mx_bluesky/hyperion/device_setup_plans/xbpm_feedback.py +4 -4
- mx_bluesky/hyperion/exceptions.py +13 -1
- mx_bluesky/hyperion/experiment_plans/__init__.py +4 -0
- mx_bluesky/hyperion/experiment_plans/change_aperture_then_move_plan.py +83 -0
- mx_bluesky/hyperion/experiment_plans/common/xrc_result.py +47 -0
- mx_bluesky/hyperion/experiment_plans/experiment_registry.py +9 -9
- mx_bluesky/hyperion/experiment_plans/flyscan_xray_centre_plan.py +147 -169
- mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py +48 -22
- mx_bluesky/hyperion/experiment_plans/load_centre_collect_full_plan.py +75 -9
- mx_bluesky/hyperion/experiment_plans/oav_grid_detection_plan.py +21 -20
- mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py +9 -6
- mx_bluesky/hyperion/experiment_plans/optimise_attenuation_plan.py +2 -2
- mx_bluesky/hyperion/experiment_plans/pin_centre_then_xray_centre_plan.py +40 -21
- mx_bluesky/hyperion/experiment_plans/pin_tip_centring_plan.py +22 -22
- mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py +43 -39
- mx_bluesky/hyperion/experiment_plans/robot_load_then_centre_plan.py +69 -18
- mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py +17 -7
- mx_bluesky/hyperion/experiment_plans/set_energy_plan.py +13 -13
- mx_bluesky/hyperion/external_interaction/callbacks/__init__.py +0 -4
- mx_bluesky/hyperion/external_interaction/callbacks/__main__.py +5 -2
- mx_bluesky/hyperion/external_interaction/callbacks/common/abstract_event.py +66 -0
- mx_bluesky/hyperion/external_interaction/callbacks/common/callback_util.py +5 -0
- mx_bluesky/hyperion/external_interaction/callbacks/common/ispyb_mapping.py +1 -1
- mx_bluesky/hyperion/external_interaction/callbacks/grid_detection_callback.py +30 -25
- mx_bluesky/hyperion/external_interaction/callbacks/ispyb_callback_base.py +29 -12
- mx_bluesky/hyperion/external_interaction/callbacks/log_uid_tag_callback.py +1 -1
- mx_bluesky/hyperion/external_interaction/callbacks/robot_load/ispyb_callback.py +19 -11
- mx_bluesky/hyperion/external_interaction/callbacks/rotation/ispyb_callback.py +7 -4
- mx_bluesky/hyperion/external_interaction/callbacks/rotation/nexus_callback.py +5 -3
- mx_bluesky/hyperion/external_interaction/callbacks/sample_handling/__init__.py +0 -0
- mx_bluesky/hyperion/external_interaction/callbacks/sample_handling/sample_handling_callback.py +84 -0
- mx_bluesky/hyperion/external_interaction/callbacks/xray_centre/ispyb_callback.py +38 -27
- mx_bluesky/hyperion/external_interaction/callbacks/xray_centre/nexus_callback.py +5 -4
- mx_bluesky/hyperion/external_interaction/config_server.py +11 -28
- mx_bluesky/hyperion/external_interaction/exceptions.py +0 -9
- mx_bluesky/hyperion/external_interaction/ispyb/exp_eye_store.py +65 -15
- mx_bluesky/hyperion/external_interaction/ispyb/ispyb_store.py +1 -1
- mx_bluesky/hyperion/external_interaction/nexus/nexus_utils.py +2 -2
- mx_bluesky/hyperion/external_interaction/nexus/write_nexus.py +1 -1
- mx_bluesky/hyperion/log.py +0 -84
- mx_bluesky/hyperion/parameters/components.py +4 -251
- mx_bluesky/hyperion/parameters/constants.py +22 -119
- mx_bluesky/hyperion/parameters/gridscan.py +35 -74
- mx_bluesky/hyperion/parameters/load_centre_collect.py +16 -11
- mx_bluesky/hyperion/parameters/rotation.py +23 -10
- mx_bluesky/hyperion/utils/utils.py +17 -0
- mx_bluesky/hyperion/utils/validation.py +5 -6
- {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1.dist-info}/METADATA +36 -33
- {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1.dist-info}/RECORD +102 -89
- {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1.dist-info}/WHEEL +1 -1
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Mapping_py3v1.py +0 -161
- mx_bluesky/example.py +0 -19
- mx_bluesky/hyperion/parameters/robot_load.py +0 -16
- {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1.dist-info}/LICENSE +0 -0
- {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1.dist-info}/entry_points.txt +0 -0
- {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1.dist-info}/top_level.txt +0 -0
|
@@ -9,8 +9,6 @@ the edm screen, while on the schematics they are 0 indexed. Thus, `Soft In 1` fr
|
|
|
9
9
|
schematics corresponds to soft_in_2 in the code.
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
|
-
import logging
|
|
13
|
-
|
|
14
12
|
import bluesky.plan_stubs as bps
|
|
15
13
|
from dodal.devices.zebra import (
|
|
16
14
|
AND3,
|
|
@@ -35,6 +33,8 @@ from dodal.devices.zebra import (
|
|
|
35
33
|
Zebra,
|
|
36
34
|
)
|
|
37
35
|
|
|
36
|
+
from mx_bluesky.beamlines.i24.serial.log import SSX_LOGGER
|
|
37
|
+
|
|
38
38
|
# Detector specific outs
|
|
39
39
|
TTL_EIGER = 1
|
|
40
40
|
TTL_PILATUS = 2
|
|
@@ -48,8 +48,6 @@ SHUTTER_MODE = {
|
|
|
48
48
|
GATE_START = 1.0
|
|
49
49
|
SHUTTER_OPEN_TIME = 0.05 # For pp with long delays
|
|
50
50
|
|
|
51
|
-
logger = logging.getLogger("I24ssx.setup_zebra")
|
|
52
|
-
|
|
53
51
|
|
|
54
52
|
def get_zebra_settings_for_extruder(
|
|
55
53
|
exp_time: float,
|
|
@@ -70,29 +68,29 @@ def get_zebra_settings_for_extruder(
|
|
|
70
68
|
|
|
71
69
|
|
|
72
70
|
def arm_zebra(zebra: Zebra):
|
|
73
|
-
yield from bps.abs_set(zebra.pc.arm, ArmDemand.ARM, wait=True)
|
|
74
|
-
|
|
71
|
+
yield from bps.abs_set(zebra.pc.arm, ArmDemand.ARM, wait=True) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
72
|
+
SSX_LOGGER.info("Zebra armed.")
|
|
75
73
|
|
|
76
74
|
|
|
77
75
|
def disarm_zebra(zebra: Zebra):
|
|
78
|
-
yield from bps.abs_set(zebra.pc.arm, ArmDemand.DISARM, wait=True)
|
|
79
|
-
|
|
76
|
+
yield from bps.abs_set(zebra.pc.arm, ArmDemand.DISARM, wait=True) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
77
|
+
SSX_LOGGER.info("Zebra disarmed.")
|
|
80
78
|
|
|
81
79
|
|
|
82
80
|
def open_fast_shutter(zebra: Zebra):
|
|
83
81
|
yield from bps.abs_set(zebra.inputs.soft_in_2, SoftInState.YES, wait=True)
|
|
84
|
-
|
|
82
|
+
SSX_LOGGER.info("Fast shutter open.")
|
|
85
83
|
|
|
86
84
|
|
|
87
85
|
def close_fast_shutter(zebra: Zebra):
|
|
88
86
|
yield from bps.abs_set(zebra.inputs.soft_in_2, SoftInState.NO, wait=True)
|
|
89
|
-
|
|
87
|
+
SSX_LOGGER.info("Fast shutter closed.")
|
|
90
88
|
|
|
91
89
|
|
|
92
90
|
def set_shutter_mode(zebra: Zebra, mode: str):
|
|
93
91
|
# SOFT_IN:B0 has to be disabled for manual mode
|
|
94
92
|
yield from bps.abs_set(zebra.inputs.soft_in_1, SHUTTER_MODE[mode], wait=True)
|
|
95
|
-
|
|
93
|
+
SSX_LOGGER.info(f"Shutter mode set to {mode}.")
|
|
96
94
|
|
|
97
95
|
|
|
98
96
|
def setup_pc_sources(
|
|
@@ -124,12 +122,12 @@ def setup_zebra_for_quickshot_plan(
|
|
|
124
122
|
exp_time (float): Collection exposure time, in s.
|
|
125
123
|
num_images (float): Number of images to be collected.
|
|
126
124
|
"""
|
|
127
|
-
|
|
125
|
+
SSX_LOGGER.info("Setup ZEBRA for quickshot collection.")
|
|
128
126
|
yield from bps.abs_set(zebra.pc.arm_source, ArmSource.SOFT, group=group)
|
|
129
127
|
yield from setup_pc_sources(zebra, TrigSource.TIME, TrigSource.EXTERNAL)
|
|
130
128
|
|
|
131
129
|
gate_width = exp_time * num_images + 0.5
|
|
132
|
-
|
|
130
|
+
SSX_LOGGER.info(f"Gate start set to {GATE_START}, with width {gate_width}.")
|
|
133
131
|
yield from bps.abs_set(zebra.pc.gate_start, GATE_START, group=group)
|
|
134
132
|
yield from bps.abs_set(zebra.pc.gate_width, gate_width, group=group)
|
|
135
133
|
|
|
@@ -138,7 +136,7 @@ def setup_zebra_for_quickshot_plan(
|
|
|
138
136
|
|
|
139
137
|
if wait:
|
|
140
138
|
yield from bps.wait(group)
|
|
141
|
-
|
|
139
|
+
SSX_LOGGER.info("Finished setting up zebra.")
|
|
142
140
|
|
|
143
141
|
|
|
144
142
|
def set_logic_gates_for_porto_triggering(
|
|
@@ -204,7 +202,7 @@ def setup_zebra_for_extruder_with_pump_probe_plan(
|
|
|
204
202
|
pulse1_delay (float, optional): Delay to start pulse1 (the laser control) after \
|
|
205
203
|
gate start. Defaults to 0.0.
|
|
206
204
|
"""
|
|
207
|
-
|
|
205
|
+
SSX_LOGGER.info("Setup ZEBRA for pump probe extruder collection.")
|
|
208
206
|
|
|
209
207
|
yield from set_shutter_mode(zebra, "manual")
|
|
210
208
|
|
|
@@ -226,7 +224,7 @@ def setup_zebra_for_extruder_with_pump_probe_plan(
|
|
|
226
224
|
gate_width, gate_step = get_zebra_settings_for_extruder(
|
|
227
225
|
exp_time, pump_exp, pump_delay
|
|
228
226
|
)
|
|
229
|
-
|
|
227
|
+
SSX_LOGGER.info(
|
|
230
228
|
f"""
|
|
231
229
|
Gate start set to {GATE_START}, with calculated width {gate_width}
|
|
232
230
|
and step {gate_step}.
|
|
@@ -241,13 +239,13 @@ def setup_zebra_for_extruder_with_pump_probe_plan(
|
|
|
241
239
|
# Settings for extruder pump probe:
|
|
242
240
|
# PULSE1_DLY is the start (0 usually), PULSE1_WID is the laser dwell set on edm
|
|
243
241
|
# PULSE2_DLY is the laser delay set on edm, PULSE2_WID is the exposure time
|
|
244
|
-
|
|
242
|
+
SSX_LOGGER.info(
|
|
245
243
|
f"Pulse1 starting at {pulse1_delay} with width set to laser dwell {pump_exp}."
|
|
246
244
|
)
|
|
247
245
|
yield from bps.abs_set(zebra.output.pulse_1.input, PC_GATE, group=group)
|
|
248
246
|
yield from bps.abs_set(zebra.output.pulse_1.delay, pulse1_delay, group=group)
|
|
249
247
|
yield from bps.abs_set(zebra.output.pulse_1.width, pump_exp, group=group)
|
|
250
|
-
|
|
248
|
+
SSX_LOGGER.info(
|
|
251
249
|
f"""
|
|
252
250
|
Pulse2 starting at laser delay {pump_delay} with width set to \
|
|
253
251
|
exposure time {exp_time}.
|
|
@@ -259,7 +257,7 @@ def setup_zebra_for_extruder_with_pump_probe_plan(
|
|
|
259
257
|
|
|
260
258
|
if wait:
|
|
261
259
|
yield from bps.wait(group)
|
|
262
|
-
|
|
260
|
+
SSX_LOGGER.info("Finished setting up zebra.")
|
|
263
261
|
|
|
264
262
|
|
|
265
263
|
def setup_zebra_for_fastchip_plan(
|
|
@@ -302,7 +300,7 @@ def setup_zebra_for_fastchip_plan(
|
|
|
302
300
|
start_time_offset (float): Delay on the start of the position compare. \
|
|
303
301
|
Defaults to 0.0 (standard chip collection).
|
|
304
302
|
"""
|
|
305
|
-
|
|
303
|
+
SSX_LOGGER.info("Setup ZEBRA for a fixed target collection.")
|
|
306
304
|
|
|
307
305
|
yield from set_shutter_mode(zebra, "manual")
|
|
308
306
|
|
|
@@ -341,7 +339,7 @@ def setup_zebra_for_fastchip_plan(
|
|
|
341
339
|
|
|
342
340
|
if wait:
|
|
343
341
|
yield from bps.wait(group)
|
|
344
|
-
|
|
342
|
+
SSX_LOGGER.info("Finished setting up zebra.")
|
|
345
343
|
|
|
346
344
|
|
|
347
345
|
def open_fast_shutter_at_each_position_plan(
|
|
@@ -371,10 +369,10 @@ def open_fast_shutter_at_each_position_plan(
|
|
|
371
369
|
num_exposures (int): Number of times data is collected in each aperture.
|
|
372
370
|
exposure_time (float): Exposure time for each shot.
|
|
373
371
|
"""
|
|
374
|
-
|
|
372
|
+
SSX_LOGGER.info(
|
|
375
373
|
"ZEBRA setup for fastchip collection with long delays between exposures."
|
|
376
374
|
)
|
|
377
|
-
|
|
375
|
+
SSX_LOGGER.debug("Controlling the fast shutter on PULSE2.")
|
|
378
376
|
# Output panel pulse_2 settings
|
|
379
377
|
yield from bps.abs_set(zebra.output.pulse_2.input, PC_GATE, group=group)
|
|
380
378
|
yield from bps.abs_set(zebra.output.pulse_2.delay, 0.0, group=group)
|
|
@@ -386,7 +384,7 @@ def open_fast_shutter_at_each_position_plan(
|
|
|
386
384
|
|
|
387
385
|
if wait:
|
|
388
386
|
yield from bps.wait(group=group)
|
|
389
|
-
|
|
387
|
+
SSX_LOGGER.debug("Finished setting up for long delays.")
|
|
390
388
|
|
|
391
389
|
|
|
392
390
|
def reset_pc_gate_and_pulse(zebra: Zebra, group: str = "reset_pc"):
|
|
@@ -444,16 +442,16 @@ def zebra_return_to_normal_plan(
|
|
|
444
442
|
|
|
445
443
|
if wait:
|
|
446
444
|
yield from bps.wait(group)
|
|
447
|
-
|
|
445
|
+
SSX_LOGGER.info("Zebra settings back to normal.")
|
|
448
446
|
|
|
449
447
|
|
|
450
448
|
def reset_zebra_when_collection_done_plan(zebra: Zebra):
|
|
451
449
|
"""
|
|
452
450
|
End of collection zebra operations: close fast shutter, disarm and reset settings.
|
|
453
451
|
"""
|
|
454
|
-
|
|
452
|
+
SSX_LOGGER.debug("Close the fast shutter.")
|
|
455
453
|
yield from close_fast_shutter(zebra)
|
|
456
|
-
|
|
454
|
+
SSX_LOGGER.debug("Disarm the zebra.")
|
|
457
455
|
yield from disarm_zebra(zebra)
|
|
458
|
-
|
|
456
|
+
SSX_LOGGER.debug("Set zebra back to normal.")
|
|
459
457
|
yield from zebra_return_to_normal_plan(zebra, wait=True)
|
|
@@ -1,105 +1,107 @@
|
|
|
1
|
-
import logging
|
|
2
1
|
import os
|
|
3
2
|
import pathlib
|
|
4
3
|
import pprint
|
|
5
4
|
import time
|
|
6
5
|
from datetime import datetime
|
|
7
|
-
from typing import Literal
|
|
8
6
|
|
|
9
7
|
import requests
|
|
10
8
|
|
|
11
9
|
from mx_bluesky.beamlines.i24.serial.fixed_target.ft_utils import ChipType, MappingType
|
|
10
|
+
from mx_bluesky.beamlines.i24.serial.log import SSX_LOGGER
|
|
12
11
|
from mx_bluesky.beamlines.i24.serial.parameters import (
|
|
13
12
|
ExtruderParameters,
|
|
14
13
|
FixedTargetParameters,
|
|
15
14
|
)
|
|
16
|
-
from mx_bluesky.beamlines.i24.serial.setup_beamline import Eiger, caget
|
|
17
|
-
|
|
18
|
-
logger = logging.getLogger("I24ssx.nexus_writer")
|
|
15
|
+
from mx_bluesky.beamlines.i24.serial.setup_beamline import Eiger, caget
|
|
19
16
|
|
|
20
17
|
|
|
21
18
|
def call_nexgen(
|
|
22
19
|
chip_prog_dict: dict | None,
|
|
23
|
-
start_time: datetime,
|
|
24
20
|
parameters: ExtruderParameters | FixedTargetParameters,
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
wavelength_in_a: float,
|
|
22
|
+
beam_center_in_pix: tuple[float, float],
|
|
23
|
+
start_time: datetime | None = None,
|
|
27
24
|
):
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
"""Call the nexus writer by sending a request to nexgen-server.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
chip_prog_dict (dict | None): Dictionary containing most of the information \
|
|
29
|
+
passed to the program runner for the collection. Only used for fixed target.
|
|
30
|
+
start_time
|
|
31
|
+
parameters (SerialAndLaserExperiment): Collection parameters.
|
|
32
|
+
wavelength_in_a (float): Wavelength, in A.
|
|
33
|
+
beam_center_in_pix (list[float]): Beam center position on detector, in pixels.
|
|
34
|
+
start_time (datetime, optional): Collection start time.
|
|
35
|
+
|
|
36
|
+
Raises:
|
|
37
|
+
ValueError: For a wrong experiment type passed (either unknwon or not matched \
|
|
38
|
+
to parameter model).
|
|
30
39
|
|
|
40
|
+
"""
|
|
31
41
|
current_chip_map = None
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
match parameters:
|
|
43
|
+
case FixedTargetParameters():
|
|
44
|
+
if not (
|
|
45
|
+
parameters.map_type == MappingType.NoMap
|
|
46
|
+
or parameters.chip.chip_type == ChipType.Custom
|
|
47
|
+
):
|
|
48
|
+
# NOTE Nexgen server is still on nexgen v0.7.2 (fully working for ssx)
|
|
49
|
+
# Will need to be updated, for correctness sake map needs to be None.
|
|
50
|
+
current_chip_map = (
|
|
51
|
+
"/dls_sw/i24/scripts/fastchips/litemaps/currentchip.map"
|
|
52
|
+
)
|
|
53
|
+
pump_status = bool(parameters.pump_repeat)
|
|
54
|
+
total_numb_imgs = parameters.total_num_images
|
|
55
|
+
case ExtruderParameters():
|
|
56
|
+
total_numb_imgs = parameters.num_images
|
|
57
|
+
pump_status = parameters.pump_status
|
|
48
58
|
|
|
49
|
-
filename_prefix =
|
|
50
|
-
meta_h5 =
|
|
51
|
-
pathlib.Path(parameters.visit)
|
|
52
|
-
/ parameters.directory
|
|
53
|
-
/ f"{filename_prefix}_meta.h5"
|
|
54
|
-
)
|
|
59
|
+
filename_prefix = parameters.filename
|
|
60
|
+
meta_h5 = parameters.visit / parameters.directory / f"{filename_prefix}_meta.h5"
|
|
55
61
|
t0 = time.time()
|
|
56
62
|
max_wait = 60 # seconds
|
|
57
|
-
|
|
63
|
+
SSX_LOGGER.info(f"Watching for {meta_h5}")
|
|
58
64
|
while time.time() - t0 < max_wait:
|
|
59
65
|
if meta_h5.exists():
|
|
60
|
-
|
|
66
|
+
SSX_LOGGER.info(f"Found {meta_h5} after {time.time() - t0:.1f} seconds")
|
|
61
67
|
time.sleep(5)
|
|
62
68
|
break
|
|
63
|
-
|
|
69
|
+
SSX_LOGGER.debug(f"Waiting for {meta_h5}")
|
|
64
70
|
time.sleep(1)
|
|
65
71
|
if not meta_h5.exists():
|
|
66
|
-
|
|
67
|
-
return
|
|
68
|
-
|
|
69
|
-
transmission = (float(caget(Eiger.pv.transmission)),)
|
|
72
|
+
SSX_LOGGER.warning(f"Giving up waiting for {meta_h5} after {max_wait} seconds")
|
|
73
|
+
return
|
|
70
74
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
)
|
|
75
|
+
bit_depth = int(caget(Eiger.pv.bit_depth))
|
|
76
|
+
SSX_LOGGER.debug(
|
|
77
|
+
f"Call to nexgen server with the following chip definition: \n{chip_prog_dict}"
|
|
78
|
+
)
|
|
76
79
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
access_token = pathlib.Path("/scratch/ssx_nexgen.key").read_text().strip()
|
|
81
|
+
url = "https://ssx-nexgen.diamond.ac.uk/ssx_eiger/write"
|
|
82
|
+
headers = {"Authorization": f"Bearer {access_token}"}
|
|
80
83
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return False
|
|
84
|
+
payload = {
|
|
85
|
+
"beamline": "i24",
|
|
86
|
+
"beam_center": beam_center_in_pix,
|
|
87
|
+
"chipmap": current_chip_map,
|
|
88
|
+
"chip_info": chip_prog_dict,
|
|
89
|
+
"det_dist": parameters.detector_distance_mm,
|
|
90
|
+
"exp_time": parameters.exposure_time_s,
|
|
91
|
+
"expt_type": parameters.nexgen_experiment_type,
|
|
92
|
+
"filename": filename_prefix,
|
|
93
|
+
"num_imgs": total_numb_imgs,
|
|
94
|
+
"pump_status": pump_status,
|
|
95
|
+
"pump_exp": parameters.laser_dwell_s,
|
|
96
|
+
"pump_delay": parameters.laser_delay_s,
|
|
97
|
+
"transmission": parameters.transmission,
|
|
98
|
+
"visitpath": os.fspath(meta_h5.parent),
|
|
99
|
+
"wavelength": wavelength_in_a,
|
|
100
|
+
"bit_depth": bit_depth,
|
|
101
|
+
"start_time": start_time,
|
|
102
|
+
}
|
|
103
|
+
SSX_LOGGER.info(f"Sending POST request to {url} with payload:")
|
|
104
|
+
SSX_LOGGER.info(pprint.pformat(payload))
|
|
105
|
+
response = requests.post(url, headers=headers, json=payload)
|
|
106
|
+
response.raise_for_status()
|
|
107
|
+
SSX_LOGGER.info(f"Response: {response.text} (status code: {response.status_code})")
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import bluesky.plan_stubs as bps
|
|
2
|
+
from dodal.devices.eiger import EigerDetector
|
|
3
|
+
|
|
4
|
+
from mx_bluesky.common.parameters.constants import DocDescriptorNames
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def read_hardware_for_zocalo(detector: EigerDetector):
|
|
8
|
+
""" "
|
|
9
|
+
If the RunEngine is subscribed to the ZocaloCallback, this plan will also trigger zocalo.
|
|
10
|
+
A bluesky run must be open to use this plan
|
|
11
|
+
"""
|
|
12
|
+
yield from bps.create(name=DocDescriptorNames.ZOCALO_HW_READ)
|
|
13
|
+
yield from bps.read(detector.odin.file_writer.id) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
14
|
+
yield from bps.save()
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from functools import cache
|
|
3
|
+
|
|
4
|
+
from daq_config_server.client import ConfigServer
|
|
5
|
+
from pydantic import BaseModel, Field, model_validator
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class FeatureFlags(BaseModel, ABC):
|
|
9
|
+
"""Abstract class to use ConfigServer to toggle features for an experiment
|
|
10
|
+
|
|
11
|
+
A module wanting to use FeatureFlags should inherit this class, add boolean features
|
|
12
|
+
as attributes, and implement a get_config_server method, which returns a cached creation of
|
|
13
|
+
ConfigServer. See HyperionFeatureFlags for an example
|
|
14
|
+
|
|
15
|
+
Values supplied upon class instantiation will always take priority over the config server. If connection to the server cannot
|
|
16
|
+
be made AND values were not supplied, attributes will use their default values
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
# Feature values supplied at construction will override values from the config server
|
|
20
|
+
overriden_features: dict = Field(default_factory=dict, exclude=True)
|
|
21
|
+
|
|
22
|
+
@staticmethod
|
|
23
|
+
@cache
|
|
24
|
+
@abstractmethod
|
|
25
|
+
def get_config_server() -> ConfigServer: ...
|
|
26
|
+
|
|
27
|
+
@model_validator(mode="before")
|
|
28
|
+
@classmethod
|
|
29
|
+
def mark_overridden_features(cls, values):
|
|
30
|
+
assert isinstance(values, dict)
|
|
31
|
+
values["overriden_features"] = values.copy()
|
|
32
|
+
return values
|
|
33
|
+
|
|
34
|
+
def _get_flags(self):
|
|
35
|
+
flags = type(self).get_config_server().best_effort_get_all_feature_flags()
|
|
36
|
+
return {f: flags[f] for f in flags if f in self.model_fields.keys()}
|
|
37
|
+
|
|
38
|
+
def update_self_from_server(self):
|
|
39
|
+
"""Used to update the feature flags from the server during a plan. Where there are flags which were explicitly set from externally supplied parameters, these values will be used instead."""
|
|
40
|
+
for flag, value in self._get_flags().items():
|
|
41
|
+
updated_value = (
|
|
42
|
+
value
|
|
43
|
+
if flag not in self.overriden_features.keys()
|
|
44
|
+
else self.overriden_features[flag]
|
|
45
|
+
)
|
|
46
|
+
setattr(self, flag, updated_value)
|