Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

using a CNiTimer

I am using MSVC++ for my development.
I created a CNiTimer that checks the status of my trigger. If the trigger fires i want to post a message to my main thread so that it can start processing data.

So my question is this:
The CNiTimer thread will check the trigger status every few milliseconds and call the SetEvent() function to signal the main thread to acquire and process data. Will this event fire fast enough to work consistantly in a real time environment that must process data at the millisecond level?
0 Kudos
Message 1 of 5
(3,488 Views)
Hi,

The CNiTimer is developed using the Windows Multimedia timers; which are the most accurate timers in the Windows environment. Microsoft does not reports an specific accuracy of the time, but it will be around 1 millisecond resolution.

To say whether this is suitable for real time or not depends on what you expect. Any software timers in Windows are going to have variations, the timer event will be generated on time, but since this is a Windows message, it may have to wait for the chance to execute the code, resulting in variations dependong on other circunstances.

In general I would not consider a Windows based system to be real-time, you may want to look at our Real-Time solutions they offer hardware targets
that runs at a deterministic rate.

I hope this helps, let me know if you have other questions.

Regards,

Juan Carlos
N.I.
0 Kudos
Message 2 of 5
(3,488 Views)
Well, i knew that the CNiTimer was based on the Multimedia timer, which i think is accurate enough. But I'm wondering if setting an event if the trigger has fired will be fast enough. Will this event just be added to the windows messaging queue?
0 Kudos
Message 3 of 5
(3,488 Views)
Sounds like just creating your own dedicated thread would work good here. The thread would only be responsible for detecting the trigger event and posting a message. You could vary the priority level of the thread and see what gets you the best performance.

I like threads here because of the ability to set priority. To increase program flow it could kill itself right after it posts a message indicating the trigger event.
Grant M. Johnson
Project Engineer
LECO Corporation
0 Kudos
Message 4 of 5
(3,488 Views)
okay. So instead of setting a timer, you think i should create a low priority thread that contains a while loop that continuously polls the status of the trigger, and then if the trigger fires, have the thread set a window's event?
The trigger thread won't slow the processing of my image processing thread?

Thanks for your help.
0 Kudos
Message 5 of 5
(3,488 Views)