Skip to content

Commit 0eae737

Browse files
author
Kay Kasemir (ky9)
committed
XY scan
1 parent 0aa9cd8 commit 0eae737

File tree

10 files changed

+1040
-3255
lines changed

10 files changed

+1040
-3255
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Python
22
*.pyc
33

4+
build/*
5+
46
# Generated docs
57
doc/_build
68
doc/version.rst

doc/getting_started.rst

Lines changed: 83 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,41 @@ Initial Setup
99
We assume that you already have a recent version of EPICS base installed
1010
with access to commands like `softIoc`, `caget`, `caput`.
1111

12+
Prepare the PyScanClient::
13+
14+
git clone https://github.com/PythonScanClient/PyScanClient.git
15+
cd PyScanClient
16+
python setup.py build
17+
export PYTHONPATH=`pwd`/build/lib
18+
1219
The scan server is a CS-Studio service.
1320
Both the scan server and the CS-Studio GUI can be built
1421
from https://github.com/ControlSystemStudio/phoebus.
15-
Binaries are for example available from
22+
More convenient binaries are available from
1623
https://controlssoftware.sns.ornl.gov/css_phoebus/nightly/
1724

25+
Create a settings file for CS-Studio that holds the path to
26+
this python library::
27+
28+
echo org.csstudio.display.builder.runtime/python_path=$PYTHONPATH >>my_settings.ini
29+
30+
You may also add common settings like CA or PVA address lists
31+
to that file, or add the `..runtime/python_path` setting to
32+
an already existing local settings file.
33+
1834
All CS-Studio tools are based on Java. The CS-Studio GUI binary
1935
may bundle a java runtime. If it includes a `jdk` folder, use that.
2036
Otherwise fetch a Java runtime from https://jdk.java.net
2137
Either way, declare your JDK and add its `bin` folder to the PATH::
2238

2339
export JAVA_HOME=/path/to/jdk
2440
export PATH=$JAVA_HOME/bin:$PATH
25-
26-
Check::
27-
2841
java -version
2942

30-
Assuming a binary, start the scan server like this::
43+
Assuming you fetched a scan server binary, start the scan server like this::
3144

3245
unzip scan-server.zip
46+
rm scan-server.zip
3347
cd scan-server-*
3448
./scan-server.sh
3549

@@ -45,23 +59,21 @@ On success, note the REST URL and list of console commands::
4559
You would stop the scan server by typing `shutdown`, then restart via `scan-server.sh`.
4660

4761

48-
Beamline Simulation
49-
-------------------
50-
51-
Subsequent sections use a simple beamline simulation.
62+
Test Beamline
63+
-------------
5264

53-
While we will use the complete PyScanClient later,
54-
fetch it now to obtain that simulation and run it like this::
65+
Subsequent sections use a simple test beamline.
66+
Run it like this::
5567

56-
git clone https://github.com/PythonScanClient/PyScanClient.git
5768
cd PyScanClient/example
5869
softIoc -d ioc/simulation.db
5970

6071
Assuming you fetched a binary for CS-Studio, start the associated GUI like this::
6172

62-
unzip phoebus-linux.zip
73+
unzip phoebus-linux.zip
74+
rm phoebus-linux.zip
6375
cd phoebus-*/
64-
./phoebus.sh -resource /path/to/PyScanClient/example/opi/1_BeamLine.opi
76+
./phoebus.sh -settings /path/to/my_settings.ini -resource /path/to/PyScanClient/example/opi/1_BeamLine.bob
6577

6678
.. image:: simulation.png
6779

@@ -134,7 +146,6 @@ CS-Studio GUI
134146
* In CS-Studio, invoke the menu Applications, Scan, Scan Monitor.
135147
You should see the last submitted scan as "Finished-OK",
136148
the others as simply "Logged".
137-
138149
* Right-click on any scan and open the "Data Table".
139150
* Right-click no the "Finished" scan and open the "Scan Editor".
140151
* In the scan editor, right-click to "Submit scan".
@@ -158,11 +169,11 @@ CS-Studio GUI
158169
scans, or aborted.
159170
* In the scan monitor, selet a few older scans, right-click on them and "Remove selected".
160171

161-
In an operational setup, the scan monitor can be very useful to monitor
172+
The scan monitor is very useful to monitor
162173
the progress of queued and active scans.
163174

164175
The scan editor could be used to manually assemble small scans,
165-
or to debug scans that have been submitted by other means.
176+
but it's mainly meant to debug scans that have been submitted by other means.
166177

167178
The scan server will hold the commands of past scans in memory
168179
and persist the logged data on disk, but this
@@ -177,9 +188,59 @@ it is thus suggested to manually remove information for older scans,
177188
either by deleting selected scans or by invoking "Remove completed scans"
178189
from the scan monitor context menu.
179190

