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

P11 develop #800

Closed
wants to merge 159 commits into from
Closed
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
e80379d
Fixing the ambiguity with Poller value and .any
Sep 18, 2023
5f29dc6
P11Collect additional debug after upgrade
Sep 18, 2023
d2b8c35
Fixing the ambiguity with Poller value and .any
Sep 18, 2023
ba7d34c
P11Collect additional debug after upgrade
Sep 18, 2023
9585b03
Merge remote-tracking branch 'origin/p11_develop' into p11_develop
Sep 27, 2023
df5dfd3
Force upgrade from the develop to avoid merging conflict
Sep 27, 2023
de981e7
Added missing warnings module
Sep 27, 2023
24c07c7
Enabled back explicit check on if beamtimeid is open
Sep 27, 2023
d22d705
Added debug info in case beamtime ID is not opened
Sep 27, 2023
4a38247
Added beamtime info as a property
Sep 27, 2023
480ec3e
Added additional debug messages for shutter
Sep 27, 2023
56d2cad
Fixed get_properties naming (Bixente)
Sep 27, 2023
a07b2ec
Removed faulty login_type=user fot P11
Sep 27, 2023
be6c170
Removed is_open() as a function and assigned is_closed() as a propert…
Sep 27, 2023
3e58e8d
Added is_open as a property inside P11NanoDiff (Bixente)
Sep 27, 2023
2a6a21e
Fixed other get_properties typos which were preventing loading
Sep 27, 2023
5d7ca11
Removed faulty login_type=user for P11
Sep 27, 2023
c20ec81
Removed is_open() as a function and assigned is_closed() as a propert…
Sep 27, 2023
7574477
Added is_open as a property inside P11NanoDiff (Bixente)
Sep 27, 2023
b4b8f9b
Fixed other get_properties typos which were preventing loading
Sep 27, 2023
4a192df
Merge remote-tracking branch 'origin/p11_develop' into p11_develop
Sep 29, 2023
f3bd7d5
Fixed shutter openning wainting forever (Bixente)
Oct 5, 2023
6fe81ab
Merge remote-tracking branch 'origin/p11_develop' into p11_develop
Oct 5, 2023
75621a3
Added preliminary flux HO for P11
Oct 6, 2023
30ddf3a
Upgraded the characterisation part for P11 using EDNA
Oct 6, 2023
e878dfb
Linting
Oct 6, 2023
7a11684
Add empty store_robot_action for P11 (temp fix due to ISPyB tests).
Oct 17, 2023
3fe9dff
Fix in AbstractSampleChanger that was causing sample not loaded error…
Oct 25, 2023
2d31d70
Fixing the ambiguity with Poller value and .any
Sep 18, 2023
8011a9c
P11Collect additional debug after upgrade
Sep 18, 2023
7def003
Force upgrade from the develop to avoid merging conflict
Sep 27, 2023
0451f47
Added missing warnings module
Sep 27, 2023
f4ea552
Enabled back explicit check on if beamtimeid is open
Sep 27, 2023
3f16e79
Added debug info in case beamtime ID is not opened
Sep 27, 2023
832f6e7
Added beamtime info as a property
Sep 27, 2023
0dc5d28
Added additional debug messages for shutter
Sep 27, 2023
d62e6bf
Fixed get_properties naming (Bixente)
Sep 27, 2023
44491ab
Removed faulty login_type=user fot P11
Sep 27, 2023
d652b9c
Removed is_open() as a function and assigned is_closed() as a propert…
Sep 27, 2023
8a03c76
Added is_open as a property inside P11NanoDiff (Bixente)
Sep 27, 2023
14e9de0
Fixed other get_properties typos which were preventing loading
Sep 27, 2023
fb4f534
Fixed shutter openning wainting forever (Bixente)
Oct 5, 2023
d002f93
Added preliminary flux HO for P11
Oct 6, 2023
3575ae9
Upgraded the characterisation part for P11 using EDNA
Oct 6, 2023
4dafa5b
Linting
Oct 6, 2023
b807078
Add empty store_robot_action for P11 (temp fix due to ISPyB tests).
Oct 17, 2023
ae9588f
Fix in AbstractSampleChanger that was causing sample not loaded error…
Oct 25, 2023
62ccaba
Merge remote-tracking branch 'origin/p11_develop' into p11_develop
Oct 25, 2023
5dabc0f
Added new HO for the beam representation for P11 (Bixente)
Oct 25, 2023
7e3188b
Fix beam position update in P11 Nanodiff
Nov 8, 2023
75ad89c
Minor changes
Nov 8, 2023
b2f3c7c
Added slits gap None (no slits) for P11 (Bixente)
Nov 8, 2023
2fd8ad5
Temp fix for P11 specific routine
Nov 8, 2023
3d4f0d2
Fixing the ambiguity with Poller value and .any
Sep 18, 2023
2b7e1fa
P11Collect additional debug after upgrade
Sep 18, 2023
9476766
Force upgrade from the develop to avoid merging conflict
Sep 27, 2023
77fe447
Added missing warnings module
Sep 27, 2023
b7c2e64
Enabled back explicit check on if beamtimeid is open
Sep 27, 2023
47c6c2c
Added debug info in case beamtime ID is not opened
Sep 27, 2023
0177daf
Added beamtime info as a property
Sep 27, 2023
cf28f6c
Added additional debug messages for shutter
Sep 27, 2023
1e62320
Fixed get_properties naming (Bixente)
Sep 27, 2023
dd41e29
Removed faulty login_type=user fot P11
Sep 27, 2023
b7e7294
Removed is_open() as a function and assigned is_closed() as a propert…
Sep 27, 2023
abb9df8
Added is_open as a property inside P11NanoDiff (Bixente)
Sep 27, 2023
b3c2ec3
Fixed other get_properties typos which were preventing loading
Sep 27, 2023
33b70bf
Fixed shutter openning wainting forever (Bixente)
Oct 5, 2023
3b56eaf
Added preliminary flux HO for P11
Oct 6, 2023
07a6e6a
Upgraded the characterisation part for P11 using EDNA
Oct 6, 2023
69f7734
Linting
Oct 6, 2023
72d1966
Add empty store_robot_action for P11 (temp fix due to ISPyB tests).
Oct 17, 2023
518f517
Fix in AbstractSampleChanger that was causing sample not loaded error…
Oct 25, 2023
a3a645d
Fixing the ambiguity with Poller value and .any
Sep 18, 2023
732d330
P11Collect additional debug after upgrade
Sep 18, 2023
dbf92d1
Force upgrade from the develop to avoid merging conflict
Sep 27, 2023
2b0d5e9
Removed is_open() as a function and assigned is_closed() as a propert…
Sep 27, 2023
2475e32
Upgraded the characterisation part for P11 using EDNA
Oct 6, 2023
738f981
Linting
Oct 6, 2023
d0bec06
Added new HO for the beam representation for P11 (Bixente)
Oct 25, 2023
9a07a93
Fix beam position update in P11 Nanodiff
Nov 8, 2023
4112629
Minor changes
Nov 8, 2023
ab9ec24
Added slits gap None (no slits) for P11 (Bixente)
Nov 8, 2023
f86bc95
Temp fix for P11 specific routine
Nov 8, 2023
7c64161
Merge remote-tracking branch 'origin/p11_develop' into p11_develop
Nov 8, 2023
349bda9
Renamed get_properties to get_properties_ as before and made appropri…
Nov 8, 2023
8037795
Merge branch 'p11_develop' of https://github.com/agruzinov/mxcubecore…
Nov 8, 2023
8ee4cc4
Cleanup unused code (PR800)
Nov 8, 2023
50be287
Fixing the ambiguity with Poller value and .any
Sep 18, 2023
888ec97
P11Collect additional debug after upgrade
Sep 18, 2023
a091d6f
Fixing the ambiguity with Poller value and .any
Sep 18, 2023
a01d46e
Force upgrade from the develop to avoid merging conflict
Sep 27, 2023
8414e3f
Added missing warnings module
Sep 27, 2023
3d8eaa8
Enabled back explicit check on if beamtimeid is open
Sep 27, 2023
2d02ae3
Added debug info in case beamtime ID is not opened
Sep 27, 2023
988c3c5
Added beamtime info as a property
Sep 27, 2023
ead7953
Added additional debug messages for shutter
Sep 27, 2023
40250bd
Fixed get_properties naming (Bixente)
Sep 27, 2023
ae8b878
Removed faulty login_type=user fot P11
Sep 27, 2023
13f14b8
Removed is_open() as a function and assigned is_closed() as a propert…
Sep 27, 2023
b021661
Added is_open as a property inside P11NanoDiff (Bixente)
Sep 27, 2023
f31ed83
Fixed other get_properties typos which were preventing loading
Sep 27, 2023
9aa5e33
Fixed shutter openning wainting forever (Bixente)
Oct 5, 2023
859bbf8
Added preliminary flux HO for P11
Oct 6, 2023
e095b64
Upgraded the characterisation part for P11 using EDNA
Oct 6, 2023
3965257
Linting
Oct 6, 2023
41adec3
Add empty store_robot_action for P11 (temp fix due to ISPyB tests).
Oct 17, 2023
3956097
Fix in AbstractSampleChanger that was causing sample not loaded error…
Oct 25, 2023
c3b5452
Fixing the ambiguity with Poller value and .any
Sep 18, 2023
5d45193
P11Collect additional debug after upgrade
Sep 18, 2023
81f2018
Force upgrade from the develop to avoid merging conflict
Sep 27, 2023
dbbe6d4
Enabled back explicit check on if beamtimeid is open
Sep 27, 2023
a801746
Added debug info in case beamtime ID is not opened
Sep 27, 2023
9f87b9d
Added additional debug messages for shutter
Sep 27, 2023
d5230fc
Removed is_open() as a function and assigned is_closed() as a propert…
Sep 27, 2023
fa994b1
Fixed shutter openning wainting forever (Bixente)
Oct 5, 2023
deb07e9
Added preliminary flux HO for P11
Oct 6, 2023
1aeb1f7
Upgraded the characterisation part for P11 using EDNA
Oct 6, 2023
23922d2
Linting
Oct 6, 2023
5fd5872
Added new HO for the beam representation for P11 (Bixente)
Oct 25, 2023
55100bc
Fix beam position update in P11 Nanodiff
Nov 8, 2023
73c9a05
Minor changes
Nov 8, 2023
a8d8fdf
Added slits gap None (no slits) for P11 (Bixente)
Nov 8, 2023
32c0666
Temp fix for P11 specific routine
Nov 8, 2023
2e722cc
Fixing the ambiguity with Poller value and .any
Sep 18, 2023
8f1755e
P11Collect additional debug after upgrade
Sep 18, 2023
2a41443
Force upgrade from the develop to avoid merging conflict
Sep 27, 2023
198be99
Added debug info in case beamtime ID is not opened
Sep 27, 2023
554d003
Added additional debug messages for shutter
Sep 27, 2023
4d320cc
Removed is_open() as a function and assigned is_closed() as a propert…
Sep 27, 2023
22f4a2a
Fixed shutter openning wainting forever (Bixente)
Oct 5, 2023
0076681
Added preliminary flux HO for P11
Oct 6, 2023
4f0dc72
Upgraded the characterisation part for P11 using EDNA
Oct 6, 2023
e9e7f7b
Linting
Oct 6, 2023
f6dc76d
Fixing the ambiguity with Poller value and .any
Sep 18, 2023
e7aa787
P11Collect additional debug after upgrade
Sep 18, 2023
01a26e9
Force upgrade from the develop to avoid merging conflict
Sep 27, 2023
1c72ab6
Removed is_open() as a function and assigned is_closed() as a propert…
Sep 27, 2023
bd966b3
Upgraded the characterisation part for P11 using EDNA
Oct 6, 2023
a25eaf7
Linting
Oct 6, 2023
0f434cb
Temp fix for P11 specific routine
Nov 8, 2023
e3fe513
Renamed get_properties to get_properties_ as before and made appropri…
Nov 8, 2023
50c6b83
Cleanup unused code (PR800)
Nov 8, 2023
8dcf8b4
Remove conflicts
Nov 15, 2023
1c872e6
Linting
Nov 15, 2023
46b4fe5
Linting
Nov 15, 2023
dfb0cb4
Removed unused file
Nov 15, 2023
13bfad3
Removed unused DigitalZoomMotor.py
Nov 15, 2023
85c4862
Removed unused Centring.py
Nov 15, 2023
85bc098
Put back deleted by mistake class
Nov 27, 2023
f03f779
Added guard variable to avoind recirsion error after sample loading i…
Nov 27, 2023
37b6915
Bugfix for osc_start always initialised as None in case default param…
Dec 2, 2023
b35f10f
Fixed add_h5_info function in case the file is already existing
Dec 2, 2023
31cd0b8
Changed path conversion in P11Characterisation.py
Dec 2, 2023
1bba3ed
Modified the way additional shutter values are handeled (PR800)
Dec 2, 2023
8686c65
Run black
Dec 2, 2023
c3a2a03
Disabled additional logging
Dec 2, 2023
3f63381
Remove unnessesary triggerring of autoprocessing. It is triggered aut…
Dec 12, 2023
1a0b15e
Set omega to 0 at the end explicitly
Dec 12, 2023
44d8f09
Merge branch 'mxcube:develop' into p11_develop
agruzinov Feb 20, 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
156 changes: 96 additions & 60 deletions mxcubecore/HardwareObjects/DESY/P11Collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,18 @@

