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 23 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
124 changes: 75 additions & 49 deletions mxcubecore/HardwareObjects/DESY/P11Collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,42 @@

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


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.filter_server_name = self.get_property("filterserver")
self.mono_server_name = self.get_property("monoserver")
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,26 +84,9 @@ 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,
self.acq_arm_cmd,
self.acq_on_cmd,
self.acq_off_cmd,
self.acq_window_off_cmd,
]:
if None in [self.lower_bound_ch, self.upper_bound_ch,
self.acq_arm_cmd, self.acq_on_cmd, self.acq_off_cmd,
self.acq_window_off_cmd]:
self.init_ok = False
self.log.debug("lower_bound_ch: %s" % self.lower_bound_ch)
self.log.debug("upper_bound_ch: %s" % self.upper_bound_ch)
Expand All @@ -95,7 +96,6 @@ def init(self):
self.log.debug("acq_window_off_cmd: %s" % self.acq_window_off_cmd)
else:
self.init_ok = True

@task
def move_motors(self, motor_position_dict):
HWR.beamline.diffractometer.wait_omega()
Expand Down Expand Up @@ -339,21 +339,32 @@ 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)
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()
self.lower_bound_ch.set_value(stop_angle)
self.upper_bound_ch.set_value(start_angle)

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,34 +385,44 @@ 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.log.debug(
"======= collect_characterisation Waiting ======================================="
)
# 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
#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):
"""
Expand Down Expand Up @@ -439,12 +460,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
8 changes: 1 addition & 7 deletions mxcubecore/HardwareObjects/DESY/P11DetectorCover.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,7 @@ 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
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
2 changes: 0 additions & 2 deletions mxcubecore/HardwareObjects/DESY/P11ISPyBClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ def init(self):
"PROPOSAL NUMBER is %s" % self.simulated_prop_number
)

self.loginType = "user"

Copy link
Member

Choose a reason for hiding this comment

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

How come that you need a P11ISpyBClieant, do you have some extra stuff to handle ?

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 inherits from the IspybClient and adds for example simulated proposal option used for the testing with ISPyB instance. Maybe it can be replaced later once the system is completely up.

def update_data_collection(self, mx_collection, wait=False):
mx_collection["beamline_name"] = "P11"
ISPyBClient.update_data_collection(self, mx_collection, wait)
Expand Down
8 changes: 4 additions & 4 deletions mxcubecore/HardwareObjects/DESY/P11NanoDiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,9 +737,9 @@ def detector_cover_close(self, wait=True):
def wait_detcover(self, state, timeout=60):
start_time = time.time()
while time.time() - start_time > timeout:
if state == "open" and self.detcover_hwobj.is_open():
if state == "open" and self.detcover_hwobj.is_open:
break
elif state == "close" and self.detcover_hwobj.is_closed():
elif state == "close" and self.detcover_hwobj.is_closed:
break
gevent.sleep(0.5)

Expand Down Expand Up @@ -802,8 +802,8 @@ def update_phase(self, value=None):

omega_pos = self.get_omega_position()

cover_open = self.detcover_hwobj.is_open()
cover_closed = self.detcover_hwobj.is_closed()
cover_open = self.detcover_hwobj.is_open
cover_closed = self.detcover_hwobj.is_closed
blight_in = self.backlight_hwobj.is_in()
blight_out = self.backlight_hwobj.is_out()
collim = self.collimator_hwobj.get_position()
Expand Down
12 changes: 10 additions & 2 deletions mxcubecore/HardwareObjects/DESY/P11Session.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,13 @@ def info_set_defaults(self):
self.beamtime_info["rootPath"] = PATH_FALLBACK

def is_beamtime_open(self):
return True
# return self.is_writable_dir( os.path.join(PATH_BEAMTIME, self.raw_data_folder_name) )
self.log.debug("=========== CHECKING IF BEAMTIME ID IS OPEN... ============")
if self.is_writable_dir(os.path.join(PATH_BEAMTIME, self.raw_data_folder_name)):
self.log.debug("=========== BEAMTIME IS OPEN (/gpfs/current exists) ============")
else:
self.log.debug("=========== NO BEMTIME ID IS OPEN (check /gpfs/current) ============")

return self.is_writable_dir( os.path.join(PATH_BEAMTIME, self.raw_data_folder_name) )

def is_commissioning_open(self):
return self.is_writable_dir(
Expand All @@ -111,6 +116,9 @@ def get_current_proposal_number(self):
info = self.get_beamtime_info()
return info["proposalId"]

def get_beamtime_info(self):
return self.beamtime_info

def read_beamtime_info(self):
self.log.debug("=========== READING BEAMTIME INFO ============")
if os.path.exists(PATH_BEAMTIME):
Expand Down
24 changes: 23 additions & 1 deletion mxcubecore/HardwareObjects/DESY/P11Shutter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import gevent
import urllib
from mxcubecore.HardwareObjects.abstract.AbstractShutter import AbstractShutter
import mxcubecore.HardwareObjects.abstract.AbstractShutter as absshut
from mxcubecore.BaseHardwareObjects import HardwareObjectState
from enum import Enum, unique

Expand Down Expand Up @@ -85,6 +86,8 @@ def init(self):
else:
self.simulated_update()

self.update_state(self.STATES.READY)

super(AbstractShutter, self).init()

def get_value(self):
Expand All @@ -105,25 +108,39 @@ def _set_value(self, value):
if self.simulation:
self.simulated_opened = open_it
self.simulated_moving = True
gevent.spawn(self.simul_do)
self.t1 = gevent.spawn(self.simul_do)
self.t1.link(self.do_finish)
self.t1.link_exception(self.do_finish_exc)
else:
if open_it:
self.do_open()
else:
self.do_close()
self.cmd_started = time.time()
self.log.debug(" ### setting value value for shutter done")

def do_open(self, timeout=3):
self.log.debug(" OPENING SHUTTER (web request)")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will you be removing these when you have finished testing?

Copy link
Member

Choose a reason for hiding this comment

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

I guess its fine as its site specific code ? :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah. it was a gentle nudge, not a precondition for anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those are actually quite usefull for the debug on site. We have not yet recovered after the upgrate to the latest version.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK. This is a minor style thing anyway, so if you still need them of course you should keep them.

result = urllib.request.urlopen(self.url_open, None, timeout).readlines()
self.log.debug(" OPENING SHUTTER (web request) retured")

def do_close(self, timeout=3):
self.log.debug(" CLOSING SHUTTER (web request)")
result = urllib.request.urlopen(self.url_close, None, timeout).readlines()
self.log.debug(" CLOSING SHUTTER (web request) retured")

def simul_do(self):
self.log.debug("### starting simulated shutter move")
gevent.sleep(1)
self.simulated_moving = False
self.log.debug("### updating simulated shutter")
self.simulated_update()
self.log.debug("### ending simulated shutter move")

def do_finish(self, t=None):
self.log.debug("### simulated finished")
def do_finish_exc(self, exc=None):
self.log.debug("### simulated finished with exception")

def update_shutter_state(self, state=None):
"""Updates shutter state
Expand All @@ -133,9 +150,13 @@ def update_shutter_state(self, state=None):
if state is None:
state = self.chan_state.get_value()

