I want to use a timer-based gateway event script and have it fire every 10 seconds. I’ve put this script on the global project. What I’m finding is that it does pause but then rapidly counts up, at a rate much more frequently than I need, then pauses again. Can someone explain this behavior and how to correct it? Please see the screenshot of a super-basic tag writing script I used later for troubleshooting (same behavior). Thank you
Have you tried setting Delay Type to “Fixed Rate”?
Yes! I actually just adjusted the script, to check this and it’s behaving the same… Pause followed by a rapid increase in the counter. Its almost like the script is queing up multiple times then firing all at once.
I don't see an option for Scheduled which tells me you are on a version Prior to 8.1.6, what version are you on. I believe there was a bug at one point where the timer scripts didn't behave exactly as expected, but I could be misremembering that.
Also, I see that you have the Shared Threading option selected and there is another Timer script configured. Is it possible that other timer is somehow blocking this one? From the manual:
- The Shared setting means that all timer scripts will share a thread. This is usually desirable, as it prevents creating lots of unnecessary threads: threads have some overhead, so a small amount of resources are used per thread. However, if your script takes a long time to run, it will block other timer tasks on the shared thread.
Also, you may want to consider using system.tag.writeAsync()
instead of the blocking version depending on the actual script that you are wanting to use.
Thank you Lrose - you’ve given me some homework… I’ll reply back in a bit with what I find.
What do you mean by “global” project? The inheritable project from a v7.9 conversion? If so, don’t put it there. Inheritable projects don’t run events themselves. But every project that inherits the events will run its own “copy”. Make a new project, inheriting from global if necessary.
This page in the manual has an excerpt about what @pturmel is referring to. It’s under Inheritance and “Runnable” Resources.
Thank you for your updates. Moving the script to my active project was the solution. It now makes sense… I do have many individual projects so it follows that each one of those would have been executing the same global script multiple times, resulting in the behavior I observed. Thanks!!!