lraynal Posted April 13, 2007 Report Share Posted April 13, 2007 Hi All. I'm using a reentrant VI (for the first time). I would like some explanation I can't find on the differents existing forums: 1. Why can't we launch the reentrant VI in a for loop (and with the VI icone, not the dynamic call)? I then need to put as many "icone" as I need this reentant VI (see image below): http://forums.lavag.org/index.php?act=attach&type=post&id=5474 2. It looks like it's better to use a Template for a reentrant VI, than a normal VI. Is it correct? What will be the advantage (or disadvantage!) for using a template in this case? Thanks for your explanation! Laurent Quote Link to comment
crelf Posted April 13, 2007 Report Share Posted April 13, 2007 QUOTE(lraynal @ Apr 12 2007, 10:52 PM) Why can't we launch the reentrant VI in a for loop (and with the VI icone, not the dynamic call)? It really depends on what you're trying to do. You're right - I don't think you want reentrancy in this case, but instead a cloned template. Reentrant VIs create a new instance (ie: dataspace) for each place it is on the BD (great if you've got USRs in there keeping some data alive). So, the code in the top of the image you sent will only create one (it's only on the BD in one place = one dataspace copy), whereas the bottom one creates one dataspace for every instance of the VI (meaning that if you put something in a shift register in one instance, it will not be there in another instance). Quote Link to comment
gleichman Posted April 13, 2007 Report Share Posted April 13, 2007 QUOTE(lraynal @ Apr 12 2007, 06:52 AM) 1. Why can't we launch the reentrant VI in a for loop (and with the VI icone, not the dynamic call)?I then need to put as many "icone" as I need this reentant VI (see image below): Because a For loop iterates when all code within the loop completes. It's a the way data flow works. Quote Link to comment
lraynal Posted April 13, 2007 Author Report Share Posted April 13, 2007 Ok for the For loop explanation, which is fair enough, but pretty anoying for me: I will be "forced" to call the sub VI via VI Server, because I don't know how many data will be in my table, so how many subVI I need to launch. But, what's the difference between: cloned template and reentrancy ? In this case my sub VI has got shift register where I store data depending on the instance... I then need reentrancy. What are the advantage of the cloned template, then? It's memory is duplicated as well in as many instances I open this VIt ? same as cloned template... doesn't it ? Quote Link to comment
ragglefrock Posted April 15, 2007 Report Share Posted April 15, 2007 QUOTE(lraynal @ Apr 12 2007, 08:50 AM) Ok for the For loop explanation, which is fair enough, but pretty anoying for me: I will be "forced" to call the sub VI via VI Server, because I don't know how many data will be in my table, so how many subVI I need to launch.But, what's the difference between: cloned template and reentrancy ? In this case my sub VI has got shift register where I store data depending on the instance... I then need reentrancy. What are the advantage of the cloned template, then? It's memory is duplicated as well in as many instances I open this VIt ? same as cloned template... doesn't it ? There are less differences between cloned templates and reentrancy than there used to be in previous versions of LV. Before LV 8, you couldn't view the front panel for a reentrant VI in run mode, and you couldn't debug reentrant VIs. This made template clones the desirable solution for spawning dialogs and debugging. The difference before LV 8 was that template clones were treated essentially as completely separate VIs that happened to have the same source code. Reentrant VIs, however, shared most of their source code and front panel between all the calls. Only their data space was separate. In LV 8 and on, you can view front panels for reentrant VIs and debug them, although I still believe they share some internal memory components. So many of the cases where you had to use template clones you can now use reentrant VIs. I'm sure there's still a scenario where one is preferable over the other. I haven't used templates too much, so maybe someone can chime in with some of their advantages. 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.