Numass control room global update
This commit is contained in:
parent
b43267bded
commit
8413f48186
@ -2,7 +2,7 @@ package inr.numass.control
|
|||||||
|
|
||||||
import hep.dataforge.control.devices.Device
|
import hep.dataforge.control.devices.Device
|
||||||
import hep.dataforge.control.devices.PortSensor
|
import hep.dataforge.control.devices.PortSensor
|
||||||
import hep.dataforge.control.measurements.Sensor
|
import hep.dataforge.control.devices.Sensor
|
||||||
import hep.dataforge.fx.fragments.FXFragment
|
import hep.dataforge.fx.fragments.FXFragment
|
||||||
import hep.dataforge.fx.fragments.FragmentWindow
|
import hep.dataforge.fx.fragments.FragmentWindow
|
||||||
import hep.dataforge.storage.filestorage.FileStorage
|
import hep.dataforge.storage.filestorage.FileStorage
|
||||||
|
@ -23,7 +23,7 @@ import hep.dataforge.control.connections.Roles;
|
|||||||
import hep.dataforge.control.connections.StorageConnection;
|
import hep.dataforge.control.connections.StorageConnection;
|
||||||
import hep.dataforge.control.devices.Device;
|
import hep.dataforge.control.devices.Device;
|
||||||
import hep.dataforge.control.devices.PortSensor;
|
import hep.dataforge.control.devices.PortSensor;
|
||||||
import hep.dataforge.control.devices.SingleMeasurementDevice;
|
import hep.dataforge.control.devices.Sensor;
|
||||||
import hep.dataforge.control.devices.StateDef;
|
import hep.dataforge.control.devices.StateDef;
|
||||||
import hep.dataforge.control.measurements.AbstractMeasurement;
|
import hep.dataforge.control.measurements.AbstractMeasurement;
|
||||||
import hep.dataforge.control.ports.PortHandler;
|
import hep.dataforge.control.ports.PortHandler;
|
||||||
@ -47,6 +47,7 @@ import inr.numass.control.StorageHelper;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Alexander Nozik
|
* @author Alexander Nozik
|
||||||
@ -57,12 +58,13 @@ import java.util.*;
|
|||||||
@StateDef(name = "storing", writable = true, info = "Define if this device is currently writes to storage")
|
@StateDef(name = "storing", writable = true, info = "Define if this device is currently writes to storage")
|
||||||
@StateDef(name = "filamentOn", writable = true, info = "Mass-spectrometer filament on")
|
@StateDef(name = "filamentOn", writable = true, info = "Mass-spectrometer filament on")
|
||||||
@StateDef(name = "filamentStatus", info = "Filament status")
|
@StateDef(name = "filamentStatus", info = "Filament status")
|
||||||
public class MspDevice extends SingleMeasurementDevice<MspDevice.PeakJumpMeasurement> implements PortHandler.PortController {
|
public class MspDevice extends Sensor<DataPoint> implements PortHandler.PortController {
|
||||||
public static final String MSP_DEVICE_TYPE = "msp";
|
public static final String MSP_DEVICE_TYPE = "msp";
|
||||||
|
|
||||||
private static final int TIMEOUT = 200;
|
private static final int TIMEOUT = 200;
|
||||||
|
|
||||||
private TcpPortHandler handler;
|
private TcpPortHandler handler;
|
||||||
|
private Consumer<MspResponse> measurementDelegate;
|
||||||
|
|
||||||
public MspDevice() {
|
public MspDevice() {
|
||||||
}
|
}
|
||||||
@ -96,18 +98,21 @@ public class MspDevice extends SingleMeasurementDevice<MspDevice.PeakJumpMeasure
|
|||||||
super.shutdown();
|
super.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
protected Meta getMeasurementMeta() {
|
// protected Meta getMeasurementMeta() {
|
||||||
return meta().getMeta("peakJump");
|
// return meta().getMeta("peakJump");
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PeakJumpMeasurement createMeasurement(Meta meta) throws ControlException {
|
protected PeakJumpMeasurement createMeasurement() throws MeasurementException{
|
||||||
switch (meta.getString("type", "peakJump")) {
|
Meta measurementMeta =meta().getMeta("peakJump");
|
||||||
case "peakJump":
|
String s = measurementMeta.getString("type", "peakJump");
|
||||||
return new PeakJumpMeasurement(meta);
|
if (s.equals("peakJump")) {
|
||||||
default:
|
PeakJumpMeasurement measurement = new PeakJumpMeasurement(measurementMeta);
|
||||||
throw new ControlException("Unknown measurement type");
|
this.measurementDelegate = measurement;
|
||||||
|
return measurement;
|
||||||
|
} else {
|
||||||
|
throw new MeasurementException("Unknown measurement type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,9 +323,8 @@ public class MspDevice extends SingleMeasurementDevice<MspDevice.PeakJumpMeasure
|
|||||||
updateState("filamentStatus", status);
|
updateState("filamentStatus", status);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PeakJumpMeasurement measurement = getMeasurement();
|
if (measurementDelegate != null) {
|
||||||
if (measurement != null) {
|
measurementDelegate.accept(response);
|
||||||
measurement.eval(response);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,7 +395,7 @@ public class MspDevice extends SingleMeasurementDevice<MspDevice.PeakJumpMeasure
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PeakJumpMeasurement extends AbstractMeasurement<DataPoint> {
|
public class PeakJumpMeasurement extends AbstractMeasurement<DataPoint> implements Consumer<MspResponse> {
|
||||||
|
|
||||||
private RegularPointCollector collector = new RegularPointCollector(getAveragingDuration(), this::result);
|
private RegularPointCollector collector = new RegularPointCollector(getAveragingDuration(), this::result);
|
||||||
private StorageHelper helper = new StorageHelper(MspDevice.this, this::makeLoader);
|
private StorageHelper helper = new StorageHelper(MspDevice.this, this::makeLoader);
|
||||||
@ -486,7 +490,16 @@ public class MspDevice extends SingleMeasurementDevice<MspDevice.PeakJumpMeasure
|
|||||||
helper.push(result);
|
helper.push(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void eval(MspResponse response) {
|
void error(String errorMessage, Throwable error) {
|
||||||
|
if (error == null) {
|
||||||
|
error(new MeasurementException(errorMessage));
|
||||||
|
} else {
|
||||||
|
error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(MspResponse response) {
|
||||||
|
|
||||||
//Evaluating device state change
|
//Evaluating device state change
|
||||||
evaluateResponse(response);
|
evaluateResponse(response);
|
||||||
@ -516,14 +529,5 @@ public class MspDevice extends SingleMeasurementDevice<MspDevice.PeakJumpMeasure
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void error(String errorMessage, Throwable error) {
|
|
||||||
if (error == null) {
|
|
||||||
error(new MeasurementException(errorMessage));
|
|
||||||
} else {
|
|
||||||
error(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,10 @@ import hep.dataforge.control.collectors.ValueCollector;
|
|||||||
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.control.devices.Device;
|
import hep.dataforge.control.devices.Device;
|
||||||
|
import hep.dataforge.control.devices.Sensor;
|
||||||
import hep.dataforge.control.devices.StateDef;
|
import hep.dataforge.control.devices.StateDef;
|
||||||
import hep.dataforge.control.measurements.AbstractMeasurement;
|
import hep.dataforge.control.measurements.AbstractMeasurement;
|
||||||
import hep.dataforge.control.measurements.Measurement;
|
import hep.dataforge.control.measurements.Measurement;
|
||||||
import hep.dataforge.control.measurements.Sensor;
|
|
||||||
import hep.dataforge.exceptions.ControlException;
|
import hep.dataforge.exceptions.ControlException;
|
||||||
import hep.dataforge.exceptions.MeasurementException;
|
import hep.dataforge.exceptions.MeasurementException;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
|
@ -2,7 +2,7 @@ package inr.numass.control.readvac;
|
|||||||
|
|
||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
||||||
import hep.dataforge.control.devices.Device;
|
import hep.dataforge.control.devices.Device;
|
||||||
import hep.dataforge.control.measurements.Sensor;
|
import hep.dataforge.control.devices.Sensor;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import inr.numass.control.DeviceViewConnection;
|
import inr.numass.control.DeviceViewConnection;
|
||||||
import inr.numass.control.DeviceViewFactory;
|
import inr.numass.control.DeviceViewFactory;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package inr.numass.control.readvac.fx;
|
package inr.numass.control.readvac.fx;
|
||||||
|
|
||||||
import hep.dataforge.control.measurements.Sensor;
|
import hep.dataforge.control.devices.Sensor;
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.commons.cli.DefaultParser;
|
import org.apache.commons.cli.DefaultParser;
|
||||||
import org.apache.commons.cli.HelpFormatter;
|
import org.apache.commons.cli.HelpFormatter;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
package inr.numass.control.readvac.fx;
|
package inr.numass.control.readvac.fx;
|
||||||
|
|
||||||
import hep.dataforge.control.connections.Roles;
|
import hep.dataforge.control.connections.Roles;
|
||||||
import hep.dataforge.control.measurements.Sensor;
|
import hep.dataforge.control.devices.Sensor;
|
||||||
import hep.dataforge.control.virtual.Virtual;
|
import hep.dataforge.control.virtual.Virtual;
|
||||||
import inr.numass.control.readvac.VacCollectorDevice;
|
import inr.numass.control.readvac.VacCollectorDevice;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
|
@ -8,9 +8,9 @@ package inr.numass.control.readvac.fx;
|
|||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
||||||
import hep.dataforge.control.connections.Roles;
|
import hep.dataforge.control.connections.Roles;
|
||||||
import hep.dataforge.control.devices.Device;
|
import hep.dataforge.control.devices.Device;
|
||||||
|
import hep.dataforge.control.devices.Sensor;
|
||||||
import hep.dataforge.control.measurements.Measurement;
|
import hep.dataforge.control.measurements.Measurement;
|
||||||
import hep.dataforge.control.measurements.MeasurementListener;
|
import hep.dataforge.control.measurements.MeasurementListener;
|
||||||
import hep.dataforge.control.measurements.Sensor;
|
|
||||||
import hep.dataforge.exceptions.ControlException;
|
import hep.dataforge.exceptions.ControlException;
|
||||||
import hep.dataforge.exceptions.MeasurementException;
|
import hep.dataforge.exceptions.MeasurementException;
|
||||||
import hep.dataforge.fx.fragments.FragmentWindow;
|
import hep.dataforge.fx.fragments.FragmentWindow;
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
package inr.numass.control.readvac.fx;
|
package inr.numass.control.readvac.fx;
|
||||||
|
|
||||||
import hep.dataforge.control.devices.Device;
|
import hep.dataforge.control.devices.Device;
|
||||||
|
import hep.dataforge.control.devices.Sensor;
|
||||||
import hep.dataforge.control.measurements.Measurement;
|
import hep.dataforge.control.measurements.Measurement;
|
||||||
import hep.dataforge.control.measurements.MeasurementListener;
|
import hep.dataforge.control.measurements.MeasurementListener;
|
||||||
import hep.dataforge.control.measurements.Sensor;
|
|
||||||
import inr.numass.control.DeviceViewConnection;
|
import inr.numass.control.DeviceViewConnection;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
|
@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015 Alexander Nozik.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package inr.numass.scripts
|
|
||||||
|
|
||||||
import hep.dataforge.context.Global
|
|
||||||
import hep.dataforge.stat.fit.FitManager
|
|
||||||
import hep.dataforge.stat.fit.FitState
|
|
||||||
import hep.dataforge.stat.fit.ParamSet
|
|
||||||
import hep.dataforge.stat.models.XYModel
|
|
||||||
import hep.dataforge.tables.ListTable
|
|
||||||
import inr.numass.data.SpectrumDataAdapter
|
|
||||||
import inr.numass.data.SpectrumGenerator
|
|
||||||
import inr.numass.models.BetaSpectrum
|
|
||||||
import inr.numass.models.ModularSpectrum
|
|
||||||
import inr.numass.models.NBkgSpectrum
|
|
||||||
import inr.numass.utils.DataModelUtils
|
|
||||||
|
|
||||||
import static Global.out
|
|
||||||
import static java.util.Locale.setDefault
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Darksnake
|
|
||||||
*/
|
|
||||||
|
|
||||||
setDefault(Locale.US);
|
|
||||||
Global global = Global.instance();
|
|
||||||
// global.loadModule(new MINUITModule());
|
|
||||||
|
|
||||||
FitManager fm = new FitManager();
|
|
||||||
|
|
||||||
ModularSpectrum beta = new ModularSpectrum(new BetaSpectrum(), 9e-5, 14390d, 19001d);
|
|
||||||
beta.setCaching(false);
|
|
||||||
|
|
||||||
NBkgSpectrum spectrum = new NBkgSpectrum(beta);
|
|
||||||
XYModel model = new XYModel("tritium", spectrum, new SpectrumDataAdapter());
|
|
||||||
|
|
||||||
ParamSet allPars = new ParamSet();
|
|
||||||
|
|
||||||
allPars.setParValue("N", 3e5);
|
|
||||||
//значение 6е-6 соответствует полной интенстивности 6е7 распадов в секунду
|
|
||||||
//Проблема была в переполнении счетчика событий в генераторе. Заменил на long. Возможно стоит поставить туда число с плавающей точкой
|
|
||||||
allPars.setParError("N", 6);
|
|
||||||
allPars.setParDomain("N", 0d, Double.POSITIVE_INFINITY);
|
|
||||||
allPars.setParValue("bkg", 2d);
|
|
||||||
allPars.setParError("bkg", 0.03);
|
|
||||||
allPars.setParValue("E0", 18575.0);
|
|
||||||
allPars.setParError("E0", 2);
|
|
||||||
allPars.setParValue("mnu2", 0d);
|
|
||||||
allPars.setParError("mnu2", 1d);
|
|
||||||
allPars.setParValue("msterile2", 1000 * 1000);
|
|
||||||
allPars.setParValue("U2", 0);
|
|
||||||
allPars.setParError("U2", 1e-4);
|
|
||||||
allPars.setParDomain("U2", -1d, 1d);
|
|
||||||
allPars.setParValue("X", 0);
|
|
||||||
allPars.setParError("X", 0.01);
|
|
||||||
allPars.setParDomain("X", 0d, Double.POSITIVE_INFINITY);
|
|
||||||
allPars.setParValue("trap", 0);
|
|
||||||
allPars.setParError("trap", 0.01d);
|
|
||||||
allPars.setParDomain("trap", 0d, Double.POSITIVE_INFINITY);
|
|
||||||
|
|
||||||
// PrintNamed.printSpectrum(Global.onComplete(), spectrum, allPars, 0.0, 18700.0, 600);
|
|
||||||
//String fileName = "d:\\PlayGround\\merge\\scans.onComplete";
|
|
||||||
// String configName = "d:\\PlayGround\\SCAN.CFG";
|
|
||||||
// ListTable config = OldDataReader.readConfig(configName);
|
|
||||||
SpectrumGenerator generator = new SpectrumGenerator(model, allPars, 12316);
|
|
||||||
|
|
||||||
ListTable data = generator.generateData(DataModelUtils.getUniformSpectrumConfiguration(13500d, 18200, 1e6, 60));
|
|
||||||
|
|
||||||
// data = data.filter("X", Value.of(15510.0), Value.of(18610.0));
|
|
||||||
// allPars.setParValue("X", 0.4);
|
|
||||||
FitState state = fm.buildState(data, model, allPars);
|
|
||||||
|
|
||||||
FitState res = fm.runTask(state, "QOW", FitTask.TASK_RUN, "N", "bkg", "E0", "U2");
|
|
||||||
|
|
||||||
res.print(out());
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
|||||||
|
package inr.numass.scripts
|
||||||
|
|
||||||
|
import hep.dataforge.context.Context
|
||||||
|
import hep.dataforge.context.Global
|
||||||
|
import hep.dataforge.grind.Grind
|
||||||
|
import hep.dataforge.grind.helpers.PlotHelper
|
||||||
|
import hep.dataforge.meta.Meta
|
||||||
|
import hep.dataforge.plots.fx.FXPlotManager
|
||||||
|
import inr.numass.models.sterile.NumassResolution
|
||||||
|
import javafx.application.Platform
|
||||||
|
|
||||||
|
Context ctx = Global.instance()
|
||||||
|
ctx.pluginManager().load(FXPlotManager)
|
||||||
|
|
||||||
|
Meta meta = Grind.buildMeta("resolution", width: 8.3e-5, tail: "(0.99797 - 3.05346E-7*D - 5.45738E-10 * D**2 - 6.36105E-14 * D**3)")
|
||||||
|
|
||||||
|
PlotHelper plot = new PlotHelper(ctx);
|
||||||
|
|
||||||
|
NumassResolution resolution = new NumassResolution(ctx, meta)
|
||||||
|
|
||||||
|
plot.plot(from: 13500, to: 19000) { x ->
|
||||||
|
resolution.value(18500, x, null)
|
||||||
|
}
|
||||||
|
Platform.setImplicitExit(true)
|
||||||
|
|
@ -43,7 +43,7 @@ public class NumassResolution extends AbstractParametricBiFunction {
|
|||||||
Map<String, Object> binding = new HashMap<>();
|
Map<String, Object> binding = new HashMap<>();
|
||||||
binding.put("E", E);
|
binding.put("E", E);
|
||||||
binding.put("U", U);
|
binding.put("U", U);
|
||||||
binding.put("D", U - E);
|
binding.put("D", E - U);
|
||||||
return ExpressionUtils.function(tailFunctionStr, binding);
|
return ExpressionUtils.function(tailFunctionStr, binding);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user