[no commit message]
This commit is contained in:
parent
68ff2c89da
commit
661de3394b
@ -49,6 +49,7 @@ public class VacCollectorDevice extends Sensor<DataPoint> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Measurement<DataPoint> createMeasurement() {
|
protected Measurement<DataPoint> createMeasurement() {
|
||||||
|
//TODO use meta
|
||||||
return new VacuumMeasurement();
|
return new VacuumMeasurement();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +73,7 @@ public class VacCollectorDevice extends Sensor<DataPoint> {
|
|||||||
currentTask = executor.scheduleWithFixedDelay(() -> {
|
currentTask = executor.scheduleWithFixedDelay(() -> {
|
||||||
sensorMap.entrySet().stream().parallel().forEach((entry) -> {
|
sensorMap.entrySet().stream().parallel().forEach((entry) -> {
|
||||||
try {
|
try {
|
||||||
collector.put(entry.getKey(), entry.getValue().getMeasurement().getResult());
|
collector.put(entry.getKey(), entry.getValue().read());
|
||||||
} catch (MeasurementException ex) {
|
} catch (MeasurementException ex) {
|
||||||
onError(ex);
|
onError(ex);
|
||||||
collector.put(entry.getKey(), Value.NULL);
|
collector.put(entry.getKey(), Value.NULL);
|
||||||
|
@ -1,40 +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.devices;
|
|
||||||
|
|
||||||
import hep.dataforge.context.Context;
|
|
||||||
import hep.dataforge.control.measurements.Measurement;
|
|
||||||
import hep.dataforge.control.measurements.Sensor;
|
|
||||||
import hep.dataforge.exceptions.ControlException;
|
|
||||||
import hep.dataforge.meta.Meta;
|
|
||||||
import hep.dataforge.values.Value;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Alexander Nozik <altavir@gmail.com>
|
|
||||||
*/
|
|
||||||
public class VirtualVacDevice extends Sensor<Double> {
|
|
||||||
|
|
||||||
public VirtualVacDevice(String name, Context context, Meta meta) {
|
|
||||||
super(name, context, meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Object calculateState(String stateName) throws ControlException {
|
|
||||||
return Value.NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Measurement<Double> createMeasurement() {
|
|
||||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String type() {
|
|
||||||
return "Virtual vacuumeter device";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -11,6 +11,8 @@ import hep.dataforge.control.devices.DeviceListener;
|
|||||||
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.data.DataPoint;
|
import hep.dataforge.data.DataPoint;
|
||||||
|
import hep.dataforge.exceptions.ControlException;
|
||||||
|
import hep.dataforge.exceptions.MeasurementException;
|
||||||
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;
|
||||||
@ -26,8 +28,10 @@ import java.time.Instant;
|
|||||||
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 javafx.application.Platform;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
|
|
||||||
@ -47,6 +51,8 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
|
|||||||
private AnchorPane plotHolder;
|
private AnchorPane plotHolder;
|
||||||
@FXML
|
@FXML
|
||||||
private HBox vacBoxHolder;
|
private HBox vacBoxHolder;
|
||||||
|
@FXML
|
||||||
|
private Label timeLabel;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluateDeviceException(Device device, String message, Throwable exception) {
|
public void evaluateDeviceException(Device device, String message, Throwable exception) {
|
||||||
@ -77,7 +83,11 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMeasurementResult(Measurement<DataPoint> measurement, DataPoint result, Instant time) {
|
public void onMeasurementResult(Measurement<DataPoint> measurement, DataPoint result, Instant time) {
|
||||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
if (plottables != null) {
|
||||||
|
plottables.put(result);
|
||||||
|
}
|
||||||
|
Platform.runLater(() -> timeLabel.setText(time.toString()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupView() {
|
private void setupView() {
|
||||||
@ -94,11 +104,11 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
|
|||||||
private PlotFrame setupPlot(DynamicPlottableSet plottables) {
|
private PlotFrame setupPlot(DynamicPlottableSet plottables) {
|
||||||
Meta plotConfig = new MetaBuilder("plotFrame")
|
Meta plotConfig = new MetaBuilder("plotFrame")
|
||||||
.setNode(new MetaBuilder("yAxis")
|
.setNode(new MetaBuilder("yAxis")
|
||||||
.setValue("logAxis", true)
|
.setValue("type", "log")
|
||||||
.setValue("axisTitle", "pressure")
|
.setValue("axisTitle", "pressure")
|
||||||
.setValue("axisUnits", "mbar")
|
.setValue("axisUnits", "mbar")
|
||||||
)
|
)
|
||||||
.setValue("xAxis.timeAxis", true);
|
.setValue("xAxis.type", "time");
|
||||||
JFreeChartFrame frame = new JFreeChartFrame("pressure", plotConfig);
|
JFreeChartFrame frame = new JFreeChartFrame("pressure", plotConfig);
|
||||||
frame.addAll(plottables);
|
frame.addAll(plottables);
|
||||||
return frame;
|
return frame;
|
||||||
@ -121,8 +131,16 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
|
|||||||
setupView();
|
setupView();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startMeasurement(){
|
public void startMeasurement() throws ControlException {
|
||||||
getDevice().startMeasurement();
|
getDevice().startMeasurement().addListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopMeasurement() {
|
||||||
|
try {
|
||||||
|
getDevice().stopMeasurement(true);
|
||||||
|
} catch (MeasurementException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import java.io.IOException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
import javafx.application.Platform;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
@ -69,8 +70,10 @@ public class VacuumeterView extends DeviceViewController implements MeasurementL
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
unitLabel.setText(getDevice().meta().getString("units", "mbar"));
|
Platform.runLater(() -> {
|
||||||
deviceNameLabel.setText(getDevice().getName());
|
unitLabel.setText(getDevice().meta().getString("units", "mbar"));
|
||||||
|
deviceNameLabel.setText(getDevice().getName());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -80,26 +83,26 @@ public class VacuumeterView extends DeviceViewController implements MeasurementL
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMeasurementFailed(Measurement measurement, Throwable exception) {
|
public void onMeasurementFailed(Measurement measurement, Throwable exception) {
|
||||||
valueLabel.setText("Err");
|
Platform.runLater(() -> valueLabel.setText("Err"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMeasurementProgress(Measurement measurement, String message) {
|
public void onMeasurementProgress(Measurement measurement, String message) {
|
||||||
status.setText(message);
|
Platform.runLater(() -> status.setText(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMeasurementProgress(Measurement measurement, double progress) {
|
public void onMeasurementProgress(Measurement measurement, double progress) {
|
||||||
status.setProgress(progress);
|
Platform.runLater(() -> status.setProgress(progress));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMeasurementResult(Measurement<Double> measurement, Double result, Instant time) {
|
public void onMeasurementResult(Measurement<Double> measurement, Double result, Instant time) {
|
||||||
valueLabel.setText(Double.toString(result));
|
Platform.runLater(() -> valueLabel.setText(Double.toString(result)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName(){
|
public String getName() {
|
||||||
return getDevice().getName();
|
return getDevice().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +111,7 @@ public class VacuumeterView extends DeviceViewController implements MeasurementL
|
|||||||
return getDevice().meta();
|
return getDevice().meta();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle(){
|
public String getTitle() {
|
||||||
return meta().getString("title", getName());
|
return meta().getString("title", getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* 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.test;
|
||||||
|
|
||||||
|
import hep.dataforge.context.GlobalContext;
|
||||||
|
import hep.dataforge.control.measurements.Sensor;
|
||||||
|
import hep.dataforge.control.virtual.VirtualMeasurements;
|
||||||
|
import hep.dataforge.exceptions.ControlException;
|
||||||
|
import inr.numass.readvac.devices.VacCollectorDevice;
|
||||||
|
import inr.numass.readvac.fx.VacCollectorController;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.time.Duration;
|
||||||
|
import javafx.application.Application;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Alexander Nozik
|
||||||
|
*/
|
||||||
|
public class TestVac extends Application {
|
||||||
|
VacCollectorController controller;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(Stage primaryStage) throws IOException, ControlException {
|
||||||
|
|
||||||
|
Sensor<Double> sensor1 = VirtualMeasurements.randomDoubleSensor("vac1", Duration.ofMillis(200), 1e-5, 2e-6);
|
||||||
|
Sensor<Double> sensor2 = VirtualMeasurements.randomDoubleSensor("vac2", Duration.ofMillis(200), 2e-5, 2e-6);
|
||||||
|
Sensor<Double> sensor3 = VirtualMeasurements.randomDoubleSensor("vac3", Duration.ofMillis(200), 1e-7, 1e-8);
|
||||||
|
|
||||||
|
VacCollectorDevice collector = new VacCollectorDevice("collector", GlobalContext.instance(), null, sensor1, sensor2, sensor3);
|
||||||
|
|
||||||
|
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/VacCollector.fxml"));
|
||||||
|
loader.load();
|
||||||
|
controller = loader.getController();
|
||||||
|
controller.setDevice(collector);
|
||||||
|
|
||||||
|
Scene scene = new Scene(loader.getRoot(), 800, 600);
|
||||||
|
|
||||||
|
primaryStage.setTitle("Vacuum measurement test");
|
||||||
|
primaryStage.setScene(scene);
|
||||||
|
primaryStage.show();
|
||||||
|
controller.startMeasurement();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() throws Exception {
|
||||||
|
if(controller != null){
|
||||||
|
controller.stopMeasurement();
|
||||||
|
}
|
||||||
|
super.stop();
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param args the command line arguments
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
launch(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -9,7 +9,7 @@
|
|||||||
<?import org.controlsfx.control.StatusBar?>
|
<?import org.controlsfx.control.StatusBar?>
|
||||||
<?import org.controlsfx.control.ToggleSwitch?>
|
<?import org.controlsfx.control.ToggleSwitch?>
|
||||||
|
|
||||||
<AnchorPane prefHeight="170.0" prefWidth="200.0" styleClass="vacBox" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fxml.PoweredVacBoxController">
|
<AnchorPane prefHeight="170.0" prefWidth="200.0" styleClass="vacBox" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
<stylesheets>
|
<stylesheets>
|
||||||
<URL value="@/styles/vacstyles.css" />
|
<URL value="@/styles/vacstyles.css" />
|
||||||
</stylesheets>
|
</stylesheets>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
<?import org.controlsfx.control.StatusBar?>
|
<?import org.controlsfx.control.StatusBar?>
|
||||||
|
|
||||||
<AnchorPane prefHeight="170.0" prefWidth="200.0" styleClass="vacBox" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fxml.VacBoxController">
|
<AnchorPane prefHeight="170.0" prefWidth="200.0" styleClass="vacBox" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
<stylesheets>
|
<stylesheets>
|
||||||
<URL value="@/styles/vacstyles.css" />
|
<URL value="@/styles/vacstyles.css" />
|
||||||
</stylesheets>
|
</stylesheets>
|
||||||
|
@ -1,45 +1,42 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.scene.text.*?>
|
<?import java.net.URL?>
|
||||||
<?import java.lang.*?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import java.net.*?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
<?import java.util.*?>
|
<?import javafx.scene.layout.BorderPane?>
|
||||||
<?import javafx.scene.*?>
|
<?import javafx.scene.layout.HBox?>
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.layout.Pane?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<AnchorPane id="AnchorPane" prefHeight="600.0" prefWidth="600.0" styleClass="mainFxmlClass" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="inr.numass.readvac.fx.VacCollectorController">
|
<AnchorPane id="AnchorPane" prefHeight="600.0" prefWidth="600.0" styleClass="mainFxmlClass" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="inr.numass.readvac.fx.VacCollectorController">
|
||||||
<stylesheets>
|
<stylesheets>
|
||||||
<URL value="@/styles/vacstyles.css" />
|
<URL value="@/styles/vacstyles.css" />
|
||||||
</stylesheets>
|
</stylesheets>
|
||||||
<children>
|
<children>
|
||||||
<VBox prefHeight="200.0" prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<VBox prefHeight="200.0" prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<children>
|
<children>
|
||||||
<BorderPane prefHeight="50.0">
|
<HBox fx:id="vacBoxHolder" />
|
||||||
<center>
|
<BorderPane prefHeight="50.0">
|
||||||
<Pane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
<center>
|
||||||
<children>
|
<Pane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||||
<Label layoutX="208.0" layoutY="8.0" text="Time: ">
|
<children>
|
||||||
<font>
|
<Label layoutX="208.0" layoutY="8.0" text="Time: ">
|
||||||
<Font size="24.0" />
|
<font>
|
||||||
</font>
|
<Font size="24.0" />
|
||||||
</Label>
|
</font>
|
||||||
<Label layoutX="271.0" layoutY="8.0" text="08.02.2016 15:57">
|
</Label>
|
||||||
<font>
|
<Label fx:id="timeLabel" layoutX="271.0" layoutY="8.0" text="08.02.2016 15:57">
|
||||||
<Font size="24.0" />
|
<font>
|
||||||
</font>
|
<Font size="24.0" />
|
||||||
</Label>
|
</font>
|
||||||
</children>
|
</Label>
|
||||||
</Pane>
|
</children>
|
||||||
</center>
|
</Pane>
|
||||||
</BorderPane>
|
</center>
|
||||||
<ScrollPane prefHeight="175.0" vbarPolicy="NEVER">
|
</BorderPane>
|
||||||
<content>
|
<AnchorPane fx:id="plotHolder" VBox.vgrow="ALWAYS" />
|
||||||
<HBox fx:id="vacBoxHolder" />
|
</children>
|
||||||
</content>
|
</VBox>
|
||||||
</ScrollPane>
|
</children>
|
||||||
<AnchorPane fx:id="plotHolder" />
|
|
||||||
</children>
|
|
||||||
</VBox>
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#pressure{
|
#pressure{
|
||||||
-fx-font-size: 24;
|
-fx-font-size: 24;
|
||||||
-fx-font-style: bold
|
-fx-font-weight: bold
|
||||||
}
|
}
|
||||||
|
|
||||||
#units{
|
#units{
|
||||||
|
Loading…
Reference in New Issue
Block a user