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