Amleto, I am visualising real time updates. There is an unsigned char[] data stream coming from the hardware, usually 2048 bytes long. Around 260 of those bytes are relevant to the visualisation. The visualisation itself is a 2D colormap of the data which the user can interact with in a simple manner, only changing the scale to alter the min-max color ranges. This is done with a horizontal slider. There are also a couple of QwtPlots which visualise the same data, but in a conventional XY plot style.
The while loop specifically looks like this:
|
Source code
|
1
2
3
4
5
6
7
|
while(isAcquiring){
if (newDataPresent==1){
readFromHardware(buf,2048);//where 2048 is the size of buf array
file.write((char *) buf,2048);
processAndDisplay(buf);
}
}
|
The
newDataPresent boolean is set to high when new data is available from the hardware. This is acquisition-specific, usually ranging from 2ms, 3, 5, 10 up to 100ms. As specified before, anything under 10ms and the visualisation fails to display the correct data.
Of course, the duration of processAndDisplay(buf); depends on the specs of the machine running the software. If I have to run it on a different machine, the duration of the visualisation may vary to be less or more than ~10ms. This is why I'd like to keep the function in a worker thread so that it may display the data in parallel whenever it finishes processing. Or perhaps there may be a way to stack up a number of bufs in memory somehow and process them all at a time (the data manipulation processing itself is very fast, in the order of microseconds) and then just visualise the data once every 20ms. Thoughts?
Thank you.
Mr_Cloud