@@ -9,84 +9,106 @@ Initial Setup
99We assume that you already have a recent version of EPICS base installed
1010with access to commands like `softIoc `, `caget `, `caput `.
1111
12- Prepare the PyScanClient::
12+ Prepare the PyScanClient library and examples ::
1313
1414 git clone https://github.com/PythonScanClient/PyScanClient.git
1515 cd PyScanClient
1616 python setup.py build
17+ export PYSCANCLIENT=`pwd`
1718
18- In here, we don't "install" the library
19- but simply access it via the python path.
20- In addition, we list the folder with examples to be used later
21- in the path::
22-
23- export PYTHONPATH=`pwd`/build/lib:`pwd`/example
19+ In here, we don't "install" the library but simply access it via the python path.
20+ In addition to the library, clients also need access to the examples,
21+ so we add both to the path used by C-Python::
22+
23+ export PYTHONPATH=$PYSCANCLIENT/build/lib:$PYSCANCLIENT/example
2424
2525The scan server is a CS-Studio service.
2626Both the scan server and the CS-Studio GUI can be built
2727from https://github.com/ControlSystemStudio/phoebus.
2828More convenient binaries are available from
2929https://controlssoftware.sns.ornl.gov/css_phoebus/nightly/
3030
31- Create a settings file for CS-Studio that holds the path to
32- this python library::
33-
34- echo org.csstudio.display.builder.runtime/python_path=$PYTHONPATH >>my_settings.ini
35-
36- You may also add common settings like CA or PVA address lists
37- to that file, or add the `..runtime/python_path ` setting to
38- an already existing local settings file.
39-
40- All CS-Studio tools are based on Java. The CS-Studio GUI binary
41- may bundle a java runtime. If it includes a `jdk ` folder, use that.
42- Otherwise fetch a Java runtime from https://jdk.java.net
31+ All CS-Studio tools are implemented in Java. Some CS-Studio GUI binaries
32+ bundle a java runtime. If it includes a `jdk ` folder, use that.
33+ Otherwise fetch a Java runtime from https://jdk.java.net.
4334Either way, declare your JDK and add its `bin ` folder to the PATH::
4435
4536 export JAVA_HOME=/path/to/jdk
4637 export PATH=$JAVA_HOME/bin:$PATH
4738 java -version
4839
40+ Both the scan server and the CS-Studio GUI likely need to access
41+ the same PVs, so you can create a common `my_settings.ini ` for them.
42+ In here we start with just localhost::
43+
44+ echo org.phoebus.pv.ca/addr_list=127.0.0.1 >>my_settings.ini
45+
46+ For more on PV related settings, see
47+ https://control-system-studio.readthedocs.io/en/latest/preference_properties.html#pv
48+
49+ For the CS-Studio displays, we add the path to this python library and its examples::
50+
51+ echo org.csstudio.display.builder.runtime/python_path=$PYTHONPATH >>my_settings.ini
52+
53+ This `.../python_path ` setting is for CS-Studio displays to locate display scripts.
54+ It is not required by the scan server, but for simplicity
55+ you may combnied settings in a common file loaded by all CS-Studio tools,
56+ since the tools will ignore settings that don't apply to them.
57+
58+ The scan server uses an additional configuration file.
59+ For a full example see https://github.com/ControlSystemStudio/phoebus/blob/master/services/scan-server/src/main/resources/examples/scan_config.xml
60+
61+ For these tests we use a simpler file based on this template
62+ to primarily set the path used by server-side scripts:
63+
64+ .. literalinclude :: ../example/server/scan_config_template.xml
65+
66+ Based on that template, create the file for your PyScanClient example path::
67+
68+ cat $PYSCANCLIENT/example/server/scan_config_template.xml |
69+ sed -e "s#<path>.*#<path>$PYSCANCLIENT/example/server</path>#" >my_scan_config.xml
70+
4971Assuming you fetched a scan server binary, start the scan server like this::
5072
5173 unzip scan-server.zip
5274 rm scan-server.zip
5375 cd scan-server-*
54- ./scan-server.sh
55-
76+ ./scan-server.sh -settings /path/to/my_settings.ini -config /path/to/my_scan_config.xml
77+
5678On success, note the REST URL and list of console commands::
5779
58- INFO ../ Scan Server (PID 1766187)
80+ INFO ... Scan Server (PID 1766187)
5981 INFO ... Scan Server REST interface on http://localhost:4810/index.html
6082 Scan Server Commands:
6183 help - Show commands
6284 ...
6385 shutdown - Stop the scan server
6486
65- You would stop the scan server by typing `shutdown `, then restart via ` scan-server.sh ` .
87+ You would stop the scan server by typing `shutdown `, then restart as just shown .
6688
6789
6890Test Beamline
6991-------------
7092
71- Subsequent sections use a simple test beamline created by `simulation.db `.
93+ Subsequent sections use a test beamline created by `simulation.db `.
7294The scan GUIs use additional databases.
7395Start them all in one IOC like this::
7496
75- cd PyScanClient /example
76- softIoc -m S=Demo -d ioc/ simulation.db -d ioc/ table.db
97+ cd $PYSCANCLIENT /example/ioc
98+ softIoc -m S=Demo -d simulation.db -d table.db -d range.db -d fit .db
7799
78100Assuming you fetched a binary for CS-Studio, start the associated GUI like this::
79101
80102 unzip phoebus-linux.zip
81103 rm phoebus-linux.zip
82104 cd phoebus-*/
83- ./phoebus.sh -settings /path/to/my_settings.ini -resource /path/to/PyScanClient /example/opi/1_BeamLine.bob
105+ ./phoebus.sh -settings /path/to/my_settings.ini -resource $PYSCANCLIENT /example/opi/1_BeamLine.bob
84106
85107.. image :: simulation.png
86108
87109Familiarize yourself with the simulation.
88110
89- * The "Beam" is mostly on, but occasionally turns off.
111+ * The "Beam" is mostly on, but turns itself off for brief periods .
90112* Click on the "Shutter" to open or close it.
91113 While beam is on and the shutter open, the "Neutrons" counter increments.
92114 The "Proton Charge" increments as well, but you may
@@ -111,11 +133,11 @@ but point your web browser to http://localhost:4810 and try the following.
111133 some control system operator interface host to http://name_of_server:4810
112134 to check network connectivity to the scan server.
113135* Follow the "/server/info" link.
114- The XML format of the information is obviously not perfect for
136+ The XML format of the information is obviously not meant for
115137 interactive use. For example, you would have to convert a UNIX epoch
116138 start time of "1711118742626" into "2024-03-22 10:45:42 EDT" to verify
117139 the scan server start time,
118- but if all else fails such direct REST access can help you debug
140+ but if all else fails such direct REST access can help you to debug
119141 your setup on a low level.
120142* Back from the start page http://localhost:4810, click the
121143 "/scan/{name-of-new-scan}" link for submitting a new scan.
@@ -150,14 +172,14 @@ Scan Server Console
150172 "/scan/{name-of-new-scan}" link and submit anoter example scan.
151173
152174
153- CS-Studio GUI
154- -------------
175+ CS-Studio GUI Scan Tools
176+ ------------------------
155177
156178* In CS-Studio, invoke the menu Applications, Scan, Scan Monitor.
157179 You should see the last submitted scan as "Finished-OK",
158180 the others as simply "Logged".
159181* Right-click on any scan and open the "Data Table".
160- * Right-click no the "Finished" scan and open the "Scan Editor".
182+ * Right-click on the "Finished" scan and open the "Scan Editor".
161183* In the scan editor, right-click to "Submit scan".
162184 It submits the same commands once more. While the scan is executing,
163185 the scan editor highlights the active command in green.
@@ -166,35 +188,34 @@ CS-Studio GUI
166188.. image :: scan_monitor_editor.png
167189
168190* In the scan editor, create a list of "Delay 1 sec" commands by deleting everything else,
169- dragging noe "Delay" command from th palette into the editor,
191+ dragging one "Delay" command from the palette into the editor,
170192 then use copy/paste from the context menu or Control-drag-drop to
171193 create about 10 delays.
172194* Submit the scan and note how it highlights the active delay command.
173195 Use the "pause" button in either the scan monitor or editor to pause and then resume
174196 the commands.
175197* Quickly submit the scan multiple times from the scan editor.
176198 Use the "Re-submit Scan" entry from the scan monitor context menu.
177- Note how one scan executes, and additional scans are queued up to
199+ Note how one scan executes, and additional scans queue up to
178200 be executed next. Idle scans can be moved up or down in the list of queued
179201 scans, or aborted.
180- * In the scan monitor, selet a few older scans, right-click on them and "Remove selected".
202+ * In the scan monitor, select a few older scans, right-click on them and "Remove selected".
181203
182- The scan monitor is very useful to monitor
183- the progress of queued and active scans.
204+ The scan monitor is very useful to track the progress of queued and active scans.
184205
185206The scan editor could be used to manually assemble small scans,
186207but it's mainly meant to debug scans that have been submitted by other means.
187208
188209The scan server will hold the commands of past scans in memory
189210and persist the logged data on disk, but this
190211is all meant to debug scans, not to replace data aquisition.
191- Based on memory usage thresholds, the scan server will automatically change
192- in-memory scans to only logged scans.
212+ Based on memory usage thresholds, the scan server will automatically reduce
213+ in-memory scans to logged scans.
193214While the scan monitor can list many scans, reading the list of scans from
194- the server and displaying it will use noticable CPU once there are 10000 and more
195- scans in the list.
215+ the server and displaying it in the GUI will use noticable CPU once there are
216+ 10000 and more scans in the list.
196217Periodically, for example when a new series of experiments start,
197- it is thus suggested to manually remove information for older scans,
218+ it is thus suggested to manually remove older scans,
198219either by deleting selected scans or by invoking "Remove completed scans"
199220from the scan monitor context menu.
200221
@@ -212,31 +233,30 @@ and run it::
212233.. literalinclude :: ../example/commands1.py
213234
214235Note how the python script assembles a list of commands.
215- It builds the recipe for one "scan", submits it to the scan server,
216- and exits.
236+ It builds the recipe, submits it to the scan server, and exits.
217237The scan server then spends more than a minute to execute the submitted
218238commands.
219239
220240In the CS-Studio scan monitor, right-click on the running scan to open
221241the "Scan Data Table" and watch how samples are added.
222242This internal data logger is again not meant to replace data aquisition,
223- but meant to assist in tracknig the progress of scans and to debug them .
243+ but assists in tracking the progress of scans.
224244
225- At this point you may familiarize yourself with all the :ref: ` scan_commands `,
245+ At this point you may familiarize yourself with all the :doc: ` scan commands < commands > `,
226246especially the many options of the :class: `.Set ` command.
227- The PyScanClient `tutorial ` folder contains several examples
228- to try.
247+ The PyScanClient `tutorial ` folder contains several more example scripts.
229248
230249
231250Default Device Settings
232251-----------------------
233252
234- A command to turn a power supply on or set a voltage may be instantaneous::
253+ The command to set a power supply voltage may be instantaneous::
235254
236- commands = [ Set('PS42:Voltage', 12.0), Comment("PS is now on at 12 Volts")]
255+ commands = [ Set('PS42:Voltage', 12.0),
256+ Comment("PS is now on at 12 Volts") ]
237257
238258But this device behavior tends to be the exception.
239- When controlling a motor, the EPICS motor support allows using a "put-callback"
259+ When controlling a motor, the EPICS motor support allows a "put-callback"
240260to the device which waits until the motor reaches the desired location.
241261This mechanism is also referred to as "completion".
242262A temperature controller might support completion on its temperature
@@ -256,7 +276,7 @@ Unfortunately, the "correct" way to set a PV is not discernible from the outside
256276It requires knowledge about the implementation of a PV in the IOC.
257277And even if the correct way to set a PV is known, having to type
258278all parameters for each `Set ` command can be cumbersone.
259- The PyScanClient :ref: ` scan_settings ` provide a way to configure default parameters
279+ The PyScanClient :doc: ` scan settings < scan_settings > ` provide a way to configure default parameters
260280for each PV.
261281Wrappers for the basic `Set `, `Loop ` and `Wait ` commands then use these defaults.
262282For an example, see `example/beamline_setup.py `:
@@ -366,6 +386,19 @@ without manual conversion to CSV.
366386Alignment Scan
367387--------------
368388
389+ One fairly common beamline procedure is the alignment.
390+ For example, a slit or sample is moved across a range of positions,
391+ the intensity of a signal is noted at each position,
392+ and we try to locate the maximum of that signal.
393+
394+ In CS-Studio, use the menu `File `, `Open ` to open
395+ `PyScanClient/example/opi/1_BeamLine.bob `
396+ and in there set the "Y" motor to 3.0.
397+ Now open `PyScanClient/example/opi/4_Alignment_Scan.bob `.
398+ Adjust the settings as shown the following screenshot, then press "Submit".
399+
400+ .. image :: alignment_scan.png
401+
369402TODO
370403Custom script commands
371404
@@ -380,4 +413,5 @@ Both the scan server and the CS-Studio GUI are typically started by a site-speci
380413launcher script that adds `-settings /path/to/site/settings.ini `.
381414
382415
383- TODO: scan server's pre and post commands
416+ TODO: scan server's pre and post commands
417+
0 commit comments