Context constructors now can be called only via Global. Fixes in plugin reloading and context reusing.

This commit is contained in:
Alexander Nozik 2016-11-17 20:57:30 +03:00
parent cf6c8c0ad7
commit dd4c15f0a3
27 changed files with 108 additions and 164 deletions

View File

@ -16,13 +16,11 @@
package inr.numass.control.msp.fx; package inr.numass.control.msp.fx;
import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Level;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.Global;
import hep.dataforge.io.MetaFileReader; import hep.dataforge.io.MetaFileReader;
import hep.dataforge.io.XMLMetaReader; import hep.dataforge.io.XMLMetaReader;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.storage.commons.StorageManager; import hep.dataforge.storage.commons.StorageManager;
import java.io.File;
import java.util.Locale;
import javafx.application.Application; import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Parent; import javafx.scene.Parent;
@ -30,6 +28,9 @@ import javafx.scene.Scene;
import javafx.stage.Stage; import javafx.stage.Stage;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.Locale;
/** /**
* *
* @author darksnake * @author darksnake
@ -63,7 +64,7 @@ public class MspApp extends Application {
Parent parent = loader.load(); Parent parent = loader.load();
controller = loader.getController(); controller = loader.getController();
controller.setDeviceConfig(GlobalContext.instance(), config); controller.setDeviceConfig(Global.instance(), config);
Scene scene = new Scene(parent, 600, 400); Scene scene = new Scene(parent, 600, 400);

View File

@ -16,7 +16,7 @@
package inr.numass.control.msp.fx; package inr.numass.control.msp.fx;
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.Global;
import hep.dataforge.control.connections.Roles; import hep.dataforge.control.connections.Roles;
import hep.dataforge.control.connections.StorageConnection; import hep.dataforge.control.connections.StorageConnection;
import hep.dataforge.exceptions.ControlException; import hep.dataforge.exceptions.ControlException;
@ -174,7 +174,7 @@ public class MspViewController implements Initializable, MspListener {
} catch (IOException | URISyntaxException | ParseException ex) { } catch (IOException | URISyntaxException | ParseException ex) {
throw new Error(ex); throw new Error(ex);
} }
setDeviceConfig(GlobalContext.instance(), defaultDeviceConfig); setDeviceConfig(Global.instance(), defaultDeviceConfig);
} }
return device; return device;
} }

View File

@ -1,6 +1,6 @@
package inr.numass package inr.numass
import hep.dataforge.context.GlobalContext import hep.dataforge.context.Global
import hep.dataforge.grind.GrindShell import hep.dataforge.grind.GrindShell
import hep.dataforge.grind.GrindWorkspaceBuilder import hep.dataforge.grind.GrindWorkspaceBuilder
@ -25,5 +25,5 @@ try {
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} finally { } finally {
GlobalContext.instance().close(); Global.instance().close();
} }

View File

@ -15,7 +15,7 @@
*/ */
package inr.numass.scripts package inr.numass.scripts
import hep.dataforge.context.GlobalContext import hep.dataforge.context.Global
import hep.dataforge.stat.fit.FitManager import hep.dataforge.stat.fit.FitManager
import hep.dataforge.stat.fit.FitState import hep.dataforge.stat.fit.FitState
import hep.dataforge.stat.fit.MINUITPlugin import hep.dataforge.stat.fit.MINUITPlugin
@ -31,7 +31,7 @@ import org.apache.commons.math3.analysis.BivariateFunction
import static inr.numass.utils.OldDataReader.readData import static inr.numass.utils.OldDataReader.readData
PrintWriter out = GlobalContext.out(); PrintWriter out = Global.out();
Locale.setDefault(Locale.US); Locale.setDefault(Locale.US);
new MINUITPlugin().startGlobal(); new MINUITPlugin().startGlobal();

View File

