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 from BCAL_NIMControl_parameters import delay_time ########## Class to handle the connection ####### class PVconnect(Runnable): def __init__(self,pv): self.pv = pv self.value = 0.0 return def run(self): pv = self.pv pv.start() cnt = 0 status = pv.isConnected() while ( not status) and (cnt<5) : #Wait for connection max 1 s. 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)) value = PVUtil.getDouble(pv) if par == 'width': value *= 10 elif par == 'period': if value > 0: value = 100.0e6/(value) else: value = 100.0e6 elif par == 'npulses': value = int(value) else: ConsoleUtil.writeInfo("Parameter %s not found" % par) self.value = value #ConsoleUtil.writeInfo( "child says: thread: %d %s in cnt: %d running " % (Thread.currentThread().getId(), pv.getValue(),cnt)) return ################################################# class runInThread(Runnable): def run(self): pref = widget.getMacroValue("prefpulser1") if widget.getMacroValue("trigSide") == "UP" else widget.getMacroValue("prefpulser2") thread = [] con = [] PVs = [] count = 0; for i in range(32): if not (mask&(1< -1: text_value = "# %d" % int(value) else: text_value = "INF" else: ConsoleUtil.writeInfo("Parameter %s not found" % par) pvs[0].setValue(text_value) th = Thread(runInThread()) th.start()