forked from slaclab/exp-timing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cast_scan.py
56 lines (48 loc) · 1.77 KB
/
cast_scan.py
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
45
46
47
48
49
50
51
52
53
54
55
56
import epics as epics
import numpy as np
import time as time
import datetime
now = datetime.datetime.now()
filename = 'pcav_cast_scan_' + now.strftime('%Y-%m-%d-%H-%M-%S') + '.txt'
print(filename)
f = open(filename, 'w')
# Define the PV variables
HXR_PCAV_PV0 = 'SIOC:UNDH:PT01:0:TIME0'
HXR_PCAV_PV1 = 'SIOC:UNDH:PT01:0:TIME1'
HXR_CAST_PS_PV_W = 'LAS:UND:MMS:02'
HXR_CAST_PS_PV_R = 'LAS:UND:MMS:02.RBV'
SXR_PCAV_PV0 = 'SIOC:UNDS:PT01:0:TIME0'
SXR_PCAV_PV1 = 'SIOC:UNDS:PT01:0:TIME1'
SXR_CAST_PS_PV_W = 'LAS:UND:MMS:01'
SXR_CAST_PS_PV_R = 'LAS:UND:MMS:01.RBV'
# Assign the beamline specific PV to the general purpose call variables
CAST_PS_PV_W = SXR_CAST_PS_PV_W
CAST_PS_PV_R = SXR_CAST_PS_PV_R
PCAV_PV0 = SXR_PCAV_PV0
PCAV_PV1 = SXR_PCAV_PV1
pause_time = 1 # Let's give some time for the system to react
phase_steps = 2000 # How many steps we are taking
phase_gap = 0.001 # number of ps we are increasing each time
CAST_PS_target = 0 # Targeted value for the phase shifter
PCAV_Val_ary = np.zeros((phase_steps,))
# let's get the current value of the phase shifter
CAST_PS_init_Val = epics.caget(HXR_CAST_PS_PV_R)
CAST_PS_target = CAST_PS_init_Val
for y in range(0,phase_steps):
# print('epics.caget(CAST_PS_PV_R)')
print(y)
CAST_PS_target = CAST_PS_target+(phase_gap)
print(CAST_PS_target)
f.write(str(CAST_PS_target) + ',')
print('epics.caput(' + CAST_PS_PV_W + ', ' + str(CAST_PS_target) + ')')
# epics.caput(CAST_PS_PV_W, CAST_PS_target)
time.sleep(pause_time)
print('PCAV value')
PCAV_Val_ary[y] = epics.caget(PCAV_PV0)
print(PCAV_Val_ary[y])
f.write(str(PCAV_Val_ary[y]) + '\n')
print('==========================================')
epics.caput(CAST_PS_PV_W, CAST_PS_init_Val)
# f.close()
# print(y)
# print(now.strftime('%Y-%m-%d-%H-%M-%S'))