LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Second click generate a callback?

Solved!
Go to solution

Hi, Gurus,

 

I'm developing a software which need to do some calculation on each second changes, but I cannot find a existing way to do this.

 

I know to use a Timer in panel control to generate a 1s interval but from the experiment observation it will swing around the truely second click. Finally, I changed the strategy. Use a 0.01s Timer, read and store the second read from GetSystemTime, once the second changed, then goto the original calculation codes. The experiment shows also the calculation action really takes a good sync to the second change.

 

The issues was resolved, but my question is whether there have any better way to simplify the code and the mechanism?

 

Regards,

Pete

0 Kudos
Message 1 of 3
(172 Views)
Solution
Accepted by topic author helloPete

You do not declare which level of accuracy you pretend on the 1-second pace, anyway I would suggest you switch from standard UI timers to Asynchronous timers, an instrument which you can find in <CVIAppFolder>\toolslib\toolbox\asynctmr.fp

Asynchronous timers are built on top of multimedia timers and execute in an independent thread, so they are not subject to events in the main thread that could affect UI timers (just as an example, simply click on the window title: as long as the mouse button is on, UI timers are freezed as well as your accurately trimmed code!). A good example useful to compareUI timers and async timers can be located in <CVISamplesFolder>\toolslib\toolbox\asyncdem.cws.

 

The use of asynchronous times (and in general of a multitheaded approach) is a good solution when you need to make a task independent from system events (nevertheless keep in mind that you are not on a real-time system: there may always be conditions in which the system cannot honour the task scheduling you have setup)



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 3
(149 Views)

Thanks so much Roberto. 0.01s accuracy is good enough to me.Let me try the Asynchronous Timer. And I see your signature Proud to use CVI from 3.1. Shake hand bro. I have used CVI more than two decades, start from 4.1 on WIndowsNT.

 

I have to complain why NI doesn't provide the beautiful UI components for CVI, just like they did in Labview. And the topic quantity in Labview forum is ten times to CVI forum, this may lead a conclusion that Labview user is ten times to CVI user.

 

Anyway, I still think CVI is a great tool, thanks again! Regards, Pete

0 Kudos
Message 3 of 3
(134 Views)