mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31:50 +02:00
feat: motor move to absolute (X,Y) coordinates
This commit is contained in:
@ -138,6 +138,43 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>X</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QLabel" name="label_7">
|
||||||
|
<property name="text">
|
||||||
|
<string>Y</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QPushButton" name="pushButton_go_absolute">
|
||||||
|
<property name="text">
|
||||||
|
<string>Go</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QSpinBox" name="spinBox_absolute_x"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QSpinBox" name="spinBox_absolute_y"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_stop">
|
<widget class="QPushButton" name="pushButton_stop">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -12,6 +12,7 @@ import pyqtgraph as pg
|
|||||||
class MotorApp(QWidget):
|
class MotorApp(QWidget):
|
||||||
motor_position = pyqtSignal(float) # TODO hook to motor position update
|
motor_position = pyqtSignal(float) # TODO hook to motor position update
|
||||||
motor_update = pyqtSignal()
|
motor_update = pyqtSignal()
|
||||||
|
motor_position_xy = pyqtSignal(list)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@ -72,6 +73,13 @@ class MotorApp(QWidget):
|
|||||||
self.checkBox_enableArrows.stateChanged.connect(self.update_arrow_key_shortcuts)
|
self.checkBox_enableArrows.stateChanged.connect(self.update_arrow_key_shortcuts)
|
||||||
self.update_arrow_key_shortcuts()
|
self.update_arrow_key_shortcuts()
|
||||||
|
|
||||||
|
# Move to absolute coordinates
|
||||||
|
self.pushButton_go_absolute.clicked.connect(
|
||||||
|
lambda: self.move_motor_coordinates(
|
||||||
|
[self.spinBox_absolute_x.value(), self.spinBox_absolute_y.value()]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
# SpinBoxes - Motor Limits #TODO make spinboxes own limits updated, currently is [-1000, 1000]
|
# SpinBoxes - Motor Limits #TODO make spinboxes own limits updated, currently is [-1000, 1000]
|
||||||
# manually set limits before readout #TODO will be removed when spinboxes have own limits
|
# manually set limits before readout #TODO will be removed when spinboxes have own limits
|
||||||
# dev.samx.low_limit = -100
|
# dev.samx.low_limit = -100
|
||||||
@ -100,6 +108,7 @@ class MotorApp(QWidget):
|
|||||||
|
|
||||||
# Map
|
# Map
|
||||||
self.motor_position.connect(lambda x: self.update_image_map(*self.get_xy()))
|
self.motor_position.connect(lambda x: self.update_image_map(*self.get_xy()))
|
||||||
|
self.motor_update.connect(lambda: self.update_image_map(*self.get_xy()))
|
||||||
|
|
||||||
self.motor_position.connect(lambda x: print(f"motor position updated: {x}"))
|
self.motor_position.connect(lambda x: print(f"motor position updated: {x}"))
|
||||||
self.motor_update.connect(
|
self.motor_update.connect(
|
||||||
@ -207,6 +216,8 @@ class MotorApp(QWidget):
|
|||||||
|
|
||||||
while status.status not in ["COMPLETED", "STOPPED"]:
|
while status.status not in ["COMPLETED", "STOPPED"]:
|
||||||
print(status.status)
|
print(status.status)
|
||||||
|
motor_position = motor.position()
|
||||||
|
self.motor_position.emit(motor_position)
|
||||||
|
|
||||||
# return status
|
# return status
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -217,6 +228,21 @@ class MotorApp(QWidget):
|
|||||||
self.motor_position.emit(motor_position)
|
self.motor_position.emit(motor_position)
|
||||||
self.motor_update.emit()
|
self.motor_update.emit()
|
||||||
|
|
||||||
|
def move_motor_coordinates(self, coor: list) -> None:
|
||||||
|
try:
|
||||||
|
status = scans.mv(dev.samx, coor[0], dev.samy, coor[1], relative=False)
|
||||||
|
|
||||||
|
while status.status not in ["COMPLETED", "STOPPED"]:
|
||||||
|
print(status.status)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
|
# motor_position = self.get_xy()
|
||||||
|
# self.motor_position_xy.emit(motor_position)
|
||||||
|
|
||||||
|
self.motor_update.emit()
|
||||||
|
|
||||||
def get_xy(self): # TODO decide if useful
|
def get_xy(self): # TODO decide if useful
|
||||||
"""Get current motor position"""
|
"""Get current motor position"""
|
||||||
x = dev.samx.position()
|
x = dev.samx.position()
|
||||||
|
Reference in New Issue
Block a user