LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to make dyanmic controllers and indicators ,appearnce of controllers and indicator only when a specific case is called

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??

0 Kudos
Message 1 of 9
(2,717 Views)

Hi Juggernaut,

place all controls you ever need on your FP on it. Create a function (or find it in the forum Smiley Wink) 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

Message 2 of 9
(2,711 Views)

@MikeS81 wrote:
place all controls you ever need on your FP on it. Create a function (or find it in the forum Smiley Wink)


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?

0 Kudos
Message 3 of 9
(2,507 Views)

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)

Best regards,

Jarle Ekanger, MSc, PhD, CLD
Flow Design Bureau AS

- "The resistance of wires in LabVIEW is not dependent on their length."
0 Kudos
Message 4 of 9
(2,502 Views)

@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:

 

PN.png

 

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?)

0 Kudos
Message 5 of 9
(2,493 Views)

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.

Best regards,

Jarle Ekanger, MSc, PhD, CLD
Flow Design Bureau AS

- "The resistance of wires in LabVIEW is not dependent on their length."
Download All
Message 6 of 9
(2,481 Views)

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!

vistr.png

 

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!!

0 Kudos
Message 7 of 9
(2,475 Views)

As much as I dislike them, Tab containers do have there uses.  This is one such caseSmiley Wink


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 9
(2,469 Views)

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?

0 Kudos
Message 9 of 9
(2,452 Views)