Fixes for numass-viewer

This commit is contained in:
Alexander Nozik 2016-09-19 22:56:24 +03:00
parent e62716a80f
commit 1177bdfa6c
6 changed files with 49 additions and 51 deletions

View File

@ -12,14 +12,16 @@ import hep.dataforge.storage.api.StateLoader;
import hep.dataforge.storage.api.Storage; import hep.dataforge.storage.api.Storage;
import hep.dataforge.storage.commons.JSONMetaWriter; import hep.dataforge.storage.commons.JSONMetaWriter;
import hep.dataforge.storage.servlet.Utils; 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 org.slf4j.LoggerFactory;
import ratpack.handling.Context; import ratpack.handling.Context;
import ratpack.handling.Handler; import ratpack.handling.Handler;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import static inr.numass.server.HandlerUtils.renderStates;
/** /**
* *
* @author Alexander Nozik * @author Alexander Nozik
@ -98,7 +100,7 @@ public class NumassRootHandler implements Handler {
} }
private void renderLoader(Context ctx, StringBuilder b, Loader loader) { private void renderLoader(Context ctx, StringBuilder b, Loader loader) {
String href = "/storage?path=" + loader.getFullPath(); String href = "/storage?path=" + loader.getPath();
b.append(String.format("<p><a href=\"%s\">%s</a> (%s)</p>", href, loader.getName(), loader.getType())); b.append(String.format("<p><a href=\"%s\">%s</a> (%s)</p>", href, loader.getName(), loader.getType()));
} }
} }

View File

@ -311,7 +311,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
public boolean isReversed() { public boolean isReversed() {
//TODO replace by meta tag in later revisions //TODO replace by meta tag in later revisions
return SetDirectionUtility.isReversed(getFullPath(), n -> { return SetDirectionUtility.isReversed(getPath(), n -> {
List<Envelope> points = getPoints(); List<Envelope> points = getPoints();
if (getPoints().size() >= 2) { if (getPoints().size() >= 2) {
return readTime(points.get(0).meta()).isAfter(readTime(points.get(1).meta())); return readTime(points.get(0).meta()).isAfter(readTime(points.get(1).meta()));

View File

@ -20,8 +20,10 @@ import hep.dataforge.events.EventBuilder;
import hep.dataforge.exceptions.StorageException; import hep.dataforge.exceptions.StorageException;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.meta.MetaBuilder; import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.storage.filestorage.FilePointLoader;
import hep.dataforge.storage.filestorage.FileStorage; import hep.dataforge.storage.filestorage.FileStorage;
import hep.dataforge.storage.filestorage.VFSUtils; import hep.dataforge.storage.filestorage.VFSUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.vfs2.FileObject; import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException; import org.apache.commons.vfs2.FileSystemException;
import org.apache.commons.vfs2.FileType; import org.apache.commons.vfs2.FileType;
@ -146,6 +148,13 @@ public class NumassStorage extends FileStorage {
} }
} else if (file.getName().toString().endsWith(NUMASS_ZIP_EXTENSION)) { } else if (file.getName().toString().endsWith(NUMASS_ZIP_EXTENSION)) {
this.loaders.put(file.getName().getBaseName(), NumassDataLoader.fromZip(this, file)); this.loaders.put(file.getName().getBaseName(), NumassDataLoader.fromZip(this, file));
} else if (file.getName().toString().endsWith(".points")) {
try {
loaders.put(FilenameUtils.getBaseName(file.getName().getBaseName()),
FilePointLoader.fromFile(this, file, true));
} catch (Exception ex) {
getContext().getLogger().error("Failed to build numass point loader from file {}", file.getName());
}
} else { } else {
//updating non-numass loader files //updating non-numass loader files
updateFile(file); updateFile(file);

View File

@ -5,7 +5,7 @@ if (!hasProperty('mainClass')) {
} }
mainClassName = mainClass mainClassName = mainClass
version = "0.3.4" version = "0.3.5"
description = "The viewer for numass data" description = "The viewer for numass data"

View File

@ -23,7 +23,7 @@ package inr.numass.viewer;
import hep.dataforge.computation.ProgressCallback; import hep.dataforge.computation.ProgressCallback;
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.exceptions.StorageException; import hep.dataforge.names.Name;
import hep.dataforge.plots.PlotUtils; import hep.dataforge.plots.PlotUtils;
import hep.dataforge.plots.data.DynamicPlottable; import hep.dataforge.plots.data.DynamicPlottable;
import hep.dataforge.plots.data.DynamicPlottableSet; import hep.dataforge.plots.data.DynamicPlottableSet;
@ -31,6 +31,7 @@ import hep.dataforge.plots.fx.PlotContainer;
import hep.dataforge.plots.jfreechart.JFreeChartFrame; import hep.dataforge.plots.jfreechart.JFreeChartFrame;
import hep.dataforge.storage.api.PointLoader; import hep.dataforge.storage.api.PointLoader;
import hep.dataforge.storage.api.Storage; import hep.dataforge.storage.api.Storage;
import hep.dataforge.storage.commons.StorageUtils;
import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.DataPoint;
import hep.dataforge.tables.MapPoint; import hep.dataforge.tables.MapPoint;
import hep.dataforge.values.Value; import hep.dataforge.values.Value;
@ -88,17 +89,23 @@ public class MspViewController {
public void fillMspData(Storage rootStorage) { public void fillMspData(Storage rootStorage) {
if (rootStorage != null) { if (rootStorage != null) {
context.taskManager().submit("viewer.msp.fill", (ProgressCallback callback) -> { context.taskManager().submit("viewer.msp.fill", (ProgressCallback callback) -> {
try { // callback.updateTitle("Fill msp data (" + rootStorage.getName() + ")");
// callback.updateTitle("Fill msp data (" + rootStorage.getName() + ")");
callback.updateTitle("Load msp data (" + rootStorage.getName() + ")"); callback.updateTitle("Load msp data (" + rootStorage.getName() + ")");
List<DataPoint> mspData = new ArrayList<>();
DataPoint last = null; List<DataPoint> mspData = new ArrayList<>();
for (String loaderName : rootStorage.loaders().keySet()) {
if (loaderName.startsWith("msp")) { StorageUtils.loaderStream(rootStorage)
try (final PointLoader mspLoader = (PointLoader) rootStorage.getLoader(loaderName)) { .filter(pair -> pair.getValue() instanceof PointLoader)
.filter(pair -> Name.of(pair.getKey()).getLast().toString().startsWith("msp"))
.map(pair -> pair.getValue())
.filter(loader -> PointLoader.POINT_LOADER_TYPE.equals(loader.getType()))
.forEach(loader -> {
try {
PointLoader mspLoader = (PointLoader) loader;
mspLoader.open(); mspLoader.open();
callback.updateMessage("Loading mass spectrometer data from " + mspLoader.getName()); callback.updateMessage("Loading mass spectrometer data from " + mspLoader.getName());
DataPoint last = null;
for (DataPoint dp : mspLoader) { for (DataPoint dp : mspLoader) {
mspData.add(dp); mspData.add(dp);
last = dp; last = dp;
@ -109,30 +116,26 @@ public class MspViewController {
} catch (Exception ex) { } catch (Exception ex) {
LoggerFactory.getLogger(getClass()).error("Can't read msp loader data", ex); LoggerFactory.getLogger(getClass()).error("Can't read msp loader data", ex);
} }
} });
} callback.updateMessage("Loading msp data finished");
callback.updateMessage("Loading msp data finished");
// return mspData; // return mspData;
// List<DataPoint> mspData = (List<DataPoint>) loadProcess.getTask().get(); // List<DataPoint> mspData = (List<DataPoint>) loadProcess.getTask().get();
if (!mspData.isEmpty()) { if (!mspData.isEmpty()) {
DynamicPlottableSet plottables = new DynamicPlottableSet(); DynamicPlottableSet plottables = new DynamicPlottableSet();
for (DataPoint point : mspData) { for (DataPoint point : mspData) {
for (String name : point.names()) { for (String name : point.names()) {
if (!name.equals("timestamp")) { if (!name.equals("timestamp")) {
if (!plottables.hasPlottable(name)) { if (!plottables.hasPlottable(name)) {
plottables.addPlottable(new DynamicPlottable(name, name)); plottables.addPlottable(new DynamicPlottable(name, name));
}
} }
} }
plottables.put(point);
} }
plottables.put(point);
updateMspPane(plottables);
} }
} catch (StorageException ex) {
throw new RuntimeException(ex); updateMspPane(plottables);
} }
}); });
} }

View File

@ -16,29 +16,13 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<?import java.lang.*?> <?import javafx.geometry.Insets?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<?import org.controlsfx.control.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.ToggleButton?>
<?import javafx.scene.control.ToolBar?>
<?import javafx.scene.control.TreeTableView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<?import org.controlsfx.control.StatusBar?> <?import org.controlsfx.control.StatusBar?>
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" id="AnchorPane" prefHeight="768.0" prefWidth="1024.0"
<AnchorPane id="AnchorPane" prefHeight="768.0" prefWidth="1024.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="inr.numass.viewer.MainViewerController"> xmlns="http://javafx.com/javafx/8.0.60" fx:controller="inr.numass.viewer.MainViewerController">
<children> <children>
<BorderPane prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <BorderPane prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<top> <top>