From 5d6a328728a017eb4f1d191c96d2659800d41941 Mon Sep 17 00:00:00 2001 From: wyzula-jan <133381102+wyzula-jan@users.noreply.github.com> Date: Tue, 5 Sep 2023 10:04:22 +0200 Subject: [PATCH] feat: go, set, save current coordinates and keyboard shortcuts --- .../motor_movement/motor_controller.ui | 193 +++++++++++++----- .../examples/motor_movement/motor_example.py | 28 ++- 2 files changed, 170 insertions(+), 51 deletions(-) diff --git a/bec_widgets/examples/motor_movement/motor_controller.ui b/bec_widgets/examples/motor_movement/motor_controller.ui index 39bbe6ef..f9425aa4 100644 --- a/bec_widgets/examples/motor_movement/motor_controller.ui +++ b/bec_widgets/examples/motor_movement/motor_controller.ui @@ -6,8 +6,8 @@ 0 0 - 1129 - 550 + 1219 + 668 @@ -92,6 +92,53 @@ + + + + + + Decimal + + + + + + + Qt::AlignCenter + + + 8 + + + 2 + + + + + + + Step + + + + + + + Qt::AlignCenter + + + 0.100000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + @@ -99,6 +146,12 @@ + + + 26 + 26 + + ... @@ -122,6 +175,12 @@ + + + 26 + 26 + + ... @@ -132,6 +191,12 @@ + + + 26 + 26 + + ... @@ -155,6 +220,12 @@ + + + 26 + 26 + + ... @@ -189,19 +260,6 @@ - - - - 0.100000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - @@ -228,17 +286,39 @@ - - - - X - + + Qt::AlignCenter + + -500.000000000000000 + + + 500.000000000000000 + + + 0.100000000000000 + - + + + + Qt::AlignCenter + + + -500.000000000000000 + + + 500.000000000000000 + + + 0.100000000000000 + + + + Y @@ -248,39 +328,41 @@ - + + + + X + + + Qt::AlignCenter + + + + + + + + + + + Save + + + + + + + Set + + + + Go - - - - -500.000000000000000 - - - 500.000000000000000 - - - 0.100000000000000 - - - - - - - -500.000000000000000 - - - 500.000000000000000 - - - 0.100000000000000 - - - @@ -302,7 +384,7 @@ true - 0 + 2 @@ -353,6 +435,9 @@ + + false + Motor Limits @@ -569,6 +654,16 @@ Queue + + + + Work in progress + + + Qt::AlignCenter + + + diff --git a/bec_widgets/examples/motor_movement/motor_example.py b/bec_widgets/examples/motor_movement/motor_example.py index 8cc06061..1613b08a 100644 --- a/bec_widgets/examples/motor_movement/motor_example.py +++ b/bec_widgets/examples/motor_movement/motor_example.py @@ -69,7 +69,7 @@ class MotorApp(QWidget): self.tag_N = 1 # position label for saved coordinates # Get all motors available - self.motor_thread.retrieve_all_motors() + self.motor_thread.retrieve_all_motors() # TODO link to combobox that it always refresh def connect_motor(self, motor_x_name: str, motor_y_name: str): """ @@ -265,14 +265,28 @@ class MotorApp(QWidget): self.spinBox_absolute_x.value(), self.spinBox_absolute_y.value() ) ) + + # Go absolute button self.pushButton_go_absolute.clicked.connect(self.save_absolute_coordinates) self.pushButton_go_absolute.setShortcut("Ctrl+G") self.pushButton_go_absolute.setToolTip("Ctrl+G") + # Set absolute coordinates + self.pushButton_set.clicked.connect(self.save_absolute_coordinates) + self.pushButton_set.setShortcut("Ctrl+S") + self.pushButton_set.setToolTip("Ctrl+S") + + # Save Current coordinates + self.pushButton_save.clicked.connect(self.save_current_coordinates) + self.pushButton_save.setShortcut("Ctrl+D") + self.pushButton_save.setToolTip("Ctrl+D") + self.motor_thread.move_finished.connect(lambda: self.enable_motor_controls(True)) # Stop Button self.pushButton_stop.clicked.connect(self.motor_thread.stop_movement) + self.pushButton_stop.setShortcut("Ctrl+X") + self.pushButton_stop.setToolTip("Ctrl+X") ########################## # Motor Configs @@ -453,7 +467,17 @@ class MotorApp(QWidget): self.tableWidget_coordinates, (self.spinBox_absolute_x.value(), self.spinBox_absolute_y.value()), tag=f"Pos {self.tag_N}", - precision=0, + precision=self.spinBox_precision.value(), + ) + + self.tag_N += 1 + + def save_current_coordinates(self): + self.generate_table_coordinate( + self.tableWidget_coordinates, + self.motor_thread.retrieve_coordinates(), + tag=f"Current {self.tag_N}", + precision=self.spinBox_precision.value(), ) self.tag_N += 1