45 Commits

Author SHA1 Message Date
28bd7c40d8 removed unused option 2014-04-09 16:27:54 +02:00
dcd394b586 updated readme formatting 2014-04-08 10:11:02 +02:00
76c40ccf28 Made zmq port configureable
Updated Readme.md file
2014-04-08 10:09:05 +02:00
8522d46813 renamed fda script to server and added script to startup the viewer 2014-04-07 15:11:01 +02:00
1077ec8ab3 Added flag to generate serializable model classes (xjb.xjb)
Improved viewer to update/change the plots whenever a new scan starts...
Therefore the visualization configuration is always send before any of
the scan data is sent.
2014-04-07 11:02:40 +02:00
da0e0eab79 Updated to latest fdaq 2014-01-22 13:38:35 +01:00
ac54407e34 upgraded to latest fdaq version 2014-01-22 11:29:23 +01:00
b0d4ef9d8b Made home variable visible 2014-01-21 08:41:07 +01:00
f8ee1bd666 updated readme 2014-01-20 13:30:45 +01:00
8d37cdbeca created all in one jar for gui application. 2014-01-20 13:12:25 +01:00
fbe03b7ade Added tracking id for isActive call 2014-01-20 11:12:20 +01:00
d866fa0eda fixed rest documentation 2014-01-15 16:09:39 +01:00
2b0877c65d Documented fda rest api 2014-01-15 16:08:06 +01:00
d7f1b15927 new package version
FDA-106
FDA-1
2014-01-15 14:31:28 +01:00
35a4949907 Rest server now also takes ch.psi.fda.home variable into account
FDA-106
2014-01-15 13:38:03 +01:00
30355deacc removed setting of java.util.logging.config.file inside this class as
this has no effect!
2014-01-15 13:37:07 +01:00
eb0aa9a1b6 Cleaned up configuration mess 2014-01-15 13:14:56 +01:00
b447ec12d7 FDA-1
Added function to wait for the termination of a request
2014-01-15 11:04:24 +01:00
ae78b8c7a7 Removed unnecessary queue in AcquisitionEngine 2014-01-15 10:15:00 +01:00
c9ff7ccf2c tests ... 2014-01-15 09:05:51 +01:00
c01995675e decreased log level for logging complete message send out by the zmq
streamer
2014-01-14 13:47:05 +01:00
e4885d11e1 added startup scripts: FDA-106
created assembly descriptor for build
Renamed RestServer to FdaServer
2014-01-14 11:39:10 +01:00
407aff2e24 Upgrade fdaq and cdump code dependencies ... 2014-01-14 11:08:59 +01:00
9d6ae89f13 Added TODO comment for reminding that filtering is not yet done 2014-01-09 09:17:27 +01:00
fafea6dc69 FDA-103
Created first version of Cdump REST service
2014-01-09 09:10:25 +01:00
3e841c7596 FDA-102 2014-01-09 08:35:50 +01:00
542379545b Added (singleton) fdaq engine class to be able to unregister the zmq
streamer and to avoid having more than one thing driving the fdaq box
...
2014-01-08 16:30:59 +01:00
4d0f329e72 removed class because of no time to fully implement it ...
will add it later .
2014-01-08 16:11:40 +01:00
488fa5c908 FDA-102
moved request object to rest.model package
2014-01-08 16:10:12 +01:00
d550e59254 Implemented FDAQ REST API and started to with Cdump 2014-01-08 09:58:26 +01:00
685ac0cd2d renamed ScanService to FDAService 2013-12-20 15:25:09 +01:00
9476f9b57c cleaned comments 2013-12-20 14:35:37 +01:00
8888172ede Renamed class RestClient to ControlClient 2013-12-20 14:31:44 +01:00
e324987c8e FDA-1
Improved client - Now multiple clients can submit scans and only the one
submitted the scan will receive the data as well as can abor the scan.
2013-12-20 14:28:32 +01:00
76e9ea1bed FDA-1
Improved server and client
2013-12-20 13:43:16 +01:00
244001fd99 First working (messy) version of client/server split
FDA-1
2013-12-20 08:54:55 +01:00
55faaa2aa3 FDA-1
Improved rest server
2013-12-19 11:23:56 +01:00
ab0d1654c1 fixed pom for artifact upload 2013-12-18 11:09:47 +01:00
726cf9c0ff fixed pom 2013-12-17 15:31:54 +01:00
03c7d84b05 Renamed serializer classes (removed Data prefix)
Moved SerializerTXT to core project
2013-12-17 15:20:53 +01:00
54fb16a0e9 Renamed package from core.messages to messages 2013-12-17 15:18:09 +01:00
f96b85f6d0 Renamed test case 2013-12-17 15:16:44 +01:00
696893ba16 Renamed unnecessary interface DataSerializer
moved messages package into own project
2013-12-17 15:11:38 +01:00
d84ce43676 Update readme 2013-12-17 14:56:59 +01:00
e625185b6d Updated version to 2.0.x
Added Readme.md file - Starting of development documentation
2013-11-27 11:44:48 +01:00
77 changed files with 1923 additions and 1090 deletions

107
ch.psi.fda/Readme.md Normal file
View File

