Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

how to fire .NET custom event into LabVIEW,

I want to add callback functionality to an instrument, for which the driver has been written in C++.

We are trying to do this with a custom .NET event to pass data into LabVIEW, but LabVIEW doesn't seem to like it.

Does anyone know how to do this ?

Ideally the event data would be an enumerated type and a variant.

An enumerated type and a 1D array would also be a lot better than our current interface, which is forced to use polling to get the information we need.

 

Background as follows:

 

To control my instrument, there are three types of interfaces I need as follows:

1. Send a command to the instrument.

2. Request information and receive a synchronous reply.

3. Request to be kept informed, receive information at one or more later times. This is asynchronous.

 

Inside LabVIEW I can (and do) write all three types.

Inside C++, all three types are available from the instrument interface. The third type uses callback functions.

However, between LabVIEW and C++, I can only use types 1 and 2.

 

This is because in LabVIEW, you can't pass a pointer to a function directly, so across a DLL to C++, you can't pass a pointer to a callback function. This means some of the instrument functionality is not accessible from LabVIEW.

 

Currently we are using a horrible solution based on polling, but want to replace this with an asynchronous mechanism.

 

Thank you !

0 Kudos
Message 1 of 5
(4,594 Views)

Hi there,

 

Thanks for your post! Please find some attached information that I found that may be of use whilst searching quickly, I will keep looking into this however.

 

This first one talks of handling .NET events in LabVIEW and the second of invoking callbacks in LabVIEW.

 

http://zone.ni.com/devzone/cda/epd/p/id/6047

 

http://digital.ni.com/public.nsf/allkb/90C5727DFCDEE6038625743900450F16?OpenDocument

 

Please take a look at these and let me know if I am heading in the right direction with this information - I will continue looking into this in the meantime.

Many thanks,

 

Liam

Liam A.
National Instruments
Applications Engineer
0 Kudos
Message 2 of 5
(4,586 Views)

hi,

it looks promising,

we'll try to get back to you on Monday

 

THANK YOU !

0 Kudos
Message 3 of 5
(4,572 Views)

I was excited when I found this thread because this is exactly what I need to do...  and then got to the end and there was no follow-up.

 

Here is my situation:

 

The main programming effort is all done in LabVIEW using a Producer / Consumer architecture, but for various reasons, we are using a C# class to actually interface to the UUT (ethernet). Most everything is going well with the two sides of the programming, but when the data is received from the UUT via the .NET class, how can we use the .NET event capability (delegate) to pass the ethernet data from the .NET class back to the LabVIEW program?  This structure is being used so that neither of the programs are sitting there polling to dee if data is available.

 

Thanks.

0 Kudos
Message 4 of 5
(4,456 Views)

m3rl3n,

 

The links Liam posted above explain/show how to register a VI to be used as the callback of a .NET event.

 

The function you'd use in LabVIEW is the Register Event Callback Function.

 

Note that it has to be a .NET event rather than just a delegate (events are a specialized type of delegate).

 

Hope this helps,

 

Simon

0 Kudos
Message 5 of 5
(4,451 Views)