08-13-2008 10:21 AM
I have a front panel with a 2D arrays control (exemple: X=4, Y=16).
When I change a value inside this array, I use a "value change" event, and I would
like to know the indexes of the value which have been changed.
How can I do this ?
Francis
08-13-2008 10:57 AM
08-13-2008 11:00 AM - edited 08-13-2008 11:04 AM
For a 2D array, you could user Gerd's solution of comparing the two arrays (by element), converting the 2D boolean array to (0,1), then use "array max". The max index gives you an array with two elements, corresponding to the 2D indices of the changed element.
Since you are using an event structure monitoring FP activity, only once element will be changed per event. If the VI cannot handle the event immediately, several events will get queued up, one per changed element. 🙂
If you also plan to change element using a value(sgnl) property, several (or zero) elements could have changed, so you would need to handle these cases with a bit more code. 🙂
08-13-2008 11:08 AM
You can also track the index you are changing ( however we always know it 🙂 ) at some indicator,and add indication
of it change to the event handler that handles the change of the array.
08-13-2008 11:14 AM
mishklyar wrote:You can also track the index you are changing ( however we always know it 🙂 ) at some indicator,and add indication
of it change to the event handler that handles the change of the array.
Sorry, I I have idea what you mean. can you attach a small example?
(If I understand the problem correctly, we are talking about an array control on the front panel and we are trying to determine which element just got changed by the operator.)
08-13-2008 11:31 AM
Hello altenbach,
May be something like this..it is 1D array for simplicity 🙂
Regards,
Michael
08-13-2008 11:45 AM
Well, Yes. If the array is resized to only show one element, this will work.
In the general case, the array is resized to show multiple elements, so this will only give you the element that currently shows on the upper left corner of the scrolled array, it does not indicate which element has been changed.
08-13-2008 12:10 PM
08-14-2008 03:11 AM
Thanks a lot to everybody who answered.
I used the solution proposed by GerdW and Altenbach (make a compare and find the max of a boolean array) and this
perfectly adapted to my need (see vi atached)
Thansk again
Francis
08-14-2008 10:03 AM - edited 08-14-2008 10:04 AM
A few minor comments: