[no commit message]

This commit is contained in:
Alexander Nozik 2016-06-02 18:41:34 +03:00
parent 94dba3b02e
commit 695c0ee75b
15 changed files with 1261 additions and 144 deletions

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
<system systemId="http://javafx.com/javafx/8.0.65" uri="www.oracle.com/technetwork/java/javase/overview/index.html"/>
</catalog>

File diff suppressed because one or more lines are too long

View File

@ -43,6 +43,10 @@ import org.slf4j.LoggerFactory;
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

@ -58,7 +58,6 @@ public class NumassContext extends Context {
loadPlugin("hep.dataforge:actions"); loadPlugin("hep.dataforge:actions");
loadPlugin("inr.numass:numass"); loadPlugin("inr.numass:numass");
setIO(new NumassIO()); setIO(new NumassIO());
SetDirectionUtility.load(this);
} }
public static void printDescription(Context context, boolean allowANSI) throws DescriptorException { public static void printDescription(Context context, boolean allowANSI) throws DescriptorException {
@ -79,11 +78,4 @@ public class NumassContext extends Context {
writer.println("***End of actions list***"); writer.println("***End of actions list***");
writer.flush(); writer.flush();
} }
@Override
public void close() throws Exception {
SetDirectionUtility.save(this);
super.close();
}
} }

View File

