def clearConflictsDisplay(): if PVUtil.getDouble(pvs[1]) != 0: return for row in range(9): for col in range(9): cell = getWidget(row, col) pv = pvs[calcPVIndex(row, col)] if PVUtil.getString(pv) == "#": pv.write(" ") cell.setPropertyValue("foreground_color", text)
def findConflicts(row, col, value): conflicts = [] if value == " " or value == "_": return conflicts for currCol in range(9): if currCol != col and \ value == PVUtil.getString(pvs[calcPVIndex(row,currCol)]): conflicts.append((row, currCol)) for currRow in range(9): if currRow != row and \ value == PVUtil.getString(pvs[calcPVIndex(currRow,col)]): conflicts.append((currRow, col)) for currRow in calcBlockRange(row): for currCol in calcBlockRange(col): if currRow != row and \ currCol != col and \ value == PVUtil.getString(pvs[calcPVIndex(currRow,currCol)]): conflicts.append((currRow, currCol)) if len(conflicts) > 0: conflicts.append((row, col)) return conflicts
from org.csstudio.display.builder.runtime.script import PVUtil, ScriptUtil # Which trace parm is this for? #trace_parm = "trace_0_visible" trace_parm = PVUtil.getString(pvs[1]) # Locate graph widget in the display based on name graph_widget = widget.getDisplayModel().runtimeChildren().getChildByName( "time-history") if PVUtil.getLong(pvs[0]) == 1: state = True else: state = False graph_widget.setPropertyValue(trace_parm, state)
# For Phoebus, disable widgets that have not been implemented # pvs[0] - widget type to check from org.csstudio.display.builder.runtime.script import ScriptUtil, PVUtil if 'PHOEBUS' in dir(ScriptUtil): from org.csstudio.display.builder.representation.javafx.widgets import BaseWidgetRepresentations type = PVUtil.getString(pvs[0]) supported = False for t in BaseWidgetRepresentations().getWidgetRepresentationFactories(): if t.getType() == type: supported = True break if not supported: print("Disable " + type) widget.setPropertyValue("visible", False)
# Set color map from org.csstudio.display.builder.runtime.script import PVUtil, ScriptUtil from org.csstudio.display.builder.model.properties import PredefinedColorMaps mapname = PVUtil.getString(pvs[0]) colormap = None # Initial Display Builder used ColorMap.PREDEFINED .. for map in PredefinedColorMaps.PREDEFINED: if mapname == map.getName(): colormap = map break if colormap is None: ScriptUtil.getLogger().warning("Unknown color map " + mapname) else: widget.setPropertyValue("color_map", colormap)
from org.csstudio.display.builder.runtime.script import PVUtil, ConsoleUtil cameras = PVUtil.getStringArray(pvs[0]) timeout = 2000 if PVUtil.getString(pvs[1]) == "Fine": pvToWrite = ":SET_ROI_VIEW.PROC" else: pvToWrite = ":SET_FULL_CHIP.PROC" [PVUtil.writePV(cam + pvToWrite, 1, timeout) for cam in cameras]
def showInfo(text): w = display.runtimeChildren().getChildByName("info") w.setPropertyValue("text", str(text)) t3 = display.getUserData("T3") if t3 is None: # Initialize new board t3 = T3() display.setUserData("T3", t3) showBoard(t3) else: # User entered a move pos = int(PVUtil.getString(pvs[0])) if not (0 <= pos < 9): showInfo("Field must be 0 .. 8") elif t3.board[pos] != ' ': showInfo("Field %d already occupied!" % pos) else: # Perform user's move t3.board[pos] = 'x' showBoard(t3) # Compute computer's move test = T3(t3.board) pos = test.makeMove('o') if pos is not None: showInfo("I set " + str(pos)) t3.board[pos] = 'o'
# Set color map from org.csstudio.display.builder.runtime.script import PVUtil, ScriptUtil from org.csstudio.display.builder.model.properties import PredefinedColorMaps mapname = PVUtil.getString(pvs[0]).upper() colormap = None # Initial Display Builder used ColorMap.PREDEFINED .. for m in PredefinedColorMaps.PREDEFINED: if mapname == m.getName(): colormap = m break if colormap is None: ScriptUtil.getLogger().warning("Unknown color map " + mapname) else: widget.setPropertyValue("color_map", colormap)
from org.csstudio.display.builder.runtime.script import PVUtil import time run = PVUtil.getInt(pvs[0]) max_time = PVUtil.getString(pvs[1]) indicator = pvs[2] def format(secs): """Format seconds as 'MM:SS' """ sec = int(secs) min = sec / 60 sec -= min*60 return "%02d:%02d" % (min, sec) if run: # Expecting "MM:SS" as runtime total = float(max_time[0:2])*60 + float(max_time[3:5]) end = time.time() + total now = time.time() while run and now < end: secs = end - now fraction = secs/total widget.setPropertyValue("total_angle", 360.0*fraction) if fraction < 0.25: color = [ 255, 0, 0 ] elif fraction < 0.4: color = [ 255, 255, 0 ] else: color = [ 0, 255, 0 ] widget.setPropertyValue("background_color", color)
""" Input: pvs[0] - PV name to use """ from org.csstudio.display.builder.runtime.script import PVUtil value = PVUtil.getString(pvs[0]); # print "update_pv_name.py: Name is %s" % value widget.setPropertyValue("pv_name", value)
to the PV named in the widget called 'pv_name' """ from org.csstudio.display.builder.runtime.script import PVUtil, ScriptUtil logger = ScriptUtil.getLogger() # Locate other widgets in the display based on their name children = widget.getDisplayModel().runtimeChildren() name_widget = children.getChildByName("pv_name") value_widget = children.getChildByName("pv_value") # Get the current value of those widgets logger.info("Name widget " + str(name_widget)) logger.info("Value widget " + str(value_widget)) name_pv = ScriptUtil.getPrimaryPV(name_widget) value_pv = ScriptUtil.getPrimaryPV(value_widget) name = PVUtil.getString(name_pv) value = PVUtil.getString(value_pv) logger.info("Need to set " + name + " = " + value) # Locate one of the target widgets based on their name target_widget_name = name.replace("loc://", "") target_widget = children.getChildByName(target_widget_name) logger.info("Widget named " + target_widget_name + ": " + str(target_widget)) # Write to the PV of the target widget pv = ScriptUtil.getPrimaryPV(target_widget) pv.write(value)
from org.csstudio.display.builder.runtime.script import PVUtil import time run = PVUtil.getInt(pvs[0]) max_time = PVUtil.getString(pvs[1]) indicator = pvs[2] def format(secs): """Format seconds as 'MM:SS' """ sec = int(secs) min = sec / 60 sec -= min * 60 return "%02d:%02d" % (min, sec) if run: # Expecting "MM:SS" as runtime total = float(max_time[0:2]) * 60 + float(max_time[3:5]) end = time.time() + total now = time.time() while run and now < end: secs = end - now fraction = secs / total widget.setPropertyValue("total_angle", 360.0 * fraction) if fraction < 0.25: color = [255, 0, 0] elif fraction < 0.4: color = [255, 255, 0] else:
def clearConflictsDisplay(): if PVUtil.getDouble(pvs[1]) != 0: return for row in range(9): for col in range(9): cell = getWidget(row, col) pv = pvs[calcPVIndex(row, col)] if PVUtil.getString(pv) == "#": pv.write(" ") cell.setPropertyValue("foreground_color", text) #logger.warning("finished clearing conflicts") selected = int(widget.getPropertyValue("name")[4:]) value = PVUtil.getString(pvs[0]) #logger.warning("*Entry for %d" % selected) if value != "#" and PVUtil.getDouble(pvs[1]) != -1: col = selected % 10 row = (selected - col) / 10 if value != " ": clearConflictsDisplay() conflicts = findConflicts(row, col, value) if value == "_": pvs[0].write(" ") elif len(conflicts) > 0: pvs[0].write("#") #logger.warning("conflicted (%d,%d)" % (row, col)) for pos in conflicts: cell = getWidget(pos[0], pos[1]) cell.setPropertyValue(