bec-widgets 0.49.0__py3-none-any.whl → 0.50.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bec_widgets/cli/client.py +69 -4
- bec_widgets/cli/client_utils.py +18 -11
- bec_widgets/cli/rpc_register.py +76 -0
- bec_widgets/cli/server.py +8 -16
- bec_widgets/examples/jupyter_console/jupyter_console_window.py +5 -0
- bec_widgets/utils/bec_connector.py +21 -1
- bec_widgets/widgets/__init__.py +0 -1
- bec_widgets/widgets/figure/figure.py +23 -22
- bec_widgets/widgets/plots/image.py +14 -24
- bec_widgets/widgets/plots/motor_map.py +12 -19
- bec_widgets/widgets/plots/plot_base.py +1 -0
- bec_widgets/widgets/plots/waveform.py +18 -14
- {bec_widgets-0.49.0.dist-info → bec_widgets-0.50.0.dist-info}/METADATA +4 -4
- {bec_widgets-0.49.0.dist-info → bec_widgets-0.50.0.dist-info}/RECORD +23 -20
- tests/end-2-end/__init__.py +0 -0
- tests/end-2-end/conftest.py +25 -0
- tests/end-2-end/test_bec_figure_rpc_e2e.py +165 -0
- tests/end-2-end/test_rpc_register_e2e.py +50 -0
- tests/unit_tests/conftest.py +7 -0
- tests/unit_tests/test_rpc_register.py +52 -0
- bec_widgets/widgets/editor/__init__.py +0 -1
- bec_widgets/widgets/editor/editor.py +0 -407
- tests/unit_tests/test_editor.py +0 -170
- {bec_widgets-0.49.0.dist-info → bec_widgets-0.50.0.dist-info}/LICENSE +0 -0
- {bec_widgets-0.49.0.dist-info → bec_widgets-0.50.0.dist-info}/WHEEL +0 -0
- {bec_widgets-0.49.0.dist-info → bec_widgets-0.50.0.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: bec-widgets
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.50.0
|
4
4
|
Summary: BEC Widgets
|
5
5
|
Home-page: https://gitlab.psi.ch/bec/bec-widgets
|
6
6
|
Project-URL: Bug Tracker, https://gitlab.psi.ch/bec/bec-widgets/issues
|
@@ -12,8 +12,8 @@ Description-Content-Type: text/markdown
|
|
12
12
|
License-File: LICENSE
|
13
13
|
Requires-Dist: pydantic
|
14
14
|
Requires-Dist: qtconsole
|
15
|
-
Requires-Dist: PyQt6
|
16
|
-
Requires-Dist: PyQt6
|
15
|
+
Requires-Dist: PyQt6-Qt6 <=6.6.3
|
16
|
+
Requires-Dist: PyQt6 <=6.6.3
|
17
17
|
Requires-Dist: jedi
|
18
18
|
Requires-Dist: qtpy
|
19
19
|
Requires-Dist: pyqtgraph
|
@@ -33,7 +33,7 @@ Requires-Dist: isort ; extra == 'dev'
|
|
33
33
|
Provides-Extra: pyqt5
|
34
34
|
Requires-Dist: PyQt5 >=5.9 ; extra == 'pyqt5'
|
35
35
|
Provides-Extra: pyqt6
|
36
|
-
Requires-Dist: PyQt6
|
36
|
+
Requires-Dist: PyQt6 <=6.6.3 ; extra == 'pyqt6'
|
37
37
|
|
38
38
|
# BEC Widgets
|
39
39
|
|
@@ -2,16 +2,17 @@ bec_widgets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
bec_widgets/cli/__init__.py,sha256=ULoNTVnv2UeSSjhFq3uCQJ-0JTJf9oU76l27aRiizL4,78
|
3
3
|
bec_widgets/cli/auto_updates.py,sha256=ptZeBKr13o9THc8oKLn93K_16i6G3pxzw8hZ4MUgjW4,3845
|
4
4
|
bec_widgets/cli/bec_widgets_icon.png,sha256=pRCGpoOtwyZl97fBV_CHcGppliErzd0qQkCXLxjbp-s,5760
|
5
|
-
bec_widgets/cli/client.py,sha256=
|
6
|
-
bec_widgets/cli/client_utils.py,sha256=
|
5
|
+
bec_widgets/cli/client.py,sha256=AvkaEDKB8cZFm2WS5JWIusMXtcqErEeP2Ayk9l7iAp8,39163
|
6
|
+
bec_widgets/cli/client_utils.py,sha256=FBuU0LTi1lQrzRIH_4ued_isC_iknYMAaNxnSTsJvTw,10118
|
7
7
|
bec_widgets/cli/generate_cli.py,sha256=JLqUlUgfz_f_4KHPRUAN-Xli-K7uNOc8-F-LkAC7Scw,4004
|
8
|
-
bec_widgets/cli/
|
8
|
+
bec_widgets/cli/rpc_register.py,sha256=OZOWX0IKGXqDsnrUYi0Irl_zpPS4Q_JPCV9JQfN6YYw,2212
|
9
|
+
bec_widgets/cli/server.py,sha256=Xru-gLqDhTRIu6EnYIsFXeinMDW_NbtKYtPivlfdBY8,4772
|
9
10
|
bec_widgets/examples/__init__.py,sha256=WWQ0cu7m8sA4Ehy-DWdTIqSISjaHsbxhsNmNrMnhDZU,202
|
10
11
|
bec_widgets/examples/eiger_plot/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
12
|
bec_widgets/examples/eiger_plot/eiger_plot.py,sha256=Uxl2Usf8jEzaX7AT8zVqa1x8ZIEgI1HmazSlb-tRFWE,10359
|
12
13
|
bec_widgets/examples/eiger_plot/eiger_plot.ui,sha256=grHfnO3OG_lelJhdRsnA0badCvRdDunPrIMIyNQ5N-w,5809
|
13
14
|
bec_widgets/examples/jupyter_console/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
|
-
bec_widgets/examples/jupyter_console/jupyter_console_window.py,sha256=
|
15
|
+
bec_widgets/examples/jupyter_console/jupyter_console_window.py,sha256=aEwwOHNW4CJab41hbEB3hvWEEAPNtGjFQEwMo8GkEmM,3581
|
15
16
|
bec_widgets/examples/jupyter_console/jupyter_console_window.ui,sha256=GodXBvBvs5QAUsHbo3pcxR4o51Tvce4DTqpTluk3hOs,742
|
16
17
|
bec_widgets/examples/mca_readout/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
17
18
|
bec_widgets/examples/mca_readout/mca_plot.py,sha256=do7mSK_nzHtojRiMi8JoN_Rckg9yfjYYWz2S_Nl3xbE,5079
|
@@ -28,7 +29,7 @@ bec_widgets/examples/stream_plot/line_plot.ui,sha256=rgNfhOXu1AcWF0P6wnOlmJKDjS-
|
|
28
29
|
bec_widgets/examples/stream_plot/stream_plot.py,sha256=vHii1p9JxSyGQ_VcCjnk9SHJ41Q6Oi1GGd6swVVHLRM,12177
|
29
30
|
bec_widgets/simulations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
30
31
|
bec_widgets/utils/__init__.py,sha256=xytx86Yosjkta0PU4rHfoeO7FCPcimS15xjMPQUgIXc,403
|
31
|
-
bec_widgets/utils/bec_connector.py,sha256=
|
32
|
+
bec_widgets/utils/bec_connector.py,sha256=U_quQy7p1ISEpTnvwKsnDw5rdCc3jEoATfPVez2K7eI,4867
|
32
33
|
bec_widgets/utils/bec_dispatcher.py,sha256=sLv9CmJ3GKGDhvCXCDmuKtNRlI4w1oWxuQu_Mq2mDDY,4840
|
33
34
|
bec_widgets/utils/bec_table.py,sha256=Xy5qM343K8EvEpB4g_129b63yo1wdEvEY3wqxB_p_Iw,716
|
34
35
|
bec_widgets/utils/colors.py,sha256=JsLxzkxbw-I8GIuvnIKyiM83n0edhyMG2Fa4Ffm62ww,2392
|
@@ -43,11 +44,9 @@ bec_widgets/utils/widget_io.py,sha256=JKl508VnqQSxcaHqKaoBQ1TWSOm3pXhxQGx7iF_pRA
|
|
43
44
|
bec_widgets/utils/yaml_dialog.py,sha256=soZI8BOjlqYGfYDga70MEvkxJTsktq4y7B3uog2cSik,1851
|
44
45
|
bec_widgets/validation/__init__.py,sha256=ismd1bU5FhFb0zFPwNKuq7oT48G4Y2GfaMZOdNKUtGk,132
|
45
46
|
bec_widgets/validation/monitor_config_validator.py,sha256=M9p8K_nvxicnqJB4X7j90R377WHYVH4wMCtSXsRI51M,8150
|
46
|
-
bec_widgets/widgets/__init__.py,sha256=
|
47
|
-
bec_widgets/widgets/editor/__init__.py,sha256=5mBdFYi_IpygCz81kbLEZUWhd1b6oqiO3nASejuV_ug,30
|
48
|
-
bec_widgets/widgets/editor/editor.py,sha256=pIIYLPqqqhXqT11Xj10cyGEiy-ieNGE4ZujN5lf0e68,15110
|
47
|
+
bec_widgets/widgets/__init__.py,sha256=HBzIWJYX4dp2iDZl_qIuyy-X5IWRMhGwQ-4UisP8wqE,353
|
49
48
|
bec_widgets/widgets/figure/__init__.py,sha256=3hGx_KOV7QHCYAV06aNuUgKq4QIYCjUTad-DrwkUaBM,44
|
50
|
-
bec_widgets/widgets/figure/figure.py,sha256=
|
49
|
+
bec_widgets/widgets/figure/figure.py,sha256=IOj5rz3dXHOThtdLRPHx0lpoIQCLg-QbPGO1ECM-CKo,28484
|
51
50
|
bec_widgets/widgets/monitor/__init__.py,sha256=afXuZcBOxNAuYdCkIQXX5J60R5A3Q_86lNEW2vpFtPI,32
|
52
51
|
bec_widgets/widgets/monitor/config_dialog.py,sha256=Z1a4WRIVlfEGdwC-QG25kba2EHCZWi5J843tBVZlWiI,20275
|
53
52
|
bec_widgets/widgets/monitor/config_dialog.ui,sha256=ISMcF7CLTAMXhfZh2Yv5yezzAjMtb9fxY1pmX4B_jCg,5932
|
@@ -62,18 +61,22 @@ bec_widgets/widgets/motor_control/motor_control_table.ui,sha256=t6aRKiSmutMfp0Ay
|
|
62
61
|
bec_widgets/widgets/motor_map/__init__.py,sha256=K3c-3A_LbxK0UJ0_bV3opL-wGLTwBLendsJXsg8GAqE,32
|
63
62
|
bec_widgets/widgets/motor_map/motor_map.py,sha256=vJlLWa0BXv5KMZ7UVT0q3I1I5CXgsDiXoM_ptsAsG3c,21860
|
64
63
|
bec_widgets/widgets/plots/__init__.py,sha256=kGQTORTr-2M9vmVCK-T7AFre4bY5LVVzGxcIzT81-ZU,237
|
65
|
-
bec_widgets/widgets/plots/image.py,sha256=
|
66
|
-
bec_widgets/widgets/plots/motor_map.py,sha256=
|
67
|
-
bec_widgets/widgets/plots/plot_base.py,sha256=
|
68
|
-
bec_widgets/widgets/plots/waveform.py,sha256=
|
64
|
+
bec_widgets/widgets/plots/image.py,sha256=uanFs3YoAefLgfQnAW5oiQtssRLfhKmWHMlOMpb9HqQ,32504
|
65
|
+
bec_widgets/widgets/plots/motor_map.py,sha256=wbD95aIA4K3BLDZHZmHLblvKea7jPA7u4yw_tFaA4OE,15298
|
66
|
+
bec_widgets/widgets/plots/plot_base.py,sha256=ZieahcTwz0tynszdYe4r0rrOlWcRmXblplIYuuTX1ic,8474
|
67
|
+
bec_widgets/widgets/plots/waveform.py,sha256=CzPPq_9ZgBr4pZkLNSDqPbP8AJXXkan221-Fe8rw31c,28693
|
69
68
|
bec_widgets/widgets/scan_control/__init__.py,sha256=IOfHl15vxb_uC6KN62-PeUzbBha_vQyqkkXbJ2HU674,38
|
70
69
|
bec_widgets/widgets/scan_control/scan_control.py,sha256=tbO9tbVynRvs4VCxTZ4ZFBDTVAojIr-zkl70vuHbWgw,17116
|
71
70
|
bec_widgets/widgets/toolbar/__init__.py,sha256=d-TP4_cr_VbpwreMM4ePnfZ5YXsEPQ45ibEf75nuGoE,36
|
72
71
|
bec_widgets/widgets/toolbar/toolbar.py,sha256=sxz7rbc8XNPS6n2WMObF4-2PqdYfPxVtsOZEGV6mqa0,5124
|
73
72
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
73
|
+
tests/end-2-end/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
74
|
+
tests/end-2-end/conftest.py,sha256=jksYsc3Vm15LDyke-fmc80qCKBUnYuEjYi_QikeSOkE,756
|
75
|
+
tests/end-2-end/test_bec_figure_rpc_e2e.py,sha256=-eMCKkj6sh_OkuVRhVTGMw5KJOyNhzDR783jdi5hNM4,5350
|
76
|
+
tests/end-2-end/test_rpc_register_e2e.py,sha256=zqatLWjM_tYxiB3GgupYHHGTorGUFa0jvDFaqJpkZyA,1560
|
74
77
|
tests/unit_tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
75
78
|
tests/unit_tests/client_mocks.py,sha256=LNUgI9Ccv5Ol7_pmybIhoVqZZem1RPIsTDk7ZTARNls,4128
|
76
|
-
tests/unit_tests/conftest.py,sha256=
|
79
|
+
tests/unit_tests/conftest.py,sha256=KrnktXPWmZhnKNue-xGWOLD1XGEvdz9Vf7V2eO3XQ3A,596
|
77
80
|
tests/unit_tests/test_bec_connector.py,sha256=f2XXGGw3NoZLIUrDuZuEWwF_ttOYmmquCgUrV5XkIOY,1951
|
78
81
|
tests/unit_tests/test_bec_dispatcher.py,sha256=MtNyfC7-Y4na-Fwf1ny9raHBqE45eSnQNWSqqAx79FU,1857
|
79
82
|
tests/unit_tests/test_bec_figure.py,sha256=T4k-E1D3sjTTDTFZGdTFDQv0EYNQ_R-QbWOM7pQwFw4,7926
|
@@ -82,12 +85,12 @@ tests/unit_tests/test_bec_motor_map.py,sha256=IXSfitUGxOPqmngwVNPK5nwi2QDcXWjBkG
|
|
82
85
|
tests/unit_tests/test_client_utils.py,sha256=fIApd5WgnJuyIzV-hdSABn6T-aOel2Wr2xuUX4Z651A,774
|
83
86
|
tests/unit_tests/test_config_dialog.py,sha256=5uNGcpvrx8qDdMwFCTXr8HMzFZF4rFi-ZHoDpMxGMf8,6955
|
84
87
|
tests/unit_tests/test_crosshair.py,sha256=d7fX-ymboZPALNqqiAj86PZ96llmGZ_3jf0yjVP0S94,5039
|
85
|
-
tests/unit_tests/test_editor.py,sha256=TED5k1xFJHRZ4KDAg2VxSRu_hMJnra-lbAmVwsDicsM,6784
|
86
88
|
tests/unit_tests/test_eiger_plot.py,sha256=bWnKBQid0YcLMQeBLy6ojb4ZpwTG-rFVT0kMg9Y08p8,4427
|
87
89
|
tests/unit_tests/test_generate_cli_client.py,sha256=BdpTZMNUFOBJa2e-rme9AJUoXfueYyLiUCOpGi3SNvc,2400
|
88
90
|
tests/unit_tests/test_motor_control.py,sha256=jdTG35z3jOL9XCAIDNIGfdv60vcwGLHa3KJjKqJkoZw,20322
|
89
91
|
tests/unit_tests/test_motor_map.py,sha256=UEjmtIYI2mxq9BUeopqoqNNy7UiPJEts9h45ufsFcrA,5979
|
90
92
|
tests/unit_tests/test_plot_base.py,sha256=bOdlgAxh9oKk5PwiQ_MSFmzr44uJ61Tlg242RCIhl5c,2610
|
93
|
+
tests/unit_tests/test_rpc_register.py,sha256=hECjZEimd440mwRrO0rg7L3PKN7__3DgjmESN6wx3bo,1179
|
91
94
|
tests/unit_tests/test_scan_control.py,sha256=7dtGpE0g4FqUhhQeCkyJl-9o7NH3DFZJgEaqDmBYbBc,7551
|
92
95
|
tests/unit_tests/test_stream_plot.py,sha256=LNCYIj9CafremGaz-DwDktCRJRrjgfOdVewCUwwZE5s,5843
|
93
96
|
tests/unit_tests/test_validator_errors.py,sha256=NFxyv0TIOXeZKZRRUBfVQ7bpunwY4KkG95yTUdQmvns,3532
|
@@ -96,8 +99,8 @@ tests/unit_tests/test_widget_io.py,sha256=FeL3ZYSBQnRt6jxj8VGYw1cmcicRQyHKleahw7
|
|
96
99
|
tests/unit_tests/test_yaml_dialog.py,sha256=HNrqferkdg02-9ieOhhI2mr2Qvt7GrYgXmQ061YCTbg,5794
|
97
100
|
tests/unit_tests/test_msgs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
98
101
|
tests/unit_tests/test_msgs/available_scans_message.py,sha256=m_z97hIrjHXXMa2Ex-UvsPmTxOYXfjxyJaGkIY6StTY,46532
|
99
|
-
bec_widgets-0.
|
100
|
-
bec_widgets-0.
|
101
|
-
bec_widgets-0.
|
102
|
-
bec_widgets-0.
|
103
|
-
bec_widgets-0.
|
102
|
+
bec_widgets-0.50.0.dist-info/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
|
103
|
+
bec_widgets-0.50.0.dist-info/METADATA,sha256=2i8dBEDDsAAbm4Hgxf_Vt5h2weKOK-dQ0KKtb75wlG0,3719
|
104
|
+
bec_widgets-0.50.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
105
|
+
bec_widgets-0.50.0.dist-info/top_level.txt,sha256=EXCwhJYmXmd1DjYYL3hrGsddX-97IwYSiIHrf27FFVk,18
|
106
|
+
bec_widgets-0.50.0.dist-info/RECORD,,
|
File without changes
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import pytest
|
2
|
+
|
3
|
+
from bec_widgets.cli.rpc_register import RPCRegister
|
4
|
+
from bec_widgets.cli.server import BECWidgetsCLIServer
|
5
|
+
from bec_widgets.utils import BECDispatcher
|
6
|
+
|
7
|
+
|
8
|
+
@pytest.fixture(autouse=True)
|
9
|
+
def rpc_register():
|
10
|
+
yield RPCRegister()
|
11
|
+
RPCRegister.reset_singleton()
|
12
|
+
|
13
|
+
|
14
|
+
@pytest.fixture
|
15
|
+
def rpc_server(qtbot, bec_client_lib, threads_check):
|
16
|
+
dispatcher = BECDispatcher(client=bec_client_lib) # Has to init singleton with fixture client
|
17
|
+
server = BECWidgetsCLIServer(gui_id="figure")
|
18
|
+
qtbot.addWidget(server.fig)
|
19
|
+
qtbot.waitExposed(server.fig)
|
20
|
+
qtbot.wait(1000) # 1s long to wait until gui is ready
|
21
|
+
yield server
|
22
|
+
dispatcher.disconnect_all()
|
23
|
+
server.client.shutdown()
|
24
|
+
server.shutdown()
|
25
|
+
dispatcher.reset_singleton()
|
@@ -0,0 +1,165 @@
|
|
1
|
+
import numpy as np
|
2
|
+
import pytest
|
3
|
+
from bec_lib import MessageEndpoints
|
4
|
+
|
5
|
+
from bec_widgets.cli.client import BECFigure, BECImageShow, BECMotorMap, BECWaveform
|
6
|
+
|
7
|
+
|
8
|
+
def test_rpc_waveform1d_custom_curve(rpc_server, qtbot):
|
9
|
+
fig = BECFigure(rpc_server.gui_id)
|
10
|
+
fig_server = rpc_server.fig
|
11
|
+
|
12
|
+
ax = fig.add_plot()
|
13
|
+
curve = ax.add_curve_custom([1, 2, 3], [1, 2, 3])
|
14
|
+
curve.set_color("red")
|
15
|
+
curve = ax.curves[0]
|
16
|
+
curve.set_color("blue")
|
17
|
+
|
18
|
+
assert len(fig_server.widgets) == 1
|
19
|
+
assert len(fig_server.widgets["widget_1"].curves) == 1
|
20
|
+
|
21
|
+
|
22
|
+
def test_rpc_plotting_shortcuts_init_configs(rpc_server, qtbot):
|
23
|
+
fig = BECFigure(rpc_server.gui_id)
|
24
|
+
fig_server = rpc_server.fig
|
25
|
+
|
26
|
+
plt = fig.plot("samx", "bpm4i")
|
27
|
+
im = fig.image("eiger")
|
28
|
+
motor_map = fig.motor_map("samx", "samy")
|
29
|
+
plt_z = fig.add_plot("samx", "samy", "bpm4i")
|
30
|
+
|
31
|
+
# Checking if classes are correctly initialised
|
32
|
+
assert len(fig_server.widgets) == 4
|
33
|
+
assert plt.__class__.__name__ == "BECWaveform"
|
34
|
+
assert plt.__class__ == BECWaveform
|
35
|
+
assert im.__class__.__name__ == "BECImageShow"
|
36
|
+
assert im.__class__ == BECImageShow
|
37
|
+
assert motor_map.__class__.__name__ == "BECMotorMap"
|
38
|
+
assert motor_map.__class__ == BECMotorMap
|
39
|
+
|
40
|
+
# check if the correct devices are set
|
41
|
+
# plot
|
42
|
+
assert plt.config_dict["curves"]["bpm4i-bpm4i"]["signals"] == {
|
43
|
+
"source": "scan_segment",
|
44
|
+
"x": {"name": "samx", "entry": "samx", "unit": None, "modifier": None, "limits": None},
|
45
|
+
"y": {"name": "bpm4i", "entry": "bpm4i", "unit": None, "modifier": None, "limits": None},
|
46
|
+
"z": None,
|
47
|
+
}
|
48
|
+
# image
|
49
|
+
assert im.config_dict["images"]["eiger"]["monitor"] == "eiger"
|
50
|
+
# motor map
|
51
|
+
assert motor_map.config_dict["signals"] == {
|
52
|
+
"source": "device_readback",
|
53
|
+
"x": {
|
54
|
+
"name": "samx",
|
55
|
+
"entry": "samx",
|
56
|
+
"unit": None,
|
57
|
+
"modifier": None,
|
58
|
+
"limits": [-50.0, 50.0],
|
59
|
+
},
|
60
|
+
"y": {
|
61
|
+
"name": "samy",
|
62
|
+
"entry": "samy",
|
63
|
+
"unit": None,
|
64
|
+
"modifier": None,
|
65
|
+
"limits": [-50.0, 50.0],
|
66
|
+
},
|
67
|
+
"z": None,
|
68
|
+
}
|
69
|
+
# plot with z scatter
|
70
|
+
assert plt_z.config_dict["curves"]["bpm4i-bpm4i"]["signals"] == {
|
71
|
+
"source": "scan_segment",
|
72
|
+
"x": {"name": "samx", "entry": "samx", "unit": None, "modifier": None, "limits": None},
|
73
|
+
"y": {"name": "samy", "entry": "samy", "unit": None, "modifier": None, "limits": None},
|
74
|
+
"z": {"name": "bpm4i", "entry": "bpm4i", "unit": None, "modifier": None, "limits": None},
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
def test_rpc_waveform_scan(rpc_server, qtbot):
|
79
|
+
fig = BECFigure(rpc_server.gui_id)
|
80
|
+
|
81
|
+
# add 3 different curves to track
|
82
|
+
plt = fig.plot("samx", "bpm4i")
|
83
|
+
fig.plot("samx", "bpm3a")
|
84
|
+
fig.plot("samx", "bpm4d")
|
85
|
+
|
86
|
+
client = rpc_server.client
|
87
|
+
dev = client.device_manager.devices
|
88
|
+
scans = client.scans
|
89
|
+
queue = client.queue
|
90
|
+
|
91
|
+
status = scans.line_scan(dev.samx, -5, 5, steps=10, exp_time=0.05, relative=False)
|
92
|
+
|
93
|
+
# wait for scan to finish
|
94
|
+
while not status.status == "COMPLETED":
|
95
|
+
qtbot.wait(200)
|
96
|
+
|
97
|
+
last_scan_data = queue.scan_storage.storage[-1].data
|
98
|
+
|
99
|
+
# get data from curves
|
100
|
+
plt_data = plt.get_all_data()
|
101
|
+
|
102
|
+
# check plotted data
|
103
|
+
assert plt_data["bpm4i-bpm4i"]["x"] == last_scan_data["samx"]["samx"].val
|
104
|
+
assert plt_data["bpm4i-bpm4i"]["y"] == last_scan_data["bpm4i"]["bpm4i"].val
|
105
|
+
assert plt_data["bpm3a-bpm3a"]["x"] == last_scan_data["samx"]["samx"].val
|
106
|
+
assert plt_data["bpm3a-bpm3a"]["y"] == last_scan_data["bpm3a"]["bpm3a"].val
|
107
|
+
assert plt_data["bpm4d-bpm4d"]["x"] == last_scan_data["samx"]["samx"].val
|
108
|
+
assert plt_data["bpm4d-bpm4d"]["y"] == last_scan_data["bpm4d"]["bpm4d"].val
|
109
|
+
|
110
|
+
|
111
|
+
def test_rpc_image(rpc_server, qtbot):
|
112
|
+
fig = BECFigure(rpc_server.gui_id)
|
113
|
+
|
114
|
+
im = fig.image("eiger")
|
115
|
+
|
116
|
+
client = rpc_server.client
|
117
|
+
dev = client.device_manager.devices
|
118
|
+
scans = client.scans
|
119
|
+
|
120
|
+
status = scans.line_scan(dev.samx, -5, 5, steps=10, exp_time=0.05, relative=False)
|
121
|
+
|
122
|
+
# wait for scan to finish
|
123
|
+
while not status.status == "COMPLETED":
|
124
|
+
qtbot.wait(200)
|
125
|
+
|
126
|
+
last_image_device = client.connector.get_last(MessageEndpoints.device_monitor("eiger"))[
|
127
|
+
"data"
|
128
|
+
].data
|
129
|
+
qtbot.wait(500)
|
130
|
+
last_image_plot = im.images[0].get_data()
|
131
|
+
|
132
|
+
# check plotted data
|
133
|
+
np.testing.assert_equal(last_image_device, last_image_plot)
|
134
|
+
|
135
|
+
|
136
|
+
def test_rpc_motor_map(rpc_server, qtbot):
|
137
|
+
fig = BECFigure(rpc_server.gui_id)
|
138
|
+
fig_server = rpc_server.fig
|
139
|
+
|
140
|
+
motor_map = fig.motor_map("samx", "samy")
|
141
|
+
|
142
|
+
client = rpc_server.client
|
143
|
+
dev = client.device_manager.devices
|
144
|
+
scans = client.scans
|
145
|
+
|
146
|
+
initial_pos_x = dev.samx.read()["samx"]["value"]
|
147
|
+
initial_pos_y = dev.samy.read()["samy"]["value"]
|
148
|
+
|
149
|
+
status = scans.mv(dev.samx, 1, dev.samy, 2, relative=True)
|
150
|
+
|
151
|
+
# wait for scan to finish
|
152
|
+
while not status.status == "COMPLETED":
|
153
|
+
qtbot.wait(200)
|
154
|
+
final_pos_x = dev.samx.read()["samx"]["value"]
|
155
|
+
final_pos_y = dev.samy.read()["samy"]["value"]
|
156
|
+
|
157
|
+
# check plotted data
|
158
|
+
motor_map_data = motor_map.get_data()
|
159
|
+
|
160
|
+
np.testing.assert_equal(
|
161
|
+
[motor_map_data["x"][0], motor_map_data["y"][0]], [initial_pos_x, initial_pos_y]
|
162
|
+
)
|
163
|
+
np.testing.assert_equal(
|
164
|
+
[motor_map_data["x"][-1], motor_map_data["y"][-1]], [final_pos_x, final_pos_y]
|
165
|
+
)
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import pytest
|
2
|
+
|
3
|
+
from bec_widgets.cli.client import BECFigure, BECImageShow, BECMotorMap, BECWaveform
|
4
|
+
|
5
|
+
|
6
|
+
def find_deepest_value(d: dict):
|
7
|
+
"""
|
8
|
+
Recursively find the deepest value in a dictionary
|
9
|
+
Args:
|
10
|
+
d(dict): Dictionary to search
|
11
|
+
|
12
|
+
Returns:
|
13
|
+
The deepest value in the dictionary.
|
14
|
+
"""
|
15
|
+
if isinstance(d, dict):
|
16
|
+
if d:
|
17
|
+
return find_deepest_value(next(iter(d.values())))
|
18
|
+
return d
|
19
|
+
|
20
|
+
|
21
|
+
def test_rpc_register_list_connections(rpc_server, rpc_register, qtbot):
|
22
|
+
fig = BECFigure(rpc_server.gui_id)
|
23
|
+
fig_server = rpc_server.fig
|
24
|
+
|
25
|
+
plt = fig.plot("samx", "bpm4i")
|
26
|
+
im = fig.image("eiger")
|
27
|
+
motor_map = fig.motor_map("samx", "samy")
|
28
|
+
plt_z = fig.add_plot("samx", "samy", "bpm4i")
|
29
|
+
|
30
|
+
all_connections = rpc_register.list_all_connections()
|
31
|
+
|
32
|
+
# Construct dict of all rpc items manually
|
33
|
+
all_subwidgets_expected = dict(fig_server.widgets)
|
34
|
+
curve_1D = find_deepest_value(fig_server.widgets[plt.rpc_id]._curves_data)
|
35
|
+
curve_2D = find_deepest_value(fig_server.widgets[plt_z.rpc_id]._curves_data)
|
36
|
+
curves_expected = {curve_1D.rpc_id: curve_1D, curve_2D.rpc_id: curve_2D}
|
37
|
+
fig_expected = {fig.rpc_id: fig_server}
|
38
|
+
image_item_expected = {
|
39
|
+
fig_server.widgets[im.rpc_id].images[0].rpc_id: fig_server.widgets[im.rpc_id].images[0]
|
40
|
+
}
|
41
|
+
|
42
|
+
all_connections_expected = {
|
43
|
+
**all_subwidgets_expected,
|
44
|
+
**curves_expected,
|
45
|
+
**fig_expected,
|
46
|
+
**image_item_expected,
|
47
|
+
}
|
48
|
+
|
49
|
+
assert len(all_connections) == 8
|
50
|
+
assert all_connections == all_connections_expected
|
tests/unit_tests/conftest.py
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
import pytest
|
2
2
|
|
3
|
+
from bec_widgets.cli.rpc_register import RPCRegister
|
3
4
|
from bec_widgets.utils import bec_dispatcher as bec_dispatcher_module
|
4
5
|
|
5
6
|
|
7
|
+
@pytest.fixture(autouse=True)
|
8
|
+
def rpc_register():
|
9
|
+
yield RPCRegister()
|
10
|
+
RPCRegister.reset_singleton()
|
11
|
+
|
12
|
+
|
6
13
|
@pytest.fixture(autouse=True)
|
7
14
|
def bec_dispatcher(threads_check):
|
8
15
|
bec_dispatcher = bec_dispatcher_module.BECDispatcher()
|
@@ -0,0 +1,52 @@
|
|
1
|
+
from bec_widgets.cli.rpc_register import RPCRegister
|
2
|
+
|
3
|
+
|
4
|
+
class FakeObject:
|
5
|
+
def __init__(self, gui_id):
|
6
|
+
self.gui_id = gui_id
|
7
|
+
|
8
|
+
|
9
|
+
def test_add_connection(rpc_register):
|
10
|
+
obj1 = FakeObject("id1")
|
11
|
+
obj2 = FakeObject("id2")
|
12
|
+
|
13
|
+
rpc_register.add_rpc(obj1)
|
14
|
+
rpc_register.add_rpc(obj2)
|
15
|
+
|
16
|
+
all_connections = rpc_register.list_all_connections()
|
17
|
+
|
18
|
+
assert len(all_connections) == 2
|
19
|
+
assert all_connections["id1"] == obj1
|
20
|
+
assert all_connections["id2"] == obj2
|
21
|
+
|
22
|
+
|
23
|
+
def test_remove_connection(rpc_register):
|
24
|
+
|
25
|
+
obj1 = FakeObject("id1")
|
26
|
+
obj2 = FakeObject("id2")
|
27
|
+
|
28
|
+
rpc_register.add_rpc(obj1)
|
29
|
+
rpc_register.add_rpc(obj2)
|
30
|
+
|
31
|
+
rpc_register.remove_rpc(obj1)
|
32
|
+
|
33
|
+
all_connections = rpc_register.list_all_connections()
|
34
|
+
|
35
|
+
assert len(all_connections) == 1
|
36
|
+
assert all_connections["id2"] == obj2
|
37
|
+
|
38
|
+
|
39
|
+
def test_reset_singleton(rpc_register):
|
40
|
+
obj1 = FakeObject("id1")
|
41
|
+
obj2 = FakeObject("id2")
|
42
|
+
|
43
|
+
rpc_register.add_rpc(obj1)
|
44
|
+
rpc_register.add_rpc(obj2)
|
45
|
+
|
46
|
+
rpc_register.reset_singleton()
|
47
|
+
rpc_register = RPCRegister()
|
48
|
+
|
49
|
+
all_connections = rpc_register.list_all_connections()
|
50
|
+
|
51
|
+
assert len(all_connections) == 0
|
52
|
+
assert all_connections == {}
|
@@ -1 +0,0 @@
|
|
1
|
-
from .editor import BECEditor
|