File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -215,11 +215,13 @@ class SimpleRemoteProxy(SimpleBaseProxy):
215215 True
216216 >>> proxy.get_object_titles()
217217 ['toto']
218- >>> proxy.get_object_from_title( "toto")
218+ >>> proxy[ "toto"]
219219 <cdlclient.model.signal.SignalObj at 0x7f7f1c0b4a90>
220- >>> proxy.get_object(1)
220+ >>> "toto" in proxy
221+ True
222+ >>> proxy[1]
221223 <cdlclient.model.signal.SignalObj at 0x7f7f1c0b4a90>
222- >>> proxy.get_object(1) .data
224+ >>> proxy[1] .data
223225 array([1., 2., 3.])
224226 """
225227
Original file line number Diff line number Diff line change @@ -63,6 +63,15 @@ between your application and DataLab:
6363
6464 Screenshot of remote client application test (``cdlclient.tests.remoteclient_app ``)
6565
66+ Example
67+ ^^^^^^^
68+
69+ Here is an example in Python 3 of a script that connects to a running DataLab
70+ instance, adds a signal and an image, and then runs calculations (the cell
71+ structure of the script make it convenient to be used in `Spyder `_ IDE):
72+
73+ .. literalinclude :: remote_example.py
74+
6675Additional features
6776^^^^^^^^^^^^^^^^^^^
6877
Original file line number Diff line number Diff line change 1+ # -*- coding: utf-8 -*-
2+ """
3+ Example of remote control of DataLab current session,
4+ from a Python script running outside DataLab (e.g. in Spyder)
5+
6+ Created on Fri May 12 12:28:56 2023
7+
8+ @author: p.raybaut
9+ """
10+
11+ # %% Importing necessary modules
12+
13+ # NumPy for numerical array computations:
14+ import numpy as np
15+
16+ # DataLab remote control client:
17+ from cdlclient import SimpleRemoteProxy
18+
19+ # %% Connecting to DataLab current session
20+
21+ proxy = SimpleRemoteProxy ()
22+ proxy .connect ()
23+
24+ # %% Executing commands in DataLab (...)
25+
26+ z = np .random .rand (20 , 20 )
27+ proxy .add_image ("toto" , z )
28+
29+ # %% Executing commands in DataLab (...)
30+
31+ x = np .array ([1.0 , 2.0 , 3.0 ])
32+ y = np .array ([4.0 , 5.0 , - 1.0 ])
33+ proxy .add_signal ("toto" , x , y )
34+
35+ # %% Executing commands in DataLab (...)
36+
37+ proxy .compute_derivative ()
38+
39+ # %% Executing commands in DataLab (...)
40+
41+ proxy .set_current_panel ("image" )
42+
43+ # %% Executing commands in DataLab (...)
44+
45+ proxy .compute_fft ()
You can’t perform that action at this time.
0 commit comments