# V. Kakoyan Oct 2014 # from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.opibuilder.scriptUtil import WidgetUtil from org.csstudio.opibuilder.scriptUtil import ConsoleUtil from org.csstudio.utility.pv import PVFactory from org.csstudio.opibuilder.scriptUtil import ColorFontUtil from java.lang import Thread, Runnable import re import os import time import sys import os.path import threading def connectPV(pvName): pvN = PVFactory.createPV(pvName) pvN.start() cnt = 0 status1 = pvN.isConnected() #ConsoleUtil.writeInfo( "status of isConnected() is "+str(status1)) while (( not (status1)) and (cnt<5) ): cnt += 1 time.sleep(0.1) status1 = pvN.isConnected() if (cnt<5): #ConsoleUtil.writeInfo( "epics variable is connected!") #val = pvN.getValue() #ConsoleUtil.writeInfo( "and the value is " + str(val)) val = PVUtil.getString(pvN) #ConsoleUtil.writeInfo( "***str value is " + str(val)) else: ConsoleUtil.writeInfo( "epics PV " + pvName + " is NOT connected!") pvN.stop() return val class Task_rw(Runnable): def __init__(self, ) : return #----- def run(self): try: # Motor= widget.getParent().getMacroValue("P") # ConsoleUtil.writeInfo("Motor=" + str(Motor)) # # PVFileSystem =Motor + "saveData_fileSystem" # PVSubDir =Motor + "saveData_subDir" # PVBaseName =Motor + "saveData_baseName" # PVFullPathName=Motor + "saveData_fullPathName" # PVmdaFileName =Motor + "saveData_fileName" ##--- connect to the saveData PVs # FileSystem=connectPV(PVFileSystem) # ConsoleUtil.writeInfo( "FileSystem = " + str(FileSystem)) # SubDir=connectPV(PVSubDir) # ConsoleUtil.writeInfo( "SubDir = " + str(SubDir)) # BaseName=connectPV(PVBaseName) # ConsoleUtil.writeInfo( "BaseName = " + str(BaseName)) # FullPathName=connectPV(PVFullPathName) # ConsoleUtil.writeInfo( "FullPathName = " + str(FullPathName)) # mdaFileName=connectPV(PVmdaFileName) # ConsoleUtil.writeInfo( "mdaFileName = " + str(mdaFileName)) # #--------- newLine=[] nOfScalers2=34 # N of scalers+2 # dir and file names from sscan # dirName_out=FileSystem # dirName_mda_asc=FileSystem+"/"+SubDir+"/" # ConsoleUtil.writeInfo( "dirName_out = " + str(dirName_out)) # ConsoleUtil.writeInfo( "dirName_mda_asc = " + str(dirName_mda_asc)) # fName_mda=mdaFileName + ".mda" # fName_asc=mdaFileName + ".asc" # ConsoleUtil.writeInfo( "fName_mda = " + str(fName_mda) +" fName_asc =" + str(fName_asc)) #--------------------- dirName_out="/gluonfs1/gluex/data/HarpScans/" dirName_mda_asc="/gluonfs1/gluex/data/HarpScans/sscanData/" fName_mda="data_0001.mda" fName_asc="data_0001.asc" #--------------------- fName_out="harp_electron_" #--------- fAbsName_mda=dirName_mda_asc+fName_mda fAbsName_asc=dirName_mda_asc+fName_asc if os.path.isfile(fAbsName_mda): ConsoleUtil.writeInfo(fAbsName_mda+" file exists") cmd="/gapps/mdautils/mdautils-1.3.0-linux-64/mda2ascii -o " + fAbsName_asc +" "+ fAbsName_mda os.system(cmd) else: raise ValueError("%s isn't a file!" % fAbsName_mda) file1 = open(fAbsName_asc, 'r') for line in file1: #print "Read Line: %s" % (line) # print line #ConsoleUtil.writeInfo("------------------- ") #ConsoleUtil.writeInfo("Read Line: "+str(line)) words = line.split() # print words #ConsoleUtil.writeInfo("N of words in line " +str(len(words)) ) numberOfWords=len(words) if (numberOfWords==0): continue if ((words[0] == "#")or(words[0] == "##")): if((words[1]=="Scan")and (words[2]=="time")): words2 = words[7].split(":") scanTime=words[4]+"_"+words[5].replace(",","")+"_"+words[6]+"_"+words2[0]+"_"+words2[1] ConsoleUtil.writeInfo("Scan time is: " + str(scanTime)) fAbsName_out=dirName_out+fName_out+scanTime+".out" file2 = open(fAbsName_out, 'w') continue else: for i in range(0,numberOfWords): #ConsoleUtil.writeInfo("i= " +str(i) + " " +str(words[i])) if(i