Skip to content

Commit b2d9bc8

Browse files
authored
Update documentation on accessing PVs in scripts
`widget.getPV()` as mentioned in doc doesn't exist. Added some ScriptUtil examples. Also removed some ';' that are not necessary for python
1 parent 2d1b91b commit b2d9bc8

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

app/display/editor/doc/access_pv_in_script.rst

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@ Access PV in Script
88
The input PVs for a script can be accessed in script via ``pvs`` object. The order of the input PVs in the
99
configuration list is preserved in ``pvs``. ``pvs[0]`` is the first input pv. If you have N input PVs, ``pvs[N-1]`` is the last input PV.
1010

11-
A button-type widget configured to execute script(s) should instead
12-
reference pvs using ``widget.getPV()`` or ``widget.getPVByName(my_pv_name)``.
11+
When using the ``pvs`` object, the display runtime will invoke the script once all PVs connected
12+
and then whenever those marked as a "Trigger" change.
13+
Scripts might also access PVs associated with a widget like this, but the preferred way
14+
is using ``pvs`` for PVs listed as script inputs.
15+
16+
.. code-block:: python
17+
18+
from org.csstudio.display.builder.runtime.script import ScriptUtil
19+
pv = ScriptUtil.getPrimaryPV(widget)
20+
pvs = ScriptUtil.getPVs(widget)
21+
pv = ScriptUtil.getPVByName(widget, "SomePVName")
1322
1423
You can read/write PV or get its timestamp or severity via the utility APIs provided in ``PVUtil``.
1524

@@ -20,16 +29,18 @@ You can read/write PV or get its timestamp or severity via the utility APIs prov
2029
.. code-block:: python
2130
2231
from org.csstudio.display.builder.runtime.script import PVUtil
23-
value = PVUtil.getDouble(pvs[0]);
32+
value = PVUtil.getDouble(pvs[0])
2433
2534
**Write PV Value**
2635

36+
While the ``pvs`` are configured as script inputs, they may also be used
37+
as outputs by writing to them.
2738
Several method argument types are supported, e.g. Double, Double[], Integer, String. If writing a PV is forbidden by
2839
PV security, an exception will be thrown and shown in console.
2940

3041
.. code-block:: python
3142
32-
pvs[0].write(0);
43+
pvs[0].write(0)
3344
3445
**Get severity of PV**
3546

0 commit comments

Comments
 (0)