# Script executed by jython

# Can import any Java package
from org.csstudio.display.builder.runtime.script import PVUtil

# Can also import some python code that's available under Jython
import sys, time


trigger = PVUtil.getInt(pvs[0])
if trigger:
    info = "%s,\ninvoked at %s" % (sys.version, time.strftime("%Y-%m-%d %H:%M:%S"))
    widget.setPropertyValue("text", info)
Exemple #2
0
from org.csstudio.display.builder.runtime.script import PVUtil, ScriptUtil
from java.util.concurrent import TimeUnit
from java.lang import Throwable

max_duration = 5
play = PVUtil.getInt(pvs[0])
if play:
    widget.setPropertyValue("text", "Playing audio..")
    # Start playing audio
    audio = ScriptUtil.playAudio(widget, "timer.wav")
    try:
        # Could wait until end of playback with
        #   audio.get()
        # In this example, using a timeout to limit the playback
        audio.get(max_duration, TimeUnit.SECONDS)
        # Without timeout, we're done
        widget.setPropertyValue("text", "Done")
    except Throwable, ex:
        # In case of timeout, we cancel the player
        print(str(ex))
        widget.setPropertyValue("text", "Cancelling")
        audio.cancel(True)
# else: Called with play=0, so don't do anything
    
print("Script done")

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

doit = PVUtil.getInt(pvs[0])
if doit:
    print "Loading other display.."
    ScriptUtil.openDisplay(widget, "other.bob", "REPLACE", None)
    pvs[0].write(0)
Exemple #5
0
# Script executed by jython

# Can import any Java package
from org.csstudio.display.builder.runtime.script import PVUtil

# Can also import some python code that's available under Jython
import sys, time

trigger = PVUtil.getInt(pvs[0])
if trigger:
    info = "%s,\ninvoked at %s" % (sys.version,
                                   time.strftime("%Y-%m-%d %H:%M:%S"))
    widget.setPropertyValue("text", info)
Exemple #6
0
# pvs[0]: initial trigger
# pvs[1]: Re-fetch?
# import sys
# print("Search path:\n" + "\n".join(sys.path))

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

if PVUtil.getInt(pvs[1]):
    message = "Re-fetching logbook entries"
else:
    message = "Fetching Logbook entries..."

widget.setValue([["-", message]])

from my_service import read_html, create_table

html = read_html()
widget.setValue(create_table(html))
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
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)
Exemple #9
0
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:
Exemple #10
0
def readMap(map, map_pvs):
    for row in range(len(map)):
        for col in range(len(map[row])):
            map[row][col] = PVUtil.getInt(map_pvs[row][col])