Skip to content

RulesEditorBoxDesign

berryma4 edited this page Jun 20, 2013 · 3 revisions

Design for a Rules Editor Box

Scope

Four different rule set properties have been identified for use with BOY widgets:

  • Visibility Rules
  • Color Rules
  • Enable Rules
  • Linked Container Rules

I think effort can be minimized and BOY usability maximized by creating a generic rules editor box that can be used for all these cases.

Graphical Appearance

From a user perspective, I would like to see such a box like this: Right hand side: Input PVs selector.

Similar to the right hand side of the "Attach Scripts" box. Each PV gets assigned an uppercase letter. Left hand side: Rules selector.

Top: "Default Value: " <value_selector>

Then a table similar to the right hand side (with "Add", "Remove", "Up", "Down" buttons).

Left column: "Expression" (text field), right column "Value" (<value_selector>).

Each expression is a Java expression, the uppercase letters of the PVs can be used as variables. The value will be used if the expression is true. Bottom: Save/Load/Edit'' - ''OK/Cancel

Save/Load/Edit buttons to enable file based rules.

"Save" saves to a file, then makes the tables read/only (greyed out). In this state the rules file will be used for this widget.

"Edit" removes the link to the rules file (thus making the rules local), and activates the rules tables for editing.

"Load" reads in a rules file, leaving the tables read/only.

OK/Cancel are obvious. <value_selector>:

Whatever is necessary to select a value for the property.

Color: Color field with a button to open the color picker.

Visibility, Enable: Check box.

Linked Container opi selection: File name plus browse button that opens a file picker.

Runtime Behavior

The lines are evaluated in order, the first match gets executed and the value configured with it is set.

(So that the table works like a large if'' - ''else if'' - ''else if - ... block.)

Implementation Idea

The rules are stored within the panel (for local rules) or in the rules file as data (XML).

When the panel is opened, the rules data is used to create a Javascript on-the-fly. The script is attached to the widget and executed using the existing methods.

Advantages:

  • Development-safe: Javascript always matches widget code, as it is generated by the widget on-the-fly
  • Named (site-wide) rules files are possible, but not mandatory
  • Easy conversion from existing medm/dm2k/edm panels' visibility, enable and color rules
Clone this wiki locally