[no commit message]

This commit is contained in:
Alexander Nozik 2016-04-24 22:17:52 +03:00
parent 70ee806674
commit 73908683b8
23 changed files with 306 additions and 135 deletions

View File

@ -30,7 +30,7 @@ import hep.dataforge.exceptions.MeasurementException;
import hep.dataforge.exceptions.PortException;
import hep.dataforge.exceptions.StorageException;
import hep.dataforge.meta.Meta;
import hep.dataforge.points.Format;
import hep.dataforge.points.PointFormat;
import hep.dataforge.points.FormatBuilder;
import hep.dataforge.storage.api.PointLoader;
import hep.dataforge.storage.api.Storage;
@ -411,7 +411,7 @@ public class MspDevice extends SingleMeasurementDevice implements PortHandler.Po
builder.addNumber(peakName);
});
Format format = builder.build();
PointFormat format = builder.build();
String suffix = Integer.toString((int) Instant.now().toEpochMilli());
PointLoader loader = LoaderFactory

View File

@ -33,6 +33,7 @@ import hep.dataforge.plots.data.PlottableData;
import hep.dataforge.plots.data.PlottableFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
import hep.dataforge.points.PointSet;
import hep.dataforge.points.PointSource;
/**
*
@ -46,7 +47,7 @@ public class PlotFitResultAction extends OneToOneAction<FitState, FitState> {
@Override
protected FitState execute(Context context,Logable log, String name, Laminate metaData, FitState input) {
PointSet data = input.getDataSet();
PointSource data = input.getDataSet();
if (!(input.getModel() instanceof XYModel)) {
log.logError("The fit model should be instance of XYModel for this action. Action failed!");
return input;

View File

@ -17,6 +17,7 @@ import hep.dataforge.meta.Meta;
import java.util.ArrayList;
import java.util.List;
import hep.dataforge.points.PointSet;
import hep.dataforge.points.PointSource;
/**
* Adjust errors for all numass points in the dataset
@ -33,7 +34,7 @@ public class AdjustErrorsAction extends OneToOneAction<PointSet, PointSet> {
points.add(evalPoint(meta, dp));
}
return new ListPointSet(points, input.getDataFormat());
return new ListPointSet(input.getFormat(), points);
}
private DataPoint evalPoint(Meta meta, DataPoint dp) {

View File

@ -29,6 +29,7 @@ import hep.dataforge.points.DataPoint;
import hep.dataforge.points.ListPointSet;
import hep.dataforge.points.MapPoint;
import hep.dataforge.points.PointSet;
import hep.dataforge.points.PointSource;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collection;
@ -63,7 +64,7 @@ public class MergeDataAction extends ManyToOneAction<PointSet, PointSet> {
@Override
protected PointSet execute(Context context, Logable log, String nodeName, Map<String, PointSet> data, Meta meta) {
PointSet res = mergeDataSets(nodeName, data.values());
return res.sort("Uset", true);
return new ListPointSet(res.getFormat(),res.sort("Uset", true));
}
@Override
@ -143,8 +144,8 @@ public class MergeDataAction extends ManyToOneAction<PointSet, PointSet> {
private PointSet mergeDataSets(String name, Collection<PointSet> ds) {
//Сливаем все точки в один набор данных
Map<Double, List<DataPoint>> points = new LinkedHashMap<>();
for (PointSet d : ds) {
if (!d.getDataFormat().contains(parnames)) {
for (PointSource d : ds) {
if (!d.getFormat().contains(parnames)) {
throw new IllegalArgumentException();
}
for (DataPoint dp : d) {

View File

@ -37,6 +37,7 @@ import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.concurrent.CopyOnWriteArrayList;
import hep.dataforge.points.PointSet;
import hep.dataforge.points.PointSource;
/**
*

View File

@ -17,7 +17,7 @@ package inr.numass.actions;
import hep.dataforge.actions.OneToOneAction;
import hep.dataforge.context.Context;
import hep.dataforge.points.Format;
import hep.dataforge.points.PointFormat;
import hep.dataforge.points.DataPoint;
import hep.dataforge.points.ListPointSet;
import hep.dataforge.points.MapPoint;
@ -90,13 +90,13 @@ public class PrepareDataAction extends OneToOneAction<NMFile, PointSet> {
dataList.add(new MapPoint(parnames, new Object[]{Uset, Uread, time, total, wind, corr, cr, crErr, timestamp}));
}
Format format;
PointFormat format;
if (!dataList.isEmpty()) {
//Генерируем автоматический формат по первой строчке
format = Format.forPoint(dataList.get(0));
format = PointFormat.forPoint(dataList.get(0));
} else {
format = Format.forNames(8, parnames);
format = PointFormat.forNames(8, parnames);
}
// AnnotationBuilder builder = dataFile.meta().getBuilder();
@ -109,7 +109,7 @@ public class PrepareDataAction extends OneToOneAction<NMFile, PointSet> {
}
head = head + "\n" + new XMLMetaWriter().writeString(meta, null) + "\n";
ListPointSet data = new ListPointSet(dataList, format);
ListPointSet data = new ListPointSet(format, dataList);
OutputStream stream = buildActionOutput(context, name);

View File

@ -172,7 +172,7 @@ public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
ParamSet parameters = input.getParameters().getSubSet(new String[]{"exPos", "ionPos", "exW", "ionW", "exIonRatio"});
NamedMatrix covariance = input.getCovariance();
PointSet spreadData = generateSpread(writer, name, parameters, covariance);
ColumnedDataWriter.writeDataSet(System.out, spreadData, "", spreadData.getDataFormat().asArray());
ColumnedDataWriter.writeDataSet(System.out, spreadData, "", spreadData.getFormat().asArray());
}
}

View File

@ -15,7 +15,7 @@
*/
package inr.numass.actions;
import hep.dataforge.points.Format;
import hep.dataforge.points.PointFormat;
import hep.dataforge.points.ListPointSet;
import hep.dataforge.points.MapPoint;
import hep.dataforge.values.Value;
@ -36,11 +36,11 @@ public class SlicedData extends ListPointSet {
private static final String UNAME = "U";
private static Format prepateFormat(Map<String,Pair<Integer,Integer>> intervals){
private static PointFormat prepateFormat(Map<String,Pair<Integer,Integer>> intervals){
ArrayList<String> names = new ArrayList<>(intervals.keySet());
names.add(0, TNAME);
names.add(0, UNAME);
return Format.forNames(8, names);
return PointFormat.forNames(8, names);
}

View File

@ -19,7 +19,7 @@ import hep.dataforge.actions.ManyToOneAction;
import hep.dataforge.actions.GroupBuilder;
import hep.dataforge.context.Context;
import hep.dataforge.data.DataNode;
import hep.dataforge.points.Format;
import hep.dataforge.points.PointFormat;
import hep.dataforge.points.DataPoint;
import hep.dataforge.points.ListPointSet;
import hep.dataforge.points.MapPoint;
@ -68,7 +68,7 @@ public class SummaryAction extends ManyToOneAction<FitState, PointSet> {
}
names[names.length - 1] = "chi2";
ListPointSet res = new ListPointSet(Format.forNames(8, names));
ListPointSet res = new ListPointSet(PointFormat.forNames(8, names));
double[] weights = new double[parNames.length];
Arrays.fill(weights, 0);

View File

@ -15,7 +15,7 @@
*/
package inr.numass.data;
import hep.dataforge.points.Format;
import hep.dataforge.points.PointFormat;
import hep.dataforge.points.ListPointSet;
import hep.dataforge.points.MapPoint;
import hep.dataforge.io.ColumnedDataWriter;
@ -30,6 +30,13 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import static java.lang.String.format;
import static java.lang.String.format;
import static java.lang.String.format;
import static java.lang.String.format;
import static java.lang.String.format;
import static java.lang.String.format;
import static java.lang.String.format;
import static java.lang.String.format;
/**
*
@ -39,7 +46,7 @@ public class ESpectrum extends ListPointSet {
private final static String binCenter = "chanel";
private static Format prepareFormat(List<NMPoint> points) {
private static PointFormat prepareFormat(List<NMPoint> points) {
// ArrayList<String> names = new ArrayList<>();
// names.add(binCenter);
Map<String, ValueFormat> format = new LinkedHashMap<>();
@ -49,7 +56,7 @@ public class ESpectrum extends ListPointSet {
format.put(format("%.3f", point.getUread()), ValueFormatFactory.fixedWidth(10));
}
return new Format(format);
return new PointFormat(format);
}
int binning = 1;
@ -82,7 +89,7 @@ public class ESpectrum extends ListPointSet {
public void printToFile(OutputStream stream) {
ColumnedDataWriter.writeDataSet(stream, this, null);
// new ColumnedDataWriter(stream, this.getDataFormat().asArray()).writeDataSet(this, null);
// new ColumnedDataWriter(stream, this.getFormat().asArray()).writeDataSet(this, null);
}
}

View File

@ -27,6 +27,13 @@ import java.util.Iterator;
import org.apache.commons.math3.random.JDKRandomGenerator;
import org.apache.commons.math3.random.RandomDataGenerator;
import org.apache.commons.math3.random.RandomGenerator;
import static java.lang.Double.isNaN;
import static java.lang.Double.isNaN;
import static java.lang.Double.isNaN;
import static java.lang.Double.isNaN;
import static java.lang.Double.isNaN;
import static java.lang.Double.isNaN;
import static java.lang.Double.isNaN;
/**
* Генератор наборов данных для спектров. На входе требуется набор данных,

View File

@ -22,6 +22,7 @@ import java.io.FileNotFoundException;
import java.util.ArrayList;
import org.apache.commons.math3.util.Pair;
import hep.dataforge.points.PointSet;
import hep.dataforge.points.PointSource;
/**
*
@ -34,7 +35,7 @@ public class FSS{
public FSS(File FSSFile) {
try {
PointSet data = IOUtils.readColumnedData(FSSFile,"E","P");
PointSource data = IOUtils.readColumnedData(FSSFile,"E","P");
this.points = new ArrayList<>();
norm = 0;
for (DataPoint dp : data) {

View File

@ -22,6 +22,7 @@ import hep.dataforge.io.ColumnedDataReader;
import hep.dataforge.meta.Meta;
import hep.dataforge.points.DataPoint;
import hep.dataforge.points.PointSet;
import hep.dataforge.points.PointSource;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
@ -49,7 +50,7 @@ public class TransmissionInterpolator implements UnivariateFunction {
public static TransmissionInterpolator fromAction(Context context, Meta actionAnnotation,
String xName, String yName, int nSmooth, double w, double border) throws InterruptedException {
DataNode<PointSet> node = ActionUtils.runConfig(context, actionAnnotation);
PointSet data = node.getData().get();
PointSource data = node.getData().get();
return new TransmissionInterpolator(data, xName, yName, nSmooth, w, border);
}

View File

@ -40,6 +40,118 @@ import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
/**
*

View File

@ -22,6 +22,13 @@ import static java.lang.Math.exp;
import static java.lang.Math.sqrt;
import org.apache.commons.math3.analysis.UnivariateFunction;
import static java.lang.Math.abs;
import static java.lang.Math.abs;
import static java.lang.Math.abs;
import static java.lang.Math.abs;
import static java.lang.Math.abs;
import static java.lang.Math.abs;
import static java.lang.Math.abs;
import static java.lang.Math.abs;
/**
*
@ -41,7 +48,7 @@ public class TritiumUtils {
// public static ListPointSet applyDrift(ListPointSet data, double driftPerSecond) {
// double t = 0;
//
// ListPointSet res = new ListPointSet(data.getDataFormat());
// ListPointSet res = new ListPointSet(data.getFormat());
// for (DataPoint d : data) {
// SpectrumDataPoint dp = (SpectrumDataPoint) d;
// double corrFactor = 1 + driftPerSecond * t;
@ -62,7 +69,7 @@ public class TritiumUtils {
*/
public static ListPointSet correctForDeadTime(ListPointSet data, double dtime) {
SpectrumDataAdapter reader = adapter();
ListPointSet res = new ListPointSet(data.getDataFormat());
ListPointSet res = new ListPointSet(data.getFormat());
for (DataPoint dp : data) {
double corrFactor = 1 / (1 - dtime * reader.getCount(dp) /reader.getTime(dp));
res.add(reader.buildSpectrumDataPoint(reader.getX(dp).doubleValue(), (long) (reader.getCount(dp)*corrFactor),reader.getTime(dp)));
@ -80,7 +87,7 @@ public class TritiumUtils {
*/
public static ListPointSet setHVScale(ListPointSet data, double beta) {
SpectrumDataAdapter reader = adapter();
ListPointSet res = new ListPointSet(data.getDataFormat());
ListPointSet res = new ListPointSet(data.getFormat());
for (DataPoint dp : data) {
double corrFactor = 1 + beta;
res.add(reader.buildSpectrumDataPoint(reader.getX(dp).doubleValue()*corrFactor, reader.getCount(dp), reader.getTime(dp)));

View File

@ -11,6 +11,17 @@ task runServer(type: JavaExec) {
standardInput = System.in
}
//sourceSets.main.resources{
// srcDir project(':dataforge-storage:storage-servlet').file('ratpack')
//}
//task copyAssets(type: Copy) {
// from project(':dataforge-storage:storage-servlet').file('src/main/resouces/ratpack')
// into 'src/main/resouces/ratpack'
//}
//processResources.dependsOn("copyAssets")
dependencies {
compile project(':numass-storage')
compile project(':dataforge-storage:storage-servlet')

View File

@ -14,7 +14,8 @@ import hep.dataforge.values.Value;
*/
public class HandlerUtils {
public static void renderStates(StringBuilder b, StateLoader states) {
public static String renderStates(StateLoader states) {
StringBuilder b = new StringBuilder();
b.append("<div class=\"shifted\">\n");
for (String state : states.getStateNames()) {
Value val = states.getValue(state);
@ -37,6 +38,7 @@ public class HandlerUtils {
state, color, val.stringValue()));
}
b.append("</div>\n");
return b.toString();
}
public static void renderHTMLHeader(StringBuilder b) {

View File

@ -5,13 +5,18 @@
*/
package inr.numass.server;
import freemarker.template.Template;
import hep.dataforge.exceptions.StorageException;
import hep.dataforge.storage.api.Loader;
import hep.dataforge.storage.api.StateLoader;
import hep.dataforge.storage.api.Storage;
import hep.dataforge.storage.commons.JSONMetaWriter;
import static inr.numass.server.HandlerUtils.*;
import inr.numass.storage.NumassStorage;
import hep.dataforge.storage.servlet.Utils;
import static inr.numass.server.HandlerUtils.renderStates;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.LoggerFactory;
import ratpack.handling.Context;
import ratpack.handling.Handler;
@ -19,6 +24,7 @@ import ratpack.handling.Handler;
*
* @author Alexander Nozik
*/
@SuppressWarnings("unchecked")
public class NumassRootHandler implements Handler {
private final JSONMetaWriter writer = new JSONMetaWriter();
@ -30,43 +36,51 @@ public class NumassRootHandler implements Handler {
}
@Override
public void handle(Context c) throws Exception {
c.getResponse().contentType("text/html");
StringBuilder b = new StringBuilder();
renderHTMLHeader(b);
b.append("<h1> Server configuration </h1>\n");
public void handle(Context ctx) throws Exception {
try {
ctx.getResponse().contentType("text/html");
Template template = Utils.freemarkerConfig().getTemplate("NumassRoot.ftl");
Map data = new HashMap(6);
if (!server.meta().isEmpty()) {
b.append("<h3> Server metadata: </h3>\n");
b.append(writer.writeString(server.meta()));
b.append("\n");
}
if (server.getRootState() != null) {
b.append("<h3> Current root state: </h3>\n");
renderStates(b, server.getRootState());
}
if (server.getRun() != null) {
b.append("<h1> Current run configuration </h1>\n");
if (!server.getRun().meta().isEmpty()) {
b.append("<h3> Run metadata: </h3>\n");
b.append(writer.writeString(server.getRun().meta()));
b.append("\n");
}
StateLoader runStates = server.getRun().getStates();
if (!runStates.isEmpty()) {
b.append("<h3> Current run state: </h3>\n");
renderStates(b, runStates);
data.put("serverMeta", writer.writeString(server.meta()));
}
if (server.getRootState() != null) {
data.put("serverRootState", renderStates(server.getRootState()));
}
if (server.getRun() != null) {
data.put("runPresent", true);
if (!server.getRun().meta().isEmpty()) {
data.put("runMeta", writer.writeString(server.getRun().meta()));
}
StateLoader runState = server.getRun().getStates();
if (!runState.isEmpty()) {
data.put("runState", renderStates(runState));
}
b.append("<h2> Current run storage content: </h2>\n");
NumassStorage storage = server.getRun().getStorage();
try {
renderStorage(c, b, storage);
StringBuilder b = new StringBuilder();
renderStorage(ctx, b, server.getRun().getStorage());
data.put("storageContent", b.toString());
} catch (StorageException ex) {
b.append("\n<strong>Error reading sotrage structure!!!</strong>\n");
data.put("storageContent", ex.toString());
}
} else {
data.put("runPresent", false);
}
StringWriter stringWriter = new StringWriter();
template.process(data, stringWriter);
ctx.render(stringWriter.toString());
} catch (Exception ex) {
LoggerFactory.getLogger(getClass()).error("Error rendering storage tree");
ctx.render(ex.toString());
}
renderHTMLFooter(b);
c.render(b);
}
private void renderStorage(Context ctx, StringBuilder b, Storage storage) throws StorageException {

View File

@ -24,13 +24,16 @@ import hep.dataforge.storage.commons.AbstractNetworkListener;
import hep.dataforge.storage.commons.LoaderFactory;
import hep.dataforge.storage.commons.StorageManager;
import hep.dataforge.storage.filestorage.FileStorage;
import hep.dataforge.storage.servlet.StorageRatpackHandler;
import inr.numass.storage.NumassStorage;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ratpack.file.FileHandlerSpec;
import ratpack.handling.Chain;
import ratpack.server.BaseDir;
import ratpack.server.RatpackServer;
import ratpack.server.RatpackServerSpec;
import ratpack.server.ServerConfigBuilder;
@ -81,8 +84,12 @@ public class NumassServer extends AbstractNetworkListener {
super.open();
int port = meta().getInt("ratpack.port", 8336);
ratpack = RatpackServer.start((RatpackServerSpec server) -> server
.serverConfig((ServerConfigBuilder config) -> config.port(port))
.serverConfig((ServerConfigBuilder config) -> config
// .baseDir(Paths.get(getClass().getClassLoader().getResource("ratpack").toURI()))
// .baseDir(BaseDir.find())
.port(port))
.handlers((Chain chain) -> chain
// .files()
.get(new NumassRootHandler(this))
.get("storage", new NumassStorageHandler(root))
)
@ -232,67 +239,4 @@ public class NumassServer extends AbstractNetworkListener {
public NumassRun getRun() {
return run;
}
// private class NumassRootHandler implements Handler {
//
// @Override
// public void handle(Context c) throws Exception {
// c.getResponse().contentType("text/html");
// StringBuilder b = new StringBuilder();
// renderHTMLHeader(b);
// b.append("<h1> Server configuration </h1>\n");
// if (!meta().isEmpty()) {
// b.append("<h3> Server metadata: </h3>\n");
// b.append(writer.writeString(meta()));
// b.append("\n");
// }
// if (getRootState() != null) {
// b.append("<h3> Current root state: </h3>\n");
// renderStates(b, getRootState());
// }
// if (getRun() != null) {
// b.append("<h1> Current run configuration </h1>\n");
// if (!run.meta().isEmpty()) {
// b.append("<h3> Run metadata: </h3>\n");
// b.append(writer.writeString(getRun().meta()));
// b.append("\n");
// }
// StateLoader runStates = getRun().getStates();
// if (!runStates.isEmpty()) {
// b.append("<h3> Current run state: </h3>\n");
// renderStates(b, runStates);
// }
//
// b.append("<h2> Current run storage content: </h2>\n");
// NumassStorage storage = getRun().getStorage();
// try {
// renderStorage(c, b, storage);
// } catch (StorageException ex) {
// b.append("\n<strong>Error reading sotrage structure!!!</strong>\n");
// }
// }
// renderHTMLFooter(b);
// c.render(b);
// }
//
// private void renderStorage(Context ctx, StringBuilder b, Storage storage) throws StorageException {
// b.append("<div class=\"shifted\">\n");
// for (Storage shelf : storage.shelves().values()) {
// b.append(String.format("<p><strong>+ %s</strong></p>%n", shelf.getName()));
// renderStorage(ctx, b, shelf);
// }
// b.append("<div class=\"shifted\">\n");
// for (Loader loader : storage.loaders().values()) {
// defaultRenderLoader(ctx, b, loader);
// }
// b.append("</div>\n");
// b.append("</div>\n");
// }
//
// private void defaultRenderLoader(Context ctx, StringBuilder b, Loader loader) {
// String href = "/storage?path="+loader.getFullPath();
// b.append(String.format("<p><a href=\"%s\">%s</a> (%s)</p>", href, loader.getName(), loader.getType()));
// }
//
// }
}

View File

@ -12,9 +12,13 @@ import hep.dataforge.storage.api.Storage;
import hep.dataforge.storage.servlet.StorageRatpackHandler;
import hep.dataforge.storage.servlet.Utils;
import java.io.StringWriter;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -28,6 +32,11 @@ import ratpack.handling.Context;
*/
public class NumassStorageHandler extends StorageRatpackHandler {
private static DateTimeFormatter formatter
= DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
.withLocale(Locale.US)
.withZone(ZoneId.systemDefault());
public NumassStorageHandler(Storage root) {
super(root);
}
@ -40,7 +49,7 @@ public class NumassStorageHandler extends StorageRatpackHandler {
ctx.getResponse().contentType("text/html");
Template template = Utils.freemarkerConfig().getTemplate("NoteLoader.ftl");
List<String> notes = getNotes(loader).limit(100).map(note->render(note)).collect(Collectors.toList());
List<String> notes = getNotes(loader).limit(100).map(note -> render(note)).collect(Collectors.toList());
Map data = new HashMap(2);
data.put("notes", notes);
@ -58,8 +67,8 @@ public class NumassStorageHandler extends StorageRatpackHandler {
}
}
private String render(NumassNote note){
return String.format("%s: <strong>%s</strong> %s", note.ref(), note.time(), note.content());
private String render(NumassNote note) {
return String.format("<strong id=\"%s\">%s</strong> %s", note.ref(), formatter.format(note.time()), note.content());
}
/**

View File

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="30">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<title>Numass storage</title>
</head>
<style>
.shifted {
margin: 20px;
}
</style>
<body>
<h1> Server configuration </h1>
<#if serverMeta??>
<h3> Server metadata: </h3>
${serverMeta}
</#if>
<br/>
<#if serverRootState??>
<h3> Current root state: </h3>
${serverRootState}
</#if>
<br/>
<#if runPresent>
<h1> Current run configuration </h1>
<#if runMeta??>
<h3> Run metadata: </h3>
${runMeta}
</#if>
<#if runState?? >
<h3> Current run state: </h3>
${runState}
</#if>
<h2> Current run storage content: </h2>
${storageContent}
</#if>
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</body>
</html>

View File

@ -101,7 +101,7 @@ public class MspViewController {
try (final PointLoader mspLoader = (PointLoader) rootStorage.getLoader(loaderName)) {
mspLoader.open();
callback.updateMessage("Loading mass spectrometer data from " + mspLoader.getName());
for (DataPoint dp : mspLoader.asDataSet()) {
for (DataPoint dp : mspLoader) {
mspData.add(dp);
last = dp;
}

View File

@ -13,6 +13,7 @@ configurations {
}
repositories {
jcenter()
mavenCentral()
maven { url "http://www.inr.ru/~nozik/maven2/" }
// mavenLocal()