bugfixes
This commit is contained in:
parent
aa9cac6e8a
commit
b15e9e2ad5
@ -244,7 +244,7 @@ public class MspViewController implements Initializable, MspListener {
|
|||||||
)
|
)
|
||||||
.setValue("xAxis.type", "time");
|
.setValue("xAxis.type", "time");
|
||||||
|
|
||||||
this.plot = new JFreeChartFrame(mspName, plotConfig);
|
this.plot = new JFreeChartFrame(plotConfig);
|
||||||
PlotContainer container = PlotContainer.anchorTo(plotPane);
|
PlotContainer container = PlotContainer.anchorTo(plotPane);
|
||||||
container.setPlot(plot);
|
container.setPlot(plot);
|
||||||
updatePlot();
|
updatePlot();
|
||||||
|
@ -433,7 +433,7 @@ public class VACFrame extends javax.swing.JFrame {
|
|||||||
.setValue("axisUnits", "mbar")
|
.setValue("axisUnits", "mbar")
|
||||||
)
|
)
|
||||||
.setValue("xAxis.timeAxis", true);
|
.setValue("xAxis.timeAxis", true);
|
||||||
this.plotFrame = new JFreeChartFrame("pressures", plotConfig).display(chartPannel);
|
this.plotFrame = new JFreeChartFrame(plotConfig).display(chartPannel);
|
||||||
XYPlot xyPlot = plotFrame.getChart().getXYPlot();
|
XYPlot xyPlot = plotFrame.getChart().getXYPlot();
|
||||||
|
|
||||||
LogarithmicAxis logAxis = new LogarithmicAxis("Pressure (mbar)");
|
LogarithmicAxis logAxis = new LogarithmicAxis("Pressure (mbar)");
|
||||||
|
@ -171,7 +171,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
|
|||||||
.setValue("axisUnits", "mbar")
|
.setValue("axisUnits", "mbar")
|
||||||
)
|
)
|
||||||
.setValue("xAxis.type", "time");
|
.setValue("xAxis.type", "time");
|
||||||
JFreeChartFrame frame = new JFreeChartFrame("pressure", plotConfig);
|
JFreeChartFrame frame = new JFreeChartFrame(plotConfig);
|
||||||
frame.addAll(plottables);
|
frame.addAll(plottables);
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package inr.numass.scripts
|
||||||
|
|
||||||
|
import inr.numass.storage.NMFile
|
||||||
|
import inr.numass.storage.NumassData
|
||||||
|
import inr.numass.storage.NumassDataLoader
|
||||||
|
import hep.dataforge.meta.Meta
|
||||||
|
import inr.numass.actions.FindBorderAction
|
||||||
|
import hep.dataforge.grind.GrindMetaBuilder
|
||||||
|
|
||||||
|
File dataDir = new File("D:\\Work\\Numass\\data\\2016_04\\T2_data\\Fill_1_7\\set_2_3b127e3254010000")
|
||||||
|
if(!dataDir.exists()){
|
||||||
|
println "dataDir directory does not exist"
|
||||||
|
}
|
||||||
|
Meta config = new GrindMetaBuilder().config(lower: 500, upper: 1600)
|
||||||
|
println config
|
||||||
|
NumassData data = NumassDataLoader.fromLocalDir(null, dataDir)
|
||||||
|
new FindBorderAction().eval(data, config)
|
@ -27,6 +27,7 @@ import hep.dataforge.datafitter.models.XYModel;
|
|||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.plotfit.PlotFitResultAction;
|
import hep.dataforge.plotfit.PlotFitResultAction;
|
||||||
import hep.dataforge.plots.PlotDataAction;
|
import hep.dataforge.plots.PlotDataAction;
|
||||||
|
import hep.dataforge.storage.commons.StorageManager;
|
||||||
import hep.dataforge.tables.PointAdapter;
|
import hep.dataforge.tables.PointAdapter;
|
||||||
import hep.dataforge.tables.XYAdapter;
|
import hep.dataforge.tables.XYAdapter;
|
||||||
import inr.numass.actions.AdjustErrorsAction;
|
import inr.numass.actions.AdjustErrorsAction;
|
||||||
@ -35,6 +36,7 @@ import inr.numass.actions.MergeDataAction;
|
|||||||
import inr.numass.actions.MonitorCorrectAction;
|
import inr.numass.actions.MonitorCorrectAction;
|
||||||
import inr.numass.actions.PrepareDataAction;
|
import inr.numass.actions.PrepareDataAction;
|
||||||
import inr.numass.actions.ReadNumassDataAction;
|
import inr.numass.actions.ReadNumassDataAction;
|
||||||
|
import inr.numass.actions.ReadNumassStorageAction;
|
||||||
import inr.numass.actions.ShowLossSpectrumAction;
|
import inr.numass.actions.ShowLossSpectrumAction;
|
||||||
import inr.numass.actions.ShowSpectrumAction;
|
import inr.numass.actions.ShowSpectrumAction;
|
||||||
import inr.numass.actions.SlicingAction;
|
import inr.numass.actions.SlicingAction;
|
||||||
@ -65,6 +67,7 @@ public class NumassPlugin extends BasicPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void attach(Context context) {
|
public void attach(Context context) {
|
||||||
|
// StorageManager.buildFrom(context);
|
||||||
FitManager fm = context.provide("fitting", FitPlugin.class).getFitManager();
|
FitManager fm = context.provide("fitting", FitPlugin.class).getFitManager();
|
||||||
ModelManager mm = fm.getModelManager();
|
ModelManager mm = fm.getModelManager();
|
||||||
loadModels(mm);
|
loadModels(mm);
|
||||||
@ -82,6 +85,7 @@ public class NumassPlugin extends BasicPlugin {
|
|||||||
actions.registerAction(PlotFitResultAction.class);
|
actions.registerAction(PlotFitResultAction.class);
|
||||||
actions.registerAction(ShowLossSpectrumAction.class);
|
actions.registerAction(ShowLossSpectrumAction.class);
|
||||||
actions.registerAction(AdjustErrorsAction.class);
|
actions.registerAction(AdjustErrorsAction.class);
|
||||||
|
actions.registerAction(ReadNumassStorageAction.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,6 +20,7 @@ import hep.dataforge.tables.SimplePointSource;
|
|||||||
import hep.dataforge.values.Value;
|
import hep.dataforge.values.Value;
|
||||||
import inr.numass.storage.NMFile;
|
import inr.numass.storage.NMFile;
|
||||||
import inr.numass.storage.NMPoint;
|
import inr.numass.storage.NMPoint;
|
||||||
|
import inr.numass.storage.NumassData;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ public class BorderData extends SimplePointSource {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BorderData(NMFile file, int upper, int lower, NMPoint reference) {
|
public BorderData(NumassData file, int upper, int lower, NMPoint reference) {
|
||||||
super(names);
|
super(names);
|
||||||
if (upper <= lower) {
|
if (upper <= lower) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
@ -51,7 +52,7 @@ public class BorderData extends SimplePointSource {
|
|||||||
fill(file, lower, upper, reference);
|
fill(file, lower, upper, reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fill(NMFile file, int lower, int upper, NMPoint reference) {
|
private void fill(NumassData file, int lower, int upper, NMPoint reference) {
|
||||||
for (NMPoint point : file.getNMPoints()) {
|
for (NMPoint point : file.getNMPoints()) {
|
||||||
if ((reference != null) && (point.getUset() == reference.getUset())) {
|
if ((reference != null) && (point.getUset() == reference.getUset())) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -24,6 +24,7 @@ import hep.dataforge.io.reports.Reportable;
|
|||||||
import hep.dataforge.meta.Laminate;
|
import hep.dataforge.meta.Laminate;
|
||||||
import inr.numass.storage.NMFile;
|
import inr.numass.storage.NMFile;
|
||||||
import inr.numass.storage.NMPoint;
|
import inr.numass.storage.NMPoint;
|
||||||
|
import inr.numass.storage.NumassData;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,13 +32,13 @@ import java.io.OutputStream;
|
|||||||
* @author Darksnake
|
* @author Darksnake
|
||||||
*/
|
*/
|
||||||
@TypedActionDef(name = "findBorder", inputType = NMFile.class, outputType = NMFile.class)
|
@TypedActionDef(name = "findBorder", inputType = NMFile.class, outputType = NMFile.class)
|
||||||
public class FindBorderAction extends OneToOneAction<NMFile, NMFile> {
|
public class FindBorderAction extends OneToOneAction<NumassData, NumassData> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NMFile execute(Context context, Reportable log, String name, Laminate meta, NMFile source) throws ContentException {
|
protected NumassData execute(Context context, Reportable log, String name, Laminate meta, NumassData source) throws ContentException {
|
||||||
log.report("File {} started", source.getName());
|
log.report("File {} started", source.getName());
|
||||||
|
|
||||||
int upperBorder = meta.getInt("upper", 4096);
|
int upperBorder = meta.getInt("upper", 4094);
|
||||||
int lowerBorder = meta.getInt("lower", 0);
|
int lowerBorder = meta.getInt("lower", 0);
|
||||||
double substractReference = meta.getDouble("reference", 0);
|
double substractReference = meta.getDouble("reference", 0);
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import hep.dataforge.tables.ListTable;
|
|||||||
import hep.dataforge.tables.MapPoint;
|
import hep.dataforge.tables.MapPoint;
|
||||||
import hep.dataforge.tables.PointSource;
|
import hep.dataforge.tables.PointSource;
|
||||||
import hep.dataforge.tables.Table;
|
import hep.dataforge.tables.Table;
|
||||||
|
import hep.dataforge.tables.TableFormat;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -144,10 +144,12 @@ public class MonitorCorrectAction extends OneToOneAction<Table, Table> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void printMonitorData(Context context, Meta meta) {
|
private void printMonitorData(Context context, Meta meta) {
|
||||||
String monitorFileName = meta.getString("monitorFile", "monitor");
|
if (!monitorPoints.isEmpty()) {
|
||||||
OutputStream stream = buildActionOutput(context, monitorFileName);
|
String monitorFileName = meta.getString("monitorFile", "monitor");
|
||||||
ListTable data = new ListTable(monitorPoints);
|
OutputStream stream = buildActionOutput(context, monitorFileName);
|
||||||
ColumnedDataWriter.writeDataSet(stream, data.sort("Timestamp", true), "Monitor points", monitorNames);
|
ListTable data = new ListTable(monitorPoints);
|
||||||
|
ColumnedDataWriter.writeDataSet(stream, data.sort("Timestamp", true), "Monitor points", monitorNames);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMonitorPoint(double monitor, DataPoint point) {
|
private boolean isMonitorPoint(double monitor, DataPoint point) {
|
||||||
@ -155,7 +157,7 @@ public class MonitorCorrectAction extends OneToOneAction<Table, Table> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private LocalDateTime getTime(DataPoint point) {
|
private LocalDateTime getTime(DataPoint point) {
|
||||||
return LocalDateTime.ofInstant(point.getValue("Timestamp").timeValue(), ZoneId.of("GMT+3"));
|
return LocalDateTime.ofInstant(point.getValue("Timestamp").timeValue(), ZoneId.systemDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getTotal(DataPoint point) {
|
private int getTotal(DataPoint point) {
|
||||||
|
@ -30,8 +30,8 @@ import hep.dataforge.tables.ListTable;
|
|||||||
import hep.dataforge.tables.MapPoint;
|
import hep.dataforge.tables.MapPoint;
|
||||||
import hep.dataforge.tables.Table;
|
import hep.dataforge.tables.Table;
|
||||||
import hep.dataforge.tables.TableFormat;
|
import hep.dataforge.tables.TableFormat;
|
||||||
import inr.numass.storage.NMFile;
|
|
||||||
import inr.numass.storage.NMPoint;
|
import inr.numass.storage.NMPoint;
|
||||||
|
import inr.numass.storage.NumassData;
|
||||||
import inr.numass.storage.RawNMPoint;
|
import inr.numass.storage.RawNMPoint;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@ -42,12 +42,12 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Darksnake
|
* @author Darksnake
|
||||||
*/
|
*/
|
||||||
@TypedActionDef(name = "prepareData", inputType = NMFile.class, outputType = Table.class)
|
@TypedActionDef(name = "prepareData", inputType = NumassData.class, outputType = Table.class)
|
||||||
@ValueDef(name = "lowerWindow", type = "NUMBER", def = "0", info = "Base for the window lowerWindow bound")
|
@ValueDef(name = "lowerWindow", type = "NUMBER", def = "0", info = "Base for the window lowerWindow bound")
|
||||||
@ValueDef(name = "lowerWindowSlope", type = "NUMBER", def = "0", info = "Slope for the window lowerWindow bound")
|
@ValueDef(name = "lowerWindowSlope", type = "NUMBER", def = "0", info = "Slope for the window lowerWindow bound")
|
||||||
@ValueDef(name = "upperWindow", type = "NUMBER", info = "Upper bound for window")
|
@ValueDef(name = "upperWindow", type = "NUMBER", info = "Upper bound for window")
|
||||||
@ValueDef(name = "deadTime", type = "NUMBER", def = "0", info = "Dead time in us")
|
@ValueDef(name = "deadTime", type = "NUMBER", def = "0", info = "Dead time in us")
|
||||||
public class PrepareDataAction extends OneToOneAction<NMFile, Table> {
|
public class PrepareDataAction extends OneToOneAction<NumassData, Table> {
|
||||||
|
|
||||||
public static String[] parnames = {"Uset", "Uread", "Length", "Total", "Window", "Corrected", "CR", "CRerr", "Timestamp"};
|
public static String[] parnames = {"Uset", "Uread", "Length", "Total", "Window", "Corrected", "CR", "CRerr", "Timestamp"};
|
||||||
|
|
||||||
@ -59,8 +59,8 @@ public class PrepareDataAction extends OneToOneAction<NMFile, Table> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ListTable execute(Context context, Reportable log, String name, Laminate meta, NMFile dataFile) {
|
protected ListTable execute(Context context, Reportable log, String name, Laminate meta, NumassData dataFile) {
|
||||||
// log.logString("File %s started", dataFile.getName());
|
// log.report("File %s started", dataFile.getName());
|
||||||
|
|
||||||
int upper = meta.getInt("upperWindow", RawNMPoint.MAX_CHANEL - 1);
|
int upper = meta.getInt("upperWindow", RawNMPoint.MAX_CHANEL - 1);
|
||||||
|
|
||||||
@ -99,11 +99,9 @@ public class PrepareDataAction extends OneToOneAction<NMFile, Table> {
|
|||||||
format = TableFormat.fixedWidth(8, parnames);
|
format = TableFormat.fixedWidth(8, parnames);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AnnotationBuilder builder = dataFile.meta().getBuilder();
|
|
||||||
String head;
|
String head;
|
||||||
if (dataFile.getHead() != null) {
|
if (dataFile.getInfo() != null) {
|
||||||
head = dataFile.getHead();
|
head = dataFile.getInfo().toString();
|
||||||
// builder.putValue("datafilehead",head);
|
|
||||||
} else {
|
} else {
|
||||||
head = dataFile.getName();
|
head = dataFile.getName();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package inr.numass.actions;
|
||||||
|
|
||||||
|
import hep.dataforge.actions.GenericAction;
|
||||||
|
import hep.dataforge.context.Context;
|
||||||
|
import hep.dataforge.data.Data;
|
||||||
|
import hep.dataforge.data.DataFilter;
|
||||||
|
import hep.dataforge.data.DataNode;
|
||||||
|
import hep.dataforge.data.DataSet;
|
||||||
|
import hep.dataforge.data.StaticData;
|
||||||
|
import hep.dataforge.description.TypedActionDef;
|
||||||
|
import hep.dataforge.description.ValueDef;
|
||||||
|
import hep.dataforge.exceptions.StorageException;
|
||||||
|
import hep.dataforge.meta.Meta;
|
||||||
|
import hep.dataforge.storage.api.Loader;
|
||||||
|
import hep.dataforge.storage.commons.StorageUtils;
|
||||||
|
import inr.numass.storage.NumassData;
|
||||||
|
import inr.numass.storage.NumassStorage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Alexander Nozik
|
||||||
|
*/
|
||||||
|
@TypedActionDef(name = "readStorage",
|
||||||
|
outputType = NumassData.class, info = "Read numass storage data")
|
||||||
|
@ValueDef(name = "uri", info = "The path to Numass storage")
|
||||||
|
//@NodeDef(name = "debunch", target = "class::inr.numass.actions.DebunchAction", info = "If given, governs debunching")
|
||||||
|
public class ReadNumassStorageAction extends GenericAction<Void, NumassData> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataNode<NumassData> run(Context context, DataNode<Void> data, Meta actionMeta) {
|
||||||
|
try {
|
||||||
|
NumassStorage storage = NumassStorage.buildNumassRoot(actionMeta.getString("uri"), true, false);
|
||||||
|
DataFilter filter = new DataFilter().configure(actionMeta);
|
||||||
|
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 -> {
|
||||||
|
Data<NumassData> datum = new StaticData<>(nd);
|
||||||
|
if (filter.acceptData(nd.getName(), datum)) {
|
||||||
|
builder.putData("legacy." + nd.getName(), datum);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return builder.build();
|
||||||
|
} catch (StorageException ex) {
|
||||||
|
throw new RuntimeException("Failed to load storage", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,8 +5,6 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.workbench;
|
package inr.numass.workbench;
|
||||||
|
|
||||||
import ch.qos.logback.classic.Level;
|
|
||||||
import de.jensd.shichimifx.utils.ConsoleDude;
|
|
||||||
import hep.dataforge.actions.Action;
|
import hep.dataforge.actions.Action;
|
||||||
import hep.dataforge.actions.ActionManager;
|
import hep.dataforge.actions.ActionManager;
|
||||||
import hep.dataforge.actions.ActionStateListener;
|
import hep.dataforge.actions.ActionStateListener;
|
||||||
@ -18,6 +16,7 @@ import hep.dataforge.data.FileDataFactory;
|
|||||||
import hep.dataforge.description.ActionDescriptor;
|
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.FXProcessManager;
|
import hep.dataforge.fx.FXProcessManager;
|
||||||
import hep.dataforge.fx.LogOutputPane;
|
import hep.dataforge.fx.LogOutputPane;
|
||||||
import hep.dataforge.fx.MetaEditor;
|
import hep.dataforge.fx.MetaEditor;
|
||||||
@ -51,11 +50,13 @@ import javafx.fxml.FXML;
|
|||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.Accordion;
|
import javafx.scene.control.Accordion;
|
||||||
|
import javafx.scene.control.Alert;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.Tab;
|
import javafx.scene.control.Tab;
|
||||||
import javafx.scene.control.TabPane;
|
import javafx.scene.control.TabPane;
|
||||||
import javafx.scene.control.TextArea;
|
import javafx.scene.control.TextArea;
|
||||||
import javafx.scene.control.TitledPane;
|
import javafx.scene.control.TitledPane;
|
||||||
|
import javafx.scene.control.ToggleButton;
|
||||||
import javafx.stage.FileChooser;
|
import javafx.stage.FileChooser;
|
||||||
import org.controlsfx.control.StatusBar;
|
import org.controlsfx.control.StatusBar;
|
||||||
|
|
||||||
@ -79,6 +80,7 @@ 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 = new ProcessManagerFragment(new FXProcessManager());
|
||||||
|
ConsoleFragment consoleWindow = new ConsoleFragment();
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private StatusBar statusBar;
|
private StatusBar statusBar;
|
||||||
@ -97,7 +99,7 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
|
|||||||
@FXML
|
@FXML
|
||||||
private Button runButton;
|
private Button runButton;
|
||||||
@FXML
|
@FXML
|
||||||
private TextArea consoleArea;
|
private ToggleButton consoleButton;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearStage(String stageName) {
|
public void clearStage(String stageName) {
|
||||||
@ -117,7 +119,9 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
|
|||||||
public void initialize(URL url, ResourceBundle rb) {
|
public void initialize(URL url, ResourceBundle rb) {
|
||||||
logPane = new LogOutputPane();
|
logPane = new LogOutputPane();
|
||||||
logTab.setContent(logPane);
|
logTab.setContent(logPane);
|
||||||
ConsoleDude.hookStdStreams(consoleArea);
|
consoleWindow.bindTo(consoleButton);
|
||||||
|
consoleWindow.addRootLogHandler();
|
||||||
|
consoleWindow.hookStd();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Context getContext() {
|
public Context getContext() {
|
||||||
@ -132,17 +136,15 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
|
|||||||
this.context = this.contextFactory.build(parentContext, config);
|
this.context = this.contextFactory.build(parentContext, config);
|
||||||
context.setIO(new WorkbenchIOManager(new NumassIO(), this));
|
context.setIO(new WorkbenchIOManager(new NumassIO(), this));
|
||||||
processWindow = ProcessManagerFragment.attachToContext(context);
|
processWindow = ProcessManagerFragment.attachToContext(context);
|
||||||
|
processWindow.setOwner(this.logPane.getScene().getWindow());
|
||||||
buildContextPane();
|
buildContextPane();
|
||||||
this.logPane.attachLog(context);
|
this.logPane.listenTo(context);
|
||||||
context.getLogger().addAppender(logPane.getLoggerAppender());
|
// this.logPane.listenTo(context);
|
||||||
context.getLogger().setLevel(Level.ALL);
|
// this.logPane.listenTo(GlobalContext.instance().getLogger());
|
||||||
GlobalContext.instance().getLogger().addAppender(logPane.getLoggerAppender());
|
|
||||||
|
|
||||||
((PlotsPlugin) context.provide("plots")).setPlotHolderDelegate(this);
|
((PlotsPlugin) context.provide("plots")).setPlotHolderDelegate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private Tab findTabWithName(TabPane pane, String name) {
|
private Tab findTabWithName(TabPane pane, String name) {
|
||||||
return pane.getTabs().stream().filter((t) -> t.getText().equals(name)).findFirst().orElse(null);
|
return pane.getTabs().stream().filter((t) -> t.getText().equals(name)).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
@ -254,9 +256,9 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
|
|||||||
|
|
||||||
private void clearAllStages() {
|
private void clearAllStages() {
|
||||||
logPane.clear();
|
logPane.clear();
|
||||||
for (String stageName : stages.keySet()) {
|
stages.keySet().stream().forEach((stageName) -> {
|
||||||
clearStage(stageName);
|
clearStage(stageName);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -264,6 +266,7 @@ 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();
|
||||||
metaContainer.getPanes().removeIf((ap) -> ap.getText().startsWith("action"));
|
metaContainer.getPanes().removeIf((ap) -> ap.getText().startsWith("action"));
|
||||||
clearAllStages();
|
clearAllStages();
|
||||||
actionsConfig = null;
|
actionsConfig = null;
|
||||||
@ -294,7 +297,7 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void onRunButtonClick(ActionEvent event) {
|
private void onRunButtonClick(ActionEvent event) {
|
||||||
if (getContext() != null && !dataConfig.isEmpty() && !actionsConfig.isEmpty()) {
|
if (getContext() != null && !actionsConfig.isEmpty()) {
|
||||||
statusBar.setText("Starting action execution");
|
statusBar.setText("Starting action execution");
|
||||||
runActions();
|
runActions();
|
||||||
}
|
}
|
||||||
@ -314,12 +317,26 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
|
|||||||
processWindow.show();
|
processWindow.show();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
DataNode data = new FileDataFactory().build(getContext(), getDataConfiguration());
|
DataNode data = new FileDataFactory().build(getContext(), getDataConfiguration());
|
||||||
if (data.isEmpty()) {
|
Platform.runLater(() -> statusBar.setProgress(-1));
|
||||||
//FIXME evaluate error here
|
try {
|
||||||
throw new Error("Empty data");
|
ActionUtils.runAction(getContext(), data, getActionConfiguration()).compute();
|
||||||
|
Platform.runLater(() -> statusBar.setText("Execution complete"));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
GlobalContext.instance().getLogger().error("Exception while executing action chain", ex);
|
||||||
|
Platform.runLater(() -> {
|
||||||
|
// ex.printStackTrace();
|
||||||
|
statusBar.setText("Execution failed");
|
||||||
|
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||||
|
alert.setTitle("Exception!");
|
||||||
|
alert.setHeaderText("Action execution failure");
|
||||||
|
alert.setContentText(ex.getMessage());
|
||||||
|
alert.show();
|
||||||
|
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
Platform.runLater(() -> statusBar.setProgress(0));
|
||||||
}
|
}
|
||||||
ActionUtils.runAction(getContext(), data, getActionConfiguration()).compute();
|
|
||||||
Platform.runLater(() -> statusBar.setText("Execution complete"));
|
|
||||||
}, "actions").start();
|
}, "actions").start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ public class PlotOutputTab extends OutputTab {
|
|||||||
public PlotOutputTab(String name, Meta meta) {
|
public PlotOutputTab(String name, Meta meta) {
|
||||||
super(name);
|
super(name);
|
||||||
PlotContainer container = new PlotContainer();
|
PlotContainer container = new PlotContainer();
|
||||||
frame = new JFreeChartFrame(name, meta);
|
frame = new JFreeChartFrame(meta);
|
||||||
container.setPlot(frame);
|
container.setPlot(frame);
|
||||||
// AnchorPane pane = new AnchorPane();
|
// AnchorPane pane = new AnchorPane();
|
||||||
// frame = new JFreeChartFrame(name, meta).display(pane);
|
// frame = new JFreeChartFrame(name, meta).display(pane);
|
||||||
@ -26,7 +26,7 @@ public class PlotOutputTab extends OutputTab {
|
|||||||
public PlotOutputTab(String name, String title, Meta meta) {
|
public PlotOutputTab(String name, String title, Meta meta) {
|
||||||
super(name, title);
|
super(name, title);
|
||||||
PlotContainer container = new PlotContainer();
|
PlotContainer container = new PlotContainer();
|
||||||
frame = new JFreeChartFrame(name, meta);
|
frame = new JFreeChartFrame(meta);
|
||||||
container.setPlot(frame);
|
container.setPlot(frame);
|
||||||
setContent(container);
|
setContent(container);
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,22 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.geometry.*?>
|
<?import javafx.scene.control.Accordion?>
|
||||||
<?import javafx.scene.text.*?>
|
<?import javafx.scene.control.Button?>
|
||||||
<?import org.controlsfx.control.*?>
|
<?import javafx.scene.control.ScrollPane?>
|
||||||
<?import java.lang.*?>
|
<?import javafx.scene.control.SplitPane?>
|
||||||
<?import java.net.*?>
|
<?import javafx.scene.control.Tab?>
|
||||||
<?import java.util.*?>
|
<?import javafx.scene.control.TabPane?>
|
||||||
<?import javafx.scene.*?>
|
<?import javafx.scene.control.TitledPane?>
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.ToggleButton?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.control.ToolBar?>
|
||||||
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
<?import javafx.scene.layout.BorderPane?>
|
||||||
|
<?import javafx.scene.layout.Pane?>
|
||||||
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
<?import javafx.scene.text.Font?>
|
||||||
|
<?import org.controlsfx.control.StatusBar?>
|
||||||
|
|
||||||
<AnchorPane id="AnchorPane" prefHeight="600.0" prefWidth="800.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.40" fx:controller="inr.numass.workbench.NumassWorkbenchController">
|
<AnchorPane id="AnchorPane" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="inr.numass.workbench.NumassWorkbenchController">
|
||||||
<children>
|
<children>
|
||||||
<BorderPane layoutX="-165.0" layoutY="100.0" prefHeight="200.0" prefWidth="765.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<BorderPane layoutX="-165.0" layoutY="100.0" prefHeight="200.0" prefWidth="765.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<bottom>
|
<bottom>
|
||||||
@ -21,12 +27,7 @@
|
|||||||
<items>
|
<items>
|
||||||
<TabPane fx:id="stagesPane" prefHeight="200.0" prefWidth="200.0" side="LEFT" tabClosingPolicy="UNAVAILABLE">
|
<TabPane fx:id="stagesPane" prefHeight="200.0" prefWidth="200.0" side="LEFT" tabClosingPolicy="UNAVAILABLE">
|
||||||
<tabs>
|
<tabs>
|
||||||
<Tab fx:id="LogTab" closable="false" text="Log" />
|
<Tab fx:id="logTab" closable="false" text="Log" />
|
||||||
<Tab text="System">
|
|
||||||
<content>
|
|
||||||
<TextArea fx:id="consoleArea" editable="false" prefHeight="200.0" prefWidth="200.0" wrapText="true" />
|
|
||||||
</content>
|
|
||||||
</Tab>
|
|
||||||
</tabs>
|
</tabs>
|
||||||
</TabPane>
|
</TabPane>
|
||||||
<VBox alignment="TOP_CENTER" style="-fx-border-color: blue;">
|
<VBox alignment="TOP_CENTER" style="-fx-border-color: blue;">
|
||||||
@ -39,6 +40,8 @@
|
|||||||
<Font name="System Bold" size="12.0" />
|
<Font name="System Bold" size="12.0" />
|
||||||
</font>
|
</font>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Pane />
|
||||||
|
<ToggleButton fx:id="consoleButton" mnemonicParsing="false" text="Console" />
|
||||||
</items>
|
</items>
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
<ScrollPane fitToHeight="true" fitToWidth="true">
|
<ScrollPane fitToHeight="true" fitToWidth="true">
|
||||||
|
@ -82,36 +82,6 @@ public class NMFile extends NamedMetaHolder implements NumassData {
|
|||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* merge of all point with given Uset
|
|
||||||
*
|
|
||||||
* @param U
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public NMPoint getByUset(double U) {
|
|
||||||
for (NMPoint point : points) {
|
|
||||||
if (point.getUset() == U) {
|
|
||||||
return point;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* merge of all point with given Uread
|
|
||||||
*
|
|
||||||
* @param U
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public NMPoint getByUread(double U) {
|
|
||||||
for (NMPoint point : points) {
|
|
||||||
if (point.getUread() == U) {
|
|
||||||
return point;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.storage;
|
package inr.numass.storage;
|
||||||
|
|
||||||
import inr.numass.storage.NMPoint;
|
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.names.Named;
|
import hep.dataforge.names.Named;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@ -15,7 +14,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Alexander Nozik <altavir@gmail.com>
|
* @author Alexander Nozik <altavir@gmail.com>
|
||||||
*/
|
*/
|
||||||
public interface NumassData extends Named{
|
public interface NumassData extends Named {
|
||||||
|
|
||||||
String getDescription();
|
String getDescription();
|
||||||
|
|
||||||
@ -27,4 +26,34 @@ public interface NumassData extends Named{
|
|||||||
|
|
||||||
Instant startTime();
|
Instant startTime();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find first point with given Uset
|
||||||
|
*
|
||||||
|
* @param U
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
default NMPoint getByUset(double U) {
|
||||||
|
for (NMPoint point : getNMPoints()) {
|
||||||
|
if (point.getUset() == U) {
|
||||||
|
return point;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find first point with given Uread
|
||||||
|
*
|
||||||
|
* @param U
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
default NMPoint getByUread(double U) {
|
||||||
|
for (NMPoint point : getNMPoints()) {
|
||||||
|
if (point.getUread() == U) {
|
||||||
|
return point;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.storage;
|
package inr.numass.storage;
|
||||||
|
|
||||||
|
import hep.dataforge.context.GlobalContext;
|
||||||
import hep.dataforge.data.binary.Binary;
|
import hep.dataforge.data.binary.Binary;
|
||||||
import hep.dataforge.exceptions.StorageException;
|
import hep.dataforge.exceptions.StorageException;
|
||||||
import hep.dataforge.io.envelopes.DefaultEnvelopeReader;
|
import hep.dataforge.io.envelopes.DefaultEnvelopeReader;
|
||||||
@ -31,24 +32,19 @@ import java.net.URL;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import org.apache.commons.vfs2.FileObject;
|
import org.apache.commons.vfs2.FileObject;
|
||||||
import org.apache.commons.vfs2.FileSystemException;
|
import org.apache.commons.vfs2.FileSystemException;
|
||||||
import static org.apache.commons.vfs2.FileType.FOLDER;
|
import static org.apache.commons.vfs2.FileType.FOLDER;
|
||||||
import org.apache.commons.vfs2.VFS;
|
import org.apache.commons.vfs2.VFS;
|
||||||
import org.apache.commons.vfs2.provider.local.DefaultLocalFileProvider;
|
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,7 +71,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
public static final String HV_FRAGMENT_NAME = "voltage";
|
public static final String HV_FRAGMENT_NAME = "voltage";
|
||||||
|
|
||||||
public static NumassDataLoader fromLocalDir(Storage storage, File directory) throws IOException {
|
public static NumassDataLoader fromLocalDir(Storage storage, File directory) throws IOException {
|
||||||
return fromDir(storage, new DefaultLocalFileProvider().findLocalFile(directory), null);
|
return fromDir(storage, VFS.getManager().toFileObject(directory), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NumassDataLoader fromZip(Storage storage, FileObject zipFile) throws IOException {
|
public static NumassDataLoader fromZip(Storage storage, FileObject zipFile) throws IOException {
|
||||||
@ -98,6 +94,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
Meta annotation = new MetaBuilder("loader")
|
Meta annotation = new MetaBuilder("loader")
|
||||||
.putValue("type", "numass")
|
.putValue("type", "numass")
|
||||||
.putValue("numass.loaderFormat", "dir")
|
.putValue("numass.loaderFormat", "dir")
|
||||||
|
.putValue("file.timeCreated", Instant.ofEpochMilli(directory.getContent().getLastModifiedTime()))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
if (name == null || name.isEmpty()) {
|
if (name == null || name.isEmpty()) {
|
||||||
@ -106,44 +103,50 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
|
|
||||||
URL url = directory.getURL();
|
URL url = directory.getURL();
|
||||||
|
|
||||||
return new NumassDataLoader(storage, name, annotation, () -> {
|
Map<String, Supplier<Envelope>> items = new LinkedHashMap<>();
|
||||||
FileObject dir = null;
|
|
||||||
try {
|
|
||||||
dir = VFS.getManager().resolveFile(url.toString());
|
|
||||||
|
|
||||||
Map<String, Envelope> items = new HashMap<>();
|
FileObject dir = null;
|
||||||
for (FileObject it : dir.getChildren()) {
|
try {
|
||||||
Envelope envelope = readFile(it);
|
dir = VFS.getManager().resolveFile(url.toString());
|
||||||
if (envelope != null) {
|
|
||||||
items.put(it.getName().getBaseName(), envelope);
|
for (FileObject it : dir.getChildren()) {
|
||||||
}
|
items.put(it.getName().getBaseName(), () -> readFile(it));
|
||||||
}
|
}
|
||||||
return items;
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LoggerFactory.getLogger(NumassDataLoader.class)
|
LoggerFactory.getLogger(NumassDataLoader.class)
|
||||||
.error("Can't load numass data directory " + directory.getName().getBaseName(), ex);
|
.error("Can't load numass data directory " + directory.getName().getBaseName(), ex);
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
if (dir != null) {
|
if (dir != null) {
|
||||||
try {
|
try {
|
||||||
dir.close();
|
dir.close();
|
||||||
} catch (FileSystemException ex) {
|
} catch (FileSystemException ex) {
|
||||||
LoggerFactory.getLogger(NumassDataLoader.class)
|
LoggerFactory.getLogger(NumassDataLoader.class)
|
||||||
.error("Can't close remote directory", ex);
|
.error("Can't close remote directory", ex);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
return new NumassDataLoader(storage, name, annotation, items);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Envelope readFile(FileObject file) throws FileSystemException {
|
private static Envelope readFile(FileObject file) {
|
||||||
String fileName = file.getName().getBaseName();
|
//VFS file reading seems to work basly in parallel
|
||||||
if (fileName.equals(META_FRAGMENT_NAME)
|
synchronized (GlobalContext.instance()) {
|
||||||
|| fileName.equals(HV_FRAGMENT_NAME)
|
String fileName = file.getName().getBaseName();
|
||||||
|| fileName.startsWith(POINT_FRAGMENT_NAME)) {
|
if (fileName.equals(META_FRAGMENT_NAME)
|
||||||
return readStream(file.getContent().getInputStream());
|
|| fileName.equals(HV_FRAGMENT_NAME)
|
||||||
} else {
|
|| fileName.startsWith(POINT_FRAGMENT_NAME)) {
|
||||||
return null;
|
try {
|
||||||
|
return readStream(file.getContent().getInputStream());
|
||||||
|
} catch (FileSystemException ex) {
|
||||||
|
LoggerFactory.getLogger(NumassDataLoader.class).error("Can't read file envelope", ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +157,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
* @param transformation
|
* @param transformation
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static NMPoint readPoint(Envelope envelope, Function<RawNMPoint, NMPoint> transformation) {
|
public NMPoint readPoint(Envelope envelope, Function<RawNMPoint, NMPoint> transformation) {
|
||||||
List<NMEvent> events = new ArrayList<>();
|
List<NMEvent> events = new ArrayList<>();
|
||||||
ByteBuffer buffer;
|
ByteBuffer buffer;
|
||||||
try {
|
try {
|
||||||
@ -181,7 +184,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
// LocalDateTime startTime = envelope.meta().get
|
// LocalDateTime startTime = envelope.meta().get
|
||||||
double u = envelope.meta().getDouble("external_meta.HV1_value", 0);
|
double u = envelope.meta().getDouble("external_meta.HV1_value", 0);
|
||||||
double pointTime;
|
double pointTime;
|
||||||
if(envelope.meta().hasValue("external_meta.acquisition_time")){
|
if (envelope.meta().hasValue("external_meta.acquisition_time")) {
|
||||||
pointTime = envelope.meta().getValue("external_meta.acquisition_time").doubleValue();
|
pointTime = envelope.meta().getValue("external_meta.acquisition_time").doubleValue();
|
||||||
} else {
|
} else {
|
||||||
pointTime = envelope.meta().getValue("acquisition_time").doubleValue();
|
pointTime = envelope.meta().getValue("acquisition_time").doubleValue();
|
||||||
@ -194,12 +197,15 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
return transformation.apply(raw);
|
return transformation.apply(raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "start_time": "2016-04-20T04:08:50",
|
||||||
|
*
|
||||||
|
* @param meta
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private static Instant readTime(Meta meta) {
|
private static Instant readTime(Meta meta) {
|
||||||
if (meta.hasValue("date") && meta.hasValue("start_time")) {
|
if (meta.hasValue("start_time")) {
|
||||||
LocalDate date = LocalDate.parse(meta.getString("date"), DateTimeFormatter.ofPattern("uuuu.MM.dd"));
|
return meta.getValue("start_time").timeValue();
|
||||||
LocalTime time = LocalTime.parse(meta.getString("start_time"));
|
|
||||||
LocalDateTime dateTime = LocalDateTime.of(date, time);
|
|
||||||
return dateTime.toInstant(ZoneOffset.UTC);
|
|
||||||
} else {
|
} else {
|
||||||
return Instant.EPOCH;
|
return Instant.EPOCH;
|
||||||
}
|
}
|
||||||
@ -211,7 +217,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
* @param envelope
|
* @param envelope
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static NMPoint readPoint(Envelope envelope) {
|
public NMPoint readPoint(Envelope envelope) {
|
||||||
return readPoint(envelope, (p) -> new NMPoint(p));
|
return readPoint(envelope, (p) -> new NMPoint(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,27 +232,22 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Supplier<Map<String, Envelope>> items;
|
private final Map<String, Supplier<Envelope>> itemsProvider;
|
||||||
|
|
||||||
private NumassDataLoader(Storage storage, String name, Meta annotation) {
|
private NumassDataLoader(Storage storage, String name, Meta annotation) {
|
||||||
super(storage, name, annotation);
|
super(storage, name, annotation);
|
||||||
items = () -> new HashMap<>();
|
itemsProvider = new HashMap<>();
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private NumassDataLoader(Storage storage, String name, Meta annotation, Supplier<Map<String, Envelope>> items) {
|
private NumassDataLoader(Storage storage, String name, Meta annotation, Map<String, Supplier<Envelope>> items) {
|
||||||
super(storage, name, annotation);
|
super(storage, name, annotation);
|
||||||
this.items = items;
|
this.itemsProvider = items;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Envelope> getItems() {
|
private Map<String, Supplier<Envelope>> getItems() {
|
||||||
Map<String, Envelope> map = items.get();
|
return itemsProvider;
|
||||||
if (map == null) {
|
|
||||||
return Collections.emptyMap();
|
|
||||||
} else {
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -258,6 +259,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
public Meta getInfo() {
|
public Meta getInfo() {
|
||||||
return getItems()
|
return getItems()
|
||||||
.get(META_FRAGMENT_NAME)
|
.get(META_FRAGMENT_NAME)
|
||||||
|
.get()
|
||||||
.meta();
|
.meta();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,28 +268,16 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
// }
|
// }
|
||||||
@Override
|
@Override
|
||||||
public List<NMPoint> getNMPoints() {
|
public List<NMPoint> getNMPoints() {
|
||||||
List<NMPoint> res = new ArrayList<>();
|
return this.getPoints().stream().parallel().map(env -> readPoint(env)).collect(Collectors.toList());
|
||||||
this.getPoints().stream().forEachOrdered((point) -> {
|
|
||||||
res.add(readPoint(point));
|
|
||||||
});
|
|
||||||
// res.sort((NMPoint o1, NMPoint o2) -> o1.getStartTime().compareTo(o2.getStartTime()));
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<Envelope> getPoints() {
|
private List<Envelope> getPoints() {
|
||||||
List<Envelope> res = new ArrayList<>();
|
return getItems().entrySet().stream()
|
||||||
getItems().forEach((k, v) -> {
|
.filter(entry -> entry.getKey().startsWith(POINT_FRAGMENT_NAME) && entry.getValue() != null)
|
||||||
if (k.startsWith(POINT_FRAGMENT_NAME)) {
|
.map(entry -> entry.getValue().get())//TODO check for nulls?
|
||||||
if (v != null) {
|
.sorted((Envelope t, Envelope t1)
|
||||||
res.add(v);
|
-> t.meta().getInt("external_meta.point_index", -1).compareTo(t1.meta().getInt("external_meta.point_index", -1)))
|
||||||
}
|
.collect(Collectors.toList());
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
res.sort((Envelope t, Envelope t1) -> t.meta().getInt("external_meta.point_index", -1)
|
|
||||||
.compareTo(t1.meta().getInt("external_meta.point_index", -1)));
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -298,7 +288,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
@Override
|
@Override
|
||||||
public Envelope pull(String header) {
|
public Envelope pull(String header) {
|
||||||
//PENDING read data to memory?
|
//PENDING read data to memory?
|
||||||
return getItems().get(header);
|
return getItems().get(header).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -313,13 +303,12 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instant startTime() {
|
public Instant startTime() {
|
||||||
return null;
|
if (meta().hasValue("file.timeCreated")) {
|
||||||
// List<NMPoint> points = getNMPoints();
|
return meta().getValue("file.timeCreated").timeValue();
|
||||||
// if(!points.isEmpty()){
|
} else {
|
||||||
// return points.get(0).getStartTime();
|
return null;
|
||||||
// } else {
|
}
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
9
numass-viewer/proguard.cfg
Normal file
9
numass-viewer/proguard.cfg
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
-injars build\libs\numass-viewer-0.3.1-all.jar
|
||||||
|
-outjars build\libs\numass-viewer-0.3.1-min.jar
|
||||||
|
|
||||||
|
-libraryjars 'c:\Program Files\Java\jdk\jre\lib\rt.jar'
|
||||||
|
-libraryjars 'C:\Program Files\Java\jdk\jre\lib\ext\jfxrt.jar'
|
||||||
|
-libraryjars 'C:\Users\darksnake\.posh_gvm\groovy\2.4.6\lib\groovy-2.4.6.jar'
|
||||||
|
|
||||||
|
-dontobfuscate
|
||||||
|
-dontwarn
|
@ -68,7 +68,7 @@ public class MspViewController {
|
|||||||
// .setValue("axisUnits", "mbar")
|
// .setValue("axisUnits", "mbar")
|
||||||
// .setValue("type", "log")
|
// .setValue("type", "log")
|
||||||
// );
|
// );
|
||||||
JFreeChartFrame frame = new JFreeChartFrame("mspData", null);
|
JFreeChartFrame frame = new JFreeChartFrame();
|
||||||
PlotUtils.setYAxis(frame, "partial pressure", "mbar", "log");
|
PlotUtils.setYAxis(frame, "partial pressure", "mbar", "log");
|
||||||
frame.getConfig().setValue("yAxis.range.lower", 1e-10);
|
frame.getConfig().setValue("yAxis.range.lower", 1e-10);
|
||||||
frame.getConfig().setValue("yAxis.range.upper", 1e-3);
|
frame.getConfig().setValue("yAxis.range.upper", 1e-3);
|
||||||
|
@ -17,8 +17,6 @@ package inr.numass.viewer;
|
|||||||
|
|
||||||
import hep.dataforge.context.ProcessManager;
|
import hep.dataforge.context.ProcessManager;
|
||||||
import hep.dataforge.exceptions.StorageException;
|
import hep.dataforge.exceptions.StorageException;
|
||||||
import hep.dataforge.storage.api.Loader;
|
|
||||||
import hep.dataforge.storage.api.Storage;
|
|
||||||
import inr.numass.storage.NumassData;
|
import inr.numass.storage.NumassData;
|
||||||
import inr.numass.storage.NumassStorage;
|
import inr.numass.storage.NumassStorage;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@ -31,6 +29,8 @@ import javafx.scene.control.TreeItem;
|
|||||||
import javafx.scene.control.TreeTableColumn;
|
import javafx.scene.control.TreeTableColumn;
|
||||||
import javafx.scene.control.TreeTableView;
|
import javafx.scene.control.TreeTableView;
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -108,41 +108,41 @@ public class NumassLoaderTreeBuilder {
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Logger getLogger() {
|
||||||
|
return LoggerFactory.getLogger(getClass());
|
||||||
|
}
|
||||||
|
|
||||||
private List<TreeItem<TreeItemValue>> buildChildren(NumassStorage storage,
|
private List<TreeItem<TreeItemValue>> buildChildren(NumassStorage storage,
|
||||||
Consumer<NumassData> numassViewBuilder, ProcessManager.Callback callback) throws StorageException {
|
Consumer<NumassData> numassViewBuilder, ProcessManager.Callback callback) throws StorageException {
|
||||||
List<TreeItem<TreeItemValue>> list = new ArrayList<>();
|
List<TreeItem<TreeItemValue>> list = new ArrayList<>();
|
||||||
|
|
||||||
for (Storage subStorage : storage.shelves().values()) {
|
storage.shelves().values().stream().forEach(subStorage -> {
|
||||||
if (subStorage instanceof NumassStorage) {
|
if (subStorage instanceof NumassStorage) {
|
||||||
NumassStorage numassSubStorage = (NumassStorage) subStorage;
|
try {
|
||||||
TreeItem<TreeItemValue> childNode = buildNode(numassSubStorage, numassViewBuilder, callback);
|
NumassStorage numassSubStorage = (NumassStorage) subStorage;
|
||||||
if (!childNode.isLeaf()) {
|
TreeItem<TreeItemValue> childNode = buildNode(numassSubStorage, numassViewBuilder, callback);
|
||||||
list.add(buildNode(numassSubStorage, numassViewBuilder, callback));
|
if (!childNode.isLeaf()) {
|
||||||
|
list.add(buildNode(numassSubStorage, numassViewBuilder, callback));
|
||||||
|
}
|
||||||
|
} catch (StorageException ex) {
|
||||||
|
getLogger().error("Error while loading numass storage node", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
callback.updateMessage("Building storage " + storage.getName());
|
callback.updateMessage("Building storage " + storage.getName());
|
||||||
callback.setProgress(0);
|
callback.setProgress(0);
|
||||||
callback.setMaxProgress(storage.loaders().size());
|
callback.setMaxProgress(storage.loaders().size());
|
||||||
for (Loader loader : storage.loaders().values()) {
|
storage.loaders().values().stream()
|
||||||
if (loader instanceof NumassData) {
|
.forEach(loader -> {
|
||||||
callback.updateMessage("Building numass data loader " + loader.getName());
|
if (loader instanceof NumassData) {
|
||||||
NumassData numassLoader = (NumassData) loader;
|
callback.updateMessage("Building numass data loader " + loader.getName());
|
||||||
TreeItem<TreeItemValue> numassLoaderTreeItem = new TreeItem<>(buildValue(numassLoader));
|
NumassData numassLoader = (NumassData) loader;
|
||||||
|
TreeItem<TreeItemValue> numassLoaderTreeItem = new TreeItem<>(buildValue(numassLoader));
|
||||||
// numassLoaderTreeItem.addEventHandler(MouseEvent.MOUSE_CLICKED, (MouseEvent event) -> {
|
list.add(numassLoaderTreeItem);
|
||||||
// if (event.getClickCount() >= 2) {
|
}
|
||||||
// TreeItemValue value = numassLoaderTreeItem.getValue();
|
callback.increaseProgress(1);
|
||||||
// if (value.isLoader()) {
|
});
|
||||||
// numassViewBuilder.accept(value.getLoader());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
list.add(numassLoaderTreeItem);
|
|
||||||
}
|
|
||||||
callback.increaseProgress(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
callback.updateMessage("Loading legacy DAT files");
|
callback.updateMessage("Loading legacy DAT files");
|
||||||
callback.setProgress(0);
|
callback.setProgress(0);
|
||||||
@ -184,7 +184,11 @@ public class NumassLoaderTreeBuilder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTime() {
|
public String getTime() {
|
||||||
return "";
|
if (getStorage().meta().hasValue("file.timeModified")) {
|
||||||
|
return getStorage().meta().getValue("file.timeModified").stringValue();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -279,7 +279,8 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
|
|||||||
.setValue("yAxis.axisUnits", "Hz")
|
.setValue("yAxis.axisUnits", "Hz")
|
||||||
.setValue("legend.show", false);
|
.setValue("legend.show", false);
|
||||||
|
|
||||||
spectrumPlotFrame = new JFreeChartFrame("spectrum", plotMeta).display(spectrumPlotPane);
|
spectrumPlotFrame = new JFreeChartFrame(plotMeta).display(spectrumPlotPane);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spectrumData == null) {
|
if (spectrumData == null) {
|
||||||
@ -337,7 +338,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
|
|||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
detectorPlotFrame = new JFreeChartFrame("detectorSignal", frameMeta).display(detectorPlotPane);
|
detectorPlotFrame = new JFreeChartFrame(frameMeta).display(detectorPlotPane);
|
||||||
|
|
||||||
for (XYPlottable pl : detectorData) {
|
for (XYPlottable pl : detectorData) {
|
||||||
detectorPlotFrame.add(pl);
|
detectorPlotFrame.add(pl);
|
||||||
|
Loading…
Reference in New Issue
Block a user