05-05-2007 08:14 AM - edited 05-05-2007 08:14 AM
my today problem deals with the profused use of template vis in a main vi.
this might be a nugget for novices.
exactly as for a regular vi, template vi (vit) can be used like a reentrant subvi in a main application.
This strategy is usefull when dealing simultaneously with several datasets of identical class. for example, in a recent thread someone asked about how to display a number of arrays, not knowing in advance how many would there be. the main application could open n vit displaying n 1D datasets.
Also, similar to opening and manipulating a subvi panel in a subpanel of the main vi, it is possible to do so as well with vit, as depicted below:
in this example the main vi includes several subpanels, which are empty when the vi is not running. in the diagram, we affect a reference to a single copy of the vit to every subpanel. data can be input to / retrieved from the vit via an invoke node. here is how thediagram could look like:
we create a vit, with the sole purpose to display and allow user manipulation of an array of clusters. of course such vit can support all the usual LV operations
When vi is not running, the subpanels are empty. as the main vi runs, the subpanels get filled with the vit front panel:
it is important to point that every panel now has its own dataset, either programmatically input in the main vi, or user-modified. it is subsequently possible to extract data separately from each subvi template.
notes and questions ( this is why i wrote all this):
* make sure the name of every control is exactly written for programmatically input-output data. even upper case are important.
* update values of variables in the vit before displaying in front panel. this way one avoid confusion about the values of the variables.
* do not forget to close references. it is even advised toforce deallocate memory.
*I do not know how to use the LV8 version of "flatten to string". how to i get the type descriptor?
*in LV7.x, one could hide the scrollbars of the subpanels. not anymore in LV8. do i miss something?
*now is my real problem. in my application i open about 20-30 such vit copies in subpanels. in LV7.x i never had any problems with it. as i upgraded to LV8.2, a bug appeared:
most of the times when i fill the vits with data i can look at their panel with updated values of the variables. however, sometimes (about 30% of cases) the first vit would not get filled with updated data from my main application. in about 5% of cases even the second subpanel would not get updated. meaning, the vit front panel would appear, but not with the data i programmatically input. anywone has an idea?
dont forget to rate if you liked it! and especially i would like suggestions to make my applications better.
Message Edited by Gabi1 on 05-05-2007 08:16 AM
05-05-2007 11:30 AM
It would really help if you could also attach e.g. a zip file containing your code so we can actually play with it. 😉 I am confused about quite a few things, so playing with it would help me get started.
Just looking at the posted code image on top, it can be simplified quite a bit:
05-05-2007 01:48 PM - edited 05-05-2007 01:48 PM
Message Edited by Gabi1 on 05-05-2007 02:02 PM
05-05-2007 01:52 PM - edited 05-05-2007 01:52 PM
Message Edited by Gabi1 on 05-05-2007 01:53 PM
05-05-2007 02:12 PM
Hello Altenbach,
thanks a lot for your comments. i made a long response, but somehow it got erased...
Anyway, in this example i use flat sequence only to show the steps to do for using vits in this configuration. it is common to use a loop for input output data from those vits, then the reference is only opened and closed once, at beginning and end of vi.
you are right tough about the cases, and i attached a better version of the example vi. about wiring the error terminals: i am not a big fan of it actually, because except in debugging hte kind of add wiring a lot, and in evolved programs this makes the picture messy. dont get me wrong tough, they are vital for debugging.
about what the post is: i dont pretend to make good nuggets, but i did not saw anybody use this feature. i tought then to share it. in the same time, to get new ideas on improvements and bug fixes. i like your ideas and trics. give me some!
05-05-2007 03:55 PM
05-05-2007 06:57 PM - edited 05-05-2007 06:57 PM
@Gabi1 wrote:
...about wiring the error terminals: i am not a big fan of it actually, because except in debugging hte kind of add wiring a lot, and in evolved programs this makes the picture messy.
Message Edited by altenbach on 05-05-2007 04:57 PM
05-06-2007 02:28 AM
05-06-2007 02:39 AM
Jarrod,
very nice way. i am still learning all the whay how you do it. when i master it i see what i can do with. might be usefull for expandable systems...
05-06-2007 02:28 PM