09-26-2006 08:11 PM
The attached demo (LabVIEW 8.20) shows one solution attempt that actually works pretty well: Skip the recalculation unless the cursor position from the event terminal is equal to the cursor position of the graph property node. This basically races through all unecessary intermediary recalculations on stale positions. However, the code can get complicated very quickly if there are multiple cursors.
Solved! Go to Solution.
09-27-2006 12:37 AM - edited 09-27-2006 12:37 AM
Message Edited by TonP on 09-27-2006 07:38 AM
09-27-2006 01:38 AM
Thanks Ton, interesting idea but needs some adjustment. 😉
The major flaw is that there is no guarantee that the very last cursor position causes a recalculation. Since queue elements are randomly thrown out. My example is designed that the curve must intercept the baseline (y=0) at the cursor position once the cursor is released. If I implement your code, the cursor often does not coincide with the location where the curve crosses zero after I release the cursor.
However, I think the following modification will solve this problem: Remove the "flush queue" after the "dequeue" and insert in in front of the "enqueue" operation instead. 😄
(My real program is much more complex and has about 4 graphs that all need to get updated as the cursors are moved and all the calculations take place in the main loop. I would prefer to keep all graph terminals in one loop.)
09-27-2006 08:22 AM
HIi Christian,
The Event structure will return the Time of the event.
If you compare the time with the tick clock you can ignore any event that happened more than (?) 1 second ago.
I hope that helps,
Ben
09-27-2006 10:18 AM - edited 09-27-2006 10:18 AM
Message Edited by TonP on 09-27-2006 05:18 PM
Message Edited by TonP on 09-27-2006 05:20 PM
09-27-2006 11:24 AM
@TonP wrote:
But what about using the cursor grab event, and then periodically poll the position of the cursor (and use Cursor release to stop polling)
09-28-2006 07:50 AM - edited 09-28-2006 07:50 AM
Message Edited by DFGray on 09-28-2006 07:53 AM
09-28-2006 02:42 PM - edited 09-28-2006 02:42 PM
As you can see, it works extremely well: 🙂
NO shift registers, extra loops, queues, tuning parameters (min times, etc.), etc.etc.
Just a deceptively simple "equal" followed by a case structure.
The demo shows a typical recording if I quicky move the slide up and down, then release it. You can see that the raw event structure takes more than 40 seconds to stabilize while my selective solution follows the slider position almost perfectly despite the 500ms stall in each update.
See for yourself! Can anyone think of a drawback of this method? Even if the slide terminal is not in the same loop, a comparison of a local variable with the newval should do the trick just fine.
Message Edited by altenbach on 09-28-2006 12:43 PM
09-29-2006 05:30 AM
I have done this in the past, only in my case the event case registered value change events for several controls. Looking at the code, I see I used the CtlRef terminal to get the Value property of the control, but that I added a small wait before getting it. I don't know if that was a precaution or if I did it because the values didn't always update immediately (that specific bit of the code was written in a hurry, because it was only discovered that this caused some annoying UI delays when we were at the actual site, so I guess I never got around to putting in a comment about it).
@altenbach wrote:
See for yourself! Can anyone think of a drawback of this method? Even if the slide terminal is not in the same loop, a comparison of a local variable with the newval should do the trick just fine.
09-29-2006 08:13 AM