LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using tlb and DLL

Lycangeek, you are my hero!  I didn't know the variant to data function was in fact "QueryInterface" in LabVIEW...  I just tried it out with the instrument and everything works fine!  Thanks for the help!
By the way, this topic hadn't been discussed before in the forum , at least I didn't find anything.  I'm happy this could help anyone else having the same type of problem.
Cheers

Yohan
0 Kudos
Message 11 of 21
(1,440 Views)
0 Kudos
Message 12 of 21
(1,434 Views)
Hi Brian!

I thought I would revive this thread with another question regarding COM/ActiveX... I read in your blog that sadly you're not part of the NI team anymore, but I'll take my chances and see if you're still posting.

I would like to know if it is possible through LabVIEW to create a class structure / skeleton by impleting the interface of a given IDL file or TLB file.  Basically, I want to implment a class using someone else's definition (IDL or TLB file).  I know OOP in LabVIEW is at it's early stages but maybe some 3rd party program allows the use of these files to create classes.  I saw an article which slightly concerns this in the LabWindows Developer Zone...

Thanks for the help and good luck with your new endeavors at Microsoft.

Yohan
0 Kudos
Message 13 of 21
(1,349 Views)
By the way,
Anybody feel free to answer!  This question isn't strickly aimed at Brian! Smiley Very Happy
Thanks

Yohan
0 Kudos
Message 14 of 21
(1,342 Views)
Hey, here is the OOP page for LabVIEW.  http://zone.ni.com/devzone/cda/tut/p/id/3573
 
It references a third party vendor for a toolkit for OOP (Endevo). 
 
Let me know if this helps!!
Daniel Eaton
National Instruments
Systems Engineering
Embedded and Industrial Control
0 Kudos
Message 15 of 21
(1,334 Views)
Hi Daniel,

seems Endevo doesn't have this option in their OOP software...

thanks for the link anyways!

Yohan
0 Kudos
Message 16 of 21
(1,322 Views)
Does anyone know how I can reach Lycangeek, a.k.a Brian Tyler?
Thanks

Message Edited by NahoY on 08-06-2007 02:09 PM

0 Kudos
Message 17 of 21
(1,307 Views)
Well, I happened to check in and look what I found 🙂

To answer your question. Yes and no. You cannot directly implement an IDL interface inside LabVIEW - the LabVEW concept of classes and those of ActiveX are not the same - too long to explain here. However, it is possible to invoke VI's from other languages which can do this. For example

1. You could use VB6/C++ to create an implementation of the IDL and then use the ActiveX interface of LabVIEW to invoke VIs
2. You could use VB6/C++ to create an implementation of the IDL and then call LabVIEW VIs by compiling them to a C DLL can calling them from VB6/C++

If you know .NET, you could do some similar things with VB.NET or C# - both can create .NET classes that are exposed as COM objects (see ComVisable attribute). Then from .NET you can invoke LabVIEW.

What is interesting about the last option is that you can do something very interesting. Implement the COM objects with .NET. The implementation of each method would in turn invoke an event with the same signature. LabVIEW can register a VI as a callback to such a method, which gives you some dynamic hooks...a bit more complicated arrangement but something to consider.
0 Kudos
Message 18 of 21
(1,298 Views)
Hi Brian!
Thanks for answering this obscure question...

The third option you proposed seems to be the closest as to what I would like to acheive... do you have any example code of this?  Or any concrete example to help me understand better?
Thanks for your help!  You seem to be the only one with enough experience and knowledge in both C++ and LabVIEW to figure these things out.
Cheers

Yohan
0 Kudos
Message 19 of 21
(1,286 Views)
I don't have any code laying around for this, but I can walk you through the basics...the first thing to do is to create a managed C++ class that defines the methods you want. For example
 


Then in the body of MyRegularCFunction

   void MyRegularCFunction( Object^ arg1, String^ arg2 )
{
if (ThisIsTheEventDefnForLabVIEW !...



So, when a C++ client calls "MyRegularCFunction", it turns around and invokes the event. LabVIEW allows you to register a LabVIEW VI as an event handler, so you need to hook up the LV VI's first.

Issues to consider:

1. How do you initialize this? You'll need to get the VI's initialized first - before any C++ client calls the object. One solution is to make the events static and pass the "this" pointer as an argument to the event handler. That way you only need to register the event once for all instances of your C++ class.

2. You must conform to the restrictions of event handler VIs...read up on this, but it's basically stuff like "don't do a lot - you don't want to hang the system" and "don't do any UI work - post events to LV event structures"...etc.



0 Kudos
Message 20 of 21
(1,269 Views)