minor changes

This commit is contained in:
2013-04-16 09:24:48 +02:00
parent 3d2702bab2
commit 3dc2d4c7da
3 changed files with 51 additions and 32 deletions
@@ -76,6 +76,7 @@ public class FdaqService {
// open file and write
logger.info("Open file: "+file.getAbsolutePath());
writer = new PrintWriter(new BufferedWriter(new FileWriter(file)));
writer.println("# a" + "\t" + "b1" + "\t" + "b2" + "\t" + "c1" + "\t" + "c2" + "\t" + "d");
@@ -100,8 +101,12 @@ public class FdaqService {
int c2 = (c >> 16) & 0xffff;
int d = buffer.getInt();
// System.out.println(a + " " + b1 + " " + b2 + " " + c1 + " " + c2 + " " + d);
logger.info(a + " " + b1 + " " + b2 + " " + c1 + " " + c2 + " " + d);
writer.println(a + "\t" + b1 + "\t" + b2 + "\t" + c1 + "\t" + c2 + "\t" + d);
if(t%100==0){ // flush at least every hundered messages
writer.flush();
}
}
writer.close();
@@ -128,25 +133,34 @@ public class FdaqService {
t.start();
}
public void stopAcquistion() {
try {
stopAcquisition=true;
FdaqConfiguration c = FdaqConfiguration.getInstance();
Socket echoSocket = new Socket(c.getHostname(), c.getKillPort());
DataOutputStream out = new DataOutputStream(echoSocket.getOutputStream());
public void stopAcquisition() {
Thread t = new Thread(new Runnable() {
ByteBuffer bytebuffer = ByteBuffer.allocate(1 * 4); // 2 times
// Integers
bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
bytebuffer.putInt(666);
out.write(bytebuffer.array());
out.flush();
@Override
public void run() {
try {
stopAcquisition = true;
FdaqConfiguration c = FdaqConfiguration.getInstance();
Socket echoSocket = new Socket(c.getHostname(), c.getKillPort());
DataOutputStream out = new DataOutputStream(echoSocket.getOutputStream());
out.close();
echoSocket.close();
} catch (IOException e) {
logger.log(Level.SEVERE, "", e);
}
ByteBuffer bytebuffer = ByteBuffer.allocate(1 * 4); // 2
// times
// Integers
bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
bytebuffer.putInt(666);
out.write(bytebuffer.array());
out.flush();
out.close();
echoSocket.close();
} catch (IOException e) {
logger.log(Level.SEVERE, "", e);
}
}
});
t.start();
}
}