From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how get cluster element value change event

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?

0 Kudos
Message 21 of 32
(1,819 Views)

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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 22 of 32
(1,818 Views)

AryOfClusters.JPGThanks.  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.

 

 

0 Kudos
Message 23 of 32
(1,814 Views)

@jpshaw wrote:

AryOfClusters.JPGThanks.  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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 24 of 32
(1,808 Views)

Thanks!  I like that idea.  I will investigate.

Message 25 of 32
(1,805 Views)

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.

Message 26 of 32
(1,778 Views)

@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.

compare.png

Capture.PNG

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 27 of 32
(1,768 Views)

@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.

 

 

0 Kudos
Message 28 of 32
(1,547 Views)

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...)

 

 

AlexElb_0-1699003153075.png

 

also see https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000owfZCAQ&l=de-DE


Proud developer at Hampel Software Engineering where we turn '404 not found' into '200 OK'. Join us on Discord
0 Kudos
Message 29 of 32
(457 Views)

You can register for Cluster element value change through their references.

Yamaeda_0-1699007800807.png

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 30 of 32
(446 Views)