diff --git a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8App.java b/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8App.java index bcd67588..eb26df9a 100644 --- a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8App.java +++ b/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8App.java @@ -95,8 +95,8 @@ public class PKT8App extends Application { device = setupDevice(deviceName, config); // setting up storage connections - if (config.hasNode("storage")) { - config.getNodes("storage").forEach(node -> { + if (config.hasMeta("storage")) { + config.getMetaList("storage").forEach(node -> { Storage storage = StorageFactory.buildStorage(device.getContext(), node); if(config.hasValue("numass.run")){ try { @@ -148,7 +148,7 @@ public class PKT8App extends Application { public PKT8Device setupDevice(String deviceName, Meta config) throws ControlException { Meta deviceMeta; - if (config.hasNode("device")) { + if (config.hasMeta("device")) { deviceMeta = MetaUtils.findNodeByValue(config, "device", "name", deviceName); } else { deviceMeta = config; diff --git a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8Device.java b/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8Device.java index 057c82df..68d49d98 100644 --- a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8Device.java +++ b/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8Device.java @@ -69,8 +69,8 @@ public class PKT8Device extends PortSensor { public void init() throws ControlException { //read channel configuration - if (meta().hasNode("channel")) { - for (Meta node : meta().getNodes("channel")) { + if (meta().hasMeta("channel")) { + for (Meta node : meta().getMetaList("channel")) { String designation = node.getString("designation", "default"); this.channels.put(designation, new PKT8Channel(node)); } diff --git a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8PlotController.java b/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8PlotController.java index 4d61f5a9..4636ff71 100644 --- a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8PlotController.java +++ b/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8PlotController.java @@ -80,13 +80,13 @@ public class PKT8PlotController implements Initializable, MeasurementListener { //plot config from device configuration - Meta deviceLineMeta = channel.meta().getNode("plot", channel.meta()); + Meta deviceLineMeta = channel.meta().getMeta("plot", channel.meta()); //Do not use view config here, it is applyed separately TimePlottable plottable = new TimePlottable(channel.getName()); diff --git a/numass-control/msp/src/main/java/inr/numass/control/msp/MspDevice.java b/numass-control/msp/src/main/java/inr/numass/control/msp/MspDevice.java index 155b25fa..40401d2e 100644 --- a/numass-control/msp/src/main/java/inr/numass/control/msp/MspDevice.java +++ b/numass-control/msp/src/main/java/inr/numass/control/msp/MspDevice.java @@ -89,7 +89,7 @@ public class MspDevice extends SingleMeasurementDevice implements PortHandler.Po protected Meta getMetaForMeasurement(String name) { switch (name) { case "peakJump": - return meta().getNode("peakJump"); + return meta().getMeta("peakJump"); default: return super.getMetaForMeasurement(name); } @@ -427,7 +427,7 @@ public class MspDevice extends SingleMeasurementDevice implements PortHandler.Po sendAndWait("MeasurementRemove", name); if (sendAndWait("AddPeakJump", name, filterMode, accuracy, 0, 0, 0).isOK()) { peakMap = new LinkedHashMap<>(); - for (Meta peak : meta.getNodes("peak")) { + for (Meta peak : meta.getMetaList("peak")) { peakMap.put(peak.getInt("mass"), peak.getString("name", peak.getString("mass"))); if (!sendAndWait("MeasurementAddMass", peak.getString("mass")).isOK()) { throw new ControlException("Can't add mass to measurement measurement for msp"); 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 84f16983..a06add49 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 @@ -152,7 +152,7 @@ public class MspViewController implements Initializable, MspListener { public Configuration getViewConfig() { if (viewConfig == null) { - viewConfig = new Configuration(getDevice().meta().getNode("peakJump")); + viewConfig = new Configuration(getDevice().meta().getMeta("peakJump")); viewConfig.addObserver(viewConfigObserver); LoggerFactory.getLogger(getClass()).warn("Could not find view configuration. Using default view configuration instead."); } @@ -181,14 +181,14 @@ public class MspViewController implements Initializable, MspListener { public void setDeviceConfig(Context context, Meta config) { Meta mspConfig = null; - if (config.hasNode("device")) { - for (Meta d : config.getNodes("device")) { + if (config.hasMeta("device")) { + for (Meta d : config.getMetaList("device")) { if (d.getString("type", "unknown").equals(MSP_DEVICE_TYPE) && d.getString("name", "msp").equals(this.mspName)) { mspConfig = d; } } - } else if (config.hasNode("peakJump")) { + } else if (config.hasMeta("peakJump")) { mspConfig = config; } @@ -213,8 +213,8 @@ public class MspViewController implements Initializable, MspListener { throw new RuntimeException(); } - if (config.hasNode("plots.msp")) { - setViewConfig(config.getNode("plots.msp")); + if (config.hasMeta("plots.msp")) { + setViewConfig(config.getMeta("plots.msp")); } updatePlot(); @@ -251,11 +251,11 @@ public class MspViewController implements Initializable, MspListener { initPlot(); } Meta config = getViewConfig(); - if (config.hasNode("plotFrame")) { - this.plot.configure(config.getNode("plotFrame")); + if (config.hasMeta("plotFrame")) { + this.plot.configure(config.getMeta("plotFrame")); } - if (config.hasNode("peakJump.line")) { - for (Meta an : config.getNodes("peakJump.line")) { + if (config.hasMeta("peakJump.line")) { + for (Meta an : config.getMetaList("peakJump.line")) { String mass = an.getString("mass"); if (!this.plottables.hasPlottable(mass)) { @@ -363,7 +363,7 @@ public class MspViewController implements Initializable, MspListener { private void onStoreButtonClick(ActionEvent event) { if (storeButton.isSelected()) { - if (!device.meta().hasNode("storage")) { + if (!device.meta().hasMeta("storage")) { device.getLogger().info("Storage not defined. Starting storage selection dialog"); DirectoryChooser chooser = new DirectoryChooser(); File storageDir = chooser.showDialog(this.plotPane.getScene().getWindow()); @@ -374,13 +374,13 @@ public class MspViewController implements Initializable, MspListener { device.getConfig().putNode(new MetaBuilder("storage") .putValue("path", storageDir.getAbsolutePath())); } - Meta storageConfig = device.meta().getNode("storage"); + Meta storageConfig = device.meta().getMeta("storage"); Storage localStorage = StorageManager.buildFrom(device.getContext()) .buildStorage(storageConfig); String runName = device.meta().getString("numass.run", ""); Meta meta = device.meta(); - if (meta.hasNode("numass")) { + if (meta.hasMeta("numass")) { try { device.getLogger().info("Obtaining run information from cetral server..."); NumassClient client = new NumassClient(meta.getString("numass.ip", "192.168.111.1"), diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/app/ReadVac.java b/numass-control/vac/src/main/java/inr/numass/readvac/app/ReadVac.java index 062979b8..7263a266 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/app/ReadVac.java +++ b/numass-control/vac/src/main/java/inr/numass/readvac/app/ReadVac.java @@ -15,13 +15,8 @@ import hep.dataforge.storage.commons.LoaderFactory; import hep.dataforge.tables.TableFormatBuilder; import hep.dataforge.values.ValueType; import inr.numass.client.NumassClient; -import inr.numass.readvac.devices.CM32Device; -import inr.numass.readvac.devices.MKSBaratronDevice; -import inr.numass.readvac.devices.MKSVacDevice; -import inr.numass.readvac.devices.VITVacDevice; -import inr.numass.readvac.devices.VacCollectorDevice; +import inr.numass.readvac.devices.*; import inr.numass.readvac.fx.VacCollectorController; -import java.io.File; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; @@ -29,6 +24,8 @@ import javafx.stage.Stage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; + /** * * @author Alexander Nozik @@ -53,19 +50,19 @@ public class ReadVac extends Application { } Sensor p1 = new MKSVacDevice(config.getString("p1.port", "com::/dev/ttyUSB0")); - p1.configure(config.getNode("p1", Meta.empty())); + p1.configure(config.getMeta("p1", Meta.empty())); p1.setName(config.getString("p1.name", "P1")); Sensor p2 = new CM32Device(config.getString("p2.port", "tcp::192.168.111.32:4002")); - p2.configure(config.getNode("p2", Meta.empty())); + p2.configure(config.getMeta("p2", Meta.empty())); p2.setName(config.getString("p2.name", "P2")); Sensor p3 = new CM32Device(config.getString("p3.port", "tcp::192.168.111.32:4003")); - p3.configure(config.getNode("p3", Meta.empty())); + p3.configure(config.getMeta("p3", Meta.empty())); p3.setName(config.getString("p3.name", "P3")); Sensor px = new VITVacDevice(config.getString("px.port", "com::/dev/ttyUSB1")); - px.configure(config.getNode("px", Meta.empty())); + px.configure(config.getMeta("px", Meta.empty())); px.setName(config.getString("px.name", "Px")); Sensor baratron = new MKSBaratronDevice(config.getString("baratron.port", "tcp::192.168.111.33:4004")); - baratron.configure(config.getNode("baratron", Meta.empty())); + baratron.configure(config.getMeta("baratron", Meta.empty())); baratron.setName(config.getString("baratron.name", "Baratron")); VacCollectorDevice collector = new VacCollectorDevice(); @@ -82,7 +79,7 @@ public class ReadVac extends Application { controller.setLoaderFactory((VacCollectorDevice device, Storage localStorage) -> { try { String runName = device.meta().getString("numass.run", ""); - if (config.hasNode("numass")) { + if (config.hasMeta("numass")) { try { logger.info("Obtaining run information from cetral server..."); NumassClient client = new NumassClient(config.getString("numass.ip", "192.168.111.1"), 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 39ae68c8..cce07154 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 @@ -232,7 +232,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me private void onStoreToggle(ActionEvent event) { if (storeButton.isSelected()) { //creating storage on UI thread - if (!device.meta().hasNode("storage")) { + if (!device.meta().hasMeta("storage")) { getLogger().info("Storage not defined. Starting storage selection dialog"); DirectoryChooser chooser = new DirectoryChooser(); File storageDir = chooser.showDialog(plotHolder.getScene().getWindow()); @@ -243,7 +243,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me device.getConfig().putNode(new MetaBuilder("storage") .putValue("path", storageDir.getAbsolutePath())); } - Meta storageConfig = device.meta().getNode("storage"); + Meta storageConfig = device.meta().getMeta("storage"); Storage localStorage = StorageManager.buildFrom(device.getContext()) .buildStorage(storageConfig); //Start storage creation on non-UI thread diff --git a/numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java b/numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java index 5c51e6ff..5e523971 100644 --- a/numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java +++ b/numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java @@ -54,8 +54,8 @@ public class PlotFitResultAction extends OneToOneAction { XYModel model = (XYModel) input.getModel(); XYAdapter adapter; - if (metaData.hasNode("adapter")) { - adapter = new XYAdapter(metaData.getNode("adapter")); + if (metaData.hasMeta("adapter")) { + adapter = new XYAdapter(metaData.getMeta("adapter")); } else if (input.getModel() instanceof XYModel) { adapter = model.getAdapter(); } else { @@ -66,7 +66,7 @@ public class PlotFitResultAction extends OneToOneAction { XYPlotFrame frame = (XYPlotFrame) PlotsPlugin .buildFrom(getContext()).buildPlotFrame(getName(), name, - metaData.getNode("plot", Meta.empty())); + metaData.getMeta("plot", Meta.empty())); PlottableXYFunction fit = new PlottableXYFunction("fit"); fit.setDensity(100, false); diff --git a/numass-main/src/main/java/inr/numass/NumassPlugin.java b/numass-main/src/main/java/inr/numass/NumassPlugin.java index efb27d0d..46e987db 100644 --- a/numass-main/src/main/java/inr/numass/NumassPlugin.java +++ b/numass-main/src/main/java/inr/numass/NumassPlugin.java @@ -259,8 +259,8 @@ public class NumassPlugin extends BasicPlugin { return TransmissionInterpolator .fromFile(context, transmissionFile, transXName, transYName, nSmooth, w, stitchBorder); - } else if (an.hasNode("transBuildAction")) { - Meta transBuild = an.getNode("transBuildAction"); + } else if (an.hasMeta("transBuildAction")) { + Meta transBuild = an.getMeta("transBuildAction"); try { return TransmissionInterpolator.fromAction((Context) context, transBuild, transXName, transYName, nSmooth, w, stitchBorder); @@ -273,8 +273,8 @@ public class NumassPlugin extends BasicPlugin { } private XYAdapter getAdapter(Meta an) { - if (an.hasNode(PointAdapter.DATA_ADAPTER_KEY)) { - return new XYAdapter(an.getNode(PointAdapter.DATA_ADAPTER_KEY)); + if (an.hasMeta(PointAdapter.DATA_ADAPTER_KEY)) { + return new XYAdapter(an.getMeta(PointAdapter.DATA_ADAPTER_KEY)); } else { return new XYAdapter("Uread", "CR", "CRerr"); } diff --git a/numass-main/src/main/java/inr/numass/actions/AdjustErrorsAction.java b/numass-main/src/main/java/inr/numass/actions/AdjustErrorsAction.java index 087c2a30..4adbc558 100644 --- a/numass-main/src/main/java/inr/numass/actions/AdjustErrorsAction.java +++ b/numass-main/src/main/java/inr/numass/actions/AdjustErrorsAction.java @@ -36,16 +36,16 @@ public class AdjustErrorsAction extends OneToOneAction { } private DataPoint evalPoint(Meta meta, DataPoint dp) { - if (meta.hasNode("point")) { - for (Meta pointMeta : meta.getNodes("point")) { + if (meta.hasMeta("point")) { + for (Meta pointMeta : meta.getMetaList("point")) { if (pointMeta.getDouble("Uset") == dp.getDouble("Uset")) { return adjust(dp, pointMeta); } } } - if (meta.hasNode("range")) { - for (Meta rangeMeta : meta.getNodes("range")) { + if (meta.hasMeta("range")) { + for (Meta rangeMeta : meta.getMetaList("range")) { double from = rangeMeta.getDouble("from", 0); double to = rangeMeta.getDouble("to", Double.POSITIVE_INFINITY); double u = rangeMeta.getDouble("Uset"); @@ -55,8 +55,8 @@ public class AdjustErrorsAction extends OneToOneAction { } } - if (meta.hasNode("all")) { - return adjust(dp, meta.getNode("all")); + if (meta.hasMeta("all")) { + return adjust(dp, meta.getMeta("all")); } return dp; diff --git a/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java b/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java index 8d534062..6357550b 100644 --- a/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java +++ b/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java @@ -147,8 +147,8 @@ public class PrepareDataAction extends OneToOneAction { if (meta.hasValue("correction")) { // log.report("Using correction from formula: {}", meta.getString("correction")); return evaluateExpression(point, meta.getString("correction")); - } else if (meta.hasNode("underflow")) { - return new UnderflowCorrection().get(log, meta.getNode("underflow"), point); + } else if (meta.hasMeta("underflow")) { + return new UnderflowCorrection().get(log, meta.getMeta("underflow"), point); } else { return 1; } diff --git a/numass-main/src/main/java/inr/numass/actions/ReadNumassDataAction.java b/numass-main/src/main/java/inr/numass/actions/ReadNumassDataAction.java index 02202117..e80835ed 100644 --- a/numass-main/src/main/java/inr/numass/actions/ReadNumassDataAction.java +++ b/numass-main/src/main/java/inr/numass/actions/ReadNumassDataAction.java @@ -50,7 +50,7 @@ public class ReadNumassDataAction extends OneToOneAction { if (meta.getNodeNames(false).contains("debunch")) { DebunchAction debunch = new DebunchAction(); - Laminate laminate = new Laminate(meta.getNode("debunch")) + Laminate laminate = new Laminate(meta.getMeta("debunch")) .setValueContext(getContext()) .setDescriptor(debunch.getDescriptor()); raw = debunch.execute(name, laminate, raw); 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 426a89f5..b65e9d33 100644 --- a/numass-main/src/main/java/inr/numass/actions/ShowEnergySpectrumAction.java +++ b/numass-main/src/main/java/inr/numass/actions/ShowEnergySpectrumAction.java @@ -80,10 +80,10 @@ public class ShowEnergySpectrumAction extends OneToOneAction ColumnedDataWriter.writeDataSet(out, table, inputMeta.toString()); - if (inputMeta.hasNode("plot") || inputMeta.getBoolean("plot", false)) { + if (inputMeta.hasMeta("plot") || inputMeta.getBoolean("plot", false)) { XYPlotFrame frame = (XYPlotFrame) PlotsPlugin .buildFrom(getContext()).buildPlotFrame(getName(), name, - inputMeta.getNode("plot", Meta.empty())); + inputMeta.getMeta("plot", Meta.empty())); fillDetectorData(valueMap).forEach(frame::add); } diff --git a/numass-main/src/main/java/inr/numass/actions/SlicingAction.java b/numass-main/src/main/java/inr/numass/actions/SlicingAction.java index 315f52b4..280b1bfd 100644 --- a/numass-main/src/main/java/inr/numass/actions/SlicingAction.java +++ b/numass-main/src/main/java/inr/numass/actions/SlicingAction.java @@ -49,7 +49,7 @@ public class SlicingAction extends OneToOneAction { Map> slicingConfig; LinkedHashMap> res = new LinkedHashMap<>(); - List list = meta.getNode("sliceconfig").getNodes("slicepoint"); + List list = meta.getMeta("sliceconfig").getMetaList("slicepoint"); for (Meta slice : list) { String title = slice.getString("title", slice.getName()); diff --git a/numass-main/src/main/java/inr/numass/models/sterile/SterileNeutrinoSpectrum.java b/numass-main/src/main/java/inr/numass/models/sterile/SterileNeutrinoSpectrum.java index 9ecb074b..fb3a8c96 100644 --- a/numass-main/src/main/java/inr/numass/models/sterile/SterileNeutrinoSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/sterile/SterileNeutrinoSpectrum.java @@ -73,7 +73,7 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction { } transmission = new NumassTransmission(context, configuration.getNodeOrEmpty("transmission")); - resolution = new NumassResolution(configuration.getNode("resolution", Meta.empty())); + resolution = new NumassResolution(configuration.getMeta("resolution", Meta.empty())); this.fast = configuration.getBoolean("fast", true); transRes = new TransRes(); } diff --git a/numass-main/src/main/java/inr/numass/workbench/NumassWorkbenchController.java b/numass-main/src/main/java/inr/numass/workbench/NumassWorkbenchController.java index 210d2df2..f0a98070 100644 --- a/numass-main/src/main/java/inr/numass/workbench/NumassWorkbenchController.java +++ b/numass-main/src/main/java/inr/numass/workbench/NumassWorkbenchController.java @@ -236,8 +236,8 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder buildContext(config); //loading data configuration - if (config.hasNode("data")) { - dataConfig = new Configuration(config.getNode("data")); + if (config.hasMeta("data")) { + dataConfig = new Configuration(config.getMeta("data")); //replacing file name value with appropriate nodes if (dataConfig.hasValue("file")) { Value fileValue = dataConfig.getValue("file"); @@ -258,7 +258,7 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder //loading actions configuration actionsConfig = new Configuration("actionlist"); - List actions = config.getNodes("action").stream() + List actions = config.getMetaList("action").stream() .map(m -> new Configuration(m)).collect(Collectors.toList()); actionsConfig.attachNodeItem("action", actions); diff --git a/numass-main/src/main/java/inr/numass/workspace/NumassFitScanTask.java b/numass-main/src/main/java/inr/numass/workspace/NumassFitScanTask.java index 0e4572ad..61a8989c 100644 --- a/numass-main/src/main/java/inr/numass/workspace/NumassFitScanTask.java +++ b/numass-main/src/main/java/inr/numass/workspace/NumassFitScanTask.java @@ -33,7 +33,7 @@ public class NumassFitScanTask extends AbstractTask { DataTree.Builder resultBuilder = DataTree.builder(FitState.class); DataNode sourceNode = data.getCheckedNode("prepare", Table.class); - if (config.hasNode("merge")) { + if (config.hasMeta("merge")) { //use merged data and ignore raw data sourceNode = sourceNode.getCheckedNode("merge", Table.class); } @@ -47,10 +47,10 @@ public class NumassFitScanTask extends AbstractTask { MetaBuilder overrideMeta = new MetaBuilder(fitConfig); overrideMeta.setValue("@resultName", String.format("%s[%s=%s]", d.getName(), scanParameter, val.stringValue())); - if (overrideMeta.hasNode("params." + scanParameter)) { + if (overrideMeta.hasMeta("params." + scanParameter)) { overrideMeta.setValue("params." + scanParameter + ".value", val); } else { - overrideMeta.getNodes("params.param").stream() + overrideMeta.getMetaList("params.param").stream() .filter(par -> par.getString("name") == scanParameter).forEach(par -> par.setValue("value", val)); } // Data
newData = new Data
(data.getGoal(),data.type(),overrideMeta); @@ -67,7 +67,7 @@ public class NumassFitScanTask extends AbstractTask { protected TaskModel transformModel(TaskModel model) { //Transmit meta as-is MetaBuilder metaBuilder = new MetaBuilder(model.meta()).removeNode("fit"); - if (model.meta().hasNode("filter")) { + if (model.meta().hasMeta("filter")) { model.dependsOn("numass.filter", metaBuilder.build(), "prepare"); } else { model.dependsOn("numass.prepare", metaBuilder.build(), "prepare"); diff --git a/numass-main/src/main/java/inr/numass/workspace/NumassFitSummaryTask.java b/numass-main/src/main/java/inr/numass/workspace/NumassFitSummaryTask.java index 60d5f77f..8834db24 100644 --- a/numass-main/src/main/java/inr/numass/workspace/NumassFitSummaryTask.java +++ b/numass-main/src/main/java/inr/numass/workspace/NumassFitSummaryTask.java @@ -47,7 +47,7 @@ public class NumassFitSummaryTask extends SingleActionTask { @Override protected Meta transformMeta(TaskModel model) { - return model.meta().getNode("summary"); + return model.meta().getMeta("summary"); } @Override diff --git a/numass-main/src/main/java/inr/numass/workspace/NumassFitTask.java b/numass-main/src/main/java/inr/numass/workspace/NumassFitTask.java index e594e2ad..66d96d95 100644 --- a/numass-main/src/main/java/inr/numass/workspace/NumassFitTask.java +++ b/numass-main/src/main/java/inr/numass/workspace/NumassFitTask.java @@ -43,7 +43,7 @@ public class NumassFitTask extends SingleActionTask { @Override public void validate(TaskModel model) { - if (!model.meta().hasNode("fit")) { + if (!model.meta().hasMeta("fit")) { throw new RuntimeException("Fit element not found in model"); } } @@ -55,14 +55,14 @@ public class NumassFitTask extends SingleActionTask { @Override protected Meta transformMeta(TaskModel model) { - return model.meta().getNode("fit"); + return model.meta().getMeta("fit"); } @Override protected TaskModel transformModel(TaskModel model) { //Transmit meta as-is MetaBuilder metaBuilder = new MetaBuilder(model.meta()).removeNode("fit"); - if (model.meta().hasNode("filter")) { + if (model.meta().hasMeta("filter")) { model.dependsOn("numass.filter", metaBuilder.build(), "prepare"); } else { model.dependsOn("numass.prepare", metaBuilder.build(), "prepare"); diff --git a/numass-main/src/main/java/inr/numass/workspace/NumassPrepareTask.java b/numass-main/src/main/java/inr/numass/workspace/NumassPrepareTask.java index ef8de10a..576a08bf 100644 --- a/numass-main/src/main/java/inr/numass/workspace/NumassPrepareTask.java +++ b/numass-main/src/main/java/inr/numass/workspace/NumassPrepareTask.java @@ -57,38 +57,38 @@ public class NumassPrepareTask extends AbstractTask
{ Context context = model.getContext(); //acquiring initial data. Data node could not be empty - Meta dataMeta = config.getNode("data"); + Meta dataMeta = config.getMeta("data"); URI storageUri = input.getCheckedData("dataRoot", URI.class).get(); DataSet.Builder dataBuilder = readData(callback, context, storageUri, dataMeta); - if (config.hasNode("empty")) { - dataBuilder.putNode("empty", readData(callback, context, storageUri, config.getNode("empty")).build()); + if (config.hasMeta("empty")) { + dataBuilder.putNode("empty", readData(callback, context, storageUri, config.getMeta("empty")).build()); } DataNode data = dataBuilder.build(); //preparing table data - Meta prepareMeta = config.getNode("prepare"); + Meta prepareMeta = config.getMeta("prepare"); DataNode
tables = runAction(new PrepareDataAction(), callback, context, data, prepareMeta); - if (config.hasNode("monitor")) { - Meta monitorMeta = config.getNode("monitor"); + if (config.hasMeta("monitor")) { + Meta monitorMeta = config.getMeta("monitor"); tables = runAction(new MonitorCorrectAction(), callback, context, tables, monitorMeta); } //merging if needed - if (config.hasNode("merge")) { + if (config.hasMeta("merge")) { DataTree.Builder
resultBuilder = DataTree.builder(Table.class); DataTree.Builder
tablesForMerge = new DataTree.Builder<>(tables); //extracting empty data - if (config.hasNode("empty")) { + if (config.hasMeta("empty")) { DataNode
emptySourceNode = tables.getCheckedNode("empty", Table.class); Meta emptyMergeMeta = new MetaBuilder("emptySource").setValue("mergeName", "emptySource"); resultBuilder.putData("merge.empty", runAction(new MergeDataAction(), callback, context, emptySourceNode, emptyMergeMeta).getData()); tablesForMerge.removeNode("empty"); } - config.getNodes("merge").forEach(mergeNode -> { + config.getMetaList("merge").forEach(mergeNode -> { Meta mergeMeta = Template.compileTemplate(mergeNode, config); DataNode
mergeData = runAction(new MergeDataAction(), callback, context, tablesForMerge.build(), mergeMeta); mergeData.dataStream().forEach(d -> { @@ -158,7 +158,7 @@ public class NumassPrepareTask extends AbstractTask
{ @Override public void validate(TaskModel model) { - if (!model.meta().hasNode("data")) { + if (!model.meta().hasMeta("data")) { } } diff --git a/numass-main/src/main/java/inr/numass/workspace/NumassTableFilterTask.java b/numass-main/src/main/java/inr/numass/workspace/NumassTableFilterTask.java index 8498e4c5..c36ff2ab 100644 --- a/numass-main/src/main/java/inr/numass/workspace/NumassTableFilterTask.java +++ b/numass-main/src/main/java/inr/numass/workspace/NumassTableFilterTask.java @@ -28,7 +28,7 @@ public class NumassTableFilterTask extends SingleActionTask { @Override protected TaskModel transformModel(TaskModel model) { MetaBuilder metaBuilder = new MetaBuilder(model.meta()).removeNode("filter"); - if (model.meta().hasNode("empty")) { + if (model.meta().hasMeta("empty")) { model.dependsOn("numass.substractEmpty", metaBuilder.build(), "prepare"); } else { model.dependsOn("numass.prepare", metaBuilder.build(), "prepare"); diff --git a/numass-storage/numass-client/src/main/java/inr/numass/client/ClientUtils.java b/numass-storage/numass-client/src/main/java/inr/numass/client/ClientUtils.java new file mode 100644 index 00000000..cb2f7184 --- /dev/null +++ b/numass-storage/numass-client/src/main/java/inr/numass/client/ClientUtils.java @@ -0,0 +1,24 @@ +package inr.numass.client; + +import hep.dataforge.meta.Meta; + +import java.io.IOException; + +/** + * Created by darksnake on 09-Oct-16. + */ +public class ClientUtils { + public String getRunName(Meta config) { + if (config.hasValue("numass.run")) { + return config.getString("numass.run"); + } else if (config.hasMeta("numass.server")) { + try { + return new NumassClient(config.getMeta("numass.server")).getCurrentRun().getString("path"); + } catch (IOException e) { + return "default"; + } + } else { + return "default"; + } + } +} diff --git a/numass-storage/numass-client/src/main/java/inr/numass/client/NumassClient.java b/numass-storage/numass-client/src/main/java/inr/numass/client/NumassClient.java index a0e052b7..e2a28429 100644 --- a/numass-storage/numass-client/src/main/java/inr/numass/client/NumassClient.java +++ b/numass-storage/numass-client/src/main/java/inr/numass/client/NumassClient.java @@ -20,6 +20,7 @@ import hep.dataforge.meta.Meta; import hep.dataforge.meta.MetaBuilder; import hep.dataforge.storage.commons.MessageFactory; import hep.dataforge.storage.commons.StorageUtils; +import hep.dataforge.tables.DataPoint; import hep.dataforge.values.Value; import inr.numass.storage.NumassStorage; import org.slf4j.LoggerFactory; @@ -32,25 +33,32 @@ import java.nio.channels.FileChannel; import java.nio.file.StandardOpenOption; import java.time.Instant; import java.util.Arrays; +import java.util.Collection; import java.util.HashMap; import java.util.Map; /** * @author darksnake */ -public class NumassClient extends MessageFactory implements AutoCloseable, Responder { +public class NumassClient implements AutoCloseable, Responder { Socket socket; + MessageFactory mf = new MessageFactory(); public NumassClient(String address, int port) throws IOException { socket = new Socket(address, port); socket.setSoTimeout(300); } + + public NumassClient(Meta meta) throws IOException { + this(meta.getString("ip", "192.168.111.1"), meta.getInt("port", 8335)); + } + @Override public void close() throws IOException { if (!socket.isClosed()) { - write(terminator(), socket.getOutputStream()); + write(mf.terminator(), socket.getOutputStream()); } socket.close(); } @@ -62,7 +70,7 @@ public class NumassClient extends MessageFactory implements AutoCloseable, Respo return read(socket.getInputStream()); } catch (IOException ex) { LoggerFactory.getLogger(getClass()).error("Error in envelope exchange", ex); - return errorResponseBase(message, ex).build(); + return mf.errorResponseBase(message, ex).build(); } } @@ -76,7 +84,7 @@ public class NumassClient extends MessageFactory implements AutoCloseable, Respo } private EnvelopeBuilder requestActionBase(String type, String action) { - return requestBase(type).putMetaValue("action", action); + return mf.requestBase(type).putMetaValue("action", action); } public Meta getCurrentRun() { @@ -118,7 +126,7 @@ public class NumassClient extends MessageFactory implements AutoCloseable, Respo return StorageUtils.getErrorMeta(new FileNotFoundException(fileName)); } - Envelope bin = requestBase("numass.data") + Envelope bin = mf.requestBase("numass.data") .putMetaValue("action", "push") .putMetaValue("path", path) .putMetaValue("name", zipName) @@ -148,7 +156,7 @@ public class NumassClient extends MessageFactory implements AutoCloseable, Respo Meta response = respond(env.build()).meta(); if (response.getBoolean("success", true)) { Map res = new HashMap<>(); - response.getNodes("state").stream().forEach((stateMeta) -> { + response.getMetaList("state").stream().forEach((stateMeta) -> { res.put(stateMeta.getString("name"), stateMeta.getValue("value")); }); return res; @@ -208,5 +216,40 @@ public class NumassClient extends MessageFactory implements AutoCloseable, Respo return respond(env.build()).meta(); } + /** + * Create remote storage with given meta + * + * @param path full path relative to root storage + * @param meta + * @return + */ + public Envelope createStorage(String path, Meta meta) { + throw new UnsupportedOperationException(); + } + + /** + * Create remote loader + * + * @param shelf full path to the shelf + * @param name the name of the loader + * @param meta loader meta + * @return + */ + public Envelope createLoader(String shelf, String name, Meta meta) { + throw new UnsupportedOperationException(); + } + + /** + * Send points to existing point loader + * + * @param shelf + * @param loaderName + * @param points + * @return + */ + public Envelope sendDataPoints(String shelf, String loaderName, Collection points) { + throw new UnsupportedOperationException(); + } + } diff --git a/numass-storage/numass-server/src/main/java/inr/numass/server/NumassRun.java b/numass-storage/numass-server/src/main/java/inr/numass/server/NumassRun.java index adc589ce..c2a59dd2 100644 --- a/numass-storage/numass-server/src/main/java/inr/numass/server/NumassRun.java +++ b/numass-storage/numass-server/src/main/java/inr/numass/server/NumassRun.java @@ -135,8 +135,8 @@ public class NumassRun implements Annotated, Responder { private synchronized Envelope pushNote(Envelope message) { try { - if (message.meta().hasNode("note")) { - for (Meta node : message.meta().getNodes("note")) { + if (message.meta().hasMeta("note")) { + for (Meta node : message.meta().getMetaList("note")) { addNote(NumassNote.buildFrom(node)); } } else { diff --git a/numass-storage/numass-server/src/main/java/inr/numass/server/NumassServer.java b/numass-storage/numass-server/src/main/java/inr/numass/server/NumassServer.java index 0af79bdd..07aada1a 100644 --- a/numass-storage/numass-server/src/main/java/inr/numass/server/NumassServer.java +++ b/numass-storage/numass-server/src/main/java/inr/numass/server/NumassServer.java @@ -96,7 +96,7 @@ public class NumassServer extends AbstractNetworkListener { private void startRun(Meta annotation) throws StorageException { String path = annotation.getString("path", DEFAULT_RUN_PATH); - //Meta meta = annotation.getNode("meta", null); + //Meta meta = annotation.getMeta("meta", null); run = new NumassRun(path, NumassStorage.buildNumassStorage(root, path, false, true), getResponseFactory()); getRootState().setValue("numass.current.run", path); } diff --git a/numass-storage/numass-server/src/main/java/inr/numass/server/NumassServerDaemon.java b/numass-storage/numass-server/src/main/java/inr/numass/server/NumassServerDaemon.java index 6002a507..10b8fbb7 100644 --- a/numass-storage/numass-server/src/main/java/inr/numass/server/NumassServerDaemon.java +++ b/numass-storage/numass-server/src/main/java/inr/numass/server/NumassServerDaemon.java @@ -20,13 +20,14 @@ import hep.dataforge.meta.Annotated; import hep.dataforge.meta.Meta; import hep.dataforge.storage.commons.StorageManager; import hep.dataforge.storage.filestorage.FileStorage; -import java.io.File; import org.apache.commons.daemon.Daemon; import org.apache.commons.daemon.DaemonContext; import org.apache.commons.daemon.DaemonInitException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; + /** * A daemon wrapper for numass server * @@ -79,8 +80,8 @@ public class NumassServerDaemon implements Daemon, Annotated { String repoPath = meta().getString(NUMASS_REPO_PATH_PROPERTY, "/home/numass-storage/"); Meta repoConfig = null; - if (meta().hasNode(NUMASS_REPO_ELEMENT)) { - repoConfig = meta().getNode(NUMASS_REPO_ELEMENT); + if (meta().hasMeta(NUMASS_REPO_ELEMENT)) { + repoConfig = meta().getMeta(NUMASS_REPO_ELEMENT); } logger.info("Initializing file storage in {}", repoPath); root = FileStorage.in(new File(repoPath), repoConfig); @@ -92,8 +93,8 @@ public class NumassServerDaemon implements Daemon, Annotated { if (root != null) { root.open(); Meta listenerConfig = null; - if (meta().hasNode(LISTENER_ELEMENT)) { - listenerConfig = meta().getNode(LISTENER_ELEMENT); + if (meta().hasMeta(LISTENER_ELEMENT)) { + listenerConfig = meta().getMeta(LISTENER_ELEMENT); } listener = new NumassServer(root, listenerConfig);