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
@@ -19,6 +19,7 @@
package ch.psi.fdaq;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
@@ -38,7 +39,7 @@ public class FdaqConfiguration {
private String hostname = "mchip015.psi.ch";
private int port = 2233;
private int killPort = 2234;
private int nelements = Integer.MAX_VALUE;
private int nelements = Integer.MAX_VALUE/2;
private String filePrefix = "${yyyy_MM}/${yyyyMMdd}/${yyyyMMddHHmmss}_${name}/${yyyyMMddHHmm}_";
private String dataDirectory;
@@ -57,19 +58,23 @@ public class FdaqConfiguration {
throw new RuntimeException("No configuration file specified via -D"+FdaqService.APP_HOME+"=...");
}
Properties properties = new Properties();
try {
properties.load(new FileReader(config+"/config/fdaq.properties"));
} catch (FileNotFoundException e) {
throw new RuntimeException("Configuration file "+config+" not found", e);
} catch (IOException e) {
throw new RuntimeException("Cannot read configuration file "+config, e);
File cfile = new File(config+"/config/fdaq.properties");
if(cfile.exists()){
Properties properties = new Properties();
try {
properties.load(new FileReader(cfile));
} catch (FileNotFoundException e) {
throw new RuntimeException("Configuration file "+config+" not found", e);
} catch (IOException e) {
throw new RuntimeException("Cannot read configuration file "+config, e);
}
hostname = properties.getProperty(FdaqConfiguration.class.getPackage().getName()+".hostname", "mchip015.psi.ch");
port = Integer.parseInt(properties.getProperty(FdaqConfiguration.class.getPackage().getName()+".port", "2233"));
killPort = Integer.parseInt(properties.getProperty(FdaqConfiguration.class.getPackage().getName()+".killPort", "2234"));
dataDirectory = config+"/data";
}
hostname = properties.getProperty(FdaqConfiguration.class.getPackage().getName()+".hostname", "mchip015.psi.ch");
port = Integer.parseInt(properties.getProperty(FdaqConfiguration.class.getPackage().getName()+".port", "2233"));
killPort = Integer.parseInt(properties.getProperty(FdaqConfiguration.class.getPackage().getName()+".killPort", "2234"));
dataDirectory = config+"/data";
}
public String getHostname() {
@@ -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();
}
}
@@ -33,7 +33,7 @@ public class SocketClientStop {
/**
* Requires connection to:
* ssh -L9999:mchip015:2234 x10da-gw
* ssh -L9998:mchip015:2234 x10da-gw
*
* @param args
* @throws IOException