LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to share/update front panel buttons

Solved!
Go to solution

Oh wow great trick indeed Sam_Sharp! Thanks alot!

 

That will definatly cleanup a lot the code as actually we have a long list of event structure case.

Thanks again that was actually another aspect I add to improve on the code.  

 

You answered an unasked question! Smiley Wink

Best regards!

Fabrice

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

That is a nice example Sam, and I will probably make use of it soon. Just curious, is there some way to make it so that the corresponding action does not rely on the control label?

 

I am just thinking sometimes I change labels like if I originally think I just need a "Voltage" indicator, and later decide I want "Avg Voltage" and "Instantaneous Voltage".

0 Kudos
Message 12 of 20
(2,526 Views)

There is a property of each front panel control called "UID". This value doesn't change once you've created the control. Each element in a cluster also has its own UID.

 

The UIDs aren't very human readable as much as the labels are, but they're consistant.

Cheers


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

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


Message 13 of 20
(2,516 Views)

In the past couple of years, I wrote something very similar to Ben's GUI manager using LVOOP. That method is very flexible.

 

To update my controls, I used control indexes. That requires some forethought and supporting infrastructure, though. I traverse the UI at launch, gather and cache all refs and control indexes, and then conditionally access and update them as needed. It works beautifully and updates very efficiently.

 

Maybe this will be helpful? Maybe not.

Message 14 of 20
(2,500 Views)

This is a very good thread. I'll have to remember this the next time I have a bunch of controls to manage.

0 Kudos
Message 15 of 20
(2,479 Views)

Hi Mr_Jim, when you say you used LVOOP for the GUI manager do you mean your references are stored in a LabVIEW class? 

Can you do a very quick and simple example showing it?

I am also learning LVOOP as I learn more advance functionality of LabVIEW and I am very interested in hearing more about OOP.

Best regards!

Fabrice

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

Hi Lawats,

 

> when you say you used LVOOP for the GUI manager do you mean your references are stored in a LabVIEW class? 

 

Spoiler
Oh man, I'm revealing my secrets now.

 

Yes. What I did was make a UI manager class that is generic to any UI:

  • At initialization of the application, I provide a VI reference belonging to the UI.
  • Then I run a method that recursively traverses the entire UI once, including tab controls.
  • Within the above method, I cache the references and control indexes, storing them by label text. (You could use something else if you wanted to)
  • When I need to perform enabling and disabling, perhaps several SubVIs deep, I can quickly retrieve the cached references using an efficient lookup table. (Be careful with this - it can get ugly if you overuse it)
  • I also used the references to register dynamic events the way SAM did. This works really well when you have dozens of controls that do the same thing. Just name them "Widget_1" ... "Widget_2" etc. Then parse out the number in the event handling to figure out which item the front panel control goes to.
  • For updating values, control indexes work very well because you can easily add logic to only update items that have changed.
  • You can also reference control indexes in groups, again if you have a whole lot of controls that do the same thing and are numbered. ("Widget_1" ... "Widget_2" etc)

Now, all this being said, this can have a "black magic" feel to it because it bypasses dataflow. It's very efficient, though, provided you handle your references with care.

 

If you encapsulate everything inside a UI manager class, though, it makes usage pretty simple.

0 Kudos
Message 17 of 20
(2,444 Views)

Hi Mr._Jim,

 


 

  • Within the above method, I cache the references and control indexes, storing them by label text. (You could use something else if you wanted to)

 

I can't seem to get a hold on Set Control Values by Index Function . I'm using LabVIEW 2011, can this limited to a more recent version?  

Best regards!

Fabrice

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

Looks like you are correct, your 2011 LV won't include this VI unfortunately.

 

Here's the palette documentation for 2011.

Here is is for 2013.

Cheers


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

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


Message 19 of 20
(2,408 Views)

Ah, yes. Control indexes are a fairly recent (and not well-known) feature.

 

Sorry about that...

 

Well, you could still cache control references, anyway.

0 Kudos
Message 20 of 20
(2,396 Views)