# running from LED_LVChannels.opi # bild a dinamic list of Bias Channel # # V. Kakoyan Sept 2018 # 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 from org.csstudio.opibuilder.scriptUtil import ColorFontUtil from java.lang import Thread, Runnable import re import os import time import sys import threading class MyTask_table(Runnable): def __init__(self, wid ) : self.widget = wid #self.widget.removeAllChildren() self.widget.setPropertyValue("height",550.0) self.lc = [] self.addedChannels = [] return def AddContainer(self) : columnMutex.acquire() for iLC in range( 0, len(self.lc) ): self.widget.addChildToBottom( self.lc[iLC] ) #ConsoleUtil.writeInfo("Added "+str(iLC+1) + " of" + str(len(self.lc))) #ConsoleUtil.writeInfo("Added PVName "+str(self.addedChannels[iLC]) ) columnMutex.release() return #----- def run(self): columnMutex.acquire() try: Arr=[] channelEnable = [] Pref= widget.getParent().getMacroValue("pref") CHANNUM = Pref + widget.getParent().getMacroValue("CHANNUM") #----------------- NChannels=1 #ConsoleUtil.writeInfo( "NChannels = "+str(NChannels)) height_n=(NChannels+1)*32. self.widget.setPropertyValue("height",height_n) for i in range(0,NChannels): #ConsoleUtil.writeInfo( "=====epics variable is connected!") locLC = WidgetUtil.createWidgetModel("org.csstudio.opibuilder.widgets.linkingContainer") #locLC.setPropertyValue("opi_file", "STBias_channel.opi") locLC.setPropertyValue("opi_file", "../../Voltages/LV/winner.opi") locLC.setPropertyValue("auto_size", True) locLC.setPropertyValue("zoom_to_fit", False) locLC.setPropertyValue("border_style", 0) locLC.setPropertyValue("x", 0 ) locLC.setPropertyValue("name", "LC" + str(i) ) locLC.addMacro("CHANNUM", CHANNUM) #locLC.addMacro("shortCHANNUM", shortCHANNUM) self.addedChannels.append(CHANNUM) self.lc.append( locLC ) return except Exception, e: ConsoleUtil.writeInfo( "There was a problem : " + str(e) ) raise e finally: #ConsoleUtil.writeInfo( "Finally" ) columnMutex.release() return ####################################################################################################################################### task = MyTask_table( widget ) columnMutex = threading.BoundedSemaphore(1) thread = Thread( task ) thread.start() Thread.sleep(1) #task.AddContainer() while( not columnMutex.acquire( 0 ) ) : #ConsoleUtil.writeInfo( "Locked" ) Thread.sleep( 1 ) columnMutex.release() #ConsoleUtil.writeInfo( "Now unlocked" ) task.AddContainer()