Getting Started¶
Counter¶
Consider a simple EPICS database with one record. Call it cntrec.db
record(longin, "test:count") {
field(DTYP, "Python Device")
field(INP , "@cntmod")
field(SCAN, "1 second")
}
This is creating a single record which will use the “Python Device” support code (aka this package).
It will attempt to scan (call the process method) one a second.
The INP field is parsed and the first work identifies the Python module which will provide
the logic behind this record (everything after the first word is passed to the module build()
function.
Now create cntmod.py
with the following.
class MySupport:
def __init__(self, rec, link):
pass
def detach(self, rec):
pass
def process(self, rec, reason):
rec.VAL = rec.VAL + 1
build = MySupport
This module is expected to provide a special callable build()
.
We also provide a constructor and method detach
which don’t do anything.
The process
method increments the VAL field of the attached Record
.
Start this IOC with.
$ ./bin/linux-x86_64/softIocPy2.7 -d cntrec.db
Starting iocInit
...
iocRun: All initialization complete
epics>dbl
test:count
epics>
Now in another terminal run.:
$ camonitor test:count
...
test:count 2014-06-16 16:48:22.891825 9
test:count 2014-06-16 16:48:23.891967 10
test:count 2014-06-16 16:48:24.892137 11
test:count 2014-06-16 16:48:25.892286 12
It may be necessary to run export EPICS_CA_ADDR_LIST=localhost first.
Additional examples and applications¶
This module comes with several examples in testApp as well as three complete applications.
- logApp
- Observes a line based text file as new lines are appended. Writes each line to a charactor array PV. Special handling of caPutLog files.
- pidMonApp
- Monitors the PID file created by a UNIX daemon.
- weatherApp
- Retreives weather reports via the pymetar module.