Use of a buffered input stream ...

This commit is contained in:
2014-03-21 14:32:15 +01:00
parent 0ad4f9f6db
commit 416a9ab3af
2 changed files with 12 additions and 21 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ch.psi</groupId>
<artifactId>ch.psi.fda.fdaq</artifactId>
<version>1.0.13</version>
<version>1.0.14</version>
<dependencies>
<dependency>
@@ -18,6 +18,7 @@
*/
package ch.psi.fda.fdaq;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
@@ -66,6 +67,14 @@ public class Fdaq {
public void acquire() {
running = true; // potential threading problem
final List<Metadata> metadata = new ArrayList<>();
metadata.add(new Metadata("counter"));
metadata.add(new Metadata("ain1"));
metadata.add(new Metadata("ain2"));
metadata.add(new Metadata("ain3"));
metadata.add(new Metadata("ain4"));
metadata.add(new Metadata("enc1"));
Socket echoSocket = null;
DataOutputStream out = null;
DataInputStream in = null;
@@ -79,7 +88,7 @@ public class Fdaq {
stopAcquisition = false;
echoSocket = new Socket(configuration.getHostname(), configuration.getPort());
out = new DataOutputStream(echoSocket.getOutputStream());
in = new DataInputStream(echoSocket.getInputStream());
in = new DataInputStream(new BufferedInputStream(echoSocket.getInputStream()));
ByteBuffer bytebuffer = ByteBuffer.allocate(3 * 4); // 3 times Integer
bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
@@ -97,20 +106,7 @@ public class Fdaq {
out.write(bytebuffer.array());
out.flush();
final List<Metadata> metadata = new ArrayList<>();
metadata.add(new Metadata("counter"));
metadata.add(new Metadata("ain1"));
metadata.add(new Metadata("ain2"));
metadata.add(new Metadata("ain3"));
metadata.add(new Metadata("ain4"));
metadata.add(new Metadata("enc1"));
int index=0;
for (int t = 0; t < numberOfElements; t++) {
// struct fdaqbloc_out {int trigindex;int adc1reg;int
// adc2reg;int encoder;};
byte[] cbuffer = new byte[4*4]; // 4 times Integers a 4 bytes
try{
@@ -147,14 +143,9 @@ public class Fdaq {
message.getData().add(c2);
message.getData().add(d);
bus.post(message);
if(t==0){
logger.info("index: "+a);
}
index=a;
}
logger.info("Done ..."+index);
logger.info("Done ...");
} catch (IOException e) {
// Ignore potential exceptions if stop was triggered before all messages were retrieved