self.log.debug(" SHUTTER state changed")

if state[0] == 3:
self.log.debug(" P11SHUTTER IS OPEN")
value = self.VALUES.OPEN
else:
self.log.debug(" P11SHUTTER IS CLOSED")
value = self.VALUES.CLOSED

# else:
Expand All @@ -146,6 +167,7 @@ def update_shutter_state(self, state=None):

self.update_value(value)

self.log.debug(" update shutter state done")
return value

def simulated_update(self):
Expand Down
1 change: 1 addition & 0 deletions mxcubecore/HardwareObjects/ISPyBClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pprint import pformat
from collections import namedtuple
from datetime import datetime
import warnings

try:
from urlparse import urljoin
Expand Down
4 changes: 2 additions & 2 deletions mxcubecore/HardwareObjects/MotorsNPosition.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def load_positions(self):
def get_position_list(self):
return list(self._positions.keys())

def get_properties_(self, position_index, property_name):
def get_properties(self, position_index, property_name):
Copy link
Contributor

Choose a reason for hiding this comment

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

If I am not mistaken, there is already a get_properties in one of the parent classes. Namely in HardwareObjectNode, via HardwareObject and AbstractActuator.

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. Changed.

"""
returns property with name property_name for position_index
if position_index is None returns OrderedDict with property_name for all positions
Expand Down Expand Up @@ -161,7 +161,7 @@ def set_position(self, posname):
posidx = -1
for name in self._positions:
posidx += 1
if posname == self.get_properties_(posidx, "posname"):
if posname == self.get_properties(posidx, "posname"):
self._set_value(posidx)
return

Expand Down