LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to use variables seperately for each clone VI

Solved!
Go to solution
I am writting an VI that could be open for multiple times, Each opened one is an instance VI(VI clone). Because it's complex so I have to use global variables or functional global. But comes with question, how can VI clone 1 and VI clone 2 use the different set of global? I mean each clone could manage its own global. For example, global A initialize to 1. VI clone 1 write global A to 2. so all subVIs called by clone 1 get global A as 2. But in clone 2 and all its subVIs the global A is still 1. The only way I figured out to do this is using call chain to find current clone name. And then search for the global of the clone. It works but may have performance issue in the future that each time I read or write global means a search operation and a get call chain operation. Is there any better way to do this?? Many thanks!
0 Kudos
Message 1 of 7
(3,008 Views)

And also I think functional global is performance better than global when dealing with large set of data. Am I right?

Smiley Happy

0 Kudos
Message 2 of 7
(3,007 Views)

Global variable has to be non-reentrant, you can probably make a global variable with an array of 'Data-type' that you were planning to have in Global 1 & 2 separately. Now each Clone has its own space (identified by the array index)...!!

But still at sub-VI level it should know, whether its caller is Clone-1 or Clone-2..., now apart from using 'Call Chain' you might want to pass the name of clone to each sub-VI, so that instead of using "Call Chain", the sub-VI already have the Clone ID available with them...!!


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 3 of 7
(2,997 Views)

Well, it's ok if this is a project about hundred VIs. But there are thousands VIs so pass the clone name to all subVIs may not be an option.

Visit global by index, sure. But I mean is there any way to avoid calling "call chain"? 

0 Kudos
Message 4 of 7
(2,993 Views)
Solution
Accepted by topic author brucexliu

For a sub-VI(s) to know, who is its caller, there is only two methods possible:

1. use 'Call Chain'.

2. Pass the name of Caller.

 

I cant think of any third method...!!

 

Now even if there are thousands of sub-VIs, do they all need the name/identity of caller..?? If thats the requirement... probably you should re-design the architecture (yeah I know it sounds painfulSmiley Sad)...!!


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


Message 5 of 7
(2,983 Views)

Assuming you have your dataset/controls as a cluster (which you should), use that cluster as input and output of the VI. In the main VI, use an Array of Clusters. Feed each VI their data, collect result.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 7
(2,970 Views)

Thanks.

I prefer call chain then..

0 Kudos
Message 7 of 7
(2,946 Views)