LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Questions about where to Unbudle and Bundle

I have been wondering lately, as I clean up some code, how much it matters where clusters are unbudled and bundled. Please refer to these two pictures, and, if you could, provide your opinion. Thanks!

 

Diagram 1

 

Case unbundling.jpg

 

 

Diagram 2

 

VI bundle.jpg

Richard






Message 1 of 15
(3,161 Views)

I'm not sure about the first question though if it is a large cluster I think the first may be more efficient. This is only my opinion though. The compiler may be smart enough to optimize that for you.

 

As for the second question, from a purest point of view you should only pass the data that the VI actually needs. Again, if this is a large cluster you may get extra memory alocations and use much more memory than you actually need. From the viewpoint of "future" proofing your code it may make sense to pass the whole cluster if you think it would be possible you would need to use more elements of the cluster in the future.



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
Message 2 of 15
(3,143 Views)

Agree with Mark on the first question, although it is purely speculative.  At least in the first case it is obvious that you won't be modifying the cluster.  No guarantees that the compiler will track things down inside the Case structure.    Unless it is a monster cluster, I would probably let aesthetics win, and that is a function of how many elements you will be using inside the Case.

 

The lower diagram seems to be asking for an In Place Element Structure.

Message 3 of 15
(3,131 Views)

@Darin.K wrote:

{...} 

The lower diagram seems to be asking for an In Place Element Structure.


Yes, it's perfect for that. Ok then, inside or outside the VI? It just seems to me that putting a big control and indicator in the VI is such a waste of.... buttons and whatnot. Smiley Tongue

 

But all this unbundling from a state machine data cluster gets large (in graphical size). Ideally, I'd like to know where the cut-off point is between esthetics and performance, and I'd like to know how some other programmers feel. I remember one time, one of the heavy hitters said that he had stopped being overly concerned with tiny minutiae performance aspects and was building his diagrams to be elegant and maintainable over and above saving an immeasurable amount of speed and memory. Do my two examples fall into the tiny minutiae category?

Richard






0 Kudos
Message 4 of 15
(3,118 Views)

Seems to me like either works but I want to get into Why this type of question comes up.

 

Data Structure is important.  Its all too easy for us to create a "God Cluster" that holds every variable we need to pass around - even when they are only marginally related.  This leaves us with either a lot of bundle and unbundles or a lot of data copies in modules that should not access the data and the risk that some hack might operate on data in the wrong place because "that Block Diagram had more space" .~~Yes I've heard that excuse~~~

 

Perhaps your Main Engine or your report generator needs access to all of your data (usually, good, modular code prevents this.) and perhaps it does not.  On the rare occasions I have a "God cluster" Iv'e found that compsing it of smaller sub-clusters allows me the ability to keep data out of the wrong hands.  For instance, Proj Data contains sub clusters; user info, station options, parameters, Status ,etc...  my sub vis only get the data they need so when a value goes beserk I know how few sub vis the change can take place in.  Suppose I see that User Name becomes <default> during execution.  If EVERY sub vi gets "God" ANY sub.vi may have an unwired tunnel set to use default if unwired.  I need to check them all.  If I limit data availability to my Action Engine "User AE.vi" I know it did not change any where else.


"Should be" isn't "Is" -Jay
Message 5 of 15
(3,110 Views)

 


@broken Arrow wrote:

@Darin.K wrote:

{...} 

The lower diagram seems to be asking for an In Place Element Structure.


Yes, it's perfect for that. Ok then, inside or outside the VI? It just seems to me that putting a big control and indicator in the VI is such a waste of.... buttons and whatnot. Smiley Tongue


 

With LV10 and onward, you can have your cake and eat it too.  Put the IPE inside the SubVI, and set the SubVI to inline automatically and you get the beauty of the subVI and the performance of dumping it all on the BD.

 

I agree about the minutae, you are usually better off in the long run keeping your code intuitive.  As long as your intuition is reasonable, you are fine, and you can wait for an actual performance issue before diving into crazy tweaks that may make a slight difference.  Most of these tweaks are becoming outdated anyway.  It seems to me that the tide is turning: for a long time we had to do things to improve the compiler's performance, now the compiler is beginning to do things to improve our codes' performance...

 

 

Message 6 of 15
(3,104 Views)

I want to thank those who replied, it’s been helpful and enjoyable. I like the InLine option as Darin suggested. If you want to unbundle inside a VI due to real estate or esthetics, that seems like the way to go.  

 

Speaking of “God clusters” (nice one Jeff), most of my programs have a large amount of configuration data that end up in one of those big honkin’ clusters. I’m speaking of the parameters the user sets upon entering the program but are never modified (i.e. static data). These items will be used throughout the program in a dozen or more states of a state machine and in dozens of VI’s, and in parallel loops. What's your preferred method of dealing with this data? Big Cluster, AE, Global, a batch of smaller clusters, dozens of flat S/R's… ??? I have often thought of putting all the “config data” in a large string, and just carry that one string around and parse from it. What I don’t like about that idea is all the data conversion and typecasting that will have to occur. Any thoughts about the string idea?

Richard






0 Kudos
Message 7 of 15
(3,045 Views)

I don't think you will save much memory between a single large string and a cluster. You will however make the code more obtuse. I would recommend against using the string. I have often thought about the best approach for passing data around and have in the past used a "God cluster" which was a cluster of clusters. Each internal cluster had the data organized in a logical fashion and kept related items together. The "God" cluster was used primarily to provide a single wire through the state machine. Each state would only need to extract/update the data on the cluster that it needed but from a BD standpoint it reduced the clutter of wire. When I bundled/unbundled and I would not show the full name so it looked more like a wire with the single cluster.

 

I have been thinking more about an LVOOP option. A base class could be defined which provided the methods for setting/getting configuration parameters. The derived classes would implement the specific instances of the the data related to the specific configuration data. I would think this approach would use a name to do the lookup for the specific parameter. Some of the methods could include the means to read or write these parameters from an ini file. This approach would work fairly well for defined data types but I'm not sure how well it would work for typedefed data. I haven't had time to investigate this much further than a thought experiment. The one benefit of this is that it would provide a standard method for all of my applications. The downside though is that it might take a bit of BD space since it would require the code to specify the object type it was dealing with every time it acted on the class wire.



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
Message 8 of 15
(3,030 Views)

About diagram 2. The way it's coded is more reuse friendly than to pass the big cluster to the VI.

 

Felix

Message 9 of 15
(3,016 Views)

@Mark Yedinak wrote:

 

I have been thinking more about an LVOOP option.


 

I used OOP in my last large project for the configuration data. Not as fancy as what you propose. Just assessors. The advantages were that it was (and still is) the tidiest configuration code I've ever written (you are obviously forced to unbundle only in member VI's) and I liked the fact that each VI just had that neat box as an input rather than a large cluster. (I'm unsure of the memory impact of passing that class into a VI vs.. passing a normal cluster of equal elements, but I like to think that it's less - it's certainly easier on the eyes). Ultimately, I have written subsequent code without OOP because, at times, I want to see what is being passed to a VI by looking at the top level diagram - i.e., as in Diagram 2 Smiley Happy

 

Richard






0 Kudos
Message 10 of 15
(3,002 Views)