-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstaubliEpicsLib.py
73 lines (52 loc) · 1.91 KB
/
staubliEpicsLib.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
67
68
69
70
71
from beamline_support import *
import time
################################################
#Acessing regular PVs (getter/setters)
################################################
################################################
#Calling Method PVs
################################################
NO_PARAMETERS = "__EMPTY__"
class MethodPV():
def __init__(self, pvName):
self.robotTaskPV = pvCreate(pvName)
def execute(self,*args):
if len(args)==0:
pars = [NO_PARAMETERS,]
else:
pars=[]
for arg in args:
pars.append(str(arg))
#Python implementation does not support writing a an array if return is a single value
if (len(pars)>1):
pvPut(self.robotTaskPV,pars)
ret = pvGet(self.robotTaskPV)[0]
else:
pvPut(self.robotTaskPV,pars[0])
ret = pvGet(self.robotTaskPV)
# if self.severity!=0:
# raise Exception(ret)
return ret
################################################
#Sincronizing Activities
################################################
def waitReady(timeout=-1):
state = pvCreate("SW:State")
start=time.clock()
while True:
if pvGet(state) not in ("Running","Moving","Busy","Initialize"):
break
if (timeout>=0) and ((time.clock() - start) > timeout):
raise Exception("Timeout waiting ready")
time.sleep(0.01)
def isTaskRunning(id):
pv = MethodPV("SW:isTaskRunning")
return pv.execute(id)
#method_pv=MethodPV("SW:startRobotTask")
#task_id = method_pv.execute("Test",50000)
#print "Task ID = " + str(task_id)
#print "Task Status = " + str(epics.PV("SW:LastTaskInfo").get())
#print "Task Running = " + isTaskRunning(task_id)
#waitReady()
#print "Task Status = " + str(epics.PV("SW:LastTaskInfo").get())
#print "Task Running = " + isTaskRunning(task_id)