-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHXNSampleExchange.py
executable file
·172 lines (109 loc) · 5.14 KB
/
HXNSampleExchange.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import time, tqdm
from epics import caget, caput
from PyQt5 import QtWidgets, uic, QtCore, QtGui, QtTest
from PyQt5.QtWidgets import QMessageBox
def triggerPV(PV_name):
caput(PV_name,1)
time.sleep(2)
def waitWithProgessBar(time_in_minues, pBarName):
print(f"Timer started for {time_in_minues} minutes")
timeNow = 0
perTime = 0
for _ in range(time_in_minues*60):
QtTest.QTest.qWait(500)
perTime += (timeNow+1)*100/(time_in_minues*60)
pBarName.setValue(int(round(perTime)))
QtTest.QTest.qWait(500)
def StartPumpingProtocol(pBarName):
#pumping PVs
slowVentClose = 'XF:03IDC-VA{ES:1-SlowVtVlv:Stg2}Cmd:Cls-Cmd'
fastVentClose = 'XF:03IDC-VA{ES:1-FastVtVlv:Stg3}Cmd:Cls-Cmd'
slowVentStatus = 'XF:03IDC-VA{ES:1-SlowVtVlv:Stg2}Sts:Cls-Sts'
fastVentStatus = 'XF:03IDC-VA{ES:1-FastVtVlv:Stg3}Sts:Cls-Sts'
pumpAON = 'XF:03IDC-VA{ES:1-FrPmp:A}Cmd:Start-Cmd'
pumpBON = 'XF:03IDC-VA{ES:1-FrPmp:B}Cmd:Start-Cmd'
pumpASlowOpen = 'XF:03IDC-VA{ES:1-SlowFrVlv:A}Cmd:Opn-Cmd'
pumpAFastOpen = 'XF:03IDC-VA{ES:1-FastFrVlv:A}Cmd:Opn-Cmd'
pumpBSlowOpen = 'XF:03IDC-VA{ES:1-SlowFrVlv:B}Cmd:Opn-Cmd'
pumpBFastOpen = 'XF:03IDC-VA{ES:1-FastFrVlv:B}Cmd:Opn-Cmd'
pumpAOFF = 'XF:03IDC-VA{ES:1-FrPmp:A}Cmd:Stop-Cmd'
pumpBOFF = 'XF:03IDC-VA{ES:1-FrPmp:B}Cmd:Stop-Cmd'
pumpASlowClose = 'XF:03IDC-VA{ES:1-SlowFrVlv:A}Cmd:Cls-Cmd'
pumpAFastClose = 'XF:03IDC-VA{ES:1-FastFrVlv:A}Cmd:Cls-Cmd'
pumpBSlowClose = 'XF:03IDC-VA{ES:1-SlowFrVlv:B}Cmd:Cls-Cmd'
pumpBFastClose = 'XF:03IDC-VA{ES:1-FastFrVlv:B}Cmd:Cls-Cmd'
#make sure vents are closed
[triggerPV(pv) for pv in [fastVentClose,slowVentClose]]
#turn on pumps
#make sure vents are closed
if caget(fastVentStatus)==1 and caget(slowVentStatus)==1:
#turn pumps on and open slow valves
[triggerPV(pv) for pv in [pumpAON,pumpASlowOpen,pumpBON,pumpBSlowOpen]]
#wait for vaccum to reach below 300 for fast open
waitWithProgessBar(8,pBarName[0])
while caget("XF:03IDC-VA{VT:Chm-CM:1}P-I")>300:
print("waiting for threshold pressure value")
QtTest.QTest.qWait(30000)
print("FAST Open triggered")
[triggerPV(pv) for pv in [pumpBFastOpen,pumpAFastOpen]]
#wait for vaccum to reach ~1
waitWithProgessBar(15,pBarName[1])
while caget("XF:03IDC-VA{VT:Chm-CM:1}P-I")>1.2:
print("waiting for threshold pressure value")
QtTest.QTest.qWait(30000)
QtTest.QTest.qWait(2*1000)
#close pump valves
[triggerPV(pv) for pv in [pumpBFastClose,pumpAFastClose,
pumpBSlowClose,pumpASlowClose]]
#tun off the pumps
[triggerPV(pv) for pv in [pumpAOFF,pumpBOFF]]
#Done!
return "Pumping completed Successfully, Ready for He Backfill"
else: return "Closing the vents failed; Try Manually closing them"
def StartAutoHeBackFill(pBarName):
#pump valve status
pumpBSlowStats = 'XF:03IDC-VA{ES:1-SlowFrVlv:B}Sts:Cls-Sts'
pumpASlowStats = 'XF:03IDC-VA{ES:1-SlowFrVlv:A}Sts:Cls-Sts'
pumpBFastStats = 'XF:03IDC-VA{ES:1-FastFrVlv:B}Sts:Cls-Sts'
pumpAFastStats = 'XF:03IDC-VA{ES:1-FastFrVlv:A}Sts:Cls-Sts'
#He backfill PVs
startAutoHeBackfill = 'XF:03IDC-VA{ES:1-AutoVt:He}Cmd:Start-Cmd'
HeFillReadiness = [pumpBSlowStats,pumpASlowStats,pumpBFastStats,pumpAFastStats]
if [caget(pvs) == 1 for pvs in HeFillReadiness]:
readyForHe = True
print("He backfill strats in 30 seconds; Make sure the cylider is open")
QtTest.QTest.qWait(30*1000)
#only execute if pump vales are closed
if readyForHe:
triggerPV(startAutoHeBackfill)
waitWithProgessBar(15,pBarName)
return "He backfilled; Please close the cyclinder"
else: return "One or more valves is not closed; try again"
def ventChamber(pBarName):
'''
choice = QMessageBox.question(self, 'Detector has to be moved out',
"Make sure this motion is safe. \n Move?", QMessageBox.Yes |
QMessageBox.No, QMessageBox.No)
if choice == QMessageBox.Yes:
caput("XF:03IDC-ES{Diff-Ax:X}Mtr.VAL", -600)
else:
pass
'''
#make sure fluorescence detector is out before relasing the vaccuum
caput('XF:03IDC-ES{Det:Vort-Ax:X}Mtr.VAL',-107)
QtTest.QTest.qWait(10000)
slowVentOpen = 'XF:03IDC-VA{ES:1-SlowVtVlv:Stg2}Cmd:Opn-Cmd'
fastVentOpen = 'XF:03IDC-VA{ES:1-FastVtVlv:Stg3}Cmd:Opn-Cmd'
triggerPV(slowVentOpen)
waitWithProgessBar(3,pBarName[0])
while caget("XF:03IDC-VA{VT:Chm-CM:1}P-I")<550:
QtTest.QTest.qWait(30000)
print("waiting for threshold pressure ")
triggerPV(fastVentOpen)
waitWithProgessBar(1,pBarName[1])
return "vending completed"
class TaskThread(QtCore.QThread):
taskFinished = QtCore.pyqtSignal()
def run(self):
time.sleep(3)
self.taskFinished.emit()