cleaned up cdump stuff
This commit is contained in:
@@ -82,6 +82,17 @@ public class Cdump {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait until acquire is done
|
||||
*/
|
||||
public void waitAcquireDone(){
|
||||
try {
|
||||
adcCmd.waitForValue(AdcCmd.READY.ordinal());
|
||||
} catch (InterruptedException | ExecutionException | ChannelException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package ch.psi.fda.cdump;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
|
||||
@@ -11,38 +10,24 @@ import ch.psi.jcae.ChannelService;
|
||||
|
||||
public class CdumpEContainer implements EContainer {
|
||||
|
||||
public final static String CDUMP_CONFIG = "ch.psi.fda.cdump.config.file";
|
||||
|
||||
private final ChannelService cservice;
|
||||
private final CdumpEDescriptor edescriptor;
|
||||
private final EventBus eventbus;
|
||||
|
||||
private CdumpConfiguration configuration;
|
||||
private Cdump cdump;
|
||||
|
||||
private volatile boolean running = false;
|
||||
|
||||
private final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
public CdumpEContainer(ChannelService cservice, EventBus eventbus, CdumpEDescriptor edescriptor) {
|
||||
this.cservice = cservice;
|
||||
this.edescriptor = edescriptor;
|
||||
this.eventbus = eventbus;
|
||||
|
||||
configuration = new CdumpConfiguration();
|
||||
|
||||
String config = System.getProperty(CDUMP_CONFIG);
|
||||
|
||||
if (config != null) {
|
||||
configuration.loadFile(new File(config));
|
||||
}
|
||||
this.edescriptor = edescriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
cdump = new Cdump(cservice, eventbus, configuration);
|
||||
cdump = new Cdump(cservice, eventbus, new CdumpConfiguration());
|
||||
|
||||
|
||||
File file = new File(edescriptor.getFileName());
|
||||
file.getParentFile().mkdirs(); // Create data base directory
|
||||
|
||||
@@ -55,15 +40,9 @@ public class CdumpEContainer implements EContainer {
|
||||
@Override
|
||||
public void execute() {
|
||||
running = true;
|
||||
try {
|
||||
try{
|
||||
cdump.acquire(edescriptor.getSamplingRate());
|
||||
latch.await();
|
||||
System.out.println("__sucks");
|
||||
} catch (InterruptedException e) {
|
||||
// ignore
|
||||
System.out.println("__sucker");
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
cdump.waitAcquireDone();
|
||||
}
|
||||
finally{
|
||||
running=false;
|
||||
@@ -72,8 +51,6 @@ public class CdumpEContainer implements EContainer {
|
||||
|
||||
@Override
|
||||
public void abort() {
|
||||
latch.countDown();
|
||||
System.out.println("SOMI");
|
||||
cdump.stop();
|
||||
running = false;
|
||||
}
|
||||
@@ -85,8 +62,6 @@ public class CdumpEContainer implements EContainer {
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
latch.countDown();
|
||||
System.out.println("SOMI DEST");
|
||||
cdump.stop();
|
||||
running = false;
|
||||
}
|
||||
|
||||
@@ -23,5 +23,4 @@ public class CdumpEContainerFactory implements EContainerFactory {
|
||||
public EContainer getEContainer(EDescriptor descriptor, EventBus bus) {
|
||||
return new CdumpEContainer(cservice, bus, (CdumpEDescriptor) descriptor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,16 +7,9 @@ import ch.psi.fda.edescriptor.EDescriptor;
|
||||
@XmlRootElement(name="cdump")
|
||||
public class CdumpEDescriptor implements EDescriptor {
|
||||
|
||||
// private String name;
|
||||
private String samplingRate;
|
||||
private String fileName;
|
||||
|
||||
// public String getName() {
|
||||
// return name;
|
||||
// }
|
||||
// public void setName(String name) {
|
||||
// this.name = name;
|
||||
// }
|
||||
public String getSamplingRate() {
|
||||
return samplingRate;
|
||||
}
|
||||
@@ -29,5 +22,4 @@ public class CdumpEDescriptor implements EDescriptor {
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,27 +2,37 @@ package ch.psi.fda.cdump;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
import ch.psi.fda.DescriptorProvider;
|
||||
import ch.psi.fda.edescriptor.EDescriptor;
|
||||
import ch.psi.fda.vdescriptor.VDescriptor;
|
||||
|
||||
public class CdumpEDescriptorProvider implements DescriptorProvider {
|
||||
|
||||
private EDescriptor edescriptor;
|
||||
|
||||
@Override
|
||||
public void load(File... files) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
JAXBContext context = JAXBContext.newInstance(CdumpEDescriptor.class);
|
||||
Unmarshaller u = context.createUnmarshaller();
|
||||
edescriptor = (EDescriptor) u.unmarshal(files[0]);
|
||||
} catch (JAXBException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EDescriptor getEDescriptor() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return edescriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VDescriptor getVDescriptor() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user