Jump to content

which is better to use


Recommended Posts

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

Link to comment

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

Link to comment

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.

Link to comment

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.

Link to comment
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.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.