Skip to content

Commit 379e715

Browse files
authored
Merge pull request #17 from dls-controls/pva
Add PVA support
2 parents 94d2e66 + 36e5d39 commit 379e715

File tree

16 files changed

+230
-72
lines changed

16 files changed

+230
-72
lines changed

.github/workflows/code.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
run: cibuildwheel --output-dir dist
8888
env:
8989
CIBW_BUILD: ${{ matrix.python }}*64
90-
CIBW_TEST_REQUIRES: pytest-cov ${{ matrix.test_requires }}
90+
CIBW_TEST_REQUIRES: pytest-cov p4p ${{ matrix.test_requires }}
9191
CIBW_TEST_COMMAND: pytest --cov=softioc {project}/tests --cov-report xml:${{ matrix.cov_file }}
9292
# Disable auditwheel as it isn't compatible with setuptools_dso approach
9393
# https://github.com/mdavidsaver/setuptools_dso/issues/17

CHANGELOG.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0
99
Unreleased_
1010
-----------
1111

12-
Nothing yet
12+
Added:
13+
14+
- PVA support to the IOC #17
1315

1416

1517
3.0_ - 2021-07-05

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pytest-flake8 = "*"
99
sphinx-rtd-theme = "*"
1010
setuptools-dso = "*"
1111
pytest-asyncio = "*"
12+
p4p = "*"
1213

1314
[packages]
1415
# All other package requirements from setup.py

Pipfile.lock

Lines changed: 151 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
from softioc import softioc
21
from cothread.catools import caget, caput, camonitor
32

43
print(caget("MY-DEVICE-PREFIX:AI"))
54
print(caget("MY-DEVICE-PREFIX:AO"))
6-
print(caput("MY-DEVICE-PREFIX:AO", "999"))
5+
caput("MY-DEVICE-PREFIX:AO", "999")
76
print(caget("MY-DEVICE-PREFIX:AO"))
8-
9-
softioc.interactive_ioc(globals())
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from p4p.client.cothread import Context
2+
3+
ctx = Context("pva")
4+
print(ctx.get("MY-DEVICE-PREFIX:AI"))
5+
print(ctx.get("MY-DEVICE-PREFIX:AO"))
6+
ctx.put("MY-DEVICE-PREFIX:AO", "999")
7+
print(ctx.get("MY-DEVICE-PREFIX:AO"))

docs/how-to/read-data-from-ioc.rst

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,54 @@
11
Read data from an IOC
22
======================
33

4-
This guide explains how to read data from an IOC in a separate Python program.
4+
This guide explains how to read data from an IOC in a separate Python program.
55

6-
.. note::
7-
Please ensure your firewall allows both TCP and UDP traffic on ports 5064 and 5065.
6+
To start, run the `cothread` IOC from `../tutorials/creating-an-ioc` or the
7+
`asyncio` IOC from `use-asyncio-in-an-ioc` and leave it running at the
8+
interactive shell.
9+
10+
Using Channel Access
11+
--------------------
12+
13+
.. note::
14+
Please ensure your firewall allows both TCP and UDP traffic on ports 5064 and 5065.
815
These are used by EPICS for channel access to the PVs.
916

17+
We will read data from the IOC using this script:
1018

11-
To start, run the `cothread` IOC from `../tutorials/creating-an-ioc` or the
12-
`asyncio` IOC from `use-asyncio-in-an-ioc` and leave it running at the
13-
interactive shell.
19+
.. literalinclude:: ../examples/example_read_from_ioc_ca.py
1420

15-
We will read data from that IOC using this script:
21+
You can run this as::
1622

17-
.. literalinclude:: ../examples/example_read_from_ioc.py
23+
python -i example_read_from_ioc_ca.py
24+
25+
From the interactive command line you can now use the ``caget`` and ``caput`` functions to operate on
26+
the PVs exposed in the IOC. Another interesting command to try is::
27+
28+
camonitor("MY-DEVICE-PREFIX:AI", print)
29+
30+
You should observe the value of ``AI`` being printed out, once per second, every time the PV value
31+
updates.
32+
33+
Using PVAccess
34+
--------------
1835

1936
.. note::
20-
You may see warnings regarding the missing "caRepeater" program. This is an EPICS tool
21-
that is used to track when PVs start and stop. It is not required for this simple example,
22-
and so the warning can be ignored.
37+
Please ensure your firewall allows both TCP and UDP traffic on ports 5075 and 5076.
38+
These are used by EPICS for PVAccess to the PVs.
2339

24-
From the interactive command line you can now use the ``caget`` and ``caput`` functions to operate on
25-
the PVs exposed in the IOC. Another interesting command to try is::
40+
We will read data from the IOC using this script:
2641

27-
camonitor("MY-DEVICE-PREFIX:AI", lambda val: print(val))
42+
.. literalinclude:: ../examples/example_read_from_ioc_pva.py
2843

44+
You can run this as::
2945

30-
You should observe the value of ``AI`` being printed out, once per second, every time the PV value
31-
updates.
46+
python -i example_read_from_ioc_pva.py
47+
48+
From the interactive command line you can now use the ``ctx.get`` and ``ctx.put`` functions to operate on
49+
the PVs exposed in the IOC. Another interesting command to try is::
50+
51+
ctx.monitor("MY-DEVICE-PREFIX:AI", print)
52+
53+
You should observe the value and timestamp of ``AI`` being printed out, once per second, every time the PV value
54+
updates.

docs/tutorials/creating-an-ioc.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ functionality for Python soft IOCs and are the ones that are normally used.
2525

2626
`cothread` is one of the two possible libraries the IOC can use for
2727
asynchronous operations.
28-
(see `../how-to/use-asyncio-in-an-ioc` for the alternative)
2928

29+
.. note::
3030

31+
`cothread` doesn't work on Windows or on a Mac M1. You can use `asyncio`
32+
instead by following `../how-to/use-asyncio-in-an-ioc`
3133

3234
.. literalinclude:: ../examples/example_cothread_ioc.py
3335
:start-after: # Create

docs/tutorials/installation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ You can now use ``pip`` to install the library::
3535

3636
python3 -m pip install softioc
3737

38-
Optionally on Linux or MacOS you can install cothread, which is used in the
39-
first tutorial::
38+
Optionally on Linux or MacOS (not M1) you can install cothread, which is used in
39+
the first tutorial::
4040

4141
python3 -m pip install cothread
4242

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "setuptools_dso", "epicscorelibs>=7.0.4.99.1"]
2+
requires = ["setuptools", "wheel", "setuptools_dso", "epicscorelibs>=7.0.6.99.1.0a1"]
33
build-backend = "setuptools.build_meta:__legacy__"

0 commit comments

Comments
 (0)