Hi,
I’m trying to do a continuous reading via DSOLink.
My configuration :
- Windows 7
- PCSU1000
- PcLab2000SE v4.05
- Access to the dll with Java 1.7 via JNA
If i want to get data for a single run, it works. My problem is when I try to get data for several continuous run.
private void waitForData()
{
long t1 = System.currentTimeMillis();
System.out.println("Process : "+(t1-t0));
t0 = t1;
while((thread != null)&&(!dsolink.DataReady())) {
try {
synchronized(thread) { thread.wait(1); }
}
catch(Exception ex) {}
}
t1 = System.currentTimeMillis();
System.out.println("Wait : "+(t1-t0)+" ms");
t0 = t1;
}
public void run()
{
Pointer buffer1 = new Memory(5000 * Native.getNativeSize(Integer.TYPE));
Pointer buffer2 = new Memory(5000 * Native.getNativeSize(Integer.TYPE));
System.out.println("Go");
t0 = System.currentTimeMillis();
waitForData();
dsolink.ReadCh1(buffer1);
dsolink.ReadCh2(buffer2);
waitForData();
dsolink.ReadCh1(buffer1);
dsolink.ReadCh2(buffer2);
waitForData();
dsolink.ReadCh1(buffer1);
dsolink.ReadCh2(buffer2);
int[] b1 = buffer1.getIntArray(0, 5000);
int[] b2 = buffer2.getIntArray(0, 5000);
waitForData();
dsolink.ReadCh1(buffer1);
dsolink.ReadCh2(buffer2);
int[] b1b = buffer1.getIntArray(0, 5000);
int[] b2b = buffer2.getIntArray(0, 5000);
waitForData();
dsolink.ReadCh1(buffer1);
dsolink.ReadCh2(buffer2);
waitForData();
dsolink.ReadCh1(buffer1);
dsolink.ReadCh2(buffer2);
System.out.println("Hz1:"+b1[0]);
System.out.println("Hz2:"+b2[0]);
System.out.println("FullScale1:"+b1[1]);
System.out.println("FullScale2:"+b2[1]);
System.out.println("GroundLevel1:"+b1[2]);
System.out.println("GroundLevel2:"+b2[3]);
...
For a configuration of 10ms/div, I got :
Go
Process : 0
Wait : 8 ms
Process : 1
Wait : 135 ms
Process : 0
Wait : 375 ms
Process : 0
Wait : 370 ms
Process : 0
Wait : 376 ms
Process : 0
Wait : 376 ms
Hz1:12500
Hz2:12500
FullScale1:8000
FullScale2:8000
GroundLevel1:128
GroundLevel2:120
Finish
For 4098 samples at 12500Hz, the delay should be 328ms, i got ~375ms (+47ms) and so I don’t have every data (gaspe between 2 calls of ReadCh1/ReadCh2).
Same thing with with 1ms/div, the delay should be 33ms and I got ~95 ms (+62ms).
It doesn’t seem to be because of java calls (processing = 0ms).
Is DataReady should work like this ?
Is there a way to be sure to have all data ?