Skip to content

Commit b864e0a

Browse files
author
Kay Kasemir (ky9)
committed
beamline settings...
1 parent 83282b1 commit b864e0a

File tree

4 files changed

+42
-9
lines changed

4 files changed

+42
-9
lines changed

doc/getting_started.rst

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,35 @@ need to be configured on the scan server.
243243
Default Device Settings
244244
-----------------------
245245

246-
TODO
246+
A command to turn a power supply on or set a voltage may be instantaneous::
247+
248+
commands = [ Set('PS42:Voltage', 12.0), Comment("PS is now on at 12 Volts")]
249+
250+
But this device behavior tends to be the exception.
251+
When controlling a motor, the EPICS motor support allows using a "put-callback"
252+
to the device which waits until the motor reaches the desired location.
253+
This mechanism is also referred to as "completion".
254+
A temperature controller might support completion on its temperature
255+
setpoint PV.
256+
On devices that do not support completion, it may be possible
257+
to read the current device state from a separate readback PV and wait until
258+
it agrees with the commanded value.
259+
260+
Based on the device at hand, we want to use the appropriate :class:`.Set` command::
261+
262+
Set('SomePV', 42.3, completion=True, timeout=30)
263+
Set('SomePV', 42.3, completion=True, timeout=3000)
264+
Set('SomePV', 42.3, completion=True, timeout=3000, readback="SomePV.RBV", tolerance=0.1)
265+
Set('SomePV', 42.3, readback="OtherPV", tolerance=10, timeout=15)
266+
267+
Unfortunately, the "correct" way to set a PV is not discernible from the outside.
268+
It requires knowledge about the implementation of a PV in the IOC.
269+
And even if the correct way to set a PV is known, having to type
270+
all parameters for each `Set` command can be cumbersone.
271+
The PyScanClient library offers :ref:`scan_settings` where the ideal
272+
parameters for each PV can be configured once, and wrappers for the
273+
basic `Set` and `Wait` commands will then automatically use them as a default.
274+
247275

248276
Table Scan
249277
----------

example/beamline_setup.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ def __init__(self):
3131
self.loggable = [ "signal" ]
3232

3333
def getReadbackName(self, device_name):
34-
# Prime example would be a motor:
35-
#if "motor" in device_name:
36-
# return device_name + ".RBV"
37-
return device_name
34+
# Anything that looks like a motor very likely has a .RBV.
35+
# But that does not apply to the simulated motor_x, motor_y
36+
if device_name in ( 'motor_x', 'motor_y' ):
37+
return device_name
38+
if "motor" in device_name:
39+
return device_name + ".RBV"
3840

3941
scan_settings = BeamlineScanSettings()
4042
# Install beam line specific scan settings

scan/commands/set.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class Set(Command):
4242
we wait for up to `timeout` seconds for the readback to be within tolerance.
4343
4444
*Note use of completion:*
45-
EPICS Channel Access does not communicate if completion ('put-callback') is actually
45+
The EPICS network protocol, be it Channel Access or PV Access,
46+
does not communicate if completion ('put-callback') is actually
4647
supported. When writing to a PV that does not support completion, the call is returned
4748
right away, just as it would for a PV that supports completion and happens to complete
4849
quickly.
@@ -67,9 +68,9 @@ class Set(Command):
6768
but can be problematic for a device where the readback will
6869
take time to settle. Examples include PID-controlled devices
6970
with overshoot and settling time, or motors with backlash compensation
70-
and retries where the readback might early on be close to the setpoint,
71-
but it has not settled, so we consider it 'done' when in fact the
72-
device is actively changing its value.
71+
and retries. The readback can be close to the setpoint,
72+
but the device might not have settled. We can then erroneously consider it 'done'
73+
while the device is in fact still actively changing its value.
7374
7475
**Use case 3: Enable completion but no readback**
7576

scan/util/scan_settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""
2+
.. _scan_settings:
3+
24
Scan settings
35
=============
46

0 commit comments

Comments
 (0)