long-run repeatly timer?

Q

Qiangning Hong

I asked this question on comp.python.wxpython using the subject "a
wx.Timer like timer without wx package?" and David Fraser there
suggested me to ask here for a more general solution.

I am implementing a long-run sample-and-record system. It collects data
from a PCI card every 10 seconds, saves the data (timestamped with the
current system time) in the hard disk, and shows them on the screen.
There is also a GPS receiver module exists on the system, which correct
the system time (and the hardware time) when it drifts away too much,
however, I can not access the source code of this module.

The system requires the average sample rate is 6 times per minute to
analysis. If the OS clock runs too fast or too slow, we can get the
infomation by the GPS module's log file, and then correct the analysised
result with that infomation.

So, wo need the counter (a repeatly timer for collecting data) to meet
these requirements:

1. fires 6 times per minute, or to say, fires 60*24*360 times per 60 days.
2. will not be affected by the change of system time, foreward or backward.
3. no need for external hardware device, of cource.
4. not depend on any GUI package for it's a console based app.
5. works on a Windows mechine, cross-platform solution is better.

How can I implement such a timer? Thanks in advance.
 
J

Jeff Shannon

Qiangning said:
I am implementing a long-run sample-and-record system. It collects
data from a PCI card every 10 seconds, saves the data (timestamped
with the current system time) in the hard disk, and shows them on the
screen. There is also a GPS receiver module exists on the system,
which correct the system time (and the hardware time) when it drifts
away too much, however, I can not access the source code of this module.


I think that, in order to do this, you may need to discover when the
system time has been adjusted and explicitly correct for that. Given
that system time is the only real source of timing information that you
have (because any other sources are going to be derived from that),
you're going to have a hard time doing anything that's more accurate
than your (possibly self-corrected) system time.

Is there a way to get the GPS module to inform other programs when it
adjusts time? Is there a maximum/minimum time delta that it will
apply? Does it only correct the system time at specific intervals?

Actually, if you can write a C extension (or if there's a preexisting
Windows API call that you can use through ctypes), you might be able to
hook into the hardware clock-tick interrupt and count ticks yourself,
deriving your own time with a little bit of math. You'd probably need
to sync periodically with the system clock, anyhow, to make sure that
your tick count isn't drifting, but it would give you independence from
the sudden discontinuities in the system time from being reset by the
GPS module.

Jeff Shannon
Technician/Programmer
Credit International
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top