Removed lots of stuff from the project

This commit is contained in:
2014-04-28 13:56:52 +02:00
parent b64f31e778
commit 4bb984cc1c
17 changed files with 34 additions and 264 deletions
@@ -17,7 +17,7 @@
*
*/
package ch.psi.fda.aq;
package ch.psi.fda;
import java.io.File;
import java.io.FileNotFoundException;
@@ -59,7 +59,6 @@ import sun.misc.SignalHandler;
import ch.psi.fda.edescriptor.EDescriptor;
import ch.psi.fda.gui.ProgressPanel;
import ch.psi.fda.gui.ScrollableFlowPanel;
import ch.psi.fda.install.ApplicationConfigurator;
import ch.psi.fda.vdescriptor.VDescriptor;
import ch.psi.fda.visualizer.Visualizer;
import ch.psi.jcae.ChannelService;
@@ -17,7 +17,7 @@
*
*/
package ch.psi.fda.install;
package ch.psi.fda;
import java.io.BufferedWriter;
import java.io.File;
@@ -33,8 +33,6 @@ import java.util.Enumeration;
import java.util.List;
import java.util.logging.Logger;
import ch.psi.fda.aq.AcquisitionConfiguration;
public class ApplicationConfigurator {
private static final Logger logger = Logger.getLogger(ApplicationConfigurator.class.getName());
@@ -16,7 +16,7 @@
* along with this code. If not, see <http://www.gnu.org/licenses/>.
*
*/
package ch.psi.fda.rest;
package ch.psi.fda;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
@@ -33,22 +33,7 @@ public class ControlClient {
private Client client = ClientBuilder.newClient().register(JacksonFeature.class);
private WebTarget target = client.target("http://emac:8080").path("fda");
public String acquire(String trackingId, EDescriptor edescriptor){
// For testing purposes
// try {
// JAXBContext context = JAXBContext.newInstance(EDescriptor.class, XScanDescriptor.class);
// Marshaller m = context.createMarshaller();
// m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
// m.marshal( edescriptor, System.out );
// } catch( JAXBException jbe ){
// // ...
// jbe.printStackTrace();
// }
// System.out.println("----");
return target.path(trackingId).request().put(Entity.entity(edescriptor, MediaType.APPLICATION_XML), String.class);
}
@@ -59,8 +59,6 @@ import sun.misc.SignalHandler;
import ch.psi.fda.edescriptor.EDescriptor;
import ch.psi.fda.gui.ProgressPanel;
import ch.psi.fda.gui.ScrollableFlowPanel;
import ch.psi.fda.rest.ControlClient;
import ch.psi.fda.rest.StreamClient;
import ch.psi.fda.vdescriptor.VDescriptor;
import ch.psi.fda.visualizer.Visualizer;
@@ -16,7 +16,7 @@
* along with this code. If not, see <http://www.gnu.org/licenses/>.
*
*/
package ch.psi.fda.rest;
package ch.psi.fda;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -42,7 +42,6 @@ import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import ch.psi.fda.gui.ScrollableFlowPanel;
import ch.psi.fda.rest.StreamClient;
import ch.psi.fda.vdescriptor.VDescriptor;
import ch.psi.fda.visualizer.Visualizer;
@@ -31,7 +31,7 @@ import java.util.logging.Logger;
import javax.inject.Inject;
import ch.psi.fda.aq.AcquisitionConfiguration;
import ch.psi.fda.AcquisitionConfiguration;
import ch.psi.fda.edescriptor.EDescriptor;
import ch.psi.jcae.ChannelService;
@@ -21,10 +21,10 @@ package ch.psi.fda.rest;
import java.util.ServiceLoader;
import java.util.logging.Logger;
import ch.psi.fda.AcquisitionConfiguration;
import ch.psi.fda.EContainer;
import ch.psi.fda.EContainerFactory;
import ch.psi.fda.InjectionModule;
import ch.psi.fda.aq.AcquisitionConfiguration;
import ch.psi.fda.edescriptor.EDescriptor;
import ch.psi.jcae.ChannelService;
@@ -18,7 +18,7 @@ import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.grizzly.http.server.HttpServer;
import ch.psi.fda.install.ApplicationConfigurator;
import ch.psi.fda.ApplicationConfigurator;
import sun.misc.Signal;
import sun.misc.SignalHandler;
@@ -66,11 +66,8 @@ public class FdaServer {
resourceConfig.register(JacksonFeature.class);
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig);
// Static content
// String home = System.getenv("FDA_BASE");
// if (home == null) {
@@ -80,6 +77,7 @@ public class FdaServer {
// server.getServerConfiguration().addHttpHandler(new StaticHttpHandler(home), "/static");
// logger.info(String.format("Management interface available at %sstatic/", baseUri));
logger.info("Server started");
logger.info("Use ctrl+c to stop ...");
@@ -103,6 +101,11 @@ public class FdaServer {
server.shutdownNow();
logger.info("Server terminated");
System.exit(0); // TODO need to shutdown ChannelService correctly !!!!
// Destroy global resources
binder.destroy();
// Using System.exit() to ensure that JVM is going down
System.exit(0);
}
}
@@ -6,25 +6,34 @@ import javax.inject.Singleton;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import ch.psi.fda.aq.AcquisitionConfiguration;
import ch.psi.fda.AcquisitionConfiguration;
//import ch.psi.fda.cdump.CdumpConfiguration;
import ch.psi.jcae.ChannelService;
import ch.psi.jcae.impl.DefaultChannelService;
public class ResourceBinder extends AbstractBinder {
private ChannelService channelService = new DefaultChannelService();
private ZMQDataService zmqService = new ZMQDataService(10000);
@Override
protected void configure() {
bind(DefaultChannelService.class).to(ChannelService.class).in(Singleton.class);
bind(channelService).to(ChannelService.class);
bind(AcquisitionConfiguration.class).to(AcquisitionConfiguration.class).in(Singleton.class);
bind(AcquisitionEngine.class).to(AcquisitionEngine.class).in(Singleton.class);
// bind(FdaqEngine.class).to(FdaqEngine.class).in(Singleton.class);
// ZMQ data service singleton
bind(new ZMQDataService(10000)).to(ZMQDataService.class);
// bind(CdumpEngine.class).to(CdumpEngine.class).in(Singleton.class);
// bind(CdumpConfiguration.class).to(CdumpConfiguration.class).in(Singleton.class);
bind(zmqService).to(ZMQDataService.class);
}
/**
* Destroy the allocated global resource.
* Resources destroyed are:
* - ChannelService
* - ZMQDataService
*/
public void destroy(){
channelService.destroy();
zmqService.terminate();
}
}
@@ -1,48 +0,0 @@
/**
*
* Copyright 2014 Paul Scherrer Institute. All rights reserved.
*
* This code is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This code is distributed in the hope that it will be useful, but without any
* warranty; without even the implied warranty of merchantability or fitness for
* a particular purpose. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this code. If not, see <http://www.gnu.org/licenses/>.
*
*/
package ch.psi.fda.rest.model;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class CdumpRequest {
private String filename;
private Stream stream;
private String samplingRate;
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
public Stream getStream() {
return stream;
}
public void setStream(Stream stream) {
this.stream = stream;
}
public String getSamplingRate() {
return samplingRate;
}
public void setSamplingRate(String samplingRate) {
this.samplingRate = samplingRate;
}
}
@@ -1,74 +0,0 @@
/**
*
* Copyright 2014 Paul Scherrer Institute. All rights reserved.
*
* This code is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This code is distributed in the hope that it will be useful, but without any
* warranty; without even the implied warranty of merchantability or fitness for
* a particular purpose. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this code. If not, see <http://www.gnu.org/licenses/>.
*
*/
package ch.psi.fda.rest.model;
import javax.xml.bind.annotation.XmlRootElement;
import org.codehaus.jackson.map.annotate.JsonDeserialize;
/**
* Execution request
*/
@XmlRootElement
@JsonDeserialize(using = ERequestJsonDeserializer.class)
public class ERequest {
/**
* List of ids to stream
*/
private Stream stream;
/**
* Execution type: scan, fdaq, cdump
*/
private String etype;
/**
* Json string holding the executions' configuration. It will interpreted differently based on the specified etype
*
* Use adapter ???? https://www.google.ch/url?sa=t&rct=j&q=&esrc=s&source=web&cd=6&cad=rja&ved=0CFgQFjAF&url=http%3A%2F%2Fblog.bdoughan.com%2F2012%2F01%2Fjaxb-and-inhertiance-using-xmladapter.html&ei=GfrMUtzTNsGp7AbykYDQDw&usg=AFQjCNG3xDZKYLYV6Ez-EvvJe_AIYE5EHA&sig2=ND5Epp90O-FWrJI4T3zyCw&bvm=bv.58187178,d.ZGU
*/
private String configuration;
public Stream getStream() {
return stream;
}
public void setStream(Stream stream) {
this.stream = stream;
}
public String getEtype() {
return etype;
}
public void setEtype(String etype) {
this.etype = etype;
}
public String getConfiguration() {
return configuration;
}
public void setConfiguration(String configuration) {
this.configuration = configuration;
}
}
@@ -1,30 +0,0 @@
package ch.psi.fda.rest.model;
import java.io.IOException;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.DeserializationContext;
import org.codehaus.jackson.map.JsonDeserializer;
class ERequestJsonDeserializer extends JsonDeserializer<ERequest> {
@Override
public ERequest deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
ERequest request = new ERequest();
JsonNode node = jp.readValueAsTree();
request.setEtype(node.get("etype").asText());
request.setStream(jp.getCodec().treeToValue(node.get("stream"), Stream.class));
request.setConfiguration(node.get("configuration").toString());
// Class<? extends ERe> concreteType = determineConcreteType(node); //Implement
// return jp.getCodec().treeToValue(node, concreteType);
//
// return jp.readValueAsTree().toString();
return request;
}
}
@@ -1,40 +0,0 @@
/**
*
* Copyright 2014 Paul Scherrer Institute. All rights reserved.
*
* This code is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This code is distributed in the hope that it will be useful, but without any
* warranty; without even the implied warranty of merchantability or fitness for
* a particular purpose. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this code. If not, see <http://www.gnu.org/licenses/>.
*
*/
package ch.psi.fda.rest.model;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class FdaqRequest {
private String filename;
private Stream stream;
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
public Stream getStream() {
return stream;
}
public void setStream(Stream stream) {
this.stream = stream;
}
}
@@ -1,31 +0,0 @@
/**
*
* Copyright 2014 Paul Scherrer Institute. All rights reserved.
*
* This code is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This code is distributed in the hope that it will be useful, but without any
* warranty; without even the implied warranty of merchantability or fitness for
* a particular purpose. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this code. If not, see <http://www.gnu.org/licenses/>.
*
*/
package ch.psi.fda.rest.model;
public class Stream {
private String[] ids;
public String[] getIds() {
return ids;
}
public void setIds(String[] ids) {
this.ids = ids;
}
}
@@ -25,6 +25,8 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import ch.psi.fda.ApplicationConfigurator;
/**
* @author ebner
*