05-08-2019 02:10 PM
Hi,
I'd like to programmatically change control values in a cluster, referencing the controls by index (alternatively by control label). The attached code works, but seems ridiculously complex for such a simple task. I'm sure there's a better way. Any suggestions would be appreciated.
Thanks,
Martin
Solved! Go to Solution.
05-08-2019 02:54 PM
If you don't mind using toolkits, there is one available on VIPM called, of all things, Cluster Toolkit. Many functions available including one to index a cluster by element. I've never had a need to use this toolkit so I can't speak to the quality of the VIs.
05-08-2019 04:27 PM - edited 05-08-2019 04:28 PM
@mdebrecz wrote:
The attached code works, but seems ridiculously complex for such a simple task.
This entire thing just does not smell right. "Coeffs out" is an indicator, so how does it ever gets it's initial values? (and if you would configure the VI to "clear indicators when called", all's lost. Can you explain the logic and use case for all this.
How generic should that tool be? Since the clusters are strictly typed, you might as well do a simple explicit solution that keeps the unchanged output values in a feedback node, for example. Here's one idea.
05-08-2019 04:50 PM
Thanks aputnam! I installed the Cluster Toolkit (thanks Autotestware!), and tried out the "Get or Set Cluster Element". It worked nicely as a drop-in replacement for my clumsy code.
Martin
05-08-2019 05:21 PM
@altenbach wrote:
@mdebrecz wrote:
The attached code works, but seems ridiculously complex for such a simple task.
This entire thing just does not smell right. "Coeffs out" is an indicator, so
Thanks for weighing in altenbach (and I have to agree about the malodorous code ;). The cluster in my actual use case contains about 40 different controls, so I was hoping to avoid having to create a case structure to handle each control (which I should have mentioned initially). The actual program I'm working on is for reading/writing coefficients from/to instrument memory. There is a enum selector for the different coefficients. All coefficients other than the selected one are hidden from the user. The user can read the coefficients to/from file and/or edit them within the cluster. I'm creating an object for each command that is a child of a generic command, so that I can call a generic read or write and override that with the specific coefficient read/write. I'm sending the corresponding control value (as a variant) to the read/write call - thus the need to read/write to the specific controls within the cluster.