Fire a command at a specific time.
Thorleifur Posts: 58
I was wondering how to fire commands at specific times now. I used to put it in the define_program section as the IF(TIME = XX:XX:XX or ??), but now I am putting it in my feedback timeline. I feel like there is a more processor friendly approach here. I might be wrong of course . How do you guys do it?
My preferred method is that I convert all times to an integer starting at midnight. it's basically minutes past midnight. (ex: 3:00 AM equals 180 minutes. there are 1440 minutes per day) I then do a quick check if current time equals the "do something" time - go do it. You can easily also just do the IF(TIME = XX:XX:XX or ??) thing as well.
Obviously the timeline needs to be repeating. Also, there have been times I've seen timelines stall for no apparent reason. I've built in a little named wait in each timeline that gets cancelled upon entering the timeline but restarted when the code section completes. The named wait has code to restart the timeline if it's killed for some reason.
I think they've fixed the bug in FW (this seemed to happen with the first NX series) but I'm probably a little superstitious and gun-shy. Once bitten, twice shy...
An early version of NX FW had a bug that would kill timelines after like 50 days (it had to do with transitioning from 32bit to 64bit).
in my main I'll have something like this:
This also has a 250ms function call to trigger things faster than every second like FB routines or triggering send queues so this one include can be used for everything on the main side in you want. It also keeps track on everything else time related I could think of like day occurrence per month which is useful for some holiday calculations and DST stuff.