|
<< Click to Display Table of Contents >> Simple multiple color change with scripts |
![]() ![]()
|
If you need to change the color depending on several tags, you need to use scripts. For example, you have a Motor object that has 2 parameters - State and Speed, and you want to use fill color depending on the State and Speed values:
State |
Speed |
Fill color |
|---|---|---|
0 |
Any |
RED |
1 |
0...500 |
GREEN |
1 |
500...1000 |
YELLOW |
1 |
>1000 |
BLUE |
1. Create tags: Speed (set the data type - Short(16bit), initial PV - 0) and State (set the data type - Byte(8bit), initial PV - 0):

2. Let’s create a graphical object - Motor for our example:

3. Create a script with the name stMotorFill, type - Object and execution type - OnDataChange:

4. Let's write the script::

After you have recorded the script, be sure to launch it by clicking the button on the toolbar: ![]()
5. Now let’s bind the script to our Motor object, go to the object’s properties (General tab) and add our script to the “Scripts” field:
|
|
6. Let's Run simulation to check the settings:

You can download this project here.