180-
PyScanClient
181-
------------
191+
Basic PyScanClient
192+
------------------
193+
194+
Check the content of `example/commands1.py`
195+
and run it::
182196

197+
cd example
198+
python commands1.py
199+
200+
201+
.. literalinclude:: ../example/commands1.py
202+
203+
Note how the python script assembles a list of commands.
204+
It builds the recipe for one "scan", submits it to the scan server,
205+
and exits.
206+
The scan server then spends more than a minute to execute the submitted
207+
commands.
208+
209+
In the CS-Studio scan monitor, right-click on the running scan to open
210+
the "Scan Data Table" and watch how samples are added.
211+
This internal data logger is again not meant to replace data aquisition,
212+
but meant to assist in tracknig the progress of scans and to debug them.
213+
214+
For more on the available scan commands, read the other sections
215+
of this document.
216+
217+
CS-Studio GUI combined with PyScanClient
218+
----------------------------------------
219+
220+
In CS-Studio, use the menu File, Open to open `PyScanClient/example/opi/2_XYScan.bob`.
221+
In addition to the beam, shutter and X/Y motors that we've already seen,
222+
it adds a "Scan" section. By default, it will scan both motors from 0 to 5,
223+
and at each position await 3 neutrons.
224+
225+
Press "Go!" and note how the Scan Monitor now shows a running "XY Scan".
226+
Right-click on the scan in the monitor, open the "Scan Data Table"
227+
and watch it add new data for each scanned position.
228+
Close the data table and instead open the "Scan Data Plot".
229+
From the "X Axis" drop-down, select "xpos", and from the "Value 1" drop-down select "ypos".
230+
231+
.. image:: scan_xy.png
232+
233+
Start the next scan after "Up/Down" is turned off and compare the motor positions in the plot.
234+
235+
Check "Simulate" to submit the scan for simulation, without actually executing it.
236+
Simulation can be useful to verify which commands will be created.
237+
It performs a simple run time estimate based on rate-of-change estimates that
238+
need to be configured on the scan server.
239+
240+
Default Device Settings
241+
-----------------------
242+
243+
TODO
183244

184245
Production Setup
185246
----------------
@@ -188,3 +249,6 @@ In the above example we executed the scan server within a terminal window.
188249
A production setup would typically run it as a Linux service using `procServ`,
189250
https://github.com/ralphlange/procServ
190251

252+
Both the scan server and the CS-Studio GUI are typically started by a site-specific
253+
launcher script that adds `-settings /path/to/site/settings.ini`.
254+

doc/scan_xy.png

110 KB
Loading

example/commands1.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,42 @@
22

33
# Assemble list of commands
44
cmds = [
5-
Set('shutter:open', 1, completion=True),
6-
Loop('motor1', 1, 10, 0.5,
5+
Set('shutter', 1),
6+
Loop('motor_x', 1, 10, 0.5,
77
[
8-
Set('daq:run', 1, completion=True),
8+
Comment('daq:start'),
99
Delay(10),
10-
Set('daq:run', 0, completion=True),
11-
], completion=True, readback='motor1.RBV', tolerance=0.5)
10+
Comment('daq:stop'),
11+
Log('motor_x')
12+
], readback='motor_x', tolerance=0.5)
1213
]
1314

14-
print cmds
15+
print("Basic list of commands:")
16+
print(cmds)
1517
# Result:
16-
# [Set('shutter:open', 1, completion=True), Loop('motor1', 1, 10, 0.5, ...
18+
# [Set('shutter', 1), Loop('motor_x', 1, 10, 0.5, [ Comment('daq:start'),...
1719

1820
# Alternatively, use `CommandSequence` which can start
1921
# empty or use list of commands
2022
seq = CommandSequence(cmds)
2123
# Commands can be added to sequence
2224
seq.append(Comment('Done'))
2325

24-
# `CommandSequence` results in nicer printout
25-
print seq
26+
print("`CommandSequence` results in nicer printout:")
27+
print(seq)
2628
# Result:
2729
# [
28-
# Set('shutter:open', 1, completion=True)
29-
# Loop('motor1', 1, 10, 0.5,
30+
# Set('shutter', 1)
31+
# Loop('motor_x', 1, 10, 0.5,
3032
# [
31-
# Set('daq:run', 1, completion=True),
33+
# Comment('daq:start'),
3234
# Delay(10),
33-
# Set('daq:run', 0, completion=True),
34-
# ], completion=True, readback='motor1.RBV', tolerance=0.5)
35+
# Comment('daq:stop'),
36+
# Log('motor_x')
37+
# ], readback='motor_x', tolerance=0.5)
3538
# Comment('Done')
3639
# ]
3740

38-
3941
# .. and then submit to scan server for execution
4042
client = ScanClient()
4143
id = client.submit(seq)

0 commit comments

Comments
 (0)