diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/fx/PoweredVacBoxController.java b/numass-control/vac/src/main/java/inr/numass/readvac/fx/PoweredVacBoxController.java deleted file mode 100644 index cd1bd0ad..00000000 --- a/numass-control/vac/src/main/java/inr/numass/readvac/fx/PoweredVacBoxController.java +++ /dev/null @@ -1,31 +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.fx; - -import java.net.URL; -import java.util.ResourceBundle; -import javafx.fxml.FXML; -import org.controlsfx.control.ToggleSwitch; - -/** - * FXML Controller class - * - * @author Alexander Nozik - */ -public class PoweredVacBoxController extends VacBoxController { - - @FXML - ToggleSwitch powerSwitch; - - /** - * Initializes the controller class. - */ - @Override - public void initialize(URL url, ResourceBundle rb) { - // TODO - } - -} diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/fx/PoweredVacuumeterView.java b/numass-control/vac/src/main/java/inr/numass/readvac/fx/PoweredVacuumeterView.java new file mode 100644 index 00000000..a08715a8 --- /dev/null +++ b/numass-control/vac/src/main/java/inr/numass/readvac/fx/PoweredVacuumeterView.java @@ -0,0 +1,120 @@ +/* + * 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 hep.dataforge.control.connections.DeviceView; +import hep.dataforge.control.devices.Device; +import hep.dataforge.control.measurements.Measurement; +import hep.dataforge.control.measurements.MeasurementListener; +import hep.dataforge.values.Value; +import java.io.IOException; +import java.net.URL; +import java.time.Instant; +import java.util.ResourceBundle; +import javafx.beans.value.ObservableValue; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.Node; +import javafx.scene.control.Label; +import org.controlsfx.control.StatusBar; +import org.controlsfx.control.ToggleSwitch; + +/** + * + * @author Alexander Nozik + */ +public class PoweredVacuumeterView extends DeviceView { + + private VacuumeterViewNode controller; + private Node node; + + @Override + public void accept(Device device, String measurementName, Measurement measurement) { + + } + + VacuumeterViewNode getController() { + if (controller == null) { + getComponent(); + } + return controller; + } + + @Override + public void evaluateDeviceException(Device device, String message, Throwable exception) { + //show dialog or tooltip + } + + @Override + public Node getComponent() { + if (getDevice() == null) { + throw new RuntimeException("Connection not attached"); + } else { + if (node == null) { + try { + FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/VacBox.fxml")); + controller = new VacuumeterViewNode(); + loader.setController(controller); + this.node = loader.load(); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } + return node; + } + } + + @Override + public void notifyDeviceStateChanged(Device device, String name, Value state) { + + } + + private class VacuumeterViewNode implements MeasurementListener, Initializable { + + @FXML + Label deviceNameLabel; + @FXML + Label valueLabel; + @FXML + Label unitLabel; + @FXML + StatusBar status; + @FXML + ToggleSwitch powerSwitch; + + @Override + public void initialize(URL location, ResourceBundle resources) { + unitLabel.setText(getDevice().meta().getString("units", "mbar")); + deviceNameLabel.setText(getDevice().getName()); + powerSwitch.selectedProperty().addListener((ObservableValue observable, Boolean oldValue, Boolean newValue) -> { + getDevice().setState("power", newValue); + }); + } + + @Override + public void onMeasurementFailed(Measurement measurement, Throwable exception) { + valueLabel.setText("Err"); + } + + @Override + public void onMeasurementResult(Measurement measurement, Double result, Instant time) { + valueLabel.setText(Double.toString(result)); + } + + @Override + public void onMeasurementProgress(Measurement measurement, String message) { + status.setText(message); + } + + @Override + public void onMeasurementProgress(Measurement measurement, double progress) { + status.setProgress(progress); + } + + } + +} diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacBoxController.java b/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacBoxController.java deleted file mode 100644 index 2d51d1af..00000000 --- a/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacBoxController.java +++ /dev/null @@ -1,39 +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.fx; - -import java.net.URL; -import java.util.ResourceBundle; -import javafx.fxml.FXML; -import javafx.fxml.Initializable; -import javafx.scene.control.Label; -import org.controlsfx.control.StatusBar; - -/** - * FXML Controller class - * - * @author Alexander Nozik - */ -public class VacBoxController implements Initializable { - - @FXML - protected Label deviceNameLabel; - @FXML - protected Label valueLabel; - @FXML - protected Label unitLabel; - @FXML - protected StatusBar status; - - /** - * Initializes the controller class. - */ - @Override - public void initialize(URL url, ResourceBundle rb) { - // TODO - } - -} diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacView.java b/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacView.java deleted file mode 100644 index fa3b5384..00000000 --- a/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacView.java +++ /dev/null @@ -1,17 +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.fx; - -import hep.dataforge.control.devices.DeviceListener; -import hep.dataforge.control.measurements.MeasurementListener; - -/** - * - * @author Alexander Nozik - */ -public interface VacView extends DeviceListener, MeasurementListener { - -} diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacuumeterView.java b/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacuumeterView.java new file mode 100644 index 00000000..637c7672 --- /dev/null +++ b/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacuumeterView.java @@ -0,0 +1,112 @@ +/* + * 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 hep.dataforge.control.connections.DeviceView; +import hep.dataforge.control.devices.Device; +import hep.dataforge.control.measurements.Measurement; +import hep.dataforge.control.measurements.MeasurementListener; +import hep.dataforge.values.Value; +import java.io.IOException; +import java.net.URL; +import java.time.Instant; +import java.util.ResourceBundle; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.Node; +import javafx.scene.control.Label; +import org.controlsfx.control.StatusBar; + +/** + * + * @author Alexander Nozik + */ +public class VacuumeterView extends DeviceView { + + private VacuumeterViewNode controller; + private Node node; + + @Override + public void accept(Device device, String measurementName, Measurement measurement) { + + } + + VacuumeterViewNode getController(){ + if(controller == null){ + getComponent(); + } + return controller; + } + + @Override + public void evaluateDeviceException(Device device, String message, Throwable exception) { + //show dialog or tooltip + } + + @Override + public Node getComponent() { + if (node == null) { + try { + FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/VacBox.fxml")); + controller = new VacuumeterViewNode(); + loader.setController(controller); + this.node = loader.load(); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } + return node; + } + + @Override + public void notifyDeviceStateChanged(Device device, String name, Value state) { + + } + + + + private class VacuumeterViewNode implements MeasurementListener, Initializable{ + + @FXML + Label deviceNameLabel; + @FXML + Label valueLabel; + @FXML + Label unitLabel; + @FXML + StatusBar status; + + @Override + public void initialize(URL location, ResourceBundle resources) { + unitLabel.setText(getDevice().meta().getString("units", "mbar")); + deviceNameLabel.setText(getDevice().getName()); + } + + @Override + public void onMeasurementFailed(Measurement measurement, Throwable exception) { + valueLabel.setText("Err"); + } + + @Override + public void onMeasurementResult(Measurement measurement, Double result, Instant time) { + valueLabel.setText(Double.toString(result)); + } + + @Override + public void onMeasurementProgress(Measurement measurement, String message) { + status.setText(message); + } + + @Override + public void onMeasurementProgress(Measurement measurement, double progress) { + status.setProgress(progress); + } + + + } + +}