02-22-2024 05:39 PM
Hello, I have been trying to run the code by @Altenback I found here inside of my main program. I run this file as a subvi, with while loop in the subvi being replaced by my main loop. When I run this subvi and nothing else inside of while loop, everything works fine (first part of the video), but then I put this subvi into my actual main program, it sometimes loses mouse input. When I press on the knob again, it regains input from the mouse, to then randomly lose it again.
How should I go about troubleshooting it? I understand that something in my main loop is slowing it down... I think I have about ~100 ms of delay in my main loop. I see how it makes my knob movement a little bit more choppy, but I don't see how it register mouse button release.
Thanks
https://forums.ni.com/ni/attachments/ni/170/81151/1/TrimKnob.vi
02-22-2024 09:16 PM
All that has to happen is the control loses focus for a split second and that is that.
02-23-2024 09:03 AM - edited 02-23-2024 09:29 AM
I don't think that it loses focus, I've tried setting KeyFocus property to True before the event structure so that the control is always in focus, but it didn't resolve the problem, the subvi must be somehow registering mouse drag end event. I hope there's a simple solution to this, I don't want to write a custom event structure that detects mouse drag, drop, location change, etc.
Edit: When I set execution of this subvi to be user interface and highest priority, this did not solve the problem. However, when I compiled everything as a executable, this resolved the problem.
02-23-2024 11:50 AM - edited 02-23-2024 12:00 PM
@John32d wrote:
Hello, I have been trying to run the code by @Altenback I found here inside of my main program.
First of all, thanks for mentioning my name, but please spell it correctly. Much more important would be a link to the original discussion. 😄
@John32d wrote:
How should I go about troubleshooting it? I understand that something in my main loop is slowing it down... I think I have about ~100 ms of delay in my main loop. I see how it makes my knob movement a little bit more choppy, but I don't see how it register mouse button release.
A knob is an analog style control and can fill the event queue very fast with stale data. You need to limit the event queue to 1 and not lock the panel. (This option was not available back then! read more about it in this idea .).
I also don't understand why you have a delay in a toplevel loop if it contains an event structure. Is this just a wait or a real delay because of complicated recalculations? Can you show us the rest of the code?
(I very strongly advise not to mess with priorities and threads as mentioned. It will make things worse! Also repeatedly setting key focus is not a good idea. You are just forcing yet another tread switch! If it "works" in the executable, that's no guarantee that it is really fixed.)
02-23-2024 03:50 PM
Thank you, sir for your time.
I've made the suggested changes and though the knob runs much smoother, it doesn't resolve the problem. I ended up setting priority to normal and proffered system to user input, without setting focus programmatically, this is the only combination that doesn't cause this problem in the executable (when ran from LabView, I still occurs).
The main loop has delays (stall data flow) to keep TCP Read from immediately executing TCP Write, I don't read the right data from the device then. I thought that TCP buffer of the device should take care of it, but it doesn't.
I appreciate the help.