mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 11:41:49 +02:00
fix(cli): fix cli connector.send to set_and_publish for gui_instruction_response
This commit is contained in:
@ -540,3 +540,46 @@ class BECConnector(RPCBase):
|
||||
Returns:
|
||||
dict: The configuration of the plot widget.
|
||||
"""
|
||||
|
||||
|
||||
class BECImageItem(RPCBase):
|
||||
@rpc_call
|
||||
def set(self, **kwargs):
|
||||
"""
|
||||
None
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def set_color_map(self, cmap: "str" = "magma"):
|
||||
"""
|
||||
Set the color map of the image.
|
||||
Args:
|
||||
cmap(str): The color map of the image.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def set_auto_downsample(self, auto: "bool" = True):
|
||||
"""
|
||||
Set the auto downsample of the image.
|
||||
Args:
|
||||
auto(bool): Whether to downsample the image.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def set_monitor(self, monitor: "str"):
|
||||
"""
|
||||
Set the monitor of the image.
|
||||
Args:
|
||||
monitor(str): The name of the monitor.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def set_vrange(
|
||||
self, vmin: "float" = None, vmax: "float" = None, vrange: "tuple[int, int]" = None
|
||||
):
|
||||
"""
|
||||
Set the range of the color bar.
|
||||
Args:
|
||||
vmin(float): Minimum value of the color bar.
|
||||
vmax(float): Maximum value of the color bar.
|
||||
"""
|
||||
|
@ -132,7 +132,8 @@ class RPCBase:
|
||||
print(f"RPCBase: {rpc_msg}")
|
||||
# pylint: disable=protected-access
|
||||
receiver = self._root._gui_id
|
||||
self._client.connector.send(MessageEndpoints.gui_instructions(receiver), rpc_msg)
|
||||
# self._client.connector.send(MessageEndpoints.gui_instructions(receiver), rpc_msg)
|
||||
self._client.connector.set_and_publish(MessageEndpoints.gui_instructions(receiver), rpc_msg)
|
||||
|
||||
if not wait_for_rpc_response:
|
||||
return None
|
||||
|
@ -107,13 +107,22 @@ if __name__ == "__main__": # pragma: no cover
|
||||
import os
|
||||
|
||||
from bec_widgets.widgets.figure import BECFigure
|
||||
from bec_widgets.widgets.plots import BECPlotBase, BECWaveform1D, BECImageShow # ,BECCurve
|
||||
from bec_widgets.widgets.plots import BECPlotBase, BECWaveform1D, BECImageShow
|
||||
from bec_widgets.widgets.plots.waveform1d import BECCurve
|
||||
from bec_widgets.widgets.plots.image import BECImageItem
|
||||
from bec_widgets.utils import BECConnector
|
||||
|
||||
current_path = os.path.dirname(__file__)
|
||||
client_path = os.path.join(current_path, "client.py")
|
||||
clss = [BECPlotBase, BECWaveform1D, BECFigure, BECCurve, BECImageShow, BECConnector]
|
||||
clss = [
|
||||
BECPlotBase,
|
||||
BECWaveform1D,
|
||||
BECFigure,
|
||||
BECCurve,
|
||||
BECImageShow,
|
||||
BECConnector,
|
||||
BECImageItem,
|
||||
]
|
||||
generator = ClientGenerator()
|
||||
generator.generate_client(clss)
|
||||
generator.write(client_path)
|
||||
|
@ -42,7 +42,7 @@ class BECWidgetsCLIServer:
|
||||
self.send_response(request_id, True, {"result": res})
|
||||
|
||||
def send_response(self, request_id: str, accepted: bool, msg: dict):
|
||||
self.client.connector.set(
|
||||
self.client.connector.set_and_publish(
|
||||
MessageEndpoints.gui_instruction_response(request_id),
|
||||
messages.RequestResponseMessage(accepted=accepted, message=msg),
|
||||
expire=60,
|
||||
|
@ -53,7 +53,7 @@ class ImageConfig(WidgetConfig):
|
||||
)
|
||||
|
||||
|
||||
class BECImageItem(BECConnector, pg.ImageItem): # TODO decide how complex it should be
|
||||
class BECImageItem(BECConnector, pg.ImageItem):
|
||||
USER_ACCESS = ["set", "set_color_map", "set_auto_downsample", "set_monitor", "set_vrange"]
|
||||
|
||||
def __init__(
|
||||
|
Reference in New Issue
Block a user