Time and wait()


Mixergy

Recommended Posts

Dear all,

I am fairly new to daqfactory and have an issue regarding designate task at certain time. I have been using the following time and wait()/delay() function in the sequence to schedule tasks on specific time:

 

time 0

Event A

Wait(10)

Event B

time 30

Event C

 

My purpose was: do A when sequence starts, do B after 10 seconds, and do C in 30 seconds after sequence starts. However in test, it did the following: Event A at start, Event B after 10 seconds, and Event C in 40 (30+10) seconds after sequence starts. It appears that 30 seconds specified by time is happened after Event B.

 

Is there a way to specify the time (from the beginning of the sequence) of the event even with wait() or delay() in between (sorry I know it is weird but event B is a while loop with wait() function inside, so I don’t exactly know how long event B would take)? I can upload the script if that is any helpful. Many thanks!

Ren

Link to comment
Share on other sites

The "time" syntax is left over from DAQFactory Release 3 and is very deprecated.  I'm not sure why its still supported, and from your post, maybe its functionality has fallen through the cracks.  You should really stick with delay() and occasionally wait().  In your case, wait() is about right.  There are a number of ways to achieve what you want, here is one:

private startTime = systime()
// event A
waituntil(startTime + 10)
// event B
waituntil(startTime + 30)
// event C

waituntil() waits until a particular time stamp.  In the first line, I recorded the time of the start of the sequence.  Then subsequent waitUntils all reference that time plus some offset.  As I said, this is just one way to do it.

 

Link to comment
Share on other sites

Hi AzeoTech,

Many thanks for your reply. I have been using daqfactory Lite version, not sure if that is the reason I can still use the time function.

On another note, my events are occuring with intervals of hours in minutes, and I noticed that when I use second unit in wait(), i.e. wait(startTime + 39600), there is a slight accuracy issue (time shift in minutes). Will there be similar issue if I use wait(startTime + 11h0m0s)? In this case, is using waituntil(startTime + 11h0m0s) more accurate than using waituntil(startTime + 39600)?

Cheers,
Ren

Link to comment
Share on other sites

wait() or waituntil()?  Because wait() takes number of seconds to wait, a delta T, where waituntil() takes an absolute time which would be a number in the billions.  startTime in my example is absolute time, so startTime + 39600 is an absolute time.  Doing wait() on that would cause it to wait a very, very long time (about 47 years).

Also, 11h0m0s gives an absolute time including the date which defaults to today when not specified.  As such, startTime + 11h0m0s is a time about 47 years in the future.

Both really should be precise to the millisecond.  There are rare cases, however, where the high precision clock that DAQFactory uses is poorly implemented by the hardware.  You can usually tell this by creating a component that displays the current time:

formatDateTime("%c", systime())

and then leaving it for a few hours, then seeing if the displayed time drifts from the Windows time at all.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.