robert.berger Posted April 1, 2005 Report Share Posted April 1, 2005 im thinking about using lv2globals to share information between states in a queued message architecture program. which approach would be better to use? reading and writing the entire cluster each time as in example#1 or writing just whats needed each time as in example#2. or if there is a better option i am open to that as well. obviously the cluster items will grow in number as the program matures, so this is a concern as well. i don't want to pass around too much data unnecessarily. Download File:post-981-1112375596.vi Download File:post-981-1112375599.vi Quote Link to comment
Michael_Burgess Posted April 1, 2005 Report Share Posted April 1, 2005 I'm no pro by any means, but surely in any language you shouldn't pass around data you don't need to? I must say, since I discovered LV2 globals they're a godsend! Quote Link to comment
Louis Manfredi Posted April 1, 2005 Report Share Posted April 1, 2005 Hi Robert: I agree with Micheal-- not just from the point of view of moving extra data around, which is a valid concern for big clusters, but also from the point of view that providing the correct values to all the items you don't want to change ends up being a big amount of clutter in the calling vis which can only make your program harder to read (never mind write.) However, for really simple clusters-- say something less complex than an error cluster-- you might want to do things the other way, for the sake of readability. I've done it both ways, but more often the way Micheal suggests. I'm interested in hearing other opinions. Best regards, Louis Quote Link to comment
Michael Aivaliotis Posted April 2, 2005 Report Share Posted April 2, 2005 Well, the approach really depends on what you are trying to do with the data. For example, is the data usually written to all at once all the time? If so then you might want to always write the data in one shot as one cluster. The only time I would write individual values would be if the writing will happen in multiple places in my code. Quote Link to comment
robert.berger Posted April 2, 2005 Author Report Share Posted April 2, 2005 thanks for the responses. the cluster is not written to all at once. most times each state will only read or write two pieces of data from the cluster at a time. i had used a shift register to carry the cluster through the states but thought i would try this aproach this time. it seems cleaner. i just wasn't sure if this was a common aproach used (lv2 global) or i was off on my own. also, i didn't know about the memory usage of the lv2 global versus the shift register aproach i used before. Quote Link to comment
Michael Aivaliotis Posted April 4, 2005 Report Share Posted April 4, 2005 i didn't know about the memory usage of the lv2 global versus the shift register aproach i used before. 4419[/snapback] I would think that the memory usage would be the same since both approaches use a shift register. The only thing I see is a bit of overhead during the conversion process from variant to datatype. Also you have the issue of a call to a VI which takes up very little cpu time but a VI call nonetheless. If this VI will be called from a single caller all the time then I don't see the point. I would prefer to use a shift register in the caller. Like I said before, this would be a good a pproach if this VI is called from multiple callers. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.