[no commit message]
This commit is contained in:
parent
b6323d2f90
commit
70ee806674
@ -5,13 +5,13 @@ if (!hasProperty('mainClass')) {
|
||||
}
|
||||
mainClassName = mainClass
|
||||
|
||||
version = "0.2.5"
|
||||
version = "0.3.0"
|
||||
|
||||
description = "The viewer for numass data"
|
||||
|
||||
dependencies {
|
||||
compile project(':numass-main')
|
||||
compile project(':dataforge-storage')
|
||||
// compile project(':dataforge-storage')
|
||||
compile project(':numass-storage')
|
||||
compile project(':dataforge-fx')
|
||||
compile 'com.jcraft:jsch:0.1.53'
|
||||
|
@ -27,11 +27,9 @@ import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.Optional;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javafx.application.Platform;
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
@ -150,50 +148,22 @@ public class MainViewerController implements Initializable {
|
||||
});
|
||||
}
|
||||
|
||||
private class DirectoryLoadTask extends Task<Void> {
|
||||
|
||||
private final String uri;
|
||||
|
||||
public DirectoryLoadTask(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void call() throws Exception {
|
||||
updateTitle("Load storage (" + uri + ")");
|
||||
updateProgress(-1, 1);
|
||||
updateMessage("Building numass storage tree...");
|
||||
try {
|
||||
NumassStorage root = NumassStorage.buildNumassRoot(uri, true, false);
|
||||
setRootStorage(root);
|
||||
Platform.runLater(() -> storagePathLabel.setText("Storage: " + uri));
|
||||
} catch (StorageException ex) {
|
||||
updateProgress(0, 1);
|
||||
updateMessage("Failed to load storage " + uri);
|
||||
Logger.getLogger(MainViewerController.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Context getContext() {
|
||||
return GlobalContext.instance();
|
||||
}
|
||||
|
||||
public void setRootStorage(NumassStorage root) {
|
||||
// Task fillTask = new StorageDataFillTask(root);
|
||||
// postTask(fillTask);
|
||||
// Viewer.runTask(fillTask);
|
||||
|
||||
getContext().processManager().post("viewer.storage.load", new Consumer<ProcessManager.Callback>() {
|
||||
@Override
|
||||
public void accept(ProcessManager.Callback callback) {
|
||||
getContext().processManager().cleanup();
|
||||
getContext().processManager().post("viewer.storage.load", (ProcessManager.Callback callback) -> {
|
||||
callback.updateTitle("Fill data to UI (" + root.getName() + ")");
|
||||
callback.updateProgress(-1, 1);
|
||||
// callback.updateProgress(-1, 1);
|
||||
Platform.runLater(() -> statusBar.setProgress(-1));
|
||||
|
||||
callback.updateMessage("Loading numass storage tree...");
|
||||
|
||||
new NumassLoaderTreeBuilder().build(getContext(), numassLoaderDataTree, root, (NumassData loader) -> {
|
||||
try {
|
||||
new NumassLoaderTreeBuilder().build(callback, numassLoaderDataTree, root, (NumassData loader) -> {
|
||||
NumassLoaderViewComponent component = new NumassLoaderViewComponent(getContext());
|
||||
component.loadData(loader);
|
||||
numassLoaderViewContainer.getChildren().clear();
|
||||
@ -204,13 +174,14 @@ public class MainViewerController implements Initializable {
|
||||
AnchorPane.setBottomAnchor(component, 0.0);
|
||||
numassLoaderViewContainer.requestLayout();
|
||||
});
|
||||
} catch (StorageException ex) {
|
||||
Logger.getLogger(MainViewerController.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
callback.updateProgress(0, 1);
|
||||
// callback.updateProgress(1, 1);
|
||||
Platform.runLater(() -> statusBar.setProgress(0));
|
||||
callback.updateMessage("Numass storage tree loaded.");
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
mspController = new MspViewController(getContext(), mspPlotPane);
|
||||
mspController.fillMspData(root);
|
||||
|
@ -21,6 +21,9 @@ package inr.numass.viewer;
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
import hep.dataforge.context.Context;
|
||||
import hep.dataforge.context.DFProcess;
|
||||
import hep.dataforge.context.ProcessManager;
|
||||
import hep.dataforge.exceptions.StorageException;
|
||||
import hep.dataforge.points.DataPoint;
|
||||
import hep.dataforge.points.MapPoint;
|
||||
import hep.dataforge.plots.PlotUtils;
|
||||
@ -33,9 +36,11 @@ import hep.dataforge.storage.api.Storage;
|
||||
import hep.dataforge.values.Value;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.StreamSupport;
|
||||
import javafx.application.Platform;
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -46,7 +51,6 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class MspViewController {
|
||||
|
||||
|
||||
private final AnchorPane mspPlotPane;
|
||||
private final Context context;
|
||||
|
||||
@ -75,8 +79,8 @@ public class MspViewController {
|
||||
PlotUtils.setXAxis(frame, "time", null, "time");
|
||||
|
||||
StreamSupport.stream(mspData.spliterator(), false)
|
||||
.sorted((DynamicPlottable o1, DynamicPlottable o2) ->
|
||||
Integer.valueOf(o1.getName()).compareTo(Integer.valueOf(o2.getName()))).forEach((pl) -> frame.add(pl));
|
||||
.sorted((DynamicPlottable o1, DynamicPlottable o2)
|
||||
-> Integer.valueOf(o1.getName()).compareTo(Integer.valueOf(o2.getName()))).forEach((pl) -> frame.add(pl));
|
||||
Platform.runLater(() -> {
|
||||
PlotContainer container = PlotContainer.anchorTo(mspPlotPane);
|
||||
container.setPlot(frame);
|
||||
@ -85,32 +89,35 @@ public class MspViewController {
|
||||
|
||||
public void fillMspData(Storage rootStorage) {
|
||||
if (rootStorage != null) {
|
||||
MspDataFillTask fillTask = new MspDataFillTask(rootStorage);
|
||||
if (callback != null) {
|
||||
callback.postTask(fillTask);
|
||||
context.processManager().post("viewer.msp.fill", (ProcessManager.Callback callback) -> {
|
||||
try {
|
||||
// callback.updateTitle("Fill msp data (" + rootStorage.getName() + ")");
|
||||
|
||||
callback.updateTitle("Load msp data (" + rootStorage.getName() + ")");
|
||||
List<DataPoint> mspData = new ArrayList<>();
|
||||
DataPoint last = null;
|
||||
for (String loaderName : rootStorage.loaders().keySet()) {
|
||||
if (loaderName.startsWith("msp")) {
|
||||
try (final PointLoader mspLoader = (PointLoader) rootStorage.getLoader(loaderName)) {
|
||||
mspLoader.open();
|
||||
callback.updateMessage("Loading mass spectrometer data from " + mspLoader.getName());
|
||||
for (DataPoint dp : mspLoader.asDataSet()) {
|
||||
mspData.add(dp);
|
||||
last = dp;
|
||||
}
|
||||
Viewer.runTask(fillTask);
|
||||
if (last != null) {
|
||||
mspData.add(terminatorPoint(last));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LoggerFactory.getLogger(getClass()).error("Can't read msp loader data", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private class MspDataFillTask extends Task<Void> {
|
||||
|
||||
private final Storage storage;
|
||||
|
||||
public MspDataFillTask(Storage storage) {
|
||||
this.storage = storage;
|
||||
}
|
||||
callback.updateMessage("Loading msp data finished");
|
||||
// return mspData;
|
||||
// List<DataPoint> mspData = (List<DataPoint>) loadProcess.getTask().get();
|
||||
|
||||
@Override
|
||||
protected Void call() throws Exception {
|
||||
updateTitle("Fill msp data (" + storage.getName() + ")");
|
||||
MspDataLoadTask loadTask = new MspDataLoadTask(storage);
|
||||
if (callback != null) {
|
||||
callback.postTask(loadTask);
|
||||
}
|
||||
Viewer.runTask(loadTask);
|
||||
List<DataPoint> mspData = loadTask.get();
|
||||
|
||||
if (!mspData.isEmpty()) {
|
||||
DynamicPlottableSet plottables = new DynamicPlottableSet();
|
||||
|
||||
for (DataPoint point : mspData) {
|
||||
@ -125,50 +132,13 @@ public class MspViewController {
|
||||
}
|
||||
|
||||
updateMspPane(plottables);
|
||||
return null;
|
||||
}
|
||||
|
||||
} catch (StorageException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
private class MspDataLoadTask extends Task<List<DataPoint>> {
|
||||
|
||||
private final Storage storage;
|
||||
|
||||
public MspDataLoadTask(Storage storage) {
|
||||
this.storage = storage;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<DataPoint> call() throws Exception {
|
||||
updateTitle("Load msp data (" + storage.getName() + ")");
|
||||
List<DataPoint> mspData = new ArrayList<>();
|
||||
DataPoint last = null;
|
||||
for (String loaderName : storage.loaders().keySet()) {
|
||||
if (loaderName.startsWith("msp")) {
|
||||
try (PointLoader mspLoader = (PointLoader) storage.getLoader(loaderName)) {
|
||||
mspLoader.open();
|
||||
updateMessage("Loading mass spectrometer data from " + mspLoader.getName());
|
||||
updateProgress(-1, 1);
|
||||
for (DataPoint dp : mspLoader.asDataSet()) {
|
||||
mspData.add(dp);
|
||||
last = dp;
|
||||
}
|
||||
if (last != null) {
|
||||
mspData.add(terminatorPoint(last));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LoggerFactory.getLogger(getClass()).error("Can't read msp loader data", ex);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateMessage("Loading msp data finished");
|
||||
updateProgress(0, 1);
|
||||
return mspData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a null value point to terminate msp series
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package inr.numass.viewer;
|
||||
|
||||
import hep.dataforge.context.Context;
|
||||
import hep.dataforge.context.ProcessManager;
|
||||
import hep.dataforge.exceptions.StorageException;
|
||||
import hep.dataforge.storage.api.Loader;
|
||||
@ -48,14 +47,12 @@ public class NumassLoaderTreeBuilder {
|
||||
// this.rootStorage = rootStorage;
|
||||
// this.numassViewBuilder = numassViewBuilder;
|
||||
// }
|
||||
public void build(Context context,
|
||||
public void build(ProcessManager.Callback callback,
|
||||
TreeTableView<TreeItemValue> numassLoaderDataTree,
|
||||
NumassStorage rootStorage,
|
||||
Consumer<NumassData> numassViewBuilder) {
|
||||
Consumer<NumassData> numassViewBuilder) throws StorageException {
|
||||
|
||||
context.processManager().post("viewer.storage.load.buildTree", (ProcessManager.Callback callback) -> {
|
||||
try {
|
||||
callback.updateTitle("Load numass data (" + rootStorage.getName() + ")");
|
||||
// callback.updateTitle("Load numass data (" + rootStorage.getName() + ")");
|
||||
TreeItem<TreeItemValue> root = buildNode(rootStorage, numassViewBuilder, callback);
|
||||
root.setExpanded(true);
|
||||
|
||||
@ -89,15 +86,22 @@ public class NumassLoaderTreeBuilder {
|
||||
numassLoaderTimeColumn.setVisible(false);
|
||||
nummassLoaderDescriptionColumn.setVisible(false);
|
||||
});
|
||||
} catch (StorageException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private TreeItem<TreeItemValue> buildNode(NumassStorage storage,
|
||||
Consumer<NumassData> numassViewBuilder, ProcessManager.Callback callback) throws StorageException {
|
||||
// CompletableFuture<TreeItem<TreeItemValue>> future = CompletableFuture.supplyAsync(() -> {
|
||||
// try {
|
||||
// TreeItem<TreeItemValue> node = new TreeItem<>(buildValue(storage));
|
||||
// node.getChildren().setAll(buildChildren(storage, numassViewBuilder, callback));
|
||||
// return node;
|
||||
// } catch (StorageException ex) {
|
||||
// throw new RuntimeException(ex);
|
||||
// }
|
||||
// });
|
||||
// callback.getProcess().addChild(storage.getName(), future);
|
||||
// return future.join();
|
||||
TreeItem<TreeItemValue> node = new TreeItem<>(buildValue(storage));
|
||||
node.getChildren().setAll(buildChildren(storage, numassViewBuilder, callback));
|
||||
return node;
|
||||
@ -110,16 +114,18 @@ public class NumassLoaderTreeBuilder {
|
||||
for (Storage subStorage : storage.shelves().values()) {
|
||||
if (subStorage instanceof NumassStorage) {
|
||||
NumassStorage numassSubStorage = (NumassStorage) subStorage;
|
||||
TreeItem<TreeItemValue> childNode = buildNode(numassSubStorage, numassViewBuilder, callback);
|
||||
if (!childNode.isLeaf()) {
|
||||
list.add(buildNode(numassSubStorage, numassViewBuilder, callback));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
callback.updateMessage("Building storage " + storage.getName());
|
||||
|
||||
double counter = 0;
|
||||
callback.updateProgress(-1, 1);
|
||||
callback.updateProgress(0, storage.loaders().size());
|
||||
for (Loader loader : storage.loaders().values()) {
|
||||
callback.updateMessage("Building numass data loader " + loader.getName());
|
||||
callback.updateProgress(counter, storage.loaders().size());
|
||||
|
||||
if (loader instanceof NumassData) {
|
||||
NumassData numassLoader = (NumassData) loader;
|
||||
@ -135,17 +141,19 @@ public class NumassLoaderTreeBuilder {
|
||||
// });
|
||||
list.add(numassLoaderTreeItem);
|
||||
}
|
||||
counter++;
|
||||
callback.changeProgress(1, 0);
|
||||
}
|
||||
|
||||
callback.updateMessage("Loading legacy DAT files");
|
||||
callback.updateProgress(-1, 1);
|
||||
List<NumassData> legacyFiles = storage.legacyFiles();
|
||||
callback.updateProgress(0, legacyFiles.size());
|
||||
//adding legacy data files
|
||||
counter = 0;
|
||||
for (NumassData legacyDat : storage.legacyFiles()) {
|
||||
for (NumassData legacyDat : legacyFiles) {
|
||||
callback.updateMessage("Loading numass DAT file " + legacyDat.getName());
|
||||
callback.updateProgress(counter, storage.loaders().size());
|
||||
TreeItem<TreeItemValue> numassLoaderTreeItem = new TreeItem<>(buildValue(legacyDat));
|
||||
callback.changeProgress(1, 0);
|
||||
list.add(numassLoaderTreeItem);
|
||||
counter++;
|
||||
}
|
||||
|
||||
return list;
|
||||
|
@ -30,6 +30,7 @@ limitations under the License.
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import org.controlsfx.control.StatusBar?>
|
||||
|
||||
<AnchorPane id="AnchorPane" prefHeight="768.0" prefWidth="1024.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="inr.numass.viewer.MainViewerController">
|
||||
<children>
|
||||
|
Loading…
Reference in New Issue
Block a user