LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Globals to pass Control References

I'm using Globals to store Control References in order to pass them between vi's. My application (a Data Visualization software package) requires sub-vi's to pass control references to eachother, and up to higher vi's. I will be building an executable in the end, and I am wondering if this is a good/safe method of handling Control References, or if I should keep looking for another way?
0 Kudos
Message 1 of 4
(2,944 Views)
I tend to shy away from globals. You could wrap your GUI state in a GOOP object and keep your control refnums there; then you can pass the GOOP refnum among your VIs on the connector pane instead of using globals.

Another approach might be to use queues instead of control references for communication between VIs. So instead of passing around a boolean control reference so other VIs can light up an indicator, you could pass a VI your own custom message in a queue: 'Machine status: running' or something. That way, if you decide to replace the boolean with a string status bar or a picture ring, you won't have to search through your whole program for all the places where you used that global.
Message 2 of 4
(2,944 Views)
I am passing Control References of graphs and tables with large amounts of data in each (10's of thousands of data points). The goal is not to repeat the data (i.e. variables storing the data in order to pass it around).

Also, when the user interacts with 1 vi, this may trigger analysis on data based on data from other vi's, as well as trigger analysis on other vi's. Many of these data fetching (SQL, and binary file reading) and analysis routines are very time consuming, I therefore wanted to move the processing to hidden vi's (in my case, the top level vi) so the user's screen would not freeze during the processing time (as it would if I had all vi's call a common "Processing" sub vi.)

I use Queue's extensively in the software, and had considered
passing control references in queues, but I wasn't able to re/associate the properties with the reference after it was passed (especially the Value property of multi plot XY Graphs). Globals, although "Bad Form", seam to have all the functionality I'm looking for, but I'm afraid that I may end up with a very unstable product (much like typecasting error clusters into strings, and passing them in queues in LabVIEW 6.0, works great, until you build it!).

Any insight or safer methodologies would be greatly appreciated.
0 Kudos
Message 3 of 4
(2,944 Views)
If you store your refnums in a GOOP object, they can be the exact same strictly defined refnums you're keeping in the globals, so (for example) the Value properties will be the same as the control, instead of being in a refnum.

If you use a queue to pass refnums and you're concerned about the types of the refnums being "not quite right" (some properties missing), you can use the "To More Specific/Generic Class" nodes to coerce the refnum to the correct type.

But if you're just using control refnums to grab data inside other VIs that do your processing, my understanding is that it's much faster just to pass the data itself.

The model I typically use to insulate intensive processing from the user is to create a GOOP object and pass in the dat
a. All my "slow" VIs are called dynamically, so that control immediately returns to the user. That way, my processing VIs don't typically need control refnums (though I do use control refnums in GUI-related subVIs).
0 Kudos
Message 4 of 4
(2,944 Views)