Attaching Rules to Widgets

To obtain customized dynamic hehaviors than just setting from properties sheet, you can attach rules or scripts to widgets or OPI. With rules, you can make widget properties dynamically changeable without any programming. Widget property value will change along with the boolean expression status or input PV value. The execution of a rule is triggered by its input PV(s), so at least one trigger PV is needed for a rule.

To have more complex dynamic behaviors if rules cannot achieve, you will need to attach scripts to the widget or OPI. Diffrent with script, rules is part of the OPI file, so no additional file is needed.

Steps to attach rules to a widget:

  1. Select Rules property in property sheet view. You will see "Attache Rules" dialog.

    Attach Rules

  2. In Attach Rules Dialog, you can add more than one rule. When you add a rule or double click a rule, a rule edit dialog will pop out. In which,

    Rule edit dialog

Boolean Expression

The Boolean Expression is javascript boolean expression, so all javascript operators are applicable here. Besides, all input PVs of the rule are also accessible in the expression.

Output Expression

Besides outputing a constant value to the property based on the boolean expression value, you can also output an expression value to the property. For example, if you want make the String value of a PV as the URL of a web browser widget, you can set the output expression to pvStr0. If you want to skip the boolean expression, simply set boolean expression to true.

Output Expression