Exemple #1
0
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)
from org.csstudio.display.builder.runtime.script import PVUtil, ScriptUtil

secs = PVUtil.getDouble(pvs[0])
max_time = PVUtil.getDouble(pvs[1])
sound = PVUtil.getInt(pvs[2]) > 0

def startSound():
    global audio
    if not 'audio' in globals()  or  audio is None:
        print("Play Sound")
        audio = ScriptUtil.playAudio(widget, "timer.mp3")
    
def stopSound():
    global audio
    if 'audio' in globals()  and  audio is not None:
        print("End Sound")
        audio.cancel(True)
        audio = None
 
fraction = secs/max_time
widget.setPropertyValue("total_angle", 360.0*fraction)

if fraction < 0.25:
    color = [ 255, 0, 0 ]
    play = True
elif fraction < 0.4:
    color = [ 255, 255, 0 ]
    play = False
else:
    color = [ 0, 255, 0 ]
    play = False
# only the package name differs.
# 
#   from org.csstudio.opibuilder.scriptUtil import PVUtil
#
# needs to change into
#
#   from org.csstudio.display.builder.runtime.script import PVUtil
#
# This specific package name is actually patched by the
# display builder, so this script, attached to a Label,
# will simply 'run', issuing a warning that the package
# name has been patched:
#
#   from org.csstudio.opibuilder.scriptUtil import PVUtil
#   widget.setPropertyValue("text", "Hello")

# To write a portable script, check for the display builder's widget type:
display_builder = 'getVersion' in dir(widget)

if display_builder:
    from org.csstudio.display.builder.runtime.script import PVUtil, ScriptUtil
    ScriptUtil.getLogger().info("Executing in display builder")
else:
    from org.csstudio.opibuilder.scriptUtil import PVUtil, ConsoleUtil
    ConsoleUtil.writeInfo("Executing in BOY")

# This API is now the same:
val = PVUtil.getDouble(pvs[0])
widget.setPropertyValue("text", "Value is %.3f" % val)

"""
Sudoku board creator.

@author Amanda Carpenter
"""

from org.csstudio.display.builder.runtime.script import PVUtil, ScriptUtil

logger = ScriptUtil.getLogger()

logger.info("Loading sudoku.py")

pvVal = int(PVUtil.getDouble(pvs[0]))
if pvVal == -1:
    board = [
        [0, 1, 2, 0, 4, 5, 6, 7, 8],
        [1, 2, 3, 0, 5, 6, 7, 8, 0],
        [2, 3, 4, 0, 6, 7, 8, 0, 1],
        [3, 4, 5, 0, 7, 8, 0, 1, 2],
        [4, 5, 6, 0, 8, 0, 1, 2, 3],
        [5, 6, 7, 0, 0, 1, 2, 3, 4],
        [6, 7, 8, 0, 1, 2, 3, 4, 5],
        [7, 8, 0, 0, 2, 3, 4, 5, 6],
        [8, 0, 1, 0, 3, 4, 5, 6, 7],
    ]

elif pvVal == 3:
    board = [
        [0, 2, 0, 0, 0, 4, 3, 0, 0],
        [9, 0, 0, 0, 2, 0, 0, 0, 8],
        [0, 0, 0, 6, 0, 9, 0, 5, 0],
""" Input:
    pvs[0] - Value around -5 .. 5
"""
from org.csstudio.display.builder.runtime.script import PVUtil

value = PVUtil.getDouble(pvs[0]);
if value >= 0:
    widget.setPropertyValue("text", "Positive")
else:
    widget.setPropertyValue("text", "Negative")

""" Input:
    pvs[0] - Value around -5 .. 5
    pvs[1] - Default value for X
    pvs[2] - Scaling factor
"""
from org.csstudio.display.builder.runtime.script import PVUtil

value = PVUtil.getDouble(pvs[0])
x0 = PVUtil.getDouble(pvs[1])
scale = PVUtil.getDouble(pvs[2])
widget.setPropertyValue("x", x0 + scale * value)
Exemple #7
0
from org.csstudio.display.builder.runtime.script import PVUtil, ScriptUtil

secs = PVUtil.getDouble(pvs[0])
max_time = PVUtil.getDouble(pvs[1])
sound = PVUtil.getInt(pvs[2]) > 0


def startSound():
    global audio
    if not 'audio' in globals() or audio is None:
        print("Play Sound")
        audio = ScriptUtil.playAudio(widget, "timer.mp3")


def stopSound():
    global audio
    if 'audio' in globals() and audio is not None:
        print("End Sound")
        audio.cancel(True)
        audio = None


fraction = secs / max_time
widget.setPropertyValue("total_angle", 360.0 * fraction)

if fraction < 0.25:
    color = [255, 0, 0]
    play = True
elif fraction < 0.4:
    color = [255, 255, 0]
    play = False
Exemple #8
0
from org.csstudio.display.builder.runtime.script import PVUtil
from org.csstudio.display.builder.model.properties import WidgetColor

pid_out = PVUtil.getDouble(pvs[0])
sine = PVUtil.getDouble(pvs[1])

if pid_out > 600:
    text = "Giving it all ..."
    color = WidgetColor(255, 0, 255)  # PINK
elif pid_out > 400:
    text = "Heating a lot ..."
    color = WidgetColor(180, 50, 255)  # PURPLE
elif pid_out > 200:
    text = "Heating some ..."
    color = WidgetColor(255, 50, 50)  # RED
elif pid_out > 100:
    text = "Warming up ..."
    color = WidgetColor(255, 155, 50)  # ORANGE
elif pid_out > 0:
    text = "Keeping warm ..."
    color = WidgetColor(255, 255, 50)  # YELLOW
elif pid_out < 0:
    text = "Cooling down ..."
    color = WidgetColor(200, 200, 255)  # LIGHT_BLUE
else:
    text = "Temperature is just right"
    color = WidgetColor(0, 255, 0)  # GREEN

widget.setPropertyValue("text", text)
widget.setPropertyValue("background_color", color)
widget.setPropertyValue("x", 440 + sine)
Exemple #9
0
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(
                "foreground_color",
                WidgetColorService.getColor(NamedWidgetColors.ALARM_MAJOR))