Trigging a function at a predefined time

Hello all,

I’m new to Ignition but very impressed so far. As part of the company’s transition from being a Citect integrator to whatever it is we choose (OK its going to be Ignition). I decided replicate a Citect project in Ignition to ensure that we can achieve all the basic functions required. The only thing I can’t seem to do is a timed event.

What I want to do is to send an email at 7am every day detailing some tag data from the previous day, I have the email set up as a script module and I can trigger it from a button and it works fine. What I’d like to do is to trigger it automatically at 7am gateway time, I thought the Gateway time script may help but I seems to be only for duration.
Please, how do I do this?

Chris

Put the timer script on a 1000ms timer, then you can use some python scripting to see if the current time is equal to 7am:

[code]from time import localtime, strftime
curTime = strftime("%H:%M:%S", localtime())

if curTime == “07:00:00”:
# call script module[/code]

Thanks James

I’ll try that in the morning, although I have some way to go before Python becomes simple.

It didn’t occur to me that there wasn’t a built in function

what if the scan should skip07:00:00, i.e. from 06:59:59 to 07:00:01, the function won’t run? can I look for a span and just trigger once?

I assume I could extend that script with additional IF statments to include running other scripts at other times,

Chris

There really shouldn’t be a time when it “skips” a second. Make sure your timer is set to “fixed rate”, from what I’ve seen the timer executes “on time” down to the microsecond, from time to time it may be off by approx. a millisecond at most. As long as your timer doesn’t start at hh:mm:ss.999001 (which would be an extreme edge case), it will be fine. Just throw a print statement inside the “if”, and check out your wrapper.log to make sure:

if curTime == "07:00:00": import datetime print datetime.datetime.now() # call script module

Thanks James

Once I sorted a little syntax out my end it worked a treat.

I also quickly found that additional “if” needs to be “elif” but now it works

Chris