|
| 1 | +Getting Started |
| 2 | +=============== |
| 3 | + |
| 4 | +In the following, we describe the setup and some basic scan server interactions. |
| 5 | + |
| 6 | +Initial Setup |
| 7 | +------------- |
| 8 | + |
| 9 | +We assume that you already have a recent version of EPICS base installed |
| 10 | +with access to commands like `softIoc`, `caget`, `caput`. |
| 11 | + |
| 12 | +The scan server is a CS-Studio service. |
| 13 | +Both the scan server and the CS-Studio GUI can be built |
| 14 | +from https://github.com/ControlSystemStudio/phoebus. |
| 15 | +Binaries are for example available from |
| 16 | +https://controlssoftware.sns.ornl.gov/css_phoebus/nightly/ |
| 17 | + |
| 18 | +All CS-Studio tools are based on Java. The CS-Studio GUI binary |
| 19 | +may bundle a java runtime. If it includes a `jdk` folder, use that. |
| 20 | +Otherwise fetch a Java runtime from https://jdk.java.net |
| 21 | +Either way, declare your JDK and add its `bin` folder to the PATH:: |
| 22 | + |
| 23 | + export JAVA_HOME=/path/to/jdk |
| 24 | + export PATH=$JAVA_HOME/bin:$PATH |
| 25 | + |
| 26 | +Check:: |
| 27 | + |
| 28 | + java -version |
| 29 | + |
| 30 | +Assuming a binary, start the scan server like this:: |
| 31 | + |
| 32 | + unzip scan-server.zip |
| 33 | + cd scan-server-* |
| 34 | + ./scan-server.sh |
| 35 | + |
| 36 | +On success, note the REST URL and list of console commands:: |
| 37 | + |
| 38 | + INFO ../ Scan Server (PID 1766187) |
| 39 | + INFO ... Scan Server REST interface on http://localhost:4810/index.html |
| 40 | + Scan Server Commands: |
| 41 | + help - Show commands |
| 42 | + ... |
| 43 | + shutdown - Stop the scan server |
| 44 | + |
| 45 | +You would stop the scan server by typing `shutdown`, then restart via `scan-server.sh`. |
| 46 | + |
| 47 | + |
| 48 | +Beamline Simulation |
| 49 | +------------------- |
| 50 | + |
| 51 | +Subsequent sections use a simple beamline simulation. |
| 52 | + |
| 53 | +While we will use the complete PyScanClient later, |
| 54 | +fetch it now to obtain that simulation and run it like this:: |
| 55 | + |
| 56 | + git clone https://github.com/PythonScanClient/PyScanClient.git |
| 57 | + cd PyScanClient/example |
| 58 | + softIoc -d ioc/simulation.db |
| 59 | + |
| 60 | +Assuming you fetched a binary for CS-Studio, start the associated GUI like this:: |
| 61 | + |
| 62 | + unzip phoebus-linux.zip |
| 63 | + cd phoebus-*/ |
| 64 | + ./phoebus.sh -resource /path/to/PyScanClient/example/opi/1_BeamLine.opi |
| 65 | + |
| 66 | +.. image:: simulation.png |
| 67 | + |
| 68 | +Familiarize yourself with the simulation. |
| 69 | + |
| 70 | +* The "Beam" is mostly on, but occasionally turns off. |
| 71 | +* Click on the "Shutter" to open or close it. |
| 72 | + While beam is on and the shutter open, the "Neutrons" counter increments. |
| 73 | + The "Proton Charge" increments as well, but you may |
| 74 | + only see that when you show it in "Probe" or a "Data Browser". |
| 75 | +* Move the "X" and "Y" motor position sliders. |
| 76 | + There's a motor position that maximizes the signal on the detector |
| 77 | + (vertical orange bar). |
| 78 | +* Move the "Device" setpoint slider and notice how its |
| 79 | + value (horizontal orange bar) follows with a delay. |
| 80 | + |
| 81 | +Direct REST Access |
| 82 | +------------------ |
| 83 | + |
| 84 | +The scan server is fundamentally a web service. |
| 85 | +You will typically NOT directly interact with the web service, |
| 86 | +but point your web browser to http://localhost:4810 and try the following. |
| 87 | + |
| 88 | +* You should see a "Scan Server REST Interface" web page. |
| 89 | + Seeing that page confirms that the scan server is running. |
| 90 | + In an operational setup you might try to point a web browser on |
| 91 | + some control system operator interface host to http://name_of_server:4810 |
| 92 | + to check network connectivity to the scan server. |
| 93 | +* Follow the "/server/info" link. |
| 94 | + The XML format of the information is obviously not perfect for |
| 95 | + interactive use. For example, you would have to convert a UNIX epoch |
| 96 | + start time of "1711118742626" into "2024-03-22 10:45:42 EDT" to verify |
| 97 | + the scan server start time, |
| 98 | + but if all else fails such direct REST access can help you debug |
| 99 | + your setup on a low level. |
| 100 | +* Back from the start page http://localhost:4810, click the |
| 101 | + "/scan/{name-of-new-scan}" link for submitting a new scan. |
| 102 | + The "Example" scan that is pre-populated in the web interface |
| 103 | + will set the "xpos" motor to 1, then 2, and log each value. |
| 104 | +* "Submit" the scan and note in the CS-Studio GUI how the X motor is moved. |
| 105 | + The web interface will indicate the "ID" of the submitted scan and then |
| 106 | + switch to a list of scans. You may find the submitted scan either already finished |
| 107 | + or with an active "Delay 10.0 sec" command. |
| 108 | + Note that the web page needs a manual refresh to update. |
| 109 | + After a few manual refreshes, the scan should be "Finished". |
| 110 | +* On the list of scans, follow the "(cmds)" link to view the commands of the scan, |
| 111 | + which should match what was submitted. Follow the "(data)" link and note how |
| 112 | + it lists one sample with value 1.0 and another with value 2.0. |
| 113 | + |
| 114 | +Scan Server Console |
| 115 | +------------------- |
| 116 | + |
| 117 | +* In the scan server console, note how it logs each executed command. |
| 118 | + Type "help", then "scans". Type "commands ID" with the ID of the last submitted scan |
| 119 | + to get a list of commands. Type "data ID" to show the logged data. |
| 120 | +* Stop the scan server by typing "shutdown" in its console, then restart the scan server. |
| 121 | + Try "scans" again. |
| 122 | + Note that "commands ID" will report an error because the list of commands |
| 123 | + is only held in memory for the duration of a scan server run. |
| 124 | + On the other hand, "data ID" will still show the logged data, which is persisted over |
| 125 | + scan server restarts. |
| 126 | + Those logged values are meant to help debug a scan or track its progress. |
| 127 | + It is neither meant to replace an archive system or experiment data aquision. |
| 128 | +* Back from the start page http://localhost:4810, click the |
| 129 | + "/scan/{name-of-new-scan}" link and submit anoter example scan. |
| 130 | + |
| 131 | +CS-Studio GUI |
| 132 | +------------- |
| 133 | + |
| 134 | +* In CS-Studio, invoke the menu Applications, Scan, Scan Monitor. |
| 135 | + You should see the last submitted scan as "Finished-OK", |
| 136 | + the others as simply "Logged". |
| 137 | + |
| 138 | +* Right-click on any scan and open the "Data Table". |
| 139 | +* Right-click no the "Finished" scan and open the "Scan Editor". |
| 140 | +* In the scan editor, right-click to "Submit scan". |
| 141 | + It submits the same commands once more. While the scan is executing, |
| 142 | + the scan editor highlights the active command in green. |
| 143 | + Both the scan monitor and editor offer a red button to abort the scan. |
| 144 | + |
| 145 | +.. image:: scan_monitor_editor.png |
| 146 | + |
| 147 | +* In the scan editor, create a list of "Delay 1 sec" commands by deleting everything else, |
| 148 | + dragging noe "Delay" command from th palette into the editor, |
| 149 | + then use copy/paste from the context menu or Control-drag-drop to |
| 150 | + create about 10 delays. |
| 151 | +* Submit the scan and note how it highlights the active delay command. |
| 152 | + Use the "pause" button in either the scan monitor or editor to pause and then resume |
| 153 | + the commands. |
| 154 | +* Quickly submit the scan multiple times from the scan editor. |
| 155 | + Use the "Re-submit Scan" entry from the scan monitor context menu. |
| 156 | + Note how one scan executes, and additional scans are queued up to |
| 157 | + be executed next. Idle scans can be moved up or down in the list of queued |
| 158 | + scans, or aborted. |
| 159 | +* In the scan monitor, selet a few older scans, right-click on them and "Remove selected". |
| 160 | + |
| 161 | +In an operational setup, the scan monitor can be very useful to monitor |
| 162 | +the progress of queued and active scans. |
| 163 | + |
| 164 | +The scan editor could be used to manually assemble small scans, |
| 165 | +or to debug scans that have been submitted by other means. |
| 166 | + |
| 167 | +The scan server will hold the commands of past scans in memory |
| 168 | +and persist the logged data on disk, but this |
| 169 | +is all meant to debug scans, not to replace data aquisition. |
| 170 | +Based on memory usage thresholds, the scan server will automatically change |
| 171 | +in-memory scans to only logged scans. |
| 172 | +While the scan monitor can list many scans, reading the list of scans from |
| 173 | +the server and displaying it will use noticable CPU once there are 10000 and more |
| 174 | +scans in the list. |
| 175 | +Periodically, for example when a new series of experiments start, |
| 176 | +it is thus suggested to manually remove information for older scans, |
| 177 | +either by deleting selected scans or by invoking "Remove completed scans" |
| 178 | +from the scan monitor context menu. |
| 179 | + |
| 180 | +PyScanClient |
| 181 | +------------ |
| 182 | + |
| 183 | + |
| 184 | +Production Setup |
| 185 | +---------------- |
| 186 | + |
| 187 | +In the above example we executed the scan server within a terminal window. |
| 188 | +A production setup would typically run it as a Linux service using `procServ`, |
| 189 | +https://github.com/ralphlange/procServ |
| 190 | + |
0 commit comments