69 lines
1.9 KiB
Python
69 lines
1.9 KiB
Python
#!/usr/bin/env python
|
|
|
|
import os,time,subprocess
|
|
|
|
# this checks whether the T control is running or not
|
|
# it returns True if T control script is running AND the control is switched ON
|
|
# if the script is not running OR the control is switched OFF then this check will return False
|
|
def check_Tcontrol_on():
|
|
try:
|
|
#prog = os.popen("caget -noname -num -nostat X07MA-ES1-TEMP:CONTROL")
|
|
sp = float( TControl.read() )
|
|
except: # if channel doesn't exist because orange window with script is not running
|
|
#Tcontrol_on = False
|
|
sp = 0
|
|
finally:
|
|
# sp=prog.read()
|
|
if sp != 1:
|
|
Tcontrol_on = False
|
|
else:
|
|
Tcontrol_on = True
|
|
|
|
return Tcontrol_on
|
|
|
|
#def check_Tcontrol_on():
|
|
# return (caget('X07MA-ES1-TEMP:CONTROL','i') == 1)
|
|
|
|
Tctrl = check_Tcontrol_on()
|
|
#print ("Tctrl value:", Tctrl)
|
|
|
|
|
|
if Tctrl == False :
|
|
sp = temperature.read() # caget("X07MA-PC-TC:DMD:LOOP1:SETPOINT")
|
|
print 'T auto control not running. Setpoint = ' + str(sp) + ' K'
|
|
|
|
# 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):
|
|
t = temperature.readback.read() # caget("X07MA-PC-TC:STS:T1",'d')
|
|
print "t= ",t
|
|
hl = caget("X07MA-PC-HE:LEVELB",'d')
|
|
print "hl= ",hl
|
|
|
|
if (t > 3.7):
|
|
run("refill_1kpot")
|
|
|
|
else:
|
|
print 'T auto control is running. Waiting for temperature to stabilize...'
|
|
|
|
while True:
|
|
st = caget("X07MA-ES1-TEMP:STATUS",'i')
|
|
|
|
# if temperature is stable
|
|
if st == 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)
|
|
|