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
|
@@ -4,9 +4,7 @@ This version changed to python3 March2020 by RLO
|
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
import json
|
|
7
|
-
import logging
|
|
8
7
|
import re
|
|
9
|
-
import shutil
|
|
10
8
|
import sys
|
|
11
9
|
import time
|
|
12
10
|
from pathlib import Path
|
|
@@ -15,30 +13,23 @@ from time import sleep
|
|
|
15
13
|
|
|
16
14
|
import bluesky.plan_stubs as bps
|
|
17
15
|
import numpy as np
|
|
18
|
-
from
|
|
19
|
-
from dodal.beamlines import i24
|
|
16
|
+
from bluesky.utils import MsgGenerator
|
|
20
17
|
from dodal.common import inject
|
|
18
|
+
from dodal.devices.attenuator import ReadOnlyAttenuator
|
|
21
19
|
from dodal.devices.i24.beamstop import Beamstop, BeamstopPositions
|
|
22
20
|
from dodal.devices.i24.dual_backlight import BacklightPositions, DualBacklight
|
|
23
21
|
from dodal.devices.i24.i24_detector_motion import DetectorMotion
|
|
24
22
|
from dodal.devices.i24.pmac import PMAC, EncReset, LaserSettings
|
|
25
23
|
|
|
26
|
-
from mx_bluesky.beamlines.i24.serial import
|
|
27
|
-
from mx_bluesky.beamlines.i24.serial.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
i24ssx_Chip_StartUp_py3v1 as startup,
|
|
32
|
-
)
|
|
33
|
-
from mx_bluesky.beamlines.i24.serial.fixed_target.ft_utils import (
|
|
34
|
-
ChipType,
|
|
35
|
-
Fiducials,
|
|
36
|
-
MappingType,
|
|
24
|
+
from mx_bluesky.beamlines.i24.serial.fixed_target.ft_utils import ChipType, Fiducials
|
|
25
|
+
from mx_bluesky.beamlines.i24.serial.log import (
|
|
26
|
+
SSX_LOGGER,
|
|
27
|
+
_read_visit_directory_from_file,
|
|
28
|
+
log_on_entry,
|
|
37
29
|
)
|
|
38
30
|
from mx_bluesky.beamlines.i24.serial.parameters import get_chip_format
|
|
39
31
|
from mx_bluesky.beamlines.i24.serial.parameters.constants import (
|
|
40
32
|
CS_FILES_PATH,
|
|
41
|
-
FULLMAP_PATH,
|
|
42
33
|
LITEMAP_PATH,
|
|
43
34
|
PARAM_FILE_NAME,
|
|
44
35
|
PARAM_FILE_PATH_FT,
|
|
@@ -49,8 +40,6 @@ from mx_bluesky.beamlines.i24.serial.setup_beamline.setup_detector import (
|
|
|
49
40
|
get_detector_type,
|
|
50
41
|
)
|
|
51
42
|
|
|
52
|
-
logger = logging.getLogger("I24ssx.chip_manager")
|
|
53
|
-
|
|
54
43
|
# An approximation of the chip size for the move during fiducials alignment.
|
|
55
44
|
CHIP_MOVES = {
|
|
56
45
|
ChipType.Oxford: 25.40,
|
|
@@ -65,22 +54,15 @@ PUMP_REPEAT_PV = pv.me14e_gp4
|
|
|
65
54
|
MAP_FILEPATH_PV = pv.me14e_gp5
|
|
66
55
|
|
|
67
56
|
|
|
68
|
-
|
|
69
|
-
# Log should now change name daily.
|
|
70
|
-
logfile = time.strftime("i24fixedtarget_%d%B%y.log").lower()
|
|
71
|
-
log.config(logfile)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
@log.log_on_entry
|
|
57
|
+
@log_on_entry
|
|
75
58
|
def initialise_stages(
|
|
76
59
|
pmac: PMAC = inject("pmac"),
|
|
77
60
|
) -> MsgGenerator:
|
|
78
61
|
"""Initialise the portable stages PVs, usually used only once right after setting \
|
|
79
62
|
up the stages either after use at different facility.
|
|
80
63
|
"""
|
|
81
|
-
setup_logging()
|
|
82
64
|
group = "initialise_stages"
|
|
83
|
-
|
|
65
|
+
SSX_LOGGER.info("Setting velocity, acceleration and limits for stages")
|
|
84
66
|
|
|
85
67
|
yield from bps.abs_set(pmac.x.velocity, 20, group=group)
|
|
86
68
|
yield from bps.abs_set(pmac.y.velocity, 20, group=group)
|
|
@@ -110,26 +92,32 @@ def initialise_stages(
|
|
|
110
92
|
caput(pv.pilat_cbftemplate, 0)
|
|
111
93
|
|
|
112
94
|
sleep(0.1)
|
|
113
|
-
|
|
95
|
+
SSX_LOGGER.info("Clearing General Purpose PVs 1-120")
|
|
114
96
|
for i in range(4, 120):
|
|
97
|
+
if i == 100:
|
|
98
|
+
# Do not clear visit PV
|
|
99
|
+
continue
|
|
115
100
|
pvar = "ME14E-MO-IOC-01:GP" + str(i)
|
|
116
101
|
caput(pvar, 0)
|
|
117
102
|
sys.stdout.write(".")
|
|
118
103
|
sys.stdout.flush()
|
|
119
104
|
|
|
120
|
-
|
|
105
|
+
SSX_LOGGER.info("Initialisation of the stages complete")
|
|
121
106
|
yield from bps.wait(group=group)
|
|
122
107
|
|
|
123
108
|
|
|
124
|
-
@
|
|
109
|
+
@log_on_entry
|
|
125
110
|
def write_parameter_file(
|
|
126
111
|
detector_stage: DetectorMotion,
|
|
112
|
+
attenuator: ReadOnlyAttenuator,
|
|
127
113
|
) -> MsgGenerator:
|
|
128
114
|
param_path: Path = PARAM_FILE_PATH_FT
|
|
129
115
|
# Create directory if it doesn't yet exist.
|
|
130
116
|
param_path.mkdir(parents=True, exist_ok=True)
|
|
131
117
|
|
|
132
|
-
|
|
118
|
+
SSX_LOGGER.info(
|
|
119
|
+
f"Writing Parameter File: {(param_path / PARAM_FILE_NAME).as_posix()}"
|
|
120
|
+
)
|
|
133
121
|
|
|
134
122
|
filename = caget(pv.me14e_chip_name)
|
|
135
123
|
det_type = yield from get_detector_type(detector_stage)
|
|
@@ -146,24 +134,27 @@ def write_parameter_file(
|
|
|
146
134
|
# Note for future reference. Appending underscore causes more hassle and
|
|
147
135
|
# high probability of users accidentally overwriting data. Use a dash
|
|
148
136
|
filename = filename + "-"
|
|
149
|
-
|
|
137
|
+
SSX_LOGGER.debug(
|
|
150
138
|
f"Requested filename ends in a number. Appended dash: {filename}"
|
|
151
139
|
)
|
|
152
140
|
|
|
141
|
+
transmission = yield from bps.rd(attenuator.actual_transmission)
|
|
142
|
+
|
|
153
143
|
params_dict = {
|
|
154
|
-
"visit":
|
|
144
|
+
"visit": _read_visit_directory_from_file().as_posix(), # noqa
|
|
155
145
|
"directory": caget(pv.me14e_filepath),
|
|
156
146
|
"filename": filename,
|
|
157
147
|
"exposure_time_s": caget(pv.me14e_exptime),
|
|
158
148
|
"detector_distance_mm": caget(pv.me14e_dcdetdist),
|
|
159
149
|
"detector_name": str(det_type),
|
|
160
150
|
"num_exposures": int(caget(NUM_EXPOSURES_PV)),
|
|
161
|
-
"
|
|
151
|
+
"transmission": transmission,
|
|
152
|
+
"chip": chip_params.model_dump(),
|
|
162
153
|
"map_type": map_type,
|
|
163
154
|
"pump_repeat": pump_repeat,
|
|
164
155
|
"checker_pattern": bool(caget(pv.me14e_gp111)),
|
|
165
|
-
"laser_dwell_s": float(caget(pv.me14e_gp103)) if pump_repeat != 0 else
|
|
166
|
-
"laser_delay_s": float(caget(pv.me14e_gp110)) if pump_repeat != 0 else
|
|
156
|
+
"laser_dwell_s": float(caget(pv.me14e_gp103)) if pump_repeat != 0 else 0.0,
|
|
157
|
+
"laser_delay_s": float(caget(pv.me14e_gp110)) if pump_repeat != 0 else 0.0,
|
|
167
158
|
"pre_pump_exposure_s": float(caget(pv.me14e_gp109))
|
|
168
159
|
if pump_repeat != 0
|
|
169
160
|
else None,
|
|
@@ -172,14 +163,9 @@ def write_parameter_file(
|
|
|
172
163
|
with open(param_path / PARAM_FILE_NAME, "w") as f:
|
|
173
164
|
json.dump(params_dict, f, indent=4)
|
|
174
165
|
|
|
175
|
-
|
|
176
|
-
|
|
166
|
+
SSX_LOGGER.info("Information written to file \n")
|
|
167
|
+
SSX_LOGGER.info(pformat(params_dict))
|
|
177
168
|
|
|
178
|
-
if map_type == MappingType.Full:
|
|
179
|
-
# This step creates some header files (.addr, .spec), containing the parameters,
|
|
180
|
-
# that are only needed when full mapping is in use.
|
|
181
|
-
logger.info("Full mapping in use. Running start up now.")
|
|
182
|
-
startup.run()
|
|
183
169
|
yield from bps.null()
|
|
184
170
|
|
|
185
171
|
|
|
@@ -207,13 +193,12 @@ def scrape_pvar_file(fid: str, pvar_dir: Path = PVAR_FILE_PATH):
|
|
|
207
193
|
return block_start_list
|
|
208
194
|
|
|
209
195
|
|
|
210
|
-
@
|
|
196
|
+
@log_on_entry
|
|
211
197
|
def define_current_chip(
|
|
212
198
|
chipid: str = "oxford",
|
|
213
199
|
pmac: PMAC = inject("pmac"),
|
|
214
200
|
) -> MsgGenerator:
|
|
215
|
-
|
|
216
|
-
logger.debug("Run load stock map for just the first block")
|
|
201
|
+
SSX_LOGGER.debug("Run load stock map for just the first block")
|
|
217
202
|
yield from load_stock_map("Just The First Block")
|
|
218
203
|
"""
|
|
219
204
|
Not sure what this is for:
|
|
@@ -221,43 +206,41 @@ def define_current_chip(
|
|
|
221
206
|
caput(pv.me14e_gp2, 1)
|
|
222
207
|
"""
|
|
223
208
|
chip_type = int(caget(CHIPTYPE_PV))
|
|
224
|
-
|
|
209
|
+
SSX_LOGGER.info(f"Chip type:{chip_type} Chipid:{chipid}")
|
|
225
210
|
if chipid == "oxford":
|
|
226
211
|
caput(CHIPTYPE_PV, 0)
|
|
227
212
|
|
|
228
213
|
with open(PVAR_FILE_PATH / f"{chipid}.pvar") as f:
|
|
229
|
-
|
|
214
|
+
SSX_LOGGER.info(f"Opening {chipid}.pvar")
|
|
230
215
|
for line in f.readlines():
|
|
231
216
|
if line.startswith("#"):
|
|
232
217
|
continue
|
|
233
218
|
line_from_file = line.rstrip("\n")
|
|
234
|
-
|
|
219
|
+
SSX_LOGGER.info(f"{line_from_file}")
|
|
235
220
|
yield from bps.abs_set(pmac.pmac_string, line_from_file)
|
|
236
221
|
|
|
237
222
|
|
|
238
|
-
@
|
|
223
|
+
@log_on_entry
|
|
239
224
|
def save_screen_map() -> MsgGenerator:
|
|
240
|
-
setup_logging()
|
|
241
225
|
litemap_path: Path = LITEMAP_PATH
|
|
242
226
|
litemap_path.mkdir(parents=True, exist_ok=True)
|
|
243
227
|
|
|
244
|
-
|
|
228
|
+
SSX_LOGGER.info(f"Saving {litemap_path.as_posix()} currentchip.map")
|
|
245
229
|
with open(litemap_path / "currentchip.map", "w") as f:
|
|
246
|
-
|
|
230
|
+
SSX_LOGGER.debug("Printing only blocks with block_val == 1")
|
|
247
231
|
for x in range(1, 82):
|
|
248
|
-
block_str = "ME14E-MO-IOC-01:GP
|
|
232
|
+
block_str = f"ME14E-MO-IOC-01:GP{x + 10:d}"
|
|
249
233
|
block_val = int(caget(block_str))
|
|
250
234
|
if block_val == 1:
|
|
251
|
-
|
|
252
|
-
line = "
|
|
235
|
+
SSX_LOGGER.info(f"{block_str} {block_val:d}")
|
|
236
|
+
line = f"{x:02d}status P3{x:02d}1 \t{block_val}\n"
|
|
253
237
|
f.write(line)
|
|
254
238
|
yield from bps.null()
|
|
255
239
|
|
|
256
240
|
|
|
257
|
-
@
|
|
241
|
+
@log_on_entry
|
|
258
242
|
def upload_parameters(pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
259
|
-
|
|
260
|
-
logger.info("Uploading Parameters for Oxford Chip to the GeoBrick")
|
|
243
|
+
SSX_LOGGER.info("Uploading Parameters for Oxford Chip to the GeoBrick")
|
|
261
244
|
caput(CHIPTYPE_PV, 0)
|
|
262
245
|
width = 8
|
|
263
246
|
|
|
@@ -266,8 +249,8 @@ def upload_parameters(pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
|
266
249
|
raise FileNotFoundError(f"The file {map_file} has not yet been created")
|
|
267
250
|
|
|
268
251
|
with open(map_file) as f:
|
|
269
|
-
|
|
270
|
-
|
|
252
|
+
SSX_LOGGER.info(f"Chipid {ChipType.Oxford}")
|
|
253
|
+
SSX_LOGGER.info(f"width {width}")
|
|
271
254
|
x = 1
|
|
272
255
|
for line in f.readlines()[: width**2]:
|
|
273
256
|
cols = line.split()
|
|
@@ -288,41 +271,16 @@ def upload_parameters(pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
|
288
271
|
yield from bps.abs_set(pmac.pmac_string, s, wait=True)
|
|
289
272
|
sleep(0.02)
|
|
290
273
|
|
|
291
|
-
|
|
292
|
-
|
|
274
|
+
SSX_LOGGER.warning("Automatic Setting Mapping Type to Lite has been disabled")
|
|
275
|
+
SSX_LOGGER.debug("Upload parameters done.")
|
|
293
276
|
yield from bps.null()
|
|
294
277
|
|
|
295
278
|
|
|
296
|
-
@
|
|
297
|
-
def upload_full(pmac: PMAC | None = None) -> MsgGenerator:
|
|
298
|
-
setup_logging()
|
|
299
|
-
if not pmac:
|
|
300
|
-
pmac = i24.pmac()
|
|
301
|
-
|
|
302
|
-
map_file: Path = FULLMAP_PATH / "currentchip.full"
|
|
303
|
-
if not map_file.exists():
|
|
304
|
-
raise FileNotFoundError(f"The file {map_file} has not yet been created")
|
|
305
|
-
with open(map_file) as fh:
|
|
306
|
-
f = fh.readlines()
|
|
307
|
-
|
|
308
|
-
for _i in range(len(f) // 2):
|
|
309
|
-
pmac_list = []
|
|
310
|
-
for _j in range(2):
|
|
311
|
-
pmac_list.append(f.pop(0).rstrip("\n"))
|
|
312
|
-
writeline = " ".join(pmac_list)
|
|
313
|
-
logger.info(f"{writeline}")
|
|
314
|
-
yield from bps.abs_set(pmac.pmac_string, writeline, wait=True)
|
|
315
|
-
yield from bps.sleep(0.02)
|
|
316
|
-
logger.debug("Upload fullmap done")
|
|
317
|
-
yield from bps.null()
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
@log.log_on_entry
|
|
279
|
+
@log_on_entry
|
|
321
280
|
def load_stock_map(map_choice: str = "clear") -> MsgGenerator:
|
|
322
281
|
# TODO See https://github.com/DiamondLightSource/mx_bluesky/issues/122
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
logger.debug("Please wait, adjusting lite map")
|
|
282
|
+
SSX_LOGGER.info("Adjusting Lite Map EDM Screen")
|
|
283
|
+
SSX_LOGGER.debug("Please wait, adjusting lite map")
|
|
326
284
|
#
|
|
327
285
|
r33 = [19, 18, 17, 26, 31, 32, 33, 24, 25]
|
|
328
286
|
r55 = [9, 10, 11, 12, 13, 16, 27, 30, 41, 40, 39, 38, 37, 34, 23, 20] + r33
|
|
@@ -505,25 +463,24 @@ def load_stock_map(map_choice: str = "clear") -> MsgGenerator:
|
|
|
505
463
|
map_dict["half1"] = half1
|
|
506
464
|
map_dict["half2"] = half2
|
|
507
465
|
|
|
508
|
-
|
|
466
|
+
SSX_LOGGER.info("Clearing GP 10-74") # Actually 11-44
|
|
509
467
|
for i in range(1, 65):
|
|
510
468
|
pvar = "ME14E-MO-IOC-01:GP" + str(i + 10)
|
|
511
469
|
caput(pvar, 0)
|
|
512
470
|
sys.stdout.write(".")
|
|
513
471
|
sys.stdout.flush()
|
|
514
|
-
|
|
515
|
-
|
|
472
|
+
SSX_LOGGER.info("Map cleared")
|
|
473
|
+
SSX_LOGGER.info(f"Loading Map Choice {map_choice}")
|
|
516
474
|
for i in map_dict[map_choice]:
|
|
517
475
|
pvar = "ME14E-MO-IOC-01:GP" + str(i + 10)
|
|
518
476
|
caput(pvar, 1)
|
|
519
|
-
|
|
477
|
+
SSX_LOGGER.debug("Load stock map done.")
|
|
520
478
|
yield from bps.null()
|
|
521
479
|
|
|
522
480
|
|
|
523
|
-
@
|
|
481
|
+
@log_on_entry
|
|
524
482
|
def load_lite_map() -> MsgGenerator:
|
|
525
|
-
|
|
526
|
-
logger.debug("Run load stock map with 'clear' setting.")
|
|
483
|
+
SSX_LOGGER.debug("Run load stock map with 'clear' setting.")
|
|
527
484
|
yield from load_stock_map("clear")
|
|
528
485
|
# fmt: off
|
|
529
486
|
# Oxford_block_dict is wrong (columns and rows need to flip) added in script below to generate it automatically however kept this for backwards compatiability/reference
|
|
@@ -540,7 +497,7 @@ def load_lite_map() -> MsgGenerator:
|
|
|
540
497
|
# fmt: on
|
|
541
498
|
chip_type = int(caget(CHIPTYPE_PV))
|
|
542
499
|
if chip_type in [ChipType.Oxford, ChipType.OxfordInner]:
|
|
543
|
-
|
|
500
|
+
SSX_LOGGER.info("Oxford Block Order")
|
|
544
501
|
rows = ["A", "B", "C", "D", "E", "F", "G", "H"]
|
|
545
502
|
columns = list(range(1, 10))
|
|
546
503
|
btn_names = {}
|
|
@@ -559,20 +516,20 @@ def load_lite_map() -> MsgGenerator:
|
|
|
559
516
|
elif flip is True:
|
|
560
517
|
z = 8 - (y + 1)
|
|
561
518
|
else:
|
|
562
|
-
|
|
519
|
+
SSX_LOGGER.warning("Problem in Chip Grid Creation")
|
|
563
520
|
break
|
|
564
521
|
button_name = str(row) + str(column)
|
|
565
522
|
lab_num = x * 8 + z
|
|
566
|
-
label = "
|
|
523
|
+
label = f"{lab_num + 1:02d}"
|
|
567
524
|
btn_names[button_name] = label
|
|
568
525
|
block_dict = btn_names
|
|
569
526
|
else:
|
|
570
527
|
raise ValueError(f"{chip_type=} unrecognised")
|
|
571
528
|
|
|
572
529
|
litemap_fid = f"{caget(MAP_FILEPATH_PV)}.lite"
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
530
|
+
SSX_LOGGER.info("Please wait, loading LITE map")
|
|
531
|
+
SSX_LOGGER.debug("Loading Lite Map")
|
|
532
|
+
SSX_LOGGER.info("Opening %s" % (LITEMAP_PATH / litemap_fid))
|
|
576
533
|
with open(LITEMAP_PATH / litemap_fid) as fh:
|
|
577
534
|
f = fh.readlines()
|
|
578
535
|
for line in f:
|
|
@@ -581,57 +538,37 @@ def load_lite_map() -> MsgGenerator:
|
|
|
581
538
|
yesno = entry[1]
|
|
582
539
|
block_num = block_dict[block_name]
|
|
583
540
|
pvar = "ME14E-MO-IOC-01:GP" + str(int(block_num) + 10)
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
yield from bps.null()
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
@log.log_on_entry
|
|
590
|
-
def load_full_map() -> MsgGenerator:
|
|
591
|
-
setup_logging()
|
|
592
|
-
params = startup.read_parameter_file()
|
|
593
|
-
|
|
594
|
-
fullmap_fid = FULLMAP_PATH / f"{caget(MAP_FILEPATH_PV)}.spec"
|
|
595
|
-
logger.info(f"Opening {fullmap_fid}")
|
|
596
|
-
mapping.plot_file(fullmap_fid, params.chip.chip_type.value)
|
|
597
|
-
mapping.convert_chip_to_hex(fullmap_fid, params.chip.chip_type.value)
|
|
598
|
-
shutil.copy2(fullmap_fid.with_suffix(".full"), FULLMAP_PATH / "currentchip.full")
|
|
599
|
-
logger.info(
|
|
600
|
-
"Copying {} to {}".format(
|
|
601
|
-
fullmap_fid.with_suffix(".full"), FULLMAP_PATH / "currentchip.full"
|
|
602
|
-
)
|
|
603
|
-
)
|
|
604
|
-
logger.debug("Load full map done")
|
|
541
|
+
SSX_LOGGER.info(f"Block: {block_name} \tScanned: {yesno} \tPVAR: {pvar}")
|
|
542
|
+
SSX_LOGGER.debug("Load lite map done")
|
|
605
543
|
yield from bps.null()
|
|
606
544
|
|
|
607
545
|
|
|
608
|
-
@
|
|
546
|
+
@log_on_entry
|
|
609
547
|
def moveto(place: str = "origin", pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
610
|
-
|
|
611
|
-
logger.info(f"Move to: {place}")
|
|
548
|
+
SSX_LOGGER.info(f"Move to: {place}")
|
|
612
549
|
if place == Fiducials.zero:
|
|
613
|
-
|
|
550
|
+
SSX_LOGGER.info("Chip aspecific move.")
|
|
614
551
|
yield from bps.trigger(pmac.to_xyz_zero)
|
|
615
552
|
return
|
|
616
553
|
|
|
617
554
|
chip_type = ChipType(int(caget(CHIPTYPE_PV)))
|
|
618
|
-
|
|
555
|
+
SSX_LOGGER.info(f"Chip type is {chip_type}")
|
|
619
556
|
if chip_type not in list(ChipType):
|
|
620
|
-
|
|
557
|
+
SSX_LOGGER.warning("Unknown chip_type move")
|
|
621
558
|
return
|
|
622
559
|
|
|
623
|
-
|
|
560
|
+
SSX_LOGGER.info(f"{str(chip_type)} Move")
|
|
624
561
|
chip_move = CHIP_MOVES[chip_type]
|
|
625
562
|
|
|
626
563
|
if place == Fiducials.origin:
|
|
627
|
-
yield from bps.mv(pmac.x, 0.0, pmac.y, 0.0)
|
|
564
|
+
yield from bps.mv(pmac.x, 0.0, pmac.y, 0.0) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
628
565
|
if place == Fiducials.fid1:
|
|
629
|
-
yield from bps.mv(pmac.x, chip_move, pmac.y, 0.0)
|
|
566
|
+
yield from bps.mv(pmac.x, chip_move, pmac.y, 0.0) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
630
567
|
if place == Fiducials.fid2:
|
|
631
|
-
yield from bps.mv(pmac.x, 0.0, pmac.y, chip_move)
|
|
568
|
+
yield from bps.mv(pmac.x, 0.0, pmac.y, chip_move) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
632
569
|
|
|
633
570
|
|
|
634
|
-
@
|
|
571
|
+
@log_on_entry
|
|
635
572
|
def moveto_preset(
|
|
636
573
|
place: str,
|
|
637
574
|
pmac: PMAC = inject("pmac"),
|
|
@@ -639,15 +576,13 @@ def moveto_preset(
|
|
|
639
576
|
backlight: DualBacklight = inject("backlight"),
|
|
640
577
|
det_stage: DetectorMotion = inject("detector_motion"),
|
|
641
578
|
) -> MsgGenerator:
|
|
642
|
-
setup_logging()
|
|
643
|
-
|
|
644
579
|
# Non Chip Specific Move
|
|
645
580
|
if place == "zero":
|
|
646
|
-
|
|
581
|
+
SSX_LOGGER.info(f"Moving to {place}")
|
|
647
582
|
yield from bps.trigger(pmac.to_xyz_zero)
|
|
648
583
|
|
|
649
584
|
elif place == "load_position":
|
|
650
|
-
|
|
585
|
+
SSX_LOGGER.info("load position")
|
|
651
586
|
yield from bps.abs_set(
|
|
652
587
|
beamstop.pos_select, BeamstopPositions.ROBOT, group=place
|
|
653
588
|
)
|
|
@@ -656,9 +591,9 @@ def moveto_preset(
|
|
|
656
591
|
yield from bps.wait(group=place)
|
|
657
592
|
|
|
658
593
|
elif place == "collect_position":
|
|
659
|
-
|
|
594
|
+
SSX_LOGGER.info("collect position")
|
|
660
595
|
caput(pv.me14e_filter, 20)
|
|
661
|
-
yield from bps.mv(pmac.x, 0.0, pmac.y, 0.0, pmac.z, 0.0)
|
|
596
|
+
yield from bps.mv(pmac.x, 0.0, pmac.y, 0.0, pmac.z, 0.0) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
662
597
|
yield from bps.abs_set(
|
|
663
598
|
beamstop.pos_select, BeamstopPositions.DATA_COLLECTION, group=place
|
|
664
599
|
)
|
|
@@ -666,53 +601,52 @@ def moveto_preset(
|
|
|
666
601
|
yield from bps.wait(group=place)
|
|
667
602
|
|
|
668
603
|
elif place == "microdrop_position":
|
|
669
|
-
|
|
670
|
-
yield from bps.mv(pmac.x, 6.0, pmac.y, -7.8, pmac.z, 0.0)
|
|
604
|
+
SSX_LOGGER.info("microdrop align position")
|
|
605
|
+
yield from bps.mv(pmac.x, 6.0, pmac.y, -7.8, pmac.z, 0.0) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
671
606
|
|
|
672
607
|
|
|
673
|
-
@
|
|
608
|
+
@log_on_entry
|
|
674
609
|
def laser_control(laser_setting: str, pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
675
|
-
|
|
676
|
-
logger.info(f"Move to: {laser_setting}")
|
|
610
|
+
SSX_LOGGER.info(f"Move to: {laser_setting}")
|
|
677
611
|
if laser_setting == "laser1on": # these are in laser edm
|
|
678
|
-
|
|
612
|
+
SSX_LOGGER.info("Laser 1 /BNC2 shutter is open")
|
|
679
613
|
# Use M712 = 0 if triggering on falling edge. M712 =1 if on rising edge
|
|
680
614
|
# Be sure to also change laser1off
|
|
681
615
|
# caput(pv.me14e_pmac_str, ' M712=0 M711=1')
|
|
682
616
|
yield from bps.abs_set(pmac.laser, LaserSettings.LASER_1_ON, wait=True)
|
|
683
617
|
|
|
684
618
|
elif laser_setting == "laser1off":
|
|
685
|
-
|
|
619
|
+
SSX_LOGGER.info("Laser 1 shutter is closed")
|
|
686
620
|
yield from bps.abs_set(pmac.laser, LaserSettings.LASER_1_OFF, wait=True)
|
|
687
621
|
|
|
688
622
|
elif laser_setting == "laser2on":
|
|
689
|
-
|
|
623
|
+
SSX_LOGGER.info("Laser 2 / BNC3 shutter is open")
|
|
690
624
|
yield from bps.abs_set(pmac.laser, LaserSettings.LASER_2_ON, wait=True)
|
|
691
625
|
|
|
692
626
|
elif laser_setting == "laser2off":
|
|
693
|
-
|
|
627
|
+
SSX_LOGGER.info("Laser 2 shutter is closed")
|
|
694
628
|
yield from bps.abs_set(pmac.laser, LaserSettings.LASER_2_OFF, wait=True)
|
|
695
629
|
|
|
696
630
|
elif laser_setting == "laser1burn":
|
|
697
631
|
led_burn_time = caget(pv.me14e_gp103)
|
|
698
|
-
|
|
699
|
-
|
|
632
|
+
SSX_LOGGER.info("Laser 1 on")
|
|
633
|
+
SSX_LOGGER.info(f"Burn time is {led_burn_time} s")
|
|
700
634
|
yield from bps.abs_set(pmac.laser, LaserSettings.LASER_1_ON, wait=True)
|
|
701
|
-
yield from bps.sleep(led_burn_time)
|
|
702
|
-
|
|
635
|
+
yield from bps.sleep(float(led_burn_time))
|
|
636
|
+
SSX_LOGGER.info("Laser 1 off")
|
|
703
637
|
yield from bps.abs_set(pmac.laser, LaserSettings.LASER_1_OFF, wait=True)
|
|
704
638
|
|
|
705
639
|
elif laser_setting == "laser2burn":
|
|
706
640
|
led_burn_time = caget(pv.me14e_gp109)
|
|
707
|
-
|
|
708
|
-
|
|
641
|
+
SSX_LOGGER.info("Laser 2 on")
|
|
642
|
+
SSX_LOGGER.info(f"burntime {led_burn_time} s")
|
|
709
643
|
yield from bps.abs_set(pmac.laser, LaserSettings.LASER_2_ON, wait=True)
|
|
710
|
-
yield from bps.sleep(led_burn_time)
|
|
711
|
-
|
|
644
|
+
yield from bps.sleep(float(led_burn_time))
|
|
645
|
+
SSX_LOGGER.info("Laser 2 off")
|
|
712
646
|
yield from bps.abs_set(pmac.laser, LaserSettings.LASER_2_OFF, wait=True)
|
|
713
647
|
|
|
714
648
|
|
|
715
|
-
@
|
|
649
|
+
@log_on_entry
|
|
716
650
|
def scrape_mtr_directions(motor_file_path: Path = CS_FILES_PATH):
|
|
717
651
|
with open(motor_file_path / "motor_direction.txt") as f:
|
|
718
652
|
lines = f.readlines()
|
|
@@ -726,13 +660,12 @@ def scrape_mtr_directions(motor_file_path: Path = CS_FILES_PATH):
|
|
|
726
660
|
mtr3_dir = float(line.split("=")[1])
|
|
727
661
|
else:
|
|
728
662
|
continue
|
|
729
|
-
|
|
663
|
+
SSX_LOGGER.debug(f"mt1_dir {mtr1_dir} mtr2_dir {mtr2_dir} mtr3_dir {mtr3_dir}")
|
|
730
664
|
return mtr1_dir, mtr2_dir, mtr3_dir
|
|
731
665
|
|
|
732
666
|
|
|
733
|
-
@
|
|
667
|
+
@log_on_entry
|
|
734
668
|
def fiducial(point: int = 1, pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
735
|
-
setup_logging()
|
|
736
669
|
scale = 10000.0 # noqa: F841
|
|
737
670
|
|
|
738
671
|
mtr1_dir, mtr2_dir, mtr3_dir = scrape_mtr_directions(CS_FILES_PATH)
|
|
@@ -743,18 +676,18 @@ def fiducial(point: int = 1, pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
|
743
676
|
|
|
744
677
|
output_param_path = PARAM_FILE_PATH_FT
|
|
745
678
|
output_param_path.mkdir(parents=True, exist_ok=True)
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
679
|
+
SSX_LOGGER.info(f"Writing Fiducial File {output_param_path}/fiducial_{point}.txt")
|
|
680
|
+
SSX_LOGGER.info("MTR\tRBV\tRAW\tCorr\tf_value")
|
|
681
|
+
SSX_LOGGER.info(f"MTR1\t{rbv_1:1.4f}\t{mtr1_dir:d}")
|
|
682
|
+
SSX_LOGGER.info(f"MTR2\t{rbv_2:1.4f}\t{mtr2_dir:d}")
|
|
683
|
+
SSX_LOGGER.info(f"MTR3\t{rbv_3:1.4f}\t{mtr3_dir:d}")
|
|
751
684
|
|
|
752
685
|
with open(output_param_path / f"fiducial_{point}.txt", "w") as f:
|
|
753
686
|
f.write("MTR\tRBV\tCorr\n")
|
|
754
|
-
f.write("MTR1\t
|
|
755
|
-
f.write("MTR2\t
|
|
756
|
-
f.write("MTR3\t
|
|
757
|
-
|
|
687
|
+
f.write(f"MTR1\t{rbv_1:1.4f}\t{mtr1_dir:d}\n")
|
|
688
|
+
f.write(f"MTR2\t{rbv_2:1.4f}\t{mtr2_dir:d}\n")
|
|
689
|
+
f.write(f"MTR3\t{rbv_3:1.4f}\t{mtr3_dir:d}")
|
|
690
|
+
SSX_LOGGER.info(f"Fiducial {point} set.")
|
|
758
691
|
yield from bps.null()
|
|
759
692
|
|
|
760
693
|
|
|
@@ -769,7 +702,7 @@ def scrape_mtr_fiducials(
|
|
|
769
702
|
return f_x, f_y, f_z
|
|
770
703
|
|
|
771
704
|
|
|
772
|
-
@
|
|
705
|
+
@log_on_entry
|
|
773
706
|
def cs_maker(pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
774
707
|
"""
|
|
775
708
|
Coordinate system.
|
|
@@ -800,28 +733,27 @@ def cs_maker(pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
|
800
733
|
This should be measured in situ prior to expriment, ie. measure by hand using
|
|
801
734
|
opposite and adjacent RBV after calibration of scale factors.
|
|
802
735
|
"""
|
|
803
|
-
setup_logging()
|
|
804
736
|
chip_type = int(caget(CHIPTYPE_PV))
|
|
805
737
|
fiducial_dict = {}
|
|
806
738
|
fiducial_dict[0] = [25.400, 25.400]
|
|
807
739
|
fiducial_dict[1] = [24.600, 24.600]
|
|
808
740
|
fiducial_dict[2] = [25.400, 25.400]
|
|
809
741
|
fiducial_dict[3] = [18.25, 18.25]
|
|
810
|
-
|
|
742
|
+
SSX_LOGGER.info(f"Chip type is {chip_type} with size {fiducial_dict[chip_type]}")
|
|
811
743
|
|
|
812
744
|
mtr1_dir, mtr2_dir, mtr3_dir = scrape_mtr_directions()
|
|
813
745
|
f1_x, f1_y, f1_z = scrape_mtr_fiducials(1)
|
|
814
746
|
f2_x, f2_y, f2_z = scrape_mtr_fiducials(2)
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
747
|
+
SSX_LOGGER.info(f"mtr1 direction: {mtr1_dir}")
|
|
748
|
+
SSX_LOGGER.info(f"mtr2 direction: {mtr2_dir}")
|
|
749
|
+
SSX_LOGGER.info(f"mtr3 direction: {mtr3_dir}")
|
|
818
750
|
|
|
819
751
|
# Scale parameters saved in json file
|
|
820
752
|
try:
|
|
821
753
|
with open(CS_FILES_PATH / "cs_maker.json") as fh:
|
|
822
754
|
cs_info = json.load(fh)
|
|
823
755
|
except json.JSONDecodeError:
|
|
824
|
-
|
|
756
|
+
SSX_LOGGER.error("Invalid JSON file.")
|
|
825
757
|
raise
|
|
826
758
|
|
|
827
759
|
try:
|
|
@@ -837,7 +769,7 @@ def cs_maker(pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
|
837
769
|
int(cs_info["Sz_dir"]),
|
|
838
770
|
)
|
|
839
771
|
except KeyError:
|
|
840
|
-
|
|
772
|
+
SSX_LOGGER.error("Wrong or missing key in the cs json file.")
|
|
841
773
|
raise
|
|
842
774
|
|
|
843
775
|
def check_dir(val):
|
|
@@ -854,21 +786,21 @@ def cs_maker(pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
|
854
786
|
Sz2 = f2_x / fiducial_dict[chip_type][1]
|
|
855
787
|
Sz = Sz_dir * ((Sz1 + Sz2) / 2)
|
|
856
788
|
Cz = np.sqrt(1 - Sz**2)
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
789
|
+
SSX_LOGGER.info(f"Sz1 , {Sz1:1.4f}, {np.degrees(np.arcsin(Sz1)):1.4f}")
|
|
790
|
+
SSX_LOGGER.info(f"Sz2 , {Sz2:1.4f}, {np.degrees(np.arcsin(Sz2)):1.4f}")
|
|
791
|
+
SSX_LOGGER.info(f"Sz , {Sz:1.4f}, {np.degrees(np.arcsin(Sz)):1.4f}")
|
|
792
|
+
SSX_LOGGER.info(f"Cz , {Cz:1.4f}, {np.degrees(np.arcsin(Cz)):1.4f}")
|
|
861
793
|
# Rotation Around Y
|
|
862
794
|
Sy = Sy_dir * f1_z / fiducial_dict[chip_type][0]
|
|
863
795
|
Cy = np.sqrt(1 - Sy**2)
|
|
864
|
-
|
|
865
|
-
|
|
796
|
+
SSX_LOGGER.info(f"Sy , {Sy:1.4f}, {np.degrees(np.arcsin(Sy)):1.4f}")
|
|
797
|
+
SSX_LOGGER.info(f"Cy , {Cy:1.4f}, {np.degrees(np.arcsin(Cy)):1.4f}")
|
|
866
798
|
# Rotation Around X
|
|
867
799
|
# If stages upsidedown (I24) change sign of Sx
|
|
868
800
|
Sx = Sx_dir * f2_z / fiducial_dict[chip_type][1]
|
|
869
801
|
Cx = np.sqrt(1 - Sx**2)
|
|
870
|
-
|
|
871
|
-
|
|
802
|
+
SSX_LOGGER.info(f"Sx , {Sx:1.4f}, {np.degrees(np.arcsin(Sx)):1.4f}")
|
|
803
|
+
SSX_LOGGER.info(f"Cx , {Cx:1.4f}, {np.degrees(np.arcsin(Cx)):1.4f}")
|
|
872
804
|
|
|
873
805
|
x1factor = mtr1_dir * scalex * (Cy * Cz)
|
|
874
806
|
y1factor = mtr2_dir * scaley * (-1.0 * Cx * Sz)
|
|
@@ -882,15 +814,15 @@ def cs_maker(pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
|
882
814
|
y3factor = mtr2_dir * scaley * ((Cx * Sy * Sz) + (Sx * Cz))
|
|
883
815
|
z3factor = mtr3_dir * scalez * (Cx * Cy)
|
|
884
816
|
|
|
885
|
-
|
|
817
|
+
SSX_LOGGER.info(f"Skew being used is: {skew:1.4f}")
|
|
886
818
|
s1 = np.degrees(np.arcsin(Sz1))
|
|
887
819
|
s2 = np.degrees(np.arcsin(Sz2))
|
|
888
820
|
rot = np.degrees(np.arcsin((Sz1 + Sz2) / 2))
|
|
889
821
|
calc_skew = (s1 - rot) - (s2 - rot)
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
822
|
+
SSX_LOGGER.info(f"s1:{s1:1.4f} s2:{s2:1.4f} rot:{rot:1.4f}")
|
|
823
|
+
SSX_LOGGER.info(f"Calculated rotation from current fiducials is: {rot:1.4f}")
|
|
824
|
+
SSX_LOGGER.info(f"Calculated Skew from current fiducials is: {calc_skew:1.4f}")
|
|
825
|
+
SSX_LOGGER.info("Calculated Skew has been known to have the wrong sign")
|
|
894
826
|
|
|
895
827
|
sinD = np.sin((skew / 2) * (np.pi / 180))
|
|
896
828
|
cosD = np.cos((skew / 2) * (np.pi / 180))
|
|
@@ -902,44 +834,43 @@ def cs_maker(pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
|
902
834
|
cs1 = f"#1->{new_x1factor:+1.3f}X{new_y1factor:+1.3f}Y{z1factor:+1.3f}Z"
|
|
903
835
|
cs2 = f"#2->{new_x2factor:+1.3f}X{new_y2factor:+1.3f}Y{z2factor:+1.3f}Z"
|
|
904
836
|
cs3 = f"#3->{x3factor:+1.3f}X{y3factor:+1.3f}Y{z3factor:+1.3f}Z"
|
|
905
|
-
|
|
906
|
-
|
|
837
|
+
SSX_LOGGER.info(f"PMAC strings. \ncs1: {cs1} \ncs2: {cs2}cs3: {cs3}")
|
|
838
|
+
SSX_LOGGER.info(
|
|
907
839
|
"""These next values should be 1.
|
|
908
840
|
This is the sum of the squares of the factors divided by their scale."""
|
|
909
841
|
)
|
|
910
842
|
sqfact1 = np.sqrt(x1factor**2 + y1factor**2 + z1factor**2) / scalex
|
|
911
843
|
sqfact2 = np.sqrt(x2factor**2 + y2factor**2 + z2factor**2) / scaley
|
|
912
844
|
sqfact3 = np.sqrt(x3factor**2 + y3factor**2 + z3factor**2) / scalez
|
|
913
|
-
|
|
914
|
-
|
|
845
|
+
SSX_LOGGER.info(f"{sqfact1:1.4f} \n {sqfact2:1.4f} \n {sqfact3:1.4f}")
|
|
846
|
+
SSX_LOGGER.debug("Long wait, please be patient")
|
|
915
847
|
yield from bps.trigger(pmac.to_xyz_zero)
|
|
916
848
|
sleep(2.5)
|
|
917
849
|
yield from set_pmac_strings_for_cs(pmac, {"cs1": cs1, "cs2": cs2, "cs3": cs3})
|
|
918
850
|
yield from bps.trigger(pmac.to_xyz_zero)
|
|
919
|
-
sleep(
|
|
851
|
+
sleep(2.5)
|
|
920
852
|
yield from bps.trigger(pmac.home, wait=True)
|
|
921
|
-
sleep(
|
|
922
|
-
|
|
853
|
+
sleep(2.5)
|
|
854
|
+
SSX_LOGGER.debug(f"Chip_type is {chip_type}")
|
|
923
855
|
if chip_type == 0:
|
|
924
856
|
yield from bps.abs_set(pmac.pmac_string, "!x0.4y0.4", wait=True)
|
|
925
|
-
sleep(
|
|
857
|
+
sleep(2.5)
|
|
926
858
|
yield from bps.trigger(pmac.home, wait=True)
|
|
927
859
|
else:
|
|
928
860
|
yield from bps.trigger(pmac.home, wait=True)
|
|
929
|
-
|
|
861
|
+
SSX_LOGGER.debug("CSmaker done.")
|
|
930
862
|
yield from bps.null()
|
|
931
863
|
|
|
932
864
|
|
|
933
865
|
def cs_reset(pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
934
866
|
"""Used to clear CS when using Custom Chip"""
|
|
935
|
-
setup_logging()
|
|
936
867
|
cs1 = "#1->10000X+0Y+0Z"
|
|
937
868
|
cs2 = "#2->+0X-10000Y+0Z"
|
|
938
869
|
cs3 = "#3->0X+0Y-10000Z"
|
|
939
870
|
strg = "\n".join([cs1, cs2, cs3])
|
|
940
871
|
print(strg)
|
|
941
872
|
yield from set_pmac_strings_for_cs(pmac, {"cs1": cs1, "cs2": cs2, "cs3": cs3})
|
|
942
|
-
|
|
873
|
+
SSX_LOGGER.debug("CSreset Done")
|
|
943
874
|
yield from bps.null()
|
|
944
875
|
|
|
945
876
|
|
|
@@ -964,16 +895,15 @@ def set_pmac_strings_for_cs(pmac: PMAC, cs_str: dict):
|
|
|
964
895
|
yield from bps.abs_set(pmac.pmac_string, cs_str["cs3"], wait=True)
|
|
965
896
|
|
|
966
897
|
|
|
967
|
-
@
|
|
898
|
+
@log_on_entry
|
|
968
899
|
def pumpprobe_calc() -> MsgGenerator:
|
|
969
900
|
# TODO See https://github.com/DiamondLightSource/mx_bluesky/issues/122
|
|
970
|
-
|
|
971
|
-
logger.info("Calculate and show exposure and dwell time for each option.")
|
|
901
|
+
SSX_LOGGER.info("Calculate and show exposure and dwell time for each option.")
|
|
972
902
|
exptime = float(caget(pv.me14e_exptime))
|
|
973
903
|
pumpexptime = float(caget(pv.me14e_gp103))
|
|
974
904
|
movetime = 0.008
|
|
975
|
-
|
|
976
|
-
|
|
905
|
+
SSX_LOGGER.info(f"X-ray exposure time {exptime}")
|
|
906
|
+
SSX_LOGGER.info(f"Laser dwell time {pumpexptime}")
|
|
977
907
|
repeat1 = 2 * 20 * (movetime + (pumpexptime + exptime) / 2)
|
|
978
908
|
repeat2 = 4 * 20 * (movetime + (pumpexptime + exptime) / 2)
|
|
979
909
|
repeat3 = 6 * 20 * (movetime + (pumpexptime + exptime) / 2)
|
|
@@ -988,48 +918,42 @@ def pumpprobe_calc() -> MsgGenerator:
|
|
|
988
918
|
):
|
|
989
919
|
rounded = round(repeat, 4)
|
|
990
920
|
caput(pv_name, rounded)
|
|
991
|
-
|
|
992
|
-
|
|
921
|
+
SSX_LOGGER.info(f"Repeat ({pv_name}): {rounded} s")
|
|
922
|
+
SSX_LOGGER.debug("PP calculations done")
|
|
993
923
|
yield from bps.null()
|
|
994
924
|
|
|
995
925
|
|
|
996
|
-
@
|
|
926
|
+
@log_on_entry
|
|
997
927
|
def block_check(pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
998
|
-
setup_logging()
|
|
999
928
|
# TODO See https://github.com/DiamondLightSource/mx_bluesky/issues/117
|
|
1000
929
|
caput(pv.me14e_gp9, 0)
|
|
1001
930
|
while True:
|
|
1002
931
|
if int(caget(pv.me14e_gp9)) == 0:
|
|
1003
932
|
chip_type = int(caget(CHIPTYPE_PV))
|
|
1004
933
|
if chip_type == ChipType.Minichip:
|
|
1005
|
-
|
|
934
|
+
SSX_LOGGER.info("Oxford mini chip in use.")
|
|
1006
935
|
block_start_list = scrape_pvar_file("minichip_oxford.pvar")
|
|
1007
936
|
elif chip_type == ChipType.Custom:
|
|
1008
|
-
|
|
937
|
+
SSX_LOGGER.error("This is a custom chip, no block check available!")
|
|
1009
938
|
raise ValueError(
|
|
1010
939
|
"Chip type set to 'custom', which has no block check."
|
|
1011
940
|
"If not using a custom chip, please double check chip in the GUI."
|
|
1012
941
|
)
|
|
1013
942
|
else:
|
|
1014
|
-
|
|
943
|
+
SSX_LOGGER.warning("Default is Oxford chip block start list.")
|
|
1015
944
|
block_start_list = scrape_pvar_file("oxford.pvar")
|
|
1016
945
|
for entry in block_start_list:
|
|
1017
946
|
if int(caget(pv.me14e_gp9)) != 0:
|
|
1018
|
-
|
|
947
|
+
SSX_LOGGER.warning("Block Check Aborted")
|
|
1019
948
|
sleep(1.0)
|
|
1020
949
|
break
|
|
1021
950
|
block, x, y = entry
|
|
1022
|
-
|
|
951
|
+
SSX_LOGGER.debug(f"Block: {block} -> (x={x} y={y})")
|
|
1023
952
|
yield from bps.abs_set(pmac.pmac_string, f"!x{x}y{y}", wait=True)
|
|
1024
953
|
time.sleep(0.4)
|
|
1025
954
|
else:
|
|
1026
|
-
|
|
955
|
+
SSX_LOGGER.warning("Block Check Aborted due to GP 9 not equalling 0")
|
|
1027
956
|
break
|
|
1028
957
|
break
|
|
1029
|
-
|
|
958
|
+
SSX_LOGGER.debug("Block check done")
|
|
1030
959
|
yield from bps.null()
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
# setup_logging now called in all functions.
|
|
1034
|
-
# TODO See logging issue on blueapi
|
|
1035
|
-
# https://github.com/DiamondLightSource/blueapi/issues/494
|