08-20-2008 07:26 AM
how can we make a front panel dynamic in such a way that suppose we select a case structure or press a button than the controllers and indicators corresponding to that choice r visible in the front panel not of other options??
can we do this using subvi or any other tool??
08-20-2008 07:49 AM
Hi Juggernaut,
place all controls you ever need on your FP on it. Create a function (or find it in the forum ) to get all references of it. With this references you can show or hide the controls you need. You can do this also in a subvi. Create an array of your references and connect it to your subvi.
Hope it helps.
Mike
07-29-2013 06:54 AM
@MikeS81 wrote:
place all controls you ever need on your FP on it. Create a function (or find it in the forum )
Hi, sorry to bring this old thread back but I can't find how to do that! It would help me reduce the size of my VI block diagram alot and make it more readable if I could pass along a list of references of various controllers to a subVI and change their status there instead.
I've figured out how to pass along a reference to "this VI" and then open a reference to the front panel in a subVI, but the controller-reference's I get from there is an array with the name Controllers[], how can I programmatically choose only those I'm interessted in when I can't get their names?
07-29-2013 07:21 AM
The array named Controllers[] contains all the reference numbers to all the controls on the front panel (I'm assuming in the order you created them). You can create references to specific controllers by right-clicking them and selecting Create -> Reference. The resulting constant looks much like the "This VI". Now, you could for instance build an array of the references you need in the case structure, and as you suggested use a subVI to change visibility.
If many of the controls you have are specific to only one case, you could put these in a "Tab Control" (Front panel pallette -> containers -> tab..."). You can hide the tabs and use a case structure to programmatically set which tab is visible. (Or use the value of the tab control to set which other buttons are visible)
07-29-2013 08:36 AM
@JarleEkanger wrote:
The array named Controllers[] contains all the reference numbers to all the controls on the front panel (I'm assuming in the order you created them). You can create references to specific controllers by right-clicking them and selecting Create -> Reference. The resulting constant looks much like the "This VI". Now, you could for instance build an array of the references you need in the case structure, and as you suggested use a subVI to change visibility.
Thanks for answering JarleEkanger!
I've tried your suggestion but went with using the Bundle (to a cluster) function of a couple of controller's references instead. Then I created a SubVI, and into this SubVI's block diagram I copied a constant of the output cluster (from main VI's block diagram), made an controller out of it and wired it to the SubVI's connector pane. In the SubVI I then used the unbundle by name-function to be able to get a property node of only the interesting controller:
But I'd like to know whether it's possible to somehow access those controlles reference's inside the SubVI itself? (That is, is there a way to create that cluster I'm using in the image above inside a SubVI upon start of Main VI using only a reference to "This VI" or something similar as input?)
07-29-2013 10:02 AM
First of all; your way of attacking this is creating a very specific subVI. It is a general rule that subVIs should be as reusable as possible, so they should just perform a task upon some standardized input. That's why i suggested that you use an array input (but forgot to mention why...).
I've attached a small example of how i would handle this sort of problem. See the attached VIs, the subVI only handles the task of setting visibility on or off. The array input is dynamic in size, as opposed to the cluster, so any size 1D array of control refnums can be passed to it, using the boolean input to determine visiblity setting.
Your other question; yes it is possible to reach the control references from inside a subVI by passing the "This VI" reference to the subVI. But again, you'll have to change the subVI or make a different one for each different set of visible/invisible controls for it to work. Which is why i recommended building an array of just the refnums of the controls you want to set visibility for, and pass it to the subVI.
07-29-2013 11:07 AM
Thanks again for your time and effort! I can definitely understand your point about keeping SubVI's reusable, and I realize your approach is better at setting certain controls visible/invisble.
One of the things I'd like to achieve with setting various controlls properties in a specific SubVI is to increase readability of my code. I'm trying to make a sort of test config wizard that could load up a new configuration window (using default values in all controls) or if an input boolean is true load other values to the front panel and let the user edit those values instead. Check attatched image!
If I have alot of controls I'd have to clog up the block diagram with alot of controler references and I believe that would make it harder to understand the code. Is it possible to achieve this? How would I be able to make references to the relevant controlers inside InitUI.vi in above image?
Thanks again!!
07-29-2013 12:33 PM
As much as I dislike them, Tab containers do have there uses. This is one such case
07-30-2013 05:22 AM
I do use tab controls alot (:
Would it be a good idea to (in the SubVI) use the control property Label.text to match a particular control in Controls[]-array to controller in a calling VI?