@ -109,7 +109,7 @@ public class NumassPlugin extends BasicPlugin {
sp.setCaching(false); sp.setCaching(false);
NBkgSpectrum spectrum = new NBkgSpectrum(sp); NBkgSpectrum spectrum = new NBkgSpectrum(sp);
return new XYModel("tritium", spectrum, getAdapter(an)); return new XYModel(spectrum, getAdapter(an));
}); });
manager.addModel("scatter", (context, an) -> { manager.addModel("scatter", (context, an) -> {
@ -127,7 +127,7 @@ public class NumassPlugin extends BasicPlugin {
NBkgSpectrum spectrum = new NBkgSpectrum(sp); NBkgSpectrum spectrum = new NBkgSpectrum(sp);
sp.setCaching(false); sp.setCaching(false);
return new XYModel("scatter", spectrum, getAdapter(an)); return new XYModel(spectrum, getAdapter(an));
}); });
manager.addModel("scatter-empiric", (context, an) -> { manager.addModel("scatter-empiric", (context, an) -> {
@ -140,7 +140,7 @@ public class NumassPlugin extends BasicPlugin {
double weightReductionFactor = an.getDouble("weightReductionFactor", 2.0); double weightReductionFactor = an.getDouble("weightReductionFactor", 2.0);
return new WeightedXYModel("scatter-empiric", spectrum, getAdapter(an), (dp) -> weightReductionFactor); return new WeightedXYModel(spectrum, getAdapter(an), (dp) -> weightReductionFactor);
}); });
manager.addModel("scatter-empiric-variable", (context, an) -> { manager.addModel("scatter-empiric-variable", (context, an) -> {
@ -162,7 +162,7 @@ public class NumassPlugin extends BasicPlugin {
double weightReductionFactor = an.getDouble("weightReductionFactor", 2.0); double weightReductionFactor = an.getDouble("weightReductionFactor", 2.0);
WeightedXYModel res = new WeightedXYModel("scatter-variable", spectrum, getAdapter(an), (dp) -> weightReductionFactor); WeightedXYModel res = new WeightedXYModel(spectrum, getAdapter(an), (dp) -> weightReductionFactor);
res.setMeta(an); res.setMeta(an);
return res; return res;
}); });
@ -181,7 +181,7 @@ public class NumassPlugin extends BasicPlugin {
spectrum = CustomNBkgSpectrum.tritiumBkgSpectrum(loss, tritiumBackground); spectrum = CustomNBkgSpectrum.tritiumBkgSpectrum(loss, tritiumBackground);
} }
return new XYModel("scatter-variable", spectrum, getAdapter(an)); return new XYModel(spectrum, getAdapter(an));
}); });
manager.addModel("scatter-empiric-experimental", (context, an) -> { manager.addModel("scatter-empiric-experimental", (context, an) -> {
@ -199,7 +199,7 @@ public class NumassPlugin extends BasicPlugin {
double weightReductionFactor = an.getDouble("weightReductionFactor", 2.0); double weightReductionFactor = an.getDouble("weightReductionFactor", 2.0);
WeightedXYModel res WeightedXYModel res
= new WeightedXYModel("scatter-empiric-experimental", spectrum, getAdapter(an), (dp) -> weightReductionFactor); = new WeightedXYModel(spectrum, getAdapter(an), (dp) -> weightReductionFactor);
res.setMeta(an); res.setMeta(an);
return res; return res;
}); });
@ -208,18 +208,21 @@ public class NumassPlugin extends BasicPlugin {
double A = an.getDouble("resolution", 8.3e-5);//8.3e-5 double A = an.getDouble("resolution", 8.3e-5);//8.3e-5
double from = an.getDouble("from", 13900d); double from = an.getDouble("from", 13900d);
double to = an.getDouble("to", 18700d); double to = an.getDouble("to", 18700d);
context.getReport().report("Setting up tritium model with real transmission function");
BivariateFunction resolutionTail = ResolutionFunction.getRealTail(); BivariateFunction resolutionTail = ResolutionFunction.getRealTail();
RangedNamedSetSpectrum beta = new BetaSpectrum(context.io().getFile("FS.txt")); RangedNamedSetSpectrum beta = new BetaSpectrum(context.io().getFile("FS.txt"));
ModularSpectrum sp = new ModularSpectrum(beta, new ResolutionFunction(A, resolutionTail), from, to); ModularSpectrum sp = new ModularSpectrum(beta, new ResolutionFunction(A, resolutionTail), from, to);
if (!an.getBoolean("caching", false)) { if (!an.getBoolean("caching", false)) {
context.getReport().report("Caching turned off");
sp.setCaching(false); sp.setCaching(false);
} }
//Adding trapping energy dependence //Adding trapping energy dependence
//Intercept = 4.95745, B1 = -0.36879, B2 = 0.00827 //Intercept = 4.95745, B1 = -0.36879, B2 = 0.00827
sp.setTrappingFunction((Ei,Ef)->LossCalculator.getTrapFunction().value(Ei, Ef)*(4.95745-0.36879*Ei+0.00827*Ei*Ei)); sp.setTrappingFunction((Ei,Ef)->LossCalculator.getTrapFunction().value(Ei, Ef)*(4.95745-0.36879*Ei+0.00827*Ei*Ei));
context.getReport().report("Using folowing trapping energy dependecy^ {}", "4.95745-0.36879*Ei+0.00827*Ei*Ei");
NBkgSpectrum spectrum = new NBkgSpectrum(sp); NBkgSpectrum spectrum = new NBkgSpectrum(sp);
return new XYModel("tritium", spectrum, getAdapter(an)); return new XYModel(spectrum, getAdapter(an));
}); });
manager.addModel("modularbeta-unadeabatic", (context, an) -> { manager.addModel("modularbeta-unadeabatic", (context, an) -> {
@ -240,7 +243,7 @@ public class NumassPlugin extends BasicPlugin {
sp.setCaching(false); sp.setCaching(false);
NBkgSpectrum spectrum = new NBkgSpectrum(sp); NBkgSpectrum spectrum = new NBkgSpectrum(sp);
return new XYModel("tritium", spectrum, getAdapter(an)); return new XYModel(spectrum, getAdapter(an));
}); });
manager.addModel("gun", (context, an) -> { manager.addModel("gun", (context, an) -> {
@ -255,7 +258,7 @@ public class NumassPlugin extends BasicPlugin {
spectrum = CustomNBkgSpectrum.tritiumBkgSpectrum(gsp, tritiumBackground); spectrum = CustomNBkgSpectrum.tritiumBkgSpectrum(gsp, tritiumBackground);
} }
return new XYModel("gun", spectrum, getAdapter(an)); return new XYModel(spectrum, getAdapter(an));
}); });
} }

