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 import re import os import time import sys import os.path def connectPV(pvName): pvN = PVFactory.createPV(pvName) pvN.start() cnt = 0 status1 = pvN.isConnected() while (( not (status1)) and (cnt<5) ): cnt += 1 time.sleep(0.1) status1 = pvN.isConnected() if (cnt<5): val = PVUtil.getString(pvN) else: ConsoleUtil.writeInfo( "epics PV " + pvName + " is NOT connected!") pvN.stop() return val Motor= widget.getParent().getMacroValue("P") 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)) dirName_mda_asc=FileSystem + "/" + SubDir + "/" envCmd = 'source /gapps/root/Linux_RHEL6-i686-gcc4.4.7/5.34.26/bin/thisroot.csh /gapps/root/Linux_RHEL6-i686-gcc4.4.7/5.34.26 ;' analysisCmd = ' readMDA --input-directory=' + dirName_mda_asc + ' ' + mdaFileName + ' ; ' xtermCmd = "xterm -geometry 80x10 -e '" + envCmd + " printenv; sleep 1; " + analysisCmd + " ' &> /dev/null &" cmd = xtermCmd #ConsoleUtil.writeInfo( "Will issue command " + cmd ) status = os.system(cmd)