[no commit message]
This commit is contained in:
parent
406549eecf
commit
68ff2c89da
@ -16,7 +16,7 @@
|
||||
package inr.numass.control.msp;
|
||||
|
||||
import hep.dataforge.context.Context;
|
||||
import hep.dataforge.context.GlobalContext;
|
||||
import hep.dataforge.control.connections.Roles;
|
||||
import hep.dataforge.control.connections.StorageConnection;
|
||||
import hep.dataforge.control.devices.SingleMeasurementDevice;
|
||||
import hep.dataforge.control.measurements.AbstractMeasurement;
|
||||
@ -380,7 +380,7 @@ public class MspDevice extends SingleMeasurementDevice implements PortHandler.Po
|
||||
|
||||
private void prepareLoaders() {
|
||||
loaders = new ArrayList<>();
|
||||
forEachTypedConnection("storage", StorageConnection.class, (StorageConnection con) -> {
|
||||
forEachTypedConnection(Roles.STORAGE_ROLE, StorageConnection.class, (StorageConnection con) -> {
|
||||
try {
|
||||
Storage storage = con.getStorage();
|
||||
|
||||
|
@ -16,6 +16,7 @@ import hep.dataforge.exceptions.ControlException;
|
||||
import hep.dataforge.exceptions.MeasurementException;
|
||||
import hep.dataforge.meta.Meta;
|
||||
import hep.dataforge.values.Value;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executors;
|
||||
@ -43,7 +44,7 @@ public class VacCollectorDevice extends Sensor<DataPoint> {
|
||||
@Override
|
||||
protected Object calculateState(String stateName) throws ControlException {
|
||||
//TODO add dot path notation for states
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
return Value.NULL;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -55,6 +56,10 @@ public class VacCollectorDevice extends Sensor<DataPoint> {
|
||||
public String type() {
|
||||
return "Numass vacuum";
|
||||
}
|
||||
|
||||
public Collection<Sensor<Double>> getSensors(){
|
||||
return sensorMap.values();
|
||||
}
|
||||
|
||||
private class VacuumMeasurement extends AbstractMeasurement<DataPoint> {
|
||||
|
||||
@ -91,5 +96,5 @@ public class VacCollectorDevice extends Sensor<DataPoint> {
|
||||
return isRunning;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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";
|
||||
}
|
||||
|
||||
}
|
@ -5,116 +5,28 @@
|
||||
*/
|
||||
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 {
|
||||
public class PoweredVacuumeterView extends VacuumeterView {
|
||||
|
||||
private VacuumeterViewNode controller;
|
||||
private Node node;
|
||||
@FXML
|
||||
ToggleSwitch powerSwitch;
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* 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.Roles;
|
||||
import hep.dataforge.control.devices.Device;
|
||||
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.meta.Meta;
|
||||
import hep.dataforge.meta.MetaBuilder;
|
||||
import hep.dataforge.plots.PlotFrame;
|
||||
import hep.dataforge.plots.data.DynamicPlottable;
|
||||
import hep.dataforge.plots.data.DynamicPlottableSet;
|
||||
import hep.dataforge.plots.fx.PlotContainer;
|
||||
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
|
||||
import hep.dataforge.values.Value;
|
||||
import inr.numass.readvac.devices.MKSVacDevice;
|
||||
import inr.numass.readvac.devices.VacCollectorDevice;
|
||||
import java.net.URL;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
|
||||
/**
|
||||
* FXML Controller class
|
||||
*
|
||||
* @author Alexander Nozik <altavir@gmail.com>
|
||||
*/
|
||||
public class VacCollectorController implements Initializable, DeviceListener, MeasurementListener<DataPoint> {
|
||||
|
||||
private VacCollectorDevice device;
|
||||
private final List<VacuumeterView> views = new ArrayList<>();
|
||||
private PlotContainer plotContainer;
|
||||
private DynamicPlottableSet plottables;
|
||||
|
||||
@FXML
|
||||
private AnchorPane plotHolder;
|
||||
@FXML
|
||||
private HBox vacBoxHolder;
|
||||
|
||||
@Override
|
||||
public void evaluateDeviceException(Device device, String message, Throwable exception) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the controller class.
|
||||
*/
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
plotContainer = PlotContainer.anchorTo(plotHolder);
|
||||
}
|
||||
|
||||
public VacCollectorDevice getDevice() {
|
||||
return device;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyDeviceStateChanged(Device device, String name, Value state) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeasurementFailed(Measurement measurement, Throwable exception) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@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.
|
||||
}
|
||||
|
||||
private void setupView() {
|
||||
vacBoxHolder.getChildren().clear();
|
||||
plottables = new DynamicPlottableSet();
|
||||
views.stream().forEach((controller) -> {
|
||||
vacBoxHolder.getChildren().add(controller.getComponent());
|
||||
plottables.addPlottable(new DynamicPlottable(controller.getTitle(),
|
||||
controller.meta(), controller.getName()));
|
||||
});
|
||||
plotContainer.setPlot(setupPlot(plottables));
|
||||
}
|
||||
|
||||
private PlotFrame setupPlot(DynamicPlottableSet plottables) {
|
||||
Meta plotConfig = new MetaBuilder("plotFrame")
|
||||
.setNode(new MetaBuilder("yAxis")
|
||||
.setValue("logAxis", true)
|
||||
.setValue("axisTitle", "pressure")
|
||||
.setValue("axisUnits", "mbar")
|
||||
)
|
||||
.setValue("xAxis.timeAxis", true);
|
||||
JFreeChartFrame frame = new JFreeChartFrame("pressure", plotConfig);
|
||||
frame.addAll(plottables);
|
||||
return frame;
|
||||
}
|
||||
|
||||
public void setDevice(VacCollectorDevice device) {
|
||||
this.device = device;
|
||||
device.getSensors().stream().map((sensor) -> {
|
||||
VacuumeterView controller;
|
||||
if (sensor instanceof MKSVacDevice) {
|
||||
controller = new PoweredVacuumeterView();
|
||||
} else {
|
||||
controller = new VacuumeterView();
|
||||
}
|
||||
sensor.connect(controller, Roles.DEVICE_LISTENER_ROLE, Roles.MEASUREMENT_CONSUMER_ROLE);
|
||||
return controller;
|
||||
}).forEach((controller) -> {
|
||||
views.add(controller);
|
||||
});
|
||||
setupView();
|
||||
}
|
||||
|
||||
private void startMeasurement(){
|
||||
getDevice().startMeasurement();
|
||||
}
|
||||
|
||||
}
|
@ -5,10 +5,13 @@
|
||||
*/
|
||||
package inr.numass.readvac.fx;
|
||||
|
||||
import hep.dataforge.control.connections.DeviceView;
|
||||
import hep.dataforge.content.Named;
|
||||
import hep.dataforge.control.connections.DeviceViewController;
|
||||
import hep.dataforge.control.devices.Device;
|
||||
import hep.dataforge.control.measurements.Measurement;
|
||||
import hep.dataforge.control.measurements.MeasurementListener;
|
||||
import hep.dataforge.meta.Annotated;
|
||||
import hep.dataforge.meta.Meta;
|
||||
import hep.dataforge.values.Value;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
@ -25,35 +28,37 @@ import org.controlsfx.control.StatusBar;
|
||||
*
|
||||
* @author Alexander Nozik <altavir@gmail.com>
|
||||
*/
|
||||
public class VacuumeterView extends DeviceView {
|
||||
public class VacuumeterView extends DeviceViewController implements MeasurementListener<Double>, Initializable, Named, Annotated {
|
||||
|
||||
private VacuumeterViewNode controller;
|
||||
private Node node;
|
||||
protected Node node;
|
||||
|
||||
@FXML
|
||||
Label deviceNameLabel;
|
||||
|
||||
@FXML
|
||||
StatusBar status;
|
||||
|
||||
@FXML
|
||||
Label unitLabel;
|
||||
|
||||
@FXML
|
||||
Label valueLabel;
|
||||
|
||||
@Override
|
||||
public void accept(Device device, String measurementName, Measurement measurement) {
|
||||
|
||||
measurement.addListener(this);
|
||||
}
|
||||
|
||||
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);
|
||||
loader.setController(this);
|
||||
this.node = loader.load();
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
@ -62,51 +67,48 @@ public class VacuumeterView extends DeviceView {
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
unitLabel.setText(getDevice().meta().getString("units", "mbar"));
|
||||
deviceNameLabel.setText(getDevice().getName());
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onMeasurementFailed(Measurement measurement, Throwable exception) {
|
||||
valueLabel.setText("Err");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeasurementProgress(Measurement measurement, String message) {
|
||||
status.setText(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeasurementProgress(Measurement measurement, double progress) {
|
||||
status.setProgress(progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeasurementResult(Measurement<Double> measurement, Double result, Instant time) {
|
||||
valueLabel.setText(Double.toString(result));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(){
|
||||
return getDevice().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Meta meta() {
|
||||
return getDevice().meta();
|
||||
}
|
||||
|
||||
public String getTitle(){
|
||||
return meta().getString("title", getName());
|
||||
}
|
||||
}
|
||||
|
@ -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">
|
||||
<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">
|
||||
<stylesheets>
|
||||
<URL value="@/styles/vacstyles.css" />
|
||||
</stylesheets>
|
||||
|
45
numass-control/vac/src/main/resources/fxml/VacCollector.fxml
Normal file
45
numass-control/vac/src/main/resources/fxml/VacCollector.fxml
Normal file
@ -0,0 +1,45 @@
|
||||
<?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.*?>
|
||||
|
||||
<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">
|
||||
<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>
|
||||
</AnchorPane>
|
Loading…
Reference in New Issue
Block a user