LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to control multiple property nodes with a Boolean without cluttering schematic (other than using local variable)?

Solved!
Go to solution

Code is attached. 

 

What I want to do here is to display indicators corresponding to number of units that the user selects. If user selects 1, only show one, if 3 then 3, etc. 

 

In my code I have 3 indicators only, but in reality I would have about 30 of them, so dragging a wire across the schematic would definitely create a rat's nest. I could use local variables instead, would this be a good solution? Is there way to simplify it even further?

Thank you

0 Kudos
Message 1 of 5
(591 Views)

There's not a whole lot you can do when it comes to initializing controls and indicators with property nodes .

 

Using a Sub-VI and references helps a little bit. Setting your indicators and controls to NOT view as icon helps too

 

I did a quick highlight and create sub-vi here to give you an idea.

 

sub1Capture.PNG

 

 

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 5
(565 Views)

All you might need is an array where each element is s cluster  cluster of a boolean, string, and numeric. Then just adjust the array and container size.

 

(Not sure why you have a greedy loop and all these coercion dots. Your indexing makes no sense. Did you know that "index array" is resizable? Your cases differs only by a diagram constant, so that's all that needs to be inside the case!)

0 Kudos
Message 3 of 5
(558 Views)

Here's a quick draft to get you started.

 

altenbach_0-1696608190115.png

 

altenbach_1-1696608223117.png

 

 

0 Kudos
Message 4 of 5
(549 Views)
Solution
Accepted by topic author John32d

Edit: Dang, shouldn't have made such a long reply, y'all beat me to it. I guess "How do I make my code more compact" questions are like dangling a string in front of a cat 😉

 

 

You can simplify your code quite a bit. The "Index Array" function can be expanded by clicking the bottom and pulling down, and if you don't wire "Index" then it defaults to 0, 1, 2... etc.

 

So you can remove all of the math constants, subtractions, and all but one Index Array node to get the following:

 

BertMcMahan_0-1696607927620.png

 

(The only thing left in the other case structure cases are the other boolean array constants).

 

So, that's a start. But we can do better! Since you have three elements that are always clustered together... you can use a cluster to combine them! Now, we can see:

hide_unused.png

 

From 3 wires per entry to 1, or from 9 total to 3. Much smaller! But... we can do better still!

 

Property nodes don't need to be statically linked to a single item. Right click the property node and select "Disconnect from control". Now, the node gains a "Reference" input. Right click on your control and click "Create reference" and now you can wire that reference to the input to the property node. This lets us put everything in a loop and get rid of Index Array. We can also use some math to get rid of the need for boolean array constants, so you can get to the following:

 

hide_unused.png

 

Much better! Plus, now all you have to do to add a new control is to make the reference for it and stick it on the end of the array. No need to make boolean array constants for each one.

 

(A couple last points- first, I know this is an example, but it would be much better to have an event structure in there that activated on Value Change on Numeric0. Right now the loop runs about a million times a second, which eats processor power for no reason, but I didn't want to muddy up the example with event structures.

 

Second, I don't know exactly what your application is, but you say you had 30 potential indicators. This sounds to me like you could be using an array of clusters (assuming all "on/off groups" are identical. In that case you could pick the number of elements in the array, change how many are visible, etc. but that might be too big of a deviation for now.)

Message 5 of 5
(542 Views)