View File

@ -7,6 +7,8 @@ package inr.numass.actions;
import hep.dataforge.actions.GenericAction; import hep.dataforge.actions.GenericAction;
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.context.DFProcess;
import hep.dataforge.context.ProcessManager.Callback;
import hep.dataforge.data.Data; import hep.dataforge.data.Data;
import hep.dataforge.data.DataFilter; import hep.dataforge.data.DataFilter;
import hep.dataforge.data.DataNode; import hep.dataforge.data.DataNode;
@ -14,13 +16,13 @@ import hep.dataforge.data.DataSet;
import hep.dataforge.data.StaticData; import hep.dataforge.data.StaticData;
import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.TypedActionDef;
import hep.dataforge.description.ValueDef; import hep.dataforge.description.ValueDef;
import hep.dataforge.exceptions.StorageException;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.storage.api.Loader; import hep.dataforge.storage.api.Loader;
import hep.dataforge.storage.commons.StorageUtils; import hep.dataforge.storage.commons.StorageUtils;
import inr.numass.storage.NumassData; import inr.numass.storage.NumassData;
import inr.numass.storage.NumassDataLoader; import inr.numass.storage.NumassDataLoader;
import inr.numass.storage.NumassStorage; import inr.numass.storage.NumassStorage;
import inr.numass.storage.SetDirectionUtility;
/** /**
* *
@ -38,45 +40,51 @@ public class ReadNumassStorageAction extends GenericAction<Void, NumassData> {
NumassStorage storage = NumassStorage.buildNumassRoot(actionMeta.getString("uri"), true, false); NumassStorage storage = NumassStorage.buildNumassRoot(actionMeta.getString("uri"), true, false);
DataFilter filter = new DataFilter().configure(actionMeta); DataFilter filter = new DataFilter().configure(actionMeta);
DataSet.Builder<NumassData> builder = DataSet.builder(NumassData.class);
boolean forwardOnly = actionMeta.getBoolean("forwardOnly", false); boolean forwardOnly = actionMeta.getBoolean("forwardOnly", false);
boolean reverseOnly = actionMeta.getBoolean("reverseOnly", false); boolean reverseOnly = actionMeta.getBoolean("reverseOnly", false);
StorageUtils.loaderStream(storage).forEach(pair -> { DFProcess<DataSet<NumassData>> process = context.processManager().<DataSet<NumassData>>post(getName(), (Callback callback) -> {
Loader loader = pair.getValue(); //FIXME remove in later revisions
if (loader instanceof NumassData) { SetDirectionUtility.load(context);
NumassDataLoader nd = (NumassDataLoader) loader;
boolean reversed = nd.isReversed(); DataSet.Builder<NumassData> builder = DataSet.builder(NumassData.class);
if ((reverseOnly && reversed) || (forwardOnly && !reversed) || (!forwardOnly && !reverseOnly)) { callback.setMaxProgress(StorageUtils.loaderStream(storage).count());
StorageUtils.loaderStream(storage).forEach(pair -> {
Loader loader = pair.getValue();
if (loader instanceof NumassData) {
NumassDataLoader nd = (NumassDataLoader) loader;
Data<NumassData> datum = new StaticData<>(nd); Data<NumassData> datum = new StaticData<>(nd);
if (filter.acceptData(pair.getKey(), datum)) { if (filter.acceptData(pair.getKey(), datum)) {
builder.putData(pair.getKey(), datum); boolean accept = true;
if (forwardOnly || reverseOnly) {
boolean reversed = nd.isReversed();
accept = (reverseOnly && reversed) || (forwardOnly && !reversed);
}
if (accept) {
builder.putData(pair.getKey(), datum);
}
} }
} }
} callback.increaseProgress(1d);
}); });
// DataSet.Builder<NumassData> builder = DataSet.builder(NumassData.class);
//
// StorageUtils.loaderStream(storage).forEach(pair -> {
// Loader loader = pair.getValue();
// if (loader instanceof NumassData) {
// Data<NumassData> datum = new StaticData<>((NumassData) loader);
// if (filter.acceptData(pair.getKey(), datum)) {
// builder.putData(pair.getKey(), datum);
// }
// }
// });
storage.legacyFiles().forEach(nd -> { if (actionMeta.getBoolean("loadLegacy", false)) {
Data<NumassData> datum = new StaticData<>(nd); logger().info("Loading legacy files");
if (filter.acceptData(nd.getName(), datum)) { storage.legacyFiles().forEach(nd -> {
builder.putData("legacy." + nd.getName(), datum); Data<NumassData> datum = new StaticData<>(nd);
if (filter.acceptData(nd.getName(), datum)) {
builder.putData("legacy." + nd.getName(), datum);
}
});
} }
//FIXME remove in later revisions
SetDirectionUtility.save(context);
return builder.build();
}); });
return builder.build(); return process.getTask().get();
} catch (StorageException ex) { } catch (Exception ex) {
throw new RuntimeException("Failed to load storage", ex); throw new RuntimeException("Failed to load storage", ex);
} }
} }

View File

@ -80,7 +80,7 @@ public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
new MetaBuilder("plot") new MetaBuilder("plot")
.setValue("plotTitle", "Differential scattering crossection for " + name) .setValue("plotTitle", "Differential scattering crossection for " + name)
); );
switch (input.getModel().getName()) { switch (input.getModel().meta().getString("name","")) {
case "scatter-variable": case "scatter-variable":
scatterFunction = LossCalculator.getSingleScatterFunction(pars); scatterFunction = LossCalculator.getSingleScatterFunction(pars);
calculateRatio = true; calculateRatio = true;

View File

@ -215,12 +215,15 @@ public class ModularSpectrum extends AbstractParametricFunction {
} }
} }
/**
* Suppress warnings about cache recalculation
* @param suppress
*/
public void setSuppressWarnings(boolean suppress) { public void setSuppressWarnings(boolean suppress) {
this.trappingCache.setSuppressWarnings(suppress); this.trappingCache.setSuppressWarnings(suppress);
for (NamedSpectrumCaching sp : this.cacheList) { this.cacheList.stream().forEach((sp) -> {
sp.setSuppressWarnings(suppress); sp.setSuppressWarnings(suppress);
});
}
} }
@Override @Override

