#!/APSshare/anaconda3/x86_64/bin/python import epics from time import sleep import sys arg2 = sys.argv outpath = "/home/8-id-g/2018-3/tsai201810p/device/" outfile = outpath + arg2[1] sweepit = 1 plotit = 0 verbose = 0 countup = 1 # see documentation for PyEpics release 3.2.4 # https://www.slac.stanford.edu/grp/ssrl/spear/epics/extensions/pyepics/pyepics.pdf # section 3.1 "The PV class", 3.1.1 for the get() method and 3.1.2 for the timestamp attribute numelem = epics.PV("8ide:2400:ReadArray.NORD"); data2400 = epics.PV("8ide:2400:ReadArray"); print( data2400.get()[1] ) print( data2400.timestamp) oldtime = data2400.timestamp; print("oldtime : ", oldtime) if sweepit : data2400.get(); checktime = data2400.timestamp; epics.caput("8ide:2400:ReadArray.PROC", 1) # wait for sweep to complete -- hack with fixed delay. Is there a condition to test so we know when sweep is complete? print('sweep in progress') sweepct = 0; while (checktime == oldtime) : sleep(0.5); sweepct=sweepct+1; print('waiting for sweep: ', sweepct) data2400.get() checktime = data2400.timestamp; if countup: print('checktime: ', checktime); # close fast shutter epics.caput("8idg:Unidig1Bo13",1) # read in the sweep data indata = epics.caget("8ide:2400:ReadArray"); # read in number of non-zero elements. num2pts = epics.caget("8ide:2400:ReadArray.NORD"); print(num2pts); # development # Why doesn't this agree? For 41 pts (82 values), returns 752. print(sys.getsizeof(indata)) # development if verbose: print(indata) # development f = open(outfile,"w") counter = 0 for i in indata : #print(i) counter=counter+1; if (counter % 2 == 1): try: VOLT = float(i) except: VOLT = "NaN" print("Error converting string to float./n") else : try: CURR = float(i) except: CURR = "NaN" print("Error converting string to float./n") if verbose : print("VOLTAGE=",VOLT," CURRENT=",CURR) f.write('{0:>6} {1}\n'.format(VOLT ,CURR)) f.close() print(arg2[1]) if plotit : print("Plot the data here.")