LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is a global best in this case

 
Message 1 of 7
(3,305 Views)
Hello everyone

I currently have the following situation: I have one main VI with 7 other VI's I would like to run in parellel. The main VI will bring any one of the other 7 windows to the forefront. Ideally all the VI's will run in parrelel and whichever one is selected will come to the forefront. In the past we attempted to do something like this using a call to another VI, however we found that whichever VI was selected was in fact, the only one running. I think we have fixed this using VI servers.

The main issue is the fact that many of the Front Panels of these VI's will contain common information. The information they display is all generated by a VI without a front screen. Currently we are struggling with a clean way to have one VI generate information and have it passed to several display VI's running concurrently, without actually calling the "display" VIs and using inputs/outputs. Essentially this data is either an array or cluster of boolens. We have played around with using a Que but have had limited success. We have not used Global variables in the past so are not familiar with thier capablities. The amount of data at most is 2 arrays 123 items and a cluster of 5. The program polls our hardware every 5 seconds over the serial port. I do not belive any of these operations are very taxing .

What is the cleanest way to do something like this?

I have tried to be as clear as possible but if I need to clarify please let me know. SOrry about the blank message to start with.'
Thanks
Trent
0 Kudos
Message 2 of 7
(3,306 Views)
A global is probably the most efficient way of solving your problem, since there is no significant memory cost (small data size). As a coincidence, a similar question was posted a few hours ago here...

CC
Chilly Charly    (aka CC)
0 Kudos
Message 3 of 7
(3,290 Views)
You need to be careful with the global variables. If you have multiple programs running simultaneously reading and writing data to the global then there may be race conditions which will give unexpected results. A functional global (also called a LV2 style global) is usually more appropriate. These are well documented on this forum. Essentially you use a non-reentrant vi with an unitialized shift register in which to store the data. Because the shift register is not initialized it will retain the previous value when called again. Because the vi is set as to be non-reentrant race conditions are eliminated. These are almost always better than standard globals.
Message 4 of 7
(3,260 Views)
The plan is to have only one VI write the global and maybe 6 or so read from that global. Is this appropriate for the standard global variable?

Thanks
Trent
0 Kudos
Message 5 of 7
(3,257 Views)
It appears that a global will work in your case, but I still think that it is a good idea to learn to use LV2 style globals. LV2 style globals are considerably more versatile than standard globals. You can include scaling, if desired. You can also write any or all variables simultaneously if the LV2 global is properly structure. All variables can also be read simultaneously. In my opinion this is a considerable advantage over the standard global which only allows for read or write access to a single variable per call of the global.
Message 6 of 7
(3,240 Views)
Hi Trent,

In the very limited case that you have specified, a normal global is OK.

BEST?

Define "BEST"!

I have abondined normal globals in my code. I work with them because I X-shoot other peoples code.

The gotcha's associated with normal globals do not exits with LV2 globals. This is why I use LV2 globals even in the most trivial fo case.

In my experience, it only take the customer about two minutes to figure out how to change a projects requirements such that the normal global causes problems!

So for me "BEST" = works now, and easily adaptable in the future.

I hope this helps,

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 7 of 7
(3,225 Views)