mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 11:41:49 +02:00
feat: active motors from motor_map.py can be changed by slot without changing the whole config
This commit is contained in:
@ -383,6 +383,9 @@ class MotorControlRelative(MotorControlWidget):
|
|||||||
lambda error: MotorControlErrors.display_error_message(error)
|
lambda error: MotorControlErrors.display_error_message(error)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Stop Button
|
||||||
|
self.pushButton_stop.clicked.connect(self.motor_thread.stop_movement)
|
||||||
|
|
||||||
def _init_keyboard_shortcuts(self) -> None:
|
def _init_keyboard_shortcuts(self) -> None:
|
||||||
"""Initialize the keyboard shortcuts"""
|
"""Initialize the keyboard shortcuts"""
|
||||||
|
|
||||||
|
@ -74,6 +74,11 @@ class MotorControlMap(QWidget):
|
|||||||
layout.addWidget(splitter)
|
layout.addWidget(splitter)
|
||||||
self.setLayout(layout)
|
self.setLayout(layout)
|
||||||
|
|
||||||
|
# Connecting signals and slots
|
||||||
|
self.motor_control_panel.selection_widget.selected_motors_signal.connect(
|
||||||
|
lambda x, y: self.motion_map.change_motors(x, y, 0)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class MotorControlPanel(QWidget):
|
class MotorControlPanel(QWidget):
|
||||||
def __init__(self, parent=None, client=None, config=None):
|
def __init__(self, parent=None, client=None, config=None):
|
||||||
|
@ -122,6 +122,28 @@ class MotorMap(pg.GraphicsLayoutWidget):
|
|||||||
else: # TODO implement validator
|
else: # TODO implement validator
|
||||||
print("Do validation")
|
print("Do validation")
|
||||||
|
|
||||||
|
@pyqtSlot(str, str, int)
|
||||||
|
def change_motors(self, motor_x: str, motor_y: str, subplot: int = 0) -> None:
|
||||||
|
"""
|
||||||
|
Change the active motors for the plot.
|
||||||
|
Args:
|
||||||
|
motor_x(str): Motor name for the X axis.
|
||||||
|
motor_y(str): Motor name for the Y axis.
|
||||||
|
subplot(int): Subplot number.
|
||||||
|
"""
|
||||||
|
if subplot >= len(self.plot_data):
|
||||||
|
print(f"Invalid subplot index: {subplot}. Available subplots: {len(self.plot_data)}")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Update the motor names in the plot configuration
|
||||||
|
self.config["motors"][subplot]["signals"]["x"][0]["name"] = motor_x
|
||||||
|
self.config["motors"][subplot]["signals"]["x"][0]["entry"] = motor_x
|
||||||
|
self.config["motors"][subplot]["signals"]["y"][0]["name"] = motor_y
|
||||||
|
self.config["motors"][subplot]["signals"]["y"][0]["entry"] = motor_y
|
||||||
|
|
||||||
|
# reinitialise the config and UI
|
||||||
|
self._init_config()
|
||||||
|
|
||||||
def _init_config(self):
|
def _init_config(self):
|
||||||
"""Initiate the configuration."""
|
"""Initiate the configuration."""
|
||||||
|
|
||||||
@ -146,6 +168,9 @@ class MotorMap(pg.GraphicsLayoutWidget):
|
|||||||
# Connect motors to slots
|
# Connect motors to slots
|
||||||
self._connect_motors_to_slots()
|
self._connect_motors_to_slots()
|
||||||
|
|
||||||
|
# Render init position of selected motors
|
||||||
|
self._update_plots()
|
||||||
|
|
||||||
def _get_global_settings(self):
|
def _get_global_settings(self):
|
||||||
"""Get global settings from the config."""
|
"""Get global settings from the config."""
|
||||||
self.plot_settings = self.config.get("plot_settings", {})
|
self.plot_settings = self.config.get("plot_settings", {})
|
||||||
|
Reference in New Issue
Block a user