File: pv_callback.py

package info (click to toggle)
python-pyepics 3.4.1%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,080 kB
  • sloc: python: 11,184; makefile: 106; javascript: 104; sh: 1
file content (26 lines) | stat: -rw-r--r-- 530 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import time
import epics
import sys
import pvnames

pvname = pvnames.updating_pv1 # motor1

mypv = epics.PV(pvname)

write = sys.stdout.write

mypv.get_ctrlvars()

write('Created PV = %s\n' % mypv)
def onChanges(pvname=None, value=None, char_value=None, **kw):
    write( 'PV %s %s, %s Changed!\n' % (pvname, repr(value), char_value))

mypv.add_callback(onChanges)

write('Added a callback.  Now wait for changes...\n')

def wait(timeout=10):
    t0 = time.time()
    while time.time() - t0 < timeout: time.sleep(1.e-4)

wait(10)