Files
x07ma/script/TEMP_wait_fill.py
2017-02-08 14:03:07 +01:00

76 lines
1.8 KiB
Python

#!/usr/bin/env python
import os,time,subprocess
def check_Tcontrol_on():
prog = os.popen("caget -noname -num -nostat X07MA-ES1-TEMP:CONTROL")
sp=prog.read()
if sp =='':
Tcontrol_on = False
else:
sp = float(sp)
if sp != 1:
Tcontrol_on = False
else:
Tcontrol_on = True
# print "Tctrl on =",Tcontrol_on
return Tcontrol_on
Tctrl = check_Tcontrol_on()
if Tctrl == False :
print 'T auto control not running.'
prog2 = os.popen("caget -plain X07MA-PC-TC:DMD:LOOP1:SETPOINT")
sp=prog2.read()
#print "sp= "+str(sp)
sp=float(sp)
# path contains the path of the refill log file
path1=time.strftime("%Y_%m", time.localtime())
path2=time.strftime("%Y%m%d", time.localtime())
path="/sls/X07MA/data/x07maop/Data1/"+path1+"/"+path2 +"/"+"refill.log"
if (sp<2.0):
prog = os.popen("caget -plain X07MA-PC-TC:STS:T1")
t=prog.read()
print "t= "+str(t)
t=float(t)
prog2 = os.popen("caget -plain X07MA-PC-HE:LEVELB")
hl=prog2.read()
print "hl= "+str(hl)
hl=float(hl)
if (t > 3.7):
#prc = subprocess.Popen("/sls/X07MA/data/x07maop/python/refill_1kpot.py",shell=True)
#prc.wait()
run("refill_1kpot")
else:
print 'T auto control is running.'
while True:
prog = os.popen("caget -noname -num -nostat X07MA-ES1-TEMP:STATUS")
sp = prog.read()
if sp !='':
sp = float(sp)
else:
break
# if temperature is stable
if sp == 1:
print "T is now stable."
break
time.sleep(1.0)
Tctrl = check_Tcontrol_on()
if Tctrl == False:
print "Tcontrol was switched off. Exiting."
break
time.sleep(1.0)