09-11-2017 09:50 AM
How do you create an event for each cluster element? I have an array of clusters. I would like to know if a button is clicked in a particular cluster. How do I get to that button?
09-11-2017 10:03 AM
You can not configure an event for a particular element of an array.
You could configure the event for a value change of the array, then do a compare of the old and new to decide which element in the array changed and then determine which element in the cluster changed.
Now if you used a cluster of clusters on the FP instead of an array...
You could configure an event for an element in all of the clusters.
Pick your poison, use and array and do more coding or switch to a cluster of clusters and let LV tell you which one changed.
Ben
09-11-2017 10:12 AM
Thanks. That's what I figured I would have to do. I don't know that I can create a cluster of clusters because the number of lines is dynamic.
09-11-2017 10:19 AM
@jpshaw wrote:
Thanks. That's what I figured I would have to do. I don't know that I can create a cluster of clusters because the number of lines is dynamic.
If you can specify a max number of elements you can create a cluster on the GUI that is large enough and then hide the ones that are not valid.
Just trying to make your job easier... if there is a chance!
Ben
09-11-2017 10:23 AM
Thanks! I like that idea. I will investigate.
09-11-2017 01:46 PM
A couple of things. First a solution to the question about cluster value changes. Here is a post I made where there are an array of clusters and you want to know what element in what cluster changed value. In this case we were looking to find which button was pressed, but the point is that you can use the New and Old value, performing a Not Equal, and detect what element in the cluster had the value change.
Secondly having an event structure inside an event structure is a bad coding practice. Even NI R&D had put serious thought into limiting each block diagram to only having one event structure since so many new developers were shooting themselves in the foot and abusing it. There are also VI Analyzer tests to help find VIs that have multiple event structures, as well as a few other event based pitfalls.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
09-11-2017 02:50 PM - edited 09-11-2017 02:52 PM
@Hooovahh wrote:
A couple of things. First a solution to the question about cluster value changes. Here is a post I made where there are an array of clusters and you want to know what element in what cluster changed value. In this case we were looking to find which button was pressed, but the point is that you can use the New and Old value, performing a Not Equal, and detect what element in the cluster had the value change.
Secondly having an event structure inside an event structure is a bad coding practice. Even NI R&D had put serious thought into limiting each block diagram to only having one event structure since so many new developers were shooting themselves in the foot and abusing it. There are also VI Analyzer tests to help find VIs that have multiple event structures, as well as a few other event based pitfalls.
To elaborate on the emphasized point above, if the clusters are the same - and this would definitely apply here - an EQUALS comparison will yield a cluster of Booleans with the same structure as the clusters being compared. Any Boolean that is FALSE tells you the corresponding value has changed.
04-02-2019 09:54 AM - edited 04-02-2019 09:55 AM
@altenbach wrote:
What I sometimes do is compare old and new from the event data node using "not equal", convert the resulting boolean cluster to a boolean array (cluster to array) and search for the single true element (search array). The resulting index (typically wired to a case structure) will give you the element position in cluster order.
I have tried performing the same comparison myself but I do not know what you mean by "convert the resulting boolean cluster to a boolean array" Do you have a boolean cluster that you are checking for a change?
How would you go about finding the changed element if you are comparing against a cluster that has multiple data types e.g, string, string, boolean? Inside a 1d array.
11-03-2023 04:20 AM
Sorry for commenting an old post, but since no answer was marked as solution and the question might come up often, the following picture might help to handle changed cluster elements. (Array of cluster is a different question...)
also see https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000owfZCAQ&l=de-DE
11-03-2023 05:36 AM
You can register for Cluster element value change through their references.