- Overview
- Display Builder
- Display Runner
- Processed Variables
- Widgets
- Actions
- Borders
- Rules
- Scripts
- Macros
- Tuning
Yamcs Studio Release Notes
Source Code Documentation
Rules¶
Widgets have many static properties. With rules we can modify these properties dynamically, for example based on the incoming value updates of a Parameter PV.
Rules are simpler to create than Scripts, but offer only a subset of dynamic functionality. In fact, under the hood rules are automatically converted to a script.
Assume that want to make an LED square when it is off, and round when it is on. The static properties would not allow for such behaviour, so we add a rule.
Click the Rules property fo the LED to pop up this dialog.
Click the plus icon, which opens this dialog:
First choose the rule’s target Property. Select Square LED.
In the right Input PVs table add your input PV. In this example we choose to generate an alternating 0/1 value using a simulated PV. Notice the sequential number in the
#
column. The first PV is numbered0
. Make sure to check theTrigger
checkbox as this will then trigger the execution of the rule whenever the PV’s value is updated.In the Expressions table, fill in the conditions in the Boolean Expression column, and add the matching value of the rule’s property in the Output Value column. The double value of the top-most right PV is available as the variable
pv0
. The next PV in the list (if applicable) is available as the variablepv1
, etc.Confirm all dialogs, save your display and refresh a runtime view of it. You should see the LED’s shape now alternating between square and round.
Boolean Expression
This input field needs to be expressed in JavaScript. The Input PVs are available in different formats:
Type |
Example |
---|---|
Double Value |
|
String Value |
|
Integer Value |
|
The numeric alarm state of an input PV is is accessible as follows:
Alarm |
Example |
---|---|
Invalid |
|
No Alarm |
|
Minor Alarm |
|
Major Alarm |
|
Note
If you wish to set a property value that always applies, use true
(or 1==1
) as the Boolean Expression.
Output Value
The exact form that the Output Value column adopts depends on the type of the property. Some properties are colors, so you would see a color picker, other properties expect text, and the above example was a boolean yes/no, so we got a checkbox.