Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use BlueAPI abort #124

Merged
merged 39 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f342859
A start
noemifrisina Jul 5, 2024
77afc3d
Add return type
noemifrisina Jul 8, 2024
6e2dd10
Finish setting up plans
noemifrisina Jul 8, 2024
3636c18
Use error
noemifrisina Jul 8, 2024
b5f7457
COpy file change
noemifrisina Jul 12, 2024
0be3927
Merge branch 'main' into 117_use-blueapi-abort
noemifrisina Jul 12, 2024
3a94029
Tidy up from merge
noemifrisina Jul 12, 2024
91ae67f
Pin to dodal branch
noemifrisina Jul 12, 2024
e97e35b
Start trying to fix extruder tests
noemifrisina Jul 12, 2024
bd139c9
Fix extruder tests and add one for idy up plan
noemifrisina Jul 12, 2024
45f6827
Add aborted test
noemifrisina Jul 12, 2024
c83b813
Tidy up
noemifrisina Jul 12, 2024
e78b318
Starting skeleton for fixed target TBC
noemifrisina Jul 12, 2024
793a42b
Add a generate method to DCID
noemifrisina Jul 15, 2024
79630c5
Start using wrapper in fixed target
noemifrisina Jul 15, 2024
aa971b8
Add tests for aborted and tidy up plans in fixed target
noemifrisina Jul 17, 2024
5f26046
Start adding new test
noemifrisina Jul 17, 2024
44d5a28
Stop test from hanging
noemifrisina Jul 17, 2024
dc5afcb
Complete finish test
noemifrisina Jul 17, 2024
e44215a
Add to test
noemifrisina Jul 17, 2024
1ffed30
Merge branch 'main' into 117_use-blueapi-abort
noemifrisina Jul 18, 2024
f421ce8
Partial changes to callnexgen and use of run_program
noemifrisina Jul 18, 2024
bd98168
Get bit_depth from eiger PV and pass it to nexus writer
noemifrisina Jul 19, 2024
314b3fb
Add comment
noemifrisina Jul 19, 2024
f87693d
Change the edm abort button to use blueapi
noemifrisina Jul 19, 2024
8317a53
Merge branch 'main' into 117_use-blueapi-abort
noemifrisina Jul 19, 2024
5bf69f5
Merge branch 'main' into 117_use-blueapi-abort
noemifrisina Jul 19, 2024
3d8b1e6
Update
noemifrisina Jul 19, 2024
efa78aa
Remove obsolete check
noemifrisina Jul 19, 2024
f177bb1
Use new pmac run_program
noemifrisina Jul 22, 2024
49f0928
Fix write params file
noemifrisina Jul 23, 2024
820dc2b
Add forgotten group
noemifrisina Jul 23, 2024
6d2c002
Merge branch 'main' into 117_use-blueapi-abort
noemifrisina Jul 23, 2024
ac9f0bc
dodal pin
noemifrisina Jul 23, 2024
ae9c202
Add an else plan for extruder
noemifrisina Jul 24, 2024
6d6a448
Update extruder plans
noemifrisina Jul 26, 2024
964150d
Tidy up a bit
noemifrisina Jul 26, 2024
cab6ae5
Dodal pin
noemifrisina Jul 26, 2024
2489557
Add link to issue
noemifrisina Jul 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 37 additions & 27 deletions src/mx_bluesky/I24/serial/dcid.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ class DCID:
stop collection if you can't get a DCID
timeout: Length of time to wait for the DB server before giving up
ssx_type: The type of SSX experiment this is for
visit: The name of the visit e.g. "mx12345-4"
image_dir: The location the images will be written

detector: The detector in use for current collection.


