|
| 1 | +Use soft records in an IOC |
| 2 | +========================== |
| 3 | + |
| 4 | +It is possible to use records with soft device support mixed with pythonSoftIOC |
| 5 | +records (with Python device support). This allows use of ``calc``, ``fanout`` |
| 6 | +and other EPICS database soft records. |
| 7 | + |
| 8 | +.. literalinclude:: ../examples/example_records_calculate.py |
| 9 | + |
| 10 | +The ``VAL1`` record is created in the usual pythonSoftIOC way, with Python |
| 11 | +device support. You can :meth:`~softioc.device.ProcessDeviceSupportOut.set` it, |
| 12 | +and `on_update` will be called when you ``caput`` it. |
| 13 | + |
| 14 | +The ``VAL2`` record is created using the lower level |
| 15 | +:attr:`softioc.builder.records` object. You can `dbpf` it, and no Python will |
| 16 | +be called when you ``caput`` to it. |
| 17 | + |
| 18 | +Note that the Device Name is shared between both kinds of records - both will |
| 19 | +have the same prefix. |
| 20 | + |
| 21 | +We construct the ``calc`` record again using :attr:`softioc.builder.records`. |
| 22 | +This record will calculate ``A*B``: |
| 23 | + |
| 24 | +- ``A`` is provided by the record pointed at by ``INPA``, which is |
| 25 | + ``py_record``, and the `CP` link causes it to be monitored, processing |
| 26 | + ``calc`` each time it updates. |
| 27 | + |
| 28 | +- ``B`` is initially set to 1. When ``soft_record`` processes, it sends its |
| 29 | + value to ``calc.B``, and the `PP` link causes it to process. |
| 30 | + |
| 31 | +.. note:: |
| 32 | + |
| 33 | + You could also use ``calc(SCAN="1 second", ...)`` instead of the `PP` and |
| 34 | + `CP` links, which would fetch the value periodically rather than just on |
| 35 | + change. |
| 36 | + |
| 37 | +The output of this IOC can be examined by running this IOC in one terminal, and |
| 38 | +then modifying and running the example scripts found in `read-data-from-ioc`. |
| 39 | +Try setting the value of either ``VAL1`` or ``VAL2`` and observe the effect on |
| 40 | +the ``CALC`` output. |
0 commit comments