Cleanup of work mechanism
This commit is contained in:
parent
0e55abfabc
commit
068b85c7eb
@ -7,17 +7,13 @@
|
|||||||
package inr.numass.scripts
|
package inr.numass.scripts
|
||||||
|
|
||||||
import hep.dataforge.io.ColumnedDataWriter
|
import hep.dataforge.io.ColumnedDataWriter
|
||||||
import hep.dataforge.tables.TableFormatBuilder
|
|
||||||
import hep.dataforge.tables.ListTable
|
import hep.dataforge.tables.ListTable
|
||||||
import hep.dataforge.tables.MapPoint
|
import hep.dataforge.tables.MapPoint
|
||||||
import hep.dataforge.tables.Table
|
import hep.dataforge.tables.TableFormatBuilder
|
||||||
import inr.numass.storage.NumassData
|
import inr.numass.storage.NumassData
|
||||||
import inr.numass.data.*
|
|
||||||
import javafx.stage.FileChooser
|
|
||||||
|
|
||||||
|
|
||||||
NumassData.metaClass.findPoint{double u ->
|
NumassData.metaClass.findPoint{double u ->
|
||||||
delegate.getNMPoints().find{it.getUset() == u}.getMapWithBinning(20,true)
|
delegate.getNMPoints().getWork{it.getUset() == u}.getMapWithBinning(20,true)
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Double, Double> dif(NumassData data1, NumassData data2, double uset){
|
Map<Double, Double> dif(NumassData data1, NumassData data2, double uset){
|
||||||
|
@ -162,7 +162,7 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
|
|||||||
this.context = this.contextFactory.build(parentContext, config);
|
this.context = this.contextFactory.build(parentContext, config);
|
||||||
|
|
||||||
// attachig visual process manager
|
// attachig visual process manager
|
||||||
processWindow.setManager(context.taskManager());
|
processWindow.setManager(context.getWorkManager());
|
||||||
|
|
||||||
// setting io manager
|
// setting io manager
|
||||||
context.setIO(new WorkbenchIOManager(new NumassIO(), this));
|
context.setIO(new WorkbenchIOManager(new NumassIO(), this));
|
||||||
@ -337,7 +337,7 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
|
|||||||
runActions();
|
runActions();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.context.taskManager().shutdown();
|
this.context.getWorkManager().shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ public class Workbench extends Application {
|
|||||||
|
|
||||||
scene.getWindow().setOnCloseRequest((WindowEvent event) -> {
|
scene.getWindow().setOnCloseRequest((WindowEvent event) -> {
|
||||||
try {
|
try {
|
||||||
controller.getContext().taskManager().getRoot().cancel(true);
|
controller.getContext().getWorkManager().getRoot().cancel(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import hep.dataforge.context.Context;
|
|||||||
import hep.dataforge.data.DataNode;
|
import hep.dataforge.data.DataNode;
|
||||||
import hep.dataforge.data.DataSet;
|
import hep.dataforge.data.DataSet;
|
||||||
import hep.dataforge.description.TypedActionDef;
|
import hep.dataforge.description.TypedActionDef;
|
||||||
import hep.dataforge.goals.ProgressCallback;
|
|
||||||
import hep.dataforge.io.ColumnedDataWriter;
|
import hep.dataforge.io.ColumnedDataWriter;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.stat.fit.FitState;
|
import hep.dataforge.stat.fit.FitState;
|
||||||
@ -33,7 +32,7 @@ import java.util.Map;
|
|||||||
public class NumassFitScanSummaryTask extends AbstractTask<Table> {
|
public class NumassFitScanSummaryTask extends AbstractTask<Table> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DataNode<Table> run(TaskModel model, ProgressCallback callback, DataNode<?> data) {
|
protected DataNode<Table> run(TaskModel model, DataNode<?> data) {
|
||||||
DataSet.Builder<Table> builder = DataSet.builder(Table.class);
|
DataSet.Builder<Table> builder = DataSet.builder(Table.class);
|
||||||
Action<FitState, Table> action = new FitSummaryAction();
|
Action<FitState, Table> action = new FitSummaryAction();
|
||||||
DataNode<FitState> input = data.getCheckedNode("fitscan", FitState.class);
|
DataNode<FitState> input = data.getCheckedNode("fitscan", FitState.class);
|
||||||
|
@ -8,7 +8,6 @@ package inr.numass.workspace;
|
|||||||
import hep.dataforge.actions.Action;
|
import hep.dataforge.actions.Action;
|
||||||
import hep.dataforge.data.DataNode;
|
import hep.dataforge.data.DataNode;
|
||||||
import hep.dataforge.data.DataTree;
|
import hep.dataforge.data.DataTree;
|
||||||
import hep.dataforge.goals.ProgressCallback;
|
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.meta.MetaBuilder;
|
import hep.dataforge.meta.MetaBuilder;
|
||||||
import hep.dataforge.stat.fit.FitAction;
|
import hep.dataforge.stat.fit.FitAction;
|
||||||
@ -27,7 +26,7 @@ public class NumassFitScanTask extends AbstractTask<FitState> {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DataNode<FitState> run(TaskModel model, ProgressCallback callback, DataNode<?> data) {
|
protected DataNode<FitState> run(TaskModel model, DataNode<?> data) {
|
||||||
Meta config = model.meta();
|
Meta config = model.meta();
|
||||||
String scanParameter = config.getString("scan.parameter", "msterile2");
|
String scanParameter = config.getString("scan.parameter", "msterile2");
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import hep.dataforge.context.Context;
|
|||||||
import hep.dataforge.data.*;
|
import hep.dataforge.data.*;
|
||||||
import hep.dataforge.description.DescriptorBuilder;
|
import hep.dataforge.description.DescriptorBuilder;
|
||||||
import hep.dataforge.description.NodeDescriptor;
|
import hep.dataforge.description.NodeDescriptor;
|
||||||
import hep.dataforge.goals.ProgressCallback;
|
import hep.dataforge.goals.Work;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.meta.Template;
|
import hep.dataforge.meta.Template;
|
||||||
import hep.dataforge.storage.api.Loader;
|
import hep.dataforge.storage.api.Loader;
|
||||||
@ -35,23 +35,23 @@ import java.net.URI;
|
|||||||
public class NumassPrepareTask extends AbstractTask<Table> {
|
public class NumassPrepareTask extends AbstractTask<Table> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DataNode<Table> run(TaskModel model, ProgressCallback callback, DataNode<?> input) {
|
protected DataNode<Table> run(TaskModel model, DataNode<?> input) {
|
||||||
Meta config = model.meta();
|
Meta config = model.meta();
|
||||||
Context context = model.getContext();
|
Context context = model.getContext();
|
||||||
|
|
||||||
//acquiring initial data. Data node could not be empty
|
//acquiring initial data. Data node could not be empty
|
||||||
Meta dataMeta = config.getMeta("data");
|
Meta dataMeta = config.getMeta("data");
|
||||||
URI storageUri = input.getCheckedData("dataRoot", URI.class).get();
|
URI storageUri = input.getCheckedData("dataRoot", URI.class).get();
|
||||||
DataSet.Builder<NumassData> dataBuilder = readData(callback, context, storageUri, dataMeta);
|
DataSet.Builder<NumassData> dataBuilder = readData(getWork(model, input.getName()), context, storageUri, dataMeta);
|
||||||
DataNode<NumassData> data = dataBuilder.build();
|
DataNode<NumassData> data = dataBuilder.build();
|
||||||
|
|
||||||
//preparing table data
|
//preparing table data
|
||||||
Meta prepareMeta = config.getMeta("prepare");
|
Meta prepareMeta = config.getMeta("prepare");
|
||||||
DataNode<Table> tables = runAction(new PrepareDataAction(), callback, context, data, prepareMeta);
|
DataNode<Table> tables = runAction(new PrepareDataAction(), context, data, prepareMeta);
|
||||||
|
|
||||||
if (config.hasMeta("monitor")) {
|
if (config.hasMeta("monitor")) {
|
||||||
Meta monitorMeta = config.getMeta("monitor");
|
Meta monitorMeta = config.getMeta("monitor");
|
||||||
tables = runAction(new MonitorCorrectAction(), callback, context, tables, monitorMeta);
|
tables = runAction(new MonitorCorrectAction(), context, tables, monitorMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
//merging if needed
|
//merging if needed
|
||||||
@ -62,7 +62,7 @@ public class NumassPrepareTask extends AbstractTask<Table> {
|
|||||||
|
|
||||||
config.getMetaList("merge").forEach(mergeNode -> {
|
config.getMetaList("merge").forEach(mergeNode -> {
|
||||||
Meta mergeMeta = Template.compileTemplate(mergeNode, config);
|
Meta mergeMeta = Template.compileTemplate(mergeNode, config);
|
||||||
DataNode<Table> mergeData = runAction(new MergeDataAction(), callback, context, tablesForMerge.build(), mergeMeta);
|
DataNode<Table> mergeData = runAction(new MergeDataAction(), context, tablesForMerge.build(), mergeMeta);
|
||||||
mergeData.dataStream().forEach(d -> {
|
mergeData.dataStream().forEach(d -> {
|
||||||
resultBuilder.putData("merge." + d.getName(), d.anonymize());
|
resultBuilder.putData("merge." + d.getName(), d.anonymize());
|
||||||
});
|
});
|
||||||
@ -80,7 +80,7 @@ public class NumassPrepareTask extends AbstractTask<Table> {
|
|||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DataSet.Builder<NumassData> readData(ProgressCallback callback, Context context, URI numassRoot, Meta meta) {
|
private DataSet.Builder<NumassData> readData(Work callback, Context context, URI numassRoot, Meta meta) {
|
||||||
|
|
||||||
NumassStorage storage = NumassStorage.buildNumassRoot(numassRoot, true, false);
|
NumassStorage storage = NumassStorage.buildNumassRoot(numassRoot, true, false);
|
||||||
DataFilter filter = new DataFilter().configure(meta);
|
DataFilter filter = new DataFilter().configure(meta);
|
||||||
@ -148,7 +148,7 @@ public class NumassPrepareTask extends AbstractTask<Table> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T, R> DataNode<R> runAction(GenericAction<T, R> action, ProgressCallback callback, Context context, DataNode<T> data, Meta meta) {
|
private <T, R> DataNode<R> runAction(GenericAction<T, R> action, Context context, DataNode<T> data, Meta meta) {
|
||||||
return action.run(context, data, meta);
|
return action.run(context, data, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import hep.dataforge.data.Data;
|
|||||||
import hep.dataforge.data.DataNode;
|
import hep.dataforge.data.DataNode;
|
||||||
import hep.dataforge.data.DataTree;
|
import hep.dataforge.data.DataTree;
|
||||||
import hep.dataforge.data.DataUtils;
|
import hep.dataforge.data.DataUtils;
|
||||||
import hep.dataforge.goals.ProgressCallback;
|
|
||||||
import hep.dataforge.io.ColumnedDataWriter;
|
import hep.dataforge.io.ColumnedDataWriter;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.meta.MetaBuilder;
|
import hep.dataforge.meta.MetaBuilder;
|
||||||
@ -33,6 +32,7 @@ import hep.dataforge.workspace.TaskModel;
|
|||||||
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by darksnake on 06-Sep-16.
|
* Created by darksnake on 06-Sep-16.
|
||||||
@ -44,7 +44,7 @@ public class NumassSubstractEmptySourceTask extends AbstractTask<Table> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DataNode<Table> run(TaskModel model, ProgressCallback callback, DataNode<?> data) {
|
protected DataNode<Table> run(TaskModel model, DataNode<?> data) {
|
||||||
DataTree.Builder<Table> builder = DataTree.builder(Table.class);
|
DataTree.Builder<Table> builder = DataTree.builder(Table.class);
|
||||||
DataNode<Table> rootNode = data.getCheckedNode("prepare", Table.class);
|
DataNode<Table> rootNode = data.getCheckedNode("prepare", Table.class);
|
||||||
Data<? extends Table> emptySource = data.getCheckedNode("empty", Table.class).getData();
|
Data<? extends Table> emptySource = data.getCheckedNode("empty", Table.class).getData();
|
||||||
@ -77,9 +77,7 @@ public class NumassSubstractEmptySourceTask extends AbstractTask<Table> {
|
|||||||
|
|
||||||
|
|
||||||
private Data<? extends Table> subtractBackground(Data<? extends Table> mergeData, Data<? extends Table> emptyData) {
|
private Data<? extends Table> subtractBackground(Data<? extends Table> mergeData, Data<? extends Table> emptyData) {
|
||||||
return DataUtils.combine(Table.class, mergeData, emptyData, mergeData.meta(),
|
return DataUtils.combine(Table.class, mergeData, emptyData, mergeData.meta(), (BiFunction<Table, Table, Table>) this::subtractBackground);
|
||||||
(Table merge, Table empty) -> subtractBackground(merge, empty)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Table subtractBackground(Table merge, Table empty) {
|
private Table subtractBackground(Table merge, Table empty) {
|
||||||
|
@ -21,7 +21,7 @@ import hep.dataforge.exceptions.StorageException;
|
|||||||
import hep.dataforge.fx.fragments.FragmentWindow;
|
import hep.dataforge.fx.fragments.FragmentWindow;
|
||||||
import hep.dataforge.fx.fragments.LogFragment;
|
import hep.dataforge.fx.fragments.LogFragment;
|
||||||
import hep.dataforge.fx.work.WorkManagerFragment;
|
import hep.dataforge.fx.work.WorkManagerFragment;
|
||||||
import hep.dataforge.goals.ProgressCallback;
|
import hep.dataforge.goals.Work;
|
||||||
import inr.numass.NumassProperties;
|
import inr.numass.NumassProperties;
|
||||||
import inr.numass.storage.NumassData;
|
import inr.numass.storage.NumassData;
|
||||||
import inr.numass.storage.NumassStorage;
|
import inr.numass.storage.NumassStorage;
|
||||||
@ -131,17 +131,17 @@ public class MainViewerController implements Initializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadDirectory(String path) {
|
private void loadDirectory(String path) {
|
||||||
getContext().taskManager().submit("viewer.loadDirectory", (ProgressCallback callback) -> {
|
getContext().getWorkManager().startWork("viewer.loadDirectory", (Work work) -> {
|
||||||
callback.updateTitle("Load storage (" + path + ")");
|
work.setTitle("Load storage (" + path + ")");
|
||||||
callback.setProgress(-1);
|
work.setProgress(-1);
|
||||||
callback.updateMessage("Building numass storage tree...");
|
work.setStatus("Building numass storage tree...");
|
||||||
try {
|
try {
|
||||||
NumassStorage root = NumassStorage.buildNumassRoot(path, true, false);
|
NumassStorage root = NumassStorage.buildNumassRoot(path, true, false);
|
||||||
setRootStorage(root);
|
setRootStorage(root);
|
||||||
Platform.runLater(() -> storagePathLabel.setText("Storage: " + path));
|
Platform.runLater(() -> storagePathLabel.setText("Storage: " + path));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
callback.setProgress(0);
|
work.setProgress(0);
|
||||||
callback.updateMessage("Failed to load storage " + path);
|
work.setStatus("Failed to load storage " + path);
|
||||||
Logger.getLogger(MainViewerController.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MainViewerController.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -153,13 +153,13 @@ public class MainViewerController implements Initializable {
|
|||||||
|
|
||||||
public void setRootStorage(NumassStorage root) {
|
public void setRootStorage(NumassStorage root) {
|
||||||
|
|
||||||
getContext().taskManager().cleanup();
|
getContext().getWorkManager().cleanup();
|
||||||
getContext().taskManager().submit("viewer.storage.load", (ProgressCallback callback) -> {
|
getContext().getWorkManager().startWork("viewer.storage.load", (Work callback) -> {
|
||||||
callback.updateTitle("Fill data to UI (" + root.getName() + ")");
|
callback.setTitle("Fill data to UI (" + root.getName() + ")");
|
||||||
callback.setProgress(-1);
|
callback.setProgress(-1);
|
||||||
Platform.runLater(() -> statusBar.setProgress(-1));
|
Platform.runLater(() -> statusBar.setProgress(-1));
|
||||||
|
|
||||||
callback.updateMessage("Loading numass storage tree...");
|
callback.setStatus("Loading numass storage tree...");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new NumassLoaderTreeBuilder().build(callback, numassLoaderDataTree, root, (NumassData loader) -> {
|
new NumassLoaderTreeBuilder().build(callback, numassLoaderDataTree, root, (NumassData loader) -> {
|
||||||
@ -179,7 +179,7 @@ public class MainViewerController implements Initializable {
|
|||||||
|
|
||||||
// callback.setProgress(1, 1);
|
// callback.setProgress(1, 1);
|
||||||
Platform.runLater(() -> statusBar.setProgress(0));
|
Platform.runLater(() -> statusBar.setProgress(0));
|
||||||
callback.updateMessage("Numass storage tree loaded.");
|
callback.setStatus("Numass storage tree loaded.");
|
||||||
callback.setProgressToMax();
|
callback.setProgressToMax();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ import hep.dataforge.context.Encapsulated;
|
|||||||
import hep.dataforge.names.AlphanumComparator;
|
import hep.dataforge.names.AlphanumComparator;
|
||||||
import hep.dataforge.names.Name;
|
import hep.dataforge.names.Name;
|
||||||
import hep.dataforge.plots.PlotUtils;
|
import hep.dataforge.plots.PlotUtils;
|
||||||
import hep.dataforge.plots.data.*;
|
import hep.dataforge.plots.data.PlotDataUtils;
|
||||||
|
import hep.dataforge.plots.data.XYPlottable;
|
||||||
import hep.dataforge.plots.fx.PlotContainer;
|
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;
|
||||||
@ -46,7 +47,6 @@ import java.io.IOException;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import java.util.stream.StreamSupport;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FXML Controller class
|
* FXML Controller class
|
||||||
@ -158,7 +158,7 @@ public class MspViewController implements Encapsulated {
|
|||||||
try {
|
try {
|
||||||
loader.open();
|
loader.open();
|
||||||
List<DataPoint> points = new ArrayList<>();
|
List<DataPoint> points = new ArrayList<>();
|
||||||
// callback.updateMessage("Loading mass spectrometer data from " + loader.getName());
|
// callback.updateStatus("Loading mass spectrometer data from " + loader.getName());
|
||||||
|
|
||||||
DataPoint last = null;
|
DataPoint last = null;
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ public class MspViewController implements Encapsulated {
|
|||||||
|
|
||||||
// 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", (TaskCallback callback) -> {
|
||||||
// // 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() + ")");
|
||||||
@ -198,7 +198,7 @@ public class MspViewController implements Encapsulated {
|
|||||||
// try {
|
// try {
|
||||||
// PointLoader mspLoader = (PointLoader) loader;
|
// PointLoader mspLoader = (PointLoader) loader;
|
||||||
// mspLoader.open();
|
// mspLoader.open();
|
||||||
// callback.updateMessage("Loading mass spectrometer data from " + mspLoader.getName());
|
// callback.updateStatus("Loading mass spectrometer data from " + mspLoader.getName());
|
||||||
// DataPoint last = null;
|
// DataPoint last = null;
|
||||||
// for (DataPoint dp : mspLoader) {
|
// for (DataPoint dp : mspLoader) {
|
||||||
// mspData.add(dp);
|
// mspData.add(dp);
|
||||||
@ -211,7 +211,7 @@ public class MspViewController implements Encapsulated {
|
|||||||
// 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.updateStatus("Loading msp data finished");
|
||||||
//// return mspData;
|
//// return mspData;
|
||||||
//// List<DataPoint> mspData = (List<DataPoint>) loadProcess.getTask().get();
|
//// List<DataPoint> mspData = (List<DataPoint>) loadProcess.getTask().get();
|
||||||
//
|
//
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
package inr.numass.viewer;
|
package inr.numass.viewer;
|
||||||
|
|
||||||
import hep.dataforge.exceptions.StorageException;
|
import hep.dataforge.exceptions.StorageException;
|
||||||
import hep.dataforge.goals.ProgressCallback;
|
import hep.dataforge.goals.Work;
|
||||||
import inr.numass.storage.NumassData;
|
import inr.numass.storage.NumassData;
|
||||||
import inr.numass.storage.NumassStorage;
|
import inr.numass.storage.NumassStorage;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
@ -39,7 +39,7 @@ import java.util.function.Consumer;
|
|||||||
*/
|
*/
|
||||||
public class NumassLoaderTreeBuilder {
|
public class NumassLoaderTreeBuilder {
|
||||||
|
|
||||||
public void build(ProgressCallback callback,
|
public void build(Work callback,
|
||||||
TreeTableView<TreeItemValue> numassLoaderDataTree,
|
TreeTableView<TreeItemValue> numassLoaderDataTree,
|
||||||
NumassStorage rootStorage,
|
NumassStorage rootStorage,
|
||||||
Consumer<NumassData> numassViewBuilder) throws StorageException {
|
Consumer<NumassData> numassViewBuilder) throws StorageException {
|
||||||
@ -82,7 +82,7 @@ public class NumassLoaderTreeBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TreeItem<TreeItemValue> buildNode(NumassStorage storage,
|
private TreeItem<TreeItemValue> buildNode(NumassStorage storage,
|
||||||
Consumer<NumassData> numassViewBuilder, ProgressCallback callback) throws StorageException {
|
Consumer<NumassData> numassViewBuilder, Work callback) throws StorageException {
|
||||||
TreeItem<TreeItemValue> node = new TreeItem<>(buildValue(storage));
|
TreeItem<TreeItemValue> node = new TreeItem<>(buildValue(storage));
|
||||||
node.getChildren().setAll(buildChildren(storage, numassViewBuilder, callback));
|
node.getChildren().setAll(buildChildren(storage, numassViewBuilder, callback));
|
||||||
return node;
|
return node;
|
||||||
@ -93,7 +93,7 @@ public class NumassLoaderTreeBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<TreeItem<TreeItemValue>> buildChildren(NumassStorage storage,
|
private List<TreeItem<TreeItemValue>> buildChildren(NumassStorage storage,
|
||||||
Consumer<NumassData> numassViewBuilder, ProgressCallback callback) throws StorageException {
|
Consumer<NumassData> numassViewBuilder, Work callback) throws StorageException {
|
||||||
List<TreeItem<TreeItemValue>> list = new ArrayList<>();
|
List<TreeItem<TreeItemValue>> list = new ArrayList<>();
|
||||||
|
|
||||||
storage.shelves().values().stream().forEach(subStorage -> {
|
storage.shelves().values().stream().forEach(subStorage -> {
|
||||||
@ -110,13 +110,13 @@ public class NumassLoaderTreeBuilder {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
callback.updateMessage("Building storage " + storage.getName());
|
callback.setStatus("Building storage " + storage.getName());
|
||||||
callback.setProgress(0);
|
callback.setProgress(0);
|
||||||
callback.setMaxProgress(storage.loaders().size());
|
callback.setMaxProgress(storage.loaders().size());
|
||||||
storage.loaders().values().stream()
|
storage.loaders().values().stream()
|
||||||
.forEach(loader -> {
|
.forEach(loader -> {
|
||||||
if (loader instanceof NumassData) {
|
if (loader instanceof NumassData) {
|
||||||
callback.updateMessage("Building numass data loader " + loader.getName());
|
callback.setStatus("Building numass data loader " + loader.getName());
|
||||||
NumassData numassLoader = (NumassData) loader;
|
NumassData numassLoader = (NumassData) loader;
|
||||||
TreeItem<TreeItemValue> numassLoaderTreeItem = new TreeItem<>(buildValue(numassLoader));
|
TreeItem<TreeItemValue> numassLoaderTreeItem = new TreeItem<>(buildValue(numassLoader));
|
||||||
list.add(numassLoaderTreeItem);
|
list.add(numassLoaderTreeItem);
|
||||||
@ -124,13 +124,13 @@ public class NumassLoaderTreeBuilder {
|
|||||||
callback.increaseProgress(1);
|
callback.increaseProgress(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
callback.updateMessage("Loading legacy DAT files");
|
callback.setStatus("Loading legacy DAT files");
|
||||||
callback.setProgress(0);
|
callback.setProgress(0);
|
||||||
List<NumassData> legacyFiles = storage.legacyFiles();
|
List<NumassData> legacyFiles = storage.legacyFiles();
|
||||||
callback.setMaxProgress(legacyFiles.size());
|
callback.setMaxProgress(legacyFiles.size());
|
||||||
//adding legacy data files
|
//adding legacy data files
|
||||||
for (NumassData legacyDat : legacyFiles) {
|
for (NumassData legacyDat : legacyFiles) {
|
||||||
callback.updateMessage("Loading numass DAT file " + legacyDat.getName());
|
callback.setStatus("Loading numass DAT file " + legacyDat.getName());
|
||||||
TreeItem<TreeItemValue> numassLoaderTreeItem = new TreeItem<>(buildValue(legacyDat));
|
TreeItem<TreeItemValue> numassLoaderTreeItem = new TreeItem<>(buildValue(legacyDat));
|
||||||
callback.increaseProgress(1);
|
callback.increaseProgress(1);
|
||||||
list.add(numassLoaderTreeItem);
|
list.add(numassLoaderTreeItem);
|
||||||
|
@ -22,7 +22,7 @@ package inr.numass.viewer;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
||||||
import hep.dataforge.goals.ProgressCallback;
|
import hep.dataforge.goals.Work;
|
||||||
import hep.dataforge.io.ColumnedDataWriter;
|
import hep.dataforge.io.ColumnedDataWriter;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.meta.MetaBuilder;
|
import hep.dataforge.meta.MetaBuilder;
|
||||||
@ -217,8 +217,8 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
|
|||||||
public void loadData(NumassData data) {
|
public void loadData(NumassData data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
context.taskManager().<List<NMPoint>>submit("viewer.numass.load", (ProgressCallback callback) -> {
|
context.getWorkManager().<List<NMPoint>>startWork("viewer.numass.load", (Work callback) -> {
|
||||||
callback.updateTitle("Load numass data (" + data.getName() + ")");
|
callback.setTitle("Load numass data (" + data.getName() + ")");
|
||||||
points = data.getNMPoints();
|
points = data.getNMPoints();
|
||||||
|
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
@ -242,7 +242,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupHVPane(Supplier<Table> hvData) {
|
private void setupHVPane(Supplier<Table> hvData) {
|
||||||
context.taskManager().submit("viewer.numass.hv", (ProgressCallback callback) -> {
|
context.getWorkManager().startWork("viewer.numass.hv", (Work callback) -> {
|
||||||
Table t = hvData.get();
|
Table t = hvData.get();
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
@ -346,7 +346,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
|
|||||||
detectorPlot.removePlot();
|
detectorPlot.removePlot();
|
||||||
}
|
}
|
||||||
|
|
||||||
context.taskManager().submit("viewer.numass.load.detector", (ProgressCallback callback) -> {
|
context.getWorkManager().startWork("viewer.numass.load.detector", (Work callback) -> {
|
||||||
Meta plottableConfig = new MetaBuilder("plot")
|
Meta plottableConfig = new MetaBuilder("plot")
|
||||||
.setValue("connectionType", "step")
|
.setValue("connectionType", "step")
|
||||||
.setValue("thickness", 2)
|
.setValue("thickness", 2)
|
||||||
|
Loading…
Reference in New Issue
Block a user