File: thread_put2.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 (28 lines) | stat: -rw-r--r-- 676 bytes parent folder | download | duplicates (2)
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
27
28
from __future__ import print_function

import time
import threading
import epics
import pvnames
def threaded_pvput(pv, value):
    "put-with-wait for calling in a thread"
    t0 = time.time()
    print(' - threaded_pvput starting at ', pv.get())
    pv.put(value, wait=True, timeout=10.0)
    print(' - threaded_pvput done (%.3f sec)' % (time.time()-t0))
   
if __name__ == '__main__':
    pvname = pvnames.motor2
    target = 0.55
    
    pv = epics.PV(pvname)
    pv.put(-target, wait=True)
    time.sleep(0.5)
    
    th = threading.Thread(target=threaded_pvput,
                          args=(pv, target))
    th.start()
    th.join()
    print('All Done.')