Fixed devices library and vacuum measurements

This commit is contained in:
Alexander Nozik 2016-02-14 15:28:44 +03:00
parent f41e2869b8
commit b74775efc4
7 changed files with 69 additions and 32 deletions

View File

@ -5,10 +5,13 @@
*/
package inr.numass.readvac.fx;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import org.controlsfx.control.ToggleSwitch;
/**
@ -20,6 +23,21 @@ public class PoweredVacuumeterView extends VacuumeterView {
@FXML
ToggleSwitch powerSwitch;
@Override
public Node getComponent() {
if (node == null) {
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/PoweredVacBox.fxml"));
loader.setController(this);
this.node = loader.load();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
return node;
}
@Override
public void initialize(URL location, ResourceBundle resources) {
unitLabel.setText(getDevice().meta().getString("units", "mbar"));

View File

@ -119,7 +119,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
this.device = device;
device.getSensors().stream().map((sensor) -> {
VacuumeterView controller;
if (sensor instanceof MKSVacDevice) {
if (sensor.hasState("power")) {
controller = new PoweredVacuumeterView();
} else {
controller = new VacuumeterView();

View File

@ -56,7 +56,7 @@ public class VacuumeterView extends DeviceViewController implements MeasurementL
@Override
public void evaluateDeviceException(Device device, String message, Throwable exception) {
//show dialog or tooltip
Platform.runLater(() -> status.setText("ERROR: " + message));
}
public Node getComponent() {

View File

@ -7,19 +7,15 @@ package inr.numass.readvac.test;
import hep.dataforge.context.GlobalContext;
import hep.dataforge.control.measurements.Sensor;
import hep.dataforge.control.virtual.SensorFactory;
import hep.dataforge.control.virtual.Virtual;
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 java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.slf4j.LoggerFactory;
/**
*
@ -35,8 +31,16 @@ public class TestVac extends Application {
Sensor<Double> sensor1 = Virtual.randomDoubleSensor("vac1", Duration.ofMillis(200), 1e-5, 2e-6);
Sensor<Double> sensor2 = Virtual.randomDoubleSensor("vac2", Duration.ofMillis(200), 2e-5, 2e-6);
Sensor<Double> sensor3 = Virtual.randomDoubleSensor("vac3", Duration.ofMillis(200), 1e-7, 1e-8);
Sensor<Double> poweredSensor = new SensorFactory<Double>("vac4", (sensor) -> {
if (sensor.getState("power").booleanValue()) {
return 1e-6;
} else {
return null;
}
}).addState("power").build();
VacCollectorDevice collector = new VacCollectorDevice("collector", GlobalContext.instance(), null, sensor3, sensor2, sensor1);
VacCollectorDevice collector = new VacCollectorDevice("collector",
GlobalContext.instance(), null, poweredSensor, sensor3, sensor2, sensor1);
collector.init();
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/VacCollector.fxml"));

View File

@ -1,9 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.String?>
<?import java.net.URL?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>
<?import org.controlsfx.control.StatusBar?>
@ -16,20 +18,29 @@
<children>
<VBox layoutX="50.0" layoutY="6.0" prefHeight="200.0" prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Pane prefHeight="40.0" styleClass="beveled">
<Pane minHeight="30.0">
<children>
<Label id="name" fx:id="deviceNameLabel" alignment="CENTER" layoutX="12.0" prefHeight="40.0" prefWidth="176.0" text="device Name" />
<Label id="name" fx:id="deviceNameLabel" alignment="CENTER" prefHeight="40.0" prefWidth="200.0" text="device Name" />
</children>
<styleClass>
<String fx:value="beveled" />
<String fx:value="namePane" />
</styleClass>
</Pane>
<Separator prefWidth="200.0" />
<Pane prefHeight="60.0" styleClass="beveled">
<children>
<Label id="pressure" fx:id="valueLabel" alignment="CENTER_RIGHT" layoutX="14.0" prefHeight="60.0" prefWidth="90.0" text="1.22e-7" />
<Label id="units" fx:id="unitLabel" layoutX="124.0" prefHeight="60.0" prefWidth="62.0" text="mbar" />
</children>
</Pane>
<Separator prefWidth="200.0" />
<Pane VBox.vgrow="ALWAYS">
<Separator />
<BorderPane>
<left>
<Label id="pressure" fx:id="valueLabel" alignment="CENTER_RIGHT" prefHeight="60.0" prefWidth="100.0" text="#.##E-0" BorderPane.alignment="CENTER" />
</left>
<right>
<Label id="units" fx:id="unitLabel" prefHeight="60.0" prefWidth="75.0" text="mbar" BorderPane.alignment="CENTER" />
</right>
<center>
<Pane minWidth="-Infinity" prefWidth="25.0" BorderPane.alignment="CENTER" />
</center>
</BorderPane>
<Separator />
<Pane minHeight="30.0" VBox.vgrow="ALWAYS">
<children>
<ToggleSwitch fx:id="powerSwitch" layoutX="58.0" layoutY="8.0" text="Power" />
</children>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.String?>
<?import java.net.URL?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Separator?>
@ -16,10 +17,14 @@
<children>
<VBox AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Pane styleClass="beveled">
<Pane minHeight="30.0">
<children>
<Label id="name" fx:id="deviceNameLabel" alignment="CENTER" prefHeight="40.0" prefWidth="200.0" text="device Name" />
</children>
<styleClass>
<String fx:value="beveled" />
<String fx:value="namePane" />
</styleClass>
</Pane>
<Separator />
<BorderPane>

View File

@ -5,7 +5,6 @@
<?import javafx.scene.control.Separator?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
@ -16,24 +15,24 @@
<children>
<HBox AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<VBox fx:id="vacBoxHolder" styleClass="beveled"/>
<VBox fx:id="vacBoxHolder" minWidth="200.0" styleClass="beveled" />
<Separator orientation="VERTICAL" />
<VBox alignment="TOP_CENTER" HBox.hgrow="ALWAYS">
<children>
<Pane prefHeight="50.0" styleClass="beveled">
<HBox prefHeight="50.0">
<children>
<Label layoutX="208.0" layoutY="8.0" text="Time: ">
<Label alignment="CENTER_RIGHT" prefHeight="50.0" prefWidth="180.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">
<Label fx:id="timeLabel" prefHeight="50.0" prefWidth="312.0" text="08.02.2016 15:57" HBox.hgrow="ALWAYS">
<font>
<Font size="24.0" />
</font>
</Label>
</children>
</Pane>
</HBox>
<AnchorPane fx:id="plotHolder" VBox.vgrow="ALWAYS" />
</children>
</VBox>