07-11-2013 10:37 AM
Hello.
I'm trying to make a flexible test program, where the user in runtime can specify the amount of action points he/she wants to have, and the program should then adjust the front panel accordingly.
In this case I've added eight action points, with various components (indicator, parameters, comment fields etc).
Firstly, I want to be able to add or remove action points (could solve this having a maximum number placed, and disabling the ones not used, or just by making unused action points invisible).
Secondly, I want to be able to manipulate these using array functions or similar (using an index to a control in a group of controls, rather than accessing the control directly).
A method I've used before is this one:
Here I'm creating an array of references to the LED controls. This way I can just output the reference to the wanted control, and use a Property Node to set or read the value. This method works, but it's very time consuming to set up.
I'm wondering if there's a better, more elegant and less time consuming way to do this. Anybody got any ideas? 🙂
The reason I'm not using an array, is that all the controls get smooshed together on the frontpanel, and I don't have the freedom to place the controls where I want them.
Thanks for any help!
Solved! Go to Solution.
07-11-2013 10:46 AM - edited 07-11-2013 10:57 AM
use a cluster...
07-11-2013 10:50 AM
Thank you. How do I access the controls in the cluster using an index?
07-11-2013 10:52 AM
@OysteinJohnsen wrote:
Thank you. How do I access the controls in the cluster using an index?
Array index then Unbundle By Name
07-12-2013 07:07 AM - edited 07-12-2013 07:12 AM
@apok wrote:
use a cluster...
I tried your suggestion. But I fail to see how this is easier to code, as you still have to make a reference to each control, and you now also have to make an input cluster for the Bundle By Name function. Also, how can you in this case read or write one of the bools with an index, and not chosing it manually in the Unbundle By Name function in the block diagram?
07-12-2013 07:11 AM
@crossrulz wrote:
@OysteinJohnsen wrote:
Thank you. How do I access the controls in the cluster using an index?
Array index then Unbundle By Name
How do I do this? Can you please show an example?
07-12-2013 07:31 AM
What about an array of clusters?
You can pass the array of clusters to a for loop, autoindexed, and unbundle by name on the Active element. Any element of the array whose cluster has Active = False could then be discarded. The array is then as flexible as you wish it to be in terms fo size.
07-12-2013 07:54 AM - edited 07-12-2013 07:54 AM
Here's a quick example of how I would do this. I used Autoindexing of a FOR loop to do the indexing of the array. I can then use Unbundle By Name to get the elements I want. Since it looks like the LEDs are to tell the user what step is active, I also updated that using a local variable of the array, Bundle By Name, and Replace Array Subset.
07-16-2013 03:23 AM
Thank you for all ideas! I ended up with using an array of clusters, as suggested. And it works perfectly (well, more or less)! 🙂 But I'm using an event loop with a "timestamp and trigger" system instead of a FOR loop, to avoid locking the whole program down during each run.