mx-bluesky 0.0.1__py3-none-any.whl → 0.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mx_bluesky/__main__.py +1 -2
- mx_bluesky/_version.py +14 -2
- mx_bluesky/example.py +4 -4
- mx_bluesky/i04/__init__.py +3 -0
- mx_bluesky/i04/callbacks/murko_callback.py +45 -0
- mx_bluesky/i04/thawing_plan.py +84 -0
- mx_bluesky/i24/serial/__init__.py +49 -0
- mx_bluesky/i24/serial/blueapi_config.yaml +12 -0
- mx_bluesky/{I24 → i24}/serial/dcid.py +53 -41
- mx_bluesky/{I24 → i24}/serial/extruder/EX-gui-edm/DetStage.edl +1 -2
- mx_bluesky/{I24 → i24}/serial/extruder/EX-gui-edm/DiamondExtruder-I24-py3v1.edl +28 -32
- mx_bluesky/{I24 → i24}/serial/extruder/EX-gui-edm/microdrop_alignment.edl +0 -1
- mx_bluesky/i24/serial/extruder/i24ssx_Extruder_Collect_py3v2.py +513 -0
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/CustomChip_py3v1.edl +1 -2
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/DetStage.edl +1 -2
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/DiamondChipI24-py3v1.edl +46 -41
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/ME14E-GeneralPurpose.edl +0 -1
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/MappingLite-oxford_py3v1.edl +10 -11
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/PMAC_Command.edl +0 -1
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/Shutter_Control.edl +0 -1
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/microdrop_alignment.edl +0 -1
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/nudgechip.edl +0 -1
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/pumpprobe-py3v1.edl +300 -119
- mx_bluesky/i24/serial/fixed_target/FT-gui-edm/short1-laser.png +0 -0
- mx_bluesky/i24/serial/fixed_target/FT-gui-edm/short2-laser.png +0 -0
- mx_bluesky/{I24 → i24}/serial/fixed_target/ft_utils.py +24 -1
- mx_bluesky/i24/serial/fixed_target/i24ssx_Chip_Collect_py3v1.py +798 -0
- mx_bluesky/{I24 → i24}/serial/fixed_target/i24ssx_Chip_Manager_py3v1.py +374 -408
- mx_bluesky/{I24 → i24}/serial/fixed_target/i24ssx_Chip_Mapping_py3v1.py +34 -40
- mx_bluesky/i24/serial/fixed_target/i24ssx_Chip_StartUp_py3v1.py +325 -0
- mx_bluesky/{I24 → i24}/serial/fixed_target/i24ssx_moveonclick.py +40 -45
- mx_bluesky/i24/serial/log.py +156 -0
- mx_bluesky/i24/serial/parameters/__init__.py +15 -0
- mx_bluesky/i24/serial/parameters/constants.py +47 -0
- mx_bluesky/i24/serial/parameters/experiment_parameters.py +124 -0
- mx_bluesky/i24/serial/parameters/fixed_target/cs/cs_maker.json +9 -0
- mx_bluesky/{I24 → i24}/serial/parameters/fixed_target/cs/motor_direction.txt +1 -1
- mx_bluesky/{I24 → i24}/serial/parameters/fixed_target/pvar_files/minichip-oxford.pvar +1 -1
- mx_bluesky/i24/serial/parameters/utils.py +40 -0
- mx_bluesky/i24/serial/run_extruder.sh +19 -0
- mx_bluesky/i24/serial/run_fixed_target.sh +22 -0
- mx_bluesky/i24/serial/run_serial.py +36 -0
- mx_bluesky/{I24 → i24}/serial/set_visit_directory.sh +6 -1
- mx_bluesky/{I24 → i24}/serial/setup_beamline/pv.py +1 -62
- mx_bluesky/{I24 → i24}/serial/setup_beamline/pv_abstract.py +6 -7
- mx_bluesky/{I24 → i24}/serial/setup_beamline/setup_beamline.py +90 -269
- mx_bluesky/{I24 → i24}/serial/setup_beamline/setup_detector.py +47 -40
- mx_bluesky/i24/serial/setup_beamline/setup_zebra_plans.py +459 -0
- mx_bluesky/i24/serial/start_blueapi.sh +28 -0
- mx_bluesky/i24/serial/write_nexus.py +102 -0
- mx_bluesky/parameters/__init__.py +31 -0
- mx_bluesky/parameters/components.py +200 -0
- {mx_bluesky-0.0.1.dist-info → mx_bluesky-0.3.1.dist-info}/METADATA +37 -26
- mx_bluesky-0.3.1.dist-info/RECORD +67 -0
- {mx_bluesky-0.0.1.dist-info → mx_bluesky-0.3.1.dist-info}/WHEEL +1 -1
- mx_bluesky-0.3.1.dist-info/entry_points.txt +4 -0
- mx_bluesky/I24/serial/extruder/i24ssx_Extruder_Collect_py3v2.py +0 -476
- mx_bluesky/I24/serial/fixed_target/FT-gui-edm/ME14E-motors.edl +0 -1874
- mx_bluesky/I24/serial/fixed_target/__init__.py +0 -0
- mx_bluesky/I24/serial/fixed_target/i24ssx_Chip_Collect_py3v1.py +0 -695
- mx_bluesky/I24/serial/fixed_target/i24ssx_Chip_StartUp_py3v1.py +0 -463
- mx_bluesky/I24/serial/log.py +0 -101
- mx_bluesky/I24/serial/parameters/__init__.py +0 -5
- mx_bluesky/I24/serial/parameters/constants.py +0 -39
- mx_bluesky/I24/serial/parameters/fixed_target/cs/cs_maker.json +0 -9
- mx_bluesky/I24/serial/parameters/fixed_target/cs/fiducial_1.txt +0 -4
- mx_bluesky/I24/serial/parameters/fixed_target/cs/fiducial_2.txt +0 -4
- mx_bluesky/I24/serial/parameters/fixed_target/litemaps/currentchip.map +0 -81
- mx_bluesky/I24/serial/parameters/fixed_target/parameters.txt +0 -13
- mx_bluesky/I24/serial/run_serial.py +0 -52
- mx_bluesky/I24/serial/write_nexus.py +0 -113
- mx_bluesky-0.0.1.dist-info/RECORD +0 -58
- mx_bluesky-0.0.1.dist-info/entry_points.txt +0 -4
- /mx_bluesky/{I24 → i24}/__init__.py +0 -0
- /mx_bluesky/{I24/serial → i24/serial/extruder}/__init__.py +0 -0
- /mx_bluesky/{I24/serial/extruder → i24/serial/fixed_target}/__init__.py +0 -0
- /mx_bluesky/{I24 → i24}/serial/parameters/fixed_target/pvar_files/oxford.pvar +0 -0
- /mx_bluesky/{I24 → i24}/serial/run_ssx.sh +0 -0
- /mx_bluesky/{I24 → i24}/serial/setup_beamline/__init__.py +0 -0
- /mx_bluesky/{I24 → i24}/serial/setup_beamline/ca.py +0 -0
- {mx_bluesky-0.0.1.dist-info → mx_bluesky-0.3.1.dist-info}/LICENSE +0 -0
- {mx_bluesky-0.0.1.dist-info → mx_bluesky-0.3.1.dist-info}/top_level.txt +0 -0
mx_bluesky/__main__.py
CHANGED
|
@@ -9,9 +9,8 @@ __all__ = ["main"]
|
|
|
9
9
|
|
|
10
10
|
def main(args=None):
|
|
11
11
|
parser = ArgumentParser()
|
|
12
|
-
parser.add_argument("--version", action="version", version=__version__)
|
|
12
|
+
parser.add_argument("-v", "--version", action="version", version=__version__)
|
|
13
13
|
args = parser.parse_args(args)
|
|
14
|
-
|
|
15
14
|
run_plan()
|
|
16
15
|
|
|
17
16
|
|
mx_bluesky/_version.py
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
# file generated by setuptools_scm
|
|
2
2
|
# don't change, don't track in version control
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
TYPE_CHECKING = False
|
|
4
|
+
if TYPE_CHECKING:
|
|
5
|
+
from typing import Tuple, Union
|
|
6
|
+
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
7
|
+
else:
|
|
8
|
+
VERSION_TUPLE = object
|
|
9
|
+
|
|
10
|
+
version: str
|
|
11
|
+
__version__: str
|
|
12
|
+
__version_tuple__: VERSION_TUPLE
|
|
13
|
+
version_tuple: VERSION_TUPLE
|
|
14
|
+
|
|
15
|
+
__version__ = version = '0.3.1'
|
|
16
|
+
__version_tuple__ = version_tuple = (0, 3, 1)
|
mx_bluesky/example.py
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
from bluesky import RunEngine
|
|
2
1
|
from bluesky.plan_stubs import rd
|
|
2
|
+
from bluesky.run_engine import RunEngine
|
|
3
3
|
from ophyd import Component, Device, EpicsSignal
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class Synchrotron(Device):
|
|
7
|
-
ring_current
|
|
7
|
+
ring_current = Component(EpicsSignal, "SR-DI-DCCT-01:SIGNAL")
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
def
|
|
10
|
+
def example_plan(synch: Synchrotron):
|
|
11
11
|
current = yield from rd(synch.ring_current)
|
|
12
12
|
print(current)
|
|
13
13
|
|
|
@@ -16,4 +16,4 @@ def run_plan():
|
|
|
16
16
|
RE = RunEngine()
|
|
17
17
|
my_synch = Synchrotron(name="Synchrotron")
|
|
18
18
|
my_synch.wait_for_connection()
|
|
19
|
-
RE(
|
|
19
|
+
RE(example_plan(my_synch))
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import copy
|
|
2
|
+
import json
|
|
3
|
+
|
|
4
|
+
from bluesky.callbacks import CallbackBase
|
|
5
|
+
from dodal.log import LOGGER
|
|
6
|
+
from event_model.documents import Event, RunStart
|
|
7
|
+
from redis import StrictRedis
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class MurkoCallback(CallbackBase):
|
|
11
|
+
def __init__(self, redis_host: str, redis_password: str, redis_db: int = 0):
|
|
12
|
+
self.redis_client = StrictRedis(
|
|
13
|
+
host=redis_host, password=redis_password, db=redis_db
|
|
14
|
+
)
|
|
15
|
+
self.last_uuid = None
|
|
16
|
+
|
|
17
|
+
def start(self, doc: RunStart) -> RunStart | None:
|
|
18
|
+
self.murko_metadata = {
|
|
19
|
+
"zoom_percentage": doc.get("zoom_percentage"),
|
|
20
|
+
"microns_per_x_pixel": doc.get("microns_per_x_pixel"),
|
|
21
|
+
"microns_per_y_pixel": doc.get("microns_per_y_pixel"),
|
|
22
|
+
"beam_centre_i": doc.get("beam_centre_i"),
|
|
23
|
+
"beam_centre_j": doc.get("beam_centre_j"),
|
|
24
|
+
"sample_id": doc.get("sample_id"),
|
|
25
|
+
}
|
|
26
|
+
self.last_uuid = None
|
|
27
|
+
return doc
|
|
28
|
+
|
|
29
|
+
def event(self, doc: Event) -> Event:
|
|
30
|
+
if latest_omega := doc["data"].get("smargon-omega"):
|
|
31
|
+
if self.last_uuid is not None:
|
|
32
|
+
self.call_murko(self.last_uuid, latest_omega)
|
|
33
|
+
elif (uuid := doc["data"].get("oav_to_redis_forwarder-uuid")) is not None:
|
|
34
|
+
self.last_uuid = uuid
|
|
35
|
+
return doc
|
|
36
|
+
|
|
37
|
+
def call_murko(self, uuid: str, omega: float):
|
|
38
|
+
metadata = copy.deepcopy(self.murko_metadata)
|
|
39
|
+
metadata["omega_angle"] = omega
|
|
40
|
+
metadata["uuid"] = uuid
|
|
41
|
+
|
|
42
|
+
# Send metadata to REDIS and trigger murko
|
|
43
|
+
self.redis_client.hset("test-metadata", uuid, json.dumps(metadata))
|
|
44
|
+
self.redis_client.publish("murko", json.dumps(metadata))
|
|
45
|
+
LOGGER.info("Metadata sent to redis")
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import bluesky.plan_stubs as bps
|
|
2
|
+
import bluesky.preprocessors as bpp
|
|
3
|
+
from bluesky.preprocessors import run_decorator, subs_decorator
|
|
4
|
+
from dls_bluesky_core.core import MsgGenerator
|
|
5
|
+
from dodal.beamlines.i04 import MURKO_REDIS_DB, REDIS_HOST, REDIS_PASSWORD
|
|
6
|
+
from dodal.common import inject
|
|
7
|
+
from dodal.devices.oav.oav_detector import OAV
|
|
8
|
+
from dodal.devices.oav.oav_to_redis_forwarder import OAVToRedisForwarder
|
|
9
|
+
from dodal.devices.robot import BartRobot
|
|
10
|
+
from dodal.devices.smargon import Smargon
|
|
11
|
+
from dodal.devices.thawer import Thawer, ThawerStates
|
|
12
|
+
|
|
13
|
+
from mx_bluesky.i04.callbacks.murko_callback import MurkoCallback
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def thaw_and_center(
|
|
17
|
+
time_to_thaw: float,
|
|
18
|
+
rotation: float = 360,
|
|
19
|
+
robot: BartRobot = inject("robot"),
|
|
20
|
+
thawer: Thawer = inject("thawer"),
|
|
21
|
+
smargon: Smargon = inject("smargon"),
|
|
22
|
+
oav: OAV = inject("oav"),
|
|
23
|
+
oav_to_redis_forwarder: OAVToRedisForwarder = inject("oav_to_redis_forwarder"),
|
|
24
|
+
) -> MsgGenerator:
|
|
25
|
+
zoom_percentage = yield from bps.rd(oav.zoom_controller.percentage)
|
|
26
|
+
sample_id = yield from bps.rd(robot.sample_id)
|
|
27
|
+
|
|
28
|
+
yield from bps.abs_set(oav.zoom_controller.level, "1.0x", wait=True)
|
|
29
|
+
|
|
30
|
+
@subs_decorator(MurkoCallback(REDIS_HOST, REDIS_PASSWORD, MURKO_REDIS_DB))
|
|
31
|
+
@run_decorator(
|
|
32
|
+
md={
|
|
33
|
+
"microns_per_x_pixel": oav.parameters.micronsPerXPixel,
|
|
34
|
+
"microns_per_y_pixel": oav.parameters.micronsPerYPixel,
|
|
35
|
+
"beam_centre_i": oav.parameters.beam_centre_i,
|
|
36
|
+
"beam_centre_j": oav.parameters.beam_centre_j,
|
|
37
|
+
"zoom_percentage": zoom_percentage,
|
|
38
|
+
"sample_id": sample_id,
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
def _thaw_and_center():
|
|
42
|
+
yield from bps.kickoff(oav_to_redis_forwarder, wait=True)
|
|
43
|
+
yield from bps.monitor(smargon.omega.user_readback, name="smargon")
|
|
44
|
+
yield from bps.monitor(oav_to_redis_forwarder.uuid, name="oav")
|
|
45
|
+
yield from thaw(time_to_thaw, rotation, thawer, smargon)
|
|
46
|
+
yield from bps.complete(oav_to_redis_forwarder)
|
|
47
|
+
|
|
48
|
+
yield from _thaw_and_center()
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def thaw(
|
|
52
|
+
time_to_thaw: float,
|
|
53
|
+
rotation: float = 360,
|
|
54
|
+
thawer: Thawer = inject("thawer"),
|
|
55
|
+
smargon: Smargon = inject("smargon"),
|
|
56
|
+
) -> MsgGenerator:
|
|
57
|
+
"""Rotates the sample and thaws it at the same time.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
time_to_thaw (float): Time to thaw for, in seconds.
|
|
61
|
+
rotation (float, optional): How much to rotate by whilst thawing, in degrees.
|
|
62
|
+
Defaults to 360.
|
|
63
|
+
thawer (Thawer, optional): The thawing device. Defaults to inject("thawer").
|
|
64
|
+
smargon (Smargon, optional): The smargon used to rotate.
|
|
65
|
+
Defaults to inject("smargon")
|
|
66
|
+
"""
|
|
67
|
+
inital_velocity = yield from bps.rd(smargon.omega.velocity)
|
|
68
|
+
new_velocity = abs(rotation / time_to_thaw) * 2.0
|
|
69
|
+
|
|
70
|
+
def do_thaw():
|
|
71
|
+
yield from bps.abs_set(smargon.omega.velocity, new_velocity, wait=True)
|
|
72
|
+
yield from bps.abs_set(thawer.control, ThawerStates.ON, wait=True)
|
|
73
|
+
yield from bps.rel_set(smargon.omega, rotation, wait=True)
|
|
74
|
+
yield from bps.rel_set(smargon.omega, -rotation, wait=True)
|
|
75
|
+
|
|
76
|
+
def cleanup():
|
|
77
|
+
yield from bps.abs_set(smargon.omega.velocity, inital_velocity, wait=True)
|
|
78
|
+
yield from bps.abs_set(thawer.control, ThawerStates.OFF, wait=True)
|
|
79
|
+
|
|
80
|
+
# Always cleanup even if there is a failure
|
|
81
|
+
yield from bpp.contingency_wrapper(
|
|
82
|
+
do_thaw(),
|
|
83
|
+
final_plan=cleanup,
|
|
84
|
+
)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from .extruder.i24ssx_Extruder_Collect_py3v2 import (
|
|
2
|
+
enter_hutch,
|
|
3
|
+
initialise_extruder,
|
|
4
|
+
laser_check,
|
|
5
|
+
run_extruder_plan,
|
|
6
|
+
)
|
|
7
|
+
from .fixed_target.i24ssx_Chip_Collect_py3v1 import run_fixed_target_plan
|
|
8
|
+
from .fixed_target.i24ssx_Chip_Manager_py3v1 import (
|
|
9
|
+
block_check,
|
|
10
|
+
cs_maker,
|
|
11
|
+
cs_reset,
|
|
12
|
+
define_current_chip,
|
|
13
|
+
fiducial,
|
|
14
|
+
initialise_stages,
|
|
15
|
+
laser_control,
|
|
16
|
+
load_lite_map,
|
|
17
|
+
load_stock_map,
|
|
18
|
+
moveto,
|
|
19
|
+
moveto_preset,
|
|
20
|
+
pumpprobe_calc,
|
|
21
|
+
save_screen_map,
|
|
22
|
+
upload_parameters,
|
|
23
|
+
write_parameter_file,
|
|
24
|
+
)
|
|
25
|
+
from .setup_beamline.setup_detector import setup_detector_stage
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
"setup_detector_stage",
|
|
29
|
+
"run_extruder_plan",
|
|
30
|
+
"initialise_extruder",
|
|
31
|
+
"enter_hutch",
|
|
32
|
+
"laser_check",
|
|
33
|
+
"run_fixed_target_plan",
|
|
34
|
+
"moveto",
|
|
35
|
+
"moveto_preset",
|
|
36
|
+
"block_check",
|
|
37
|
+
"cs_maker",
|
|
38
|
+
"cs_reset",
|
|
39
|
+
"define_current_chip",
|
|
40
|
+
"fiducial",
|
|
41
|
+
"initialise_stages",
|
|
42
|
+
"laser_control",
|
|
43
|
+
"load_lite_map",
|
|
44
|
+
"load_stock_map",
|
|
45
|
+
"pumpprobe_calc",
|
|
46
|
+
"save_screen_map",
|
|
47
|
+
"upload_parameters",
|
|
48
|
+
"write_parameter_file",
|
|
49
|
+
]
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
1
|
import datetime
|
|
4
2
|
import json
|
|
5
3
|
import logging
|
|
@@ -12,8 +10,8 @@ from functools import lru_cache
|
|
|
12
10
|
|
|
13
11
|
import requests
|
|
14
12
|
|
|
15
|
-
from mx_bluesky.
|
|
16
|
-
from mx_bluesky.
|
|
13
|
+
from mx_bluesky.i24.serial.parameters import SSXType
|
|
14
|
+
from mx_bluesky.i24.serial.setup_beamline import (
|
|
17
15
|
Detector,
|
|
18
16
|
Eiger,
|
|
19
17
|
Pilatus,
|
|
@@ -65,9 +63,7 @@ class DCID:
|
|
|
65
63
|
stop collection if you can't get a DCID
|
|
66
64
|
timeout: Length of time to wait for the DB server before giving up
|
|
67
65
|
ssx_type: The type of SSX experiment this is for
|
|
68
|
-
|
|
69
|
-
image_dir: The location the images will be written
|
|
70
|
-
|
|
66
|
+
detector: The detector in use for current collection.
|
|
71
67
|
|
|
72
68
|
|
|
73
69
|
Attributes:
|
|
@@ -78,31 +74,24 @@ class DCID:
|
|
|
78
74
|
def __init__(
|
|
79
75
|
self,
|
|
80
76
|
*,
|
|
81
|
-
server: str = None,
|
|
77
|
+
server: str | None = None,
|
|
82
78
|
emit_errors: bool = True,
|
|
83
79
|
timeout: float = 10,
|
|
84
80
|
ssx_type: SSXType = SSXType.FIXED,
|
|
85
|
-
visit: str,
|
|
86
|
-
image_dir: str,
|
|
87
|
-
start_time: datetime.datetime,
|
|
88
|
-
num_images: int,
|
|
89
|
-
exposure_time: float,
|
|
90
|
-
shots_per_position: int = 1,
|
|
91
81
|
detector: Detector | Literal["eiger", "pilatus"] | None = None,
|
|
92
|
-
pump_exposure_time: float | None = None,
|
|
93
|
-
pump_delay: float | None = None,
|
|
94
|
-
pump_status: int = 0,
|
|
95
82
|
):
|
|
83
|
+
self.detector: Detector
|
|
96
84
|
# Handle case of string literal
|
|
97
85
|
if detector == "eiger":
|
|
98
|
-
detector = Eiger()
|
|
86
|
+
self.detector = Eiger()
|
|
99
87
|
elif detector == "pilatus":
|
|
100
|
-
detector = Pilatus()
|
|
88
|
+
self.detector = Pilatus()
|
|
101
89
|
elif detector is None:
|
|
102
|
-
detector = Pilatus()
|
|
90
|
+
self.detector = Pilatus()
|
|
103
91
|
warnings.warn(
|
|
104
92
|
"Please pass detector= to DCID. Pilatus assumed, this will be removed in the future.",
|
|
105
93
|
UserWarning,
|
|
94
|
+
stacklevel=5,
|
|
106
95
|
)
|
|
107
96
|
|
|
108
97
|
self.server = server or DEFAULT_ISPYB_SERVER
|
|
@@ -111,6 +100,25 @@ class DCID:
|
|
|
111
100
|
self.timeout = timeout
|
|
112
101
|
self.ssx_type = SSXType(ssx_type)
|
|
113
102
|
self.dcid = None
|
|
103
|
+
|
|
104
|
+
def generate_dcid(
|
|
105
|
+
self,
|
|
106
|
+
visit: str,
|
|
107
|
+
image_dir: str,
|
|
108
|
+
num_images: int,
|
|
109
|
+
exposure_time: float,
|
|
110
|
+
start_time: datetime.datetime | None = None,
|
|
111
|
+
shots_per_position: int = 1,
|
|
112
|
+
pump_exposure_time: float | None = None,
|
|
113
|
+
pump_delay: float = 0,
|
|
114
|
+
pump_status: int = 0,
|
|
115
|
+
):
|
|
116
|
+
"""Generate an ispyb DCID.
|
|
117
|
+
|
|
118
|
+
Args:
|
|
119
|
+
visit: The name of the visit e.g. "mx12345-4"
|
|
120
|
+
image_dir: The location the images will be written
|
|
121
|
+
"""
|
|
114
122
|
try:
|
|
115
123
|
if not start_time:
|
|
116
124
|
start_time = datetime.datetime.now().astimezone()
|
|
@@ -118,24 +126,24 @@ class DCID:
|
|
|
118
126
|
start_time = start_time.astimezone()
|
|
119
127
|
|
|
120
128
|
# Gather data from the beamline
|
|
121
|
-
detector_distance = float(caget(detector.pv.detector_distance))
|
|
122
|
-
wavelength = float(caget(detector.pv.wavelength))
|
|
123
|
-
resolution = get_resolution(detector, detector_distance, wavelength)
|
|
129
|
+
detector_distance = float(caget(self.detector.pv.detector_distance))
|
|
130
|
+
wavelength = float(caget(self.detector.pv.wavelength))
|
|
131
|
+
resolution = get_resolution(self.detector, detector_distance, wavelength)
|
|
124
132
|
beamsize_x, beamsize_y = get_beamsize()
|
|
125
|
-
transmission = float(caget(detector.pv.transmission)) * 100
|
|
126
|
-
xbeam, ybeam = get_beam_center(detector)
|
|
133
|
+
transmission = float(caget(self.detector.pv.transmission)) * 100
|
|
134
|
+
xbeam, ybeam = get_beam_center(self.detector)
|
|
127
135
|
|
|
128
|
-
if isinstance(detector, Pilatus):
|
|
136
|
+
if isinstance(self.detector, Pilatus):
|
|
129
137
|
# Mirror the construction that the PPU does
|
|
130
138
|
fileTemplate = get_pilatus_filename_template_from_pvs()
|
|
131
139
|
startImageNumber = 0
|
|
132
|
-
elif isinstance(detector, Eiger):
|
|
140
|
+
elif isinstance(self.detector, Eiger):
|
|
133
141
|
# Eiger base filename is directly written to the PV
|
|
134
142
|
# Nexgen then uses this to write the .nxs file
|
|
135
|
-
fileTemplate = cagetstring(detector.pv.file_name) + ".nxs"
|
|
143
|
+
fileTemplate = str(cagetstring(self.detector.pv.file_name)) + ".nxs"
|
|
136
144
|
startImageNumber = 1
|
|
137
145
|
else:
|
|
138
|
-
raise ValueError("Unknown detector:", detector)
|
|
146
|
+
raise ValueError("Unknown detector:", self.detector)
|
|
139
147
|
|
|
140
148
|
events = [
|
|
141
149
|
{
|
|
@@ -154,7 +162,8 @@ class DCID:
|
|
|
154
162
|
# pump_status = 1: pump then probe
|
|
155
163
|
# pump_status = 2: pump within probe
|
|
156
164
|
# pump_status = 3-7: different EAVA modes (i.e. also pump then probe)
|
|
157
|
-
if pump_status != 2:
|
|
165
|
+
if pump_status != 2 and self.ssx_type is SSXType.FIXED:
|
|
166
|
+
# Pump status could be 1 for extruder but not have this.
|
|
158
167
|
# pump then probe - pump_delay corresponds to time *before* first image
|
|
159
168
|
pump_delay = -pump_delay
|
|
160
169
|
events.append(
|
|
@@ -170,7 +179,7 @@ class DCID:
|
|
|
170
179
|
|
|
171
180
|
data = {
|
|
172
181
|
"detectorDistance": float(detector_distance),
|
|
173
|
-
"detectorId": detector.id,
|
|
182
|
+
"detectorId": self.detector.id,
|
|
174
183
|
"exposureTime": float(exposure_time),
|
|
175
184
|
"fileTemplate": fileTemplate,
|
|
176
185
|
"imageDirectory": str(image_dir),
|
|
@@ -276,7 +285,7 @@ class DCID:
|
|
|
276
285
|
# end_time might be a string from time.ctime
|
|
277
286
|
if isinstance(end_time, str):
|
|
278
287
|
end_time = datetime.datetime.strptime(end_time, "%a %b %d %H:%M:%S %Y")
|
|
279
|
-
logger.
|
|
288
|
+
logger.debug("Parsed end time: %s", end_time)
|
|
280
289
|
|
|
281
290
|
if not end_time:
|
|
282
291
|
end_time = datetime.datetime.now().astimezone()
|
|
@@ -311,8 +320,8 @@ class DCID:
|
|
|
311
320
|
response.raise_for_status()
|
|
312
321
|
logger.info("Successfully updated end time for DCID %d", self.dcid)
|
|
313
322
|
except Exception as e:
|
|
323
|
+
resp_obj = getattr(e, "response", None)
|
|
314
324
|
try:
|
|
315
|
-
resp_obj = getattr(e, "response", None)
|
|
316
325
|
if resp_obj is not None:
|
|
317
326
|
resp_str = resp_obj.text
|
|
318
327
|
# resp_str = repr(getattr(e, "Iresponse", "<no attribute>"))
|
|
@@ -338,17 +347,20 @@ def get_pilatus_filename_template_from_pvs() -> str:
|
|
|
338
347
|
filename_template = cagetstring(pv.pilat_filetemplate)
|
|
339
348
|
file_number = int(caget(pv.pilat_filenumber))
|
|
340
349
|
# Exploit fact that passing negative numbers will put the - before the 0's
|
|
341
|
-
expected_filename = filename_template % (filename, f"{file_number:05d}_", -9)
|
|
350
|
+
expected_filename = str(filename_template % (filename, f"{file_number:05d}_", -9))
|
|
342
351
|
# Now, find the -09 part of this
|
|
343
352
|
numberpart = re.search(r"(-0+9)", expected_filename)
|
|
344
353
|
# Make sure this was the only one
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
354
|
+
if numberpart is not None:
|
|
355
|
+
assert re.search(r"(-0+9)", expected_filename[numberpart.end() :]) is None
|
|
356
|
+
template_fill = "#" * len(numberpart.group(0))
|
|
357
|
+
return (
|
|
358
|
+
expected_filename[: numberpart.start()]
|
|
359
|
+
+ template_fill
|
|
360
|
+
+ expected_filename[numberpart.end() :]
|
|
361
|
+
)
|
|
362
|
+
else:
|
|
363
|
+
raise ValueError(f"{filename=} did not contain the numbers for templating")
|
|
352
364
|
|
|
353
365
|
|
|
354
366
|
def get_beamsize() -> tuple[float | None, float | None]:
|
|
@@ -113,7 +113,7 @@ font "arial-medium-r-18.0"
|
|
|
113
113
|
buttonLabel "Move Stage"
|
|
114
114
|
numCmds 1
|
|
115
115
|
command {
|
|
116
|
-
0 "
|
|
116
|
+
0 "blueapi -c CONFIG_LOCATION controller run setup_detector_stage '\{\"expt_type\":\"Serial Jet\"\}'"
|
|
117
117
|
}
|
|
118
118
|
endObjectProperties
|
|
119
119
|
|
|
@@ -136,4 +136,3 @@ value {
|
|
|
136
136
|
}
|
|
137
137
|
autoSize
|
|
138
138
|
endObjectProperties
|
|
139
|
-
|
|
@@ -3,8 +3,8 @@ beginScreenProperties
|
|
|
3
3
|
major 4
|
|
4
4
|
minor 0
|
|
5
5
|
release 1
|
|
6
|
-
x
|
|
7
|
-
y
|
|
6
|
+
x 1018
|
|
7
|
+
y 277
|
|
8
8
|
w 700
|
|
9
9
|
h 900
|
|
10
10
|
font "arial-medium-r-18.0"
|
|
@@ -370,7 +370,7 @@ font "arial-medium-r-24.0"
|
|
|
370
370
|
buttonLabel "Start"
|
|
371
371
|
numCmds 1
|
|
372
372
|
command {
|
|
373
|
-
0 "
|
|
373
|
+
0 "blueapi -c CONFIG_LOCATION controller run run_extruder_plan"
|
|
374
374
|
}
|
|
375
375
|
endObjectProperties
|
|
376
376
|
|
|
@@ -832,7 +832,7 @@ botShadowColor index 11
|
|
|
832
832
|
font "arial-medium-r-18.0"
|
|
833
833
|
numCmds 1
|
|
834
834
|
command {
|
|
835
|
-
0 "
|
|
835
|
+
0 "blueapi -c CONFIG_LOCATION controller run initialise_extruder"
|
|
836
836
|
}
|
|
837
837
|
endObjectProperties
|
|
838
838
|
|
|
@@ -856,31 +856,6 @@ value {
|
|
|
856
856
|
autoSize
|
|
857
857
|
endObjectProperties
|
|
858
858
|
|
|
859
|
-
# (Message Button)
|
|
860
|
-
object activeMessageButtonClass
|
|
861
|
-
beginObjectProperties
|
|
862
|
-
major 4
|
|
863
|
-
minor 1
|
|
864
|
-
release 0
|
|
865
|
-
x 561
|
|
866
|
-
y 400
|
|
867
|
-
w 100
|
|
868
|
-
h 40
|
|
869
|
-
fgColor index 0
|
|
870
|
-
onColor index 21
|
|
871
|
-
offColor index 21
|
|
872
|
-
topShadowColor index 1
|
|
873
|
-
botShadowColor index 11
|
|
874
|
-
controlPv "BL24I-EA-IOC-12:GP8"
|
|
875
|
-
pressValue "1"
|
|
876
|
-
releaseValue "1"
|
|
877
|
-
onLabel "Abort"
|
|
878
|
-
offLabel "Abort"
|
|
879
|
-
toggle
|
|
880
|
-
3d
|
|
881
|
-
font "arial-medium-r-24.0"
|
|
882
|
-
endObjectProperties
|
|
883
|
-
|
|
884
859
|
# (Message Button)
|
|
885
860
|
object activeMessageButtonClass
|
|
886
861
|
beginObjectProperties
|
|
@@ -2204,7 +2179,7 @@ font "arial-medium-r-20.0"
|
|
|
2204
2179
|
buttonLabel "Laser On"
|
|
2205
2180
|
numCmds 1
|
|
2206
2181
|
command {
|
|
2207
|
-
0 "
|
|
2182
|
+
0 "blueapi -c CONFIG_LOCATION controller run laser_check '\{\"mode\":\"laseron\"\}'"
|
|
2208
2183
|
}
|
|
2209
2184
|
endObjectProperties
|
|
2210
2185
|
|
|
@@ -2226,7 +2201,7 @@ font "arial-medium-r-20.0"
|
|
|
2226
2201
|
buttonLabel "Laser Off"
|
|
2227
2202
|
numCmds 1
|
|
2228
2203
|
command {
|
|
2229
|
-
0 "
|
|
2204
|
+
0 "blueapi -c CONFIG_LOCATION controller run laser_check '\{\"mode\":\"laseroff\"\}'"
|
|
2230
2205
|
}
|
|
2231
2206
|
endObjectProperties
|
|
2232
2207
|
|
|
@@ -2248,7 +2223,7 @@ font "arial-medium-r-18.0"
|
|
|
2248
2223
|
buttonLabel "Enter hutch"
|
|
2249
2224
|
numCmds 1
|
|
2250
2225
|
command {
|
|
2251
|
-
0 "
|
|
2226
|
+
0 "blueapi -c CONFIG_LOCATION controller run enter_hutch"
|
|
2252
2227
|
}
|
|
2253
2228
|
endObjectProperties
|
|
2254
2229
|
|
|
@@ -2275,3 +2250,24 @@ displayFileName {
|
|
|
2275
2250
|
}
|
|
2276
2251
|
endObjectProperties
|
|
2277
2252
|
|
|
2253
|
+
# (Shell Command)
|
|
2254
|
+
object shellCmdClass
|
|
2255
|
+
beginObjectProperties
|
|
2256
|
+
major 4
|
|
2257
|
+
minor 3
|
|
2258
|
+
release 0
|
|
2259
|
+
x 559
|
|
2260
|
+
y 399
|
|
2261
|
+
w 100
|
|
2262
|
+
h 40
|
|
2263
|
+
fgColor index 0
|
|
2264
|
+
bgColor index 21
|
|
2265
|
+
topShadowColor index 0
|
|
2266
|
+
botShadowColor index 11
|
|
2267
|
+
font "arial-medium-r-24.0"
|
|
2268
|
+
buttonLabel "Abort"
|
|
2269
|
+
numCmds 1
|
|
2270
|
+
command {
|
|
2271
|
+
0 "blueapi -c CONFIG_LOCATION controller abort"
|
|
2272
|
+
}
|
|
2273
|
+
endObjectProperties
|