0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-14 03:31:50 +02:00

fix(ring): set_update changed to Literals, no need to specify endpoint manually

This commit is contained in:
2024-06-05 16:57:28 +02:00
parent a951ebf1be
commit c5b6499e41
2 changed files with 26 additions and 3 deletions

View File

@ -1902,9 +1902,13 @@ class Ring(RPCBase):
"""
@rpc_call
def set_connections(self, slot: "str", endpoint: "str | EndpointInfo"):
def set_update(self, mode: "Literal['manual', 'scan', 'device']", device: "str" = None):
"""
None
Set the update mode for the ring widget
Args:
mode(str): Update mode for the ring widget. Can be "manual", "scan" or "device"
device(str): Device name for the device readback mode, only used when mode is "device"
"""
@rpc_call

View File

@ -77,7 +77,7 @@ class Ring(BECConnector):
"set_line_width",
"set_min_max_values",
"set_start_angle",
"set_connections",
"set_update",
"reset_connection",
]
@ -147,6 +147,25 @@ class Ring(BECConnector):
converted_color = QtGui.QColor(*color)
return converted_color
def set_update(self, mode: Literal["manual", "scan", "device"], device: str = None):
"""
Set the update mode for the ring widget
Args:
mode(str): Update mode for the ring widget. Can be "manual", "scan" or "device"
device(str): Device name for the device readback mode, only used when mode is "device"
"""
if mode == "manual":
self.bec_dispatcher.disconnect_slot(
getattr(self, self.config.connections.slot), self.config.connections.endpoint
)
self.config.connections.slot = None
self.config.connections.endpoint = None
elif mode == "scan":
self.set_connections("on_scan_progress", "scans/scan_progress")
elif mode == "device":
self.set_connections("on_device_readback", f"internal/devices/readback/{device}")
def set_connections(self, slot: str, endpoint: str | EndpointInfo):
if self.config.connections.endpoint == endpoint and self.config.connections.slot == slot:
return