View File

@ -23,7 +23,6 @@ import hep.dataforge.maths.MathUtils;
import hep.dataforge.maths.NamedVector; import hep.dataforge.maths.NamedVector;
import hep.dataforge.names.AbstractNamedSet; import hep.dataforge.names.AbstractNamedSet;
import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.NamedValueSet;
import hep.dataforge.values.ValueProvider;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -108,13 +107,7 @@ public class NamedSpectrumCaching extends AbstractParametricFunction {
return source.providesDeriv(name); return source.providesDeriv(name);
} }
protected boolean sameSet(ValueProvider set1, ValueProvider set2) { protected boolean sameSet(NamedValueSet set1, NamedValueSet set2) {
// if((set1 instanceof NamedDoubleSet)&&(set2 instanceof NamedDoubleSet)){
// double[] v1 = ((NamedDoubleSet)set1).getAllValues();
// double[] v2 = ((NamedDoubleSet)set2).getAllValues();
// return Arrays.equals(v1, v2);
// }
for (String name : this.names()) { for (String name : this.names()) {
if (!Objects.equals(set1.getDouble(name), set2.getDouble(name))) { if (!Objects.equals(set1.getDouble(name), set2.getDouble(name))) {
return false; return false;

View File

@ -17,10 +17,10 @@ import hep.dataforge.description.ActionDescriptor;
import hep.dataforge.description.DescriptorUtils; import hep.dataforge.description.DescriptorUtils;
import hep.dataforge.exceptions.NameNotFoundException; import hep.dataforge.exceptions.NameNotFoundException;
import hep.dataforge.fx.ConsoleFragment; import hep.dataforge.fx.ConsoleFragment;
import hep.dataforge.fx.FXProcessManager; import hep.dataforge.fx.FXDataOutputPane;
import hep.dataforge.fx.LogOutputPane; import hep.dataforge.fx.FXReportListener;
import hep.dataforge.fx.configuration.MetaEditor; import hep.dataforge.fx.configuration.MetaEditor;
import hep.dataforge.fx.ProcessManagerFragment; import hep.dataforge.fx.process.ProcessManagerFragment;
import hep.dataforge.io.IOManager; import hep.dataforge.io.IOManager;
import hep.dataforge.io.MetaFileReader; import hep.dataforge.io.MetaFileReader;
import hep.dataforge.meta.ConfigChangeListener; import hep.dataforge.meta.ConfigChangeListener;
@ -78,27 +78,24 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
Map<String, StagePane> stages = new ConcurrentHashMap<>(); Map<String, StagePane> stages = new ConcurrentHashMap<>();
ProcessManagerFragment processWindow = new ProcessManagerFragment(new FXProcessManager()); ProcessManagerFragment processWindow;
ConsoleFragment consoleWindow = new ConsoleFragment();
FXDataOutputPane logPane;
@FXML @FXML
private StatusBar statusBar; private StatusBar statusBar;
@FXML @FXML
private TabPane stagesPane; private TabPane stagesPane;
@FXML @FXML
private TitledPane contextPane;
@FXML
private TitledPane dataPane;
@FXML
private Accordion metaContainer; private Accordion metaContainer;
@FXML @FXML
private Tab logTab; private Tab logTab;
LogOutputPane logPane;
@FXML @FXML
private Button runButton; private Button runButton;
@FXML @FXML
private ToggleButton consoleButton; private ToggleButton consoleButton;
@FXML
private ToggleButton processButton;
@Override @Override
public void clearStage(String stageName) { public void clearStage(String stageName) {
@ -116,11 +113,17 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
*/ */
@Override @Override
public void initialize(URL url, ResourceBundle rb) { public void initialize(URL url, ResourceBundle rb) {
logPane = new LogOutputPane(); logPane = new FXDataOutputPane();
logTab.setContent(logPane); logTab.setContent(logPane.getRoot());
ConsoleFragment consoleWindow = new ConsoleFragment();
consoleWindow.bindTo(consoleButton); consoleWindow.bindTo(consoleButton);
consoleWindow.addRootLogHandler(); consoleWindow.addRootLogHandler();
consoleWindow.hookStd(); consoleWindow.hookStd();
processWindow = new ProcessManagerFragment();
processWindow.bindTo(processButton);
} }
public Context getContext() { public Context getContext() {
@ -131,7 +134,13 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
} }
} }
/**
* Setup context for current run
*
* @param config
*/
private void buildContext(Meta config) { private void buildContext(Meta config) {
// close existing context
if (this.context != null) { if (this.context != null) {
try { try {
this.context.close(); this.context.close();
@ -139,16 +148,19 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
context.getLogger().error("Failed to close context", ex); context.getLogger().error("Failed to close context", ex);
} }
} }
// building context using provided factory
this.context = this.contextFactory.build(parentContext, config); this.context = this.contextFactory.build(parentContext, config);
context.setIO(new WorkbenchIOManager(new NumassIO(), this));
processWindow = ProcessManagerFragment.attachToContext(context);
processWindow.setOwner(this.logPane.getScene().getWindow());
buildContextPane();
this.logPane.listenTo(context);
// this.logPane.listenTo(context);
// this.logPane.listenTo(GlobalContext.instance().getLogger());
((PlotsPlugin) context.provide("plots")).setPlotHolderDelegate(this); // attachig visual process manager
processWindow.setManager(context.processManager());
// setting io manager
context.setIO(new WorkbenchIOManager(new NumassIO(), this));
buildContextPane();
context.getReport().addReportListener(new FXReportListener(logPane));
// display plots iside workbench
PlotsPlugin.buildFrom(context).setPlotHolderDelegate(this);
} }
private Tab findTabWithName(TabPane pane, String name) { private Tab findTabWithName(TabPane pane, String name) {
@ -205,7 +217,8 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
MetaEditor contextEditor = MetaEditor.build(contextValues, null); MetaEditor contextEditor = MetaEditor.build(contextValues, null);
contextEditor.geTable().setShowRoot(false); contextEditor.geTable().setShowRoot(false);
contextPane.setContent(contextEditor); TitledPane contextPane = new TitledPane("Context", contextEditor);
metaContainer.getPanes().add(contextPane);
} }
public void loadConfig(Meta config) { public void loadConfig(Meta config) {
@ -224,15 +237,13 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
.putValue("path", fileName)); .putValue("path", fileName));
}); });
} }
} else { dataEditor = MetaEditor.build(dataConfig,
dataConfig = new Configuration("data"); DescriptorUtils.buildDescriptor(
DescriptorUtils.findAnnotatedElement("class::hep.dataforge.data.FileDataFactory")
));
dataEditor.geTable().setShowRoot(false);
metaContainer.getPanes().add(new TitledPane("Data", dataEditor));
} }
dataEditor = MetaEditor.build(dataConfig,
DescriptorUtils.buildDescriptor(
DescriptorUtils.findAnnotatedElement("class::hep.dataforge.data.FileDataFactory")
));
dataEditor.geTable().setShowRoot(false);
dataPane.setContent(dataEditor);
//loading actions configuration //loading actions configuration
actionsConfig = new Configuration("actionlist"); actionsConfig = new Configuration("actionlist");
@ -270,8 +281,10 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
*/ */
private synchronized void cleanUp() { private synchronized void cleanUp() {
//clear previus action panes //clear previus action panes
processWindow.getManager().cleanup(); if (processWindow.getManager() != null) {
metaContainer.getPanes().removeIf((ap) -> ap.getText().startsWith("action")); processWindow.getManager().cleanup();
}
metaContainer.getPanes().clear();
clearAllStages(); clearAllStages();
actionsConfig = null; actionsConfig = null;
dataConfig = null; dataConfig = null;
@ -315,17 +328,17 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
} }
public Meta getDataConfiguration() { public Meta getDataConfiguration() {
return new MetaBuilder(dataConfig).setContext(getContext()).build(); return dataConfig == null ? Meta.empty() : new MetaBuilder(dataConfig).substituteValues(getContext()).build();
} }
public Meta getActionConfiguration() { public Meta getActionConfiguration() {
return new MetaBuilder(actionsConfig).setContext(getContext()).build(); return actionsConfig == null ? Meta.empty() : new MetaBuilder(actionsConfig).substituteValues(getContext()).build();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void runActions() { public void runActions() {
clearAllStages(); clearAllStages();
processWindow.show(); // processWindow.show();
new Thread(() -> { new Thread(() -> {
DataNode data = new FileDataFactory().build(getContext(), getDataConfiguration()); DataNode data = new FileDataFactory().build(getContext(), getDataConfiguration());
Platform.runLater(() -> statusBar.setProgress(-1)); Platform.runLater(() -> statusBar.setProgress(-1));
@ -335,7 +348,7 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
} catch (Exception ex) { } catch (Exception ex) {
GlobalContext.instance().getLogger().error("Exception while executing action chain", ex); GlobalContext.instance().getLogger().error("Exception while executing action chain", ex);
Platform.runLater(() -> { Platform.runLater(() -> {
ex.printStackTrace(); // ex.printStackTrace();
statusBar.setText("Execution failed"); statusBar.setText("Execution failed");
Alert alert = new Alert(Alert.AlertType.ERROR); Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Exception!"); alert.setTitle("Exception!");

View File

@ -5,6 +5,7 @@
*/ */
package inr.numass.workbench; package inr.numass.workbench;
import hep.dataforge.fx.FXUtils;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.names.Named; import hep.dataforge.names.Named;
import hep.dataforge.plots.PlotFrame; import hep.dataforge.plots.PlotFrame;
@ -37,28 +38,36 @@ public class StagePane extends TabPane implements Named {
} }
public synchronized void closeTab(String name) { public synchronized void closeTab(String name) {
tabs.get(name).close(); FXUtils.runNow(() -> {
Platform.runLater(() -> getTabs().remove(tabs.get(name))); tabs.get(name).close();
tabs.remove(name); getTabs().remove(tabs.get(name));
tabs.remove(name);
});
} }
public synchronized TextOutputTab buildTextOutput(String name) { public synchronized TextOutputTab buildTextOutput(String name) {
if (tabs.containsKey(name)) {
closeTab(name);
}
TextOutputTab out = new TextOutputTab(name); TextOutputTab out = new TextOutputTab(name);
tabs.put(name, out); FXUtils.runNow(() -> {
Platform.runLater(() -> getTabs().add(out)); if (tabs.containsKey(name)) {
tabs.get(name).close();
getTabs().remove(tabs.get(name));
tabs.replace(name, out);
}
getTabs().add(out);
});
return out; return out;
} }
public synchronized PlotFrame buildPlotOutput(String name, Meta meta) { public synchronized PlotFrame buildPlotOutput(String name, Meta meta) {
if (tabs.containsKey(name)) {
closeTab(name);
}
PlotOutputTab out = new PlotOutputTab("plot::" + name, meta); PlotOutputTab out = new PlotOutputTab("plot::" + name, meta);
tabs.put(name, out); FXUtils.runNow(() -> {
Platform.runLater(() -> getTabs().add(out)); if (tabs.containsKey(name)) {
tabs.get(name).close();
getTabs().remove(tabs.get(name));
tabs.replace(name, out);
}
getTabs().add(out);
});
return out.getFrame(); return out.getFrame();
} }

View File

@ -29,7 +29,7 @@ public class TextOutputTab extends OutputTab {
super(name); super(name);
// out = new DataOutputPane(); // out = new DataOutputPane();
out = new FXDataOutputPane(); out = new FXDataOutputPane();
setContent(out.getHolder()); setContent(out.getRoot());
setOnClosed((Event event) -> close()); setOnClosed((Event event) -> close());
} }
@ -44,7 +44,7 @@ public class TextOutputTab extends OutputTab {
} }
public OutputStream getStream() { public OutputStream getStream() {
return out.getOutputStream(); return out.getStream();
} }
} }

View File

@ -3,16 +3,16 @@
<?import javafx.scene.control.Accordion?> <?import javafx.scene.control.Accordion?>
<?import javafx.scene.control.Button?> <?import javafx.scene.control.Button?>
<?import javafx.scene.control.ScrollPane?> <?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.control.SplitPane?> <?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.Tab?> <?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?> <?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TitledPane?>
<?import javafx.scene.control.ToggleButton?> <?import javafx.scene.control.ToggleButton?>
<?import javafx.scene.control.ToolBar?> <?import javafx.scene.control.ToolBar?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?> <?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.Pane?> <?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<?import org.controlsfx.control.StatusBar?> <?import org.controlsfx.control.StatusBar?>
@ -30,35 +30,31 @@
<Tab fx:id="logTab" closable="false" text="Log" /> <Tab fx:id="logTab" closable="false" text="Log" />
</tabs> </tabs>
</TabPane> </TabPane>
<VBox alignment="TOP_CENTER" style="-fx-border-color: blue;"> <ScrollPane fitToHeight="true" fitToWidth="true">
<children> <content>
<ToolBar prefHeight="40.0" prefWidth="200.0"> <Accordion fx:id="metaContainer" prefHeight="65536.0" prefWidth="248.0" />
<items> </content>
<Button mnemonicParsing="false" onAction="#onLoadConfigClick" text="Load" /> </ScrollPane>
<Button fx:id="runButton" disable="true" mnemonicParsing="false" onAction="#onRunButtonClick" text="Run">
<font>
<Font name="System Bold" size="12.0" />
</font>
</Button>
<Pane />
<ToggleButton fx:id="consoleButton" mnemonicParsing="false" text="Console" />
</items>
</ToolBar>
<ScrollPane fitToHeight="true" fitToWidth="true">
<content>
<Accordion fx:id="metaContainer" prefHeight="65536.0" prefWidth="248.0">
<panes>
<TitledPane fx:id="contextPane" animated="false" text="Context" />
<TitledPane fx:id="dataPane" animated="false" text="Data" />
</panes>
</Accordion>
</content>
</ScrollPane>
</children>
</VBox>
</items> </items>
</SplitPane> </SplitPane>
</center> </center>
<top>
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<items>
<ToggleButton fx:id="consoleButton" mnemonicParsing="false" text="Console" />
<ToggleButton fx:id="processButton" mnemonicParsing="false" text="Processes" />
<Separator orientation="VERTICAL" />
<Pane HBox.hgrow = "ALWAYS"/>
<Separator orientation="VERTICAL" />
<Button mnemonicParsing="false" onAction="#onLoadConfigClick" text="Load" />
<Button fx:id="runButton" disable="true" mnemonicParsing="false" onAction="#onRunButtonClick" text="Run">
<font>
<Font name="System Bold" size="12.0" />
</font>
</Button>
</items>
</ToolBar>
</top>
</BorderPane> </BorderPane>
</children> </children>
</AnchorPane> </AnchorPane>

View File

@ -26,7 +26,7 @@ public class SetDirectionUtility {
private static final String FILE_NAME = "numass_set_direction.map"; private static final String FILE_NAME = "numass_set_direction.map";
private static Map<String, Boolean> directionMap = new HashMap<>(); private static final Map<String, Boolean> directionMap = new HashMap<>();
private static boolean isLoaded = false; private static boolean isLoaded = false;
@ -45,11 +45,16 @@ public class SetDirectionUtility {
context.getLogger().info("Loading set direction utility"); context.getLogger().info("Loading set direction utility");
File file = cacheFile(context); File file = cacheFile(context);
if (file.exists()) { if (file.exists()) {
try (ObjectInputStream st = new ObjectInputStream(new FileInputStream(file))) { directionMap.clear();
directionMap = (Map<String, Boolean>) st.readObject(); try (FileInputStream fst = new FileInputStream(file)) {
context.getLogger().info("Set directions successfully loaded from file"); try (ObjectInputStream st = new ObjectInputStream(fst)) {
} catch (ClassNotFoundException | IOException ex) { directionMap.putAll((Map<String, Boolean>) st.readObject());
context.getLogger().error("Failed to load numass direction mapping", ex); context.getLogger().info("Set directions successfully loaded from file");
} catch (ClassNotFoundException | IOException ex) {
context.getLogger().error("Failed to load numass direction mapping", ex);
}
} catch (IOException ex) {
context.getLogger().error("Failed to load numass direction mapping", ex);
} }
} }

View File

@ -20,7 +20,7 @@ import hep.dataforge.context.GlobalContext;
import hep.dataforge.context.ProcessManager; import hep.dataforge.context.ProcessManager;
import hep.dataforge.exceptions.StorageException; import hep.dataforge.exceptions.StorageException;
import hep.dataforge.fx.ConsoleFragment; import hep.dataforge.fx.ConsoleFragment;
import hep.dataforge.fx.ProcessManagerFragment; import hep.dataforge.fx.process.ProcessManagerFragment;
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;