diff --git a/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspViewController.java b/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspViewController.java index bdc308eb..5c02e5fe 100644 --- a/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspViewController.java +++ b/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspViewController.java @@ -28,8 +28,8 @@ import hep.dataforge.meta.ConfigChangeListener; import hep.dataforge.meta.Configuration; import hep.dataforge.meta.Meta; import hep.dataforge.meta.MetaBuilder; -import hep.dataforge.plots.data.DynamicPlottable; -import hep.dataforge.plots.data.DynamicPlottableGroup; +import hep.dataforge.plots.data.TimePlottable; +import hep.dataforge.plots.data.TimePlottableGroup; import hep.dataforge.plots.fx.PlotContainer; import hep.dataforge.plots.jfreechart.JFreeChartFrame; import hep.dataforge.storage.api.Storage; @@ -77,7 +77,7 @@ public class MspViewController implements Initializable, MspListener { public static final String MSP_DEVICE_TYPE = "msp"; public static final String DEFAULT_CONFIG_LOCATION = "msp-config.xml"; - private final DynamicPlottableGroup plottables = new DynamicPlottableGroup(); + private final TimePlottableGroup plottables = new TimePlottableGroup(); private final String mspName = "msp"; private MspDevice device; private Configuration viewConfig; @@ -257,7 +257,7 @@ public class MspViewController implements Initializable, MspListener { String mass = an.getString("mass"); if (!this.plottables.hasPlottable(mass)) { - DynamicPlottable newPlottable = new DynamicPlottable(mass, mass); + TimePlottable newPlottable = new TimePlottable(mass, mass); newPlottable.configure(an); this.plottables.addPlottable(newPlottable); plot.add(newPlottable); diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacCollectorController.java b/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacCollectorController.java index 03b8aa59..4be50a6d 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacCollectorController.java +++ b/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacCollectorController.java @@ -17,8 +17,8 @@ import hep.dataforge.exceptions.MeasurementException; import hep.dataforge.fx.ConsoleFragment; import hep.dataforge.meta.Meta; import hep.dataforge.meta.MetaBuilder; -import hep.dataforge.plots.data.DynamicPlottable; -import hep.dataforge.plots.data.DynamicPlottableGroup; +import hep.dataforge.plots.data.TimePlottable; +import hep.dataforge.plots.data.TimePlottableGroup; import hep.dataforge.plots.fx.FXPlotFrame; import hep.dataforge.plots.fx.PlotContainer; import hep.dataforge.plots.jfreechart.JFreeChartFrame; @@ -75,7 +75,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me private LoaderConnection storageConnection; private VacCollectorDevice device; private PlotContainer plotContainer; - private DynamicPlottableGroup plottables; + private TimePlottableGroup plottables; private BiFunction loaderFactory; @FXML private AnchorPane plotHolder; @@ -161,10 +161,10 @@ public class VacCollectorController implements Initializable, DeviceListener, Me private void setupView() { vacBoxHolder.getChildren().clear(); - plottables = new DynamicPlottableGroup(); + plottables = new TimePlottableGroup(); views.stream().forEach((controller) -> { vacBoxHolder.getChildren().add(controller.getComponent()); - DynamicPlottable plot = new DynamicPlottable(controller.getTitle(), + TimePlottable plot = new TimePlottable(controller.getTitle(), controller.getName()); plot.configure(controller.meta()); plottables.addPlottable(plot); @@ -175,7 +175,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me plotContainer.setPlot(setupPlot(plottables)); } - private FXPlotFrame setupPlot(DynamicPlottableGroup plottables) { + private FXPlotFrame setupPlot(TimePlottableGroup plottables) { Meta plotConfig = new MetaBuilder("plotFrame") .setNode(new MetaBuilder("yAxis") .setValue("type", "log") diff --git a/numass-main/src/main/java/inr/numass/NumassPlugin.java b/numass-main/src/main/java/inr/numass/NumassPlugin.java index 260a6799..efb27d0d 100644 --- a/numass-main/src/main/java/inr/numass/NumassPlugin.java +++ b/numass-main/src/main/java/inr/numass/NumassPlugin.java @@ -273,8 +273,8 @@ public class NumassPlugin extends BasicPlugin { } private XYAdapter getAdapter(Meta an) { - if (an.hasNode(PointAdapter.DATA_ADAPTER_ANNOTATION_NAME)) { - return new XYAdapter(an.getNode(PointAdapter.DATA_ADAPTER_ANNOTATION_NAME)); + if (an.hasNode(PointAdapter.DATA_ADAPTER_KEY)) { + return new XYAdapter(an.getNode(PointAdapter.DATA_ADAPTER_KEY)); } else { return new XYAdapter("Uread", "CR", "CRerr"); } diff --git a/numass-main/src/main/java/inr/numass/actions/MergeDataAction.java b/numass-main/src/main/java/inr/numass/actions/MergeDataAction.java index 2a5053c2..3f885149 100644 --- a/numass-main/src/main/java/inr/numass/actions/MergeDataAction.java +++ b/numass-main/src/main/java/inr/numass/actions/MergeDataAction.java @@ -66,9 +66,9 @@ public class MergeDataAction extends ManyToOneAction { @Override protected MetaBuilder outputMeta(DataNode input) { - String numassPath = input.dataStream().map(data -> data.meta().getString("numass.path", null)) + String numassPath = input.dataStream().map(data -> data.meta().getString("numass.path", "")) .reduce("", (String path, String newPath) -> { - if (path == null) { + if (path.isEmpty()) { return null; } else if (path.isEmpty()) { return newPath; diff --git a/numass-main/src/main/java/inr/numass/actions/ShowEnergySpectrumAction.java b/numass-main/src/main/java/inr/numass/actions/ShowEnergySpectrumAction.java index e08a2c6e..8cf17981 100644 --- a/numass-main/src/main/java/inr/numass/actions/ShowEnergySpectrumAction.java +++ b/numass-main/src/main/java/inr/numass/actions/ShowEnergySpectrumAction.java @@ -13,7 +13,7 @@ import hep.dataforge.meta.Meta; import hep.dataforge.meta.MetaBuilder; import hep.dataforge.plots.PlotsPlugin; import hep.dataforge.plots.XYPlotFrame; -import hep.dataforge.plots.XYPlottable; +import hep.dataforge.plots.data.XYPlottable; import hep.dataforge.plots.data.PlottableData; import hep.dataforge.tables.*; import hep.dataforge.values.ValueType; diff --git a/numass-main/src/main/java/inr/numass/data/SpectrumDataAdapter.java b/numass-main/src/main/java/inr/numass/data/SpectrumDataAdapter.java index 551e2c0d..836a2264 100644 --- a/numass-main/src/main/java/inr/numass/data/SpectrumDataAdapter.java +++ b/numass-main/src/main/java/inr/numass/data/SpectrumDataAdapter.java @@ -41,19 +41,19 @@ public class SpectrumDataAdapter extends XYAdapter { } public SpectrumDataAdapter(String xName, String yName, String yErrName, String measurementTime) { - super(new MetaBuilder(PointAdapter.DATA_ADAPTER_ANNOTATION_NAME) - .setValue(X_NAME, xName) - .setValue(Y_NAME, yName) - .setValue(Y_ERR_NAME, yErrName) + super(new MetaBuilder(PointAdapter.DATA_ADAPTER_KEY) + .setValue(X_VALUE_KEY, xName) + .setValue(Y_VALUE_KEY, yName) + .setValue(Y_ERROR_KEY, yErrName) .setValue(POINT_LENGTH_NAME, measurementTime) .build() ); } public SpectrumDataAdapter(String xName, String yName, String measurementTime) { - super(new MetaBuilder(PointAdapter.DATA_ADAPTER_ANNOTATION_NAME) - .setValue(X_NAME, xName) - .setValue(Y_NAME, yName) + super(new MetaBuilder(PointAdapter.DATA_ADAPTER_KEY) + .setValue(X_VALUE_KEY, xName) + .setValue(Y_VALUE_KEY, yName) .setValue(POINT_LENGTH_NAME, measurementTime) .build() ); @@ -64,14 +64,14 @@ public class SpectrumDataAdapter extends XYAdapter { } public DataPoint buildSpectrumDataPoint(double x, long count, double t) { - return new MapPoint(new String[]{getValueName(X_NAME), getValueName(Y_NAME), + return new MapPoint(new String[]{getValueName(X_VALUE_KEY), getValueName(Y_VALUE_KEY), getValueName(POINT_LENGTH_NAME)}, x, count, t); } public DataPoint buildSpectrumDataPoint(double x, long count, double countErr, double t) { - return new MapPoint(new String[]{getValueName(X_NAME), getValueName(Y_NAME), - getValueName(Y_ERR_NAME), getValueName(POINT_LENGTH_NAME)}, + return new MapPoint(new String[]{getValueName(X_VALUE_KEY), getValueName(Y_VALUE_KEY), + getValueName(Y_ERROR_KEY), getValueName(POINT_LENGTH_NAME)}, x, count, countErr, t); } diff --git a/numass-storage/numass-server/src/main/java/inr/numass/server/NumassRootHandler.java b/numass-storage/numass-server/src/main/java/inr/numass/server/NumassRootHandler.java index 81138b37..78d4e8e3 100644 --- a/numass-storage/numass-server/src/main/java/inr/numass/server/NumassRootHandler.java +++ b/numass-storage/numass-server/src/main/java/inr/numass/server/NumassRootHandler.java @@ -100,7 +100,7 @@ public class NumassRootHandler implements Handler { } private void renderLoader(Context ctx, StringBuilder b, Loader loader) { - String href = "/storage?path=" + loader.getFullPath(); + String href = "/storage?path=" + loader.getPath(); b.append(String.format("

%s (%s)

", href, loader.getName(), loader.getType())); } } 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 b2307b4d..8ae761a4 100644 --- a/numass-viewer/src/main/java/inr/numass/viewer/MspViewController.java +++ b/numass-viewer/src/main/java/inr/numass/viewer/MspViewController.java @@ -23,10 +23,10 @@ package inr.numass.viewer; import hep.dataforge.context.Context; 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.DynamicPlottable; -import hep.dataforge.plots.data.DynamicPlottableGroup; +import hep.dataforge.plots.data.*; import hep.dataforge.plots.fx.PlotContainer; import hep.dataforge.plots.jfreechart.JFreeChartFrame; import hep.dataforge.storage.api.PointLoader; @@ -43,8 +43,7 @@ import javafx.scene.layout.BorderPane; import org.slf4j.LoggerFactory; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; @@ -86,16 +85,18 @@ public class MspViewController implements Encapsulated { /** * update detector pane with new data */ - private void updateMspPane(DynamicPlottableGroup mspData) { + private void updateMspPane(Iterable mspData) { JFreeChartFrame frame = new JFreeChartFrame(); PlotUtils.setYAxis(frame, "partial pressure", "mbar", "log"); frame.getConfig().setValue("yAxis.range.lower", 1e-10); frame.getConfig().setValue("yAxis.range.upper", 1e-3); PlotUtils.setXAxis(frame, "time", null, "time"); - StreamSupport.stream(mspData.spliterator(), false) - .sorted((DynamicPlottable o1, DynamicPlottable o2) - -> Integer.valueOf(o1.getName()).compareTo(Integer.valueOf(o2.getName()))).forEach((pl) -> frame.add(pl)); +// StreamSupport.stream(mspData.spliterator(), false) +// .sorted((XYPlottable o1, XYPlottable o2) +// -> Integer.valueOf(o1.getName()).compareTo(Integer.valueOf(o2.getName()))).forEach((pl) -> frame.add(pl)); + + frame.addAll(mspData); Platform.runLater(() -> { mspPlotPane.getChildren().clear(); PlotContainer container = PlotContainer.anchorTo(mspPlotPane); @@ -114,22 +115,43 @@ public class MspViewController implements Encapsulated { } public void plotData(List loaders) { - DynamicPlottableGroup plottables = new DynamicPlottableGroup(); - loaders.stream() - .flatMap(loader -> getLoaderData(loader)) - .distinct() - .forEach(point -> { - for (String name : point.names()) { - if (!name.equals("timestamp")) { - if (!plottables.hasPlottable(name)) { - plottables.addPlottable(new DynamicPlottable(name, name)); - } - } - } - plottables.put(point); - } - ); - updateMspPane(plottables); +// TimePlottableGroup plottables = new TimePlottableGroup(); +// loaders.stream() +// .flatMap(loader -> getLoaderData(loader)) +// .distinct() +// .forEach(point -> { +// for (String name : point.names()) { +// if (!name.equals("timestamp")) { +// if (!plottables.hasPlottable(name)) { +// plottables.addPlottable(new TimePlottable(name, name)); +// } +// } +// } +// plottables.put(point); +// } +// ); + + Collection names = joinNames(loaders); + + Stream stream = loaders.stream().flatMap(loader -> getLoaderData(loader)); + + + updateMspPane(PlotDataUtils.buildGroup("timestamp", names, stream)); + } + + /** + * Combine names of different point loaders + * + * @param loaders + * @return + */ + private Collection joinNames(List loaders) { + Set nameSet = new TreeSet<>(new AlphanumComparator()); + for (PointLoader loader : loaders) { + nameSet.addAll(loader.getFormat().names().asList()); + } + + return nameSet; } private Stream getLoaderData(PointLoader loader) { @@ -194,13 +216,13 @@ public class MspViewController implements Encapsulated { //// List mspData = (List) loadProcess.getTask().get(); // // if (!mspData.isEmpty()) { -// DynamicPlottableGroup plottables = new DynamicPlottableGroup(); +// TimePlottableGroup plottables = new TimePlottableGroup(); // // for (DataPoint point : mspData) { // for (String name : point.names()) { // if (!name.equals("timestamp")) { // if (!plottables.hasPlottable(name)) { -// plottables.addPlottable(new DynamicPlottable(name, name)); +// plottables.addPlottable(new TimePlottable(name, name)); // } // } // } @@ -229,4 +251,5 @@ public class MspViewController implements Encapsulated { } return p.build(); } + } 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 404655e6..48223a59 100644 --- a/numass-viewer/src/main/java/inr/numass/viewer/NumassLoaderViewComponent.java +++ b/numass-viewer/src/main/java/inr/numass/viewer/NumassLoaderViewComponent.java @@ -244,11 +244,11 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab Platform.runLater(() -> { if (t != null) { hvPlot.getPlot().plottables().clear(); - DynamicPlottableGroup set = new DynamicPlottableGroup(); + TimePlottableGroup set = new TimePlottableGroup(); for (DataPoint dp : t) { String block = dp.getString("block", "default"); if (!set.hasPlottable(block)) { - set.addPlottable(new DynamicPlottable(block, block)); + set.addPlottable(new TimePlottable(block, block)); } set.getPlottable(block).put(dp.getValue("timestamp").timeValue(), dp.getValue("value")); } diff --git a/numass.gradle b/numass.gradle index 9619044a..12bfd9f0 100644 --- a/numass.gradle +++ b/numass.gradle @@ -21,8 +21,6 @@ repositories { dependencies { // Adding dependencies here will add the dependencies to each subproject. - compile 'org.codehaus.groovy:groovy-all:2.4.+' - shadow 'org.codehaus.groovy:groovy-all:2.4.+' testCompile group: 'junit', name: 'junit', version:'4.+' deployerJars "org.apache.maven.wagon:wagon-ssh:2.8" } @@ -38,7 +36,6 @@ uploadArchives { shadowJar { dependencies { - exclude(dependency('org.codehaus.groovy:groovy-all:2.4.+')) mergeServiceFiles() } }