from mxcubecore.Command.Tango import DeviceProxy

import gevent
import time
import numpy as np
import logging
import os
import sys
import math
import h5py

import triggerUtils

from tango import DeviceProxy, DevState

FILE_TIMEOUT = 5

Expand All @@ -50,13 +59,20 @@ class P11Collect(AbstractCollect):
def __init__(self, *args):
super(P11Collect, self).__init__(*args)

def init(self):

super(P11Collect, self).init()

# os.system("/opt/xray/bin/adxv -socket -colors Gray -rings &")

# os.system("/bin/bash /gpfs/local/shared/MXCuBE/STRELA/start_viewer_zmq.sh")

self.default_speed = self.get_property("omega_default_speed", 130)
self.turnback_time = self.get_property("turnback_time", 0.1)
self.turnback_time = self.get_property("turnback_time", 0.3)
self.filter_server_name = self.get_property("filterserver")
self.mono_server_name = self.get_property("monoserver")
self.filter_server = DeviceProxy(self.filter_server_name)
self.mono_server = DeviceProxy(self.mono_server_name)
self.diffr = HWR.beamline.diffractometer

self.lower_bound_ch = self.get_channel_object("acq_lower_bound")
self.upper_bound_ch = self.get_channel_object("acq_upper_bound")
Expand All @@ -66,18 +82,6 @@ def __init__(self, *args):
self.acq_off_cmd = self.get_command_object("acq_off")
self.acq_window_off_cmd = self.get_command_object("acq_window_off")

