11-25-2011 09:38 PM - edited 11-25-2011 09:45 PM
I am trying to copy the position-x property of two cursors from an XY graph to an intensity graph or vice versa. I index through a cursor list to deal with both cursors. I've attached a VI to demonstrate the problem. It works fine going from the XY graph to the intensity graph: Grab either cursor on the top graph, move it, and it moves to the same position in the bottom graph. If you grab a cursor on the bottom (intensity) graph, it works fine for one cursor, but the other curor moves to x=0.
(I should mention, the problem is a bit different after closing and reopening my VI. When I first wrote the VI, the top graph cursors did not respond at all when I moved the bottom graph cursors.)
Solved! Go to Solution.
11-25-2011 10:35 PM
You should not lock the cursor to a plot, especially if the graph does not contain any data. Works just fine with free dragging cursors.
11-25-2011 10:46 PM
Of course it would be much simpler to use a seperate asychronous loop to handle cursor updates like this.
Here's a quick draft. Seems much simpler and it does not clutter up your main state machine. 😉
11-28-2011 09:22 AM
Thanks Altenbach,
Sorry for the slow response--I didn't have Labview with me over the weekend. Sure enough, free-dragging cursors solves the problem. Oddly though, if I switch back to the single-plot cursors, the problem does not reappear! Any thoughts on why your solution worked in the first place? Mostly, I'm glad it worked, so don't expend to many brain cells.
I see you also replaced my double array indexing with an in-place element for the 2nd array. I understand how this works, and I admit I was a little queasy about my approach. But if I'm confident that both input arrays that index a single FOR-loop will have the same number of elements, is it still bad practice for some reason?
(By the way, My original program was a 2-loop QSM. I just reverted to old habits when I put this example together)
11-28-2011 11:26 AM
@bracker wrote:
I see you also replaced my double array indexing with an in-place element for the 2nd array. I understand how this works, and I admit I was a little queasy about my approach. But if I'm confident that both input arrays that index a single FOR-loop will have the same number of elements, is it still bad practice for some reason?
Notice that you got a coercion dot when writing back to the property. Keeping the static properties array in a shift register eliminates that for some reason. The IPE can be replaced by a "index array|replace element" combo, it's just a bit more convoluted.
If the arrays have different size, you might want to wire a 2 to each N of the FOR loops and make sure you are dealing with the first two cursors.
Your graph initially has no data, so cursor locked to a graph will be coerced to the valid data range. At the next run, your graph has data and things will work. One possible workaround would be to ensure that the graph always contains suitable data.