[no commit message]
This commit is contained in:
parent
68ff2c89da
commit
661de3394b
@ -49,6 +49,7 @@ public class VacCollectorDevice extends Sensor<DataPoint> {
|
||||
|
||||
@Override
|
||||
protected Measurement<DataPoint> createMeasurement() {
|
||||
//TODO use meta
|
||||
return new VacuumMeasurement();
|
||||
}
|
||||
|
||||
@ -72,7 +73,7 @@ public class VacCollectorDevice extends Sensor<DataPoint> {
|
||||
currentTask = executor.scheduleWithFixedDelay(() -> {
|
||||
sensorMap.entrySet().stream().parallel().forEach((entry) -> {
|
||||
try {
|
||||
collector.put(entry.getKey(), entry.getValue().getMeasurement().getResult());
|
||||
collector.put(entry.getKey(), entry.getValue().read());
|
||||
} catch (MeasurementException ex) {
|
||||
onError(ex);
|
||||
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.MeasurementListener;
|
||||
import hep.dataforge.data.DataPoint;
|
||||
import hep.dataforge.exceptions.ControlException;
|
||||
import hep.dataforge.exceptions.MeasurementException;
|
||||
import hep.dataforge.meta.Meta;
|
||||
import hep.dataforge.meta.MetaBuilder;
|
||||
import hep.dataforge.plots.PlotFrame;
|
||||
@ -26,8 +28,10 @@ import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
|
||||
@ -47,6 +51,8 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
|
||||
private AnchorPane plotHolder;
|
||||
@FXML
|
||||
private HBox vacBoxHolder;
|
||||
@FXML
|
||||
private Label timeLabel;
|
||||
|
||||
@Override
|
||||
public void evaluateDeviceException(Device device, String message, Throwable exception) {
|
||||
@ -77,7 +83,11 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
|
||||
|
||||
@Override
|
||||
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() {
|
||||
@ -94,11 +104,11 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
|
||||
private PlotFrame setupPlot(DynamicPlottableSet plottables) {
|
||||
Meta plotConfig = new MetaBuilder("plotFrame")
|
||||
.setNode(new MetaBuilder("yAxis")
|
||||
.setValue("logAxis", true)
|
||||
.setValue("type", "log")
|
||||
.setValue("axisTitle", "pressure")
|
||||
.setValue("axisUnits", "mbar")
|
||||
)
|
||||
.setValue("xAxis.timeAxis", true);
|
||||
.setValue("xAxis.type", "time");
|
||||
JFreeChartFrame frame = new JFreeChartFrame("pressure", plotConfig);
|
||||
frame.addAll(plottables);
|
||||
return frame;
|
||||
@ -121,8 +131,16 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
|
||||
setupView();
|
||||
}
|
||||
|
||||
private void startMeasurement(){
|
||||
getDevice().startMeasurement();
|
||||
public void startMeasurement() throws ControlException {
|
||||
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.time.Instant;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
@ -69,8 +70,10 @@ public class VacuumeterView extends DeviceViewController implements MeasurementL
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
unitLabel.setText(getDevice().meta().getString("units", "mbar"));
|
||||
deviceNameLabel.setText(getDevice().getName());
|
||||
Platform.runLater(() -> {
|
||||
unitLabel.setText(getDevice().meta().getString("units", "mbar"));
|
||||
deviceNameLabel.setText(getDevice().getName());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,26 +83,26 @@ public class VacuumeterView extends DeviceViewController implements MeasurementL
|
||||
|
||||
@Override
|
||||
public void onMeasurementFailed(Measurement measurement, Throwable exception) {
|
||||
valueLabel.setText("Err");
|
||||
Platform.runLater(() -> valueLabel.setText("Err"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeasurementProgress(Measurement measurement, String message) {
|
||||
status.setText(message);
|
||||
Platform.runLater(() -> status.setText(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeasurementProgress(Measurement measurement, double progress) {
|
||||
status.setProgress(progress);
|
||||
Platform.runLater(() -> status.setProgress(progress));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeasurementResult(Measurement<Double> measurement, Double result, Instant time) {
|
||||
valueLabel.setText(Double.toString(result));
|
||||
Platform.runLater(() -> valueLabel.setText(Double.toString(result)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(){
|
||||
public String getName() {
|
||||
return getDevice().getName();
|
||||
}
|
||||
|
||||
@ -108,7 +111,7 @@ public class VacuumeterView extends DeviceViewController implements MeasurementL
|
||||
return getDevice().meta();
|
||||
}
|
||||
|
||||
public String getTitle(){
|
||||
public String getTitle() {
|
||||
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.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>
|
||||
<URL value="@/styles/vacstyles.css" />
|
||||
</stylesheets>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?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>
|
||||
<URL value="@/styles/vacstyles.css" />
|
||||
</stylesheets>
|
||||
|
@ -1,45 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import java.net.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.scene.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import java.net.URL?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.BorderPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?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>
|
||||
<URL value="@/styles/vacstyles.css" />
|
||||
</stylesheets>
|
||||
<children>
|
||||
<VBox prefHeight="200.0" prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<BorderPane prefHeight="50.0">
|
||||
<center>
|
||||
<Pane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||
<children>
|
||||
<Label layoutX="208.0" layoutY="8.0" text="Time: ">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label layoutX="271.0" layoutY="8.0" text="08.02.2016 15:57">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</Pane>
|
||||
</center>
|
||||
</BorderPane>
|
||||
<ScrollPane prefHeight="175.0" vbarPolicy="NEVER">
|
||||
<content>
|
||||
<HBox fx:id="vacBoxHolder" />
|
||||
</content>
|
||||
</ScrollPane>
|
||||
<AnchorPane fx:id="plotHolder" />
|
||||
</children>
|
||||
</VBox>
|
||||
</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">
|
||||
<children>
|
||||
<HBox fx:id="vacBoxHolder" />
|
||||
<BorderPane prefHeight="50.0">
|
||||
<center>
|
||||
<Pane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||
<children>
|
||||
<Label layoutX="208.0" layoutY="8.0" text="Time: ">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label fx:id="timeLabel" layoutX="271.0" layoutY="8.0" text="08.02.2016 15:57">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</Pane>
|
||||
</center>
|
||||
</BorderPane>
|
||||
<AnchorPane fx:id="plotHolder" VBox.vgrow="ALWAYS" />
|
||||
</children>
|
||||
</VBox>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#pressure{
|
||||
-fx-font-size: 24;
|
||||
-fx-font-style: bold
|
||||
-fx-font-weight: bold
|
||||
}
|
||||
|
||||
#units{
|
||||
|
Loading…
Reference in New Issue
Block a user