LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Support for late binding

Solved!
Go to solution

I've created a couple of similar top-level VIs that make use of a number of common subVIs. In the interest of modularity, I'd like to place these common subVIs into some kind of a folder or library that is shared by the top-level VIs - so far, so good.

 

Some of these shared subVIs refer to other subVIs that are separately and uniquely implemented for each of the top-level VIs. My original thought was that LabVIEW might use "late binding", when the top-level VI is loaded for execution, to resolve all of the subVI references, and thus pick up the correct uniquely-implemented subVIs for the particular top-level VI being loaded. However, observations have led me to believe that all of the subVI references are resolved statically, at compile time, and thus a shared subVI cannot refer to different subVIs depending on which top-level VI is running. And I can see that it makes sense that it needs to be this way, given the way that the LabVIEW development environment works.

 

Consequently, it seems that shared subVIs need to be able to statically resolve any of their own subVI references to one specific implementation at compile time. Thus subVIs that cannot do this cannot be shared subVIs, even though they are otherwise identical in each of the top-level VI contexts. Separate identical copies of such subVIs will need to be maintained for each top-level VI.

 

Do I have this approximately correct? Is there any way that this kind of "late binding" can be supported in LabVIEW?

 

0 Kudos
Message 1 of 2
(2,179 Views)
Solution
Accepted by topic author Barry_Wealand

There are two ways you could make this work; you'll have to determine which one is appropriate for your situation. The first is to use VI reference for the specific instance you want. Inside the generic subVI you use a Call By Reference to call the VI that was passed in. Several of the VIs supplied with LabVIEW demonstrate how this works, for example take a look at "Constrained Non-linear Optimization" under the Mathematics->Optimization palette. You'll see that one of the terminals is are reference to a VI that implements the function to be optimized.

 

Another possible solution is to use the dynamic dispatch capabilities of LabVIEW's Object-Oriented Programming. In this case, your library would implement a class. The specific instance you want to call would inherit from that class and define a specific VI that overrides the version in the generic library. When a VI in the library calls the subVI, it will dynamically dispatch to the child method, if the object is of the child class and the child method exists.

0 Kudos
Message 2 of 2
(2,168 Views)