LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

dynamic call VI outside a PPL with a class and in another application reference

Solved!
Go to solution

Hey there,

 

in my code, which gets compiled into a PPL, I need to call a VI in another application reference. (I guess this is the spot I need to change my requirement!)

To hand over the application reference, I'm using Open VI Reference. No matter if I use VI Server methods, or Call By Reference (with a strict typedef), I will have the same problem:

If there are only LV native data types, everything works fine... But the VI to call has a class on the connector pattern.

When I use Call By Reference I will get

Error 1031 occurred at Open VI Reference in PPL.lvlibp:Call By Reference.vi
Possible reason(s):
LabVIEW:  VI Reference type does not match VI connector pane.

When I use VI Server, I cannot cast the class with variant to data:

Error 91 occurred at Variant To Data in PPL.lvlibp:Call By VI Server.vi
Possible reason(s):
LabVIEW:  The data type of the variant is not compatible with the data type wired to the type input.

 

I need to hand over that class between my PPL and the VI. When the class gets pulled into the PPL it gets namespaced, so finally the class inside the PPL is not compatible with the class outside the PPL. I know this is only happening, because I try to dynamically call a VI outside the PPL. If that VI gets pulled into the PPL as well, also the class on the connector pane of the VI will be namespaced and everything would be fine. Why I'm opening the VI dynamically is because I need to call the VI in another application reference...

 

Any ideas how I could solve that?

 

I've created a minimal example (LV2016) showing my problem.


Proud developer at Hampel Software Engineering where we turn '404 not found' into '200 OK'. Join us on Discord
0 Kudos
Message 1 of 5
(1,140 Views)

Hi,

 

Even if you don't put the class directly inside the library, the PPL will contain a namespaced copy of the class anyway because you are using it statically here:

 

raphschru_0-1687873763659.png

 

and here:

raphschru_1-1687873812259.png

 

 

The only way I see is putting the class in its own PPL. So both your primary PPL and the "other application" would use the same "packed" class.

 

Regards,

Raphaël.

0 Kudos
Message 2 of 5
(1,109 Views)

@raphschru wrote:

The only way I see is putting the class in its own PPL. So both your primary PPL and the "other application" would use the same "packed" class.


Yes, I tried that and it works. Unfortunately, in the real project the VI to call belongs to an installed VIP in vi.lib, which depends on three other lvlibs, so I need to maintain four PPLs which depends on external sources...


Proud developer at Hampel Software Engineering where we turn '404 not found' into '200 OK'. Join us on Discord
0 Kudos
Message 3 of 5
(1,103 Views)
Solution
Accepted by topic author AlexElb

Alternatively, you can pass the object flattened as an XML string, then unflatten the object in the caller VI.

The difficult part is to edit the class name to trick LabVIEW into loading the class as if it was the namespaced copy inside the PPL.

Attached is your project modified:

Message 4 of 5
(1,088 Views)

Wow, thank you very much for your effort and your clever solution!

 

In my real project I need to pass in a class and the VI outputs a big cluster containing several arrays of different classes. So I would need to add a lot of code, but hey, it seems possible! 😀

 

If anyone has an even more general solution, I still would be interested.


Proud developer at Hampel Software Engineering where we turn '404 not found' into '200 OK'. Join us on Discord
0 Kudos
Message 5 of 5
(1,072 Views)