Run Gateway Script Every Minute

I want a gateway script to run every minute but importantly it needs to run “on the minute” so to speak, i.e. at 7:00:00, 7:01:00, 7:02:00, 7:03:00 etc

I believe the scheduling option in Transaction Groups allows this setup and I think I’ve heard someone say something is planned for Timer Scripts in a future Ignition release.

However, for the time being a forum search came across this:


Basically create a Timer script set for every 1000ms and then examine the current time to see if it meets the appropriate criteria - in my case that would be seconds equal to zero.

That thread’s nearly a year old so two questions.

  1. Is this the correct way to achieve this? Is it the most efficient? Will it place unnecessary load on my system?

  2. If so, what’s the best of retrieving the current time in my Python script? There seem to be various options, .e.g.
    [ul][System]Gateway/CurrentDateTime tag
    from time import localtime, strftime
    from java.util import Calendar[/ul]

Thanks very much.

It could certainly be done that way. But (and y’all knew I’d have a “but” in there right?) personally, I’d would:

[ol][li]Make a tag that holds the minute value. dateExtract(now(),“Minute”)[/li]
[li]Set it’s update rate to “pretty quickly”-- like 250ms. (You may have to create a new Scan Class)[/li]
[li]Use an “On-change” script to monitor it.[/li][/ol]

Using On-Change would eliminate the need for retreiving the time and checking the seconds within the script. :wink:
Setting the update rate to 250ms helps ensure that the script starts executing within… well… 250ms

Hope this helps!

Thanks for the reply, Jordan, your example makes sense.

I suppose it boils down again to knowing which solution is most efficient, i.e. if as you say I have a new tag evaluating every 250ms - will that put any unnecessary load on the system?

Generally I’d say no, although in reality, it boils down to what you have for hardware. Since everything is pretty well internal to Ignition, things should stay stable. Even with the server I got saddled with, I’ve not had any issues.

Server is quad core, which is nice, but Server 2003 32-bit and 4G Ram-- which is not quite as nice… :laughing:

In my operation I have approx. 1200 tags, most of them at the default rate of 1s. there are maybe 10 I run at 250ms, and 5 or 6 that run at 100ms. Some go longer, 5s or 10s. Really, you can tailor scan classes to your tags to fit whatever is necessary. And honestly, this size of project could really be considered lightweight.

This machine also acts as the file server for the Engineering Department until we can finally get replace the current file server, pdf document generator, license server for various CAD/CAM/PLC packages. I just wish it made sandwiches!

Anyway, keep it to server grade hardware. You should be okay.

EDIT: Yes, I’m hedging my bets with ‘should’ and ‘may’, because there’s a whole lot of variables-- that you may or may not have any control over-- that can come along and make life interesting for you. The best I can do is to relate my own experiences and pray that they have some relevancy for you. :smiley:

EDIT AGAIN: To the IA guys, how often does the script engine check for a tag change?

The tag change script is “subscribed” to the tag, so when the tag changes, the script is fired

Thanks, Greg!

Thanks again.