@ -15,7 +15,7 @@
*/ */
package inr.numass.scripts package inr.numass.scripts
import hep.dataforge.context.GlobalContext import hep.dataforge.context.Global
import hep.dataforge.stat.fit.FitManager import hep.dataforge.stat.fit.FitManager
import hep.dataforge.stat.fit.FitState import hep.dataforge.stat.fit.FitState
import hep.dataforge.stat.fit.ParamSet import hep.dataforge.stat.fit.ParamSet
@ -28,7 +28,7 @@ import inr.numass.models.ModularSpectrum
import inr.numass.models.NBkgSpectrum import inr.numass.models.NBkgSpectrum
import inr.numass.utils.DataModelUtils import inr.numass.utils.DataModelUtils
import static hep.dataforge.context.GlobalContext.out import static Global.out
import static java.util.Locale.setDefault import static java.util.Locale.setDefault
/** /**
@ -37,7 +37,7 @@ import static java.util.Locale.setDefault
*/ */
setDefault(Locale.US); setDefault(Locale.US);
GlobalContext global = GlobalContext.instance(); Global global = Global.instance();
// global.loadModule(new MINUITModule()); // global.loadModule(new MINUITModule());
FitManager fm = new FitManager(); FitManager fm = new FitManager();
@ -72,7 +72,7 @@ allPars.setParValue("trap", 0);
allPars.setParError("trap", 0.01d); allPars.setParError("trap", 0.01d);
allPars.setParDomain("trap", 0d, Double.POSITIVE_INFINITY); allPars.setParDomain("trap", 0d, Double.POSITIVE_INFINITY);
// PrintNamed.printSpectrum(GlobalContext.onComplete(), spectrum, allPars, 0.0, 18700.0, 600); // PrintNamed.printSpectrum(Global.onComplete(), spectrum, allPars, 0.0, 18700.0, 600);
//String fileName = "d:\\PlayGround\\merge\\scans.onComplete"; //String fileName = "d:\\PlayGround\\merge\\scans.onComplete";
// String configName = "d:\\PlayGround\\SCAN.CFG"; // String configName = "d:\\PlayGround\\SCAN.CFG";
// ListTable config = OldDataReader.readConfig(configName); // ListTable config = OldDataReader.readConfig(configName);

View File

@ -15,7 +15,7 @@
*/ */
package inr.numass.scripts package inr.numass.scripts
import hep.dataforge.context.GlobalContext import hep.dataforge.context.Global
import hep.dataforge.meta.MetaBuilder import hep.dataforge.meta.MetaBuilder
import hep.dataforge.stat.fit.ParamSet import hep.dataforge.stat.fit.ParamSet
import inr.numass.data.SpectrumInformation import inr.numass.data.SpectrumInformation
@ -28,7 +28,7 @@ import org.apache.commons.math3.analysis.UnivariateFunction
import static java.util.Locale.setDefault import static java.util.Locale.setDefault
setDefault(Locale.US); setDefault(Locale.US);
GlobalContext global = GlobalContext.instance(); Global global = Global.instance();
// global.loadModule(new MINUIT()); // global.loadModule(new MINUIT());
// FitManager fm = new FitManager("data 2013"); // FitManager fm = new FitManager("data 2013");
@ -83,7 +83,7 @@ SpectrumInformation sign = new SpectrumInformation(spectrum);
// PrintNamed.printNamedMatrix(Out.out, infoMatrix); // PrintNamed.printNamedMatrix(Out.out, infoMatrix);
// NamedMatrix cov = sign.getExpetedCovariance(allPars, config,"U2","E0","N"); // NamedMatrix cov = sign.getExpetedCovariance(allPars, config,"U2","E0","N");
// //
// PrintWriter onComplete = GlobalContext.onComplete(); // PrintWriter onComplete = Global.onComplete();
// //
// printNamedMatrix(out, cov); // printNamedMatrix(out, cov);
// //

View File

@ -29,7 +29,7 @@ import inr.numass.models.NBkgSpectrum
import inr.numass.utils.DataModelUtils import inr.numass.utils.DataModelUtils
import inr.numass.utils.TritiumUtils import inr.numass.utils.TritiumUtils
import static hep.dataforge.context.GlobalContext.out import static hep.dataforge.context.Global.out
import static java.util.Locale.setDefault import static java.util.Locale.setDefault
/** /**
@ -73,7 +73,7 @@ allPars.setParValue("trap", 1d);
allPars.setParError("trap", 0.01d); allPars.setParError("trap", 0.01d);
allPars.setParDomain("trap", 0d, Double.POSITIVE_INFINITY); allPars.setParDomain("trap", 0d, Double.POSITIVE_INFINITY);
// PrintNamed.printSpectrum(GlobalContext.onComplete(), spectrum, allPars, 0.0, 18700.0, 600); // PrintNamed.printSpectrum(Global.onComplete(), spectrum, allPars, 0.0, 18700.0, 600);
//String fileName = "d:\\PlayGround\\merge\\scans.onComplete"; //String fileName = "d:\\PlayGround\\merge\\scans.onComplete";
// String configName = "d:\\PlayGround\\SCAN.CFG"; // String configName = "d:\\PlayGround\\SCAN.CFG";
// ListTable config = OldDataReader.readConfig(configName); // ListTable config = OldDataReader.readConfig(configName);

View File

@ -15,7 +15,7 @@
*/ */
package inr.numass.scripts package inr.numass.scripts
import hep.dataforge.context.GlobalContext import hep.dataforge.context.Global
import hep.dataforge.io.FittingIOUtils import hep.dataforge.io.FittingIOUtils
import hep.dataforge.stat.fit.FitManager import hep.dataforge.stat.fit.FitManager
import hep.dataforge.stat.fit.ParamSet import hep.dataforge.stat.fit.ParamSet
@ -27,7 +27,7 @@ import inr.numass.models.NBkgSpectrum
import static java.util.Locale.setDefault import static java.util.Locale.setDefault
setDefault(Locale.US); setDefault(Locale.US);
GlobalContext global = GlobalContext.instance(); Global global = Global.instance();
// global.loadModule(new MINUITModule()); // global.loadModule(new MINUITModule());
FitManager fm = new FitManager(); FitManager fm = new FitManager();

