For complex dynamic behaviors which cannot be achieved by rules, you can attach one or more scripts to widget or display to get desired behaviors. The script can be either JavaScript or Python script. For both scripts, they accept PVs as inputs and their execution are triggered by the value change event of input trigger PVs. That means the change of PV value or timestamp will trigger the execution of script. In script, the value, timestamp or severity of the input PVs are accessible, see Access PV. The widget and display are also accessible in script, see Access Widget.
For both JavaScript and Python script, it is allowed to call Java code inside by importing corresponding packages. For example:
JavaScript Example:
importPackage(Packages.org.eclipse.jface.dialogs); MessageDialog.openInformation( null, "Dialog from JavaScript", "This is a dialog opened from JavaScript")
Python script Example:
from org.eclipse.jface.dialogs import MessageDialog MessageDialog.openInformation( None, "Dialog from Python", "This is a dialog opened from Python")
As we see, the code that is calling Java code in JavaScript and Python are very similar. So most script examples in this help document are in JavaScript, but it should be easy for you to translate them to Python. For example, here are two code snippets written in JavaScript and Python respectively. They are totally same in functionality.
JavaScript Example:
importPackage(Packages.org.csstudio.opibuilder.scriptUtil); var value = PVUtil.getDouble(pvs[0]); var RED = ColorFontUtil.RED; widget.setPropertyValue("start_angle", value); widget.setPropertyValue("foreground_color", RED);
Python script Example:
from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.opibuilder.scriptUtil import ColorFontUtil value = PVUtil.getDouble(pvs[0]) RED = ColorFontUtil.RED widget.setPropertyValue("start_angle", value) widget.setPropertyValue("foreground_color", RED)