self.latest_frames = 1
self.acq_speed = 1.0
self.init_ok = False
self.latest_h5_filename = "TEST_master.h5"

def init(self):
super(P11Collect, self).init()

# os.system("/opt/xray/bin/adxv -socket -colors Gray -rings &")

# os.system("/bin/bash /gpfs/local/shared/MXCuBE/STRELA/start_viewer_zmq.sh")

if None in [
self.lower_bound_ch,
self.upper_bound_ch,
Expand Down Expand Up @@ -201,6 +205,11 @@ def data_collection_hook(self):
# Filepath to the EDNA processing
# filepath = os.path.join(basepath,"%s_%d" % (prefix, runno))

# setting up xds_dir for characterisation (used there internally to create dirs)
self.current_dc_parameters["xds_dir"] = os.path.join(
basepath, "%s_%d" % (prefix, runno)
)

self.log.debug(
"======= CURRENT FILEPATH: "
+ str(filepath)
Expand Down Expand Up @@ -282,23 +291,24 @@ def data_collection_hook(self):
# os.system("/opt/dectris/albula/4.0/bin/albula "+self.latest_h5_filename +" &")
# os.system("adxv "+self.latest_h5_filename +" &")

# TODO: Remove for now creation of the snapshots and processing html.
# Open index_html
os.system("firefox /gpfs/current/processed/index.html")
# os.system("firefox /gpfs/current/processed/index.html")

# Create diffraction snapshots
for i in range(nframes):
os.system(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity what did this do ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks interesting :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was the "plug" for creation of the snapshots before i realized that probably EDNA is doing that. But it is still pending. I've removed it for now as it was for the test.

"python3 /gpfs/local/shared/MXCuBE/hdf5tools/albula_api/generate_image.py --input "
+ self.latest_h5_filename
+ " --output "
+ os.path.join(
basepath, prefix, "screening_" + str(runno).zfill(3)
)
+ "/"
+ " --image_number "
+ str(i + 1)
)

# for i in range(nframes):
# os.system(
# "python3 /gpfs/local/shared/MXCuBE/hdf5tools/albula_api/generate_image.py --input "
# + self.latest_h5_filename
# + " --output "
# + os.path.join(
# basepath, prefix, "screening_" + str(runno).zfill(3)
# )
# + "/"
# + " --image_number "
# + str(i + 1)
# )
#
else:
self.collect_std_collection(start_angle, stop_angle)
self.generate_xds_template()
Expand All @@ -307,21 +317,21 @@ def data_collection_hook(self):
# os.system("killall albula")
# os.system("/opt/dectris/albula/4.0/bin/albula "+self.latest_h5_filename +" &")

# Open index_html
os.system("firefox /gpfs/current/processed/index.html")

# Create diffraction snapshots
os.system(
"python3 /gpfs/local/shared/MXCuBE/hdf5tools/albula_api/generate_image.py --input "
+ self.latest_h5_filename
+ " --output "
+ os.path.join(
basepath, prefix, "rotational_" + str(runno).zfill(3)
)
+ "/"
+ " --image_number 1"
)

# # Open index_html
# os.system("firefox /gpfs/current/processed/index.html")
#
# # Create diffraction snapshots
# os.system(
# "python3 /gpfs/local/shared/MXCuBE/hdf5tools/albula_api/generate_image.py --input "
# + self.latest_h5_filename
# + " --output "
# + os.path.join(
# basepath, prefix, "rotational_" + str(runno).zfill(3)
# )
# + "/"
# + " --image_number 1"
# )
#
except RuntimeError:
self.log.error(traceback.format_exc())
finally:
Expand All @@ -339,21 +349,28 @@ def collect_std_collection(self, start_angle, stop_angle):
:param stop_angle: The stop_angle parameter is the final angle at which the collection should
stop
"""
HWR.beamline.diffractometer.wait_omega()

self.omega_mv(start_angle, self.default_speed)
start_pos = start_angle - self.turnback_time * self.acq_speed
stop_pos = stop_angle + self.turnback_time * self.acq_speed

self.log.debug("#COLLECT# Running OMEGA through the std acquisition")
if start_angle <= stop_angle:
self.lower_bound_ch.set_value(start_angle)
self.upper_bound_ch.set_value(stop_angle)

else:
self.lower_bound_ch.set_value(stop_angle)
self.upper_bound_ch.set_value(start_angle)
self.acq_arm_cmd()

final_pos = stop_angle + self.acq_speed * self.turnback_time

self.omega_mv(final_pos, self.acq_speed)
self.omega_mv(start_pos, self.default_speed)
self.acq_arm_cmd()
self.omega_mv(stop_pos, self.acq_speed)
time.sleep(0.5)
self.acq_off_cmd()
self.acq_window_off_cmd()
self.omega_mv(stop_angle, self.acq_speed)
HWR.beamline.diffractometer.wait_omega()

def collect_characterisation(
self, start_angle, img_range, nimages, angle_inc, exp_time
Expand All @@ -374,35 +391,49 @@ def collect_characterisation(

diffr = HWR.beamline.diffractometer

self.log.debug("#COLLECT# Running OMEGA through the char acquisition")
self.log.debug(
"#COLLECT# Running OMEGA through the characteristation acquisition"
)

self.omega_mv(start_angle, self.default_speed)

for img_no in range(nimages):
print("collecting image %s" % img_no)
start_at = start_angle + angle_inc * img_no
stop_angle = start_at + img_range * 1.0
# print("======= CHARACTERISATION Adding angle and range to the header...")
# Add start angle to the header
# detector = HWR.beamline.detector
# detector.set_eiger_start_angle(start_at)

# Add angle increment to the header
# detector.set_eiger_angle_increment(angle_inc)

print("collecting image %s, angle %f" % (img_no, start_at))

if start_at >= stop_angle:
init_pos = start_at - self.acq_speed * self.turnback_time
init_pos = start_at # - self.acq_speed * self.turnback_time
# init_pos = start_at - 1.5
else:
init_pos = start_at + self.acq_speed * self.turnback_time
init_pos = start_at # + self.acq_speed * self.turnback_time
# init_pos = start_at + 1.5
self.omega_mv(init_pos, self.default_speed)
self.collect_std_collection(start_angle, stop_angle)

diffr.set_omega_velocity(self.default_speed)
self.acq_window_off_cmd()
self.acq_off_cmd()
# self.omega_mv(init_pos, self.default_speed)
self.collect_std_collection(start_at, stop_angle)

# This part goes to standard collection. Otherwise it produces phantom openings.
# diffr.set_omega_velocity(self.default_speed)
# self.acq_window_off_cmd()
# self.acq_off_cmd()
self.log.debug(
"======= collect_characterisation Waiting ======================================="
)

# Let adxv know whether it is
# self.adxv_notify(self.latest_h5_filename,img_no+1)

# time.sleep(1)

def adxv_notify(self, image_filename, image_num=1):
"""
The `adxv_notify` function sends a notification to an ADXV to load an image file and
Expand Down Expand Up @@ -439,12 +470,17 @@ def acquisition_cleanup(self):
try:
diffr = HWR.beamline.diffractometer
detector = HWR.beamline.detector
diffr.set_omega_velocity(self.default_speed)
self.acq_window_off_cmd()
detector.stop_acquisition()
diffr.wait_omega()
# =================
# It is probably already finished in a standard collection.
self.acq_off_cmd()
self.acq_window_off_cmd()
# ==================
diffr.set_omega_velocity(self.default_speed)
self.log.debug("#COLLECT# Closing detector cover")
diffr.detector_cover_close(wait=True)
detector.stop_acquisition()

except RuntimeError:
self.log.error(traceback.format_exc())

Expand Down Expand Up @@ -509,7 +545,7 @@ def add_h5_info(self, h5file):
del h5fd[node]
h5fd.close()

except RuntimeError as err_msg:
except RuntimeWarning as err_msg:
self.log.debug("Error while adding info to HDF5 file (%s)" % str(err_msg))
self.log.debug(traceback.format_exc())

Expand Down
23 changes: 9 additions & 14 deletions mxcubecore/HardwareObjects/DESY/P11DetectorCover.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ class P11DetectorCover(AbstractShutter):

@unique
class BaseValueEnum(Enum):
"""Defines only the compulsory values."""
OPEN = "OPEN"
CLOSED = "CLOSED"
MOVING = "MOVING"
UNKNOWN = "UNKNOWN"

VALUES=BaseValueEnum
"""Defines only the compulsory values."""

OPEN = "OPEN"
CLOSED = "CLOSED"
MOVING = "MOVING"
UNKNOWN = "UNKNOWN"

VALUES = BaseValueEnum
Copy link
Member

@beteva beteva Oct 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it inherits from AbstractShutter, no need to do this. Please see my comment comment below


def __init__(self, name):

Expand Down Expand Up @@ -196,14 +197,8 @@ def simulated_update(self):

self.update_value(value)
return value

def is_open(self):
"""Check if the shutter is open.
Returns:
(bool): True if open, False otherwise.
"""
return self.get_value() == self.VALUES.OPEN

@property
def is_closed(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we get rid of is_closed altogether? If you just write 'not is_open' everywhere that would mean one function less - and arguably a duplication less.

"""Check if the shutter is closed.
Returns:
Expand Down
32 changes: 32 additions & 0 deletions mxcubecore/HardwareObjects/DESY/P11EDNACharacterisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ def __init__(self, name):
self.edna_default_file = None
self.start_edna_command = None

def _run_edna(self, input_file, results_file, process_directory):
"""Starts EDNA"""
msg = "Starting EDNA characterisation using xml file %s" % input_file
logging.getLogger("queue_exec").info(msg)

args = (self.start_edna_command, input_file, results_file, process_directory)
# subprocess.call("%s %s %s %s" % args, shell=True)

# Test run DESY
self.edna_maxwell(process_directory, input_file, results_file)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats edna_maxwell ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the way to start EDNA on the cluster with proper path substitution. Is there a better way? In xml is the path to the edna bash script i assume? Is it run locally?


self.result = None
if os.path.exists(results_file):
self.result = XSDataResultMXCuBE.parseFile(results_file)

return self.result

def edna_maxwell(self, process_directory, inputxml, outputxml):
"""
The function `edna_maxwell` is used to execute a command on a remote cluster using SSH and SBATCH.
Expand Down Expand Up @@ -105,6 +122,12 @@ def edna_maxwell(self, process_directory, inputxml, outputxml):
)
)

print(
'{ssh:s} "{sbatch:s} --wrap \\"{cmd:s}"\\"'.format(
ssh=ssh, sbatch=sbatch, cmd=cmd
)
)

os.system(
'{ssh:s} "{sbatch:s} --wrap \\"{cmd:s}"\\"'.format(
ssh=ssh, sbatch=sbatch, cmd=cmd
Expand Down Expand Up @@ -236,15 +259,24 @@ def input_from_params(self, data_collection, char_params):
acquisition_parameters = data_collection.acquisitions[0].acquisition_parameters
path_template = data_collection.acquisitions[0].path_template

# Make sure there is a proper path conversion between different mount points
print(
"======= Characterisation path template ====", path_template.directory
) # /gpfs/current/raw

image_dir = path_template.directory.replace(
"/gpfs/current", triggerUtils.get_beamtime_metadata()[2]
)

print(image_dir)

path_str = os.path.join(image_dir, path_template.get_image_file_name())
print(path_template.xds_dir)

characterisation_dir = path_template.xds_dir.replace(
"/autoprocessing_", "/characterisation_"
)

os.makedirs(characterisation_dir, mode=0o755, exist_ok=True)

for img_num in range(int(acquisition_parameters.num_images)):
Expand Down
2 changes: 2 additions & 0 deletions mxcubecore/HardwareObjects/DESY/P11FastShutter.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ def init(self):
def get_value(self):
return self.update_fast_shutter()

@property
def is_open(self):
return self.get_value() == self.VALUES.OPEN

@property
def is_closed(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

return self.get_value() == self.VALUES.CLOSED

Comment on lines 66 to 76
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to define FastShutterVakue enum. As it inherits from AbstractNState, uou can simply do it in your xml file, like this:
<values>{"OPEN": "Open", "CLOSED": "Closed"}</values>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment. What is best way to adress it from the code?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you, please, be more explicit. The above comment means, that your self.VALUES.OPEN.value is "Open", as you probably need.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is my xml:

FastShutter
<tangoname>p11/shutter/fs</tangoname>

<channel type="tango" name="value" polling="500">value</channel>

<values>{"OPEN": "Open", "CLOSED": "Closed"}</values>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And mxcube is not happy:

File "/mxcubecore/mxcubecore/HardwareRepository.py", line 545, in parse_xml
hardware_obj = HardwareObjectFileParser.parse_string(xml_string, ho_name)
File "/mxcubecore/HardwareObjectFileParser.py", line 78, in parse_string
xml.sax.parseString(str.encode(xml_hardware_object), cur_handler)
File "/usr/lib/python3.7/xml/sax/init.py", line 48, in parseString
parser.parse(inpsrc)
File "/usr/lib/python3.7/xml/sax/expatreader.py", line 111, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/usr/lib/python3.7/xml/sax/xmlreader.py", line 125, in parse
self.feed(buffer)
File "/usr/lib/python3.7/xml/sax/expatreader.py", line 217, in feed
self._parser.Parse(data, isFinal)
File "../Modules/pyexpat.c", line 417, in StartElement
File "/usr/lib/python3.7/xml/sax/expatreader.py", line 333, in start_element
self._cont_handler.startElement(name, AttributesImpl(attrs))
File "HardwareObjectFileParser.py", line 276, in startElement
new_object = instanciate_class(module_name, class_name, object_name)
HardwareObjectFileParser.py", line 105, in instanciate_class
module = load_module(module_name)
File "/gpfs/local/shared/MXCuBE/mxcubecore/mxcubecore/HardwareObjectFileParser.py", line 91, in load_module
return import(hardware_object_name, globals(), locals(), [""])
File "mxcubecore/HardwareObjects/DESY/P11FastShutter.py", line 41, in
class P11FastShutter(AbstractNState):
File "/usr/lib/python3.7/enum.py", line 862, in unique
for name, member in enumeration.members.items():
AttributeError: type object 'P11FastShutter' has no attribute 'members'
2023-11-08 18:23:30,869 |HWR |ERROR | Failed to load Hardware object /fast-shutter

Expand Down
Loading