LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically address indicator using text

I have alot of cells with voltage and a/c impedance indicators on a screen  50+.

 

I need the indicators to change color based on value of the numeric indicator.  

 

I know how to update this by manually setting the background, but I was wanting to write 1 vi where I could pass it the values and it change the color of the specified indicator. 

 

For example, 

 

I use string builder to build the indicator name based on slot number etc...  Slot7-voltage1  is the name of one of my indicators.

 

Slot + 7-voltage + 1 would give mye Slot7-voltage1.  I don't know how to dynamically access an indicator by using text.

 

I've been searching and will continue.  

 

Thanks in advance 🙂

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

You can get an array of references to every control on a panel through a VI property node, then loop through every element of the array, checking if the control label matches the desired value, and if so return that control reference. I don't recommend this approach, though.

 

How are your 50+ indicators arranged? There might be a better way to present your data. For example, if they're in a table format, you can use a table indicator and set the text color and background color of each cell individually. Another option might be replacing your indicator with a cluster of 2 elements - a numeric control with a transparent background on top of a colorbox. You could then write a simple VI that takes a numeric input and calculates the appropriate background color for the colorbox, with a cluster output that you can wire directly to the cluster on the front panel.

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

As Nathan suggested, its not a good idea to have 50+ individual indicators unless there is a good reason for it. Here is the non-recommended approach.

Search for indicator.png


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 3 of 12
(3,391 Views)

Attached is the way I have them arranged.  I have a subvi that I call in the background based on available slots.  I would like to write something to control the background color based on value of the Vdc 0M, AC 0M, Vdc 10M and AC 10M indicators under the individual slots.  

 

Green for pass, Red for fail, maybe even yellow for specific range.  

 

I looked out there for a custom indicator that may have background colors built in but couldn't find anything.

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

Is each slot an instance of a cluster, or does each control stand alone? If the latter, I recommend creating a Slot cluster as a type definition (not-strict), since it looks like they're all identical. Then you can do what I suggested fairly easily: set the numeric indicators to have a transparent background and place a colorbox behind them. Or, alternatively, it will be much easier to get control references with the cluster if you want to set the background color through property nodes. You'll only have to manage a reference to each cluster, from which you can easily get an array of references to all items inside the cluster, and each individual element will always be at the same index for all slots.

 

EDIT: actually, you could even use a strict type definition if you go with the colorbox approach. The "Slot N" button will not be part of the cluster, just place it on top.

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

.aCe. , 

 

I don't suppose you have that snippet of code in 8.6?

 

Thanks

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

It wouldn't take that long to rebuild, some of it isn't needed. You don't need the "This VI" reference, a VI property node will default to the current VI if the input isn't wired. Or, if you're going to turn it into a subVI, then the VI reference should be a control, not a constant. You do not need to close any of the references (although it's not a bad habit to do so). I would check whether the To More Specific cast is successful inside the for loop, and continue looping if it is not.

 

But this is still an inefficient way to handle the problem.

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

Here.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 8 of 12
(3,366 Views)

Thanks a bunch 🙂

0 Kudos
Message 9 of 12
(3,347 Views)

@.aCe. wrote:

Here.


.aCe., 

 

That code works well, but if the indicator is in a tab control, it doesn't find the indicator because it's in the tab control.  I watched the loop, it shows the tab contronl, but none of the contents of the tab control.  I think I am missing one more reference but cannot figure out which one.

 

0 Kudos
Message 10 of 12
(3,301 Views)