updates
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package ch.psi.fda.cdump;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
|
||||
@@ -20,6 +21,8 @@ public class CdumpEContainer implements EContainer {
|
||||
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;
|
||||
@@ -39,7 +42,11 @@ public class CdumpEContainer implements EContainer {
|
||||
public void initialize() {
|
||||
cdump = new Cdump(cservice, eventbus, configuration);
|
||||
|
||||
SerializerTXT serializer = new SerializerTXT(new File(edescriptor.getFileName()));
|
||||
|
||||
File file = new File(edescriptor.getFileName());
|
||||
file.getParentFile().mkdirs(); // Create data base directory
|
||||
|
||||
SerializerTXT serializer = new SerializerTXT(file);
|
||||
serializer.setShowDimensionHeader(false);
|
||||
|
||||
eventbus.register(serializer);
|
||||
@@ -50,10 +57,17 @@ public class CdumpEContainer implements EContainer {
|
||||
running = true;
|
||||
try {
|
||||
cdump.acquire(edescriptor.getSamplingRate());
|
||||
latch.await();
|
||||
System.out.println("__sucks");
|
||||
} catch (InterruptedException e) {
|
||||
// ignore
|
||||
System.out.println("__sucker");
|
||||
} catch (Exception e) {
|
||||
running = false;
|
||||
throw e;
|
||||
}
|
||||
finally{
|
||||
running=false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,6 +77,8 @@ public class CdumpEContainer implements EContainer {
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
latch.countDown();
|
||||
System.out.println("SOMI");
|
||||
cdump.stop();
|
||||
running = false;
|
||||
}
|
||||
@@ -74,6 +90,10 @@ public class CdumpEContainer implements EContainer {
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
latch.countDown();
|
||||
System.out.println("SOMI DEST");
|
||||
cdump.stop();
|
||||
running = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class CdumpEContainerFactory implements EContainerFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EContainer createContainer(EDescriptor descriptor, EventBus bus) {
|
||||
public EContainer getEContainer(EDescriptor descriptor, EventBus bus) {
|
||||
return new CdumpEContainer(cservice, bus, (CdumpEDescriptor) descriptor);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,9 @@ public class CdumpListener implements PropertyChangeListener {
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
transform((int[]) evt.getNewValue());
|
||||
if(evt.getPropertyName().equals("value")){
|
||||
transform((int[]) evt.getNewValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user