LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to share/update front panel buttons

Solved!
Go to solution

Hi y'all!

 

I'm quite a beginner in LabVIEW (2 years of experience: 1.5 year academic and mentoring a FRC team and .5 professionnaly as a fresh graduate in a startup).

 

We develop an application using LabVIEW that is aimed to be touchscreen friendly and thus we have a lot of front pannel boutton we have deal with. In order  to make the current code more readible and easily scalabe, I'll like to know if there is an efficient way of treating front pannel controls.

 

To illustrate it, let say i have this UI:

 

1.png

2.png

 

The actual way we propagte those controls is by building a cluster of the reference of all those controls (that's where i wish we had LabVIEW 2012 -_- ) an then unbundle the one we need in the appropriate section of code (thats means a lot of wires everywhere...)

 

4.png

 

So are there better ways to acheive the same goal ?

 

Thanks! 

 

Best regards!

Fabrice

--
"If Locals are Duct Tape, then Globals must be toilet paper" Greg Bush
0 Kudos
Message 1 of 20
(7,301 Views)
Solution
Accepted by topic author FabriceMTL
Message 2 of 20
(7,283 Views)

Why do you need to store the references?  Are you going to enable/disable the buttons? 

 

If you only need to know when a button was clicked, use an Event Structure and create a Value Changed event for the button. 

aputman
0 Kudos
Message 3 of 20
(7,281 Views)

Clustering can be your friend here. I could see all the controls on your Front Panel bundling down to 3-4 clusters. Those arrow keys could be one, the ok/cancel buttons another, the buttons on the left as a "menu control" cluster, and the other tab as one big cluster of buttons as well.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 4 of 20
(7,271 Views)

Thanks Ben and James.Morriƽ for your replies.

So in other word building a cluster is the way to go here.

 

How about scalability? If later on we add another tab with a bunch of controls won't I have to make modification on the code later on? i.e. off course I will have to add the new references to the cluster but even if it's a type def, won't my ouput cluster be broken? and thus require  me to go delete and create a new indicator on every subVI where the cluster is used?

Best regards!

Fabrice

--
"If Locals are Duct Tape, then Globals must be toilet paper" Greg Bush
0 Kudos
Message 5 of 20
(7,256 Views)

Hi aputman,

 

This example is not very representative but yes I'll need to enable/disable read/write values etc of the buttons (can be booleans, tables, indicators, controls, etc.) that's why i need the references.

Best regards!

Fabrice

--
"If Locals are Duct Tape, then Globals must be toilet paper" Greg Bush
0 Kudos
Message 6 of 20
(7,250 Views)
Solution
Accepted by topic author FabriceMTL

This is where type-defined clusters come in. Right click your cluster and Make Type Def. This will create a ctrl file that stores the data type of that cluster. When you make subVIs, arrays, whatever of this cluster after you make it type-def, you only need to update the single type-def control for it to update everywhere. When you first make it, make sure to go and replace any clusters you already have because it doesn't automatically update matching clusters with the type-def.

 

This is all helpful if you do really need to bring a cluster of references with you everywhere. Why are you creating this cluster of references?

I see your post above about needing to enable/disable controls. An alternative could be just to use the VI ref and pull all controls when needed.

If you're going to just enable/disable and don't need the specific datatypes, could you create arrays of references instead of clusters? You can use a For loop and a property node to enable/disable an entire array of control refs. The arrays could be built based on your application needs.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 7 of 20
(7,247 Views)

Hi James,

 

The array approached is valid if all we want to do is disable/enable all controls. The elegence of the cluster approach allows the reference to be of the type of the control itself so that when we register a dynamic event against a control in a sub-VI, we have the actual type of the data insead of generic refs.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 20
(7,232 Views)

Ah! Actually making the cluster typeDef was the solution I need for scalability

In my previous attempt my mistake was in the sequence I build the cluster :

 

1-Bundle the reference and create an indicator

2-Copy the indicator and change it to control

3-Replace bundle with bundle by name and connect the control cluster

4-Make the control cluster to TypeDef  (and that's why my output cluster wasn't typeDef)

 

About the use of references, some of the controls (not illustrated in the example) are indicators, controls and graphs too. So it's not enable/disable only but also read/write values etc.

Best regards!

Fabrice

--
"If Locals are Duct Tape, then Globals must be toilet paper" Greg Bush
0 Kudos
Message 9 of 20
(7,213 Views)
Solution
Accepted by topic author FabriceMTL

Another neat trick when you have lots of buttons and you don't want to create an event case for every button is to have a 'catch-all' value change case in an event structure.

 

There are quite a lot of different techniques in this VI snippet which are useful for dealing with lots of buttons:

Events&References.png

 

1) You can statically register for the value change event of multiple controls - as shown above

or

2) You can use cluster to array to get an array of references which you can dynamically register events for (if you're passing the cluster around though, you should use a type-definition)

3) The value change event returns the control reference of the control that was clicked - so you can use this to get the label of the button that was pressed and then based on that perform different actions (e.g. enqueue a command to another loop)

 


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 10 of 20
(7,180 Views)