LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cluster Array, detect an event from an element of a cluster contained into the Array

Solved!
Go to solution

Hi,

 

I send you my VI in order to give you an idea of whay my cluster array looks like. The array can contain 256 clusters. And in the clusters of the arrray, there is several elements. I would like to keep this kind of structure (array) for my programme. When the user press a button into the arrray from the IHM, I would to know by means of a reference for exemple which was the button pressed by the user. Then with this information, I would be able to treat/calcul the information. However, apparantly it is not easy... I can only know that the values contained into the array have changed, but I don't know which value has changed ... (There is only one value which change at a time).  If you have any solution ... Thank you very much ! 😄 


Have a nice day ! 

0 Kudos
Message 1 of 11
(5,116 Views)
  • Your cluster2 is an indicator, so an event makes little sense.
  • Controls belong inside the loop
  • Your FOR loop will execute so fast that you only ever see the values from the last element.
  • Your boolean never turns false again
  • Your timeout event has no purpose.

Create value changed even on the array and find the changed array element by comparing old and new event node.

Message 2 of 11
(5,089 Views)

Altenbach's suggestion in image form

Snap6.png

 

 

mcduff

Message 3 of 11
(5,083 Views)
Message 4 of 11
(5,081 Views)

To get an "index" of the changed cluster element, convert the value from "changed element" to a boolean array using cluster to array and again search for the truth :D). The resulting index can be wired to a case structure so you can execute different code depending on which cluster element has changed.

Message 5 of 11
(5,076 Views)

@altenbach wrote:

To get an "index" of the changed cluster element, convert the value from "changed element" to a boolean array using cluster to array and again search for the truth :D).


Here is a very primitive example that shows this suggestion. It would be simple to extract the new value of the cluster element using a case structure.

 

 

 

Message 6 of 11
(5,059 Views)
Solution
Accepted by topic author karivotski

@altenbach wrote:

Here's a quick example:

 

 ArrayChangedElement.png


While valid for this Q, watch out for elements added to the array or deleted from the array.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 11
(5,050 Views)

@karivotski wrote:

Hi,

 

I send you my VI in order to give you an idea of whay my cluster array looks like. The array can contain 256 clusters. And in the clusters of the arrray, there is several elements. I would like to keep this kind of structure (array) for my programme. When the user press a button into the arrray from the IHM, I would to know by means of a reference for exemple which was the button pressed by the user. Then with this information, I would be able to treat/calcul the information. However, apparantly it is not easy... I can only know that the values contained into the array have changed, but I don't know which value has changed ... (There is only one value which change at a time).  If you have any solution ... Thank you very much ! 😄 


Have a nice day ! 


If you have fixed size array then you can present the information in a cluster. You still have the option to convert the cluster to an array if that makes it easier to process.

 

By presenting the info as a cluster you can register a single value change event for all of the cluster elements. When the event fires, the event will provide a ref to the cluster element that changed.

 

Just another way to attack the same beast.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 8 of 11
(5,048 Views)

@Ben wrote:
While valid for this Q, watch out for elements added to the array or deleted from the array.

That's why I am hiding the index display, initialize the array to a known size, make it the default value, and match the container size 😄

 

(But yes, we could do an array size on the old a new value from the event data node and add more code if they differ :D)

Message 9 of 11
(5,043 Views)

@altenbach wrote:

@Ben wrote:
While valid for this Q, watch out for elements added to the array or deleted from the array.

That's why I am hiding the index display, initialize the array to a known size, make it the default value, and match the container size 😄

 

(But yes, we could do an array size on the old a new value from the event data node and add more code if they differ :D)


And adding to the previous based on past horror stories...

 

"Right-click Insert before" could be used to put a new element in the middle.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 10 of 11
(5,040 Views)