#Set the "value" to the PV with the "suff" suffix for all IOC-es in groupe $(grName) # using a Thread # # V. Kakoyan Feb 2018 # import re import os import time import sys import math 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 from java.lang import Thread, Runnable from java.lang import Thread, Runnable from operator import * appDirectory = os.getenv( "APP" ) iocDirectory = appDirectory + "/scripts/IOC/" sys.path.append( iocDirectory ) import iocPortMap def iocGroup(value,suff,widget): shortPVName=[] channelAddress = [] Pref= widget.getParent().getMacroValue("pref") grName = widget.getParent().getMacroValue("grName") # ConsoleUtil.writeInfo("Pref = " + str(Pref)) # ConsoleUtil.writeInfo("grName = " + str(grName)) # ConsoleUtil.writeInfo("value = " + str(value)) # ConsoleUtil.writeInfo("suff=" + suff) Nwaiting=50 sleepTime=0.1 #-- for all Groups # for groupName in iocPortMap.iocGroupMap.keys() : # if groupName != str(grName): # continue # if grName not in iocPortMap.iocGroupMap.keys() : # ConsoleUtil.writeInfo( " Group "+" *** "+str(grName) + " *** is not known") # return # ConsoleUtil.writeInfo( " Group "+" *** "+str(grName) + " *** " ) #----------------- iocNameList = iocPortMap.iocGroupMap[grName] # ConsoleUtil.writeInfo( "iocNameList : "+str(iocNameList)) N_ioc=0 for iocTuple in sorted( iocPortMap.hostPortMap.items(),key=lambda x:getitem(x[1],'title') ): iocName=str(iocTuple[0]) #ConsoleUtil.writeInfo( "iocName : "+str(iocTuple[0])) if iocName not in iocNameList: continue if iocTuple[1]["enable"] == "disabled": # ConsoleUtil.writeInfo( "iocName : "+str(iocTuple[0])+ " : "+str(iocTuple[1]["enable"])) #ConsoleUtil.writeInfo("**** EnableDisable ="+ str(iocTuple[1]["enable"])) continue N_ioc=N_ioc+1 ioc=iocName shortPVName.append( str(ioc)) # ConsoleUtil.writeInfo( "-N IOCs in group "+ str(grName) +": "+ str(len( iocNameList ))+"; 'enabled': "+ str(N_ioc)) #-------------------------------------- for i in range(0,N_ioc): PVName =Pref + shortPVName[i] + suff channelAddress.append(PVName) # ConsoleUtil.writeInfo("PVName = " + PVName) # Here define the class within this method and then run it class MyTask_softReboot(Runnable): def connectPV(self, k): try: str1 = channelAddress[k] pvN = PVFactory.createPV(str1) pvN.start() cnt = 0 status1 = pvN.isConnected() #ConsoleUtil.writeInfo( "status of isConnected() is "+str(status1)) while (( not (status1)) and (cnt