Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
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
7 changes: 7 additions & 0 deletions mxcubecore/HardwareObjects/LNLS/EPICS/EPICSActuator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ def __init__(self, name):
def init(self):
self.update_state(self.STATES.READY)
self.connect(self.get_channel_object("rbv"), "update", self.update_value)
low_limit = self.get_property("low_limit")
high_limit = self.get_property("high_limit")
tolerance = self.get_property("tolerance")
if (low_limit is not None) and (high_limit is not None):
self._nominal_limits = (low_limit, high_limit)
if (tolerance is not None):
self.unit = tolerance

def hasnt_arrived(self, setpoint):
readback = self.get_value()
Expand Down
67 changes: 67 additions & 0 deletions mxcubecore/HardwareObjects/LNLS/EPICS/EPICSNState.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import gevent
import threading
import time
from enum import Enum
from mxcubecore.HardwareObjects.abstract.AbstractNState import AbstractNState
from mxcubecore.HardwareObjects.LNLS.EPICS.EPICSActuator import EPICSActuator
from mxcubecore.HardwareObjects.abstract.AbstractNState import BaseValueEnum


class EPICSNState(EPICSActuator, AbstractNState):

def init(self):
super().init()
low_limit = self.get_property("low_limit", "")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think the limits should be in the EPICSActuator class. And if they are not set, the class should get the values directly from the PV.

high_limit = self.get_property("high_limit", "")
limits = (int(low_limit), int(high_limit))
self.set_limits(limits)
self._initialise_values()
self.update_limits(limits)
current_value = self.get_value()
self.update_value(current_value)
self.update_state(self.STATES.READY)

def wait_ready(self, timeout):
self._wait_task = threading.Event()
try:
with gevent.Timeout(timeout, exception=TimeoutError):
while (
self.setpoint != EPICSActuator.get_value(self) and not self._wait_task.is_set()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The EPICSActuator could be generalize to accept strings, and this wait_ready method could be removed.

):
time.sleep(0.15)
except TimeoutError:
pvname = self.get_channel_object("rbv").command.pv_name
self.print_log(level="error", msg=f"Motion has timed out.")
self.update_state(self.STATES.READY)

def _set_value(self, value):
if isinstance(value, Enum):
value = value.value
EPICSActuator._set_value(self, value)

def get_value(self):
value = EPICSActuator.get_value(self)
return self.value_to_enum(value)

def set_limits(self, limits=(None, None)):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this should be in the EPICSActuator

self._nominal_limits = limits
self.emit("limitsChanged", (self._nominal_limits,))

def update_limits(self, limits=None):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The name should be standardized with the one in EPICSMotor that is called get_limits. And maybe set in the EPICSActuator

if limits is None:
limits = self.get_limits()

self._nominal_limits = limits
self.emit("limitsChanged", (limits,))

def _initialise_values(self):
low, high = self.get_limits()
values = self.get_property("values")
self.VALUES = Enum(
"ValueEnum",
dict(values, **{item.name: item.value for item in BaseValueEnum}),
)

def update_value(self, value=None) -> None:
value = self.value_to_enum(value)
super().update_value(value)
6 changes: 4 additions & 2 deletions mxcubecore/HardwareObjects/LNLS/LNLSDiffractometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,11 @@ def calculate_move_to_beam_pos(self, x, y):
level="debug", msg=f"Última posição clicada pelo usuário: x={x}, y={y}"
)

zoom = self.getObjectByRole("zoom")
calibration_x = zoom.getProperty("mm_per_pixel_x")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Change to this file will cause a conflict with the bluesky branch

calibration_y = zoom.getProperty("mm_per_pixel_y")
print(calibration_x, calibration_y)
# Obtém posições atuais dos motores
omega_pos = self.motor_hwobj_dict["phi"].get_value()
goniox_pos = self.motor_hwobj_dict["phiz"].get_value()
sampx_pos = self.motor_hwobj_dict["sampx"].get_value()
sampy_pos = self.motor_hwobj_dict["sampy"].get_value()
self.print_log(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "mxcubecore"
version = "1.439.0"
version = "1.418.0"
license = "LGPL-3.0-or-later"
description = "Core libraries for the MXCuBE application"
authors = [
Expand Down