from org.csstudio.opibuilder.scriptUtil import PVUtil, ConsoleUtil from org.csstudio.utility.pv import PVFactory import time from java.lang import Thread, Runnable mask = int(widget.getParent().getMacroValue("chmask"),16) par = widget.getMacroValue("par") base = 32 PVs = [] pv0 = PVUtil.getDouble(pvs[0]) from BCAL_NIMControl_parameters import delay_time ########## Class to handle the connection ####### class PVconnect(Runnable): def __init__(self,pv,value): self.pv = pv self.value = value return def run(self): pv = self.pv value = self.value pv.start() cnt = 0 status = pv.isConnected() while ( not status) and (cnt<5) : cnt += 1 Thread.sleep(delay_time) status = pv.isConnected() if cnt == 5: ConsoleUtil.writeInfo("Error: Timeout to connect with PV %s --- %d (ms)" % (pv.getName(), cnt*delay_time)) if value : pv.setValue(-1) elif PVUtil.getDouble(pv) == -1 : pv.setValue(0) return ################################################# pref = widget.getMacroValue("prefpulser1") if widget.getMacroValue("trigSide") == "UP" else widget.getMacroValue("prefpulser2") thread = [] count = 0; for i in range(32): if not (mask&(1<