Attributes:
Expand All @@ -76,28 +74,20 @@ class DCID:
def __init__(
self,
*,
server: str = None,
server: str | None = None,
emit_errors: bool = True,
timeout: float = 10,
ssx_type: SSXType = SSXType.FIXED,
visit: str,
image_dir: str,
start_time: datetime.datetime,
num_images: int,
exposure_time: float,
shots_per_position: int = 1,
detector: Detector | Literal["eiger", "pilatus"] | None = None,
pump_exposure_time: float | None = None,
pump_delay: float | None = None,
pump_status: int = 0,
):
self.detector: Detector
# Handle case of string literal
if detector == "eiger":
detector = Eiger()
self.detector = Eiger()
elif detector == "pilatus":
detector = Pilatus()
self.detector = Pilatus()
elif detector is None:
detector = Pilatus()
self.detector = Pilatus()
warnings.warn(
"Please pass detector= to DCID. Pilatus assumed, this will be removed in the future.",
UserWarning,
Expand All @@ -109,31 +99,50 @@ def __init__(
self.timeout = timeout
self.ssx_type = SSXType(ssx_type)
self.dcid = None

def generate_dcid(
self,
visit: str,
image_dir: str,
num_images: int,
exposure_time: float,
start_time: datetime.datetime | None = None,
shots_per_position: int = 1,
pump_exposure_time: float | None = None,
pump_delay: float | None = None,
pump_status: int = 0,
):
"""Generate an ispyb DCID.

Args:
visit: The name of the visit e.g. "mx12345-4"
image_dir: The location the images will be written
"""
try:
if not start_time:
start_time = datetime.datetime.now().astimezone()
elif not start_time.timetz:
start_time = start_time.astimezone()

# Gather data from the beamline
detector_distance = float(caget(detector.pv.detector_distance))
wavelength = float(caget(detector.pv.wavelength))
resolution = get_resolution(detector, detector_distance, wavelength)
detector_distance = float(caget(self.detector.pv.detector_distance))
wavelength = float(caget(self.detector.pv.wavelength))
resolution = get_resolution(self.detector, detector_distance, wavelength)
beamsize_x, beamsize_y = get_beamsize()
transmission = float(caget(detector.pv.transmission)) * 100
xbeam, ybeam = get_beam_center(detector)
transmission = float(caget(self.detector.pv.transmission)) * 100
xbeam, ybeam = get_beam_center(self.detector)

if isinstance(detector, Pilatus):
if isinstance(self.detector, Pilatus):
# Mirror the construction that the PPU does
fileTemplate = get_pilatus_filename_template_from_pvs()
startImageNumber = 0
elif isinstance(detector, Eiger):
elif isinstance(self.detector, Eiger):
# Eiger base filename is directly written to the PV
# Nexgen then uses this to write the .nxs file
fileTemplate = cagetstring(detector.pv.file_name) + ".nxs"
fileTemplate = cagetstring(self.detector.pv.file_name) + ".nxs"
startImageNumber = 1
else:
raise ValueError("Unknown detector:", detector)
raise ValueError("Unknown detector:", self.detector)

events = [
{
Expand All @@ -152,7 +161,8 @@ def __init__(
# pump_status = 1: pump then probe
# pump_status = 2: pump within probe
# pump_status = 3-7: different EAVA modes (i.e. also pump then probe)
if pump_status != 2:
if pump_status != 2 and self.ssx_type is SSXType.FIXED:
# Pump status could be 1 for extruder but not have this.
# pump then probe - pump_delay corresponds to time *before* first image
pump_delay = -pump_delay
events.append(
Expand All @@ -168,7 +178,7 @@ def __init__(

data = {
"detectorDistance": float(detector_distance),
"detectorId": detector.id,
"detectorId": self.detector.id,
"exposureTime": float(exposure_time),
"fileTemplate": fileTemplate,
"imageDirectory": str(image_dir),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ major 4
minor 0
release 1
x 1018
y 134
y 277
w 700
h 900
font "arial-medium-r-18.0"
Expand Down Expand Up @@ -856,31 +856,6 @@ value {
autoSize
endObjectProperties

# (Message Button)
object activeMessageButtonClass
beginObjectProperties
major 4
minor 1
release 0
x 561
y 400
w 100
h 40
fgColor index 0
onColor index 21
offColor index 21
topShadowColor index 1
botShadowColor index 11
controlPv "BL24I-EA-IOC-12:GP8"
pressValue "1"
releaseValue "1"
onLabel "Abort"
offLabel "Abort"
toggle
3d
font "arial-medium-r-24.0"
endObjectProperties

# (Message Button)
object activeMessageButtonClass
beginObjectProperties
Expand Down Expand Up @@ -2275,3 +2250,25 @@ displayFileName {
}
endObjectProperties

# (Shell Command)
object shellCmdClass
beginObjectProperties
major 4
minor 3
release 0
x 559
y 399
w 100
h 40
fgColor index 0
bgColor index 21
topShadowColor index 0
botShadowColor index 11
font "arial-medium-r-24.0"
buttonLabel "Abort"
numCmds 1
command {
0 "blueapi -c CONFIG_LOCATION controller abort"
}
endObjectProperties

Loading
Loading