mx-bluesky 0.0.2__py3-none-any.whl → 1.1.0__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/beamlines/i04/__init__.py +3 -0
- mx_bluesky/beamlines/i04/callbacks/murko_callback.py +45 -0
- mx_bluesky/beamlines/i04/thawing_plan.py +85 -0
- mx_bluesky/beamlines/i24/serial/__init__.py +49 -0
- mx_bluesky/beamlines/i24/serial/blueapi_config.yaml +12 -0
- mx_bluesky/{I24 → beamlines/i24}/serial/dcid.py +53 -41
- mx_bluesky/{I24 → beamlines/i24}/serial/extruder/EX-gui-edm/DetStage.edl +3 -4
- mx_bluesky/{I24 → beamlines/i24}/serial/extruder/EX-gui-edm/DiamondExtruder-I24-py3v1.edl +28 -32
- mx_bluesky/{I24 → beamlines/i24}/serial/extruder/EX-gui-edm/microdrop_alignment.edl +0 -1
- mx_bluesky/beamlines/i24/serial/extruder/i24ssx_Extruder_Collect_py3v2.py +516 -0
- mx_bluesky/{I24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/CustomChip_py3v1.edl +3 -4
- mx_bluesky/{I24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/DetStage.edl +3 -4
- mx_bluesky/{I24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/DiamondChipI24-py3v1.edl +273 -223
- mx_bluesky/{I24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/ME14E-GeneralPurpose.edl +0 -1
- mx_bluesky/{I24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/MappingLite-oxford_py3v1.edl +12 -13
- mx_bluesky/{I24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/PMAC_Command.edl +0 -1
- mx_bluesky/{I24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/Shutter_Control.edl +0 -1
- mx_bluesky/{I24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/microdrop_alignment.edl +0 -1
- mx_bluesky/{I24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/nudgechip.edl +0 -1
- mx_bluesky/{I24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/pumpprobe-py3v1.edl +273 -143
- mx_bluesky/beamlines/i24/serial/fixed_target/FT-gui-edm/short1-laser.png +0 -0
- mx_bluesky/beamlines/i24/serial/fixed_target/FT-gui-edm/short2-laser.png +0 -0
- mx_bluesky/{I24 → beamlines/i24}/serial/fixed_target/ft_utils.py +24 -1
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Collect_py3v1.py +808 -0
- mx_bluesky/{I24 → beamlines/i24}/serial/fixed_target/i24ssx_Chip_Manager_py3v1.py +377 -416
- mx_bluesky/{I24 → beamlines/i24}/serial/fixed_target/i24ssx_Chip_Mapping_py3v1.py +34 -40
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_StartUp_py3v1.py +328 -0
- mx_bluesky/{I24 → beamlines/i24}/serial/fixed_target/i24ssx_moveonclick.py +66 -48
- mx_bluesky/{I24 → beamlines/i24}/serial/log.py +66 -19
- mx_bluesky/beamlines/i24/serial/parameters/__init__.py +15 -0
- mx_bluesky/beamlines/i24/serial/parameters/constants.py +47 -0
- mx_bluesky/beamlines/i24/serial/parameters/experiment_parameters.py +103 -0
- mx_bluesky/beamlines/i24/serial/parameters/fixed_target/cs/cs_maker.json +9 -0
- mx_bluesky/{I24 → beamlines/i24}/serial/parameters/fixed_target/cs/motor_direction.txt +1 -1
- mx_bluesky/{I24 → beamlines/i24}/serial/parameters/fixed_target/pvar_files/minichip-oxford.pvar +1 -1
- mx_bluesky/beamlines/i24/serial/parameters/utils.py +42 -0
- mx_bluesky/beamlines/i24/serial/run_extruder.sh +19 -0
- mx_bluesky/beamlines/i24/serial/run_fixed_target.sh +22 -0
- mx_bluesky/beamlines/i24/serial/run_serial.py +36 -0
- mx_bluesky/{I24 → beamlines/i24}/serial/set_visit_directory.sh +6 -1
- mx_bluesky/{I24 → beamlines/i24}/serial/setup_beamline/pv.py +1 -62
- mx_bluesky/{I24 → beamlines/i24}/serial/setup_beamline/pv_abstract.py +6 -7
- mx_bluesky/{I24 → beamlines/i24}/serial/setup_beamline/setup_beamline.py +90 -269
- mx_bluesky/{I24 → beamlines/i24}/serial/setup_beamline/setup_detector.py +47 -40
- mx_bluesky/beamlines/i24/serial/setup_beamline/setup_zebra_plans.py +459 -0
- mx_bluesky/beamlines/i24/serial/start_blueapi.sh +28 -0
- mx_bluesky/beamlines/i24/serial/write_nexus.py +105 -0
- mx_bluesky/example.py +4 -4
- mx_bluesky/hyperion/__init__.py +1 -0
- mx_bluesky/hyperion/__main__.py +374 -0
- mx_bluesky/hyperion/device_setup_plans/__init__.py +0 -0
- mx_bluesky/hyperion/device_setup_plans/dcm_pitch_roll_mirror_adjuster.py +134 -0
- mx_bluesky/hyperion/device_setup_plans/manipulate_sample.py +110 -0
- mx_bluesky/hyperion/device_setup_plans/position_detector.py +16 -0
- mx_bluesky/hyperion/device_setup_plans/read_hardware_for_setup.py +60 -0
- mx_bluesky/hyperion/device_setup_plans/setup_oav.py +87 -0
- mx_bluesky/hyperion/device_setup_plans/setup_panda.py +210 -0
- mx_bluesky/hyperion/device_setup_plans/setup_zebra.py +214 -0
- mx_bluesky/hyperion/device_setup_plans/smargon.py +25 -0
- mx_bluesky/hyperion/device_setup_plans/utils.py +44 -0
- mx_bluesky/hyperion/device_setup_plans/xbpm_feedback.py +93 -0
- mx_bluesky/hyperion/exceptions.py +47 -0
- mx_bluesky/hyperion/experiment_plans/__init__.py +30 -0
- mx_bluesky/hyperion/experiment_plans/experiment_registry.py +84 -0
- mx_bluesky/hyperion/experiment_plans/flyscan_xray_centre_plan.py +528 -0
- mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py +209 -0
- mx_bluesky/hyperion/experiment_plans/oav_grid_detection_plan.py +173 -0
- mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py +81 -0
- mx_bluesky/hyperion/experiment_plans/optimise_attenuation_plan.py +463 -0
- mx_bluesky/hyperion/experiment_plans/pin_centre_then_xray_centre_plan.py +119 -0
- mx_bluesky/hyperion/experiment_plans/pin_tip_centring_plan.py +164 -0
- mx_bluesky/hyperion/experiment_plans/robot_load_then_centre_plan.py +322 -0
- mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py +436 -0
- mx_bluesky/hyperion/experiment_plans/set_energy_plan.py +68 -0
- mx_bluesky/hyperion/external_interaction/__init__.py +9 -0
- mx_bluesky/hyperion/external_interaction/callbacks/__init__.py +10 -0
- mx_bluesky/hyperion/external_interaction/callbacks/__main__.py +148 -0
- mx_bluesky/hyperion/external_interaction/callbacks/aperture_change_callback.py +22 -0
- mx_bluesky/hyperion/external_interaction/callbacks/common/__init__.py +0 -0
- mx_bluesky/hyperion/external_interaction/callbacks/common/callback_util.py +46 -0
- mx_bluesky/hyperion/external_interaction/callbacks/common/ispyb_mapping.py +70 -0
- mx_bluesky/hyperion/external_interaction/callbacks/grid_detection_callback.py +88 -0
- mx_bluesky/hyperion/external_interaction/callbacks/ispyb_callback_base.py +203 -0
- mx_bluesky/hyperion/external_interaction/callbacks/log_uid_tag_callback.py +20 -0
- mx_bluesky/hyperion/external_interaction/callbacks/logging_callback.py +29 -0
- mx_bluesky/hyperion/external_interaction/callbacks/plan_reactive_callback.py +101 -0
- mx_bluesky/hyperion/external_interaction/callbacks/robot_load/ispyb_callback.py +88 -0
- mx_bluesky/hyperion/external_interaction/callbacks/rotation/__init__.py +0 -0
- mx_bluesky/hyperion/external_interaction/callbacks/rotation/ispyb_callback.py +174 -0
- mx_bluesky/hyperion/external_interaction/callbacks/rotation/ispyb_mapping.py +17 -0
- mx_bluesky/hyperion/external_interaction/callbacks/rotation/nexus_callback.py +102 -0
- mx_bluesky/hyperion/external_interaction/callbacks/xray_centre/__init__.py +0 -0
- mx_bluesky/hyperion/external_interaction/callbacks/xray_centre/ispyb_callback.py +269 -0
- mx_bluesky/hyperion/external_interaction/callbacks/xray_centre/ispyb_mapping.py +53 -0
- mx_bluesky/hyperion/external_interaction/callbacks/xray_centre/nexus_callback.py +95 -0
- mx_bluesky/hyperion/external_interaction/callbacks/zocalo_callback.py +92 -0
- mx_bluesky/hyperion/external_interaction/config_server.py +35 -0
- mx_bluesky/hyperion/external_interaction/exceptions.py +13 -0
- mx_bluesky/hyperion/external_interaction/ispyb/__init__.py +0 -0
- mx_bluesky/hyperion/external_interaction/ispyb/data_model.py +95 -0
- mx_bluesky/hyperion/external_interaction/ispyb/exp_eye_store.py +125 -0
- mx_bluesky/hyperion/external_interaction/ispyb/ispyb_store.py +276 -0
- mx_bluesky/hyperion/external_interaction/ispyb/ispyb_utils.py +29 -0
- mx_bluesky/hyperion/external_interaction/nexus/__init__.py +0 -0
- mx_bluesky/hyperion/external_interaction/nexus/nexus_utils.py +148 -0
- mx_bluesky/hyperion/external_interaction/nexus/write_nexus.py +114 -0
- mx_bluesky/hyperion/log.py +99 -0
- mx_bluesky/hyperion/parameters/__init__.py +2 -0
- mx_bluesky/hyperion/parameters/cli.py +68 -0
- mx_bluesky/hyperion/parameters/components.py +253 -0
- mx_bluesky/hyperion/parameters/constants.py +158 -0
- mx_bluesky/hyperion/parameters/gridscan.py +216 -0
- mx_bluesky/hyperion/parameters/rotation.py +160 -0
- mx_bluesky/hyperion/resources/panda/panda-gridscan.yaml +964 -0
- mx_bluesky/hyperion/tracing.py +28 -0
- mx_bluesky/hyperion/utils/context.py +84 -0
- mx_bluesky/hyperion/utils/utils.py +25 -0
- mx_bluesky/hyperion/utils/validation.py +196 -0
- mx_bluesky/jupyter_example.ipynb +3 -2
- {mx_bluesky-0.0.2.dist-info → mx_bluesky-1.1.0.dist-info}/METADATA +53 -32
- mx_bluesky-1.1.0.dist-info/RECORD +136 -0
- {mx_bluesky-0.0.2.dist-info → mx_bluesky-1.1.0.dist-info}/WHEEL +1 -1
- mx_bluesky-1.1.0.dist-info/entry_points.txt +8 -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/i24ssx_Chip_Collect_py3v1.py +0 -706
- mx_bluesky/I24/serial/fixed_target/i24ssx_Chip_StartUp_py3v1.py +0 -463
- 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.2.dist-info/RECORD +0 -58
- mx_bluesky-0.0.2.dist-info/entry_points.txt +0 -4
- /mx_bluesky/{I24 → beamlines}/__init__.py +0 -0
- /mx_bluesky/{I24/serial → beamlines/i24}/__init__.py +0 -0
- /mx_bluesky/{I24 → beamlines/i24}/serial/extruder/__init__.py +0 -0
- /mx_bluesky/{I24 → beamlines/i24}/serial/fixed_target/__init__.py +0 -0
- /mx_bluesky/{I24 → beamlines/i24}/serial/parameters/fixed_target/pvar_files/oxford.pvar +0 -0
- /mx_bluesky/{I24 → beamlines/i24}/serial/run_ssx.sh +0 -0
- /mx_bluesky/{I24 → beamlines/i24}/serial/setup_beamline/__init__.py +0 -0
- /mx_bluesky/{I24 → beamlines/i24}/serial/setup_beamline/ca.py +0 -0
- {mx_bluesky-0.0.2.dist-info → mx_bluesky-1.1.0.dist-info}/LICENSE +0 -0
- {mx_bluesky-0.0.2.dist-info → mx_bluesky-1.1.0.dist-info}/top_level.txt +0 -0
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
Chip manager for fixed target
|
|
3
3
|
This version changed to python3 March2020 by RLO
|
|
4
4
|
"""
|
|
5
|
-
from __future__ import annotations
|
|
6
5
|
|
|
7
|
-
import argparse
|
|
8
6
|
import json
|
|
9
7
|
import logging
|
|
10
8
|
import re
|
|
@@ -12,31 +10,59 @@ import shutil
|
|
|
12
10
|
import sys
|
|
13
11
|
import time
|
|
14
12
|
from pathlib import Path
|
|
13
|
+
from pprint import pformat
|
|
15
14
|
from time import sleep
|
|
16
15
|
|
|
16
|
+
import bluesky.plan_stubs as bps
|
|
17
17
|
import numpy as np
|
|
18
|
-
|
|
19
|
-
from
|
|
20
|
-
from
|
|
21
|
-
from
|
|
22
|
-
from
|
|
23
|
-
from
|
|
18
|
+
from blueapi.core import MsgGenerator
|
|
19
|
+
from dodal.beamlines import i24
|
|
20
|
+
from dodal.common import inject
|
|
21
|
+
from dodal.devices.i24.beamstop import Beamstop, BeamstopPositions
|
|
22
|
+
from dodal.devices.i24.dual_backlight import BacklightPositions, DualBacklight
|
|
23
|
+
from dodal.devices.i24.i24_detector_motion import DetectorMotion
|
|
24
|
+
from dodal.devices.i24.pmac import PMAC, EncReset, LaserSettings
|
|
25
|
+
|
|
26
|
+
from mx_bluesky.beamlines.i24.serial import log
|
|
27
|
+
from mx_bluesky.beamlines.i24.serial.fixed_target import (
|
|
28
|
+
i24ssx_Chip_Mapping_py3v1 as mapping,
|
|
29
|
+
)
|
|
30
|
+
from mx_bluesky.beamlines.i24.serial.fixed_target import (
|
|
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,
|
|
37
|
+
)
|
|
38
|
+
from mx_bluesky.beamlines.i24.serial.parameters import get_chip_format
|
|
39
|
+
from mx_bluesky.beamlines.i24.serial.parameters.constants import (
|
|
24
40
|
CS_FILES_PATH,
|
|
25
41
|
FULLMAP_PATH,
|
|
26
42
|
LITEMAP_PATH,
|
|
43
|
+
PARAM_FILE_NAME,
|
|
27
44
|
PARAM_FILE_PATH_FT,
|
|
28
45
|
PVAR_FILE_PATH,
|
|
29
46
|
)
|
|
30
|
-
from mx_bluesky.
|
|
31
|
-
from mx_bluesky.
|
|
47
|
+
from mx_bluesky.beamlines.i24.serial.setup_beamline import Pilatus, caget, caput, pv
|
|
48
|
+
from mx_bluesky.beamlines.i24.serial.setup_beamline.setup_detector import (
|
|
49
|
+
get_detector_type,
|
|
50
|
+
)
|
|
32
51
|
|
|
33
52
|
logger = logging.getLogger("I24ssx.chip_manager")
|
|
34
53
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
54
|
+
# An approximation of the chip size for the move during fiducials alignment.
|
|
55
|
+
CHIP_MOVES = {
|
|
56
|
+
ChipType.Oxford: 25.40,
|
|
57
|
+
ChipType.OxfordInner: 24.60,
|
|
58
|
+
ChipType.Custom: 25.40,
|
|
59
|
+
ChipType.Minichip: 25.40,
|
|
60
|
+
}
|
|
61
|
+
CHIPTYPE_PV = pv.me14e_gp1
|
|
62
|
+
MAPTYPE_PV = pv.me14e_gp2
|
|
63
|
+
NUM_EXPOSURES_PV = pv.me14e_gp3
|
|
64
|
+
PUMP_REPEAT_PV = pv.me14e_gp4
|
|
65
|
+
MAP_FILEPATH_PV = pv.me14e_gp5
|
|
40
66
|
|
|
41
67
|
|
|
42
68
|
def setup_logging():
|
|
@@ -46,47 +72,40 @@ def setup_logging():
|
|
|
46
72
|
|
|
47
73
|
|
|
48
74
|
@log.log_on_entry
|
|
49
|
-
def
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
caput(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
caput(
|
|
75
|
-
caput(pv.me14e_gp2, 0)
|
|
76
|
-
caput(pv.me14e_gp3, 1)
|
|
77
|
-
caput(pv.me14e_gp4, 0)
|
|
75
|
+
def initialise_stages(
|
|
76
|
+
pmac: PMAC = inject("pmac"),
|
|
77
|
+
) -> MsgGenerator:
|
|
78
|
+
"""Initialise the portable stages PVs, usually used only once right after setting \
|
|
79
|
+
up the stages either after use at different facility.
|
|
80
|
+
"""
|
|
81
|
+
setup_logging()
|
|
82
|
+
group = "initialise_stages"
|
|
83
|
+
logger.info("Setting velocity, acceleration and limits for stages")
|
|
84
|
+
|
|
85
|
+
yield from bps.abs_set(pmac.x.velocity, 20, group=group)
|
|
86
|
+
yield from bps.abs_set(pmac.y.velocity, 20, group=group)
|
|
87
|
+
yield from bps.abs_set(pmac.z.velocity, 20, group=group)
|
|
88
|
+
yield from bps.abs_set(pmac.x.acceleration_time, 0.01, group=group)
|
|
89
|
+
yield from bps.abs_set(pmac.y.acceleration_time, 0.01, group=group)
|
|
90
|
+
yield from bps.abs_set(pmac.z.acceleration_time, 0.01, group=group)
|
|
91
|
+
yield from bps.abs_set(pmac.x.high_limit_travel, 30, group=group)
|
|
92
|
+
yield from bps.abs_set(pmac.x.low_limit_travel, -29, group=group)
|
|
93
|
+
yield from bps.abs_set(pmac.y.high_limit_travel, 30, group=group)
|
|
94
|
+
yield from bps.abs_set(pmac.y.low_limit_travel, -30, group=group)
|
|
95
|
+
yield from bps.abs_set(pmac.z.high_limit_travel, 5.1, group=group)
|
|
96
|
+
yield from bps.abs_set(pmac.z.low_limit_travel, -4.1, group=group)
|
|
97
|
+
caput(CHIPTYPE_PV, 1) # chip type
|
|
98
|
+
caput(MAPTYPE_PV, 0) # map type
|
|
99
|
+
caput(NUM_EXPOSURES_PV, 1) # num exposures
|
|
100
|
+
caput(PUMP_REPEAT_PV, 0) # pump repeat
|
|
78
101
|
caput(pv.me14e_filepath, "test")
|
|
79
102
|
caput(pv.me14e_chip_name, "albion")
|
|
80
103
|
caput(pv.me14e_dcdetdist, 1480)
|
|
81
104
|
caput(pv.me14e_exptime, 0.01)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
# Define detector in use
|
|
88
|
-
logger.debug("Define detector in use.")
|
|
89
|
-
det_type = get_detector_type()
|
|
105
|
+
yield from bps.abs_set(pmac.enc_reset, EncReset.ENC5, group=group)
|
|
106
|
+
yield from bps.abs_set(pmac.enc_reset, EncReset.ENC6, group=group)
|
|
107
|
+
yield from bps.abs_set(pmac.enc_reset, EncReset.ENC7, group=group)
|
|
108
|
+
yield from bps.abs_set(pmac.enc_reset, EncReset.ENC8, group=group)
|
|
90
109
|
|
|
91
110
|
caput(pv.pilat_cbftemplate, 0)
|
|
92
111
|
|
|
@@ -98,95 +117,76 @@ def initialise():
|
|
|
98
117
|
sys.stdout.write(".")
|
|
99
118
|
sys.stdout.flush()
|
|
100
119
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
logger.info("Initialisation Complete")
|
|
120
|
+
logger.info("Initialisation of the stages complete")
|
|
121
|
+
yield from bps.wait(group=group)
|
|
105
122
|
|
|
106
123
|
|
|
107
124
|
@log.log_on_entry
|
|
108
|
-
def write_parameter_file(
|
|
109
|
-
|
|
125
|
+
def write_parameter_file(
|
|
126
|
+
detector_stage: DetectorMotion,
|
|
127
|
+
) -> MsgGenerator:
|
|
128
|
+
param_path: Path = PARAM_FILE_PATH_FT
|
|
129
|
+
# Create directory if it doesn't yet exist.
|
|
110
130
|
param_path.mkdir(parents=True, exist_ok=True)
|
|
111
131
|
|
|
112
|
-
|
|
113
|
-
logger.info("Writing Parameter File: %s" % (param_path / param_fid).as_posix())
|
|
114
|
-
|
|
115
|
-
visit = caget(pv.me14e_gp100)
|
|
132
|
+
logger.info(f"Writing Parameter File: {(param_path / PARAM_FILE_NAME).as_posix()}")
|
|
116
133
|
|
|
117
134
|
filename = caget(pv.me14e_chip_name)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
pump_repeat = caget(pv.me14e_gp4)
|
|
123
|
-
pumpexptime = caget(pv.me14e_gp103)
|
|
124
|
-
pumpdelay = caget(pv.me14e_gp110)
|
|
125
|
-
prepumpexptime = caget(pv.me14e_gp109)
|
|
126
|
-
n_exposures = caget(pv.me14e_gp3)
|
|
127
|
-
map_type = caget(pv.me14e_gp2)
|
|
128
|
-
chip_type = caget(pv.me14e_gp1)
|
|
129
|
-
det_type = get_detector_type()
|
|
130
|
-
|
|
131
|
-
checkerpattern = bool(caget(pv.me14e_gp111))
|
|
135
|
+
det_type = yield from get_detector_type(detector_stage)
|
|
136
|
+
chip_params = get_chip_format(ChipType(int(caget(CHIPTYPE_PV))))
|
|
137
|
+
map_type = int(caget(MAPTYPE_PV))
|
|
138
|
+
pump_repeat = int(caget(PUMP_REPEAT_PV))
|
|
132
139
|
|
|
133
140
|
# If file name ends in a digit this causes processing/pilatus pain.
|
|
134
141
|
# Append an underscore
|
|
135
|
-
if det_type
|
|
142
|
+
if isinstance(det_type, Pilatus):
|
|
136
143
|
caput(pv.pilat_cbftemplate, 0)
|
|
137
144
|
m = re.search(r"\d+$", filename)
|
|
138
145
|
if m is not None:
|
|
139
146
|
# Note for future reference. Appending underscore causes more hassle and
|
|
140
147
|
# high probability of users accidentally overwriting data. Use a dash
|
|
141
148
|
filename = filename + "-"
|
|
142
|
-
logger.
|
|
143
|
-
"Requested filename ends in a number. Appended dash:
|
|
149
|
+
logger.debug(
|
|
150
|
+
f"Requested filename ends in a number. Appended dash: {filename}"
|
|
144
151
|
)
|
|
145
152
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
logger.info(
|
|
169
|
-
logger.info(
|
|
170
|
-
|
|
171
|
-
logger.info(f"map_type: {map_type}")
|
|
172
|
-
logger.info(f"pump_repeat: {pump_repeat}")
|
|
173
|
-
logger.info(f"pumpexptime: {pumpexptime}")
|
|
174
|
-
logger.info(f"pumpdelay: {pumpdelay}")
|
|
175
|
-
logger.info(f"prepumpexptime: {prepumpexptime}")
|
|
176
|
-
logger.info(f"detector type: {str(det_type)}")
|
|
177
|
-
logger.info(f"checker pattern: {checkerpattern}")
|
|
153
|
+
params_dict = {
|
|
154
|
+
"visit": log._read_visit_directory_from_file().as_posix(), # noqa
|
|
155
|
+
"directory": caget(pv.me14e_filepath),
|
|
156
|
+
"filename": filename,
|
|
157
|
+
"exposure_time_s": caget(pv.me14e_exptime),
|
|
158
|
+
"detector_distance_mm": caget(pv.me14e_dcdetdist),
|
|
159
|
+
"detector_name": str(det_type),
|
|
160
|
+
"num_exposures": int(caget(NUM_EXPOSURES_PV)),
|
|
161
|
+
"chip": chip_params.dict(),
|
|
162
|
+
"map_type": map_type,
|
|
163
|
+
"pump_repeat": pump_repeat,
|
|
164
|
+
"checker_pattern": bool(caget(pv.me14e_gp111)),
|
|
165
|
+
"laser_dwell_s": float(caget(pv.me14e_gp103)) if pump_repeat != 0 else None,
|
|
166
|
+
"laser_delay_s": float(caget(pv.me14e_gp110)) if pump_repeat != 0 else None,
|
|
167
|
+
"pre_pump_exposure_s": float(caget(pv.me14e_gp109))
|
|
168
|
+
if pump_repeat != 0
|
|
169
|
+
else None,
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
with open(param_path / PARAM_FILE_NAME, "w") as f:
|
|
173
|
+
json.dump(params_dict, f, indent=4)
|
|
174
|
+
|
|
175
|
+
logger.info("Information written to file \n")
|
|
176
|
+
logger.info(pformat(params_dict))
|
|
177
|
+
|
|
178
178
|
if map_type == MappingType.Full:
|
|
179
179
|
# This step creates some header files (.addr, .spec), containing the parameters,
|
|
180
180
|
# that are only needed when full mapping is in use.
|
|
181
|
-
logger.
|
|
181
|
+
logger.info("Full mapping in use. Running start up now.")
|
|
182
182
|
startup.run()
|
|
183
|
+
yield from bps.null()
|
|
183
184
|
|
|
184
185
|
|
|
185
|
-
def scrape_pvar_file(fid: str, pvar_dir: Path
|
|
186
|
+
def scrape_pvar_file(fid: str, pvar_dir: Path = PVAR_FILE_PATH):
|
|
186
187
|
block_start_list = []
|
|
187
|
-
pvar_dir = _coerce_to_path(pvar_dir)
|
|
188
188
|
|
|
189
|
-
with open(pvar_dir / fid
|
|
189
|
+
with open(pvar_dir / fid) as f:
|
|
190
190
|
lines = f.readlines()
|
|
191
191
|
for line in lines:
|
|
192
192
|
line = line.rstrip()
|
|
@@ -210,40 +210,40 @@ def scrape_pvar_file(fid: str, pvar_dir: Path | str = PVAR_FILE_PATH):
|
|
|
210
210
|
@log.log_on_entry
|
|
211
211
|
def define_current_chip(
|
|
212
212
|
chipid: str = "oxford",
|
|
213
|
-
|
|
214
|
-
):
|
|
213
|
+
pmac: PMAC = inject("pmac"),
|
|
214
|
+
) -> MsgGenerator:
|
|
215
|
+
setup_logging()
|
|
215
216
|
logger.debug("Run load stock map for just the first block")
|
|
216
|
-
load_stock_map("Just The First Block")
|
|
217
|
+
yield from load_stock_map("Just The First Block")
|
|
217
218
|
"""
|
|
218
219
|
Not sure what this is for:
|
|
219
220
|
print 'Setting Mapping Type to Lite'
|
|
220
221
|
caput(pv.me14e_gp2, 1)
|
|
221
222
|
"""
|
|
222
|
-
chip_type = int(caget(
|
|
223
|
-
logger.info("Chip type
|
|
223
|
+
chip_type = int(caget(CHIPTYPE_PV))
|
|
224
|
+
logger.info(f"Chip type:{chip_type} Chipid:{chipid}")
|
|
224
225
|
if chipid == "oxford":
|
|
225
|
-
caput(
|
|
226
|
-
|
|
227
|
-
param_path = _coerce_to_path(param_path)
|
|
226
|
+
caput(CHIPTYPE_PV, 0)
|
|
228
227
|
|
|
229
|
-
with open(
|
|
230
|
-
logger.info("Opening
|
|
228
|
+
with open(PVAR_FILE_PATH / f"{chipid}.pvar") as f:
|
|
229
|
+
logger.info(f"Opening {chipid}.pvar")
|
|
231
230
|
for line in f.readlines():
|
|
232
231
|
if line.startswith("#"):
|
|
233
232
|
continue
|
|
234
233
|
line_from_file = line.rstrip("\n")
|
|
235
|
-
logger.info("
|
|
236
|
-
|
|
234
|
+
logger.info(f"{line_from_file}")
|
|
235
|
+
yield from bps.abs_set(pmac.pmac_string, line_from_file)
|
|
237
236
|
|
|
238
237
|
|
|
239
238
|
@log.log_on_entry
|
|
240
|
-
def save_screen_map(
|
|
241
|
-
|
|
239
|
+
def save_screen_map() -> MsgGenerator:
|
|
240
|
+
setup_logging()
|
|
241
|
+
litemap_path: Path = LITEMAP_PATH
|
|
242
242
|
litemap_path.mkdir(parents=True, exist_ok=True)
|
|
243
243
|
|
|
244
|
-
logger.info("Saving
|
|
244
|
+
logger.info(f"Saving {litemap_path.as_posix()} currentchip.map")
|
|
245
245
|
with open(litemap_path / "currentchip.map", "w") as f:
|
|
246
|
-
logger.
|
|
246
|
+
logger.debug("Printing only blocks with block_val == 1")
|
|
247
247
|
for x in range(1, 82):
|
|
248
248
|
block_str = "ME14E-MO-IOC-01:GP%i" % (x + 10)
|
|
249
249
|
block_val = int(caget(block_str))
|
|
@@ -251,23 +251,23 @@ def save_screen_map(litemap_path: Path | str = LITEMAP_PATH):
|
|
|
251
251
|
logger.info("%s %d" % (block_str, block_val))
|
|
252
252
|
line = "%02dstatus P3%02d1 \t%s\n" % (x, x, block_val)
|
|
253
253
|
f.write(line)
|
|
254
|
-
|
|
254
|
+
yield from bps.null()
|
|
255
255
|
|
|
256
256
|
|
|
257
257
|
@log.log_on_entry
|
|
258
|
-
def upload_parameters(
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
)
|
|
262
|
-
|
|
263
|
-
if chipid == "oxford":
|
|
264
|
-
caput(pv.me14e_gp1, 0)
|
|
265
|
-
width = 8
|
|
266
|
-
litemap_path = _coerce_to_path(litemap_path)
|
|
258
|
+
def upload_parameters(pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
259
|
+
setup_logging()
|
|
260
|
+
logger.info("Uploading Parameters for Oxford Chip to the GeoBrick")
|
|
261
|
+
caput(CHIPTYPE_PV, 0)
|
|
262
|
+
width = 8
|
|
267
263
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
264
|
+
map_file: Path = LITEMAP_PATH / "currentchip.map"
|
|
265
|
+
if not map_file.exists():
|
|
266
|
+
raise FileNotFoundError(f"The file {map_file} has not yet been created")
|
|
267
|
+
|
|
268
|
+
with open(map_file) as f:
|
|
269
|
+
logger.info(f"Chipid {ChipType.Oxford}")
|
|
270
|
+
logger.info(f"width {width}")
|
|
271
271
|
x = 1
|
|
272
272
|
for line in f.readlines()[: width**2]:
|
|
273
273
|
cols = line.split()
|
|
@@ -285,33 +285,42 @@ def upload_parameters(
|
|
|
285
285
|
x = 1
|
|
286
286
|
else:
|
|
287
287
|
x += 1
|
|
288
|
-
|
|
288
|
+
yield from bps.abs_set(pmac.pmac_string, s, wait=True)
|
|
289
289
|
sleep(0.02)
|
|
290
290
|
|
|
291
291
|
logger.warning("Automatic Setting Mapping Type to Lite has been disabled")
|
|
292
292
|
logger.debug("Upload parameters done.")
|
|
293
|
+
yield from bps.null()
|
|
293
294
|
|
|
294
295
|
|
|
295
296
|
@log.log_on_entry
|
|
296
|
-
def upload_full(
|
|
297
|
-
|
|
297
|
+
def upload_full(pmac: PMAC | None = None) -> MsgGenerator:
|
|
298
|
+
setup_logging()
|
|
299
|
+
if not pmac:
|
|
300
|
+
pmac = i24.pmac()
|
|
298
301
|
|
|
299
|
-
|
|
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:
|
|
300
306
|
f = fh.readlines()
|
|
301
307
|
|
|
302
|
-
for
|
|
308
|
+
for _i in range(len(f) // 2):
|
|
303
309
|
pmac_list = []
|
|
304
|
-
for
|
|
310
|
+
for _j in range(2):
|
|
305
311
|
pmac_list.append(f.pop(0).rstrip("\n"))
|
|
306
312
|
writeline = " ".join(pmac_list)
|
|
307
|
-
logger.info("
|
|
308
|
-
|
|
309
|
-
sleep(0.02)
|
|
313
|
+
logger.info(f"{writeline}")
|
|
314
|
+
yield from bps.abs_set(pmac.pmac_string, writeline, wait=True)
|
|
315
|
+
yield from bps.sleep(0.02)
|
|
310
316
|
logger.debug("Upload fullmap done")
|
|
317
|
+
yield from bps.null()
|
|
311
318
|
|
|
312
319
|
|
|
313
320
|
@log.log_on_entry
|
|
314
|
-
def load_stock_map(map_choice: str = "clear"):
|
|
321
|
+
def load_stock_map(map_choice: str = "clear") -> MsgGenerator:
|
|
322
|
+
# TODO See https://github.com/DiamondLightSource/mx_bluesky/issues/122
|
|
323
|
+
setup_logging()
|
|
315
324
|
logger.info("Adjusting Lite Map EDM Screen")
|
|
316
325
|
logger.debug("Please wait, adjusting lite map")
|
|
317
326
|
#
|
|
@@ -406,7 +415,7 @@ def load_stock_map(map_choice: str = "clear"):
|
|
|
406
415
|
28,
|
|
407
416
|
27,
|
|
408
417
|
10,
|
|
409
|
-
] + x77
|
|
418
|
+
] + x77 # noqa
|
|
410
419
|
x44 = [22, 21, 20, 19, 30, 35, 46, 45, 44, 43, 38, 27, 28, 29, 36, 37]
|
|
411
420
|
x49 = [x + 1 for x in range(49)]
|
|
412
421
|
x66 = [
|
|
@@ -496,24 +505,26 @@ def load_stock_map(map_choice: str = "clear"):
|
|
|
496
505
|
map_dict["half1"] = half1
|
|
497
506
|
map_dict["half2"] = half2
|
|
498
507
|
|
|
499
|
-
logger.info("Clearing GP 10-74")
|
|
508
|
+
logger.info("Clearing GP 10-74") # Actually 11-44
|
|
500
509
|
for i in range(1, 65):
|
|
501
510
|
pvar = "ME14E-MO-IOC-01:GP" + str(i + 10)
|
|
502
511
|
caput(pvar, 0)
|
|
503
512
|
sys.stdout.write(".")
|
|
504
513
|
sys.stdout.flush()
|
|
505
514
|
logger.info("Map cleared")
|
|
506
|
-
logger.info("Loading Map Choice
|
|
515
|
+
logger.info(f"Loading Map Choice {map_choice}")
|
|
507
516
|
for i in map_dict[map_choice]:
|
|
508
517
|
pvar = "ME14E-MO-IOC-01:GP" + str(i + 10)
|
|
509
518
|
caput(pvar, 1)
|
|
510
519
|
logger.debug("Load stock map done.")
|
|
520
|
+
yield from bps.null()
|
|
511
521
|
|
|
512
522
|
|
|
513
523
|
@log.log_on_entry
|
|
514
|
-
def load_lite_map(
|
|
524
|
+
def load_lite_map() -> MsgGenerator:
|
|
525
|
+
setup_logging()
|
|
515
526
|
logger.debug("Run load stock map with 'clear' setting.")
|
|
516
|
-
load_stock_map("clear")
|
|
527
|
+
yield from load_stock_map("clear")
|
|
517
528
|
# fmt: off
|
|
518
529
|
# 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
|
|
519
530
|
oxford_block_dict = { # noqa: F841
|
|
@@ -527,7 +538,7 @@ def load_lite_map(litemap_path: Path | str = LITEMAP_PATH):
|
|
|
527
538
|
'H1': '64', 'H2': '63', 'H3': '62', 'H4': '61', 'H5': '60', 'H6': '59', 'H7': '58', 'H8': '57',
|
|
528
539
|
}
|
|
529
540
|
# fmt: on
|
|
530
|
-
chip_type = int(caget(
|
|
541
|
+
chip_type = int(caget(CHIPTYPE_PV))
|
|
531
542
|
if chip_type in [ChipType.Oxford, ChipType.OxfordInner]:
|
|
532
543
|
logger.info("Oxford Block Order")
|
|
533
544
|
rows = ["A", "B", "C", "D", "E", "F", "G", "H"]
|
|
@@ -555,14 +566,14 @@ def load_lite_map(litemap_path: Path | str = LITEMAP_PATH):
|
|
|
555
566
|
label = "%02.d" % (lab_num + 1)
|
|
556
567
|
btn_names[button_name] = label
|
|
557
568
|
block_dict = btn_names
|
|
569
|
+
else:
|
|
570
|
+
raise ValueError(f"{chip_type=} unrecognised")
|
|
558
571
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
litemap_fid = str(caget(pv.me14e_gp5)) + ".lite"
|
|
572
|
+
litemap_fid = f"{caget(MAP_FILEPATH_PV)}.lite"
|
|
562
573
|
logger.info("Please wait, loading LITE map")
|
|
563
|
-
logger.
|
|
564
|
-
logger.info("Opening %s" % (
|
|
565
|
-
with open(
|
|
574
|
+
logger.debug("Loading Lite Map")
|
|
575
|
+
logger.info("Opening %s" % (LITEMAP_PATH / litemap_fid))
|
|
576
|
+
with open(LITEMAP_PATH / litemap_fid) as fh:
|
|
566
577
|
f = fh.readlines()
|
|
567
578
|
for line in f:
|
|
568
579
|
entry = line.split()
|
|
@@ -570,151 +581,140 @@ def load_lite_map(litemap_path: Path | str = LITEMAP_PATH):
|
|
|
570
581
|
yesno = entry[1]
|
|
571
582
|
block_num = block_dict[block_name]
|
|
572
583
|
pvar = "ME14E-MO-IOC-01:GP" + str(int(block_num) + 10)
|
|
573
|
-
logger.info("Block:
|
|
584
|
+
logger.info(f"Block: {block_name} \tScanned: {yesno} \tPVAR: {pvar}")
|
|
574
585
|
logger.debug("Load lite map done")
|
|
586
|
+
yield from bps.null()
|
|
575
587
|
|
|
576
588
|
|
|
577
589
|
@log.log_on_entry
|
|
578
|
-
def load_full_map(
|
|
579
|
-
(
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
)
|
|
587
|
-
fullmap_path = _coerce_to_path(fullmap_path)
|
|
588
|
-
|
|
589
|
-
fullmap_fid = fullmap_path / f"{str(caget(pv.me14e_gp5))}.spec"
|
|
590
|
-
logger.info("Opening %s" % fullmap_fid)
|
|
591
|
-
mapping.plot_file(fullmap_fid, chip_type)
|
|
592
|
-
mapping.convert_chip_to_hex(fullmap_fid, chip_type)
|
|
593
|
-
shutil.copy2(fullmap_fid.with_suffix(".full"), fullmap_path / "currentchip.full")
|
|
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")
|
|
594
599
|
logger.info(
|
|
595
|
-
"Copying
|
|
596
|
-
|
|
600
|
+
"Copying {} to {}".format(
|
|
601
|
+
fullmap_fid.with_suffix(".full"), FULLMAP_PATH / "currentchip.full"
|
|
602
|
+
)
|
|
597
603
|
)
|
|
598
604
|
logger.debug("Load full map done")
|
|
605
|
+
yield from bps.null()
|
|
599
606
|
|
|
600
607
|
|
|
601
608
|
@log.log_on_entry
|
|
602
|
-
def moveto(place: str = "origin"):
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
caput(pv.me14e_stage_x, 0.0)
|
|
614
|
-
caput(pv.me14e_stage_y, 0.0)
|
|
615
|
-
if place == "f1":
|
|
616
|
-
caput(pv.me14e_stage_x, 25.40)
|
|
617
|
-
caput(pv.me14e_stage_y, 0.0)
|
|
618
|
-
if place == "f2":
|
|
619
|
-
caput(pv.me14e_stage_x, 0.0)
|
|
620
|
-
caput(pv.me14e_stage_y, 25.40)
|
|
621
|
-
|
|
622
|
-
elif chip_type == ChipType.OxfordInner:
|
|
623
|
-
logger.info("Oxford Inner Move")
|
|
624
|
-
if place == "origin":
|
|
625
|
-
caput(pv.me14e_stage_x, 0.0)
|
|
626
|
-
caput(pv.me14e_stage_y, 0.0)
|
|
627
|
-
if place == "f1":
|
|
628
|
-
caput(pv.me14e_stage_x, 24.60)
|
|
629
|
-
caput(pv.me14e_stage_y, 0.0)
|
|
630
|
-
if place == "f2":
|
|
631
|
-
caput(pv.me14e_stage_x, 0.0)
|
|
632
|
-
caput(pv.me14e_stage_y, 24.60)
|
|
633
|
-
|
|
634
|
-
elif chip_type == ChipType.Custom:
|
|
635
|
-
logger.info("Custom Chip Move")
|
|
636
|
-
if place == "origin":
|
|
637
|
-
caput(pv.me14e_stage_x, 0.0)
|
|
638
|
-
caput(pv.me14e_stage_y, 0.0)
|
|
639
|
-
if place == "f1":
|
|
640
|
-
caput(pv.me14e_stage_x, 25.40)
|
|
641
|
-
caput(pv.me14e_stage_y, 0.0)
|
|
642
|
-
if place == "f2":
|
|
643
|
-
caput(pv.me14e_stage_x, 0.0)
|
|
644
|
-
caput(pv.me14e_stage_y, 25.40)
|
|
645
|
-
|
|
646
|
-
else:
|
|
609
|
+
def moveto(place: str = "origin", pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
610
|
+
setup_logging()
|
|
611
|
+
logger.info(f"Move to: {place}")
|
|
612
|
+
if place == Fiducials.zero:
|
|
613
|
+
logger.info("Chip aspecific move.")
|
|
614
|
+
yield from bps.trigger(pmac.to_xyz_zero)
|
|
615
|
+
return
|
|
616
|
+
|
|
617
|
+
chip_type = ChipType(int(caget(CHIPTYPE_PV)))
|
|
618
|
+
logger.info(f"Chip type is {chip_type}")
|
|
619
|
+
if chip_type not in list(ChipType):
|
|
647
620
|
logger.warning("Unknown chip_type move")
|
|
621
|
+
return
|
|
622
|
+
|
|
623
|
+
logger.info(f"{str(chip_type)} Move")
|
|
624
|
+
chip_move = CHIP_MOVES[chip_type]
|
|
625
|
+
|
|
626
|
+
if place == Fiducials.origin:
|
|
627
|
+
yield from bps.mv(pmac.x, 0.0, pmac.y, 0.0)
|
|
628
|
+
if place == Fiducials.fid1:
|
|
629
|
+
yield from bps.mv(pmac.x, chip_move, pmac.y, 0.0)
|
|
630
|
+
if place == Fiducials.fid2:
|
|
631
|
+
yield from bps.mv(pmac.x, 0.0, pmac.y, chip_move)
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
@log.log_on_entry
|
|
635
|
+
def moveto_preset(
|
|
636
|
+
place: str,
|
|
637
|
+
pmac: PMAC = inject("pmac"),
|
|
638
|
+
beamstop: Beamstop = inject("beamstop"),
|
|
639
|
+
backlight: DualBacklight = inject("backlight"),
|
|
640
|
+
det_stage: DetectorMotion = inject("detector_motion"),
|
|
641
|
+
) -> MsgGenerator:
|
|
642
|
+
setup_logging()
|
|
648
643
|
|
|
649
644
|
# Non Chip Specific Move
|
|
650
645
|
if place == "zero":
|
|
651
|
-
logger.info("Moving to
|
|
652
|
-
|
|
646
|
+
logger.info(f"Moving to {place}")
|
|
647
|
+
yield from bps.trigger(pmac.to_xyz_zero)
|
|
653
648
|
|
|
654
649
|
elif place == "load_position":
|
|
655
650
|
logger.info("load position")
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
651
|
+
yield from bps.abs_set(
|
|
652
|
+
beamstop.pos_select, BeamstopPositions.ROBOT, group=place
|
|
653
|
+
)
|
|
654
|
+
yield from bps.abs_set(backlight, BacklightPositions.OUT, group=place)
|
|
655
|
+
yield from bps.abs_set(det_stage.z, 1300, group=place)
|
|
656
|
+
yield from bps.wait(group=place)
|
|
659
657
|
|
|
660
658
|
elif place == "collect_position":
|
|
661
659
|
logger.info("collect position")
|
|
662
660
|
caput(pv.me14e_filter, 20)
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
661
|
+
yield from bps.mv(pmac.x, 0.0, pmac.y, 0.0, pmac.z, 0.0)
|
|
662
|
+
yield from bps.abs_set(
|
|
663
|
+
beamstop.pos_select, BeamstopPositions.DATA_COLLECTION, group=place
|
|
664
|
+
)
|
|
665
|
+
yield from bps.abs_set(backlight, BacklightPositions.IN, group=place)
|
|
666
|
+
yield from bps.wait(group=place)
|
|
668
667
|
|
|
669
668
|
elif place == "microdrop_position":
|
|
670
669
|
logger.info("microdrop align position")
|
|
671
|
-
|
|
672
|
-
caput(pv.me14e_stage_y, -7.8)
|
|
673
|
-
caput(pv.me14e_stage_z, 0.0)
|
|
670
|
+
yield from bps.mv(pmac.x, 6.0, pmac.y, -7.8, pmac.z, 0.0)
|
|
674
671
|
|
|
675
|
-
|
|
672
|
+
|
|
673
|
+
@log.log_on_entry
|
|
674
|
+
def laser_control(laser_setting: str, pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
675
|
+
setup_logging()
|
|
676
|
+
logger.info(f"Move to: {laser_setting}")
|
|
677
|
+
if laser_setting == "laser1on": # these are in laser edm
|
|
676
678
|
logger.info("Laser 1 /BNC2 shutter is open")
|
|
677
679
|
# Use M712 = 0 if triggering on falling edge. M712 =1 if on rising edge
|
|
678
680
|
# Be sure to also change laser1off
|
|
679
681
|
# caput(pv.me14e_pmac_str, ' M712=0 M711=1')
|
|
680
|
-
|
|
682
|
+
yield from bps.abs_set(pmac.laser, LaserSettings.LASER_1_ON, wait=True)
|
|
681
683
|
|
|
682
|
-
elif
|
|
684
|
+
elif laser_setting == "laser1off":
|
|
683
685
|
logger.info("Laser 1 shutter is closed")
|
|
684
|
-
|
|
686
|
+
yield from bps.abs_set(pmac.laser, LaserSettings.LASER_1_OFF, wait=True)
|
|
685
687
|
|
|
686
|
-
elif
|
|
688
|
+
elif laser_setting == "laser2on":
|
|
687
689
|
logger.info("Laser 2 / BNC3 shutter is open")
|
|
688
|
-
|
|
690
|
+
yield from bps.abs_set(pmac.laser, LaserSettings.LASER_2_ON, wait=True)
|
|
689
691
|
|
|
690
|
-
elif
|
|
692
|
+
elif laser_setting == "laser2off":
|
|
691
693
|
logger.info("Laser 2 shutter is closed")
|
|
692
|
-
|
|
694
|
+
yield from bps.abs_set(pmac.laser, LaserSettings.LASER_2_OFF, wait=True)
|
|
693
695
|
|
|
694
|
-
elif
|
|
696
|
+
elif laser_setting == "laser1burn":
|
|
695
697
|
led_burn_time = caget(pv.me14e_gp103)
|
|
696
698
|
logger.info("Laser 1 on")
|
|
697
|
-
logger.info("Burn time is
|
|
698
|
-
|
|
699
|
-
sleep(
|
|
699
|
+
logger.info(f"Burn time is {led_burn_time} s")
|
|
700
|
+
yield from bps.abs_set(pmac.laser, LaserSettings.LASER_1_ON, wait=True)
|
|
701
|
+
yield from bps.sleep(led_burn_time)
|
|
700
702
|
logger.info("Laser 1 off")
|
|
701
|
-
|
|
703
|
+
yield from bps.abs_set(pmac.laser, LaserSettings.LASER_1_OFF, wait=True)
|
|
702
704
|
|
|
703
|
-
elif
|
|
705
|
+
elif laser_setting == "laser2burn":
|
|
704
706
|
led_burn_time = caget(pv.me14e_gp109)
|
|
705
707
|
logger.info("Laser 2 on")
|
|
706
|
-
logger.info("burntime
|
|
707
|
-
|
|
708
|
-
sleep(
|
|
708
|
+
logger.info(f"burntime {led_burn_time} s")
|
|
709
|
+
yield from bps.abs_set(pmac.laser, LaserSettings.LASER_2_ON, wait=True)
|
|
710
|
+
yield from bps.sleep(led_burn_time)
|
|
709
711
|
logger.info("Laser 2 off")
|
|
710
|
-
|
|
712
|
+
yield from bps.abs_set(pmac.laser, LaserSettings.LASER_2_OFF, wait=True)
|
|
711
713
|
|
|
712
714
|
|
|
713
715
|
@log.log_on_entry
|
|
714
|
-
def scrape_mtr_directions(
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
with open(param_path / "motor_direction.txt", "r") as f:
|
|
716
|
+
def scrape_mtr_directions(motor_file_path: Path = CS_FILES_PATH):
|
|
717
|
+
with open(motor_file_path / "motor_direction.txt") as f:
|
|
718
718
|
lines = f.readlines()
|
|
719
719
|
mtr1_dir, mtr2_dir, mtr3_dir = 1.0, 1.0, 1.0
|
|
720
720
|
for line in lines:
|
|
@@ -726,62 +726,57 @@ def scrape_mtr_directions(param_path: Path | str = CS_FILES_PATH):
|
|
|
726
726
|
mtr3_dir = float(line.split("=")[1])
|
|
727
727
|
else:
|
|
728
728
|
continue
|
|
729
|
-
logger.
|
|
729
|
+
logger.debug(f"mt1_dir {mtr1_dir} mtr2_dir {mtr2_dir} mtr3_dir {mtr3_dir}")
|
|
730
730
|
return mtr1_dir, mtr2_dir, mtr3_dir
|
|
731
731
|
|
|
732
732
|
|
|
733
733
|
@log.log_on_entry
|
|
734
|
-
def fiducial(point: int = 1,
|
|
734
|
+
def fiducial(point: int = 1, pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
735
|
+
setup_logging()
|
|
735
736
|
scale = 10000.0 # noqa: F841
|
|
736
|
-
param_path = _coerce_to_path(param_path)
|
|
737
|
-
|
|
738
|
-
mtr1_dir, mtr2_dir, mtr3_dir = scrape_mtr_directions(param_path)
|
|
739
737
|
|
|
740
|
-
|
|
741
|
-
rbv_2 = float(caget(pv.me14e_stage_y + ".RBV"))
|
|
742
|
-
rbv_3 = float(caget(pv.me14e_stage_z + ".RBV"))
|
|
738
|
+
mtr1_dir, mtr2_dir, mtr3_dir = scrape_mtr_directions(CS_FILES_PATH)
|
|
743
739
|
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
740
|
+
rbv_1 = yield from bps.rd(pmac.x.user_readback)
|
|
741
|
+
rbv_2 = yield from bps.rd(pmac.y.user_readback)
|
|
742
|
+
rbv_3 = yield from bps.rd(pmac.z.user_readback)
|
|
747
743
|
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
logger.info("Writing Fiducial File %s/fiducial_%s.txt" % (param_path, point))
|
|
744
|
+
output_param_path = PARAM_FILE_PATH_FT
|
|
745
|
+
output_param_path.mkdir(parents=True, exist_ok=True)
|
|
746
|
+
logger.info(f"Writing Fiducial File {output_param_path}/fiducial_{point}.txt")
|
|
753
747
|
logger.info("MTR\tRBV\tRAW\tCorr\tf_value")
|
|
754
|
-
logger.info("MTR1\t%1.4f\t%i
|
|
755
|
-
logger.info("MTR2\t%1.4f\t%i
|
|
756
|
-
logger.info("MTR3\t%1.4f\t%i
|
|
757
|
-
|
|
758
|
-
with open(
|
|
759
|
-
f.write("MTR\tRBV\
|
|
760
|
-
f.write("MTR1\t%1.4f\t%i\
|
|
761
|
-
f.write("MTR2\t%1.4f\t%i\
|
|
762
|
-
f.write("MTR3\t%1.4f\t%i
|
|
748
|
+
logger.info("MTR1\t%1.4f\t%i" % (rbv_1, mtr1_dir))
|
|
749
|
+
logger.info("MTR2\t%1.4f\t%i" % (rbv_2, mtr2_dir))
|
|
750
|
+
logger.info("MTR3\t%1.4f\t%i" % (rbv_3, mtr3_dir))
|
|
751
|
+
|
|
752
|
+
with open(output_param_path / f"fiducial_{point}.txt", "w") as f:
|
|
753
|
+
f.write("MTR\tRBV\tCorr\n")
|
|
754
|
+
f.write("MTR1\t%1.4f\t%i\n" % (rbv_1, mtr1_dir))
|
|
755
|
+
f.write("MTR2\t%1.4f\t%i\n" % (rbv_2, mtr2_dir))
|
|
756
|
+
f.write("MTR3\t%1.4f\t%i" % (rbv_3, mtr3_dir))
|
|
763
757
|
logger.info(f"Fiducial {point} set.")
|
|
758
|
+
yield from bps.null()
|
|
764
759
|
|
|
765
760
|
|
|
766
|
-
def scrape_mtr_fiducials(
|
|
767
|
-
param_path =
|
|
768
|
-
|
|
769
|
-
with open(param_path / f"fiducial_{point}.txt"
|
|
761
|
+
def scrape_mtr_fiducials(
|
|
762
|
+
point: int, param_path: Path = PARAM_FILE_PATH_FT
|
|
763
|
+
) -> tuple[float, float, float]:
|
|
764
|
+
with open(param_path / f"fiducial_{point}.txt") as f:
|
|
770
765
|
f_lines = f.readlines()[1:]
|
|
771
|
-
f_x = float(f_lines[0].rsplit()[
|
|
772
|
-
f_y = float(f_lines[1].rsplit()[
|
|
773
|
-
f_z = float(f_lines[2].rsplit()[
|
|
766
|
+
f_x = float(f_lines[0].rsplit()[1])
|
|
767
|
+
f_y = float(f_lines[1].rsplit()[1])
|
|
768
|
+
f_z = float(f_lines[2].rsplit()[1])
|
|
774
769
|
return f_x, f_y, f_z
|
|
775
770
|
|
|
776
771
|
|
|
777
772
|
@log.log_on_entry
|
|
778
|
-
def cs_maker():
|
|
773
|
+
def cs_maker(pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
779
774
|
"""
|
|
780
775
|
Coordinate system.
|
|
781
776
|
|
|
782
777
|
Values for scalex, scaley, scalez, and skew, as well as the sign of
|
|
783
778
|
Sx, Sy, Sz are stored in a .json file and should be modified there.
|
|
784
|
-
Location of file: src/mx_bluesky/
|
|
779
|
+
Location of file: src/mx_bluesky/i24/serial/parameters/cs_maker.json
|
|
785
780
|
|
|
786
781
|
Theory
|
|
787
782
|
Rx: rotation about X-axis, pitch
|
|
@@ -805,24 +800,25 @@ def cs_maker():
|
|
|
805
800
|
This should be measured in situ prior to expriment, ie. measure by hand using
|
|
806
801
|
opposite and adjacent RBV after calibration of scale factors.
|
|
807
802
|
"""
|
|
808
|
-
|
|
803
|
+
setup_logging()
|
|
804
|
+
chip_type = int(caget(CHIPTYPE_PV))
|
|
809
805
|
fiducial_dict = {}
|
|
810
806
|
fiducial_dict[0] = [25.400, 25.400]
|
|
811
807
|
fiducial_dict[1] = [24.600, 24.600]
|
|
812
808
|
fiducial_dict[2] = [25.400, 25.400]
|
|
813
809
|
fiducial_dict[3] = [18.25, 18.25]
|
|
814
|
-
logger.info("Chip type is
|
|
810
|
+
logger.info(f"Chip type is {chip_type} with size {fiducial_dict[chip_type]}")
|
|
815
811
|
|
|
816
812
|
mtr1_dir, mtr2_dir, mtr3_dir = scrape_mtr_directions()
|
|
817
813
|
f1_x, f1_y, f1_z = scrape_mtr_fiducials(1)
|
|
818
814
|
f2_x, f2_y, f2_z = scrape_mtr_fiducials(2)
|
|
819
|
-
logger.info("mtr1 direction:
|
|
820
|
-
logger.info("mtr2 direction:
|
|
821
|
-
logger.info("mtr3 direction:
|
|
815
|
+
logger.info(f"mtr1 direction: {mtr1_dir}")
|
|
816
|
+
logger.info(f"mtr2 direction: {mtr2_dir}")
|
|
817
|
+
logger.info(f"mtr3 direction: {mtr3_dir}")
|
|
822
818
|
|
|
823
819
|
# Scale parameters saved in json file
|
|
824
820
|
try:
|
|
825
|
-
with open(CS_FILES_PATH / "cs_maker.json"
|
|
821
|
+
with open(CS_FILES_PATH / "cs_maker.json") as fh:
|
|
826
822
|
cs_info = json.load(fh)
|
|
827
823
|
except json.JSONDecodeError:
|
|
828
824
|
logger.error("Invalid JSON file.")
|
|
@@ -857,22 +853,22 @@ def cs_maker():
|
|
|
857
853
|
Sz1 = -1 * f1_y / fiducial_dict[chip_type][0]
|
|
858
854
|
Sz2 = f2_x / fiducial_dict[chip_type][1]
|
|
859
855
|
Sz = Sz_dir * ((Sz1 + Sz2) / 2)
|
|
860
|
-
Cz = np.sqrt(
|
|
861
|
-
logger.info("Sz1 ,
|
|
862
|
-
logger.info("Sz2 ,
|
|
863
|
-
logger.info("Sz ,
|
|
864
|
-
logger.info("Cz ,
|
|
856
|
+
Cz = np.sqrt(1 - Sz**2)
|
|
857
|
+
logger.info(f"Sz1 , {Sz1:1.4f}, {np.degrees(np.arcsin(Sz1)):1.4f}")
|
|
858
|
+
logger.info(f"Sz2 , {Sz2:1.4f}, {np.degrees(np.arcsin(Sz2)):1.4f}")
|
|
859
|
+
logger.info(f"Sz , {Sz:1.4f}, {np.degrees(np.arcsin(Sz)):1.4f}")
|
|
860
|
+
logger.info(f"Cz , {Cz:1.4f}, {np.degrees(np.arcsin(Cz)):1.4f}")
|
|
865
861
|
# Rotation Around Y
|
|
866
862
|
Sy = Sy_dir * f1_z / fiducial_dict[chip_type][0]
|
|
867
|
-
Cy = np.sqrt(
|
|
868
|
-
logger.info("Sy ,
|
|
869
|
-
logger.info("Cy ,
|
|
863
|
+
Cy = np.sqrt(1 - Sy**2)
|
|
864
|
+
logger.info(f"Sy , {Sy:1.4f}, {np.degrees(np.arcsin(Sy)):1.4f}")
|
|
865
|
+
logger.info(f"Cy , {Cy:1.4f}, {np.degrees(np.arcsin(Cy)):1.4f}")
|
|
870
866
|
# Rotation Around X
|
|
871
867
|
# If stages upsidedown (I24) change sign of Sx
|
|
872
868
|
Sx = Sx_dir * f2_z / fiducial_dict[chip_type][1]
|
|
873
|
-
Cx = np.sqrt(
|
|
874
|
-
logger.info("Sx ,
|
|
875
|
-
logger.info("Cx ,
|
|
869
|
+
Cx = np.sqrt(1 - Sx**2)
|
|
870
|
+
logger.info(f"Sx , {Sx:1.4f}, {np.degrees(np.arcsin(Sx)):1.4f}")
|
|
871
|
+
logger.info(f"Cx , {Cx:1.4f}, {np.degrees(np.arcsin(Cx)):1.4f}")
|
|
876
872
|
|
|
877
873
|
x1factor = mtr1_dir * scalex * (Cy * Cz)
|
|
878
874
|
y1factor = mtr2_dir * scaley * (-1.0 * Cx * Sz)
|
|
@@ -886,14 +882,14 @@ def cs_maker():
|
|
|
886
882
|
y3factor = mtr2_dir * scaley * ((Cx * Sy * Sz) + (Sx * Cz))
|
|
887
883
|
z3factor = mtr3_dir * scalez * (Cx * Cy)
|
|
888
884
|
|
|
889
|
-
logger.info("Skew being used is:
|
|
885
|
+
logger.info(f"Skew being used is: {skew:1.4f}")
|
|
890
886
|
s1 = np.degrees(np.arcsin(Sz1))
|
|
891
887
|
s2 = np.degrees(np.arcsin(Sz2))
|
|
892
888
|
rot = np.degrees(np.arcsin((Sz1 + Sz2) / 2))
|
|
893
889
|
calc_skew = (s1 - rot) - (s2 - rot)
|
|
894
|
-
logger.info("s1
|
|
895
|
-
logger.info("Calculated rotation from current fiducials is:
|
|
896
|
-
logger.info("Calculated Skew from current fiducials is:
|
|
890
|
+
logger.info(f"s1:{s1:1.4f} s2:{s2:1.4f} rot:{rot:1.4f}")
|
|
891
|
+
logger.info(f"Calculated rotation from current fiducials is: {rot:1.4f}")
|
|
892
|
+
logger.info(f"Calculated Skew from current fiducials is: {calc_skew:1.4f}")
|
|
897
893
|
logger.info("Calculated Skew has been known to have the wrong sign")
|
|
898
894
|
|
|
899
895
|
sinD = np.sin((skew / 2) * (np.pi / 180))
|
|
@@ -903,10 +899,10 @@ def cs_maker():
|
|
|
903
899
|
new_x2factor = (x2factor * cosD) + (y2factor * sinD)
|
|
904
900
|
new_y2factor = (x2factor * sinD) + (y2factor * cosD)
|
|
905
901
|
|
|
906
|
-
cs1 = "#1
|
|
907
|
-
cs2 = "#2
|
|
908
|
-
cs3 = "#3
|
|
909
|
-
logger.info("PMAC strings. \ncs1:
|
|
902
|
+
cs1 = f"#1->{new_x1factor:+1.3f}X{new_y1factor:+1.3f}Y{z1factor:+1.3f}Z"
|
|
903
|
+
cs2 = f"#2->{new_x2factor:+1.3f}X{new_y2factor:+1.3f}Y{z2factor:+1.3f}Z"
|
|
904
|
+
cs3 = f"#3->{x3factor:+1.3f}X{y3factor:+1.3f}Y{z3factor:+1.3f}Z"
|
|
905
|
+
logger.info(f"PMAC strings. \ncs1: {cs1} \ncs2: {cs2}cs3: {cs3}")
|
|
910
906
|
logger.info(
|
|
911
907
|
"""These next values should be 1.
|
|
912
908
|
This is the sum of the squares of the factors divided by their scale."""
|
|
@@ -914,52 +910,70 @@ def cs_maker():
|
|
|
914
910
|
sqfact1 = np.sqrt(x1factor**2 + y1factor**2 + z1factor**2) / scalex
|
|
915
911
|
sqfact2 = np.sqrt(x2factor**2 + y2factor**2 + z2factor**2) / scaley
|
|
916
912
|
sqfact3 = np.sqrt(x3factor**2 + y3factor**2 + z3factor**2) / scalez
|
|
917
|
-
logger.info("
|
|
918
|
-
logger.
|
|
919
|
-
|
|
913
|
+
logger.info(f"{sqfact1:1.4f} \n {sqfact2:1.4f} \n {sqfact3:1.4f}")
|
|
914
|
+
logger.debug("Long wait, please be patient")
|
|
915
|
+
yield from bps.trigger(pmac.to_xyz_zero)
|
|
920
916
|
sleep(2.5)
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
caput(pv.me14e_pmac_str, cs2)
|
|
924
|
-
caput(pv.me14e_pmac_str, cs3)
|
|
925
|
-
caput(pv.me14e_pmac_str, "!x0y0z0")
|
|
917
|
+
yield from set_pmac_strings_for_cs(pmac, {"cs1": cs1, "cs2": cs2, "cs3": cs3})
|
|
918
|
+
yield from bps.trigger(pmac.to_xyz_zero)
|
|
926
919
|
sleep(0.1)
|
|
927
|
-
|
|
920
|
+
yield from bps.trigger(pmac.home, wait=True)
|
|
928
921
|
sleep(0.1)
|
|
929
|
-
logger.
|
|
922
|
+
logger.debug(f"Chip_type is {chip_type}")
|
|
930
923
|
if chip_type == 0:
|
|
931
|
-
|
|
924
|
+
yield from bps.abs_set(pmac.pmac_string, "!x0.4y0.4", wait=True)
|
|
932
925
|
sleep(0.1)
|
|
933
|
-
|
|
926
|
+
yield from bps.trigger(pmac.home, wait=True)
|
|
934
927
|
else:
|
|
935
|
-
|
|
928
|
+
yield from bps.trigger(pmac.home, wait=True)
|
|
936
929
|
logger.debug("CSmaker done.")
|
|
930
|
+
yield from bps.null()
|
|
937
931
|
|
|
938
932
|
|
|
939
|
-
def cs_reset():
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
933
|
+
def cs_reset(pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
934
|
+
"""Used to clear CS when using Custom Chip"""
|
|
935
|
+
setup_logging()
|
|
936
|
+
cs1 = "#1->10000X+0Y+0Z"
|
|
937
|
+
cs2 = "#2->+0X-10000Y+0Z"
|
|
938
|
+
cs3 = "#3->0X+0Y-10000Z"
|
|
943
939
|
strg = "\n".join([cs1, cs2, cs3])
|
|
944
940
|
print(strg)
|
|
945
|
-
|
|
946
|
-
sleep(0.5)
|
|
947
|
-
caput(pv.me14e_pmac_str, cs1)
|
|
948
|
-
sleep(0.5)
|
|
949
|
-
caput(pv.me14e_pmac_str, cs2)
|
|
950
|
-
sleep(0.5)
|
|
951
|
-
caput(pv.me14e_pmac_str, cs3)
|
|
941
|
+
yield from set_pmac_strings_for_cs(pmac, {"cs1": cs1, "cs2": cs2, "cs3": cs3})
|
|
952
942
|
logger.debug("CSreset Done")
|
|
943
|
+
yield from bps.null()
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
def set_pmac_strings_for_cs(pmac: PMAC, cs_str: dict):
|
|
947
|
+
""" A plan to set the pmac_string for the (x,y,z) axes while making or resetting \
|
|
948
|
+
the coordinate system.
|
|
949
|
+
|
|
950
|
+
Args:
|
|
951
|
+
pmac (PMAC): PMAC device
|
|
952
|
+
cs_str (dict): A dictionary containing a string for each axis, in the format: \
|
|
953
|
+
{
|
|
954
|
+
"cs1": "#1->1X+0Y+0Z",
|
|
955
|
+
"cs2": "#2->...",
|
|
956
|
+
"cs3": "#3->...",
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
Note. On the PMAC the axes allocations are: #1 - X, #2 - Y, #3 - Z.
|
|
960
|
+
"""
|
|
961
|
+
yield from bps.abs_set(pmac.pmac_string, "&2", wait=True)
|
|
962
|
+
yield from bps.abs_set(pmac.pmac_string, cs_str["cs1"], wait=True)
|
|
963
|
+
yield from bps.abs_set(pmac.pmac_string, cs_str["cs2"], wait=True)
|
|
964
|
+
yield from bps.abs_set(pmac.pmac_string, cs_str["cs3"], wait=True)
|
|
953
965
|
|
|
954
966
|
|
|
955
967
|
@log.log_on_entry
|
|
956
|
-
def pumpprobe_calc():
|
|
968
|
+
def pumpprobe_calc() -> MsgGenerator:
|
|
969
|
+
# TODO See https://github.com/DiamondLightSource/mx_bluesky/issues/122
|
|
970
|
+
setup_logging()
|
|
957
971
|
logger.info("Calculate and show exposure and dwell time for each option.")
|
|
958
972
|
exptime = float(caget(pv.me14e_exptime))
|
|
959
973
|
pumpexptime = float(caget(pv.me14e_gp103))
|
|
960
974
|
movetime = 0.008
|
|
961
|
-
logger.info("X-ray exposure time
|
|
962
|
-
logger.info("Laser dwell time
|
|
975
|
+
logger.info(f"X-ray exposure time {exptime}")
|
|
976
|
+
logger.info(f"Laser dwell time {pumpexptime}")
|
|
963
977
|
repeat1 = 2 * 20 * (movetime + (pumpexptime + exptime) / 2)
|
|
964
978
|
repeat2 = 4 * 20 * (movetime + (pumpexptime + exptime) / 2)
|
|
965
979
|
repeat3 = 6 * 20 * (movetime + (pumpexptime + exptime) / 2)
|
|
@@ -974,17 +988,19 @@ def pumpprobe_calc():
|
|
|
974
988
|
):
|
|
975
989
|
rounded = round(repeat, 4)
|
|
976
990
|
caput(pv_name, rounded)
|
|
977
|
-
logger.info("Repeat (
|
|
978
|
-
# logger.info("repeat10 (%s): %s s" % (pv.me14e_gp108, round(repeat10, 4)))
|
|
991
|
+
logger.info(f"Repeat ({pv_name}): {rounded} s")
|
|
979
992
|
logger.debug("PP calculations done")
|
|
993
|
+
yield from bps.null()
|
|
980
994
|
|
|
981
995
|
|
|
982
996
|
@log.log_on_entry
|
|
983
|
-
def block_check():
|
|
997
|
+
def block_check(pmac: PMAC = inject("pmac")) -> MsgGenerator:
|
|
998
|
+
setup_logging()
|
|
999
|
+
# TODO See https://github.com/DiamondLightSource/mx_bluesky/issues/117
|
|
984
1000
|
caput(pv.me14e_gp9, 0)
|
|
985
1001
|
while True:
|
|
986
1002
|
if int(caget(pv.me14e_gp9)) == 0:
|
|
987
|
-
chip_type = int(caget(
|
|
1003
|
+
chip_type = int(caget(CHIPTYPE_PV))
|
|
988
1004
|
if chip_type == ChipType.Minichip:
|
|
989
1005
|
logger.info("Oxford mini chip in use.")
|
|
990
1006
|
block_start_list = scrape_pvar_file("minichip_oxford.pvar")
|
|
@@ -1003,72 +1019,17 @@ def block_check():
|
|
|
1003
1019
|
sleep(1.0)
|
|
1004
1020
|
break
|
|
1005
1021
|
block, x, y = entry
|
|
1006
|
-
logger.
|
|
1007
|
-
|
|
1022
|
+
logger.debug(f"Block: {block} -> (x={x} y={y})")
|
|
1023
|
+
yield from bps.abs_set(pmac.pmac_string, f"!x{x}y{y}", wait=True)
|
|
1008
1024
|
time.sleep(0.4)
|
|
1009
1025
|
else:
|
|
1010
1026
|
logger.warning("Block Check Aborted due to GP 9 not equalling 0")
|
|
1011
1027
|
break
|
|
1012
1028
|
break
|
|
1013
1029
|
logger.debug("Block check done")
|
|
1030
|
+
yield from bps.null()
|
|
1014
1031
|
|
|
1015
1032
|
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
subparsers = parser.add_subparsers(
|
|
1020
|
-
help="Choose command.",
|
|
1021
|
-
required=True,
|
|
1022
|
-
dest="sub-command",
|
|
1023
|
-
)
|
|
1024
|
-
parser_init = subparsers.add_parser(
|
|
1025
|
-
"initialise",
|
|
1026
|
-
)
|
|
1027
|
-
parser_init.set_defaults(func=initialise)
|
|
1028
|
-
parser_moveto = subparsers.add_parser(
|
|
1029
|
-
"moveto",
|
|
1030
|
-
)
|
|
1031
|
-
parser_moveto.add_argument("place", type=str)
|
|
1032
|
-
parser_moveto.set_defaults(func=moveto)
|
|
1033
|
-
parser_fid = subparsers.add_parser("fiducial")
|
|
1034
|
-
parser_fid.add_argument("point", type=int)
|
|
1035
|
-
parser_fid.set_defaults(func=fiducial)
|
|
1036
|
-
parser_csm = subparsers.add_parser("cs_maker")
|
|
1037
|
-
parser_csm.set_defaults(func=cs_maker)
|
|
1038
|
-
parser_pp = subparsers.add_parser("pumpprobe_calc")
|
|
1039
|
-
parser_pp.set_defaults(func=pumpprobe_calc)
|
|
1040
|
-
parser_write = subparsers.add_parser("write_parameter_file")
|
|
1041
|
-
parser_write.set_defaults(func=write_parameter_file)
|
|
1042
|
-
parser_def = subparsers.add_parser("define_current_chip")
|
|
1043
|
-
parser_def.add_argument("chipid", type=str)
|
|
1044
|
-
parser_def.set_defaults(func=define_current_chip)
|
|
1045
|
-
parser_stockmap = subparsers.add_parser("load_stock_map")
|
|
1046
|
-
parser_stockmap.add_argument("map_choice", type=str)
|
|
1047
|
-
parser_stockmap.set_defaults(func=load_stock_map)
|
|
1048
|
-
parser_litemap = subparsers.add_parser("load_lite_map")
|
|
1049
|
-
parser_litemap.set_defaults(func=load_lite_map)
|
|
1050
|
-
parser_fullmap = subparsers.add_parser("load_full_map")
|
|
1051
|
-
parser_fullmap.set_defaults(func=load_full_map)
|
|
1052
|
-
parser_save = subparsers.add_parser("save_screen_map")
|
|
1053
|
-
parser_save.set_defaults(func=save_screen_map)
|
|
1054
|
-
parser_upld = subparsers.add_parser("upload_full")
|
|
1055
|
-
parser_upld.set_defaults(func=upload_full)
|
|
1056
|
-
parser_params = subparsers.add_parser("upload_parameters")
|
|
1057
|
-
parser_params.add_argument("chipid", type=str)
|
|
1058
|
-
parser_params.set_defaults(func=upload_parameters)
|
|
1059
|
-
parser_csr = subparsers.add_parser("cs_reset")
|
|
1060
|
-
parser_csr.set_defaults(func=cs_reset)
|
|
1061
|
-
parser_block = subparsers.add_parser("block_check")
|
|
1062
|
-
parser_block.set_defaults(func=block_check)
|
|
1063
|
-
|
|
1064
|
-
args = parser.parse_args(args)
|
|
1065
|
-
|
|
1066
|
-
args_dict = vars(args)
|
|
1067
|
-
args_dict.pop("sub-command")
|
|
1068
|
-
args_dict.pop("func")(**args_dict)
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
if __name__ == "__main__":
|
|
1072
|
-
setup_logging()
|
|
1073
|
-
|
|
1074
|
-
parse_args_and_run_parsed_function(sys.argv[1:])
|
|
1033
|
+
# setup_logging now called in all functions.
|
|
1034
|
+
# TODO See logging issue on blueapi
|
|
1035
|
+
# https://github.com/DiamondLightSource/blueapi/issues/494
|