<< Click to Display Table of Contents >> Complex flashing with scripts |
![]() ![]() ![]() |
If you have to change flash frequency depending on several tags you need to use scripts. For example you have 2 tags for every Pump object - State and Speed:
Depending on tag's values for every Motor object use flash frequency:
State |
Speed |
Flash frequency |
0 |
Any |
Not flashing |
1 |
0...500 |
1000 |
1 |
500...1000 |
500 |
1 |
>1000 |
250 |
Let's create Motor graphical object for our example:
We need intermediate tags to enable or disable object's flashing - Flash1, Flash2 and Flash3:
Let's open Object properties window by double clicking on it:
And let's create user-defined property - Number and make it's equal 1:
Close Collection window and click OK to Object properties window. Now reopen Object properties of the Motor and setup its Flash property. First we need to setup tag and bind it to Flash tag dependent on the User-defined property - Number. To do this click "..." and setup Tag name - Flash{Number}:
Flash property setup like in the picture:
Now we have to create Object type ST script with Execution type - OnDataChange:
Now open Object properties for our Motor object and click Script's collection and add our script:
Now close Collection window and Object properties by clicking OK to confirm our changes. And now we can write our script:
Now we have Motor with setup flash property by script. To copy this Motor and bind flash property to tags - State2, Speed2 and State3, State3 you no need to setup script for every Motor you only have to duplicate Motor:
And change Number property of the new Motor in the Property sheet:
Click OK to confirm your changes and Run simulation to check your settings:
You can download this project here.