-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathcaIocExample.py
More file actions
44 lines (40 loc) · 1.19 KB
/
caIocExample.py
File metadata and controls
44 lines (40 loc) · 1.19 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
# Run this by pointing to the EPICS_BASE dbd directory, e.g.
#EPICS_DB_INCLUDE_PATH=/path/to/epics-7.0.6.1/dbd
import time
import pvaccess as pva
print('Creating IOC')
ioc = pva.CaIoc()
print('Loading DB')
ioc.loadDatabase('base.dbd', '', '')
print('Registering device record driver')
ioc.registerRecordDeviceDriver()
print('Loading records')
ioc.loadRecords('./int.db','NAME=I1')
ioc.loadRecords('./calc.db','NAME=C1')
ioc.loadRecords('./double.db','NAME=D1')
ioc.loadRecords('./waveform.db','NAME=WF1')
print('Starting IOC')
ioc.start()
print('IOC is up and running')
print('Retrieving record names')
ioc.dbl('', '')
records = ioc.getRecordNames()
print(f'Available records: {records}')
for i in range(0,10):
value = ioc.getField('D1')
print(f'D1 value before put #{i}: {value}')
ioc.putField('D1', i*1.0)
value = ioc.getField('D1')
print(f'D1 value after put #{i}: {value}')
print()
time.sleep(1)
for i in range(0,10):
value = ioc.getField('WF1')
print(f'WF1 value before put #{i}: {value}')
ioc.putField('WF1', [i]*10)
value = ioc.getField('WF1')
print(f'WF1 value after put #{i}: {value}')
print()
time.sleep(1)
time.sleep(60)