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

Updated versions of DESY P11 HO (PR 800, 854) #856

Merged
merged 8 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion mxcubecore/HardwareObjects/DESY/Centring.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with MXCuBE. If not, see <http://www.gnu.org/licenses/>.

__copyright__ = """ Copyright © 2010 - 2020 by MXCuBE Collaboration """
__copyright__ = """ Copyright © 2010 - 2024 by MXCuBE Collaboration """
__license__ = "LGPLv3+"


Expand Down
2 changes: 1 addition & 1 deletion mxcubecore/HardwareObjects/DESY/MjpgStreamVideo.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ def _do_imagePolling(self, sleep_time):
# image.setOffset(QPoint(300,300))
# self.image = QPixmap.fromImage(image)
self.image = QPixmap.fromImage(
image.scaled(self.display_width, self.display_height)
image.scaled(int(self.display_width), int(self.display_height))
)
self.emit("imageReceived", self.image)
# gevent.sleep(0.1)
8 changes: 4 additions & 4 deletions mxcubecore/HardwareObjects/DESY/P11AlbulaView.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
# You should have received a copy of the GNU Lesser General Public License
# along with MXCuBE. If not, see <http://www.gnu.org/licenses/>.

__copyright__ = """ Copyright © 2010 - 2023 by MXCuBE Collaboration """
from mxcubecore.BaseHardwareObjects import HardwareObject

__copyright__ = """ Copyright © 2010 - 2024 by MXCuBE Collaboration """
__license__ = "LGPLv3+"


import sys
import time
from PIL import Image


sys.path.append("/opt/dectris/albula/4.0/python/")

from mxcubecore.BaseHardwareObjects import HardwareObject

Copy link
Member

Choose a reason for hiding this comment

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

I like the idea of this the AlbulaView, as I understand it it starts Albula on the same machine as MXCuBE is running and gets the images from the detector zero-mq stream ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but it is not completely implemented. Also in the python 3.11 this line leads to the segfault anyway. This will require a bit more work yet.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, i see. Did you also foresee to display a certain image on demand ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally it is working right now with in-house software as a standard viewer (made by Jan). It shows the monitor interfaces during data collection and than changes to the recently collected file and shows it afterwards, so one can scroll back if needed. I was trying to understand whether the Adxv can show anything during data collection, but before hdf5 is saved, there is no way I guess.

Copy link
Member

Choose a reason for hiding this comment

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

Hm, not sure. I don't think so

try:
from dectris import albula
Expand Down Expand Up @@ -99,7 +99,7 @@ def start(self, path=None, filetype=None, interval=None, stream=False):
self.eigerThread.clearMonitorBuffer()
self.eigerThread.setMonitorDiscardNew(True)

super(LiveView, self).start()
super().start()

def stop(self, interval=0.0):

Expand Down
4 changes: 2 additions & 2 deletions mxcubecore/HardwareObjects/DESY/P11BackLight.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class P11BackLight(AbstractNState):

def __init__(self, name):

super(AbstractNState, self).__init__(name)
super().__init__(name)

self.cmd_open_close = None
self.cmd_started = 0
Expand All @@ -72,7 +72,7 @@ def init(self):
self.chan_value.connect_signal("update", self.update_light_state)

self.update_light_state(self.chan_value.get_value())
super(AbstractNState, self).init()
super().init()

def get_value(self):
return self.update_light_state()
Expand Down
107 changes: 107 additions & 0 deletions mxcubecore/HardwareObjects/DESY/P11Beam.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Project: MXCuBE
# https://github.com/mxcube
#
# This file is part of MXCuBE software.
#
# MXCuBE is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# MXCuBE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with MXCuBE. If not, see <http://www.gnu.org/licenses/>.

"""P11Beam"""

from mxcubecore.HardwareObjects.abstract.AbstractBeam import AbstractBeam
from mxcubecore.BaseHardwareObjects import HardwareObjectState


__credits__ = ["DESY P11"]
__license__ = "LGPLv3+"
__category__ = "General"


class P11Beam(AbstractBeam):
def __init__(self, *args):
super().__init__(*args)

self._beam_size_dict = {"aperture": [9999, 9999], "slits": [9999, 9999]}

self._beam_position_on_screen = [340, 256]

self.focus_sizes = {
-1: {"label": "unknown", "size": (0.2, 0.2)},
0: {"label": "flat", "size": (0.2, 0.2)},
1: {"label": "200x200", "size": (0.2, 0.2)},
2: {"label": "100x100", "size": (0.1, 0.1)},
3: {"label": "50x50", "size": (0.05, 0.05)},
4: {"label": "20x20", "size": (0.02, 0.02)},
5: {"label": "4x9", "size": (0.009, 0.004)},
}

def init(self):
self.mirror_idx_ch = self.get_channel_object("beamsize")
self.mirror_state_ch = self.get_channel_object("state")

if self.mirror_idx_ch is not None:
self.mirror_idx_ch.connect_signal("update", self.mirror_idx_changed)
if self.mirror_state_ch is not None:
self.mirror_state_ch.connect_signal("update", self.mirror_state_changed)

self.mirror_idx_changed()
self.mirror_state_changed()

def get_beam_info_state(self):
if self.mirror_state_ch is not None:
tango_state = self.mirror_state_ch.get_value()
return self._convert_tango_state(tango_state)

return self.STATES_READY

def get_slits_gap(self):
return None, None

def mirror_state_changed(self, state=None):

if state is None:
state = self.get_beam_info_state()

self.update_state(self._convert_tango_state(state))

def _convert_tango_state(self, state):
str_state = str(state)

if str_state == "ON":
_state = self.STATES.READY
elif str_state == "MOVING":
_state = self.STATES.BUSY
else:
_state = self.STATES.FAULT
return _state

def mirror_idx_changed(self, value=None):

if value is None:
value = self.mirror_idx_ch.get_value()

self.log.debug(f"P11Beam - mirror idx changed. now is {value}")

if value not in self.focus_sizes:
value = -1
self.log.debug(f" - UNKNOWN mirror index")

curr_size_item = self.focus_sizes[value]
self.log.debug(
f" current mirror focus is {curr_size_item['label']}: {curr_size_item['size']}"
)

self._beam_size_dict["aperture"] = curr_size_item["size"]

self.evaluate_beam_info()
self.re_emit_values()
Loading
Loading