-
Notifications
You must be signed in to change notification settings - Fork 0
Implement EPICSNState Class #11
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
base: develop
Are you sure you want to change the base?
Changes from all commits
eef60e4
6f75c8f
88d48fa
f1b4a9a
c4410dc
d2b5804
ecf1e3d
08209d8
916c9cb
cd3e785
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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", "") | ||
| 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() | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)): | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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): | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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") | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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( | ||
|
|
||
There was a problem hiding this comment.
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.