[no commit message]

This commit is contained in:
Alexander Nozik 2016-04-13 18:13:59 +03:00
parent f9e63d9e2c
commit fef472f22e
14 changed files with 198 additions and 106 deletions

View File

@ -438,16 +438,16 @@ public class MspDevice extends SingleMeasurementDevice implements PortHandler.Po
this.error("Failed to start scan", null); this.error("Failed to start scan", null);
} }
} catch (ControlException ex) { } catch (ControlException ex) {
onError(ex); error(ex);
} }
onStart(); afterStart();
} }
@Override @Override
public boolean stop(boolean force) throws MeasurementException { public boolean stop(boolean force) throws MeasurementException {
try { try {
boolean stop = sendAndWait("ScanStop").isOK(); boolean stop = sendAndWait("ScanStop").isOK();
onFinish(); afterStop();
responseDelegate = null; responseDelegate = null;
return stop; return stop;
} catch (PortException ex) { } catch (PortException ex) {
@ -514,9 +514,9 @@ public class MspDevice extends SingleMeasurementDevice implements PortHandler.Po
public void error(String errorMessage, Throwable error) { public void error(String errorMessage, Throwable error) {
if (error == null) { if (error == null) {
onError(new MeasurementException(errorMessage)); error(new MeasurementException(errorMessage));
} else { } else {
onError(error); error(error);
} }
} }

View File

@ -6,8 +6,15 @@
package inr.numass.readvac.app; package inr.numass.readvac.app;
import hep.dataforge.control.measurements.Sensor; import hep.dataforge.control.measurements.Sensor;
import hep.dataforge.exceptions.StorageException;
import hep.dataforge.io.MetaFileReader; import hep.dataforge.io.MetaFileReader;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.points.FormatBuilder;
import hep.dataforge.storage.api.PointLoader;
import hep.dataforge.storage.api.Storage;
import hep.dataforge.storage.commons.LoaderFactory;
import hep.dataforge.values.ValueType;
import inr.numass.client.NumassClient;
import inr.numass.readvac.devices.CM32Device; import inr.numass.readvac.devices.CM32Device;
import inr.numass.readvac.devices.MKSBaratronDevice; import inr.numass.readvac.devices.MKSBaratronDevice;
import inr.numass.readvac.devices.MKSVacDevice; import inr.numass.readvac.devices.MKSVacDevice;
@ -19,6 +26,8 @@ import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.stage.Stage; import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* *
@ -27,6 +36,7 @@ import javafx.stage.Stage;
public class ReadVac extends Application { public class ReadVac extends Application {
VacCollectorController controller; VacCollectorController controller;
Logger logger = LoggerFactory.getLogger("ReadVac");
@Override @Override
public void start(Stage primaryStage) throws Exception { public void start(Stage primaryStage) throws Exception {
@ -42,38 +52,64 @@ public class ReadVac extends Application {
config = Meta.empty(); config = Meta.empty();
} }
Sensor<Double> p1 = new MKSVacDevice(config.getString("p1.port","com::/dev/ttyUSB0")); Sensor<Double> p1 = new MKSVacDevice(config.getString("p1.port", "com::/dev/ttyUSB0"));
p1.configure(config.getNode("p1",Meta.empty())); p1.configure(config.getNode("p1", Meta.empty()));
p1.setName(config.getString("p1.name","P1")); p1.setName(config.getString("p1.name", "P1"));
p1.getConfig().putValue("powerButton", true); p1.getConfig().putValue("powerButton", true);
Sensor<Double> p2 = new CM32Device(config.getString("p2.port","tcp::192.168.111.32:4002")); Sensor<Double> p2 = new CM32Device(config.getString("p2.port", "tcp::192.168.111.32:4002"));
p1.configure(config.getNode("p2",Meta.empty())); p1.configure(config.getNode("p2", Meta.empty()));
p2.setName(config.getString("p2.name","P2")); p2.setName(config.getString("p2.name", "P2"));
Sensor<Double> p3 = new CM32Device(config.getString("p3.port","tcp::192.168.111.32:4003")); Sensor<Double> p3 = new CM32Device(config.getString("p3.port", "tcp::192.168.111.32:4003"));
p1.configure(config.getNode("p3",Meta.empty())); p1.configure(config.getNode("p3", Meta.empty()));
p3.setName(config.getString("p3.name","P3")); p3.setName(config.getString("p3.name", "P3"));
Sensor<Double> px = new VITVacDevice(config.getString("px.port","com::/dev/ttyUSB1")); Sensor<Double> px = new VITVacDevice(config.getString("px.port", "com::/dev/ttyUSB1"));
p1.configure(config.getNode("px",Meta.empty())); p1.configure(config.getNode("px", Meta.empty()));
px.setName(config.getString("px.name","Px")); px.setName(config.getString("px.name", "Px"));
Sensor<Double> baratron = new MKSBaratronDevice(config.getString("baratron.port","tcp::192.168.111.33:4004")); Sensor<Double> baratron = new MKSBaratronDevice(config.getString("baratron.port", "tcp::192.168.111.33:4004"));
baratron.setName(config.getString("baratron.name","Baratron")); baratron.setName(config.getString("baratron.name", "Baratron"));
p1.configure(config.getNode("baratron",Meta.empty())); p1.configure(config.getNode("baratron", Meta.empty()));
VacCollectorDevice collector = new VacCollectorDevice(); VacCollectorDevice collector = new VacCollectorDevice();
collector.setSensors(p1, p2, p3, px, baratron); collector.setSensors(p1, p2, p3, px, baratron);
collector.init(); collector.init();
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/VacCollector.fxml")); FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/VacCollector.fxml"));
loader.load(); loader.load();
controller = loader.getController(); controller = loader.getController();
controller.setDevice(collector); controller.setDevice(collector);
controller.setLogger(logger);
controller.setLoaderFactory((VacCollectorDevice device, Storage localStorage) -> {
try {
String runName = "";
try {
logger.info("Obtaining run information from cetral server...");
NumassClient client = new NumassClient(config.getString("numass.ip", "192.168.111.1"),
config.getInt("numass.port", 8335));
runName = client.getCurrentRun().getString("path", "");
logger.info("Run name is '{}'", runName);
} catch (Exception ex) {
logger.warn("Failed to download current run information", ex);
}
FormatBuilder format = new FormatBuilder().setFormat("timestamp", ValueType.TIME);
device.getSensors().stream().forEach((s) -> {
format.setFormat(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, 600); Scene scene = new Scene(loader.getRoot(), 800, 600);
primaryStage.setTitle("Numass vacuum measurements"); primaryStage.setTitle("Numass vacuum measurements");
primaryStage.setScene(scene); primaryStage.setScene(scene);
primaryStage.show(); primaryStage.show();
controller.startMeasurement(); // controller.startMeasurement();
} }
@Override @Override

View File

@ -74,19 +74,19 @@ public class CM32Device extends PortSensor<Double> {
String answer = getHandler().sendAndWait(CM32_QUERY, timeout()); String answer = getHandler().sendAndWait(CM32_QUERY, timeout());
if (answer.isEmpty()) { if (answer.isEmpty()) {
this.onProgressUpdate("No signal"); this.progressUpdate("No signal");
updateState(CONNECTION_STATE, false); updateState(CONNECTION_STATE, false);
return null; return null;
} else if (answer.indexOf("PM1:mbar") < -1) { } else if (answer.indexOf("PM1:mbar") < -1) {
this.onProgressUpdate("Wrong answer: " + answer); this.progressUpdate("Wrong answer: " + answer);
updateState(CONNECTION_STATE, false); updateState(CONNECTION_STATE, false);
return null; return null;
} else if (answer.substring(14, 17).equals("OFF")) { } else if (answer.substring(14, 17).equals("OFF")) {
this.onProgressUpdate("Off"); this.progressUpdate("Off");
updateState(CONNECTION_STATE, true); updateState(CONNECTION_STATE, true);
return null; return null;
} else { } else {
this.onProgressUpdate("OK"); this.progressUpdate("OK");
updateState(CONNECTION_STATE, true); updateState(CONNECTION_STATE, true);
return Double.parseDouble(answer.substring(14, 17) + answer.substring(19, 23)); return Double.parseDouble(answer.substring(14, 17) + answer.substring(19, 23));
} }

View File

@ -6,15 +6,12 @@
package inr.numass.readvac.devices; package inr.numass.readvac.devices;
import hep.dataforge.control.devices.PortSensor; import hep.dataforge.control.devices.PortSensor;
import static hep.dataforge.control.devices.PortSensor.CONNECTION_STATE;
import hep.dataforge.control.measurements.Measurement; import hep.dataforge.control.measurements.Measurement;
import hep.dataforge.control.measurements.Sensor;
import hep.dataforge.control.measurements.SimpleMeasurement; import hep.dataforge.control.measurements.SimpleMeasurement;
import hep.dataforge.control.ports.ComPortHandler;
import hep.dataforge.control.ports.PortHandler; import hep.dataforge.control.ports.PortHandler;
import hep.dataforge.description.ValueDef; import hep.dataforge.description.ValueDef;
import hep.dataforge.exceptions.ControlException; import hep.dataforge.exceptions.ControlException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* *
@ -27,17 +24,6 @@ public class MKSBaratronDevice extends PortSensor<Double> {
super(portName); super(portName);
} }
private String talk(String request) throws ControlException {
String answer = getHandler().sendAndWait(String.format("%s\r", request), timeout());
Matcher match = Pattern.compile("(.*)\r").matcher(answer);
if (match.matches()) {
return match.group(1);
} else {
throw new ControlException(answer);
}
}
@Override @Override
protected Measurement<Double> createMeasurement() { protected Measurement<Double> createMeasurement() {
return new BaratronMeasurement(); return new BaratronMeasurement();
@ -54,7 +40,7 @@ public class MKSBaratronDevice extends PortSensor<Double> {
handler.setDelimeter("\r"); handler.setDelimeter("\r");
return handler; return handler;
} }
private int getChannel() { private int getChannel() {
return meta().getInt("channel", 2); return meta().getInt("channel", 2);
} }
@ -63,20 +49,22 @@ public class MKSBaratronDevice extends PortSensor<Double> {
@Override @Override
protected synchronized Double doMeasure() throws Exception { protected synchronized Double doMeasure() throws Exception {
String answer = getHandler().sendAndWait("AV" + getChannel() + "\r", timeout());
String answer = talk("AV" + getChannel());
if (answer == null || answer.isEmpty()) { if (answer == null || answer.isEmpty()) {
// invalidateState("connection"); // invalidateState("connection");
this.onProgressUpdate("No connection"); updateState(CONNECTION_STATE, false);
this.progressUpdate("No connection");
return null; return null;
} else {
updateState(CONNECTION_STATE, true);
} }
double res = Double.parseDouble(answer); double res = Double.parseDouble(answer);
if (res <= 0) { if (res <= 0) {
this.onProgressUpdate("Non positive"); this.progressUpdate("Non positive");
// invalidateState("power"); // invalidateState("power");
return null; return null;
} else { } else {
this.onProgressUpdate("OK"); this.progressUpdate("OK");
return res; return res;
} }
} }

View File

@ -137,16 +137,16 @@ public class MKSVacDevice extends PortSensor<Double> {
String answer = talk("PR" + getChannel() + "?"); String answer = talk("PR" + getChannel() + "?");
if (answer == null || answer.isEmpty()) { if (answer == null || answer.isEmpty()) {
invalidateState("connection"); invalidateState("connection");
this.onProgressUpdate("No connection"); this.progressUpdate("No connection");
return null; return null;
} }
double res = Double.parseDouble(answer); double res = Double.parseDouble(answer);
if (res <= 0) { if (res <= 0) {
this.onProgressUpdate("Non positive"); this.progressUpdate("Non positive");
invalidateState("power"); invalidateState("power");
return null; return null;
} else { } else {
this.onProgressUpdate("OK"); this.progressUpdate("OK");
return res; return res;
} }
} }

View File

@ -72,7 +72,7 @@ public class VITVacDevice extends PortSensor<Double> {
String answer = getHandler().sendAndWait(VIT_QUERY, timeout()); String answer = getHandler().sendAndWait(VIT_QUERY, timeout());
if (answer.isEmpty()) { if (answer.isEmpty()) {
this.onProgressUpdate("No signal"); this.progressUpdate("No signal");
updateState("connection", false); updateState("connection", false);
return null; return null;
} else { } else {
@ -86,11 +86,11 @@ public class VITVacDevice extends PortSensor<Double> {
} }
BigDecimal res = BigDecimal.valueOf(base * Math.pow(10, exp)); BigDecimal res = BigDecimal.valueOf(base * Math.pow(10, exp));
res = res.setScale(4, RoundingMode.CEILING); res = res.setScale(4, RoundingMode.CEILING);
this.onProgressUpdate("OK"); this.progressUpdate("OK");
updateState("connection", true); updateState("connection", true);
return res.doubleValue(); return res.doubleValue();
} else { } else {
this.onProgressUpdate("Wrong answer: " + answer); this.progressUpdate("Wrong answer: " + answer);
updateState("connection", false); updateState("connection", false);
return null; return null;
} }

View File

@ -11,10 +11,12 @@ import hep.dataforge.control.connections.Roles;
import hep.dataforge.control.devices.annotations.RoleDef; import hep.dataforge.control.devices.annotations.RoleDef;
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.MeasurementListener;
import hep.dataforge.control.measurements.Sensor; import hep.dataforge.control.measurements.Sensor;
import hep.dataforge.points.DataPoint; import hep.dataforge.points.DataPoint;
import hep.dataforge.exceptions.ControlException; import hep.dataforge.exceptions.ControlException;
import hep.dataforge.exceptions.MeasurementException; import hep.dataforge.exceptions.MeasurementException;
import hep.dataforge.points.MapPoint;
import hep.dataforge.points.PointListener; import hep.dataforge.points.PointListener;
import hep.dataforge.values.Value; import hep.dataforge.values.Value;
import java.time.Instant; import java.time.Instant;
@ -26,6 +28,8 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer;
import org.slf4j.LoggerFactory;
/** /**
* *
@ -103,7 +107,6 @@ public class VacCollectorDevice extends Sensor<DataPoint> {
Object value = entry.getValue().read(); Object value = entry.getValue().read();
collector.put(entry.getKey(), value); collector.put(entry.getKey(), value);
} catch (Exception ex) { } catch (Exception ex) {
onError(ex);
collector.put(entry.getKey(), Value.NULL); collector.put(entry.getKey(), Value.NULL);
} }
}); });
@ -118,15 +121,25 @@ public class VacCollectorDevice extends Sensor<DataPoint> {
}); });
} }
private DataPoint terminator() {
MapPoint p = new MapPoint();
p.putValue("timestamp", Instant.now());
sensorMap.keySet().stream().forEach((n) -> {
p.putValue(n, null);
});
return p;
}
@Override @Override
public boolean stop(boolean force) { public boolean stop(boolean force) {
boolean isRunning = currentTask != null; boolean isRunning = currentTask != null;
if (isRunning) { if (isRunning) {
getLogger().debug("Stoping vacuum collector measurement"); getLogger().debug("Stoping vacuum collector measurement. Writing terminator point");
result(terminator());
currentTask.cancel(force); currentTask.cancel(force);
executor.shutdown(); executor.shutdown();
currentTask = null; currentTask = null;
onFinish(); afterStop();
} }
return isRunning; return isRunning;
} }

View File

@ -19,6 +19,7 @@ import hep.dataforge.exceptions.StorageException;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.meta.MetaBuilder; import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.plots.PlotFrame; import hep.dataforge.plots.PlotFrame;
import hep.dataforge.plots.XYPlottable;
import hep.dataforge.plots.data.DynamicPlottable; import hep.dataforge.plots.data.DynamicPlottable;
import hep.dataforge.plots.data.DynamicPlottableSet; import hep.dataforge.plots.data.DynamicPlottableSet;
import hep.dataforge.plots.fx.PlotContainer; import hep.dataforge.plots.fx.PlotContainer;
@ -32,6 +33,7 @@ import hep.dataforge.storage.commons.StorageManager;
import hep.dataforge.values.Value; import hep.dataforge.values.Value;
import hep.dataforge.values.ValueType; import hep.dataforge.values.ValueType;
import inr.numass.readvac.devices.VacCollectorDevice; import inr.numass.readvac.devices.VacCollectorDevice;
import java.io.File;
import java.net.URL; import java.net.URL;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -40,7 +42,9 @@ import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import java.util.stream.Collectors; import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.logging.Level;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.beans.value.ObservableValue; import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
@ -52,6 +56,7 @@ import javafx.scene.control.Label;
import javafx.scene.control.ToggleButton; import javafx.scene.control.ToggleButton;
import javafx.scene.layout.AnchorPane; import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.stage.DirectoryChooser;
import javafx.util.Duration; import javafx.util.Duration;
import org.controlsfx.control.Notifications; import org.controlsfx.control.Notifications;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -64,7 +69,7 @@ import org.slf4j.LoggerFactory;
*/ */
public class VacCollectorController implements Initializable, DeviceListener, MeasurementListener<DataPoint> { public class VacCollectorController implements Initializable, DeviceListener, MeasurementListener<DataPoint> {
private final Logger logger = LoggerFactory.getLogger("ValCollector"); private Logger logger;
private final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ISO_LOCAL_DATE_TIME; private final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
@ -77,6 +82,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
private final List<VacuumeterView> views = new ArrayList<>(); private final List<VacuumeterView> views = new ArrayList<>();
private PlotContainer plotContainer; private PlotContainer plotContainer;
private DynamicPlottableSet plottables; private DynamicPlottableSet plottables;
private BiFunction<VacCollectorDevice, Storage, PointLoader> loaderFactory;
@FXML @FXML
private AnchorPane plotHolder; private AnchorPane plotHolder;
@ -149,6 +155,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
plot.configure(controller.meta()); plot.configure(controller.meta());
plottables.addPlottable(plot); plottables.addPlottable(plot);
}); });
plottables.setEachConfigValue("thickness", 3);
plotContainer.setPlot(setupPlot(plottables)); plotContainer.setPlot(setupPlot(plottables));
} }
@ -198,30 +205,70 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
} }
} }
public void setLoaderFactory(BiFunction<VacCollectorDevice, Storage, PointLoader> loaderFactory) {
this.loaderFactory = loaderFactory;
}
@FXML @FXML
private void onStartStopToggle(ActionEvent event) throws ControlException { private void onStartStopToggle(ActionEvent event) {
if (startStopButton.isSelected() != getDevice().isMeasuring()) { if (startStopButton.isSelected() != getDevice().isMeasuring()) {
if (startStopButton.isSelected()) { //Starting measurement on non-UI thread
startMeasurement(); new Thread(() -> {
} else { if (startStopButton.isSelected()) {
stopMeasurement(); try {
} startMeasurement();
} catch (ControlException ex) {
getLogger().error("Failed to start measurement", ex);
startStopButton.setSelected(false);
}
} else {
stopMeasurement();
}
}).start();
} }
} }
@FXML @FXML
private void onStoreToggle(ActionEvent event) { private void onStoreToggle(ActionEvent event) {
if (storeButton.isSelected()) { if (storeButton.isSelected()) {
try { //creating storage on UI thread
Meta storageConfig = device.meta().getNode("storage"); if (!device.meta().hasNode("storage")) {
Storage storage = StorageManager.buildFrom(device.getContext()) getLogger().info("Storage not defined. Starting storage selection dialog");
.buildStorage(storageConfig); DirectoryChooser chooser = new DirectoryChooser();
storageConnection = new LoaderConnection(storage, device.meta().getString("storage.shelf", "")); File storageDir = chooser.showDialog(plotHolder.getScene().getWindow());
device.connect(storageConnection, Roles.STORAGE_ROLE); if (storageDir == null) {
} catch (Exception ex) { throw new RuntimeException("User canceled directory selection");
logger.error("Failed to start data storing", ex); }
storeButton.setSelected(false); device.getConfig().putNode(new MetaBuilder("storage")
.putValue("path", storageDir.getAbsolutePath()));
} }
Meta storageConfig = device.meta().getNode("storage");
Storage localStorage = StorageManager.buildFrom(device.getContext())
.buildStorage(storageConfig);
//Start storage creation on non-UI thread
new Thread(() -> {
try {
PointLoader loader;
if (loaderFactory != null) {
loader = loaderFactory.apply(device, localStorage);
} else {
FormatBuilder format = new FormatBuilder().setFormat("timestamp", ValueType.TIME);
device.getSensors().stream().forEach((s) -> {
format.setFormat(s.getName(), ValueType.NUMBER);
});
loader = LoaderFactory.buildPointLoder(localStorage, "vactms",
device.meta().getString("storage.shelf", ""), "timestamp", format.build());
}
storageConnection = new LoaderConnection(loader);
device.connect(storageConnection, Roles.STORAGE_ROLE);
} catch (Exception ex) {
getLogger().error("Failed to start data storing", ex);
storeButton.setSelected(false);
}
}).start();
} else if (storageConnection != null) { } else if (storageConnection != null) {
device.disconnect(storageConnection); device.disconnect(storageConnection);
} }
@ -231,15 +278,29 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
private void onLogToggle(ActionEvent event) { private void onLogToggle(ActionEvent event) {
} }
/**
* @return the logger
*/
public Logger getLogger() {
if (logger == null) {
logger = LoggerFactory.getLogger("ValCollector");
}
return logger;
}
/**
* @param logger the logger to set
*/
public void setLogger(Logger logger) {
this.logger = logger;
}
private class LoaderConnection implements PointListener, Connection<Device> { private class LoaderConnection implements PointListener, Connection<Device> {
private final PointLoader loader; private final PointLoader loader;
public LoaderConnection(Storage storage, String shelfName) throws StorageException { public LoaderConnection(PointLoader loader) {
this.loader = LoaderFactory.buildPointLoder(storage, "vactms", shelfName, "timestamp", this.loader = loader;
new FormatBuilder(device.getSensors().stream().map(sensor -> sensor.getName()).collect(Collectors.toList()))
.setFormat("timestamp", ValueType.TIME)
.build());
} }
@Override @Override
@ -247,7 +308,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
try { try {
loader.push(point); loader.push(point);
} catch (StorageException ex) { } catch (StorageException ex) {
logger.error("Error while pushing data", ex); getLogger().error("Error while pushing data", ex);
} }
} }

View File

@ -35,7 +35,7 @@ import javafx.scene.paint.Color;
*/ */
public class VacuumeterView extends DeviceViewController implements MeasurementListener<Double>, Initializable, Named, Annotated { public class VacuumeterView extends DeviceViewController implements MeasurementListener<Double>, Initializable, Named, Annotated {
private static final DecimalFormat FORMAT = new DecimalFormat("0.##E0"); private static final DecimalFormat FORMAT = new DecimalFormat("0.###E0");
private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ISO_LOCAL_TIME; private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ISO_LOCAL_TIME;
protected Node node; protected Node node;

View File

@ -56,7 +56,7 @@ public class TestVac extends Application {
collector.setSensors(sensor1, sensor2, sensor3); collector.setSensors(sensor1, sensor2, sensor3);
collector.init(); collector.init();
collector.getConfig().putNode(new MetaBuilder("storage").putValue("path", "D:\\temp\\test").putValue("monitor", false)); // collector.getConfig().putNode(new MetaBuilder("storage").putValue("path", "D:\\temp\\test"));
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/VacCollector.fxml")); FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/VacCollector.fxml"));
loader.load(); loader.load();

View File

@ -17,22 +17,19 @@
<children> <children>
<VBox layoutX="50.0" layoutY="6.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <VBox layoutX="50.0" layoutY="6.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children> <children>
<AnchorPane styleClass="namePane"> <AnchorPane styleClass="namePane">
<children> <children>
<Label id="name" fx:id="deviceNameLabel" alignment="CENTER" prefHeight="40.0" text="device Name" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /> <Label id="name" fx:id="deviceNameLabel" alignment="CENTER" prefHeight="40.0" text="device Name" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children> </children>
</AnchorPane> </AnchorPane>
<Separator /> <Separator />
<BorderPane> <BorderPane>
<left> <left>
<Label id="pressure" fx:id="valueLabel" alignment="CENTER_RIGHT" prefHeight="60.0" prefWidth="100.0" text="#.##E-0" BorderPane.alignment="CENTER" /> <Label id="pressure" fx:id="valueLabel" alignment="CENTER_RIGHT" minWidth="110.0" prefHeight="60.0" text="--- " BorderPane.alignment="CENTER" />
</left> </left>
<right> <right>
<Label id="units" fx:id="unitLabel" prefHeight="60.0" prefWidth="75.0" text="mbar" BorderPane.alignment="CENTER" /> <Label id="units" fx:id="unitLabel" prefHeight="60.0" prefWidth="75.0" text=" mbar" BorderPane.alignment="CENTER" />
</right> </right>
<center>
<Pane minWidth="-Infinity" prefWidth="25.0" BorderPane.alignment="CENTER" />
</center>
</BorderPane> </BorderPane>
<Separator /> <Separator />
<Pane minHeight="30.0" prefHeight="30.0" VBox.vgrow="ALWAYS"> <Pane minHeight="30.0" prefHeight="30.0" VBox.vgrow="ALWAYS">
@ -40,15 +37,15 @@
<ToggleSwitch fx:id="powerSwitch" layoutX="58.0" layoutY="5.0" text="Power" /> <ToggleSwitch fx:id="powerSwitch" layoutX="58.0" layoutY="5.0" text="Power" />
</children> </children>
</Pane> </Pane>
<Separator /> <Separator />
<AnchorPane styleClass="statusPane"> <AnchorPane styleClass="statusPane">
<children> <children>
<Label fx:id="status" maxWidth="200.0" text="Initializing" wrapText="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /> <Label fx:id="status" maxWidth="200.0" text="Initializing" wrapText="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children> </children>
<padding> <padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding> </padding>
</AnchorPane> </AnchorPane>
</children> </children>
</VBox> </VBox>
</children> </children>

View File

@ -6,7 +6,6 @@
<?import javafx.scene.control.Separator?> <?import javafx.scene.control.Separator?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?> <?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<AnchorPane styleClass="vacBox" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1"> <AnchorPane styleClass="vacBox" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1">
@ -24,14 +23,11 @@
<Separator /> <Separator />
<BorderPane VBox.vgrow="ALWAYS"> <BorderPane VBox.vgrow="ALWAYS">
<left> <left>
<Label id="pressure" fx:id="valueLabel" alignment="CENTER_RIGHT" prefHeight="60.0" prefWidth="100.0" text="#.##E-0" BorderPane.alignment="CENTER" /> <Label id="pressure" fx:id="valueLabel" alignment="CENTER_RIGHT" minWidth="110.0" prefHeight="60.0" text="--- " BorderPane.alignment="CENTER" />
</left> </left>
<right> <right>
<Label id="units" fx:id="unitLabel" prefHeight="60.0" prefWidth="75.0" text="mbar" BorderPane.alignment="CENTER" /> <Label id="units" fx:id="unitLabel" prefHeight="60.0" prefWidth="75.0" text=" mbar" BorderPane.alignment="CENTER" />
</right> </right>
<center>
<Pane minWidth="-Infinity" prefWidth="25.0" BorderPane.alignment="CENTER" />
</center>
</BorderPane> </BorderPane>
<Separator /> <Separator />
<AnchorPane styleClass="statusPane"> <AnchorPane styleClass="statusPane">

View File

@ -35,7 +35,7 @@
<Label text="Interval: " /> <Label text="Interval: " />
<ChoiceBox fx:id="intervalSelector" prefWidth="150.0" /> <ChoiceBox fx:id="intervalSelector" prefWidth="150.0" />
<Separator orientation="VERTICAL" /> <Separator orientation="VERTICAL" />
<Pane maxWidth="1.7976931348623157E308" /> <Pane HBox.hgrow="ALWAYS" />
<Separator orientation="VERTICAL" /> <Separator orientation="VERTICAL" />
<ToggleButton fx:id="logButton" mnemonicParsing="false" onAction="#onLogToggle" text="Log" /> <ToggleButton fx:id="logButton" mnemonicParsing="false" onAction="#onLogToggle" text="Log" />
</items> </items>

View File

@ -57,6 +57,7 @@ public class NumassClient extends MessageFactory implements Closeable {
public NumassClient(String address, int port) throws IOException { public NumassClient(String address, int port) throws IOException {
socket = new Socket(address, port); socket = new Socket(address, port);
socket.setSoTimeout(300);
} }
@Override @Override