#!/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(): 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 #def check_Tcontrol_on(): # return (caget('X07MA-ES1-TEMP:CONTROL','i') == 1) Tctrl = check_Tcontrol_on() if Tctrl == False : print 'T auto control not running.' sp = caget("X07MA-PC-TC:DMD:LOOP1:SETPOINT") # 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 = 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)