LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use two copies of a functional global variable

I have to programs that communicate with each other over the network and share many functionalities. Configuration data is stored in FGVs and read where needed. Some of the FGVs are identical in content, so I could use the same subVI (and the VIs that use it) in both programs. The problem is of course that the FGV is shared between both programs as long as they are on the same computer (which is where developement is done). Is it somehow possible to use the same FGV-SubVI but create a separate instance for each program?

0 Kudos
Message 1 of 8
(5,049 Views)

Yes, you can change the VI's property to re-entrant.  That will cause the VI to maintain its own memory space.  File > VI Properties then the Execution category.  You may want to read the help on the clone options if you have those options in your version.  Hint:  You want the pre-allocate option for your FGVs.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 2 of 8
(5,044 Views)

I doubt you want to make the FGV reenetrant.  That would likely counter act the reason for the FGV.

 

I think if you have the two programs in different projects (LabVIEW projects), the execution namespaces should be different.  But I haven't tried doing this with two projects pointing to the same file.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 8
(5,037 Views)

How would that work? As far as I understood reentrancy then every call has it's own state (even more if preallocated). If I read a config file at the start of the program and write the parsed values into a FGV and later in another part of the program read that FGV, even if it's the same subVI, it's not the same subVI call, so it wont have the values written into it.

0 Kudos
Message 4 of 8
(5,036 Views)

LabVIEW works based on VI Names. I see two possible solutions:

 

-Create and rename a copy of the caller VI as well as the FGV. Since the copy will have a different name they will use different parts of memory

 

-Create a copy and place it into a project library (*.lvlib). All members of project library run in a different namespace so they will use different parts of memory

 

More Information on project librarys can be found here:

 

Sharing Code with the LabVIEW Project Library

http://www.ni.com/white-paper/4067/en

 

Regards!

Moritz M.

0 Kudos
Message 5 of 8
(5,003 Views)

-Create and rename a copy of the caller VI as well as the FGV. Since the copy will have a different name they will use different parts of memory

That's pretty much what I've got right now. I have two FGVs and VIs calling them, although the datatype and functionality is the same. I know, if you want to reuse code you normally pass the parameters that are depending on the call from the outside. But that's one of the reasons I used the FGVs in the first place. Often there would be the need to get a parameter from the toplevel VI to the "deepest" subVIs, causing wires through all VIs just for that. But you've seen that anyway I guess.

0 Kudos
Message 6 of 8
(4,978 Views)

Another possible way you can tackle this problem is to use a FGV that supports multiple items. Since your data is the same you could use a variant attribute list, or an array, to store the individual elements. Use a name to access the data you are interested in. Variant attributes work very nicely in this regard since it handles all of the lookup activities for you. This way if you need to modify your FGV you do not have to propagate the changes to all the copies. You only use one.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 7 of 8
(4,965 Views)

I have handled this in 2 ways-

1.  make a master reentrant copy, then make template wrapper and make multiple wrapped versions.  Can be a pain to maintain.

2.  use OOP and make a class you can put the class inside of a FG and have many instances of the class.

3.  if the FG is only used in one place in the code per instance than a reentrant is ok.

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 8 of 8
(4,954 Views)