-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoves_deferred.py
executable file
·66 lines (51 loc) · 1.59 KB
/
moves_deferred.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
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/python
import sys
import time
from epics import caput, caget
from motor_lib import motor_lib
from motor_globals import motor_globals
def main():
pv1 = "BL99:Mot:Sim1"
pv2 = "BL99:Mot:Sim2"
defer = "BL99:Mot:Sim:Defer"
print "Test deferred move sequence on both motors"
lib = motor_lib()
g = motor_globals()
positions = range(20)
for pos in positions:
pos2 = pos+1
print "Set deferred flag."
caput(defer, 1, wait=True)
print "Set positions pos: " + str(pos) + " pos2: " + str(pos2)
caput(pv1, pos, wait=False)
caput(pv2, pos2, wait=False)
print "Execute deferred move."
caput(defer, 0, wait=True)
#Wait for both motors to finish
done = 0
count = 0
while (done == 0):
dmov1 = caget(pv1+".DMOV")
dmov2 = caget(pv2+".DMOV")
if (dmov1 == 1) and (dmov2 == 1):
done = 1
count = 0
print "Move Finished"
count = count + 1
if count > 1000:
print "Moves did not complete."
sys.exit(lib.testComplete(g.FAIL))
time.sleep(0.1)
try:
lib.verifyPosition(pv1, pos)
except Exception as e:
print str(e)
sys.exit(lib.testComplete(g.FAIL))
try:
lib.verifyPosition(pv2, pos2)
except Exception as e:
print str(e)
sys.exit(lib.testComplete(g.FAIL))
sys.exit(lib.testComplete(g.SUCCESS))
if __name__ == "__main__":
main()