11-03-2017 12:35 PM
Hello all, I have a question about the "style" of programming I am using in LabVIEW. Often I want to pass data and trigger event structures in sub-VIs and then pass data around from sub-Vi to sub-VI via the top level VI. The only way I have been able to achieve this so far is via reference controls and server references. Reading on the forums however, I often read that using controls as a data passing medium is a big no-no. However I have used this style in much larger applications to great effect. I essentially want to know what are the shortcomings of using this style, and is there a better way to achieve the same thing. Please see the attached VIs
Solved! Go to Solution.
11-03-2017 12:52 PM - edited 11-03-2017 12:58 PM
What you are doing here isn't inherently wrong, but that wouldn't be my first choice. (Although sometimes it is unavoidable.) Once you decide to update an indicator in this fashion, you must never update it conventionally or risk race conditions. But in general, it's okay to set properties of a control in a subVI.
In fact, a common method of distributing main VI references to subVIs is to make right-click on each reference, create a constant, and put it in a (typedef'd) single cluster. Bundle the refs to the cluster and you have a cluster of main VI references to pass around! If it's typedef'd, you can add new references as you need them and all the other instances get updated accordingly. The downside to this is that cluster can get monstrous if you have a lot of references to pass around.
11-03-2017 04:13 PM
I would recommend that you do it another way. This way although not wrong per say, will be incredibly slow as you will have a bunch of UI thread switches with all of the references.
The examples folder is your best friend here.
mcduff
11-03-2017 04:26 PM
As a rough ballpark figure, any Property-Node call is about a hundred times slower than writing to terminal/local variables, or using other communication techniques like User Events or Queues. This is not a problem if you don’t make calls too often, but is a bottleneck if you are passing data very quickly.
Another thing you might want to look into is subpanels. Subpanels can be used to “assemble” complex User Interfaces without needing to pass references around.
11-05-2017 07:02 PM
@drjdpowell wrote:
As a rough ballpark figure, any Property-Node call is about a hundred times slower than writing to terminal/local variables,
It is actually in the order of 2000 - 3000 times slower based on my last benchmarks.
Personally, if coming from just a subVI (not a parallel loop), then I just pass the value out of the subVI and write to the indicator's terminal. If it is a parallel loop, I am a huge fan of User Events to send values to the GUI (which should be using an Event Structure already).
11-05-2017 07:04 PM
+1 for user events
11-13-2017 12:36 PM
Hi All,
Thanks for all of your input and feedback. Some pretty useful information. I'm quite interested in this concpe tof User events to operate event structures in subvis. Can some one provide a toy model example or direct me to some good examples?
Thanks!
11-13-2017 12:57 PM
QuantumPenguin wrote: I'm quite interested in this concpe tof User events to operate event structures in subvis. Can some one provide a toy model example or direct me to some good examples?
In LabVIEW: Help->Find Examples. There should be one in there called User Event Generation.vi. It is doing everything in a single loop, but you can get the concepts of how User Events work. You just need to generate an event in your subVI.
11-13-2017 12:57 PM
@QuantumPenguin wrote:
Hi All,
Thanks for all of your input and feedback. Some pretty useful information. I'm quite interested in this concpe tof User events to operate event structures in subvis. Can some one provide a toy model example or direct me to some good examples?
Thanks!
I was going to change your vis to employ that but, you have some learning to do first. Period. Lets Start HERE
If you are not familiar with LabVIEW Projects see LabVIEW Core I and the getting started guides
If you are not familiar with Project Templates Start HERE