LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using same sub vi code in different data spaces of a project

Solved!
Go to solution

Hi All.

My question is pretty general.  I have a sub vi (say aaa.vi) that has data items that must remain present between successive executions (i.e. it uses shift registers on a while loop).  However there are multiple areas in the project where these persistent variables are to occur.

 

My current approach is to create aaa.vi then copy to aaa_1.vi and aaa_2.vi.  Then use these 2 secondary vi's (with the same program !), with their different sets of persistent data.  Note that with the naming, I know which persistent data set is being used.

 

What is the recommended way to achieved this same end (with LabVIEW) ??.  With my approach, a change to the aaa.vi program implies a coping process (too the clones), which is not automatic.

 

Regards JC........ 

0 Kudos
Message 1 of 23
(396 Views)

If you make the subVI reentrant, each instance will have its own persistent data.

0 Kudos
Message 2 of 23
(395 Views)

Attention: LabVIEW does not guarantee that a caller will always get the same clone. You have to use preallocates clones if your callers use data from the SubVI.

 

https://labviewwiki.org/wiki/Reentrant_VI

0 Kudos
Message 3 of 23
(358 Views)

Yes, of course. That was implied. 🙂

 

(When I learned LabVIEW, shared clones did not even exist...)

Message 4 of 23
(333 Views)

@altenbach wrote:

Yes, of course. That was implied. 🙂

 

(When I learned LabVIEW, shared clones did not even exist...)


When you learned LabVIEW, Event Structures didn't even exist.  😄

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 5 of 23
(329 Views)

@billko wrote:

@altenbach wrote:

Yes, of course. That was implied. 🙂

 

(When I learned LabVIEW, shared clones did not even exist...)


When you learned LabVIEW, Event Structures didn't even exist.  😄


🤣 I guess that puts me in good company. How did we ever program without the event structure (don't answer that, I remember all of the polling).

Message 6 of 23
(310 Views)

@billko wrote:

@altenbach wrote:

Yes, of course. That was implied. 🙂

 

(When I learned LabVIEW, shared clones did not even exist...)


When you learned LabVIEW, Event Structures didn't even exist.  😄


... and there was no UNDO! (Motto: think twice, wire once!) 😄

Message 7 of 23
(308 Views)

Thank you ThomasHenkel.

With this subject I have to think about the different type of memory involved.  To me these are;

   Program space

   Temporary data space

   Persistent data space.

 

The option of Preallocated Clone Reentrant Execution is a possibility.  The Persistent data would need to be managed separately with a reference to it.  And then you need to be careful about multiple execution colliding with the integrity of the Persistent data.

 

The option of Shared Clone Reentrant Execution is similar to the Preallocate option above.  This has less control of what data is used.

 

The option of Non-Reentrant Execution is the safest.  This is what I use with my initial post which seems to be the best for the situation involved.

Changing the program needs to be performed in multiple locations.  This ensures the mapping to the different sets of Persistent data.  The name of the program also relate to this mapping.  The single execution at a time helps with Persistent Data integrity. 

 

Regards JC.......

0 Kudos
Message 8 of 23
(276 Views)

@pushkin wrote:

Thank you ThomasHenkel.

With this subject I have to think about the different type of memory involved.  To me these are;

   Program space

   Temporary data space

   Persistent data space.

 

The option of Preallocated Clone Reentrant Execution is a possibility.  The Persistent data would need to be managed separately with a reference to it.  And then you need to be careful about multiple execution colliding with the integrity of the Persistent data.

 

The option of Shared Clone Reentrant Execution is similar to the Preallocate option above.  This has less control of what data is used.

 

The option of Non-Reentrant Execution is the safest.  This is what I use with my initial post which seems to be the best for the situation involved.

Changing the program needs to be performed in multiple locations.  This ensures the mapping to the different sets of Persistent data.  The name of the program also relate to this mapping.  The single execution at a time helps with Persistent Data integrity. 

 

Regards JC.......


I think you missed the point of altenbach’s post. The pre allocated clones will be persistent for each instance. Assuming that you’re only calling the ci once for each datatype then you already have your solution. 

I generally prefer non-reentrant as well and would keep the data at a higher level, likely as part of a class.

0 Kudos
Message 9 of 23
(273 Views)

"Assuming that you’re only calling the ci once for each datatype then you already have your solution."

 

I am not making this assumption.  I want to call the vi multiple times for the different Persistent data sets from different locations.

I generally have multiple activities/executions (with a ctl as a parameter) for the  different Persistent data sets.

 

Regards JC.......

0 Kudos
Message 10 of 23
(266 Views)