Vac in progress
This commit is contained in:
parent
b027f9b7e7
commit
75bb7a9876
@ -10,7 +10,7 @@ if (!hasProperty('mainClass')) {
|
||||
}
|
||||
mainClassName = mainClass
|
||||
|
||||
version = "0.1.2";
|
||||
version = "0.2.0";
|
||||
|
||||
//mainClassName = "inr.numass.readvac.Main"
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package inr.numass.readvac.devices;
|
||||
package inr.numass.readvac;
|
||||
|
||||
import hep.dataforge.context.Context;
|
||||
import hep.dataforge.control.devices.PortSensor;
|
@ -3,7 +3,7 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package inr.numass.readvac.devices;
|
||||
package inr.numass.readvac;
|
||||
|
||||
import hep.dataforge.context.Context;
|
||||
import hep.dataforge.control.devices.PortSensor;
|
@ -3,16 +3,18 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package inr.numass.readvac.devices;
|
||||
package inr.numass.readvac;
|
||||
|
||||
import hep.dataforge.context.Context;
|
||||
import hep.dataforge.control.devices.PortSensor;
|
||||
import hep.dataforge.control.devices.annotations.StateDef;
|
||||
import hep.dataforge.control.measurements.Measurement;
|
||||
import hep.dataforge.control.measurements.SimpleMeasurement;
|
||||
import hep.dataforge.control.ports.PortHandler;
|
||||
import hep.dataforge.description.ValueDef;
|
||||
import hep.dataforge.exceptions.ControlException;
|
||||
import hep.dataforge.meta.Meta;
|
||||
import hep.dataforge.values.Value;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.adapter.JavaBeanBooleanPropertyBuilder;
|
||||
|
||||
@ -20,12 +22,12 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alexander Nozik
|
||||
*/
|
||||
@ValueDef(name = "address", def = "253")
|
||||
@ValueDef(name = "channel", def = "5")
|
||||
@ValueDef(name = "powerButton", type = "BOOLEAN", def = "true")
|
||||
@StateDef(name = "power", writable = true, info = "Device powered up")
|
||||
public class MKSVacDevice extends PortSensor<Double> {
|
||||
|
||||
public MKSVacDevice() {
|
||||
@ -71,7 +73,7 @@ public class MKSVacDevice extends PortSensor<Double> {
|
||||
return null;
|
||||
}
|
||||
switch (stateName) {
|
||||
case "connection":
|
||||
case CONNECTION_STATE:
|
||||
return !talk("T?").isEmpty();
|
||||
case "power":
|
||||
return talk("FP?").equals("ON");
|
||||
@ -81,15 +83,17 @@ public class MKSVacDevice extends PortSensor<Double> {
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void command(String commandName, Value argument) throws ControlException {
|
||||
// if (commandName.equals("setPower")) {
|
||||
// boolean powerOn = argument.booleanValue();
|
||||
// setPowerOn(powerOn);
|
||||
// } else {
|
||||
// super.command(commandName, argument);
|
||||
// }
|
||||
// }
|
||||
@Override
|
||||
protected void requestStateChange(String stateName, Value value) throws ControlException {
|
||||
switch (stateName) {
|
||||
case "power":
|
||||
setPowerOn(value.booleanValue());
|
||||
break;
|
||||
default:
|
||||
super.requestStateChange(stateName, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() throws ControlException {
|
||||
@ -97,8 +101,7 @@ public class MKSVacDevice extends PortSensor<Double> {
|
||||
super.shutdown();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean isPowerOn() {
|
||||
return getState("power").booleanValue();
|
||||
}
|
||||
@ -150,21 +153,21 @@ public class MKSVacDevice extends PortSensor<Double> {
|
||||
@Override
|
||||
protected synchronized Double doMeasure() throws Exception {
|
||||
// if (getState("power").booleanValue()) {
|
||||
String answer = talk("PR" + getChannel() + "?");
|
||||
if (answer == null || answer.isEmpty()) {
|
||||
invalidateState(CONNECTION_STATE);
|
||||
this.progressUpdate("No connection");
|
||||
return null;
|
||||
}
|
||||
double res = Double.parseDouble(answer);
|
||||
if (res <= 0) {
|
||||
this.progressUpdate("No power");
|
||||
invalidateState("power");
|
||||
return null;
|
||||
} else {
|
||||
this.progressUpdate("OK");
|
||||
return res;
|
||||
}
|
||||
String answer = talk("PR" + getChannel() + "?");
|
||||
if (answer == null || answer.isEmpty()) {
|
||||
invalidateState(CONNECTION_STATE);
|
||||
this.progressUpdate("No connection");
|
||||
return null;
|
||||
}
|
||||
double res = Double.parseDouble(answer);
|
||||
if (res <= 0) {
|
||||
this.progressUpdate("No power");
|
||||
invalidateState("power");
|
||||
return null;
|
||||
} else {
|
||||
this.progressUpdate("OK");
|
||||
return res;
|
||||
}
|
||||
// } else {
|
||||
// return null;
|
||||
// }
|
@ -3,7 +3,7 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package inr.numass.readvac.devices;
|
||||
package inr.numass.readvac;
|
||||
|
||||
import hep.dataforge.context.Context;
|
||||
import hep.dataforge.control.devices.PortSensor;
|
@ -3,7 +3,7 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package inr.numass.readvac.devices;
|
||||
package inr.numass.readvac;
|
||||
|
||||
import hep.dataforge.control.collectors.PointCollector;
|
||||
import hep.dataforge.control.collectors.ValueCollector;
|
@ -1,163 +0,0 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package inr.numass.readvac.app;
|
||||
|
||||
import hep.dataforge.context.Context;
|
||||
import hep.dataforge.context.Global;
|
||||
import hep.dataforge.control.measurements.Sensor;
|
||||
import hep.dataforge.exceptions.StorageException;
|
||||
import hep.dataforge.io.MetaFileReader;
|
||||
import hep.dataforge.meta.Meta;
|
||||
import hep.dataforge.meta.MetaBuilder;
|
||||
import hep.dataforge.storage.api.PointLoader;
|
||||
import hep.dataforge.storage.api.Storage;
|
||||
import hep.dataforge.storage.commons.LoaderFactory;
|
||||
import hep.dataforge.tables.TableFormatBuilder;
|
||||
import hep.dataforge.values.ValueType;
|
||||
import inr.numass.client.ClientUtils;
|
||||
import inr.numass.readvac.devices.*;
|
||||
import inr.numass.readvac.fx.VacCollectorController;
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author Alexander Nozik
|
||||
*/
|
||||
public class ReadVac extends Application {
|
||||
|
||||
VacCollectorController controller;
|
||||
Logger logger = LoggerFactory.getLogger("ReadVac");
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
String configFileName = getParameters().getNamed().get("config");
|
||||
if (configFileName == null) {
|
||||
configFileName = "vac-config.xml";
|
||||
}
|
||||
File configFile = new File(configFileName);
|
||||
Meta config;
|
||||
if (configFile.exists()) {
|
||||
config = MetaFileReader.read(configFile).build();
|
||||
} else {
|
||||
config = Meta.empty();
|
||||
}
|
||||
|
||||
Context context = Global.instance();
|
||||
|
||||
Meta p1Meta = config.getMeta("p1",
|
||||
new MetaBuilder("p1")
|
||||
.setValue("port", "com::/dev/ttyUSB0")
|
||||
.setValue("name", "P1")
|
||||
.build()
|
||||
);
|
||||
|
||||
Sensor<Double> p1 = new MKSVacDevice(context, p1Meta);
|
||||
|
||||
Meta p2Meta = config.getMeta("p2",
|
||||
new MetaBuilder("p2")
|
||||
.setValue("port", "tcp::192.168.111.32:4002")
|
||||
.setValue("name", "P2")
|
||||
.build()
|
||||
);
|
||||
|
||||
Sensor<Double> p2 = new CM32Device(context,p2Meta);
|
||||
|
||||
Meta p3Meta = config.getMeta("p3",
|
||||
new MetaBuilder("p3")
|
||||
.setValue("port", "tcp::192.168.111.32:4003")
|
||||
.setValue("name", "P3")
|
||||
.build()
|
||||
);
|
||||
|
||||
Sensor<Double> p3 = new CM32Device(context, p3Meta);
|
||||
|
||||
Meta pxMeta = config.getMeta("px",
|
||||
new MetaBuilder("px")
|
||||
.setValue("port", "tcp::192.168.111.32:4003")
|
||||
.setValue("name", "Px")
|
||||
.build()
|
||||
);
|
||||
|
||||
Sensor<Double> px = new VITVacDevice(context,pxMeta);
|
||||
|
||||
Meta baratronMeta = config.getMeta("baratron",
|
||||
new MetaBuilder("baratron")
|
||||
.setValue("port", "tcp::192.168.111.33:4004")
|
||||
.setValue("name", "Baratron")
|
||||
.build()
|
||||
);
|
||||
|
||||
Sensor<Double> baratron = new MKSBaratronDevice(context,baratronMeta);
|
||||
|
||||
VacCollectorDevice collector = new VacCollectorDevice();
|
||||
collector.configure(config);
|
||||
collector.setSensors(p1, p2, p3, px, baratron);
|
||||
collector.init();
|
||||
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/VacCollector.fxml"));
|
||||
loader.load();
|
||||
controller = loader.getController();
|
||||
controller.setDevice(collector);
|
||||
controller.setLogger(logger);
|
||||
|
||||
controller.setLoaderFactory((VacCollectorDevice device, Storage localStorage) -> {
|
||||
try {
|
||||
String runName = ClientUtils.getRunName(config);
|
||||
// String runName = device.meta().getString("numass.run", "");
|
||||
// if (config.hasMeta("numass.server")) {
|
||||
// try {
|
||||
// logger.info("Obtaining run information from cetral server...");
|
||||
// NumassClient client = new NumassClient(get);
|
||||
// runName = client.getCurrentRun().getString("path", "");
|
||||
// logger.info("Run name is '{}'", runName);
|
||||
// } catch (Exception ex) {
|
||||
// logger.warn("Failed to download current run information", ex);
|
||||
// }
|
||||
// }
|
||||
|
||||
TableFormatBuilder format = new TableFormatBuilder().setType("timestamp", ValueType.TIME);
|
||||
device.getSensors().stream().forEach((s) -> {
|
||||
format.setType(s.getName(), ValueType.NUMBER);
|
||||
});
|
||||
|
||||
PointLoader pl = LoaderFactory.buildPointLoder(localStorage, "vactms", runName, "timestamp", format.build());
|
||||
return pl;
|
||||
|
||||
} catch (StorageException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
});
|
||||
Scene scene = new Scene(loader.getRoot(), 800, 700);
|
||||
|
||||
primaryStage.setTitle("Numass vacuum measurements");
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
// controller.startMeasurement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws Exception {
|
||||
if (controller != null) {
|
||||
controller.stopMeasurement();
|
||||
controller.getDevice().shutdown();
|
||||
}
|
||||
super.stop();
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package inr.numass.readvac.app;
|
||||
package inr.numass.readvac.fx;
|
||||
|
||||
import hep.dataforge.control.measurements.Sensor;
|
||||
import org.apache.commons.cli.CommandLine;
|
@ -22,7 +22,7 @@ import java.util.ResourceBundle;
|
||||
public class PoweredVacuumeterView extends VacuumeterView {
|
||||
|
||||
@FXML
|
||||
ToggleSwitch powerSwitch;
|
||||
private ToggleSwitch powerSwitch;
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,207 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package inr.numass.readvac.fx;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
import hep.dataforge.context.Context;
|
||||
import hep.dataforge.control.connections.DeviceConnection;
|
||||
import hep.dataforge.control.connections.Roles;
|
||||
import hep.dataforge.exceptions.ControlException;
|
||||
import hep.dataforge.meta.Meta;
|
||||
import inr.numass.control.DeviceViewConnection;
|
||||
import inr.numass.control.NumassControlUtils;
|
||||
import inr.numass.readvac.VacCollectorDevice;
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* @author Alexander Nozik
|
||||
*/
|
||||
public class ReadVac extends Application {
|
||||
private VacCollectorDevice device;
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
Locale.setDefault(Locale.US);// чтобы отделение десятичных знаков было точкой
|
||||
ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
|
||||
rootLogger.setLevel(Level.INFO);
|
||||
|
||||
DeviceViewConnection<VacCollectorDevice> controller = buildView();
|
||||
|
||||
Scene scene = new Scene(controller.getPane());
|
||||
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
|
||||
device = setupDevice(controller);
|
||||
primaryStage.setTitle("Numass vacuum measurements");
|
||||
}
|
||||
|
||||
|
||||
private VacCollectorDevice setupDevice(DeviceConnection<VacCollectorDevice> controller) {
|
||||
Meta config = NumassControlUtils.getConfig(this)
|
||||
.orElseGet(() -> NumassControlUtils.readResourceMeta("/config/devices.xml"));
|
||||
|
||||
Context ctx = NumassControlUtils.setupContext(config);
|
||||
Meta mspConfig = NumassControlUtils.findDeviceMeta(config, this::acceptDevice)
|
||||
.orElseThrow(() -> new RuntimeException("Device configuration not found"));
|
||||
|
||||
|
||||
try {
|
||||
D d = getDeviceFactory().build(ctx, mspConfig);
|
||||
d.init();
|
||||
NumassControlUtils.connectStorage(d, config);
|
||||
Platform.runLater(() -> {
|
||||
d.connect(controller, Roles.VIEW_ROLE, Roles.DEVICE_LISTENER_ROLE);
|
||||
});
|
||||
return d;
|
||||
} catch (ControlException e) {
|
||||
throw new RuntimeException("Failed to build device", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws Exception {
|
||||
super.stop();
|
||||
if (device != null) {
|
||||
device.shutdown();
|
||||
device.getContext().close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// VacCollectorView controller;
|
||||
// Logger logger = LoggerFactory.getLogger("ReadVac");
|
||||
//
|
||||
// /**
|
||||
// * @param args the command line arguments
|
||||
// */
|
||||
// public static void main(String[] args) {
|
||||
// launch(args);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void start(Stage primaryStage) throws Exception {
|
||||
// String configFileName = getParameters().getNamed().get("config");
|
||||
// if (configFileName == null) {
|
||||
// configFileName = "vac-config.xml";
|
||||
// }
|
||||
// File configFile = new File(configFileName);
|
||||
// Meta config;
|
||||
// if (configFile.exists()) {
|
||||
// config = MetaFileReader.read(configFile).build();
|
||||
// } else {
|
||||
// config = Meta.empty();
|
||||
// }
|
||||
//
|
||||
// Context context = Global.instance();
|
||||
//
|
||||
// Meta p1Meta = config.getMeta("p1",
|
||||
// new MetaBuilder("p1")
|
||||
// .setValue("port", "com::/dev/ttyUSB0")
|
||||
// .setValue("name", "P1")
|
||||
// .build()
|
||||
// );
|
||||
//
|
||||
// Sensor<Double> p1 = new MKSVacDevice(context, p1Meta);
|
||||
//
|
||||
// Meta p2Meta = config.getMeta("p2",
|
||||
// new MetaBuilder("p2")
|
||||
// .setValue("port", "tcp::192.168.111.32:4002")
|
||||
// .setValue("name", "P2")
|
||||
// .build()
|
||||
// );
|
||||
//
|
||||
// Sensor<Double> p2 = new CM32Device(context,p2Meta);
|
||||
//
|
||||
// Meta p3Meta = config.getMeta("p3",
|
||||
// new MetaBuilder("p3")
|
||||
// .setValue("port", "tcp::192.168.111.32:4003")
|
||||
// .setValue("name", "P3")
|
||||
// .build()
|
||||
// );
|
||||
//
|
||||
// Sensor<Double> p3 = new CM32Device(context, p3Meta);
|
||||
//
|
||||
// Meta pxMeta = config.getMeta("px",
|
||||
// new MetaBuilder("px")
|
||||
// .setValue("port", "tcp::192.168.111.32:4003")
|
||||
// .setValue("name", "Px")
|
||||
// .build()
|
||||
// );
|
||||
//
|
||||
// Sensor<Double> px = new VITVacDevice(context,pxMeta);
|
||||
//
|
||||
// Meta baratronMeta = config.getMeta("baratron",
|
||||
// new MetaBuilder("baratron")
|
||||
// .setValue("port", "tcp::192.168.111.33:4004")
|
||||
// .setValue("name", "Baratron")
|
||||
// .build()
|
||||
// );
|
||||
//
|
||||
// Sensor<Double> baratron = new MKSBaratronDevice(context,baratronMeta);
|
||||
//
|
||||
// VacCollectorDevice collector = new VacCollectorDevice();
|
||||
// collector.configure(config);
|
||||
// collector.setSensors(p1, p2, p3, px, baratron);
|
||||
// collector.init();
|
||||
//
|
||||
// FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/VacCollector.fxml"));
|
||||
// loader.load();
|
||||
// controller = loader.getController();
|
||||
// controller.setDevice(collector);
|
||||
// controller.setLogger(logger);
|
||||
//
|
||||
// controller.setLoaderFactory((VacCollectorDevice device, Storage localStorage) -> {
|
||||
// try {
|
||||
// String runName = ClientUtils.getRunName(config);
|
||||
//// String runName = device.meta().getString("numass.run", "");
|
||||
//// if (config.hasMeta("numass.server")) {
|
||||
//// try {
|
||||
//// logger.info("Obtaining run information from cetral server...");
|
||||
//// NumassClient client = new NumassClient(get);
|
||||
//// runName = client.getCurrentRun().getString("path", "");
|
||||
//// logger.info("Run name is '{}'", runName);
|
||||
//// } catch (Exception ex) {
|
||||
//// logger.warn("Failed to download current run information", ex);
|
||||
//// }
|
||||
//// }
|
||||
//
|
||||
// TableFormatBuilder format = new TableFormatBuilder().setType("timestamp", ValueType.TIME);
|
||||
// device.getSensors().stream().forEach((s) -> {
|
||||
// format.setType(s.getName(), ValueType.NUMBER);
|
||||
// });
|
||||
//
|
||||
// PointLoader pl = LoaderFactory.buildPointLoder(localStorage, "vactms", runName, "timestamp", format.build());
|
||||
// return pl;
|
||||
//
|
||||
// } catch (StorageException ex) {
|
||||
// throw new RuntimeException(ex);
|
||||
// }
|
||||
// });
|
||||
// Scene scene = new Scene(loader.getRoot(), 800, 700);
|
||||
//
|
||||
// primaryStage.setTitle("Numass vacuum measurements");
|
||||
// primaryStage.setScene(scene);
|
||||
// primaryStage.show();
|
||||
//// controller.startMeasurement();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void stop() throws Exception {
|
||||
// if (controller != null) {
|
||||
// controller.stopMeasurement();
|
||||
// controller.getDevice().shutdown();
|
||||
// }
|
||||
// super.stop();
|
||||
// }
|
||||
|
||||
}
|
@ -3,25 +3,25 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package inr.numass.readvac.app;
|
||||
package inr.numass.readvac.fx;
|
||||
|
||||
import hep.dataforge.control.measurements.Sensor;
|
||||
import hep.dataforge.control.virtual.Virtual;
|
||||
import inr.numass.readvac.devices.VacCollectorDevice;
|
||||
import inr.numass.readvac.fx.VacCollectorController;
|
||||
import java.time.Duration;
|
||||
import inr.numass.readvac.VacCollectorDevice;
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alexander Nozik
|
||||
*/
|
||||
public class TestVac extends Application {
|
||||
|
||||
VacCollectorController controller;
|
||||
VacCollectorView controller;
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
@ -75,7 +75,6 @@ public class TestVac extends Application {
|
||||
@Override
|
||||
public void stop() throws Exception {
|
||||
if (controller != null) {
|
||||
controller.stopMeasurement();
|
||||
controller.getDevice().shutdown();
|
||||
}
|
||||
super.stop();
|
@ -31,7 +31,7 @@ import hep.dataforge.tables.DataPoint;
|
||||
import hep.dataforge.tables.TableFormatBuilder;
|
||||
import hep.dataforge.values.Value;
|
||||
import hep.dataforge.values.ValueType;
|
||||
import inr.numass.readvac.devices.VacCollectorDevice;
|
||||
import inr.numass.readvac.VacCollectorDevice;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
@ -65,19 +65,17 @@ import java.util.function.BiFunction;
|
||||
*
|
||||
* @author <a href="mailto:altavir@gmail.com">Alexander Nozik</a>
|
||||
*/
|
||||
public class VacCollectorController implements Initializable, DeviceListener, MeasurementListener<DataPoint> {
|
||||
public class VacCollectorView implements Initializable, DeviceListener, MeasurementListener<DataPoint> {
|
||||
|
||||
private final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
|
||||
private final String[] intervalNames = {"1 sec", "5 sec", "10 sec", "30 sec", "1 min"};
|
||||
private final int[] intervals = {1000, 5000, 10000, 30000, 60000};
|
||||
private final List<VacuumeterView> views = new ArrayList<>();
|
||||
private LogFragment consoleWindow;
|
||||
private Logger logger;
|
||||
private LoaderConnection storageConnection;
|
||||
// private LoaderConnection storageConnection;
|
||||
private VacCollectorDevice device;
|
||||
private PlotContainer plotContainer;
|
||||
private TimePlottableGroup plottables;
|
||||
private BiFunction<VacCollectorDevice, Storage, PointLoader> loaderFactory;
|
||||
// private BiFunction<VacCollectorDevice, Storage, PointLoader> loaderFactory;
|
||||
|
||||
@FXML
|
||||
private AnchorPane plotHolder;
|
||||
@FXML
|
||||
@ -98,7 +96,6 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
|
||||
*/
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
plotContainer = PlotContainer.anchorTo(plotHolder);
|
||||
intervalSelector.setItems(FXCollections.observableArrayList(intervalNames));
|
||||
intervalSelector.getSelectionModel().select(1);
|
||||
intervalSelector.getSelectionModel().selectedIndexProperty().addListener((ObservableValue<? extends Number> observable, Number oldValue, Number newValue) -> {
|
||||
@ -111,7 +108,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
|
||||
}
|
||||
});
|
||||
|
||||
consoleWindow = new LogFragment();
|
||||
LogFragment consoleWindow = new LogFragment();
|
||||
new FragmentWindow(consoleWindow).bindTo(logButton);
|
||||
consoleWindow.hookStd();
|
||||
}
|
||||
@ -170,7 +167,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
|
||||
private void setupView() {
|
||||
vacBoxHolder.getChildren().clear();
|
||||
plottables = new TimePlottableGroup();
|
||||
views.stream().forEach((controller) -> {
|
||||
views.forEach((controller) -> {
|
||||
vacBoxHolder.getChildren().add(controller.getComponent());
|
||||
TimePlottable plot = new TimePlottable(controller.getTitle(),
|
||||
controller.getName());
|
||||
@ -179,7 +176,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
|
||||
});
|
||||
plottables.setValue("thickness", 3);
|
||||
plottables.setMaxAge(java.time.Duration.ofHours(3));
|
||||
plotContainer.setPlot(setupPlot(plottables));
|
||||
PlotContainer.anchorTo(plotHolder).setPlot(setupPlot(plottables));
|
||||
}
|
||||
|
||||
private FXPlotFrame setupPlot(TimePlottableGroup plottables) {
|
||||
@ -195,12 +192,12 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
|
||||
return frame;
|
||||
}
|
||||
|
||||
public void startMeasurement() throws ControlException {
|
||||
private void startMeasurement() throws ControlException {
|
||||
getDevice().startMeasurement().addListener(this);
|
||||
startStopButton.setSelected(true);
|
||||
}
|
||||
|
||||
public void stopMeasurement() {
|
||||
private void stopMeasurement() {
|
||||
try {
|
||||
getDevice().stopMeasurement(false);
|
||||
for (Sensor sensor : getDevice().getSensors()) {
|
||||
@ -262,7 +259,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
|
||||
loader = loaderFactory.apply(device, localStorage);
|
||||
} else {
|
||||
TableFormatBuilder format = new TableFormatBuilder().setType("timestamp", ValueType.TIME);
|
||||
device.getSensors().stream().forEach((s) -> {
|
||||
device.getSensors().forEach((s) -> {
|
||||
format.setType(s.getName(), ValueType.NUMBER);
|
||||
});
|
||||
|
||||
@ -284,17 +281,8 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
|
||||
/**
|
||||
* @return the logger
|
||||
*/
|
||||
public Logger getLogger() {
|
||||
if (logger == null) {
|
||||
logger = LoggerFactory.getLogger("ValCollector");
|
||||
}
|
||||
return logger;
|
||||
private Logger getLogger() {
|
||||
return device.getLogger();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param logger the logger to set
|
||||
*/
|
||||
public void setLogger(Logger logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
}
|
@ -1,19 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.net.URL?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.ChoiceBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.Separator?>
|
||||
<?import javafx.scene.control.ToggleButton?>
|
||||
<?import javafx.scene.control.ToolBar?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<AnchorPane id="root" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="inr.numass.readvac.fx.VacCollectorController">
|
||||
<?import java.net.URL?>
|
||||
<AnchorPane id="root" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="inr.numass.readvac.fx.VacCollectorView">
|
||||
<stylesheets>
|
||||
<URL value="@/styles/vacstyles.css" />
|
||||
</stylesheets>
|
||||
|
Loading…
Reference in New Issue
Block a user