View File

@ -15,7 +15,7 @@
*/ */
package inr.numass.scripts package inr.numass.scripts
import hep.dataforge.context.GlobalContext import hep.dataforge.context.Global
import hep.dataforge.grind.GrindMetaBuilder import hep.dataforge.grind.GrindMetaBuilder
import hep.dataforge.io.FittingIOUtils import hep.dataforge.io.FittingIOUtils
import hep.dataforge.meta.Meta import hep.dataforge.meta.Meta
@ -60,7 +60,7 @@ allPars.setPar("U2", 0.0, 1e-4, -1d, 1d);
allPars.setPar("X", 0.04, 0.01, 0d, Double.POSITIVE_INFINITY); allPars.setPar("X", 0.04, 0.01, 0d, Double.POSITIVE_INFINITY);
allPars.setPar("trap", 1.634, 0.01,0d, Double.POSITIVE_INFINITY); allPars.setPar("trap", 1.634, 0.01,0d, Double.POSITIVE_INFINITY);
FittingIOUtils.printSpectrum(GlobalContext.out(), spectrum, allPars, 14000, 18600.0, 400); FittingIOUtils.printSpectrum(Global.out(), spectrum, allPars, 14000, 18600.0, 400);
//SpectrumGenerator generator = new SpectrumGenerator(model, allPars, 12316); //SpectrumGenerator generator = new SpectrumGenerator(model, allPars, 12316);
// //

View File

@ -15,7 +15,10 @@
*/ */
package inr.numass.scripts package inr.numass.scripts
import hep.dataforge.stat.fit.* import hep.dataforge.stat.fit.FitManager
import hep.dataforge.stat.fit.FitState
import hep.dataforge.stat.fit.MINUITPlugin
import hep.dataforge.stat.fit.ParamSet
import hep.dataforge.stat.models.XYModel import hep.dataforge.stat.models.XYModel
import hep.dataforge.tables.ListTable import hep.dataforge.tables.ListTable
import inr.numass.data.SpectrumDataAdapter import inr.numass.data.SpectrumDataAdapter
@ -26,7 +29,7 @@ import inr.numass.models.NBkgSpectrum
import inr.numass.models.ResolutionFunction import inr.numass.models.ResolutionFunction
import inr.numass.utils.DataModelUtils import inr.numass.utils.DataModelUtils
import static hep.dataforge.context.GlobalContext.out import static hep.dataforge.context.Global.out
import static java.util.Locale.setDefault import static java.util.Locale.setDefault
/** /**

View File

@ -15,7 +15,10 @@
*/ */
package inr.numass.scripts package inr.numass.scripts
import hep.dataforge.stat.fit.* import hep.dataforge.stat.fit.FitManager
import hep.dataforge.stat.fit.FitState
import hep.dataforge.stat.fit.MINUITPlugin
import hep.dataforge.stat.fit.ParamSet
import hep.dataforge.stat.models.XYModel import hep.dataforge.stat.models.XYModel
import hep.dataforge.tables.ListTable import hep.dataforge.tables.ListTable
import inr.numass.data.SpectrumDataAdapter import inr.numass.data.SpectrumDataAdapter
@ -27,7 +30,7 @@ import inr.numass.models.ResolutionFunction
import inr.numass.utils.DataModelUtils import inr.numass.utils.DataModelUtils
import org.apache.commons.math3.analysis.BivariateFunction import org.apache.commons.math3.analysis.BivariateFunction
import static hep.dataforge.context.GlobalContext.out import static hep.dataforge.context.Global.out
import static java.util.Locale.setDefault import static java.util.Locale.setDefault
/** /**
@ -76,7 +79,7 @@ ListTable data = generator.generateData(DataModelUtils.getUniformSpectrumConfigu
// data = data.filter("X", Value.of(15510.0), Value.of(18610.0)); // data = data.filter("X", Value.of(15510.0), Value.of(18610.0));
allPars.setParValue("U2", 0); allPars.setParValue("U2", 0);
FitState state = new FitState(data, model, allPars); FitState state = new FitState(data, model, allPars);
//new PlotFitResultAction(GlobalContext.instance(), null).runOne(state); //new PlotFitResultAction(Global.instance(), null).runOne(state);
//double delta = 4e-6; //double delta = 4e-6;

View File

@ -15,7 +15,7 @@
*/ */
package inr.numass.scripts package inr.numass.scripts
import hep.dataforge.context.GlobalContext import hep.dataforge.context.Global
import hep.dataforge.data.DataSet import hep.dataforge.data.DataSet
import hep.dataforge.stat.fit.FitManager import hep.dataforge.stat.fit.FitManager
import hep.dataforge.stat.fit.FitState import hep.dataforge.stat.fit.FitState
@ -31,7 +31,7 @@ import inr.numass.models.NBkgSpectrum
import static hep.dataforge.maths.RandomUtils.setSeed import static hep.dataforge.maths.RandomUtils.setSeed
import static inr.numass.utils.DataModelUtils.getUniformSpectrumConfiguration import static inr.numass.utils.DataModelUtils.getUniformSpectrumConfiguration
PrintWriter out = GlobalContext.out(); PrintWriter out = Global.out();
FitManager fm = new FitManager(); FitManager fm = new FitManager();
setSeed(543982); setSeed(543982);

