For complex dynamic behaviors which cannot be obtained from rules,you can attach one or more scripts to widgets or OPI. The script grammar is JavaScript, but more than plain javascript, you can set PVs as input and change properties of widgets in the script. The script execution is triggered by input PVs. That means the change of PV value will trigger the execution of script. In script, the value or severity of the input PVs are accessible.
Besides, all Java APIs are accessible in script by importing the package of java.lang.
There are lots of free JavaScript Tutorial available from Internet, for example w3schools JS Tutorial. You only need to read the JavaScript grammar part. The other parts are not appliable in BOY.
Please notice that the JavaScript in BOY is not executed in an environment of browser, so the
objects such as document
and methods such as alert()
, confirm()
are not available here, but the JavaScript Objects such as Date
, Array
,
Math
are still available. This is an example showing the current datetime on a Label widget.
widgetController.setPropertyValue("text", new Date().toString());