LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How "local" are Local Variables?

Solved!
Go to solution
Solution
Accepted by topic author RTSLVU

Hello RTSLVU,

 

This depends on how the subVI is dispatched- if it's non-reentrant or shared-clones and the sub-loops you've described exist within the same application context, then yes, the history will (read-can and probably will at some point) be mangled.  You can address this by setting the subVI to use preallocated clones in File>>VI Properties>>Execution.

 

Redesigning this component sounds like a good idea at this point, though.

 

To clarify and better address your initial question: Local variables will only ever be shared within the same copy of a subVI.  The question here is how many copies exist and whether or not they are being shared between different parts of your calling application.  The default operation of new VIs is to be non-reentrant (only one copy exists) and in this case any history in the subVI will be shared/commingled.

 

Regards,

Tom L.
0 Kudos
Message 11 of 22
(1,979 Views)

Here is a couple screen grabs of the block diagram showing V_WFM being used by the three loops simultaneously.

 

Hopefully this will make my original question clearer?

========================
=== Engineer Ambiguously ===
========================
Download All
0 Kudos
Message 12 of 22
(1,976 Views)

@RTSLVU wrote:

Here is a couple screen grabs of the block diagram showing V_WFM being used by the three loops simultaneously.



Yes, if the three instances of the subVI should all keep their own dataspace, you need to simply make the sub-VI reentrant.

0 Kudos
Message 13 of 22
(1,948 Views)

@RTSLVU wrote:

Here is a couple screen grabs of the block diagram showing V_WFM being used by the three loops simultaneously.

 

Hopefully this will make my original question clearer?


OUCH!

 

You can be glad the contractor is long gone.  (I might know the name though....are the initials S.B.?  no relation!)


"Should be" isn't "Is" -Jay
0 Kudos
Message 14 of 22
(1,925 Views)

I finally got some time on the equipment.

 

I am happy to announce I was right. 

 

Using the same sub-vi with the same local variable "local array" in three loops simultaneously was causing the data in "local array" and therefore the displayed data to be a conglomeration of all three loops data, making all three graphs identical after a few iterations.

 

Smiley Happy

 

Now I have a ton of cleanup to do including a good 100 local variable instances X3 to get rid of.

 

As I said before I am not being paid enough.Smiley Mad

========================
=== Engineer Ambiguously ===
========================
Message 15 of 22
(1,893 Views)

I didn't look at the code, but it's likely that if you make that subVI re-entrant and set it to pre-allocate clones, the problem will go away. You may still want to re-write but perhaps that will get it up and running sooner. A reentrant subVI keeps a separate copy of all its controls and indicators for each instance, so the local variables will all be independent.

0 Kudos
Message 16 of 22
(1,880 Views)

WOW, just when I thought I had see everything I ran across this little gem in a sub-vi.Smiley Frustrated

 

Consumate Strings.png

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 17 of 22
(1,850 Views)

@RTSLVU wrote:

WOW, just when I thought I had see everything I ran across this little gem in a sub-vi.Smiley Frustrated


No, it should use "build path" instead. This current code will instantly break on any other OS.

You should use concatenate on the file name only.

0 Kudos
Message 18 of 22
(1,840 Views)

There's also the Array of strings to path, which seems like a good idea in this case.

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 19 of 22
(1,819 Views)

@RTSLVU wrote:

 

[...]

 

My company is not paying me enough.Smiley Mad


Apparently, they are. 🙂

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 20 of 22
(1,803 Views)