[no commit message]
This commit is contained in:
parent
83081f5879
commit
406549eecf
@ -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
|
||||
}
|
||||
|
||||
}
|
@ -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 <altavir@gmail.com>
|
||||
*/
|
||||
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<Double>, 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<? extends Boolean> 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<Double> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
}
|
||||
|
||||
}
|
@ -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<Double> {
|
||||
|
||||
}
|
@ -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 <altavir@gmail.com>
|
||||
*/
|
||||
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<Double>, 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<Double> 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user