LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

use front panel unbundle by name

Solved!
Go to solution

I have a labview program with 8 clusters (bundled by name) of 8-30 front panel numeric controls. The program is made to allow iterations through the various numeric controls, by a set amount. All the numeric control values then get sent on to be written to devices.

 

Currently, when I want to change which numeric control I am interating, I need to go to the backend and change which element is being unbundled by name. I would prefer to have a drop-down menu on the front panel that allows me to select the name of the control to iterate, and never have to go to the back end. Is this possible?

 

-Abe

0 Kudos
Message 1 of 12
(3,549 Views)

I would get the Label property nodes of all of your clusters and write them to the Strings[] property node of a Ring.

Then use an Event Structure to monitor changes to the Ring's value. Then based on the NewVal of the Ring, change the numeric controls of the Cluster selected.

 

 

0 Kudos
Message 2 of 12
(3,525 Views)

If all of the cluster elements are numeric data, with the same representation, you can use Cluster to Array and Array to Cluster, or Type Cast (this works even for clusters containing other clusters so long as the data type is consistent), to convert between an array and a cluster.  As previously suggested, you can retrieve the label of every cluster element (I like GetClusterInfo and GetTypeInfo in the Variant Data Type library for this) and use the strings to populate a ring control.  Use the ring control as an array index to modify the appropriate cluster element.  Here's an overly simplified example, you'll need to do more work for real use (for example, only update the value in the cluster when the value changes, not the index).  As usual the snippet tool made a mess of this, but drag it to a VI, replace the Strings[] property node with an implicit one referencing the ring, and it will be fine.

select cluster element.png

0 Kudos
Message 3 of 12
(3,513 Views)

Unfortunately there are different representation types in the clusters (I32's and Dbl's). I also have booleans in some, but the booleans won't need to be selected or iterated.I'm able to populate a ring and get the value of the selected one to work. However, I'm not sure how to use that to pull out the cooresponding value from the element of the cluster.

 

Nathand, your solution won't work because the elements aren't the same representation. I basically want the "Unbundle by name" function, but with the name as an input.

nyc, do you have any suggestions about how to do "change the numeric controls of the Cluster selected" based on the value of the ring?

 

My code so far is attached. Labview 8.6.1 on XP.

0 Kudos
Message 4 of 12
(3,478 Views)

Could you go into more detail about what you actually want to do here?  Perhaps there's some better arrangement of either the clusters or the user interface that would solve your problem.  What's the goal?  Can you reorganize the clusters so they're homogenous?  What would your ideal user interface be?

0 Kudos
Message 5 of 12
(3,467 Views)

Certainly. That's a fair question.

 

Each cluster of controls is currently a set of variables used for different stages of an experiment I run (see image attached, if interested in what the front panel looks like for the variables). I clustered by stages, and thus have a few different representations in each cluster. Most of my experiments consist of iterating through one of the variables from one stage, and seeing the optimal value. Then I optimize another variable of possibly a different stage, but similarly iterating through a range of values. Currently I need to stop labview, change the variable being unbundled in the backend, and then restart the labview program. I utilize a state-architecture and would rather be able to change the variable being iterated when I put it into "wait" mode. 

 

Some of these variables need to be integers, and some need to be doubles. I could, if needed, move all the boolean controls to their own cluster and that wouldn't be too difficult. 

 

Ideally, I keep the user interface the way I've been using it, with each cluster representing variables for stages of the experiment. Reorganizing to homogeneous numeric type clusters defeats the current design of having each stage represented by a cluster. 

 

Feel free to ask more questions; at this point I'd rather not have to redo the clustering by stage method for the front panel. 

0 Kudos
Message 6 of 12
(3,461 Views)

@ajolson wrote:

nyc, do you have any suggestions about how to do "change the numeric controls of the Cluster selected" based on the value of the ring?



The second part of my answer above talks about Event Structure which tells you what the NewVal of the Ring is.

Then you would wire the NewVal to a Case Statement.

 

Edit: The Event Structure needs to be inside a While Loop.

 

 

 

 

0 Kudos
Message 7 of 12
(3,455 Views)

I'm guessing I'm not understanding you correctly... but do you mean that each possible cluster element would need its own case, and that there would be an unbundle by name for the corresponding cluster element inside each Case statement? That would work, but would require a specific case for all of the cluster elements... I'm hoping for a bit more elegant solution than wiring up >200 cases.

0 Kudos
Message 8 of 12
(3,444 Views)

You wrote that you had 8 clusters.

0 Kudos
Message 9 of 12
(3,441 Views)
Solution
Accepted by topic author ajolson

I think your best bet is an enumeration on the front panel, wired to a case structure somewhere in the backend that pulls out the right cluster element.  It's a bit of work but expresses the goal clearly in the code, and allows you to limit which parameters can be changed.  It will be easy to add or remove parameters later if your model changes.  Any solution that tries to make this easier will require more time and debugging effort to get right, whereas choosing "duplicate case" is pretty easy.

 

Another possibility is that within each stage, you group the numeric values together inside a sub-cluster so you can use the approach I suggested.  You'll still need a case structure to get the appropriate stage cluster and convert the numerics to an array, but it will be many fewer cases.

 

If you really, really need to get into the cluster elements in-place, you could parse out the cluster structure using the Variant Type functions, determine the start offset of each cluster element, then flatten or typecast the cluster to a string, extract the right number of bits at the right offset, and convert to a numeric value, which you would then adjust, convert back to a string, and insert at the appropriate location.  Might be a fun programming project but a lot of work, and if you ever look at it later you'll wonder why someone needed such complex code to do an unbundle/bundle.

Message 10 of 12
(3,439 Views)