Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

MsgWaitForMultipleObjects and NI-DAQ Events

Is there a way to use the native Win32

MsgWaitForMultipleObjects

function with NI-DAQ events or am I stuck with callback functions?

John

0 Kudos
Message 1 of 6
(3,344 Views)

For example:

 

switch

( MsgWaitForMultipleObjects (1, &pMyEvent, FALSE, INFINITE, QS_ALLEVENTS ) ){

case WAIT_OBJ_DATA_MY_EVENT_HAS_ARRIVED:

/************************************************/

::ResetEvent (myEvent);

Process My Event

/************************************************/

break;

case WAIT_OBJ_WINDOWS_MSG:

while ( PeekMessage ( &msg, NULL, 0, 0, PM_REMOVE ) ){

if ( msg.message == WM_NI_DAQ EVENT??

Process DAQmx Event

break;

}

DispatchMessage (&msg);

}

break;

 

John

0 Kudos
Message 2 of 6
(3,340 Views)
Hi John,

I was just curious if there was a specific reason you would rather use the MsgWaitForMultipleObjects and not callbacks?  The way the DAQmx library is designed is to use callbacks to gather this event information.  These event messages are already handled by callback functions.  We don't provide any specific documentation on the DAQmx messages that are sent to the Windows event queue.  I would recommend that you try using Microsoft's Spy++ software to spy on the Windows event queue to find out the messages we use for our events.  Then you would be able to use the PeekMessage function to grab these events from the windows event queue and handle them with the MsgWaitForMultipleObjects.  I also wanted to mention that I did find another thread that had some information (more specifically with LabWindows CVI) you might be interested in.  This thread can be found here.

I hope this information helps,
Paul C.
0 Kudos
Message 3 of 6
(3,308 Views)

Paul,

 

We typically structure our services to have two threads.  An interface thread and a worker thread. What I want is the worker thread to wait for the message event to process the DIO state change.  The interface thread is to manage the outside world connections into the class/object.  We already have this struture setup and I was hoping to utilize it.  I haven't worked much with callbacks so I cannot speak on how well they work, etc.  What happens if the callback is in process and another event happens?  Do I lose it?  Is it processed off a queue on the DAQmx thread?

 

John

0 Kudos
Message 4 of 6
(3,297 Views)
Hi Rammer,

I'm afraid we don't offer documentation on how the messages are sent and handled between the Windows event queue.  However, I would be more than happy to submit this as a product suggestion for future versions of DAQmx.  I can understand why a more low level custom event handling functionality would be useful for keeping things organized within your code.  As for how callbacks work with the DAQmx events, each event is placed within a queue and handled appropriately with the callback function.  Every event will be accounted for.  I did a quick google search for "callbacks" and found some very useful information.  There is a great wikipedia article that can be found here

I hope this helps,
Paul C.
0 Kudos
Message 5 of 6
(3,271 Views)
Hi John,

I haven't tried it, but I think you can get what you want by signaling an event object from the callback function, or by sending a Windows message from the callback function.

Brad
---
Brad Keryan
NI R&D
0 Kudos
Message 6 of 6
(3,267 Views)