Common multiple color change with scripts

<< Click to Display Table of Contents >>

Navigation:  Examples > Change the color of an object >

Common multiple color change with scripts

Previous pageReturn to chapter overviewNext page

If you have to change color depending on several tags you need to use scripts. For example you have 2 tags for every Pump object - State and Speed:

commonmultiplewithscripts

Depending on tag's values for every Pump object use fill color:

State

Speed

Color

0

Any

RED

1

0...500

GREEN

1

500...1000

YELLOW

1

>1000

BLUE

Let's create Motor graphical object for our example:

motorexample

 

Let's open Object properties window by double clicking on it:

motorpropertieswindow

Now we have to create Object type ST script with Execution type - OnDataChange:

stscriptforcomplexscript

Now open Object properties for our Motor object and click Script's collection and add our script:

stcollection

Now close Collection window and Object properties by clicking OK to confirm our changes. And now we can write our script:

commonmulcolorwithscript

Click OK to confirm your changes and Run simulation to check your settings:

commonwithscript