diff --git a/bec_widgets/cli/client.py b/bec_widgets/cli/client.py index 6457a18f..27b8a378 100644 --- a/bec_widgets/cli/client.py +++ b/bec_widgets/cli/client.py @@ -51,6 +51,8 @@ _Widgets = { "RingProgressBar": "RingProgressBar", "ScanControl": "ScanControl", "ScatterWaveform": "ScatterWaveform", + "SignalComboBox": "SignalComboBox", + "SignalLineEdit": "SignalLineEdit", "StopButton": "StopButton", "TextBox": "TextBox", "VSCodeEditor": "VSCodeEditor", @@ -939,9 +941,22 @@ class DeviceComboBox(RPCBase): """Combobox widget for device input with autocomplete for device names.""" @rpc_call - def remove(self): + def set_device(self, device: "str"): """ - Cleanup the BECConnector + Set the device. + + Args: + device (str): Default name. + """ + + @property + @rpc_call + def devices(self) -> "list[str]": + """ + Get the list of devices for the applied filters. + + Returns: + list[str]: List of devices. """ @@ -959,9 +974,32 @@ class DeviceLineEdit(RPCBase): """Line edit widget for device input with autocomplete for device names.""" @rpc_call - def remove(self): + def set_device(self, device: "str"): """ - Cleanup the BECConnector + Set the device. + + Args: + device (str): Default name. + """ + + @property + @rpc_call + def devices(self) -> "list[str]": + """ + Get the list of devices for the applied filters. + + Returns: + list[str]: List of devices. + """ + + @property + @rpc_call + def _is_valid_input(self) -> bool: + """ + Check if the current value is a valid device name. + + Returns: + bool: True if the current value is a valid device name, False otherwise. """ @@ -3347,6 +3385,80 @@ class ScatterWaveform(RPCBase): """ +class SignalComboBox(RPCBase): + """Line edit widget for device input with autocomplete for device names.""" + + @rpc_call + def set_signal(self, signal: str): + """ + Set the signal. + + Args: + signal (str): signal name. + """ + + @rpc_call + def set_device(self, device: str | None): + """ + Set the device. If device is not valid, device will be set to None which happpens + + Args: + device(str): device name. + """ + + @property + @rpc_call + def signals(self) -> list[str]: + """ + Get the list of device signals for the applied filters. + + Returns: + list[str]: List of device signals. + """ + + +class SignalLineEdit(RPCBase): + """Line edit widget for device input with autocomplete for device names.""" + + @property + @rpc_call + def _is_valid_input(self) -> bool: + """ + Check if the current value is a valid device name. + + Returns: + bool: True if the current value is a valid device name, False otherwise. + """ + + @rpc_call + def set_signal(self, signal: str): + """ + Set the signal. + + Args: + signal (str): signal name. + """ + + @rpc_call + def set_device(self, device: str | None): + """ + Set the device. If device is not valid, device will be set to None which happpens + + Args: + device(str): device name. + """ + + @property + @rpc_call + def signals(self) -> list[str]: + """ + Get the list of device signals for the applied filters. + + Returns: + list[str]: List of device signals. + """ + + class StopButton(RPCBase): """A button that stops the current scan.""" diff --git a/bec_widgets/widgets/control/device_input/device_combobox/device_combobox.py b/bec_widgets/widgets/control/device_input/device_combobox/device_combobox.py index 5e39f77e..1a51a661 100644 --- a/bec_widgets/widgets/control/device_input/device_combobox/device_combobox.py +++ b/bec_widgets/widgets/control/device_input/device_combobox/device_combobox.py @@ -26,6 +26,8 @@ class DeviceComboBox(DeviceInputBase, QComboBox): arg_name: Argument name, can be used for the other widgets which has to call some other function in bec using correct argument names. """ + USER_ACCESS = ["set_device", "devices"] + ICON_NAME = "list_alt" PLUGIN = True diff --git a/bec_widgets/widgets/control/device_input/device_line_edit/device_line_edit.py b/bec_widgets/widgets/control/device_input/device_line_edit/device_line_edit.py index d65b8575..6055999e 100644 --- a/bec_widgets/widgets/control/device_input/device_line_edit/device_line_edit.py +++ b/bec_widgets/widgets/control/device_input/device_line_edit/device_line_edit.py @@ -29,6 +29,8 @@ class DeviceLineEdit(DeviceInputBase, QLineEdit): arg_name: Argument name, can be used for the other widgets which has to call some other function in bec using correct argument names. """ + USER_ACCESS = ["set_device", "devices", "_is_valid_input"] + device_selected = Signal(str) device_config_update = Signal() @@ -51,7 +53,7 @@ class DeviceLineEdit(DeviceInputBase, QLineEdit): **kwargs, ): self._callback_id = None - self._is_valid_input = False + self.__is_valid_input = False self._accent_colors = get_accent_colors() super().__init__(parent=parent, client=client, gui_id=gui_id, config=config, **kwargs) self.completer = QCompleter(self) @@ -95,6 +97,20 @@ class DeviceLineEdit(DeviceInputBase, QLineEdit): self.textChanged.connect(self.check_validity) self.check_validity(self.text()) + @property + def _is_valid_input(self) -> bool: + """ + Check if the current value is a valid device name. + + Returns: + bool: True if the current value is a valid device name, False otherwise. + """ + return self.__is_valid_input + + @_is_valid_input.setter + def _is_valid_input(self, value: bool) -> None: + self.__is_valid_input = value + def on_device_update(self, action: str, content: dict) -> None: """ Callback for device update events. Triggers the device_update signal. diff --git a/bec_widgets/widgets/control/device_input/signal_combobox/signal_combobox.py b/bec_widgets/widgets/control/device_input/signal_combobox/signal_combobox.py index babd2064..92c1f6a3 100644 --- a/bec_widgets/widgets/control/device_input/signal_combobox/signal_combobox.py +++ b/bec_widgets/widgets/control/device_input/signal_combobox/signal_combobox.py @@ -23,8 +23,11 @@ class SignalComboBox(DeviceSignalInputBase, QComboBox): arg_name: Argument name, can be used for the other widgets which has to call some other function in bec using correct argument names. """ + USER_ACCESS = ["set_signal", "set_device", "signals"] + ICON_NAME = "list_alt" PLUGIN = True + RPC = True device_signal_changed = Signal(str) diff --git a/bec_widgets/widgets/control/device_input/signal_line_edit/signal_line_edit.py b/bec_widgets/widgets/control/device_input/signal_line_edit/signal_line_edit.py index 6e4263f2..4c8ecb0d 100644 --- a/bec_widgets/widgets/control/device_input/signal_line_edit/signal_line_edit.py +++ b/bec_widgets/widgets/control/device_input/signal_line_edit/signal_line_edit.py @@ -24,9 +24,12 @@ class SignalLineEdit(DeviceSignalInputBase, QLineEdit): arg_name: Argument name, can be used for the other widgets which has to call some other function in bec using correct argument names. """ + USER_ACCESS = ["_is_valid_input", "set_signal", "set_device", "signals"] + device_signal_changed = Signal(str) PLUGIN = True + RPC = True ICON_NAME = "vital_signs" def __init__( @@ -41,7 +44,7 @@ class SignalLineEdit(DeviceSignalInputBase, QLineEdit): arg_name: str | None = None, **kwargs, ): - self._is_valid_input = False + self.__is_valid_input = False super().__init__(parent=parent, client=client, gui_id=gui_id, config=config, **kwargs) self._accent_colors = get_accent_colors() self.completer = QCompleter(self) @@ -68,6 +71,20 @@ class SignalLineEdit(DeviceSignalInputBase, QLineEdit): self.textChanged.connect(self.check_validity) self.check_validity(self.text()) + @property + def _is_valid_input(self) -> bool: + """ + Check if the current value is a valid device name. + + Returns: + bool: True if the current value is a valid device name, False otherwise. + """ + return self.__is_valid_input + + @_is_valid_input.setter + def _is_valid_input(self, value: bool) -> None: + self.__is_valid_input = value + def get_current_device(self) -> object: """ Get the current device object based on the current value.