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 par == 'width': value /= 10 elif par == 'period': if value <> 0: value = 1.0/float(value)/10e-9 else: value = 1000000.0 elif par == 'npulses': value = int(value) else: ConsoleUtil.writeInfo("Parameter %s not found" % par) pv.setValue(round(value)) #ConsoleUtil.writeInfo( "child says: thread: %d %s in cnt: %d running " % (Thread.currentThread().getId(), pv.getValue(),cnt)) return ################################################# pref = widget.getMacroValue("prefpulser1") if widget.getMacroValue("trigSide") == "UP" else widget.getMacroValue("prefpulser2") thread = [] count = 0; if par == 'npulses' and pv0 <> -1: pvs[1].setValue(0) for i in range(32): if not (mask&(1<