import re import os import time import sys from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.opibuilder.scriptUtil import ConsoleUtil from org.csstudio.utility.pv import PVFactory from org.csstudio.opibuilder.scriptUtil import ColorFontUtil channelAddress = [] #from threading import Thread from java.lang import Thread, Runnable Pref= widget.getParent().getMacroValue("P") R= widget.getParent().getMacroValue("G") value =1 ConsoleUtil.writeInfo("XPS = " + str(Pref)) ConsoleUtil.writeInfo("value = " + str(value)) NChannels=4 PVName =Pref + R + "groupKill" channelAddress.append(PVName) ConsoleUtil.writeInfo("PVName = " + PVName) PVName =Pref + R + "groupInitialize" channelAddress.append(PVName) ConsoleUtil.writeInfo("PVName = " + PVName) PVName =Pref + R + "groupHomeSearch" channelAddress.append(PVName) ConsoleUtil.writeInfo("PVName = " + PVName) PVName =Pref + R + "groupMotionDisable" channelAddress.append(PVName) ConsoleUtil.writeInfo("PVName = " + PVName) class MyTask(Runnable): def run(self): # loop over all CDC channels and switch the state to NewState for k in range(0,NChannels): str1 = channelAddress[k] #ConsoleUtil.writeInfo("LV Cannel "+str(k+1) +" of "+ str(NChannels) + " Connect to "+str1) pvN = PVFactory.createPV(str1) pvN.start() cnt = 0 #status0 = pvN.getStateInfo() #status0E = pvE.getStateInfo() #ConsoleUtil.writeInfo( "status of getStateInfo() is "+status0) status1 = pvN.isConnected() #ConsoleUtil.writeInfo( "status of isConnected() is "+str(status1)) while ( not (status1) and (cnt<5) ): cnt += 1 time.sleep(.1) status1 = pvN.isConnected() if (cnt<5): #ConsoleUtil.writeInfo( "epics variable is connected!") #val = pvN.getValue() #ConsoleUtil.writeInfo( "and the value is "+str(val)) time.sleep(3) pvN.setValue(value) # else: # ConsoleUtil.writeInfo( "Channel " + str1 + " , Ignor On/Off: Enable value is "+ str(ChannelEnable)) else: ConsoleUtil.writeInfo( "epics channels "+str1+" is NOT connected!") pvN.stop() # this is the end of the loop # this is the end of the task thread thread = Thread(MyTask()) thread.start() #===============================================================================