Devices: collections of PVs
A PyEpics Device is a collection of PVs, usually sharing a Prefix.
Similar to an Epics Record, but relying on PV names, not Record definition.
Epics Analog Input as Python epics.Device
import epics
class ai(epics.Device):
"Simple analog input device"
_fields = (’VAL’, ’EGU’, ’HOPR’, ’LOPR’, ’PREC’,
’NAME’, ’DESC’, ’DTYP’, ’INP’, ’LINR’, ’RVAL’,
’ROFF’, ’EGUF’, ’EGUL’, ’AOFF’, ’ASLO’, ’ESLO’,
’EOFF’, ’SMOO’, ’HIHI’, ’LOLO’, ’HIGH’, ’LOW’,
’HHSV’, ’LLSV’, ’HSV’, ’LSV’, ’HYST’)
def __init__(self, prefix, delim=’.’):
epics.Device.__init__(self, prefix, delim=delim,
self._fields)
Using an ai device
>>> from epics.devices import ai
>>> Pump1 = ai(’XXX:ip2:PRES’)
>>> print "%s = %s %s" % (Pump1.DESC,
Pump1.get(’VAL’,as_string=True),
Pump1.EGU )
Ion pump 1 Pressure = 4.1e-07 Torr
>>> print Pump1.get(’DTYP’, as_string=True)
asyn MPC
>>> Pump1.PV(’VAL’) # Get underlying PV
<PV ’XXX:ip1:PRES.VAL’, count=1, type=double, access=read/write>
A Device maps a set of PV
“fields” (name “suffixes”) to
object attributes, holding all the
associated PVs.
Can save / restore full state.
Can use get()/put() methods or
attribute names on any of the
defined fields.
Devices M Newville CARS, UChicago Channel Access with Python: 24-Oct-2014