Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

What is DAQmx_Val_SynchronousEventCallbacks?

For DAQmx products there are three Callback functions.  For the options parameter the user can use the variable DAQmx_Val_SynchronousEventCallbacks.
 
What options are available for this variable?
How is this used?
 
Thanks,
 
Kevin
0 Kudos
Message 1 of 12
(6,893 Views)
Hi Kevin,

You can find the details on when and where this function is used by taking a look at the NI-DAQmx C Reference Help (Start > All Programs > National Instruments > NI-DAQ)

I found that the value has the following information associated with it:
Value
Description
DAQmx_Val_SynchronousEventCallbacks
The callback function is called in the thread which registered the event. In order for the callback to occur, you must be processing messages. If you do not set this flag, the callback function is called in a DAQmx thread by default.
Depending upon the command this may be the only option available.  For the following commands DAQmx_Val_SynchronousEventCallbacks is the only 'option'.
DAQmxRegisterDoneEvent
DAQmxRegisterEveryNSamplesEvent
DAQmxRegisterSignalEvent
0 Kudos
Message 2 of 12
(6,876 Views)

Hi Otis,

Is DAQmx_Val_SynchronousEventCallbacks set by the programmer?

If DAQmx_Val_SynchronousEventCallbacks = 0 what does DAQmxRegisterDoneEvent do?

If DAQmx_Val_SynchronousEventCallbacks = 1 what does DAQmxRegisterDoneEvent do?

Thanks,

Kevin

0 Kudos
Message 3 of 12
(6,867 Views)
To clarify the documentation, there are in fact two options for each of the registration functions.


- setting the option to 0 would mean the event fires in a DAQ driver thread, not in the thread that registered the event (asychronous). This is the default behavior.

- setting the option to DAQmx_Val_SynchronousEventCallbacks means that event fires in the same thread that registered the event (synchronous)


This applies to the other event registration functions as well.


Message Edited by bilalD on 04-20-2006 09:11 AM

Bilal Durrani
NI
Message 4 of 12
(6,865 Views)

This is very good information.

1.  What is a DAQmx thread?

2.  What is a thread that registered the event?

Kevin

Message Edited by EW on 04-21-2006 12:45 PM

0 Kudos
Message 5 of 12
(6,845 Views)
Hi Kevin,

  1. Wikipedia: Thread (computer science)

    Once you have the basics you can take a look at this:
    KnowledgeBase: How Many Threads Does NI-DAQmx Have?

  2. If a DAQmx Thread (somewhat synonymous with Task for your case) registered the event, then it is that thread.
I hope this helps.  Definitely check out the Wikipedia link for more information about what a thread is.  This is something rather fundamental to most programming languages that you can use to your advantage.

Regards,


0 Kudos
Message 6 of 12
(6,826 Views)
I' m  wondering how to use  the function "

int32 DAQmxRegisterSignalEvent (TaskHandle taskHandle, int32 signalID, uInt32 options, DAQmxSignalEventCallbackPtr callbackFunction, void *callbackData);

"when I set the paramter "options" as DAQmx_Val_SynchronousEventCallbacks . Is there any sample to show me ?
0 Kudos
Message 7 of 12
(6,658 Views)

I don't know, but I would write a test program with options set to 0 first.  Get that working and then move to the next.

Kevin

0 Kudos
Message 8 of 12
(6,637 Views)

Hello Robert,

The are no DAQmx shipping example that shows how to use the option DAQmx_Val_SynchronousEventCallbacks.  The ANSI C examples that ship with DAQmx do not have a GUI and do not process windows messages.  For this reason they do not use the above option.  All the shipping examples use the asynchronous 0 option, and you can typically find them here:

C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Events\Every N Samples

There are also several example that use the asynchronous RegisterEveryNSampleEvent online.  For example you can find a Visual Basic example here.

To use the DAQmx_Val_SynchronousEventCallbacks you must either use an application that automatically handles windows messages, or write your own message handling.

Regards,

Jesse O.
Applications Engineering
National Instruments

Jesse O. | National Instruments R&D
0 Kudos
Message 9 of 12
(6,600 Views)
hi,

where can i find the windows messages
constants like "WM_APP + ???" that are send to my message handler procedure?

Regards Stefan
0 Kudos
Message 10 of 12
(6,548 Views)