04-19-2013 11:55 AM - edited 04-19-2013 11:55 AM
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 🙂
04-19-2013 12:52 PM
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.
04-19-2013 12:58 PM
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.
04-19-2013 12:59 PM
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.
04-19-2013 01:05 PM - edited 04-19-2013 01:07 PM
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.
04-19-2013 01:18 PM
04-19-2013 01:23 PM
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.
04-19-2013 01:27 PM
Here.
04-19-2013 03:03 PM
Thanks a bunch 🙂
04-24-2013 08:51 AM
@.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.