def prepare_tabledata(self): if self.s == None: self.tableData = [['', '', '', '', False]] else: self.tableData = [] for l in self.s: idstr = l[0] pvname = l[1] # read PV value curval = "---" restore_flag = l[2] try: ipv = PVUtil.createPV(pvname, self.widget) curval = PVUtil.getString(ipv) except: restore_flag = False if self.savemode: self.tableData.append( [pvname, idstr, curval, restore_flag]) else: self.tableData.append( [pvname, idstr, curval, '---', restore_flag]) if self.savemode: self.colNames = TABLE_HEADER_SAVEMODE else: self.colNames = TABLE_HEADER_LOADMODE self.dataModel = MyTableModel(self.tableData, self.colNames, savemode=self.savemode)
def run(self): simuData = array.array('d', range(65536)) value = PVUtil.getDouble(pvs[0]) dataSrc = PVUtil.getString(pvs[1]) if dataSrc == "Linear Sine Wave": for i in range(256): for j in range(256): simuData[i * 256 + j] = math.sin(j * 6 * math.pi / 256 + i * 6 * math.pi / 256 + value) else: for i in range(256): for j in range(256): x = j - 128 y = i - 128 p = math.sqrt(x * x + y * y) simuData[i * 256 + j] = math.sin(p * 2 * math.pi / 256 + value) class UITask(Runnable): def run(self): widget.setValue(simuData) UIBundlingThread.getInstance().addRunnable(currentDisplay, UITask())
def main(): if spectrumPv.isConnected(): spectrum = PVUtil.getLong(spectrumPv) if spectrum is None: spectrum = 1 else: spectrum = 1 if periodPv.isConnected(): period = PVUtil.getLong(periodPv) if period is None: period = 1 else: period = 1 if modePv.isConnected() and PVUtil.getString(modePv).lower() == "counts": mode = "YC" axis_title = "Counts" else: mode = "Y" axis_title = "Counts/us" widget.setPropertyValue("trace_0_x_pv","$(P)DAE:SPEC:" + str(period) + ":" + str(spectrum) + ":X") widget.setPropertyValue("trace_0_y_pv","$(P)DAE:SPEC:" + str(period) + ":" + str(spectrum) + ":" + mode) widget.setPropertyValue("axis_1_axis_title", axis_title)
def getWidgetPVString(display, widget): """Fetch value of a widget's PV @param display BOY Display @param widget Widget name @return Value of that PV as string """ pv = display.getWidget(widget).getPV() return str(PVUtil.getString(pv))
def getWidgetPVString(display, widget): """Fetch value of a widget's PV @param display BOY Display @param widget Widget name @return Value of that PV as string """ pv = display.getWidget(widget).getPV() return str(PVUtil.getString(pv))
def get_pv_value(pv, max_wait=1.0): """ Gets the value of a PV as a string. Returns None if no value available """ steps = 100 for i in range(steps): try: return PVUtil.getString(pv) except: sleep(max_wait/steps) return None
def get_motor_pvs(): """ Get the PVs containing the names of the motors associated with the specified soft motors """ motor_pvs = [] for name in [PVUtil.getString(pv) for pv in pvs[1:]]: # pvs[0] is for the number of motors if is_unexpanded_macro(name) or len(name) == 0: motor_pvs.append(None) else: # Associate all PVs with the top-level display for ease. Shouldn't be any conflict motor_pvs.append(PVUtil.createPV(display.getMacroValue("P") + name + ":MOTOR", display)) return motor_pvs
def run(self): element = PVUtil.getString(pvs[1]) edge = PVUtil.getString(pvs[2]) vacuum_press = PVUtil.getString(pvs[3]) default_press = PVUtil.getString(pvs[4]) wait_purge = PVUtil.getString(pvs[5]) wait_vacuum = PVUtil.getString(pvs[6]) argon_order = int(PVUtil.getDouble(pvs[7])) helium_order = int(PVUtil.getDouble(pvs[8])) nitrogen_order = int(PVUtil.getDouble(pvs[9])) ConsoleUtil.writeInfo("Element: " + str(element)) ConsoleUtil.writeInfo("Edge: " + str(edge)) ConsoleUtil.writeInfo("Vacuum_press: " + str(vacuum_press)) ConsoleUtil.writeInfo("Default_press: " + str(default_press)) ConsoleUtil.writeInfo("Wait_purge: " + str(wait_purge)) ConsoleUtil.writeInfo("Wait_vacuum: " + str(wait_vacuum)) ConsoleUtil.writeInfo("Argon_order: " + str(argon_order)) ConsoleUtil.writeInfo("Helium_order: " + str(helium_order)) ConsoleUtil.writeInfo("Nitrogen_order: " + str(nitrogen_order)) command = [ 'gass', str(element), str(edge), "--pressureVacuum=" + str(vacuum_press), "--pressureWork=" + str(default_press), "--extraTimeManifold=" + str(wait_purge), "--extraTimeManifoldVacuum=" + str(wait_vacuum), "--argonOrder=" + str(argon_order), "--heliumOrder=" + str(helium_order), "--nitrogenOrder=" + str(nitrogen_order) ] #command = ['python3.4', '/usr/local/bin/gass', '-h'] #command = ['gass', '-h'] #command = "gass %s %s" % (str(element), str(edge)) ConsoleUtil.writeInfo("command: " + str(command)) #pvs[0].setValue(0) subprocess.call(command)
from org.csstudio.opibuilder.scriptUtil import PVUtil, WidgetUtil, ConsoleUtil hvstr = PVUtil.getString(pvArray[0]) hvinfo = hvstr.split(",") hv = hvinfo[3] board = hvinfo[4] half = hvinfo[5] chstr = PVUtil.getString(pvArray[1]) chlist = chstr.split(",") nchan = len(chlist) ch2 = PVUtil.getString(pvArray[2]) ConsoleUtil.writeInfo("pv0=" + hvstr) ConsoleUtil.writeInfo("pv1=" + chstr) ConsoleUtil.writeInfo("pv2=" + ch2) #ConsoleUtil.writeInfo(str(xcoords[5])) for n in range(0, nchan): ConsoleUtil.writeInfo("Chann" + str(n)) linkingContainer = WidgetUtil.createWidgetModel( "org.csstudio.opibuilder.widgets.linkingContainer") linkingContainer.setPropertyValue("opi_file", "chan1.opi") linkingContainer.addMacro("ID", chlist[n]) linkingContainer.setPropertyValue("resize_behaviour", 1) linkingContainer.setPropertyValue("border_style", 0) widget.addChildToBottom(linkingContainer) linkingContainer = WidgetUtil.createWidgetModel(
#9 $(P)_YTITLE #10 local_YTITLE #11 local TRACETYPE init = widget.getPropertyValue("border_width") #misuse this as an init flag if init == 0: #if not already initialised xmin = PVUtil.getDouble(pvArray[0]) #get all the PVs lxmin = PVUtil.getDouble(pvArray[1]) xmax = PVUtil.getDouble(pvArray[2]) lxmax = PVUtil.getDouble(pvArray[3]) nbinsx = PVUtil.getLong(pvArray[4]) lnbinsx = PVUtil.getLong(pvArray[5]) nelm = PVUtil.getLong(pvArray[6]) xt = PVUtil.getStringArray(pvArray[7]) lxt = PVUtil.getString(pvArray[8]) yt = PVUtil.getStringArray(pvArray[9]) lyt = PVUtil.getString(pvArray[10]) trace = PVUtil.getLong(pvArray[11]) xt = list(map(int, xt)) #convert the waveforms into strings - ugly! xtstr = "".join([chr(c) for c in xt]) yt = list(map(int, yt)) ytstr = "".join([chr(c) for c in yt]) #in all cases we let the local PVs (from MACROS) override those from the ioc, #for axes, if XMAX<XMIN it means the variables are not filled - do it anther way. if (lxmin < lxmax): #test macro version first xminval = lxmin
from org.csstudio.opibuilder.scriptUtil import PVUtil, DataUtil, ConsoleUtil register_pv = pvArray[0] display_mode_pv = pvArray[1] deviation_register_pv = pvArray[2] numBPM = 160 ## Get Orbit Widgets graph_orbit_x = display.getWidget("Graph Orbit X") graph_orbit_y = display.getWidget("Graph Orbit Y") ## Update Graphical Data try: if triggerPV == register_pv: register = PVUtil.getString(register_pv) registers = widget.getWidget("Register Selection").getPropertyValue("items") if register == registers[0]: orbit_x_pv = widget.getMacroValue("orbit_x_ioc") orbit_y_pv = widget.getMacroValue("orbit_y_ioc") trigger = 1 else: orbit_x_pv = widget.getMacroValue("orbit_x_graph") orbit_y_pv = widget.getMacroValue("orbit_y_graph") orbit_x = DataUtil.createDoubleArray(numBPM) orbit_y = DataUtil.createDoubleArray(numBPM) if register == registers[1] or register == registers[2]: orbit_filename = register[-1] + ".txt" orbit_pathname = "/home/fac_files/hla/sirius/machine_apps/si_sofb/" orbit_x_data = open(orbit_pathname+"reforbit_x/"+orbit_filename).readlines() orbit_y_data = open(orbit_pathname+"reforbit_y/"+orbit_filename).readlines()
#Fill PV Name only once if widget.getVar("firstTime") == None: widget.setVar("firstTime", True) i = 0 for pv in pvs: table.setCellText(i, 0, pv.getName()) if not pv.isConnected(): table.setCellText(i, 1, "Disconnected") i += 1 #find index of the trigger PV i = 0 while triggerPV != pvs[i]: i += 1 table.setCellText(i, 1, PVUtil.getString(triggerPV)) table.setCellText(i, 2, PVUtil.getTimeString(triggerPV)) table.setCellText(i, 3, PVUtil.getStatus(triggerPV)) table.setCellText(i, 4, PVUtil.getSeverityString(triggerPV)) s = PVUtil.getSeverity(triggerPV) color = ColorFontUtil.WHITE if s == 0: color = ColorFontUtil.GREEN elif s == 1: color = ColorFontUtil.RED elif s == 2: color = ColorFontUtil.YELLOW elif s == 3: color = ColorFontUtil.PINK
from org.csstudio.opibuilder.scriptUtil import PVUtil from org.eclipse.ui import PlatformUI if PVUtil.getDouble(pvs[0]): selection_type = PVUtil.getString(pvs[1]) #if selection_type in ['ch', 'cv', 'fch', 'fcv', 'qs']: selection_type = "Corrector" title = selection_type.upper() + ' Selection' window = PlatformUI.getWorkbench().getActiveWorkbenchWindow() window.getShell().setText(title) pvs[0].setValue(0)
# If we should flip if should_flip != bool(display.getVar("flipped")): flipDisplay(display) display.setVar("flipped", should_flip) # Now iterate through the pvs, stopping when something is blocking the beam lastx = None firstpv = True for pv in pvs: # skip the first PV which is 'flipped' (and un-initialised until a flip occurs) if firstpv: firstpv = False continue # First get the name of the item name = PVUtil.getString(pv) # Now see if we can get a named widget from this pv value try: w = display.getWidget(name) except: continue # If we got this far then we have a widget that is blocking the beam # so store its x co-ordinate if should_flip: lastx = w.getPropertyValue("x") + w.getPropertyValue("width") else: lastx = w.getPropertyValue("x") break # Get the right source array of points if should_flip:
from org.csstudio.opibuilder.scriptUtil import PVUtil op1 = PVUtil.getDouble(pvs[0]) op2 = PVUtil.getDouble(pvs[1]) operator = PVUtil.getString(pvs[2]) resultPV = pvs[3] if operator == "+": resultPV.setValue(op1 + op2) elif operator == "-": resultPV.setValue(op1 - op2) elif operator == "*": resultPV.setValue(op1 * op2) elif operator == "/": resultPV.setValue(op1 / op2)
from org.csstudio.opibuilder.scriptUtil import PVUtil, WidgetUtil, ConsoleUtil ch = int(PVUtil.getDouble(pvArray[0])) desc = widget.getPropertyValue("tooltip") #ConsoleUtil.writeInfo(desc) currhv = -1 if len(desc) > 2: ConsoleUtil.writeInfo(desc) currhv = int(desc[desc.find("HVChan") + 7:]) ConsoleUtil.writeInfo("Currhv = " + str(currhv)) if currhv < 0: hv = "1" else: hv = PVUtil.getString(pvArray[1]) if (int(hv) != currhv): widget.removeAllChildren() #clean the area first linkingContainer = WidgetUtil.createWidgetModel( "org.csstudio.opibuilder.widgets.linkingContainer") linkingContainer.setPropertyValue("opi_file", "chan8.opi") linkingContainer.addMacro("ID", str(ch).zfill(3)) #linkingContainer.addMacro("ID", ch) linkingContainer.addMacro("HV", str(hv.zfill(2))) linkingContainer.setPropertyValue("resize_behaviour", 1) linkingContainer.setPropertyValue("border_style", 0) widget.addChild(linkingContainer) widget.setPropertyValue("tooltip", "ChanHV " + hv)
#Warning - some danger of infinite recursion here. Careful" #The $(LCID) macro is used to make local PVs per instance. So several instances could be run from the same CSS #without interfering. #For example loc://$(LCID)_NODE pv is like this: B_SYS_HV_ECAL_SEC1_..... #split into list with elements 0 1 2 3 4 5 #eg - with N for the menu N = 3 * # nodeLoader.readTree() #Read in the node tree n = int(widget.getMacroValue("N")) #Get N,B and NODE topnode=widget.getMacroValue("TOP") node = PVUtil.getString(pvArray[0]) if not node in nodeLoader.NodeIndex: # check node defined, or force to top node node=topnode nlist=node.split("_") #make a list of the parts of node nlist = (B,SYS,HV,ECAL,SEC1,....) #widget.setPropertyValue("height",24 ) #and size #widget.setPropertyValue("visible","false") #assume invisible until other decision made widget.setPropertyValue("enabled","false") #assume invisible until other decision made widget.setPropertyValue("background_color","OPI_Background") #assume invisible until other decision made if n<=len(nlist): #if this level is included in the node parent=topnode if n>1: for e in range(1,n):
if not pv.isConnected(): table.setCellText(i / 2, 1, "Disconnected") i += 1 # Based on value of macro SHOW_PLC_IOC, enable visibility of PLCIOCDetailsTable if widget.getPropertyValue("name") == 'PLCIOCDetailsTable': if display.getMacroValue("SHOW_PLC_IOC") == "true": widget.setPropertyValue("visible", "true") display.getWidget("PLCIOCDetailsLabel").setPropertyValue( "visible", "true") #find index of the trigger PV i = 0 while triggerPV != pvs[i]: i += 1 pvValue = PVUtil.getString(triggerPV).strip() eugValue = table.getCellText(i, 4) if eugValue != "": pvValue = pvValue + " " + eugValue table.setCellText(i, 1, pvValue) table.setCellText(i, 2, PVUtil.getStatus(triggerPV).strip()) table.setCellText(i, 3, PVUtil.getSeverityString(triggerPV).strip()) s = PVUtil.getSeverity(triggerPV) color = ColorFontUtil.WHITE if s == 0: color = ColorFontUtil.GREEN elif s == 1: color = ColorFontUtil.RED elif s == 2:
from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.opibuilder.scriptUtil import ConsoleUtil value = PVUtil.getString(pvs[0]) units = PVUtil.getString(pvs[1]) widget.setValue(value + " " + units)
from org.csstudio.opibuilder.scriptUtil import PVUtil, WidgetUtil, ConsoleUtil #select next or previous sibling in nodelist combo = display.getWidget("Node_Selector_Combo") nodelist = combo.getPropertyValue("items") listlen = len(nodelist) nodefull = PVUtil.getString(pvArray[1]) inc = int(PVUtil.getLong(pvArray[0])) index = nodelist.index(nodefull) nodelen = len(nodefull.split("_")) #ConsoleUtil.writeInfo(nodefull + " inc " + str(inc)+ " index " + str(index) + " len " + str(listlen)) if not inc == 0: index += inc if (index >= 0) and (index < listlen): node = nodelist[index] if len(node.split("_")) == nodelen: combo.setPropertyValue("pv_value", node) pvArray[1].setValue(node) pvArray[0].setValue("0")
from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.opibuilder.scriptUtil import DataUtil macroInput = DataUtil.createMacrosInput(True) pvname = widget.getPVByName("loc://SetEemem") pvvalue = PVUtil.getString(pvname) if pvvalue == "IP": pvvalue = "Ip" elif pvvalue == "MAC": pvvalue = "Mac" macroInput.put("EEMEM_VALUE", "%s" % pvvalue) widgetController.setPropertyValue("macros", macroInput) widgetController.setPropertyValue("opi_file", widgetController.getPropertyValue("opi_file"), True)
button.setPropertyValue("pv_name", power_supply) #button.setPropertyValue("text", power_supply) #spinner.setPropertyValue("pv_name", setpoint) #text_update.setPropertyValue("pv_name", readback) #led.setPropertyValue("pv_name", '$(power_supply_status)') macro_inputs = DataUtil.createMacrosInput(True) macro_inputs.put("power_supply", power_supply) macro_inputs.put("power_supply_sp", setpoint) macro_inputs.put("power_supply_rb", readback) macro_inputs.put("power_supply_start", 'sim://const("quadrupole")') linkingContainer.setPropertyValue("macros", macro_inputs) subsystem = "SIPS-" family = PVUtil.getString(pvs[0]).upper() power_supplies = get_power_supply_list(family) header_opi = "table/selection_table_low_header.opi" line_opi = "table/selection_table_line.opi" table_container = display.getWidget("table_container") #fam_table = display.getWidget("fam_table") #shunt_table_1 = display.getWidget("shunt_table_1") #shunt_table_2 = display.getWidget("shunt_table_2") #fam_table.removeAllChildren() #shunt_table_1.removeAllChildren() #shunt_table_2.removeAllChildren() if power_supplies is None: table_container.setPropertyValue("visible", False)
from org.csstudio.opibuilder.scriptUtil import PVUtil import os, time numberofboxes = 19 check_eemem_boxarray = [] eemem_message = display.getWidget("eemem_message") set_eemem = display.getWidget("eemem_choice").getPV() set_eemem_choice = PVUtil.getString(set_eemem) def is_number(s): try: float(s) return True except ValueError: return False if set_eemem_choice == "": eemem_message.setPropertyValue( "text", "Please select which values to change and alter at least one of them.") ####################### SetEemem => Cards ############################### elif set_eemem_choice == "Cards": cardscount = 0 empty_cards = 0 cards_message = ""
from org.csstudio.opibuilder.scriptUtil import ConsoleUtil from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.opibuilder.scriptUtil import ColorFontUtil import WidgetUtil lvl2 = PVUtil.getString(pvs[0]) lvl3 = PVUtil.getString(pvs[1]) label_name = "Combo_2" ATT_array = ["VM1", "VM2", "VM3", "VM4", "VM5", "VM6", "VM7", "ADC"] GATE_array = ["VM1", "VM2", "VM3", "VM4", "VM5", "VM6", "VM7"] CONST_array = ["VM1", "VM2", "VM3", "VM4", "VM5", "VM6", "VM7"] MUX_array = ["VM1", "VM2", "VM3", "VM4", "VM5", "VM6", "VM7"] SYNC_array = ["MODE", "DELAY", "ON", "OFF"] AWG_array = [ "SIN", "TRAF", "TRAR", "TRAC", "FALL", "RIS", "SQON", "SQOFF", "TRIG", "OUT" ] AMP_array = ["MODE", "Q", "GAIN"] MODEX_array = ["Q", "GAIN", "DETU"] PIEZO_array = ["GAIN"] temp = lvl2 if temp == "ATT": WidgetUtil.setItems(display, label_name, ATT_array) elif temp == "GATE": WidgetUtil.setItems(display, label_name, GATE_array) elif temp == "CONSTI" or temp == "CONSTQ": WidgetUtil.setItems(display, label_name, CONST_array) elif temp == "MUX":
col = 3 #ConsoleUtil.writeInfo("Trigger PV : " + triggerPV.getName()); while triggerPV != pvs[i]: if col == 5: if pvs[i+1].getName() == "epics://" + func + ":" + table.getCellText(row, 0) + "PLC-IOCHLTS": col = col+1 else: col = 3 row = row+1 else: col += 1 if col > 6: row += 1 col = 3 i += 1 table.setCellText(row, col, PVUtil.getString(triggerPV)) s = PVUtil.getSeverity(triggerPV) color = ColorFontUtil.WHITE if s == 0: color = ColorFontUtil.GREEN elif s == 1: color = ColorFontUtil.RED elif s == 2: color = ColorFontUtil.YELLOW elif s == 3: color = ColorFontUtil.PINK table.setCellBackground(row, col, color)
from org.csstudio.opibuilder.scriptUtil import PVUtil, WidgetUtil, DataUtil def add_header(table, header_opi): linkingContainer = WidgetUtil.createWidgetModel("org.csstudio.opibuilder.widgets.linkingContainer") linkingContainer.setPropertyValue("opi_file", header_opi) linkingContainer.setPropertyValue("resize_behaviour", 1) linkingContainer.setPropertyValue("border_style", 0) table.addChildToBottom(linkingContainer) device_type = PVUtil.getString(pvs[0]).lower() if device_type == 'bpm': left_header_opi = "table/selection_table_bpm.opi" elif device_type == 'ch': left_header_opi = "table/selection_table_ch.opi" elif device_type == 'cv': left_header_opi = "table/selection_table_cv.opi" up_header_opi = "table/selection_table_up_header.opi" low_header_opi = "table/selection_table_low_header.opi" table_container = display.getWidget("table_container") if device_type is None: table_container.setPropertyValue("visible", False) else: add_header(table_container, up_header_opi) add_header(table_container, left_header_opi) add_header(table_container, low_header_opi)
""" Initialize Table widget with last scan @author: Kay Kasemir """ from errors import showException try: from org.csstudio.opibuilder.scriptUtil import PVUtil from scan.table.table_scan import TableScan from tablescan_ui import getTableFromPath, displayTableInWidget # Try to load table from file path = PVUtil.getString(pvs[1]) table_scan = None try: table_scan = getTableFromPath(path) except: table_scan = None pvs[1].setValue("") # Create default table if nothing loaded if not table_scan: table_scan = TableScan( [ "motor_x", TableScan.WAITFOR, TableScan.VALUE, TableScan.OR_TIME ], [ [ "1", TableScan.SECONDS, "00:05:00", "" ], ]) displayTableInWidget(display, table_scan) except: showException("Sorry...")
from org.csstudio.opibuilder.scriptUtil import PVUtil import os, time numberofboxes = 19 check_eemem_boxarray =[] eemem_message = display.getWidget("eemem_message") set_eemem = display.getWidget("eemem_choice").getPV() set_eemem_choice = PVUtil.getString(set_eemem) def is_number(s): try: float(s) return True except ValueError: return False if set_eemem_choice == "": eemem_message.setPropertyValue("text","Please select which values to change and alter at least one of them.") ####################### SetEemem => Cards ############################### elif set_eemem_choice == "Cards": cardscount = 0 empty_cards = 0 cards_message ="" ################ check if calibration file exists ################# filepath = display.getWidget("eemem_cards_cal_file").getValue()
#loc://$(LCID)_MOUT (pv[1]) is changed, tiggering nodeMenuAction.py for ChoiceButton_N, which makes #loc://$(LCID)_NODE (pv[0]) change, triggering nodeMenuUpdate.py for all buttons. #Warning - some danger of infinite recursion here. Careful" #The $(LCID) macro is used to make local PVs per instance. So several instances could be run from the same CSS #without interfering. #For example loc://$(LCID)_NODE pv is like this: B_SYS_HV_ECAL_SEC1_..... #split into list with elements 0 1 2 3 4 5 #eg - with N for the menu N = 3 * # # 3 clicked to set DC changes loc://$(LCID)_NODE pv to B_SYS_HV_DC n = int(widget.getMacroValue("N")) #Get N,TOP and NODE and MOUT_$(N) topnode = widget.getMacroValue("TOP") node = PVUtil.getString(pvArray[0]) sel = PVUtil.getString(pvArray[1]) nlist = node.split( "_") #make a list of the parts of node nlist = (B,SYS,HV,ECAL,SEC1,....) #ConsoleUtil.writeInfo("Action:"+str(n)+", mode= "+node+", sel= "+sel) if not sel == 'select..': if n >= len(nlist) or ((n < len(nlist)) and (not sel == nlist[n])): newnode = topnode if n >= 1: for e in range(1, n): newnode += "_" + nlist[e] newnode += "_" + sel pvArray[0].setValue(newnode)
pvs[0-19] = CHNL:XXX:READ pvs[20-39] = CHNL:XXX:DRIFT pvs[40-59] = CHNL:XXX:TEMP ''' table = widget.getTable() color = ColorFontUtil.getColorFromRGB(240, 245, 245) number_of_channels = 20 temp_pv_index_offset = number_of_channels drift_pv_index_offset = number_of_channels*2 temp_value_column = 1 drift_value_column = 2 reading_value_column = 3 for i in range(number_of_channels): reading = PVUtil.getString(pvs[i]) temperature = PVUtil.getString(pvs[i + temp_pv_index_offset]) drift = PVUtil.getString(pvs[i + drift_pv_index_offset]) row = i+1 table.setCellText(row, temp_value_column, temperature) table.setCellText(row, drift_value_column, drift) table.setCellText(row, reading_value_column, reading) # Create colour scheme for table if row % 2 != 0: for col in range(0, 4): table.setCellBackground(row, col, color) if not pvs[i].isConnected(): table.setCellText(row, 1, "Disconnected")
from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.swt.widgets.figures.IntensityGraphFigure import IROIListener, IROIInfoProvider from org.csstudio.utility.pv import PVListener from java.lang import Thread, Runnable from org.eclipse.swt.widgets import Display roiXPV = pvs[1] roiYPV = pvs[2] roiWPV = pvs[3] roiHPV = pvs[4] intensityGraph = widget.getFigure() name = PVUtil.getString(pvs[0]) class MyROIInfoProvider(IROIInfoProvider): '''Provide custom information for ROI. ''' def getROIInfo(self, xIndex, yIndex, width, height): return name + "(" + str(xIndex) + ", " + str(yIndex) + " )" class MyROIListener(IROIListener): '''Listener on ROI updates. ''' def roiUpdated(self, xIndex, yIndex, width, height): roiXPV.setValue(xIndex) roiYPV.setValue(yIndex) roiWPV.setValue(width) roiHPV.setValue(height)
from org.csstudio.opibuilder.scriptUtil import PVUtil from org.eclipse.ui import PlatformUI selection_type = PVUtil.getString(pvs[0]).upper() title = selection_type + ' Selection' window = PlatformUI.getWorkbench().getActiveWorkbenchWindow() window.getShell().setText(title)
from org.csstudio.opibuilder.scriptUtil import PVUtil from org.eclipse.ui import PlatformUI magnet_type = PVUtil.getString(pvs[0]).capitalize() title = magnet_type + ' Power Supply' window = PlatformUI.getWorkbench().getActiveWorkbenchWindow() window.getShell().setText(title)
from org.csstudio.opibuilder.scriptUtil import PVUtil,WidgetUtil,ConsoleUtil nodefull = PVUtil.getString(pvArray[0]) #Full name of the node Eg. B_SYS_HV_ECAL_SEC1 bgcol = widget.getMacroValue("BGCOL") #BG color for button #Write this command as the tooltip, to make it available as a macro for the action (a fudge suggested in the CSS/Boy forum) widget.setPropertyValue("tooltip",nodefull) widget.setPropertyValue("background_color",bgcol)
#Warning - some danger of infinite recursion here. Careful" #The $(LCID) macro is used to make local PVs per instance. So several instances could be run from the same CSS #without interfering. #For example loc://$(LCID)_NODE pv is like this: B_SYS_HV_ECAL_SEC1_..... #split into list with elements 0 1 2 3 4 5 #eg - with N for the menu N = 3 * # # 3 clicked to set DC changes loc://$(LCID)_NODE pv to B_SYS_HV_DC n = int(widget.getMacroValue("N")) #Get N,TOP and NODE and MOUT_$(N) topnode=widget.getMacroValue("TOP") node = PVUtil.getString(pvArray[0]) sel = PVUtil.getString(pvArray[1]) nlist=node.split("_") #make a list of the parts of node nlist = (B,SYS,HV,ECAL,SEC1,....) #ConsoleUtil.writeInfo("Action:"+str(n)+", mode= "+node+", sel= "+sel) if not sel == 'select..': if n>=len(nlist) or ((n<len(nlist)) and (not sel==nlist[n])): newnode=topnode if n>=1: for e in range(1,n): newnode+="_"+nlist[e] newnode+="_"+sel pvArray[0].setValue(newnode)
from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.swt.widgets.figures.IntensityGraphFigure import IROIListener, IROIInfoProvider from org.csstudio.utility.pv import PVListener from java.lang import Thread, Runnable from org.eclipse.swt.widgets import Display roiXPV = pvs[1] roiYPV = pvs[2] roiWPV = pvs[3] roiHPV = pvs[4] intensityGraph = widget.getFigure() name = PVUtil.getString(pvs[0]) class MyROIInfoProvider(IROIInfoProvider): '''Provide custom information for ROI. ''' def getROIInfo(self, xIndex, yIndex, width, height): return name + "(" + str(xIndex) + ", " + str(yIndex) + " )" class MyROIListener(IROIListener): '''Listener on ROI updates. ''' def roiUpdated(self, xIndex, yIndex, width, height): roiXPV.setValue(xIndex) roiYPV.setValue(yIndex) roiWPV.setValue(width) roiHPV.setValue(height) currentDisplay = Display.getCurrent()
from org.csstudio.opibuilder.scriptUtil import PVUtil, WidgetUtil, ConsoleUtil nodefull = PVUtil.getString( pvArray[0]) #Full name of the node Eg. B_SYS_HV_ECAL_SEC1 bgcol = widget.getMacroValue("BGCOL") #BG color for button #Write this command as the tooltip, to make it available as a macro for the action (a fudge suggested in the CSS/Boy forum) widget.setPropertyValue("tooltip", nodefull) widget.setPropertyValue("background_color", bgcol)
from org.csstudio.opibuilder.scriptUtil import PVUtil,WidgetUtil,ConsoleUtil import fnmatch import nodeLoader import array import math nodeLoader.readTree() #Read in the node tree views=["B_SYS_HV","B_HW_HV"] #list of possible views topnode = str(widget.getMacroValue("TOP")) #Get the top node rangemode = str(widget.getMacroValue("SCALE")) #Get the scale for the (= Whole or Part) title = str(widget.getMacroValue("TITLE")) #Get the title node = PVUtil.getString(pvArray[0]) #Get the current node from local pv rangepv = PVUtil.getDoubleArray(pvArray[1]) if node.find(topnode) <0: #if the node doesn't contain topnode node = topnode #force to top #ConsoleUtil.writeInfo("Node = "+node+" Top = "+topnode) view=-1 #init index of view for n in range(len(views)): #find the vew for this node if node.find(views[n]) > -1: view=n if view > -1: #if it's a valid view widget.setPropertyValue("axis_1_auto_scale","true") if node in nodeLoader.NodeIndex: #check for node and get index #ConsoleUtil.writeInfo("Node = "+node+" Top = "+topnode) index = int(nodeLoader.NodeIndex[node]) erange = nodeLoader.ElementRange[index].strip("'")
from org.csstudio.opibuilder.scriptUtil import ConsoleUtil from org.csstudio.opibuilder.scriptUtil import PVUtil import WidgetUtil from org.eclipse.jface.dialogs import MessageDialog meas = PVUtil.getString(pvs[0]) temp = PVUtil.getString(pvs[1]) value = PVUtil.getString(pvs[2]) if meas=="" or temp =="" or value == "": MessageDialog.openWarning(None, "Warning", "At least one field is empty!") flag = 0 else: flag = 1 if flag ==1: StringToSend = meas+":"+temp+":"+value PVUtil.writePV("LLRF_USER:CavitySimulator:StringToSendTemp", StringToSend)
color = ColorFontUtil.WHITE if s == 0: color = ColorFontUtil.GREEN elif s == 1: color = ColorFontUtil.RED elif s == 2: color = ColorFontUtil.YELLOW elif s == 3: color = ColorFontUtil.PINK elif s == 4: color = ColorFontUtil.GREEN if "ellipse" == widgetType: widget.setPropertyValue("foreground_color", color) tooltip = PVUtil.getString(triggerPV) widget.setPropertyValue("tooltip", tooltip) if "IOM" in type: if ".SIMM" not in triggerPV.getName(): s = PVUtil.getSeverity(triggerPV) color = ColorFontUtil.WHITE if s == 0: color = ColorFontUtil.GREEN elif s == 1: color = ColorFontUtil.RED elif s == 2: color = ColorFontUtil.YELLOW elif s == 3: color = ColorFontUtil.PINK
"""from org.csstudio.opibuilder.scriptUtil import PVUtil from org.eclipse.ui import PlatformUI ## Define Window Title title = PVUtil.getString(pvArray[1]) ## Set Window Title window = PlatformUI.getWorkbench().getActiveWorkbenchWindow() window.getShell().setText(title)""" from org.csstudio.opibuilder.scriptUtil import PVUtil from org.eclipse.ui import PlatformUI selection_type = PVUtil.getString(pvs[0]).upper() title = selection_type + ' Selection' ## Define Window Title title = PVUtil.getString(pvArray[1]) ## Set Window Title window = PlatformUI.getWorkbench().getActiveWorkbenchWindow() window.getShell().setText(title)
#Fill PV Name only once if widget.getVar("firstTime") == None: widget.setVar("firstTime", True) i=0 for pv in pvs: table.setCellText(i, 0, pv.getName()) if not pv.isConnected(): table.setCellText(i, 1, "Disconnected") i+=1 #find index of the trigger PV i=0 while triggerPV != pvs[i]: i+=1 table.setCellText(i, 1, PVUtil.getString(triggerPV)) table.setCellText(i, 2, PVUtil.getTimeString(triggerPV)) table.setCellText(i, 3, PVUtil.getStatus(triggerPV)) table.setCellText(i, 4, PVUtil.getSeverityString(triggerPV)) s = PVUtil.getSeverity(triggerPV) color = ColorFontUtil.WHITE if s == 0: color = ColorFontUtil.GREEN elif s == 1: color = ColorFontUtil.RED elif s == 2: color = ColorFontUtil.YELLOW elif s == 3: color = ColorFontUtil.PINK
from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.opibuilder.scriptUtil import ColorFontUtil table = widget.getTable() nbColPVs=3 #find index of the trigger PV i=0 while triggerPV != pvs[i]: i+=1 table.setCellText(i/nbColPVs, i%nbColPVs +3, PVUtil.getString(triggerPV)) s = PVUtil.getSeverity(triggerPV) color = ColorFontUtil.WHITE if s == 0: color = ColorFontUtil.GREEN elif s == 1: color = ColorFontUtil.RED elif s == 2: color = ColorFontUtil.YELLOW elif s == 3: color = ColorFontUtil.PINK table.setCellBackground(i/nbColPVs, i%nbColPVs + 3, color)
from org.csstudio.opibuilder.scriptUtil import PVUtil op1=PVUtil.getDouble(pvs[0]) op2=PVUtil.getDouble(pvs[1]) operator = PVUtil.getString(pvs[2]) resultPV=pvs[3] if operator=="+": resultPV.setValue(op1 + op2) elif operator=="-": resultPV.setValue(op1 - op2) elif operator=="*": resultPV.setValue(op1 * op2) elif operator=="/": resultPV.setValue(op1 / op2)
from org.csstudio.opibuilder.scriptUtil import PVUtil,WidgetUtil,ConsoleUtil import fnmatch import nodeLoader import array import math nodeLoader.readTree() #Read in the node tree views=["B_SYS_HV"] #list of possible views topnode = str(widget.getMacroValue("TOP")) #Get the top node rangemode = str(widget.getMacroValue("SCALE")) #Get the scale for the (= Whole or Part) title = str(widget.getMacroValue("TITLE")) #Get the title node = PVUtil.getString(pvArray[0]) #Get the current node from local pv rangepv = PVUtil.getDoubleArray(pvArray[1]) if node.find(topnode) <0: #if the node doesn't contain topnode node = topnode #force to top #ConsoleUtil.writeInfo("Node = "+node+" Top = "+topnode) view=-1 #init index of view for n in range(len(views)): #find the vew for this node if node.find(views[n]) > -1: view=n if view > -1: #if it's a valid view widget.setPropertyValue("axis_1_auto_scale","true") if node in nodeLoader.NodeIndex: #check for node and get index #ConsoleUtil.writeInfo("Node = "+node+" Top = "+topnode) index = int(nodeLoader.NodeIndex[node]) erange = nodeLoader.ElementRange[index].strip("'")
from org.csstudio.opibuilder.scriptUtil import PVUtil, WidgetUtil, ConsoleUtil import fnmatch import nodeLoader from java.util import Arrays nodeLoader.readTree() #Read in the node tree topnode = widget.getMacroValue("TOP") #Get the top node nodesearch = PVUtil.getString(pvArray[0]) #Get the search string if nodesearch.find(topnode) < 0: #if the search doesn't contain topnode nodesearch = topnode + "*" #force to top + wildcard if nodesearch in nodeLoader.NodeIndex: #if it's a node, tag a wildcard on the end nodesearch = nodesearch + "*" nlist = fnmatch.filter(nodeLoader.NodeNames, nodesearch) #filter on the node search if (len(nlist) >= 1): nlist.sort() #make a sorted list of them else: nlist = ["None"] widget.setPropertyValue("items", Arrays.asList(nlist)) #set the choice list widget.setPropertyValue("pv_value", nlist[0]) #set selected as first in the list
from org.csstudio.opibuilder.scriptUtil import PVUtil text = PVUtil.getString(pvs[0]) logText = widget.getPropertyValue("text") if text == 'StandBy...': logText = text else: logText = logText + '\n' + text widget.setPropertyValue("text", logText)
from org.csstudio.opibuilder.scriptUtil import PVUtil, WidgetUtil, ConsoleUtil slotlist = PVUtil.getString(pvArray[0]) #P should be the Crate. eg B_DET_MM_FEU_Cr1 P = widget.getMacroValue("P") C = widget.getMacroValue("CRATE") slots = slotlist.split() #ConsoleUtil.writeInfo(str(slots)) for n in range(0, len(slots)): linkingContainer = WidgetUtil.createWidgetModel( "org.csstudio.opibuilder.widgets.linkingContainer") linkingContainer.setPropertyValue("opi_file", "slot_full.opi") newP = P + "_Cr" + C + "_Sl" + slots[n] #ConsoleUtil.writeInfo(newP) linkingContainer.addMacro("P", newP) linkingContainer.setPropertyValue("width", 862) linkingContainer.setPropertyValue("height", 20) linkingContainer.setPropertyValue("resize_behaviour", 2) #linkingContainer.setPropertyValue("border_style", 2) widget.addChildToBottom(linkingContainer)
from org.csstudio.opibuilder.scriptUtil import PVUtil import os save_load_configs_pv = widget.getPVByName("loc://save_load_configs") save_load_option = PVUtil.getString(save_load_configs_pv) message = "" print save_load_option if save_load_option == "Save voltage configuration": filepath_pv = display.getWidget("save_load_configs_filepath").getPV() filepath = PVUtil.getString(filepath_pv) filename_pv = display.getWidget("save_load_configs_filename").getPV() filename = PVUtil.getString(filename_pv) if filename=="" or filepath == "": message = 'Please choose directory and/ or filename first.' else: message = "" file = filepath + "/" + filename f= open(file, "w")
#loc://$(LCID)_NODE (pv[0]) change, triggering nodeMenuUpdate.py for all buttons. #Warning - some danger of infinite recursion here. Careful" #The $(LCID) macro is used to make local PVs per instance. So several instances could be run from the same CSS #without interfering. #For example loc://$(LCID)_NODE pv is like this: B_SYS_HV_ECAL_SEC1_..... #split into list with elements 0 1 2 3 4 5 #eg - with N for the menu N = 3 * # nodeLoader.readTree() #Read in the node tree n = int(widget.getMacroValue("N")) #Get N,B and NODE topnode = widget.getMacroValue("TOP") node = PVUtil.getString(pvArray[0]) if not node in nodeLoader.NodeIndex: # check node defined, or force to top node node = topnode nlist = node.split( "_") #make a list of the parts of node nlist = (B,SYS,HV,ECAL,SEC1,....) #widget.setPropertyValue("height",24 ) #and size #widget.setPropertyValue("visible","false") #assume invisible until other decision made widget.setPropertyValue("enabled", "false") #assume invisible until other decision made widget.setPropertyValue( "background_color", "OPI_Background") #assume invisible until other decision made
from org.csstudio.opibuilder.scriptUtil import PVUtil, WidgetUtil, DataUtil def add_header(table, header_opi): linkingContainer = WidgetUtil.createWidgetModel("org.csstudio.opibuilder.widgets.linkingContainer") linkingContainer.setPropertyValue("opi_file", header_opi) linkingContainer.setPropertyValue("resize_behaviour", 1) linkingContainer.setPropertyValue("border_style", 0) table.addChildToBottom(linkingContainer) feature_type = PVUtil.getString(pvs[0]).lower() if feature_type == 'bpm_selection': left_header_opi = "table/selection_table_bpm.opi" elif feature_type == 'ch_selection': left_header_opi = "table/selection_table_ch.opi" elif feature_type == 'cv_selection': left_header_opi = "table/selection_table_cv.opi" up_header_opi = "table/selection_table_up_header.opi" low_header_opi = "table/selection_table_low_header.opi" table_container = display.getWidget("table_container") if feature_type is None: table_container.setPropertyValue("visible", False) else: add_header(table_container, up_header_opi) add_header(table_container, left_header_opi) add_header(table_container, low_header_opi)
from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.opibuilder.scriptUtil import ColorFontUtil table = widget.getTable() nbColPVs = 2 #find index of the trigger PV i = 0 while triggerPV != pvs[i]: i += 1 s = PVUtil.getSeverity(triggerPV) color = ColorFontUtil.WHITE if s == 0: color = ColorFontUtil.GREEN elif s == 1: color = ColorFontUtil.RED elif s == 2: color = ColorFontUtil.YELLOW elif s == 3: color = ColorFontUtil.PINK elif s == 4: color = ColorFontUtil.GREEN # table.setCellBackground(i/nbColPVs, i%nbColPVs + 3, color) if "-CUBHLTS" in triggerPV.getName(): table.setCellText(i / nbColPVs, 3, PVUtil.getString(triggerPV)) table.setCellBackground(i / nbColPVs, 3, color) if "-PLCHLTS" in triggerPV.getName(): table.setCellText(i / nbColPVs, 4, PVUtil.getString(triggerPV)) table.setCellBackground(i / nbColPVs, 4, color)
from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.opibuilder.scriptUtil import ConsoleUtil pv0 = PVUtil.getString(pvs[0]); widget.setPropertyValue("tooltip", pv0);
from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.opibuilder.scriptUtil import DataUtil macroInput = DataUtil.createMacrosInput(True) boxpv = display.getWidget("monitor_box_container").getPVByName( "loc://monitor_box") channelpv = widget.getPVByName("loc://monitor_channel(\"\")") boxnumber = PVUtil.getLong(boxpv) channel = PVUtil.getString(channelpv) #macroInput.put("BOXNO", "%s" % boxnumber) macroInput.put("BOX", "BOX:%s" % boxnumber) macroInput.put("CHANNEL", "%s" % channel) #macroInput.put("P", "CB:CB:HV") widgetController.setPropertyValue("macros", macroInput) widgetController.setPropertyValue( "opi_file", widgetController.getPropertyValue("opi_file"), True)
from org.csstudio.opibuilder.scriptUtil import PVUtil,WidgetUtil,ConsoleUtil hvstr = PVUtil.getString(pvArray[0]) hvinfo = hvstr.split(",") hv = hvinfo[3] board = hvinfo[4] half = hvinfo[5] chstr = PVUtil.getString(pvArray[1]) chlist = chstr.split(",") nchan = len(chlist) ch2 = PVUtil.getString(pvArray[2]) ConsoleUtil.writeInfo("pv0=" + hvstr) ConsoleUtil.writeInfo("pv1=" + chstr) ConsoleUtil.writeInfo("pv2=" + ch2) #ConsoleUtil.writeInfo(str(xcoords[5])) for n in range(0,nchan): ConsoleUtil.writeInfo("Chann" + str(n)); linkingContainer = WidgetUtil.createWidgetModel("org.csstudio.opibuilder.widgets.linkingContainer") linkingContainer.setPropertyValue("opi_file", "chan1.opi") linkingContainer.addMacro("ID", chlist[n]) linkingContainer.setPropertyValue("resize_behaviour", 1) linkingContainer.setPropertyValue("border_style", 0) widget.addChildToBottom(linkingContainer) linkingContainer = WidgetUtil.createWidgetModel("org.csstudio.opibuilder.widgets.linkingContainer")
from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.opibuilder.scriptUtil import ColorFontUtil table = widget.getTable() nbColPVs = 2 #find index of the trigger PV i = 0 while triggerPV != pvs[i]: i += 1 table.setCellText(i / nbColPVs, i % nbColPVs + 3, PVUtil.getString(triggerPV)) s = PVUtil.getSeverity(triggerPV) color = ColorFontUtil.WHITE if s == 0: color = ColorFontUtil.GREEN elif s == 1: color = ColorFontUtil.RED elif s == 2: color = ColorFontUtil.YELLOW elif s == 3: color = ColorFontUtil.PINK table.setCellBackground(i / nbColPVs, i % nbColPVs + 3, color)
from org.csstudio.opibuilder.scriptUtil import PVUtil,WidgetUtil,ConsoleUtil #select next or previous sibling in nodelist combo = display.getWidget("Node_Selector_Combo") nodelist = combo.getPropertyValue("items") listlen = len(nodelist) nodefull = PVUtil.getString(pvArray[1]) inc = int(PVUtil.getLong(pvArray[0])) index = nodelist.index(nodefull) nodelen = len(nodefull.split("_")) #ConsoleUtil.writeInfo(nodefull + " inc " + str(inc)+ " index " + str(index) + " len " + str(listlen)) if not inc == 0: index += inc if (index >=0) and (index < listlen): node = nodelist[index] if len(node.split("_")) == nodelen: combo.setPropertyValue("pv_value",node ) pvArray[1].setValue(node) pvArray[0].setValue("0")