Skip to content

Commit e5b061b

Browse files
committed
Update docs and CI
1 parent 84b7ae3 commit e5b061b

File tree

7 files changed

+73
-42
lines changed

7 files changed

+73
-42
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
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: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Creating an IOC
44
Introduction
55
------------
66

7-
Once the module has been installed (see `installation`) we can create a
8-
simple EPICS Input/Output Controller (IOC).
7+
Once the module has been installed (see `installation`) we can create a
8+
simple EPICS Input/Output Controller (IOC).
99

1010
An EPICS IOC created with the help of ``pythonIoc`` and `softioc` is
1111
referred to as a "Python soft IOC". The code below illustrates a simple IOC
@@ -19,30 +19,32 @@ Each section is explained in detail below:
1919
:start-after: # Import
2020
:end-before: # Set
2121

22-
The `softioc` library is part of ``pythonIoc``. The two submodules
23-
`softioc.softioc` and `softioc.builder` provide the basic
22+
The `softioc` library is part of ``pythonIoc``. The two submodules
23+
`softioc.softioc` and `softioc.builder` provide the basic
2424
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
27-
asynchronous operations.
28-
(see `../how-to/use-asyncio-in-an-ioc` for the alternative)
27+
asynchronous operations.
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
33-
:start-after: # Create
35+
:start-after: # Create
3436
:end-before: # Boilerplate
3537

3638
PVs are normally created dynamically using `softioc.builder`. All PV
37-
creation must be done before initialising the IOC. We define a lambda function for
38-
`on_update` on ``ao`` such that whenever we set ``ao``, ``ai`` will be set to the
39-
same value. The ``always_update`` flag ensures that the ``on_update`` function is always
39+
creation must be done before initialising the IOC. We define a lambda function for
40+
`on_update` on ``ao`` such that whenever we set ``ao``, ``ai`` will be set to the
41+
same value. The ``always_update`` flag ensures that the ``on_update`` function is always
4042
triggered, which is not the default behaviour if the updated value is the same as the
4143
current value.
4244

4345

4446
.. literalinclude:: ../examples/example_cothread_ioc.py
45-
:start-after: # Boilerplate
47+
:start-after: # Boilerplate
4648
:end-before: # Start
4749

4850

@@ -52,14 +54,14 @@ which must be called in this order. After calling
5254
:func:`~softioc.builder.LoadDatabase` it is no longer possible to create PVs.
5355

5456
.. literalinclude:: ../examples/example_cothread_ioc.py
55-
:start-after: # Start
57+
:start-after: # Start
5658
:end-before: # Finally
5759

5860
We define a long-running operation that will increment the value of ``ai`` once per
59-
second. This is run as a background thread by `cothread`.
61+
second. This is run as a background thread by `cothread`.
6062

6163
.. literalinclude:: ../examples/example_cothread_ioc.py
62-
:start-after: # Finally
64+
:start-after: # Finally
6365

6466
Finally the application must refrain from exiting until the IOC is no longer
6567
needed. The :func:`~softioc.softioc.interactive_ioc` runs a Python
@@ -69,7 +71,7 @@ internals of the IOC while it's running. The alternative is to call something
6971
like :func:`cothread.WaitForQuit` or some other `cothread` blocking
7072
action.
7173

72-
In this interpreter there is immediate access to methods defined in the
74+
In this interpreter there is immediate access to methods defined in the
7375
`softioc.softioc` module. For example the :func:`~softioc.softioc.dbgf` function
7476
can be run to observe the increasing value of ``AI``::
7577

@@ -79,15 +81,15 @@ can be run to observe the increasing value of ``AI``::
7981
DBF_DOUBLE: 37
8082

8183
And the :func:`~softioc.softioc.dbpf` method allows data to be set and to observe
82-
the functionality of the lambda passed to ``on_update`` . We set the value on ``AO``
84+
the functionality of the lambda passed to ``on_update`` . We set the value on ``AO``
8385
and read the value on ``AI`` (exact values will vary based on time taken)::
8486

8587
>>> dbgf("MY-DEVICE-PREFIX:AI")
8688
DBF_DOUBLE: 15
8789
>>> dbpf("MY-DEVICE-PREFIX:AO","999")
88-
DBF_DOUBLE: 999
90+
DBF_DOUBLE: 999
8991
>>> dbgf("MY-DEVICE-PREFIX:AI")
90-
DBF_DOUBLE: 1010
92+
DBF_DOUBLE: 1010
9193

9294

9395
Creating PVs

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

0 commit comments

Comments
 (0)