|
| 1 | +Why use pythonIOC? |
| 2 | +================== |
| 3 | + |
| 4 | +EPICS IOCs are flexible and modular, why do we need to wrap it in Python? This |
| 5 | +page attempts to answer that question and list a few good use-cases for it. |
| 6 | + |
| 7 | +Calculating PVs from other values |
| 8 | +--------------------------------- |
| 9 | + |
| 10 | +Some use cases require PVs to be calculated from multiple sources. This is |
| 11 | +possible in EPICS records with ``calc`` or ``aSub`` records, but pythonIoc |
| 12 | +allows you to write this as: |
| 13 | + |
| 14 | +.. code-block:: |
| 15 | +
|
| 16 | + import numpy as np |
| 17 | + from cothread.catools import caget, camonitor |
| 18 | + from softioc import builder |
| 19 | +
|
| 20 | + # The PVs we want to average and their initial values |
| 21 | + PVs = [f"DEVICE{i}:CURRENT" for i in range(100)] |
| 22 | + values = np.array(caget(PVs)) |
| 23 | +
|
| 24 | + # The PV we want to serve |
| 25 | + avg = builder.aOut("AVERAGE:CURRENT", np.mean(values)) |
| 26 | +
|
| 27 | + # Make a monitor on the PVs to keep the value up to date |
| 28 | + def update_avg(value: float, index: int): |
| 29 | + values[index] = value |
| 30 | + avg.set(np.mean(values)) |
| 31 | +
|
| 32 | + camonitor(PVs, update_avg) |
| 33 | +
|
| 34 | +ADD THE CONCENTRATOR USE CASE HERE |
| 35 | + |
| 36 | +Dynamically created PVs |
| 37 | +----------------------- |
| 38 | + |
| 39 | +Other use cases will do something like: |
| 40 | + |
| 41 | +.. code-block:: |
| 42 | +
|
| 43 | + connect to device |
| 44 | + make PVs |
| 45 | +
|
| 46 | +ADD THE PANDA USE CASE HERE |
| 47 | + |
| 48 | +Existing Python Support |
| 49 | +----------------------- |
| 50 | + |
| 51 | +It may be that you have specific device support written in Python that you wish |
| 52 | +to expose as PVs. |
| 53 | + |
| 54 | +NEED A GOOD EXAMPLE HERE |
| 55 | + |
0 commit comments