View File

@ -32,7 +32,7 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.Locale; import java.util.Locale;
import static hep.dataforge.context.GlobalContext.out; import static hep.dataforge.context.Global.out;
import static inr.numass.Numass.printDescription; import static inr.numass.Numass.printDescription;
import static java.util.Locale.setDefault; import static java.util.Locale.setDefault;

View File

@ -17,7 +17,7 @@ package inr.numass;
import hep.dataforge.actions.ActionManager; import hep.dataforge.actions.ActionManager;
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.Global;
import hep.dataforge.description.ActionDescriptor; import hep.dataforge.description.ActionDescriptor;
import hep.dataforge.description.DescriptorFormatter; import hep.dataforge.description.DescriptorFormatter;
import hep.dataforge.description.DescriptorUtils; import hep.dataforge.description.DescriptorUtils;
@ -34,14 +34,13 @@ import java.io.PrintWriter;
public class Numass { public class Numass {
public static Context buildContext(Context parent, Meta meta) { public static Context buildContext(Context parent, Meta meta) {
Context numassContext = new Context(parent, "numass", meta); Context numassContext = Global.getContext("numass").withParent(parent).withProperties(meta);
GlobalContext.registerContext(numassContext);
numassContext.pluginManager().loadPlugin("inr.numass:numass"); numassContext.pluginManager().loadPlugin("inr.numass:numass");
return numassContext; return numassContext;
} }
public static Context buildContext() { public static Context buildContext() {
return buildContext(GlobalContext.instance(), Meta.empty()); return buildContext(Global.instance(), Meta.empty());
} }
public static void printDescription(Context context, boolean allowANSI) throws DescriptorException { public static void printDescription(Context context, boolean allowANSI) throws DescriptorException {

View File

@ -5,7 +5,8 @@
*/ */
package inr.numass; package inr.numass;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.Global;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -19,7 +20,7 @@ import java.util.Properties;
public class NumassProperties { public class NumassProperties {
private static File getNumassPropertiesFile() throws IOException { private static File getNumassPropertiesFile() throws IOException {
File file = new File(GlobalContext.instance().getUserDirectory(), "numass"); File file = new File(Global.instance().getUserDirectory(), "numass");
if (!file.exists()) { if (!file.exists()) {
file.mkdirs(); file.mkdirs();
} }
@ -48,7 +49,7 @@ public class NumassProperties {
props.setProperty(key, value); props.setProperty(key, value);
props.store(new FileOutputStream(store), ""); props.store(new FileOutputStream(store), "");
} catch (IOException ex) { } catch (IOException ex) {
GlobalContext.instance().getLogger().error("Failed to save numass properties", ex); Global.instance().getLogger().error("Failed to save numass properties", ex);
} }
} }
} }

View File

@ -1,31 +1,33 @@
/* /*
* Copyright 2015 Alexander Nozik. * Copyright 2015 Alexander Nozik.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package inr.numass.data; package inr.numass.data;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.Global;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException; import java.text.ParseException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import static java.time.temporal.ChronoUnit.SECONDS;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static java.time.temporal.ChronoUnit.SECONDS;
/** /**
* Заплатка для задания поправки на масс-спектрометр * Заплатка для задания поправки на масс-спектрометр
* *
@ -37,7 +39,7 @@ public class MonitorCorrector {
private final List<MonitorPoint> list; private final List<MonitorPoint> list;
public MonitorCorrector(String path) throws ParseException, IOException { public MonitorCorrector(String path) throws ParseException, IOException {
this(GlobalContext.instance().io().getFile(path)); this(Global.instance().io().getFile(path));
} }
public MonitorCorrector(File monitorFile) throws ParseException, IOException { public MonitorCorrector(File monitorFile) throws ParseException, IOException {

View File

@ -18,19 +18,18 @@ package inr.numass.data;
import hep.dataforge.stat.fit.ParamSet; import hep.dataforge.stat.fit.ParamSet;
import hep.dataforge.stat.models.Generator; import hep.dataforge.stat.models.Generator;
import hep.dataforge.stat.models.XYModel; import hep.dataforge.stat.models.XYModel;
import static hep.dataforge.maths.RandomUtils.getDefaultRandomGenerator;
import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.DataPoint;
import hep.dataforge.tables.ListTable; import hep.dataforge.tables.ListTable;
import hep.dataforge.tables.Table; import hep.dataforge.tables.Table;
import static java.lang.Double.isNaN;
import static java.lang.Math.sqrt;
import java.util.Iterator;
import org.apache.commons.math3.random.JDKRandomGenerator; import org.apache.commons.math3.random.JDKRandomGenerator;
import org.apache.commons.math3.random.RandomDataGenerator; import org.apache.commons.math3.random.RandomDataGenerator;
import org.apache.commons.math3.random.RandomGenerator; import org.apache.commons.math3.random.RandomGenerator;
import java.util.Iterator;
import static hep.dataforge.maths.RandomUtils.getDefaultRandomGenerator;
import static java.lang.Double.isNaN; import static java.lang.Double.isNaN;
import static java.lang.Double.isNaN; import static java.lang.Math.sqrt;
import static java.lang.Double.isNaN;
/** /**
* Генератор наборов данных для спектров. На входе требуется набор данных, * Генератор наборов данных для спектров. На входе требуется набор данных,
@ -145,7 +144,7 @@ public class SpectrumGenerator implements Generator {
// private double getSigma(DataPoint point) { // private double getSigma(DataPoint point) {
// if (!point.containsName("time")) { // if (!point.containsName("time")) {
// GlobalContext.instance().logString("SpectrumGenerator : Neither point error nor time is defined. Suspected wrong error bars for data."); // Global.instance().logString("SpectrumGenerator : Neither point error nor time is defined. Suspected wrong error bars for data.");
// } // }
// return sqrt(this.getMu(point)); // return sqrt(this.getMu(point));
// } // }

View File

@ -15,82 +15,19 @@
*/ */
package inr.numass.models; package inr.numass.models;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.Global;
import hep.dataforge.exceptions.NameNotFoundException; import hep.dataforge.exceptions.NameNotFoundException;
import hep.dataforge.stat.parametric.AbstractParametricFunction; import hep.dataforge.stat.parametric.AbstractParametricFunction;
import hep.dataforge.stat.parametric.ParametricFunction; import hep.dataforge.stat.parametric.ParametricFunction;
import static hep.dataforge.names.NamedUtils.combineNamesWithEquals;
import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.NamedValueSet;
import hep.dataforge.values.ValueProvider; import hep.dataforge.values.ValueProvider;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Math.exp;
import static java.lang.Math.sqrt;
import org.apache.commons.math3.analysis.UnivariateFunction; import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.analysis.integration.SimpsonIntegrator; import org.apache.commons.math3.analysis.integration.SimpsonIntegrator;
import org.apache.commons.math3.analysis.integration.UnivariateIntegrator; import org.apache.commons.math3.analysis.integration.UnivariateIntegrator;
import static hep.dataforge.names.NamedUtils.combineNamesWithEquals;
import static java.lang.Double.isNaN; import static java.lang.Double.isNaN;
import static java.lang.Math.abs; import static java.lang.Math.*;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
/** /**
* *
@ -131,7 +68,7 @@ public class GaussResolution extends AbstractParametricFunction implements Trans
@Override @Override
public ParametricFunction getConvolutedSpectrum(final RangedNamedSetSpectrum bare) { public ParametricFunction getConvolutedSpectrum(final RangedNamedSetSpectrum bare) {
return new AbstractParametricFunction(combineNamesWithEquals(this.namesAsArray(), bare.namesAsArray())) { return new AbstractParametricFunction(combineNamesWithEquals(this.namesAsArray(), bare.namesAsArray())) {
int maxEval = GlobalContext.instance().getInt("INTEGR_POINTS", 500); int maxEval = Global.instance().getInt("INTEGR_POINTS", 500);
@Override @Override
public double derivValue(String parName, double x, NamedValueSet set) { public double derivValue(String parName, double x, NamedValueSet set) {

View File

@ -6,7 +6,7 @@
package inr.numass.models.sterile; package inr.numass.models.sterile;
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.Global;
import hep.dataforge.description.NodeDef; import hep.dataforge.description.NodeDef;
import hep.dataforge.description.ValueDef; import hep.dataforge.description.ValueDef;
import hep.dataforge.exceptions.NotDefinedException; import hep.dataforge.exceptions.NotDefinedException;
@ -79,11 +79,11 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction {
} }
public SterileNeutrinoSpectrum(Meta configuration) { public SterileNeutrinoSpectrum(Meta configuration) {
this(GlobalContext.instance(), configuration); this(Global.instance(), configuration);
} }
public SterileNeutrinoSpectrum() { public SterileNeutrinoSpectrum() {
this(GlobalContext.instance(), Meta.empty()); this(Global.instance(), Meta.empty());
} }
@Override @Override

View File

@ -15,18 +15,20 @@
*/ */
package inr.numass.utils; package inr.numass.utils;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.Global;
import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.DataPoint;
import hep.dataforge.tables.ListTable; 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 inr.numass.data.SpectrumDataAdapter; import inr.numass.data.SpectrumDataAdapter;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.Locale; import java.util.Locale;
import static java.util.Locale.setDefault;
import java.util.Scanner; import java.util.Scanner;
import static java.util.Locale.setDefault;
/** /**
* *
* @author Darksnake * @author Darksnake
@ -36,7 +38,7 @@ public class OldDataReader {
public static Table readConfig(String path) throws FileNotFoundException { public static Table readConfig(String path) throws FileNotFoundException {
String[] list = {"X", "time", "ushift"}; String[] list = {"X", "time", "ushift"};
ListTable.Builder res = new ListTable.Builder(list); ListTable.Builder res = new ListTable.Builder(list);
File file = GlobalContext.instance().io().getFile(path); File file = Global.instance().io().getFile(path);
Scanner sc = new Scanner(file); Scanner sc = new Scanner(file);
sc.nextLine(); sc.nextLine();
@ -58,7 +60,7 @@ public class OldDataReader {
public static Table readData(String path, double Elow) { public static Table readData(String path, double Elow) {
SpectrumDataAdapter factory = new SpectrumDataAdapter(); SpectrumDataAdapter factory = new SpectrumDataAdapter();
ListTable.Builder res = new ListTable.Builder(factory.getFormat()); ListTable.Builder res = new ListTable.Builder(factory.getFormat());
File file = GlobalContext.instance().io().getFile(path); File file = Global.instance().io().getFile(path);
double x; double x;
int count; int count;
int time; int time;
@ -110,7 +112,7 @@ public class OldDataReader {
public static Table readDataAsGun(String path, double Elow) { public static Table readDataAsGun(String path, double Elow) {
SpectrumDataAdapter factory = new SpectrumDataAdapter(); SpectrumDataAdapter factory = new SpectrumDataAdapter();
ListTable.Builder res = new ListTable.Builder(factory.getFormat()); ListTable.Builder res = new ListTable.Builder(factory.getFormat());
File file = GlobalContext.instance().io().getFile(path); File file = Global.instance().io().getFile(path);
double x; double x;
long count; long count;
int time; int time;
@ -143,7 +145,7 @@ public class OldDataReader {
public static Table readSpectrumData(String path) { public static Table readSpectrumData(String path) {
SpectrumDataAdapter factory = new SpectrumDataAdapter(); SpectrumDataAdapter factory = new SpectrumDataAdapter();
ListTable.Builder res = new ListTable.Builder(factory.getFormat()); ListTable.Builder res = new ListTable.Builder(factory.getFormat());
File file = GlobalContext.instance().io().getFile(path); File file = Global.instance().io().getFile(path);
double x; double x;
double count; double count;
double time; double time;

View File

@ -10,7 +10,7 @@ import hep.dataforge.actions.ActionManager;
import hep.dataforge.actions.ActionStateListener; import hep.dataforge.actions.ActionStateListener;
import hep.dataforge.actions.ActionUtils; import hep.dataforge.actions.ActionUtils;
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.Global;
import hep.dataforge.data.DataNode; import hep.dataforge.data.DataNode;
import hep.dataforge.data.FileDataFactory; import hep.dataforge.data.FileDataFactory;
import hep.dataforge.description.ActionDescriptor; import hep.dataforge.description.ActionDescriptor;
@ -367,13 +367,13 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
} catch (Exception ex) { } catch (Exception ex) {
if (ex instanceof java.util.concurrent.CancellationException) { if (ex instanceof java.util.concurrent.CancellationException) {
//cach cancelation exception //cach cancelation exception
GlobalContext.instance().getLogger().info("Interrupted by user"); Global.instance().getLogger().info("Interrupted by user");
Platform.runLater(() -> { Platform.runLater(() -> {
statusBar.setText("Execution interrupted by user"); statusBar.setText("Execution interrupted by user");
}); });
} else { } else {
//cach all other exceptions //cach all other exceptions
GlobalContext.instance().getLogger().error("Exception while executing action chain", ex); Global.instance().getLogger().error("Exception while executing action chain", ex);
ex.printStackTrace(System.err); ex.printStackTrace(System.err);
Platform.runLater(() -> { Platform.runLater(() -> {
//printing stack trace to the default output //printing stack trace to the default output

View File

@ -5,7 +5,7 @@
*/ */
package inr.numass.workbench; package inr.numass.workbench;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.Global;
import inr.numass.Numass; import inr.numass.Numass;
import javafx.application.Application; import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
@ -55,7 +55,7 @@ public class Workbench extends Application {
@Override @Override
public void stop() throws Exception { public void stop() throws Exception {
GlobalContext.instance().close(); Global.instance().close();
super.stop(); super.stop();
} }

View File

@ -15,7 +15,7 @@
*/ */
package inr.numass.models; package inr.numass.models;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.Global;
import hep.dataforge.plots.data.PlottableData; import hep.dataforge.plots.data.PlottableData;
import hep.dataforge.plots.data.PlottableXYFunction; import hep.dataforge.plots.data.PlottableXYFunction;
import hep.dataforge.plots.jfreechart.JFreeChartFrame; import hep.dataforge.plots.jfreechart.JFreeChartFrame;
@ -30,7 +30,7 @@ public class TransmissionInterpolatorTest {
public static void main(String[] args) { public static void main(String[] args) {
JFreeChartFrame frame = NumassPlugin.displayJFreeChart("TransmissionInterpolatorTest", null); JFreeChartFrame frame = NumassPlugin.displayJFreeChart("TransmissionInterpolatorTest", null);
//JFreeChartFrame.drawFrame("TransmissionInterpolatorTest", null); //JFreeChartFrame.drawFrame("TransmissionInterpolatorTest", null);
TransmissionInterpolator interpolator = TransmissionInterpolator.fromFile(GlobalContext.instance(), TransmissionInterpolator interpolator = TransmissionInterpolator.fromFile(Global.instance(),
"d:\\sterile-new\\loss2014-11\\.dataforge\\merge\\empty_sum.onComplete", "Uset", "CR", 15, 0.8, 19002d); "d:\\sterile-new\\loss2014-11\\.dataforge\\merge\\empty_sum.onComplete", "Uset", "CR", 15, 0.8, 19002d);
frame.add(PlottableData.plot("data", interpolator.getX(), interpolator.getY())); frame.add(PlottableData.plot("data", interpolator.getX(), interpolator.getY()));
frame.add(PlottableXYFunction.plotFunction("interpolated", x->interpolator.value(x), interpolator.getXmin(), interpolator.getXmax(), 2000)); frame.add(PlottableXYFunction.plotFunction("interpolated", x->interpolator.value(x), interpolator.getXmin(), interpolator.getXmax(), 2000));

View File

@ -15,7 +15,7 @@
*/ */
package inr.numass.storage; package inr.numass.storage;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.Global;
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.ColumnedDataReader; import hep.dataforge.io.ColumnedDataReader;
@ -147,7 +147,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
private static Envelope readFile(FileObject file) { private static Envelope readFile(FileObject file) {
//VFS file reading seems to work basly in parallel //VFS file reading seems to work basly in parallel
synchronized (GlobalContext.instance()) { synchronized (Global.instance()) {
String fileName = file.getName().getBaseName(); String fileName = file.getName().getBaseName();
if (fileName.equals(META_FRAGMENT_NAME) if (fileName.equals(META_FRAGMENT_NAME)
|| fileName.equals(HV_FRAGMENT_NAME) || fileName.equals(HV_FRAGMENT_NAME)

View File

@ -6,13 +6,9 @@
package inr.numass.storage; package inr.numass.storage;
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.Global;
import java.io.File;
import java.io.FileInputStream; import java.io.*;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
@ -32,7 +28,7 @@ public class SetDirectionUtility {
static synchronized boolean isReversed(String setName, Function<String, Boolean> provider) { static synchronized boolean isReversed(String setName, Function<String, Boolean> provider) {
if (!isLoaded) { if (!isLoaded) {
load(GlobalContext.instance()); load(Global.instance());
} }
return directionMap.computeIfAbsent(setName, provider); return directionMap.computeIfAbsent(setName, provider);
} }

View File

@ -17,7 +17,7 @@ package inr.numass.viewer;
import hep.dataforge.computation.ProgressCallback; import hep.dataforge.computation.ProgressCallback;
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.Global;
import hep.dataforge.exceptions.StorageException; import hep.dataforge.exceptions.StorageException;
import hep.dataforge.fx.fragments.FragmentWindow; import hep.dataforge.fx.fragments.FragmentWindow;
import hep.dataforge.fx.fragments.LogFragment; import hep.dataforge.fx.fragments.LogFragment;
@ -104,7 +104,7 @@ public class MainViewerController implements Initializable {
LogFragment logFragment = new LogFragment(); LogFragment logFragment = new LogFragment();
logFragment.hookStd(); logFragment.hookStd();
new FragmentWindow(logFragment).bindTo(consoleButton); new FragmentWindow(logFragment).bindTo(consoleButton);
new FragmentWindow(WorkManagerFragment.attachToContext(GlobalContext.instance())).bindTo(processManagerButton); new FragmentWindow(WorkManagerFragment.attachToContext(Global.instance())).bindTo(processManagerButton);
mspController = new MspViewController(getContext()); mspController = new MspViewController(getContext());
this.mspTab.setContent(mspController.getRoot()); this.mspTab.setContent(mspController.getRoot());
@ -148,7 +148,7 @@ public class MainViewerController implements Initializable {
} }
private Context getContext() { private Context getContext() {
return GlobalContext.instance(); return Global.instance();
} }
public void setRootStorage(NumassStorage root) { public void setRootStorage(NumassStorage root) {

View File

@ -15,15 +15,16 @@
*/ */
package inr.numass.viewer; package inr.numass.viewer;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.Global;
import hep.dataforge.storage.commons.StorageManager; import hep.dataforge.storage.commons.StorageManager;
import inr.numass.storage.NumassDataLoader; import inr.numass.storage.NumassDataLoader;
import java.io.File;
import java.io.IOException;
import javafx.application.Application; import javafx.application.Application;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.stage.Stage; import javafx.stage.Stage;
import java.io.File;
import java.io.IOException;
/** /**
* *
* @author darksnake * @author darksnake
@ -37,7 +38,7 @@ public class TestDirectoryViewer extends Application {
NumassDataLoader reader = NumassDataLoader.fromLocalDir(null, new File("C:\\Users\\darksnake\\Dropbox\\PlayGround\\data-test\\20150703143643_1\\")); NumassDataLoader reader = NumassDataLoader.fromLocalDir(null, new File("C:\\Users\\darksnake\\Dropbox\\PlayGround\\data-test\\20150703143643_1\\"));
// NumassLoader reader = NumassLoader.fromZip(null, new File("C:\\Users\\darksnake\\Dropbox\\PlayGround\\data-test\\20150703143643_1.zip")); // NumassLoader reader = NumassLoader.fromZip(null, new File("C:\\Users\\darksnake\\Dropbox\\PlayGround\\data-test\\20150703143643_1.zip"));
NumassLoaderViewComponent comp = new NumassLoaderViewComponent(GlobalContext.instance()); NumassLoaderViewComponent comp = new NumassLoaderViewComponent(Global.instance());
comp.loadData(reader); comp.loadData(reader);
// FXMLLoader fxml = new FXMLLoader(getClass().getResource("/fxml/DirectoryViewer.fxml")); // FXMLLoader fxml = new FXMLLoader(getClass().getResource("/fxml/DirectoryViewer.fxml"));
// //