@@ -0,0 +1,107 @@
# Overview
This package holds the core functionality of FDA.
# Usage
use -Djava.util.logging.config.file=logging.properties` to configure logging
## Server
The FDA server is started as follows:
```
./bin/server -h
usage: fda
-h Help
-p <arg> Server port (default: 8080)
-s <arg> Server address (default: localhost)
```
Start new scan:
```
curl -X PUT -d @scan1d.xml -H 'Content-Type:application/xml' http://localhost:8080/fda/scan
```
## Viewer
```
./bin/viewer -h
usage: viewer
-h Help
-p <arg> Server port (default: 10000)
-s <arg> Server address (default: localhost)
```
# Development
When checking out the project from the repository there is the `target/generated-sources/xjc` folder missing.
After checking out the project execute `mvn compile` to create the folder and the required classes.
To build project use `mvn clean install`.
To upload the latest version to the central artifact repository use `mvn clean deploy`.
Create Zip file via `mvn clean compile assembly:assembly`
To use the FDA libary in an other project (like the GUI project) use:
```
<dependency>
<groupId>ch.psi</groupId>
<artifactId>fda</artifactId>
<version>x.x.x</version>
</dependency>
```
## REST
FDA offers a rest service to execute scans. There are 3 distinct service for fda scan, fdaq and cdump.
### FDA Service
Submit scan
```
PUT fda/{trackingId}
Content-Type: application/xml
<configuration>
...
</configuration>
204 - Success
```
Stop/cancel scan
```
DELETE fda/{trackingId}
204 - Success
```
Stop all scans
```
DELETE fda
204 - Success
```
Check if scan is running
```
GET fda/{trackingId}/running
200 - true/false
```
Wait for scan done (blocks until scan is done)
```
GET fda/{trackingId}/done
204 - Success
```
# Notes
## Upgrade FDA 1.x to 2.x
In existing fda.properties file the following property need to be added: `ch.psi.fda.aq.data.dir=../data`

View File

@@ -3,41 +3,52 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ch.psi</groupId>
<artifactId>fda</artifactId>
<version>1.1.41</version>
<version>2.1.1</version>
<dependencies>
<dependency>
<groupId>ch.psi</groupId>
<artifactId>ch.psi.fda.core</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ch.psi</groupId>
<artifactId>ch.psi.fda.cdump</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>ch.psi</groupId>
<artifactId>ch.psi.fda.fdaq</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
<version>2.3.1</version>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-sse</artifactId>
<version>2.3.1</version>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.3.1</version>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>org.jeromq</groupId>
<artifactId>jeromq</artifactId>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>15.0</version>
</dependency>
<dependency>
<groupId>ch.psi</groupId>
<artifactId>jcae</artifactId>
@@ -110,8 +121,7 @@
<target>1.7</target>
</configuration>
</plugin>
<!-- Generate Javadoc Jar -->
<plugin>
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
@@ -123,8 +133,7 @@
</goals>
</execution>
</executions>
</plugin>
<!-- Generate Source Jar -->
</plugin> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
@@ -219,23 +228,16 @@
</lifecycleMappingMetadata>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>${project.name}-${project.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<archive>
<!-- <manifest>
<mainClass>ch.psi.fda.AcquisitionMain</mainClass>
</manifest> -->
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

View File

@@ -0,0 +1,54 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>bin</id>
<!-- Generates a zip package containing the needed files -->
<formats>
<format>zip</format>
</formats>
<!-- Adds dependencies to zip package under lib directory -->
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<unpack>false</unpack>
</dependencySet>
</dependencySets>
<fileSets>
<!-- Adds startup scripts to the root directory of zip package -->
<fileSet>
<fileMode>0755</fileMode>
<directory>src/main/assembly/bin</directory>
<outputDirectory>bin</outputDirectory>
<includes>
<include>*</include>
</includes>
</fileSet>
<!-- <fileSet>
<directory>src/main/assembly/www</directory>
<outputDirectory>www</outputDirectory>
<includes>
<include>**/*</include>
</includes>
</fileSet> -->
<!-- <fileSet>
<fileMode>0755</fileMode>
<directory>src/main/assembly/var</directory>
<outputDirectory>var</outputDirectory>
<includes>
<include>**/*</include>
</includes>
</fileSet> -->
<!-- adds jar package to the root directory of zip package -->
<!-- <fileSet>
<directory>target</directory>
<outputDirectory></outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet> -->
</fileSets>
</assembly>

View File

@@ -0,0 +1,40 @@
#!/bin/bash
CURRENTDIR=`pwd`
# Resolve symlinks
BASEDIR=$0
while [ -h "$BASEDIR" ]; do
ls=`ls -ld "$BASEDIR"`
link=`expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null`
if expr "$link" : '^/' 2> /dev/null >/dev/null; then
BASEDIR="$link"
else
BASEDIR="`dirname "$BASEDIR"`/$link"
fi
done
BASEDIR=`dirname "$BASEDIR"`
SCRIPTNAME=`basename ${0}`
APPLICATION_HOME=$BASEDIR/../..
LIB_DIR=`find $BASEDIR/../lib -name "*.jar"`
LIB_DIR=`echo $LIB_DIR | sed -e 's/ /:/g'`
CLASSPATH=${APPLICATION_HOME}/config/:$LIB_DIR
ARGUMENTS=
VM_ARGUMENTS=
for i in $@
do
if [ `expr $i : '-D.*'` != '0' ] ;then
# Extract VM options
VM_ARGUMENTS="$VM_ARGUMENTS $i"
else
ARGUMENTS="$ARGUMENTS $i"
fi
done
# Execute java
java -Xmx1024m -XX:MaxPermSize=128m -cp $CLASSPATH -Dch.psi.fda.home=${APPLICATION_HOME} -Djava.util.logging.config.file=${APPLICATION_HOME}/config/logging.properties $VM_ARGUMENTS ch.psi.fda.ConversionMain $ARGUMENTS

View File

@@ -0,0 +1,40 @@
#!/bin/bash
CURRENTDIR=`pwd`
# Resolve symlinks
BASEDIR=$0
while [ -h "$BASEDIR" ]; do
ls=`ls -ld "$BASEDIR"`
link=`expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null`
if expr "$link" : '^/' 2> /dev/null >/dev/null; then
BASEDIR="$link"
else
BASEDIR="`dirname "$BASEDIR"`/$link"
fi
done
BASEDIR=`dirname "$BASEDIR"`
SCRIPTNAME=`basename ${0}`
APPLICATION_HOME=$BASEDIR/../..
LIB_DIR=`find $BASEDIR/../lib -name "*.jar"`
LIB_DIR=`echo $LIB_DIR | sed -e 's/ /:/g'`
CLASSPATH=${APPLICATION_HOME}/config/:$LIB_DIR
ARGUMENTS=
VM_ARGUMENTS=
for i in $@
do
if [ `expr $i : '-D.*'` != '0' ] ;then
# Extract VM options
VM_ARGUMENTS="$VM_ARGUMENTS $i"
else
ARGUMENTS="$ARGUMENTS $i"
fi
done
# Execute java
java -Xmx1024m -XX:MaxPermSize=128m -Dch.psi.fda.home=${APPLICATION_HOME} -Djava.util.logging.config.file=${APPLICATION_HOME}/config/logging.properties $VM_ARGUMENTS -cp $CLASSPATH ch.psi.fda.AcquisitionMain $ARGUMENTS

View File

@@ -0,0 +1,42 @@
#!/bin/bash
CURRENTDIR=`pwd`
# Resolve symlinks
BASEDIR=$0
while [ -h "$BASEDIR" ]; do
ls=`ls -ld "$BASEDIR"`
link=`expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null`
if expr "$link" : '^/' 2> /dev/null >/dev/null; then
BASEDIR="$link"
else
BASEDIR="`dirname "$BASEDIR"`/$link"
fi
done
BASEDIR=`dirname "$BASEDIR"`
SCRIPTNAME=`basename ${0}`
APPLICATION_HOME=$BASEDIR/../..
LIB_DIR=`find $BASEDIR/../lib -name "*.jar"`
LIB_DIR=`echo $LIB_DIR | sed -e 's/ /:/g'`
CLASSPATH=${APPLICATION_HOME}/config/:$LIB_DIR
ARGUMENTS=
VM_ARGUMENTS=
for i in $@
do
if [ `expr $i : '-D.*'` != '0' ] ;then
# Extract VM options
VM_ARGUMENTS="$VM_ARGUMENTS $i"
else
ARGUMENTS="$ARGUMENTS $i"
fi
done
#HUB_BASE=$BASEDIR/../
#export HUB_BASE
java $VM_ARGUMENTS -cp $CLASSPATH -Dch.psi.fda.home=${APPLICATION_HOME} -Djava.util.logging.config.file=${APPLICATION_HOME}/config/logging.properties ch.psi.fda.rest.FdaServer $ARGUMENTS

View File

@@ -0,0 +1,40 @@
#!/bin/bash
CURRENTDIR=`pwd`
# Resolve symlinks
BASEDIR=$0
while [ -h "$BASEDIR" ]; do
ls=`ls -ld "$BASEDIR"`
link=`expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null`
if expr "$link" : '^/' 2> /dev/null >/dev/null; then
BASEDIR="$link"
else
BASEDIR="`dirname "$BASEDIR"`/$link"
fi
done
BASEDIR=`dirname "$BASEDIR"`
SCRIPTNAME=`basename ${0}`
APPLICATION_HOME=$BASEDIR/../..
LIB_DIR=`find $BASEDIR/../lib -name "*.jar"`
LIB_DIR=`echo $LIB_DIR | sed -e 's/ /:/g'`
CLASSPATH=${APPLICATION_HOME}/config/:$LIB_DIR
ARGUMENTS=
VM_ARGUMENTS=
for i in $@
do
if [ `expr $i : '-D.*'` != '0' ] ;then
# Extract VM options
VM_ARGUMENTS="$VM_ARGUMENTS $i"
else
ARGUMENTS="$ARGUMENTS $i"
fi
done
# Execute java
java -Xmx1024m -XX:MaxPermSize=128m -cp $CLASSPATH -Dch.psi.fda.home=${APPLICATION_HOME} -Djava.util.logging.config.file=${APPLICATION_HOME}/config/logging.properties $VM_ARGUMENTS ch.psi.fda.ViewerMain $ARGUMENTS

View File

@@ -0,0 +1,40 @@
#!/bin/bash
CURRENTDIR=`pwd`
# Resolve symlinks
BASEDIR=$0
while [ -h "$BASEDIR" ]; do
ls=`ls -ld "$BASEDIR"`
link=`expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null`
if expr "$link" : '^/' 2> /dev/null >/dev/null; then
BASEDIR="$link"
else
BASEDIR="`dirname "$BASEDIR"`/$link"
fi
done
BASEDIR=`dirname "$BASEDIR"`
SCRIPTNAME=`basename ${0}`
APPLICATION_HOME=$BASEDIR/../..
LIB_DIR=`find $BASEDIR/../lib -name "*.jar"`
LIB_DIR=`echo $LIB_DIR | sed -e 's/ /:/g'`
CLASSPATH=${APPLICATION_HOME}/config/:$LIB_DIR
ARGUMENTS=
VM_ARGUMENTS=
for i in $@
do
if [ `expr $i : '-D.*'` != '0' ] ;then
# Extract VM options
VM_ARGUMENTS="$VM_ARGUMENTS $i"
else
ARGUMENTS="$ARGUMENTS $i"
fi
done
# Execute java
java -Xmx1024m -XX:MaxPermSize=128m -cp $CLASSPATH -Dch.psi.fda.home=${APPLICATION_HOME} -Djava.util.logging.config.file=${APPLICATION_HOME}/config/logging.properties $VM_ARGUMENTS ch.psi.fda.VisualizationMain $ARGUMENTS

View File

@@ -26,7 +26,6 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
@@ -91,8 +90,6 @@ public class AcquisitionMain {
boolean nogui = false;
String files[] = null;
HashMap<String,String> varTable = new HashMap<String,String>();
// Iterations option
OptionBuilder.hasArg();
OptionBuilder.withArgName("iterations");
@@ -100,19 +97,11 @@ public class AcquisitionMain {
OptionBuilder.withType(new Integer(1));
Option o_iterations = OptionBuilder.create( "iterations");
// Variables option
OptionBuilder.hasArg();
OptionBuilder.withArgName("variables");
OptionBuilder.withDescription("Scan variables - variables are specified in the form var=value,var2=value2");
OptionBuilder.withType(new Integer(1));
Option o_variables = OptionBuilder.create( "variables");
Option o_autoclose = new Option( "autoclose", "Close down application after scan" );
Option o_init = new Option( "initialize", "Initialize application directories and configuration files" );
Option o_nogui = new Option( "nogui", "Do not show scan GUI" );
Options options = new Options();
options.addOption(o_variables);
options.addOption(o_iterations);
options.addOption(o_autoclose);
options.addOption(o_init);
@@ -142,19 +131,6 @@ public class AcquisitionMain {
iterations = Integer.parseInt(line.getOptionValue(o_iterations.getOpt()));
}
// Variables
if( line.hasOption(o_variables.getOpt()) ){
String variables = line.getOptionValue(o_variables.getOpt() );
String[] vars = variables.split(",");
for(String varp:vars){
String[] pair = varp.split("=");
if(pair.length!=2){
throw new ParseException("Variables are not specified the correct way. -variables var1=val1,var2=val2");
}
varTable.put(pair[0], pair[1]);
}
}
// Autoclose option
if( line.hasOption( o_autoclose.getOpt() ) ) {
autoclose = true;
@@ -175,7 +151,7 @@ public class AcquisitionMain {
// Run application
try{
for(String file: files){
run(new File(file), iterations, autoclose, nogui, varTable);
run(new File(file), iterations, autoclose, nogui);
}
// Close application automatically if autoclose option is set (and visualizations are specified)
@@ -200,7 +176,7 @@ public class AcquisitionMain {
* @param nogui Flag whether to run the scan with a GUI
* @param variables Table of scan variables
*/
public static void run(File file, Integer iterations, boolean autoclose, boolean nogui, HashMap<String,String> variables){
public static void run(File file, Integer iterations, boolean autoclose, boolean nogui){
// Initialize application
ApplicationConfigurator ac = new ApplicationConfigurator();

View File

@@ -38,14 +38,13 @@ import com.google.common.eventbus.EventBus;
import ch.psi.fda.deserializer.DataDeserializer;
import ch.psi.fda.deserializer.DataDeserializerMDA;
import ch.psi.fda.deserializer.DataDeserializerTXT;
import ch.psi.fda.serializer.DataSerializer;
import ch.psi.fda.serializer.DataSerializerMAT;
import ch.psi.fda.serializer.DataSerializerMAT2D;
import ch.psi.fda.serializer.DataSerializerMAT2DZigZag;
import ch.psi.fda.serializer.DataSerializerMDA;
import ch.psi.fda.serializer.DataSerializerTXT;
import ch.psi.fda.serializer.DataSerializerTXT2D;
import ch.psi.fda.serializer.DataSerializerTXTSplit;
import ch.psi.fda.serializer.SerializerMAT;
import ch.psi.fda.serializer.SerializerMAT2D;
import ch.psi.fda.serializer.SerializerMAT2DZigZag;
import ch.psi.fda.serializer.SerializerMDA;
import ch.psi.fda.serializer.SerializerTXT;
import ch.psi.fda.serializer.SerializerTXT2D;
import ch.psi.fda.serializer.SerializerTXTSplit;
/**
* Converter to convert the format of datafiles
@@ -98,34 +97,32 @@ public class ConversionMain {
throw new IllegalArgumentException("Reader of type "+reader+" not supported.");
}
DataSerializer serializer;
if(writer.equals(Writer.MAT)){
serializer = new DataSerializerMAT(output);
bus.register(new SerializerMAT(output));
}
else if(writer.equals(Writer.MAT_2D)){
serializer = new DataSerializerMAT2D(output);
bus.register(new SerializerMAT2D(output));
}
else if(writer.equals(Writer.TXT)){
serializer = new DataSerializerTXT(output, false);
bus.register(new SerializerTXT(output, false));
}
else if(writer.equals(Writer.TXT_2D)){
serializer = new DataSerializerTXT2D(output);
bus.register(new SerializerTXT2D(output));
}
else if(writer.equals(Writer.TXT_SPLIT)){
serializer = new DataSerializerTXTSplit(output);
bus.register(new SerializerTXTSplit(output));
}
else if(writer.equals(Writer.MDA)){
serializer = new DataSerializerMDA(output);
bus.register(new SerializerMDA(output));
}
else if(writer.equals(Writer.MAT_2D_Z)){
serializer = new DataSerializerMAT2DZigZag(output);
bus.register(new SerializerMAT2DZigZag(output));
}
else{
throw new IllegalArgumentException("Writer of type "+writer+" not supported.");
}
// Start conversion
bus.register(serializer);
deserializer.read();
}

View File

@@ -20,13 +20,9 @@
package ch.psi.fda;
import java.awt.FlowLayout;
import java.awt.Label;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -37,15 +33,20 @@ import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.ScrollPaneLayout;
import org.jeromq.ZMQ;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import ch.psi.fda.aq.VisualizationMapper;
import ch.psi.fda.gui.ScrollableFlowPanel;
import ch.psi.fda.visualizer.SeriesDataFilter;
import ch.psi.fda.model.v1.Visualization;
import ch.psi.fda.rest.client.StreamClient;
import ch.psi.fda.visualizer.Visualizer;
import ch.psi.fda.visualizer.XYSeriesDataFilter;
import ch.psi.plot.xy.LinePlot;
/**
* Visualize data according to the scan description
@@ -54,6 +55,13 @@ public class ViewerMain {
private static Logger logger = Logger.getLogger(ViewerMain.class.getName());
private Visualizer visualizer;
private String source;;
public ViewerMain(String source){
this.source = source;
}
/**
* Visualize data
* @param configuration
@@ -62,32 +70,20 @@ public class ViewerMain {
*/
public void visualize() throws InterruptedException{
List<SeriesDataFilter> filters = new ArrayList<>();
filters.add(new XYSeriesDataFilter("id0", "timestamp", new LinePlot("One")));
Visualizer visualizer = new Visualizer(filters);
// visualizer.setTerminateAtEOS(true);
// Adapt default visualizer behavior to optimize performance for visualization
visualizer.setUpdateAtStreamElement(true);
visualizer.setUpdateAtStreamDelimiter(true);
visualizer.setUpdateAtEndOfStream(true);
JPanel opanel = new ScrollableFlowPanel();
final JPanel opanel = new ScrollableFlowPanel();
opanel.setLayout(new FlowLayout());
opanel.add(new Label());
JScrollPane spane = new JScrollPane(opanel, ScrollPaneLayout.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneLayout.HORIZONTAL_SCROLLBAR_NEVER);
JTabbedPane tpane = new JTabbedPane();
tpane.addTab("Overview", spane);
for (JPanel p : visualizer.getPlotPanels()) {
opanel.add(p);
}
final JFrame frame = new JFrame();
frame.setSize(1200,800);
frame.add(tpane);
// frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.addWindowListener(new WindowAdapter(){
@Override
public void windowClosing(WindowEvent we){
@@ -103,39 +99,39 @@ public class ViewerMain {
});
// Start receiving messages
EventBus bus = new EventBus();
bus.register(visualizer);
visualizer.configure();
final EventBus bus = new EventBus();
ZMQ.Context context = ZMQ.context();
zmq.ZError.clear(); // Clear error code
ZMQ.Socket socket = context.socket(ZMQ.SUB);
socket.connect("tcp://emac:10000");
socket.subscribe(""); // SUBSCRIBE !
bus.register(new Object(){
@Subscribe
public void onMessage(List<Visualization> vis){
logger.info("Build up new visualization");
// De-register old visualizer
if(visualizer!=null){
bus.unregister(visualizer);
}
visualizer = new Visualizer(VisualizationMapper.mapVisualizations(vis));
visualizer.setUpdateAtStreamElement(true);
visualizer.setUpdateAtStreamDelimiter(true);
visualizer.setUpdateAtEndOfStream(true);
opanel.removeAll();
for (JPanel p : visualizer.getPlotPanels()) {
opanel.add(p);
}
frame.repaint();
bus.register(visualizer);
visualizer.configure();
}
});
while(true){
byte[] content = null;
// String header = socket.recvStr(); // header
socket.recvStr(); // header
while(socket.hasReceiveMore()){
content = socket.recv();
}
if(content==null){ // we lost something discard read messages
logger.warning("Lost some message - discard and continue");
continue;
}
try (
ByteArrayInputStream bis = new ByteArrayInputStream(content);
ObjectInput in = new ObjectInputStream(bis);
) {
Object o = in.readObject();
bus.post(o);
} catch (IOException | ClassNotFoundException e) {
logger.log(Level.WARNING,"Unable to deserialize message",e);
}
}
new StreamClient(bus).listen(source);
}
/**
@@ -147,9 +143,38 @@ public class ViewerMain {
*/
public static void main(String[] args) {
int port = 10000;
String hostname = "localhost";
Options options = new Options();
options.addOption("h", false, "Help");
options.addOption("p", true, "Server port (default: "+port+")");
options.addOption("s", true, "Server address (default: "+hostname+")");
GnuParser parser = new GnuParser();
try {
CommandLine line = parser.parse(options, args);
if (line.hasOption("p")) {
port = Integer.parseInt(line.getOptionValue("p"));
}
if (line.hasOption("s")) {
hostname = line.getOptionValue("s");
}
if (line.hasOption("h")) {
HelpFormatter f = new HelpFormatter();
f.printHelp("viewer", options);
return;
}
} catch (ParseException e1) {
System.err.println("Wrong arguments: "+ e1.getMessage());
System.exit(-1);
}
try{
ViewerMain e = new ViewerMain();
ViewerMain e = new ViewerMain("tcp://"+hostname+":"+port);
e.visualize();
}
catch(Exception ee){

View File

@@ -106,7 +106,7 @@ import ch.psi.fda.model.v1.SimpleScalarDetector;
import ch.psi.fda.model.v1.Timestamp;
import ch.psi.fda.model.v1.Variable;
import ch.psi.fda.model.v1.VariableParameterMapping;
import ch.psi.fda.serializer.DataSerializerTXT;
import ch.psi.fda.serializer.SerializerTXT;
import ch.psi.jcae.Channel;
import ch.psi.jcae.ChannelDescriptor;
import ch.psi.jcae.ChannelException;
@@ -119,8 +119,6 @@ import ch.psi.jcae.util.ComparatorREGEX;
/**
* Data acquisition engine for performing scans
* Mapping is specific to scan model version 1.0
* @author ebner
*
*/
public class Acquisition {
@@ -130,7 +128,7 @@ public class Acquisition {
private ActionLoop actionLoop;
private Manipulator manipulator;
private DataSerializerTXT serializer;
private SerializerTXT serializer;
private List<Manipulation> manipulations;
private volatile boolean active = false;
@@ -250,7 +248,7 @@ public class Acquisition {
b.register(this.manipulator);
this.serializer = new DataSerializerTXT(datafile, true);
this.serializer = new SerializerTXT(datafile, true);
bus.register(serializer);
}
else{
@@ -259,7 +257,7 @@ public class Acquisition {
mapScan(collector, smodel);
// col = collector;
this.serializer = new DataSerializerTXT(datafile, true);
this.serializer = new SerializerTXT(datafile, true);
bus.register(serializer);
}
}
@@ -269,7 +267,13 @@ public class Acquisition {
* @throws InterruptedException
*/
public void execute() throws InterruptedException {
String hostname;
try {
hostname = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
hostname="unknown";
}
try{
active = true;
@@ -277,38 +281,16 @@ public class Acquisition {
actionLoop.execute();
actionLoop.cleanup();
// Send notifications out to all recipients that want to have success notifications
try {
String hostname = InetAddress.getLocalHost().getHostName();
notificationAgent.sendNotification("Notification - FDA Execution Finished", "The execution of the FDA on '"+hostname+"' for file '"+datafile.getName()+"' finished successfully\n\nYou received this message because you are listed in the notification list for this data acquisition configuration.", false,true);
} catch (UnknownHostException e1) {
logger.log(Level.WARNING, "Unable to send notification", e1);
}
notificationAgent.sendNotification("Notification - FDA Execution Finished", "The execution of the FDA on '"+hostname+"' for file '"+datafile.getName()+"' finished successfully\n\nYou received this message because you are listed in the notification list for this data acquisition configuration.", false,true);
}
catch(RuntimeException e){
logger.log(Level.WARNING, "Execution failed: ", e);
try {
String hostname = InetAddress.getLocalHost().getHostName();
notificationAgent.sendNotification("Notification - FDA Execution Failed", "The execution of the FDA failed on '"+hostname+"' for file '"+datafile.getName()+"'\n\nYou received this message because you are listed in the notification list for this data acquisition configuration.", true,false);
} catch (UnknownHostException e1) {
logger.log(Level.WARNING, "Unable to send notification", e1);
}
notificationAgent.sendNotification("Notification - FDA Execution Failed", "The execution of the FDA failed on '"+hostname+"' for file '"+datafile.getName()+"'\n\nYou received this message because you are listed in the notification list for this data acquisition configuration.", true,false);
throw e;
}
catch(InterruptedException e){
logger.log(Level.WARNING, "Execution interrupted: ", e);
// Execution got aborted.
try {
String hostname = InetAddress.getLocalHost().getHostName();
notificationAgent.sendNotification("Notification - FDA Execution was aborted", "The execution of the FDA on '"+hostname+"' for file '"+datafile.getName()+"' was aborted\n\nYou received this message because you are listed in the notification list for this data acquisition configuration.", false, true);
} catch (UnknownHostException e1) {
logger.log(Level.WARNING, "Unable to send notification", e1);
}
// throw e;
notificationAgent.sendNotification("Notification - FDA Execution was aborted", "The execution of the FDA on '"+hostname+"' for file '"+datafile.getName()+"' was aborted\n\nYou received this message because you are listed in the notification list for this data acquisition configuration.", false, true);
}
finally{
active = false;
@@ -340,10 +322,6 @@ public class Acquisition {
// Clear global variables Jython
jVariableDictionary.clear();
// // Destroy the CA context
// cservice.destroy();
// logger.fine("ChannelService destroyed");
// Remove log handler
if(logHandler!=null){
logger.fine("Close log handler");
@@ -352,15 +330,8 @@ public class Acquisition {
}
}
/**
* Abort acquisition
*/
public void abort(){
actionLoop.abort();
// if(acquisitionThread!=null){
// acquisitionThread.interrupt();
// }
}
public String getDatafileName(){

View File

@@ -19,6 +19,7 @@
package ch.psi.fda.aq;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
@@ -29,12 +30,6 @@ import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import ch.psi.fda.install.ApplicationConfigurator;
/**
* @author ebner
*
*/
public class AcquisitionConfiguration {
@@ -77,27 +72,21 @@ public class AcquisitionConfiguration {
* The constructor will read the configuration from the /fda.properties file (resource) located in the classpath.
*/
public AcquisitionConfiguration(){
loadConfiguration();
}
public void loadConfiguration(){
loadConfiguration(null);
loadConfiguration(System.getProperty(FDA_CONFIG_FILE));
}
/**
* Load configuration from properties file
*/
public void loadConfiguration(String file) {
if(file == null){
file = System.getProperty(FDA_CONFIG_FILE);
}
Properties properties = new Properties();
File cfile = null;
// Only read in the property file if a file is specified
if(file != null){
cfile = new File(file);
try {
properties.load(new FileReader(file));
properties.load(new FileReader(cfile));
} catch (FileNotFoundException e) {
throw new RuntimeException("Configuration file "+file+" not found", e);
} catch (IOException e) {
@@ -118,16 +107,15 @@ public class AcquisitionConfiguration {
otfUseCrlogic = new Boolean(properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".otf.useCrlogic", "false"));
otfCrlogicPrefix = properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".otf.crlogicPrefix", "");
otfCrlogicKeepTmpFiles = new Boolean(properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".otf.crlogicKeepTmpFiles", "false"));
if(System.getProperty(ApplicationConfigurator.FDA_HOME_ARGUMENT)!=null){ // TODO remove
dataBaseDirectory = System.getProperty(ApplicationConfigurator.FDA_HOME_ARGUMENT)+"/data";
dataBaseDirectory = properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".data.dir",".");
if(cfile!=null && dataBaseDirectory.matches("^\\.\\.?/.*")){ // if basedir starts with . or .. we assume the data directory to be relative to the directory of the configuration file
dataBaseDirectory = cfile.getParentFile().getAbsolutePath()+"/"+dataBaseDirectory;
}
else{
dataBaseDirectory = "./data";
}
dataFilePrefix = properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".data.filePrefix","");
actorMoveTimeout = new Long(properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".actorMoveTimeout","600000"));
smptServer= properties.getProperty(AcquisitionConfiguration.class.getPackage().getName()+".notification.host","mail.psi.ch");

View File

@@ -25,11 +25,11 @@ import java.util.List;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.core.messages.StreamDelimiterMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.EndOfStreamMessage;
import ch.psi.fda.messages.Message;
import ch.psi.fda.messages.Metadata;
import ch.psi.fda.messages.StreamDelimiterMessage;
/**
* Collector class that is collecting and merging data from different Queues.

View File

@@ -26,9 +26,9 @@ import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import ch.psi.fda.core.Manipulation;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.Message;
import ch.psi.fda.messages.Metadata;
/**
* Applies manipulations to the data stream

View File

@@ -36,10 +36,6 @@ import ch.psi.fda.visualizer.XYZSeriesDataFilter;
import ch.psi.plot.xyz.MatrixPlot;
import ch.psi.plot.xyz.MatrixPlotData;
/**
* @author ebner
*
*/
public class VisualizationMapper {
@@ -69,6 +65,12 @@ public class VisualizationMapper {
return id;
}
/**
* Converts a list of visualizations into a list of data filters which can be applied to the data stream
*
* @param vl
* @return
*/
public static List<SeriesDataFilter> mapVisualizations(List<Visualization> vl){
List<SeriesDataFilter> filters = new ArrayList<SeriesDataFilter>();

View File

@@ -21,8 +21,8 @@ package ch.psi.fda.core;
import java.util.List;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.Metadata;
public interface Manipulation {

View File

@@ -35,9 +35,9 @@ import ch.psi.fda.core.Actor;
import ch.psi.fda.core.ActorSetCallable;
import ch.psi.fda.core.Guard;
import ch.psi.fda.core.Sensor;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.EndOfStreamMessage;
import ch.psi.fda.messages.Metadata;
/**
* Loop of actions to accomplish a task or test.

View File

@@ -39,9 +39,9 @@ import com.google.common.eventbus.EventBus;
import jcifs.smb.SmbFile;
import ch.psi.fda.core.Action;
import ch.psi.fda.core.ActionLoop;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.EndOfStreamMessage;
import ch.psi.fda.messages.Metadata;
import ch.psi.jcae.ChannelException;
import ch.psi.jcae.ChannelService;

View File

@@ -38,7 +38,7 @@ import com.google.common.eventbus.Subscribe;
import ch.psi.fda.core.Action;
import ch.psi.fda.core.ActionLoop;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.messages.Message;
public class ParallelCrlogic implements ActionLoop {

View File

@@ -25,10 +25,10 @@ import java.util.concurrent.BlockingQueue;
import com.google.common.eventbus.EventBus;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.EndOfStreamMessage;
import ch.psi.fda.messages.Message;
import ch.psi.fda.messages.Metadata;
/**
* Class to merge two data streams into one. The secondary queues data is added to the primary queues data.

View File

@@ -32,9 +32,9 @@ import com.google.common.eventbus.EventBus;
import ch.psi.fda.core.Action;
import ch.psi.fda.core.ActionLoop;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.EndOfStreamMessage;
import ch.psi.fda.messages.Metadata;
import ch.psi.jcae.Channel;
import ch.psi.jcae.impl.type.DoubleTimestamp;

View File

@@ -32,10 +32,10 @@ import com.google.common.eventbus.EventBus;
import ch.psi.fda.core.Action;
import ch.psi.fda.core.ActionLoop;
import ch.psi.fda.core.Sensor;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.core.sensors.TimestampSensor;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.EndOfStreamMessage;
import ch.psi.fda.messages.Metadata;
/**
* ActionLoop that is implementing the OTF Scan logic.

View File

@@ -33,12 +33,12 @@ import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import ch.psi.fda.core.Manipulation;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.core.scripting.JythonParameterMapping;
import ch.psi.fda.core.scripting.JythonParameterMappingChannel;
import ch.psi.fda.core.scripting.JythonParameterMappingGlobalVariable;
import ch.psi.fda.core.scripting.JythonParameterMappingID;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.Metadata;
public class JythonManipulation implements Manipulation{

View File

@@ -1,29 +0,0 @@
/**
*
* Copyright 2010 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.core.messages;
/**
* A control message that is not holding any data but
* control information (like end of loop, etc.)
*/
public abstract class ControlMessage extends Message{
private static final long serialVersionUID = 1L;
}

View File

@@ -1,105 +0,0 @@
/**
*
* Copyright 2010 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.core.messages;
import java.util.ArrayList;
import java.util.List;
/**
* Message holding data
*/
public class DataMessage extends Message{
private static final long serialVersionUID = 1L;
private final List<Object> data;
private List<Metadata> metadata;
// public DataMessage(){
// this.data = new ArrayList<Object>();
// this.metadata = new ArrayList<>();
// }
//
public DataMessage(List<Metadata> metadata){
this.data = new ArrayList<Object>();
this.metadata = metadata;
}
public List<Object> getData(){
return(data);
}
public List<Metadata> getMetadata(){
return metadata;
}
public void setMetadata(List<Metadata> metadata){
this.metadata = metadata;
}
// Utility functions
@SuppressWarnings("unchecked")
public <T> T getData(String id){
int i=0;
for(Metadata m: metadata){
if(m.getId().equals(id)){
return (T) data.get(i);
}
i++;
}
throw new IllegalArgumentException("No data found for id: "+id);
}
public Metadata getMetadata(String id){
for(Metadata m: metadata){
if(m.getId().equals(id)){
return m;
}
}
throw new IllegalArgumentException("No data found for id: "+id);
}
@Override
public String toString() {
StringBuffer b = new StringBuffer();
b.append("Message [ ");
for (Object o : data) {
if (o.getClass().isArray()) {
// If the array object is of type double[] display its content
if (o instanceof double[]) {
double[] oa = (double[]) o;
b.append("[ ");
for (double o1 : oa) {
b.append(o1);
b.append(" ");
}
b.append("]");
} else {
b.append(o.toString());
}
} else {
b.append(o);
}
b.append(" ");
}
b.append("]");
return b.toString();
}
}

View File

@@ -1,52 +0,0 @@
/**
*
* Copyright 2010 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.core.messages;
/**
* Message that is send at the end of the action loop inside an ActionLoop implementation
* of just to indicate that a particular stream has finished
*/
public class EndOfStreamMessage extends ControlMessage {
private static final long serialVersionUID = 1L;
/**
* Intersect flag - flag to indicate that stream should be intersected
* after this message.
*/
private final boolean iflag;
public EndOfStreamMessage(){
this(false);
}
public EndOfStreamMessage(boolean iflag){
this.iflag = iflag;
}
public boolean isIflag(){
return(iflag);
}
@Override
public String toString() {
return "Message[ c message: end of stream ]";
}
}

View File

@@ -1,29 +0,0 @@
/**
*
* Copyright 2010 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.core.messages;
import java.io.Serializable;
/**
* Message that can be put to the data queue
*/
public abstract class Message implements Serializable{
private static final long serialVersionUID = 1L;
}

View File

@@ -1,58 +0,0 @@
/**
*
* Copyright 2010 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.core.messages;
import java.io.Serializable;
/**
* Metadata of a component of a message. Each component has a global id.
* Optionally the component can also belong to a dimension. However, depending on the
* view the number of the dimension might vary. Therefore the dimension number
* might change during the lifetime of a message (component).
*/
public class Metadata implements Serializable{
private static final long serialVersionUID = 1L;
private final String id;
private int dimension;
public Metadata(String id){
this.id = id;
this.dimension = 0;
}
public Metadata(String id, int dimension){
this.id = id;
this.dimension = dimension;
}
public void setDimension(int dimension){
this.dimension = dimension;
}
public int getDimension() {
return dimension;
}
public String getId() {
return id;
}
}

View File

@@ -1,67 +0,0 @@
/**
*
* Copyright 2010 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.core.messages;
/**
* Message that is send at the end of the action loop inside an ActionLoop implementation
*/
public class StreamDelimiterMessage extends ControlMessage{
private static final long serialVersionUID = 1L;
/**
* Number of the dimension this delimiter belongs to.
*/
private final int number;
/**
* Intersect flag - flag to indicate that stream should be intersected
* after this message.
*/
private final boolean iflag;
/**
* @param number Number of the dimension this delimiter belongs to
*/
public StreamDelimiterMessage(int number){
this(number, false);
}
/**
* @param number
* @param iflag Flag to indicate that data is grouped
*/
public StreamDelimiterMessage(int number, boolean iflag){
this.number = number;
this.iflag = iflag;
}
public int getNumber() {
return number;
}
public boolean isIflag(){
return iflag;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return "Message [ c message: delimiter dimension "+number+" ]";
}
}

View File

@@ -13,11 +13,11 @@ import java.util.logging.Logger;
import com.google.common.eventbus.EventBus;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.core.messages.StreamDelimiterMessage;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.EndOfStreamMessage;
import ch.psi.fda.messages.Message;
import ch.psi.fda.messages.Metadata;
import ch.psi.fda.messages.StreamDelimiterMessage;
/**
* Deserializer MDA file

View File

@@ -29,10 +29,10 @@ import java.util.logging.Logger;
import com.google.common.eventbus.EventBus;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.core.messages.StreamDelimiterMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.EndOfStreamMessage;
import ch.psi.fda.messages.Metadata;
import ch.psi.fda.messages.StreamDelimiterMessage;
/**
* Deserializer for text files

View File

@@ -81,15 +81,8 @@ public class ApplicationConfigurator {
createApplicationHome();
createDefaultConfigurationFiles();
// Configure used packages / e.g. via setting system/environment parameters, etc.
// Set logging configuration -Djava.util.logging=...
String property = System.getProperty("java.util.logging.config.file");
if(property==null){
System.setProperty("java.util.logging.config.file", loggingProperties.getAbsolutePath());
}
// Set FDA configuration argument -Dch.psi.fda.config.file=...
property = System.getProperty(AcquisitionConfiguration.FDA_CONFIG_FILE);
String property = System.getProperty(AcquisitionConfiguration.FDA_CONFIG_FILE);
if(property==null){
System.setProperty(AcquisitionConfiguration.FDA_CONFIG_FILE, fdaProperties.getAbsolutePath());
}
@@ -237,7 +230,7 @@ public class ApplicationConfigurator {
BufferedWriter writer = new BufferedWriter(new FileWriter(fdaProperties));
PrintWriter w = new PrintWriter(writer);
// w.println("ch.psi.fda.aq.data.baseDirectory="+datadir.getAbsolutePath());
w.println("ch.psi.fda.aq.data.dir=../data");
w.println("ch.psi.fda.aq.data.filePrefix=${yyyy_MM}/${yyyyMMdd}/${yyyyMMddHHmmss}_${name}/${yyyyMMddHHmm}_");
w.println();

View File

@@ -18,18 +18,18 @@
*/
package ch.psi.fda.rest;
import java.util.UUID;
import java.util.concurrent.BlockingQueue;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.logging.Logger;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.inject.Inject;
import com.google.common.eventbus.EventBus;
import ch.psi.fda.aq.Acquisition;
import ch.psi.fda.aq.AcquisitionConfiguration;
import ch.psi.fda.model.v1.Configuration;
import ch.psi.jcae.ChannelService;
@@ -39,69 +39,18 @@ import ch.psi.jcae.ChannelService;
*/
public class AcquisitionEngine {
private static final Logger logger = Logger.getLogger(AcquisitionEngine.class.getName());
private AcquisitionConfiguration config;
private ChannelService cservice;
private final ZMQDataService dservice;
private final AcquisitionConfiguration config;
private final ChannelService cService;
private final ZMQDataService zmqService;
/**
* Variable holding the current acquisition
*/
private volatile Acquisition acquisition;
private volatile ExecutionRequest currentRequest;
private ExecutorService eservice;
private BlockingQueue<ExecutionRequest> requests = new LinkedBlockingQueue<>();
private final ExecutorService eservice = Executors.newSingleThreadExecutor();
private final Map<String, Future<?>> erequests = new HashMap<>();
@Inject
public AcquisitionEngine(ChannelService cservice, ZMQDataService dservice, AcquisitionConfiguration config) {
this.dservice = dservice;
this.cservice = cservice;
public AcquisitionEngine(ChannelService cService, ZMQDataService zmqService, AcquisitionConfiguration config) {
this.zmqService = zmqService;
this.cService = cService;
this.config = config;
// Start main execution loop
eservice = Executors.newSingleThreadExecutor();
eservice.execute(new Runnable() {
@Override
public void run() {
try {
while (!Thread.currentThread().isInterrupted()) {
try {
ExecutionRequest r = requests.take();
logger.info("Execute - " + r.getTrackingId());
EventBus ebus = new EventBus();
// Provide tracking id to data service and register the service to the event bus
AcquisitionEngine.this.dservice.setTrackingId(r.getTrackingId());
ebus.register(AcquisitionEngine.this.dservice);
synchronized (AcquisitionEngine.this) { // synchronize access to acquisition object via the AcquisitionEngine object
acquisition = new Acquisition(AcquisitionEngine.this.cservice, AcquisitionEngine.this.config);
currentRequest = r;
}
acquisition.initalize(ebus, r.getConfiguration());
acquisition.execute();
logger.info("" + r.getTrackingId() + " done");
// Cleanup
ebus.unregister(AcquisitionEngine.this.dservice);
} finally {
acquisition.destroy();
synchronized (AcquisitionEngine.this) {
acquisition = null;
currentRequest = null;
}
}
}
} catch (InterruptedException e) {
}
}
});
}
/**
@@ -111,27 +60,30 @@ public class AcquisitionEngine {
* @param configuration
* @return
*/
public String submit(Configuration configuration){
ExecutionRequest r = new ExecutionRequest(UUID.randomUUID().toString(), configuration);
try{
requests.put(r);
} catch (InterruptedException e) {
public void submit(String trackingId, Configuration configuration){
if(erequests.keySet().contains(trackingId) && !erequests.get(trackingId).isDone()){ // Allow finished tracking ids to be reused for new scans
throw new IllegalArgumentException("A request with tracking ID "+trackingId+" is already submitted");
}
return r.getTrackingId();
AcquisitionJob job = new AcquisitionJob(cService, zmqService, config, trackingId, configuration);
Future<?> future = eservice.submit(job);
erequests.put(trackingId, future);
}
/**
* Terminate the currently executed request
*/
public void terminate(){
synchronized(this){
if(acquisition==null){
return;
public void terminateAll() {
for(Future<?> f: erequests.values()){
f.cancel(true);
}
for(Future<?> f: erequests.values()){
try{
f.get(10, TimeUnit.SECONDS);
}
catch(CancellationException | InterruptedException | ExecutionException | TimeoutException e){
// Nothing to be done here
}
logger.info("Stop current acquisition");
acquisition.abort();
}
}
@@ -142,29 +94,38 @@ public class AcquisitionEngine {
*/
public void terminate(String trackingId){
// If request is currently executed terminate it
if(currentRequest.getTrackingId().equals(trackingId)){
terminate();
return;
final Future<?> f = erequests.get(trackingId);
if(f==null){
throw new IllegalArgumentException("There is no request running/pending with tracking id "+trackingId);
}
// Remove request from request queue
ExecutionRequest rremove = null;
for(ExecutionRequest r:requests){
if(r.getTrackingId().equals(trackingId)){
rremove = r; // We have to split the filtering and termination as we otherwise get a concurrent access exception.
break;
}
f.cancel(true);
try{
f.get(10, TimeUnit.SECONDS);
}
if(rremove!=null){
boolean b = requests.remove(rremove);
// There is a chance that between the upper loop and here the request
// already got dequeued. This check ensures that the requests got removed
// if not it got dequeued and therefore we have to terminate the current
// execution.
if(!b){
terminate();
}
catch(CancellationException | InterruptedException | ExecutionException | TimeoutException e){
// Nothing to be done here
}
}
public boolean isActive(String trackingId) {
Future<?> f = erequests.get(trackingId);
if(f==null){
throw new IllegalArgumentException("There is no request for tracking id "+trackingId);
}
return !f.isDone();
}
/**
* Wait for the termination of the scan request
* @param trackingId
* @throws ExecutionException
* @throws InterruptedException
*/
public void wait(String trackingId) throws InterruptedException, ExecutionException{
Future<?> f = erequests.get(trackingId);
if(f==null){
throw new IllegalArgumentException("There is no request for tracking id "+trackingId);
}
f.get();
}
}

View File

@@ -0,0 +1,80 @@
/**
*
* 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;
import java.util.logging.Logger;
import ch.psi.fda.aq.Acquisition;
import ch.psi.fda.aq.AcquisitionConfiguration;
import ch.psi.fda.model.v1.Configuration;
import ch.psi.jcae.ChannelService;
import com.google.common.eventbus.EventBus;
public class AcquisitionJob implements Runnable {
private static final Logger logger = Logger.getLogger(AcquisitionJob.class.getName());
private final AcquisitionConfiguration config;
private final ChannelService cService;
private final ZMQDataService zmqService;
private final String trackingId;
private final Configuration configuration;
public AcquisitionJob(ChannelService cService, ZMQDataService zmqService, AcquisitionConfiguration config, String trackingId, Configuration configuration) {
this.zmqService = zmqService;
this.cService = cService;
this.config = config;
this.trackingId = trackingId;
this.configuration = configuration;
}
@Override
public void run() {
Acquisition acquisition = null;
try {
logger.info("Execute - " + trackingId);
EventBus ebus = new EventBus();
zmqService.setTrackingId(trackingId);
ebus.register(zmqService);
// Post visualization configuration
ebus.post(configuration.getVisualization());
acquisition = new Acquisition(cService, config);
acquisition.initalize(ebus, configuration);
acquisition.execute();
logger.info("" + trackingId + " done");
// Cleanup
ebus.unregister(zmqService);
} catch (InterruptedException e) {
logger.info("Execution of "+trackingId+ " was interrupted");
} finally {
if(acquisition!=null){
acquisition.destroy();
}
}
}
}

View File

@@ -0,0 +1,99 @@
/**
*
* 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;
import java.io.File;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.inject.Inject;
import ch.psi.fda.cdump.Cdump;
import ch.psi.fda.cdump.CdumpConfiguration;
import ch.psi.fda.rest.model.CdumpRequest;
import ch.psi.fda.serializer.SerializerTXT;
import ch.psi.jcae.ChannelService;
import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
public class CdumpEngine {
private Cdump cdump;
private EventBus bus;
private ZMQDataService zmqService;
private ChannelService cservice;
private CdumpConfiguration configuration;
private boolean stream = false;
private ExecutorService eservice;
@Inject
public CdumpEngine(ChannelService cservice, ZMQDataService zmqService, CdumpConfiguration configuration){
this.cservice = cservice;
this.zmqService = zmqService;
this.configuration = configuration;
eservice = Executors.newSingleThreadExecutor();
}
public void acquire(String trackingId, final CdumpRequest request){
if(cdump!=null){
throw new IllegalStateException("Cdump is already running");
}
bus = new AsyncEventBus(Executors.newSingleThreadExecutor());
cdump = new Cdump(cservice,bus,configuration);
SerializerTXT serializer = new SerializerTXT(new File(request.getFilename()));
serializer.setShowDimensionHeader(false);
bus.register(serializer);
stream = (request.getStream()!=null && request.getStream().getIds().length>0) ;
if(stream){
// Stream data via ZMQ
zmqService.setTrackingId(trackingId);
// TODO set id filter !!!
bus.register(zmqService);
}
eservice.execute(new Runnable() {
@Override
public void run() {
cdump.acquire(request.getSamplingRate());
}
});
}
public void stop(){
cdump.stop();
cdump = null;
bus.unregister(zmqService);
}
public boolean isActive(){
return cdump!=null;
}
}

View File

@@ -18,22 +18,24 @@ 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 sun.misc.Signal;
import sun.misc.SignalHandler;
@SuppressWarnings("restriction")
public class RestServer {
public class FdaServer {
private static final Logger logger = Logger.getLogger(RestServer.class.getName());
private static final Logger logger = Logger.getLogger(FdaServer.class.getName());
public static void main(String[] args) throws IOException, ParseException {
// Option handling
int port = 8080;
String hostname = InetAddress.getLocalHost().getHostName();
Options options = new Options();
options.addOption("h", false, "Help");
options.addOption("p", true, "Server port (default: "+port+")");
options.addOption("s", true, "Server address (default: "+hostname+")");
GnuParser parser = new GnuParser();
CommandLine line = parser.parse(options, args);
@@ -41,35 +43,44 @@ public class RestServer {
if (line.hasOption("p")) {
port = Integer.parseInt(line.getOptionValue("p"));
}
if (line.hasOption("s")) {
hostname = line.getOptionValue("s");
}
if (line.hasOption("h")) {
HelpFormatter f = new HelpFormatter();
f.printHelp("broker", options);
f.printHelp("fda", options);
return;
}
URI baseUri = UriBuilder.fromUri("http://" + InetAddress.getLocalHost().getHostName() + "/").port(port).build();
// set the correct environment variable based on ch.psi.fda.home variable
ApplicationConfigurator ac = new ApplicationConfigurator();
ac.initializeApplication();
URI baseUri = UriBuilder.fromUri("http://" + hostname + "/").port(port).build();
// Broker broker = createBroker(config);
ResourceBinder binder = new ResourceBinder();
ResourceConfig resourceConfig = new ResourceConfig(JacksonFeature.class);
resourceConfig.packages(RestServer.class.getPackage().getName()+".services"); // Services are located in services package
ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig.packages(FdaServer.class.getPackage().getName()+".services"); // Services are located in services package
resourceConfig.register(binder);
resourceConfig.register(JacksonFeature.class);
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig);
// Static content
// String home = System.getenv("BROKER_BASE");
// String home = System.getenv("FDA_BASE");
// if (home == null) {
// home = "src/main/assembly";
// }
// home = home + "/www";
// server.getServerConfiguration().addHttpHandler(new StaticHttpHandler(home), "/static");
logger.info("Broker started");
// logger.info(String.format("Management interface available at %sstatic/", baseUri));
logger.info("Server started");
logger.info("Use ctrl+c to stop ...");
// Signal handling
@@ -89,10 +100,9 @@ public class RestServer {
latch.await();
} catch (InterruptedException e) {
}
server.stop();
// broker.terminate();
server.shutdownNow();
logger.info("Server terminated");
System.exit(0); // TODO need to shutdown ChannelService correctly !!!!
}
}

View File

@@ -0,0 +1,90 @@
/**
*
* 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;
import java.io.File;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.inject.Inject;
import ch.psi.fda.fdaq.FdaqConfiguration;
import ch.psi.fda.fdaq.FdaqService;
import ch.psi.fda.rest.model.FdaqRequest;
import ch.psi.fda.serializer.SerializerTXT;
import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
/**
*
*/
public class FdaqEngine {
private FdaqService fdaq;
private EventBus bus;
private ZMQDataService zmqService;
private boolean stream = false;
private ExecutorService eservice;
@Inject
public FdaqEngine(ZMQDataService zmqService){
this.zmqService = zmqService;
eservice = Executors.newSingleThreadExecutor();
}
public void acquire(String trackingId, FdaqRequest request){
if(fdaq!=null && fdaq.isRunning()){
throw new IllegalStateException("FDAQ is already running");
}
bus = new AsyncEventBus(Executors.newSingleThreadExecutor());
fdaq = new FdaqService(bus, new FdaqConfiguration());
SerializerTXT serializer = new SerializerTXT(new File(request.getFilename()));
serializer.setShowDimensionHeader(false);
bus.register(serializer);
stream = (request.getStream()!=null && request.getStream().getIds().length>0) ;
if(stream){
// Stream data via ZMQ
zmqService.setTrackingId(trackingId);
// TODO Set id filter !!!!
bus.register(zmqService);
}
eservice.execute(new Runnable() {
@Override
public void run() {
fdaq.acquire();
}
});
}
public void stop(){
fdaq.stop();
bus.unregister(zmqService);
// TODO check whether serializer also needs to be unregistered ...
}
}

View File

@@ -1,11 +1,13 @@
package ch.psi.fda.rest;
import javax.inject.Singleton;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import ch.psi.fda.aq.AcquisitionConfiguration;
import ch.psi.fda.cdump.CdumpConfiguration;
import ch.psi.jcae.ChannelService;
import ch.psi.jcae.impl.DefaultChannelService;
@@ -15,8 +17,14 @@ public class ResourceBinder extends AbstractBinder {
protected void configure() {
bind(DefaultChannelService.class).to(ChannelService.class).in(Singleton.class);
bind(AcquisitionConfiguration.class).to(AcquisitionConfiguration.class).in(Singleton.class);
bind(AcquisitionEngine.class).to(AcquisitionEngine.class).in(Singleton.class);
bind(ZMQDataService.class).to(ZMQDataService.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);
}
}

View File

@@ -21,12 +21,14 @@ package ch.psi.fda.rest;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jeromq.ZMQ;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.messages.Message;
import ch.psi.fda.model.v1.Visualization;
import com.google.common.eventbus.Subscribe;
@@ -39,13 +41,15 @@ public class ZMQDataService {
private static final Logger logger = Logger.getLogger(ZMQDataService.class.getName());
private final int bufferSize = 5;
private final int port;
private ZMQ.Context context;
private ZMQ.Socket socket;
private String trackingId;
public ZMQDataService(){
public ZMQDataService(int port){
this.port = port;
initialize();
}
@@ -54,7 +58,7 @@ public class ZMQDataService {
zmq.ZError.clear(); // Clear error code
socket = context.socket(ZMQ.PUB);
socket.setHWM(bufferSize);
socket.bind("tcp://*:10000");
socket.bind("tcp://*:"+port);
}
public void terminate(){
@@ -65,8 +69,8 @@ public class ZMQDataService {
@Subscribe
public void onMessage(Message m) {
logger.info(m.toString());
socket.sendMore("{\"trackingId\":\"" + trackingId + "\"}");
logger.fine(m.toString());
socket.sendMore("{\"htype\": [\"fda-2.1\"], \"trackingId\":\"" + trackingId + "\"}");
try (
ByteArrayOutputStream b = new ByteArrayOutputStream();
ObjectOutputStream o = new ObjectOutputStream(b);
@@ -78,6 +82,20 @@ public class ZMQDataService {
}
}
@Subscribe
public void onMessage(List<Visualization> vis){
logger.fine("Sending plotting filters");
socket.sendMore("{\"htype\": [\"fda-plot-2.1\"], \"trackingId\":\"" + trackingId + "\"}");
try (
ByteArrayOutputStream b = new ByteArrayOutputStream();
ObjectOutputStream o = new ObjectOutputStream(b);
) {
o.writeObject(vis);
socket.send(b.toByteArray());
} catch (IOException e) {
logger.log(Level.WARNING, "Unable to serialize message", e);
}
}
public void setTrackingId(String id){
trackingId = id;

View File

@@ -0,0 +1,57 @@
/**
*
* Copyright 2013 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.client;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
import org.glassfish.jersey.jackson.JacksonFeature;
import ch.psi.fda.model.v1.Configuration;
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, Configuration c){
// Wrap configuration in JAXBElement as there is no @XmlRootElement available within the generated Configuration class
JAXBElement<Configuration> jaxbElement = new JAXBElement<>(new QName("ROOT"), Configuration.class, c);
return target.path(trackingId).request().put(Entity.entity(jaxbElement, MediaType.APPLICATION_XML), String.class);
}
public void terminate(String trackingId){
target.path(trackingId).request().delete();
}
public void terminateAll(){
target.request().delete();
}
public boolean isActive(String trackingId){
return target.path(trackingId).path("running").request().get(Boolean.class);
}
}

View File

@@ -0,0 +1,315 @@
/**
*
* Copyright 2010 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.client;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.ScrollPaneLayout;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
import sun.misc.Signal;
import sun.misc.SignalHandler;
import ch.psi.fda.aq.VisualizationMapper;
import ch.psi.fda.gui.ProgressPanel;
import ch.psi.fda.gui.ScrollableFlowPanel;
import ch.psi.fda.model.ModelManager;
import ch.psi.fda.model.v1.Configuration;
import ch.psi.fda.model.v1.Data;
import ch.psi.fda.visualizer.Visualizer;
@SuppressWarnings("restriction")
public class RemoteAcquisitionMain {
private static Logger logger = Logger.getLogger(RemoteAcquisitionMain.class.getName());
StreamClient streamClient = null;
private String trackingId;
/**
* Main Program Process exit code: -1 if wrong number of arguments are
* passed Process exit code: 3 if aborted via Ctrl+C
*
* @param args
* Arguments of the program
*/
public static void main(String[] args) {
String scriptname = "fda_scan";
Integer iterations = null;
boolean nogui = false;
List<File> files = new ArrayList<>();
OptionBuilder.hasArg();
OptionBuilder.withArgName("iterations");
OptionBuilder.withDescription("Number of iterations");
OptionBuilder.withType(new Integer(1));
Option o_iterations = OptionBuilder.create("iterations");
Option o_nogui = new Option("nogui", "Do not show scan GUI");
Options options = new Options();
options.addOption(o_iterations);
options.addOption(o_nogui);
CommandLineParser parser = new GnuParser();
try {
CommandLine line = parser.parse(options, args);
if (line.getArgs().length < 1) {
throw new ParseException("One argument is required");
}
if (line.hasOption(o_iterations.getOpt())) {
iterations = Integer.parseInt(line.getOptionValue(o_iterations.getOpt()));
}
if (line.hasOption(o_nogui.getOpt())) {
nogui = true;
}
for (String f : line.getArgs()) {
File file = new File(f);
if (!file.exists()) {
throw new RuntimeException("File " + file.getAbsolutePath() + " does not exist");
}
files.add(file);
}
} catch (ParseException e) {
System.err.println(e.getMessage());
HelpFormatter formatter = new HelpFormatter();
formatter.printUsage(new PrintWriter(System.out, true), HelpFormatter.DEFAULT_WIDTH, scriptname, options);
System.exit(-1);
}
try {
for (File file : files) {
RemoteAcquisitionMain m = new RemoteAcquisitionMain();
m.execute(file, iterations, nogui);
}
} catch (Exception ee) {
logger.log(Level.SEVERE, "Acquisition failed due to: ", ee);
System.exit(-1);
}
}
/**
* Execute the given scan on the server
* @param file
* @param iterations
* @param nogui
*/
public void execute(File file, Integer iterations, boolean nogui) {
trackingId = UUID.randomUUID().toString();
logger.info("TrackingID of job: " + trackingId);
Configuration c;
try {
c = ModelManager.unmarshall(file);
} catch (Exception e) {
throw new RuntimeException("Unable to deserialize configuration: " + e.getMessage(), e);
}
// Set data file name
// Determine name used for the data file
String name = file.getName();
name = name.replaceAll("\\.xml$", "");
if (c.getData() != null) {
Data data = c.getData();
// Only update filename if no name is specified in xml file
if (data.getFileName() == null) {
data.setFileName(name);
}
} else {
Data data = new Data();
data.setFileName(name);
c.setData(data);
}
// Override number of executions
if (iterations != null) {
c.setNumberOfExecution(iterations);
}
// Fix configuration if iterations is specified with 0 and no iterations
// option is specified
if (c.getNumberOfExecution() == 0) {
c.setNumberOfExecution(1);
}
EventBus b = new AsyncEventBus(Executors.newSingleThreadExecutor());
final ControlClient client = new ControlClient();
if (!nogui && c.getVisualization().size() > 0) {
streamClient = new StreamClient(b);
Visualizer visualizer = new Visualizer(VisualizationMapper.mapVisualizations(c.getVisualization()));
visualizer.configure();
b.register(visualizer);
// If there is a continuous dimension only update plot at the end of a line
if (c.getScan() != null && c.getScan().getCdimension() != null) {
visualizer.setUpdateAtStreamElement(false);
visualizer.setUpdateAtStreamDelimiter(true);
visualizer.setUpdateAtEndOfStream(true);
}
JPanel opanel = new ScrollableFlowPanel();
opanel.setLayout(new FlowLayout());
JScrollPane spane = new JScrollPane(opanel, ScrollPaneLayout.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneLayout.HORIZONTAL_SCROLLBAR_NEVER);
JTabbedPane tpane = new JTabbedPane();
tpane.addTab("Overview", spane);
for (JPanel p : visualizer.getPlotPanels()) {
opanel.add(p);
}
final JFrame frame = new JFrame("FDA: " + file);
frame.setSize(1200, 800);
final ProgressPanel progressPanel = new ProgressPanel();
progressPanel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
client.terminate(trackingId);
} catch (Exception e1) {
logger.log(Level.SEVERE, "Exception occured while aborting scan", e1);
} finally {
progressPanel.done();
}
}
});
JSplitPane splitPane = new JSplitPane();
splitPane.setLeftComponent(progressPanel);
splitPane.setRightComponent(tpane);
frame.add(splitPane);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent we) {
client.terminate(trackingId);
int count = 0;
while (client.isActive(trackingId)) {
if (count == 10) {
break;
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
count++;
}
System.exit(0);
}
});
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // .DO_NOTHING_ON_CLOSE);
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
frame.setVisible(true);
}
});
}
Signal.handle(new Signal("INT"), new SignalHandler() {
private AtomicInteger signalCount = new AtomicInteger(0);
@Override
public void handle(Signal signal) {
logger.finest("Received signal: " + signal);
try{
client.terminate(trackingId);
}
catch(Exception e){
logger.log(Level.WARNING, "Stopping scan failed with exception", e);
}
if (signalCount.incrementAndGet() > 1) {
logger.info("Terminate application");
System.exit(2);
}
}
});
if(streamClient!=null){
streamClient.filterTrackingId(trackingId);
Executors.newSingleThreadExecutor().execute(new Runnable() {
@Override
public void run() {
streamClient.listen("tcp://emac:10000");
}
});
}
client.acquire(trackingId, c);
}
}

View File

@@ -0,0 +1,98 @@
/**
*
* Copyright 2013 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.client;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.jeromq.ZMQ;
import com.google.common.eventbus.EventBus;
public class StreamClient {
private static final Logger logger = Logger.getLogger(StreamClient.class.getName());
private ObjectMapper mapper = new ObjectMapper(new JsonFactory());
private final EventBus bus;
private String trackingIdFilter = null;
public StreamClient(EventBus bus) {
this.bus = bus;
}
public void listen(String endpoint) {
ZMQ.Context context = ZMQ.context();
zmq.ZError.clear(); // Clear error code
ZMQ.Socket socket = context.socket(ZMQ.SUB);
socket.connect(endpoint);
socket.subscribe(""); // SUBSCRIBE !
while (true) {
String tid = null;
byte[] content = null;
byte[] header = socket.recv(); // header
if(trackingIdFilter!=null){
try {
Map<String,Object> m = mapper.readValue(header, new TypeReference<HashMap<String,Object>>(){});
tid = (String) m.get("trackingId");
} catch (IOException e) {
}
}
while (socket.hasReceiveMore()) {
content = socket.recv();
}
if (content == null) { // we lost something discard read messages
logger.warning("Lost some message - discard and continue");
continue;
}
if(tid!=null && !tid.matches(trackingIdFilter)){
continue;
}
try (ByteArrayInputStream bis = new ByteArrayInputStream(content); ObjectInput in = new ObjectInputStream(bis);) {
Object o = in.readObject();
bus.post(o);
} catch (IOException | ClassNotFoundException e) {
logger.log(Level.WARNING, "Unable to deserialize message", e);
}
}
}
public String getTrackingIdFilter() {
return trackingIdFilter;
}
public void filterTrackingId(String trackingId) {
this.trackingIdFilter = trackingId;
}
}

View File

@@ -0,0 +1,48 @@
/**
*
* 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;
}
}

View File

@@ -0,0 +1,74 @@
/**
*
* 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;
}
}

View File

@@ -0,0 +1,30 @@
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;
}
}

View File

@@ -0,0 +1,40 @@
/**
*
* 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;
}
}

View File

@@ -0,0 +1,31 @@
/**
*
* 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;
}
}

View File

@@ -0,0 +1,63 @@
/**
*
* Copyright 2013 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.services;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import ch.psi.fda.rest.CdumpEngine;
import ch.psi.fda.rest.model.CdumpRequest;
@Path("cdump")
public class CDUMPService {
@Inject
private CdumpEngine cdumpE;
@PUT
@Path("{trackingId}")
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public void execute(@PathParam("trackingId") String trackingId, CdumpRequest request) throws InterruptedException{
cdumpE.acquire(trackingId, request);
}
@DELETE
@Path("{trackingId}")
public void stop(@PathParam("trackingId") String trackingId){
terminateAll();
}
@DELETE
public void terminateAll(){
cdumpE.stop();
}
@GET
public boolean isActive(){
return cdumpE.isActive();
}
}

View File

@@ -19,31 +19,40 @@
package ch.psi.fda.rest.services;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import ch.psi.fda.model.v1.Configuration;
import ch.psi.fda.rest.AcquisitionEngine;
@Path("fda")
public class ScanService {
import ch.psi.fda.fdaq.FdaqService;
import ch.psi.fda.rest.model.FdaqRequest;
@Path("fdaq")
public class FDAQService {
@Inject
private AcquisitionEngine aengine;
private FdaqService fdaq;
@POST
@PUT
@Path("{trackingId}")
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
// @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public String execute(Configuration configuration) throws InterruptedException{
return aengine.submit(configuration);
public void execute(@PathParam("trackingId") String trackingId, FdaqRequest request) throws InterruptedException {
fdaq.acquire();
}
@DELETE
public void stop(){
aengine.terminate();
@Path("{trackingId}")
public void stop(@PathParam("trackingId") String trackingId) {
terminateAll();
}
@DELETE
public void terminateAll(){
fdaq.stop();
}
}

View File

@@ -0,0 +1,72 @@
/**
*
* Copyright 2013 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.services;
import java.util.concurrent.ExecutionException;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import ch.psi.fda.model.v1.Configuration;
import ch.psi.fda.rest.AcquisitionEngine;
@Path("fda")
public class FDAService {
@Inject
private AcquisitionEngine aengine;
@PUT
@Path("{trackingId}")
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public void execute(@PathParam("trackingId") String trackingId, Configuration configuration) throws InterruptedException{
aengine.submit(trackingId, configuration);
}
@DELETE
@Path("{trackingId}")
public void stop(@PathParam("trackingId") String trackingId){
aengine.terminate(trackingId);
}
@DELETE
public void terminateAll(){
aengine.terminateAll();
}
@GET
@Path("{trackingId}/running")
public boolean isActive(@PathParam("trackingId") String trackingId){
return aengine.isActive(trackingId);
}
@GET
@Path("{trackingId}/done")
public void wait(@PathParam("trackingId") String trackingId) throws InterruptedException, ExecutionException{
aengine.wait(trackingId);
}
}

View File

@@ -1,23 +0,0 @@
/**
*
* Copyright 2010 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.serializer;
public interface DataSerializer {
}

View File

@@ -1,197 +0,0 @@
/**
*
* Copyright 2010 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.serializer;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.logging.Logger;
import com.google.common.eventbus.Subscribe;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.core.messages.StreamDelimiterMessage;
/**
* Serialize data received by a DataQueue
*/
public class DataSerializerTXT implements DataSerializer{
private static final Logger logger = Logger.getLogger(DataSerializerTXT.class.getName());
private File file;
private boolean appendSuffix = true;
private boolean first = true;
private File outfile;
private int icount;
private String basename;
private String extension;
private boolean newfile;
private boolean dataInBetween;
private BufferedWriter writer;
private StringBuffer b;
private StringBuffer b1;
/**
* @param metadata
* @param file
* @param appendSuffix Flag whether to append a _0000 suffix after the original file name
*/
public DataSerializerTXT(File file, boolean appendSuffix){
this.file = file;
this.appendSuffix = appendSuffix;
}
@Subscribe
public void onMessage(Message message){
try{
if(first){
first=false;
// Write header
icount = 0;
newfile = true;
dataInBetween = false;
writer = null;
// Get basename of the file
basename = this.file.getAbsolutePath(); // Determine file name
extension = basename.replaceAll("^.*\\.", ""); // Determine extension
basename = basename.replaceAll("\\."+extension+"$", "");
}
if(message instanceof DataMessage){
dataInBetween = true;
if(newfile){
b = new StringBuffer();
b1 = new StringBuffer();
b.append("#");
b1.append("#");
for(Metadata c: ((DataMessage) message).getMetadata()){
b.append(c.getId());
b.append("\t");
b1.append(c.getDimension());
b1.append("\t");
}
b.setCharAt(b.length()-1, '\n');
b1.setCharAt(b1.length()-1, '\n');
// Open new file and write header
// Construct file name
if(appendSuffix){
outfile = new File(String.format("%s_%04d.%s", basename, icount, extension));
}
else{
outfile = new File(String.format("%s.%s", basename, extension));
}
// Open file
logger.fine("Open new data file: "+outfile.getAbsolutePath());
writer = new BufferedWriter(new FileWriter(outfile));
// Write header
writer.write(b.toString());
writer.write(b1.toString());
newfile=false;
}
// Write message to file - each message will result in one line
DataMessage m = (DataMessage) message;
StringBuffer buffer = new StringBuffer();
for(Object o: m.getData()){
if(o.getClass().isArray()){
// If the array object is of type double[] display its content
if(o instanceof double[]){
double[] oa = (double[]) o;
for(double o1 : oa){
buffer.append(o1);
buffer.append(" "); // Use space instead of tab
}
buffer.replace(buffer.length()-1,buffer.length()-1 , "\t"); // Replace last space with tab
}
else if(o instanceof Object[]){
// TODO need to be recursive ...
Object[] oa = (Object[])o;
for(Object o1 : oa){
buffer.append(o1);
buffer.append(" "); // Use space instead of tab
}
buffer.replace(buffer.length()-1,buffer.length()-1 , "\t"); // Replace last space with tab
}
else{
buffer.append("-"); // Not supported
}
}
else{
buffer.append(o);
buffer.append("\t");
}
}
if(buffer.length()>0){
buffer.deleteCharAt(buffer.length()-1); // Remove last character (i.e. \t)
buffer.append("\n"); // Append newline
}
writer.write(buffer.toString());
}
else if(message instanceof StreamDelimiterMessage){
StreamDelimiterMessage m = (StreamDelimiterMessage) message;
logger.info("Delimiter - number: "+m.getNumber()+" iflag: "+m.isIflag());
if(m.isIflag() && appendSuffix){
// Only increase iflag counter if there was data in between
// subsequent StreamDelimiterMessages.
if(dataInBetween){
icount++;
}
dataInBetween = false;
// Set flag to open new file
newfile = true;
// Close file
writer.close();
}
}
else if (message instanceof EndOfStreamMessage){
if(writer!=null){
// Close file
writer.close(); //If the stream was closed previously this has no effect
}
}
} catch (IOException e) {
throw new RuntimeException("Data serializer had a problem writing to the specified file",e);
}
}
}

View File

@@ -29,15 +29,15 @@ import com.jmatio.io.MatFileWriter;
import com.jmatio.types.MLArray;
import com.jmatio.types.MLDouble;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.EndOfStreamMessage;
import ch.psi.fda.messages.Message;
import ch.psi.fda.messages.Metadata;
/**
* Serialize data received by a DataQueue into a Matlab file
*/
public class DataSerializerMAT implements DataSerializer{
public class SerializerMAT {
private File file;
@@ -49,7 +49,7 @@ public class DataSerializerMAT implements DataSerializer{
* @param queue Data queue holding the data to serialize
* @param file Name of the Matlab file to serialize the data to
*/
public DataSerializerMAT(File file){
public SerializerMAT(File file){
this.file = file;
}

View File

@@ -30,18 +30,18 @@ import com.jmatio.io.MatFileWriter;
import com.jmatio.types.MLArray;
import com.jmatio.types.MLDouble;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.core.messages.StreamDelimiterMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.EndOfStreamMessage;
import ch.psi.fda.messages.Message;
import ch.psi.fda.messages.Metadata;
import ch.psi.fda.messages.StreamDelimiterMessage;
/**
* Serialize data received by a DataQueue into a Matlab file
*/
public class DataSerializerMAT2D implements DataSerializer{
public class SerializerMAT2D {
private static final Logger logger = Logger.getLogger(DataSerializerMAT2D.class.getName());
private static final Logger logger = Logger.getLogger(SerializerMAT2D.class.getName());
private File file;
private boolean appendSuffix = false;
@@ -61,7 +61,7 @@ public class DataSerializerMAT2D implements DataSerializer{
* @param queue Data queue holding the data to serialize
* @param file Name of the Matlab file to serialize the data to
*/
public DataSerializerMAT2D(File file){
public SerializerMAT2D(File file){
this.file = file;

View File

@@ -31,18 +31,18 @@ import com.jmatio.io.MatFileWriter;
import com.jmatio.types.MLArray;
import com.jmatio.types.MLDouble;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.core.messages.StreamDelimiterMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.EndOfStreamMessage;
import ch.psi.fda.messages.Message;
import ch.psi.fda.messages.Metadata;
import ch.psi.fda.messages.StreamDelimiterMessage;
/**
* Serialize data received by a DataQueue into a Matlab file
*/
public class DataSerializerMAT2DZigZag implements DataSerializer{
public class SerializerMAT2DZigZag {
private static final Logger logger = Logger.getLogger(DataSerializerMAT2DZigZag.class.getName());
private static final Logger logger = Logger.getLogger(SerializerMAT2DZigZag.class.getName());
private List<Metadata> metadata;
private File file;
@@ -66,7 +66,7 @@ public class DataSerializerMAT2DZigZag implements DataSerializer{
* @param queue Data queue holding the data to serialize
* @param file Name of the Matlab file to serialize the data to
*/
public DataSerializerMAT2DZigZag(File file){
public SerializerMAT2DZigZag(File file){
this.file = file;

View File

@@ -32,20 +32,20 @@ import java.util.logging.Logger;
import com.google.common.eventbus.Subscribe;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.core.messages.StreamDelimiterMessage;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.EndOfStreamMessage;
import ch.psi.fda.messages.Message;
import ch.psi.fda.messages.Metadata;
import ch.psi.fda.messages.StreamDelimiterMessage;
/**
* Serialize data received by a DataQueue
*
* http://www.aps.anl.gov/bcda/synApps/sscan/saveData_fileFormat.txt
*/
public class DataSerializerMDA implements DataSerializer{
public class SerializerMDA {
private static final Logger logger = Logger.getLogger(DataSerializerMDA.class.getName());
private static final Logger logger = Logger.getLogger(SerializerMDA.class.getName());
private File file;
@@ -59,7 +59,7 @@ public class DataSerializerMDA implements DataSerializer{
private HashMap<Integer,List<String>> idMap;
private int numberOfDimensions;
public DataSerializerMDA(File file){
public SerializerMDA(File file){
this.file = file;
}

View File

@@ -28,16 +28,16 @@ import java.util.List;
import com.google.common.eventbus.Subscribe;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.core.messages.StreamDelimiterMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.EndOfStreamMessage;
import ch.psi.fda.messages.Message;
import ch.psi.fda.messages.Metadata;
import ch.psi.fda.messages.StreamDelimiterMessage;
/**
* Serialize data received by a DataQueue into a Matlab file
*/
public class DataSerializerTXT2D implements DataSerializer{
public class SerializerTXT2D {
private File file;
private boolean appendSuffix = false;
@@ -56,7 +56,7 @@ public class DataSerializerTXT2D implements DataSerializer{
* @param queue Data queue holding the data to serialize
* @param file Name of the Matlab file to serialize the data to
*/
public DataSerializerTXT2D(File file){
public SerializerTXT2D(File file){
this.file = file;
}

View File

@@ -28,15 +28,15 @@ import java.util.List;
import com.google.common.eventbus.Subscribe;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.core.messages.StreamDelimiterMessage;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.Message;
import ch.psi.fda.messages.Metadata;
import ch.psi.fda.messages.StreamDelimiterMessage;
/**
* Serialize data received by a DataQueue
*/
public class DataSerializerTXTSplit implements DataSerializer {
public class SerializerTXTSplit {
private File file;
@@ -47,7 +47,7 @@ public class DataSerializerTXTSplit implements DataSerializer {
private List<String> header;
private List<String> data;
public DataSerializerTXTSplit(File file) {
public SerializerTXTSplit(File file) {
this.file = file;
}

View File

@@ -29,9 +29,9 @@ import javax.swing.SwingUtilities;
import com.google.common.eventbus.Subscribe;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.StreamDelimiterMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.EndOfStreamMessage;
import ch.psi.fda.messages.StreamDelimiterMessage;
import ch.psi.plot.Plot;
import ch.psi.plot.xy.LinePlot;
import ch.psi.plot.xy.XYSeriesCollectionP;

View File

@@ -0,0 +1,9 @@
<jxb:bindings version="1.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jxb:globalBindings>
<jxb:serializable uid="1"/>
</jxb:globalBindings>
</jxb:bindings>

View File

@@ -33,11 +33,11 @@ import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import ch.psi.fda.aq.Collector;
import ch.psi.fda.core.messages.ControlMessage;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.messages.ControlMessage;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.EndOfStreamMessage;
import ch.psi.fda.messages.Message;
import ch.psi.fda.messages.Metadata;
public class CollectorTest {

View File

@@ -40,13 +40,13 @@ import ch.psi.fda.TestChannels;
import ch.psi.fda.aq.Manipulator;
import ch.psi.fda.core.Manipulation;
import ch.psi.fda.core.manipulator.JythonManipulation;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.core.scripting.JythonParameterMapping;
import ch.psi.fda.core.scripting.JythonParameterMappingChannel;
import ch.psi.fda.core.scripting.JythonParameterMappingID;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.EndOfStreamMessage;
import ch.psi.fda.messages.Message;
import ch.psi.fda.messages.Metadata;
import ch.psi.jcae.Channel;
import ch.psi.jcae.ChannelDescriptor;
import ch.psi.jcae.ChannelException;

View File

@@ -44,8 +44,8 @@ import ch.psi.fda.core.actors.ChannelAccessLinearActuator;
import ch.psi.fda.core.guard.ChannelAccessGuard;
import ch.psi.fda.core.guard.ChannelAccessGuardCondition;
import ch.psi.fda.core.loops.ActorSensorLoop;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.core.sensors.ChannelAccessSensor;
import ch.psi.fda.messages.Message;
import ch.psi.jcae.Channel;
import ch.psi.jcae.ChannelDescriptor;
import ch.psi.jcae.ChannelException;

View File

@@ -39,10 +39,10 @@ import ch.psi.fda.core.loops.otf.OTFLoop;
import ch.psi.fda.core.loops.otf.OTFNamedChannelSensor;
import ch.psi.fda.core.loops.otf.OTFScalerChannelSensor;
import ch.psi.fda.core.loops.otf.TemplateOTF;
import ch.psi.fda.core.messages.ControlMessage;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.core.sensors.TimestampSensor;
import ch.psi.fda.messages.ControlMessage;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.Message;
import ch.psi.jcae.Channel;
import ch.psi.jcae.ChannelDescriptor;
import ch.psi.jcae.ChannelException;

View File

@@ -32,10 +32,10 @@ import org.junit.Test;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.EndOfStreamMessage;
import ch.psi.fda.messages.Message;
import ch.psi.fda.messages.Metadata;
public class ParallelCrlogicStreamMergeTest {

View File

@@ -34,7 +34,7 @@ import org.junit.Test;
import com.google.common.eventbus.Subscribe;
import ch.psi.fda.TestConfiguration;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.messages.Message;
import ch.psi.jcae.Channel;
import ch.psi.jcae.ChannelDescriptor;
import ch.psi.jcae.ChannelException;

View File

@@ -32,7 +32,7 @@ import org.junit.Test;
import com.google.common.eventbus.Subscribe;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.messages.Message;
import ch.psi.jcae.Channel;
import ch.psi.jcae.ChannelDescriptor;
import ch.psi.jcae.ChannelException;

View File

@@ -31,10 +31,10 @@ import org.junit.Test;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import ch.psi.fda.core.messages.ControlMessage;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.messages.ControlMessage;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.Message;
import ch.psi.fda.messages.Metadata;
/**
* @author ebner

View File

@@ -31,11 +31,11 @@ import org.junit.Test;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import ch.psi.fda.core.messages.ControlMessage;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.Message;
import ch.psi.fda.deserializer.DataDeserializer;
import ch.psi.fda.deserializer.DataDeserializerTXT;
import ch.psi.fda.messages.ControlMessage;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.Message;
public class DataDeserializerTest {

View File

@@ -29,19 +29,18 @@ import org.junit.Test;
import com.google.common.eventbus.EventBus;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.core.messages.StreamDelimiterMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.serializer.DataSerializer;
import ch.psi.fda.serializer.DataSerializerMAT;
import ch.psi.fda.serializer.DataSerializerMAT2D;
import ch.psi.fda.serializer.DataSerializerTXT;
import ch.psi.fda.serializer.DataSerializerTXT2D;
import ch.psi.fda.serializer.DataSerializerTXTSplit;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.EndOfStreamMessage;
import ch.psi.fda.messages.Metadata;
import ch.psi.fda.messages.StreamDelimiterMessage;
import ch.psi.fda.serializer.SerializerMAT;
import ch.psi.fda.serializer.SerializerMAT2D;
import ch.psi.fda.serializer.SerializerTXT;
import ch.psi.fda.serializer.SerializerTXT2D;
import ch.psi.fda.serializer.SerializerTXTSplit;
public class DataSerializerTest {
public class SerializerTest {
private static final String tmpDirectory = "target/tmp";
@@ -147,79 +146,79 @@ public class DataSerializerTest {
}
/**
* Test method for {@link ch.psi.fda.serializer.DataSerializerTXT#run()}.
* Test method for {@link ch.psi.fda.serializer.SerializerTXT#run()}.
* @throws InterruptedException
*/
@Test
public void testRunTXT() throws InterruptedException {
DataSerializer serializer = new DataSerializerTXT(new File(tmpDirectory+"/test.txt"), true);
SerializerTXT serializer = new SerializerTXT(new File(tmpDirectory+"/test.txt"), true);
bus.register(serializer);
generate1DData();
}
/**
* Test method for {@link ch.psi.fda.serializer.DataSerializerTXT#run()}.
* Test method for {@link ch.psi.fda.serializer.SerializerTXT#run()}.
* @throws InterruptedException
*/
@Test
public void testRunMAT() throws InterruptedException {
DataSerializer serializer = new DataSerializerMAT(new File(tmpDirectory+"/test.mat"));
SerializerMAT serializer = new SerializerMAT(new File(tmpDirectory+"/test.mat"));
bus.register(serializer);
generate1DData();
}
/**
* Test method for {@link ch.psi.fda.serializer.DataSerializerTXT#run()}.
* Test method for {@link ch.psi.fda.serializer.SerializerTXT#run()}.
* @throws InterruptedException
*/
@Test
public void testRunMAT2D() throws InterruptedException {
DataSerializer serializer = new DataSerializerMAT2D(new File(tmpDirectory+"/test-2d.mat"));
SerializerMAT2D serializer = new SerializerMAT2D(new File(tmpDirectory+"/test-2d.mat"));
bus.register(serializer);
generate2DData();
}
/**
* Test method for {@link ch.psi.fda.serializer.DataSerializerTXT#run()}.
* Test method for {@link ch.psi.fda.serializer.SerializerTXT#run()}.
* @throws InterruptedException
*/
@Test
public void testRunTXT2D() throws InterruptedException {
DataSerializer serializer = new DataSerializerTXT2D(new File(tmpDirectory+"/test-2d.txt"));
SerializerTXT2D serializer = new SerializerTXT2D(new File(tmpDirectory+"/test-2d.txt"));
bus.register(serializer);
generate2DData();
}
/**
* Test method for {@link ch.psi.fda.serializer.DataSerializerTXT#run()}.
* Test method for {@link ch.psi.fda.serializer.SerializerTXT#run()}.
* @throws InterruptedException
*/
@Test
public void testRunSplitTXT() throws InterruptedException {
DataSerializer serializer = new DataSerializerTXTSplit(new File(tmpDirectory+"/test-2d-split.txt"));
SerializerTXTSplit serializer = new SerializerTXTSplit(new File(tmpDirectory+"/test-2d-split.txt"));
bus.register(serializer);
generate2DData();
}
/**
* Test method for {@link ch.psi.fda.serializer.DataSerializerMDA#run()}.
* Test method for {@link ch.psi.fda.serializer.SerializerMDA#run()}.
* @throws InterruptedException
*/
@Test
public void testRun2D() throws InterruptedException {
DataSerializer serializer = new DataSerializerMDA(new File(tmpDirectory+"/test-2d.mda"));
SerializerMDA serializer = new SerializerMDA(new File(tmpDirectory+"/test-2d.mda"));
bus.register(serializer);
generate2DData();
}
/**
* Test method for {@link ch.psi.fda.serializer.DataSerializerMDA#run()}.
* Test method for {@link ch.psi.fda.serializer.SerializerMDA#run()}.
* @throws InterruptedException
*/
@Test
public void testRun3D() throws InterruptedException {
DataSerializer serializer = new DataSerializerMDA(new File(tmpDirectory+"/test-3d.mda"));
SerializerMDA serializer = new SerializerMDA(new File(tmpDirectory+"/test-3d.mda"));
bus.register(serializer);
generate3DData();
}

View File

@@ -33,10 +33,10 @@ import org.junit.Test;
import com.google.common.eventbus.EventBus;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.Metadata;
import ch.psi.fda.core.messages.StreamDelimiterMessage;
import ch.psi.fda.core.messages.EndOfStreamMessage;
import ch.psi.fda.messages.DataMessage;
import ch.psi.fda.messages.EndOfStreamMessage;
import ch.psi.fda.messages.Metadata;
import ch.psi.fda.messages.StreamDelimiterMessage;
import ch.psi.plot.xy.LinePlot;
import ch.psi.plot.xyz.MatrixPlotData;

View File

@@ -1,4 +1,5 @@
# Serialization properties
ch.psi.fda.aq.data.dir=../data
ch.psi.fda.aq.data.filePrefix=${yyyy_MM}/${yyyyMMdd}/${yyyyMMddHHmmss}_${name}/${yyyyMMddHHmm}_
# OTF scan related configuration

View File

@@ -1,4 +1,4 @@
ch.psi.jcae.ContextFactory.addressList=129.129.130.255 129.129.130.37 129.129.145.26 129.129.130.77
ch.psi.jcae.ContextFactory.addressList=129.129.130.188 129.129.130.255 129.129.130.37 129.129.145.26 129.129.130.88 129.129.130.142
ch.psi.jcae.ChannelFactory.timeout=2000
ch.psi.jcae.ChannelFactory.retries=4
ch.psi.jcae.ChannelBeanFactory.timeout=10000

View File

@@ -1,9 +1,8 @@
# Specify the handlers to create in the root logger
##handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
handlers = java.util.logging.ConsoleHandler
# Set the default logging level for the root logger
.level=ALL
.level=INFO
# Set the default logging level for new ConsoleHandler instances
java.util.logging.ConsoleHandler.level=ALL
@@ -11,22 +10,5 @@ java.util.logging.ConsoleHandler.level=ALL
# Set the default formatter for new ConsoleHandler instances
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
# Set the default logging level for new FileHandler instances
##java.util.logging.FileHandler.level=ALL
# Set the default formatter for new ConsoleHandler instances
##java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
# Naming of the output file:
##java.util.logging.FileHandler.pattern=/Users/ebner/Workspace/Eclipse/workspace-xasec/ch.psi.x10/resources/logs/fda-%u.%g.log
# Limiting size of output file in bytes (10000kb):
##java.util.logging.FileHandler.limit=10000000
# Number of output files to cycle through, by appending an
# integer to the base file name:
##java.util.logging.FileHandler.count=10
# Set the default logging level for the logger named com.mycompany
ch.psi.fda.level=ALL
com.cosylab.epics.level=ALL
ch.psi.level=ALL

View File

@@ -1,4 +0,0 @@
# Test properties file
ch.psi.jcae.ContextFactory.addressList=129.129.130.255 129.129.130.37 129.129.145.26 129.129.130.88 129.129.130.142
ch.psi.jcae.ChannelBeanFactory.retries=4

View File

@@ -1,14 +0,0 @@
# Specify the handlers to create in the root logger
handlers = java.util.logging.ConsoleHandler
# Set the default logging level for the root logger
.level=INFO
# Set the default logging level for new ConsoleHandler instances
java.util.logging.ConsoleHandler.level=ALL
# Set the default formatter for new ConsoleHandler instances
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
# Set the default logging level for the logger named com.mycompany
ch.psi.level=ALL