LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LV 8.2 reentrant vi's are sharing data via LV2 style global.

Solved!
Go to solution
Hello everyone.
 
I've been away from LabVIEW for over a year now, and am getting back up to speed here with this new fangled LabVIEW 8.2.  🙂
 
I am trying to write a simple "sub" application that I can call multiple times via subpanels in one top level vi. (using tabs, with a subpanel on each tab)
 
I would VERY MUCH like to use LV2 style globals (AKA intelligent globals) in this sub-application.  However, the LV2 global is getting shared by all the reentrant sub-applications, which is exactly what I am trying to avoid.
 
Can it be done? Or do I simply have to avoid LV2 globals if I am going to have multiple instances of the application running?
 
(I could have sworn that I did this before with LV7, but my memory is a little fuzzy)
 
Thanks!
 
John
0 Kudos
Message 1 of 6
(3,035 Views)

Hi John,

so what you want to do is to have every sub-application to own a copy of a LV2 style global to store its data.  LV2 style global will be shared by all VIs.  You can't neither have LV2 style global reentrant.  The only way I see for that is to use an array in your LV2 style global and index the data in that array with a "thread ID" or "application ID" that would be a typedef.  That's what I use to do.  I have N instances of a thread that use the same LV2 style global that contains an array of N.  I have a typedef that identifies the N threads.  So I do Get/Set data with ThreadID.

Hope that helps!

Patrick.

Message 2 of 6
(3,010 Views)
Solution
Accepted by John_Howard
If I understood you correctly, you'd like to run multiple copies of the same reentrant VI and the shift register of each instance should be able to have different values. This is exactly what happens. Create your VI with uninitialized shift register. Make the VI reentrant. Then in your main application open reference to the VIs using option 8 that will ensure that the references you get are really distict. Then depending on your application either call the VIs using Call By Reference Node or Run VI method of the VI class using an Invode node.

Tomi
--
Tomi Maila
Message 3 of 6
(3,000 Views)

Thanks for the replies!  It looks like I'll have to identify each element in the global if I insist on using this method.  (which I may just abandon for this project)

Unfortunately the LV2 global is a sub-vi of the reentrant vi, and I can't make the LV2 global reentrant since I need to use it in multiple places within the reentrant vi.

I guess this is the expected behaviour - i just isn't what I expected.  🙂

John

0 Kudos
Message 4 of 6
(2,991 Views)
What Tomi said is a solution for you. You might reread that post. It stated that you can indeed have each sub-application have its own independent copy of the LV2 style global for its internal data storage that can be called from multiple places on the diagram within that sub-application. You do this in two steps:

1. Make the LV2 style global reentrant (this is not sufficient as you noted, but see step 2).
2. Instead of calling the LV2 style global from each sub-application as a subVI, you will need to open a reference to it (once in each sub-app ) using VI Server (Open VI Reference in the Application Control Palette) as Tomi described using the special option x8. Then pass that reference around the sub-app and call the LV2 global VI using the Call by Reference Node instead of a direct subVI call. It's a little more work, particularly if you're not that familiar with VI Server, but it's not too difficult.

Let us know if you have any questions!
Jarrod S.
National Instruments
Message 5 of 6
(2,984 Views)

Dooh!!  Thanks for clarifying Jarrod.  It all makes sense now.

Sorry Tomi, I misunderstood at first.

Thanks to all!

John

PS. The only disadvantage I see is having to pass the VI reference around, which is the kind of thing I am trying to avoid by using LV2 style globals in the first place.  oh well  🙂

Message Edited by John Howard on 01-31-2007 06:17 PM

0 Kudos
Message 6 of 6
(2,960 Views)