Re: sampling rate problem
- From: "Karl Uppiano" <karl.uppiano@xxxxxxxxxxx>
- Date: Fri, 10 Nov 2006 21:37:19 GMT
"wanwan" <ericwan78@xxxxxxxxx> wrote in message
news:1163191311.122185.46730@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
First, this is a threading nightmare.I don't need the mouse positions to be precise to the pixel. I wrote
You need to syncronize so that your reading of mousepos_x and
mousepos_y is atomic. Also, there is no guaranty that your other
thread's data will be accessible to this thread unless you syncronize.
this class strictly for the purpose of data collection. Data analysis
is not done in real time.
It would ALSO probably be better for you to use the Timer class,Since I made the mouse sampling class a thread, it is doing something
instead of busy-waiting.
independent of the rest of the software (I am writing a GUI). So I
thought it'd be same idea as Timer class
The other suggestion I have for you is to instead use temporal eventWhat is a temporal event? It sounds like interrupt vs polling in asm.
based updates (calculating the change in time from the last position),
rather than polling every n milliseconds.
But what in Java can achieve the interrupt effect?
The real question I have for you is, why do you want to sample mouseIt is a software used for engineering research purposes
movement at all? Is it for some sort of macro? Just an excercise?
Something else that could be done using standard libraries instead of
writing your own sampling method?
Well, hope the suggestions help, good luck finding the right way.Thanks
Since it is unlikely that you will ever get exact timing from sleep or timer
facilities in Java (they make disclaimers about precision and accuracy), it
is better to turn the problem on its head. You get mouse move events from
the system. Check the system time when you get the event, and calculate the
time between events.
I had a similar problem getting accurate timer delays while measuring wind
speed in a weather application that I wrote. I finally realized that I could
use the timer to provide reasonably periodic wake-up events, but I needed to
determine the actual interval since the last event and calculate the wind
velocity using the measured time interval. This works even when huge delays
due to other applications bogging down the system (which can cause delays of
several seconds in some cases). I wrote an article about it - want to read
it? Here it goes: http://mysite.verizon.net/Karl_Uppiano/winddata.html
.
- References:
- sampling rate problem
- From: wanwan
- Re: sampling rate problem
- From: Daniel Pitts
- Re: sampling rate problem
- From: wanwan
- sampling rate problem
- Prev by Date: Re: Servlet error ...package Javax.servlet does not exist
- Next by Date: Re: Signing applets to load from any server
- Previous by thread: Re: sampling rate problem
- Next by thread: Re: sampling rate problem
- Index(es):
Relevant Pages
|