diff --git a/numass-control/cryotemp/build.gradle b/numass-control/cryotemp/build.gradle index 029bdc26..dc19332c 100644 --- a/numass-control/cryotemp/build.gradle +++ b/numass-control/cryotemp/build.gradle @@ -10,7 +10,7 @@ if (!hasProperty('mainClass')) { } mainClassName = mainClass -version = "0.1.2"; +version = "0.2.0"; //mainClassName = "inr.numass.readvac.Main" diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/devices/CM32Device.java b/numass-control/vac/src/main/java/inr/numass/readvac/CM32Device.java similarity index 95% rename from numass-control/vac/src/main/java/inr/numass/readvac/devices/CM32Device.java rename to numass-control/vac/src/main/java/inr/numass/readvac/CM32Device.java index 840fd6e3..fef6d626 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/devices/CM32Device.java +++ b/numass-control/vac/src/main/java/inr/numass/readvac/CM32Device.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass.readvac.devices; +package inr.numass.readvac; import hep.dataforge.context.Context; import hep.dataforge.control.devices.PortSensor; diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/devices/MKSBaratronDevice.java b/numass-control/vac/src/main/java/inr/numass/readvac/MKSBaratronDevice.java similarity index 95% rename from numass-control/vac/src/main/java/inr/numass/readvac/devices/MKSBaratronDevice.java rename to numass-control/vac/src/main/java/inr/numass/readvac/MKSBaratronDevice.java index a7109e1c..8f09c746 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/devices/MKSBaratronDevice.java +++ b/numass-control/vac/src/main/java/inr/numass/readvac/MKSBaratronDevice.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass.readvac.devices; +package inr.numass.readvac; import hep.dataforge.context.Context; import hep.dataforge.control.devices.PortSensor; diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/devices/MKSVacDevice.java b/numass-control/vac/src/main/java/inr/numass/readvac/MKSVacDevice.java similarity index 77% rename from numass-control/vac/src/main/java/inr/numass/readvac/devices/MKSVacDevice.java rename to numass-control/vac/src/main/java/inr/numass/readvac/MKSVacDevice.java index 0dc4d9f6..29f5a904 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/devices/MKSVacDevice.java +++ b/numass-control/vac/src/main/java/inr/numass/readvac/MKSVacDevice.java @@ -3,16 +3,18 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass.readvac.devices; +package inr.numass.readvac; import hep.dataforge.context.Context; import hep.dataforge.control.devices.PortSensor; +import hep.dataforge.control.devices.annotations.StateDef; import hep.dataforge.control.measurements.Measurement; import hep.dataforge.control.measurements.SimpleMeasurement; import hep.dataforge.control.ports.PortHandler; import hep.dataforge.description.ValueDef; import hep.dataforge.exceptions.ControlException; import hep.dataforge.meta.Meta; +import hep.dataforge.values.Value; import javafx.beans.property.BooleanProperty; import javafx.beans.property.adapter.JavaBeanBooleanPropertyBuilder; @@ -20,12 +22,12 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; /** - * * @author Alexander Nozik */ @ValueDef(name = "address", def = "253") @ValueDef(name = "channel", def = "5") @ValueDef(name = "powerButton", type = "BOOLEAN", def = "true") +@StateDef(name = "power", writable = true, info = "Device powered up") public class MKSVacDevice extends PortSensor { public MKSVacDevice() { @@ -71,7 +73,7 @@ public class MKSVacDevice extends PortSensor { return null; } switch (stateName) { - case "connection": + case CONNECTION_STATE: return !talk("T?").isEmpty(); case "power": return talk("FP?").equals("ON"); @@ -81,15 +83,17 @@ public class MKSVacDevice extends PortSensor { } } -// @Override -// public void command(String commandName, Value argument) throws ControlException { -// if (commandName.equals("setPower")) { -// boolean powerOn = argument.booleanValue(); -// setPowerOn(powerOn); -// } else { -// super.command(commandName, argument); -// } -// } + @Override + protected void requestStateChange(String stateName, Value value) throws ControlException { + switch (stateName) { + case "power": + setPowerOn(value.booleanValue()); + break; + default: + super.requestStateChange(stateName, value); + } + + } @Override public void shutdown() throws ControlException { @@ -97,8 +101,7 @@ public class MKSVacDevice extends PortSensor { super.shutdown(); } - - + public boolean isPowerOn() { return getState("power").booleanValue(); } @@ -150,21 +153,21 @@ public class MKSVacDevice extends PortSensor { @Override protected synchronized Double doMeasure() throws Exception { // if (getState("power").booleanValue()) { - String answer = talk("PR" + getChannel() + "?"); - if (answer == null || answer.isEmpty()) { - invalidateState(CONNECTION_STATE); - this.progressUpdate("No connection"); - return null; - } - double res = Double.parseDouble(answer); - if (res <= 0) { - this.progressUpdate("No power"); - invalidateState("power"); - return null; - } else { - this.progressUpdate("OK"); - return res; - } + String answer = talk("PR" + getChannel() + "?"); + if (answer == null || answer.isEmpty()) { + invalidateState(CONNECTION_STATE); + this.progressUpdate("No connection"); + return null; + } + double res = Double.parseDouble(answer); + if (res <= 0) { + this.progressUpdate("No power"); + invalidateState("power"); + return null; + } else { + this.progressUpdate("OK"); + return res; + } // } else { // return null; // } diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/devices/VITVacDevice.java b/numass-control/vac/src/main/java/inr/numass/readvac/VITVacDevice.java similarity index 95% rename from numass-control/vac/src/main/java/inr/numass/readvac/devices/VITVacDevice.java rename to numass-control/vac/src/main/java/inr/numass/readvac/VITVacDevice.java index 0150ed79..b1654c42 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/devices/VITVacDevice.java +++ b/numass-control/vac/src/main/java/inr/numass/readvac/VITVacDevice.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass.readvac.devices; +package inr.numass.readvac; import hep.dataforge.context.Context; import hep.dataforge.control.devices.PortSensor; diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/devices/VacCollectorDevice.java b/numass-control/vac/src/main/java/inr/numass/readvac/VacCollectorDevice.java similarity index 96% rename from numass-control/vac/src/main/java/inr/numass/readvac/devices/VacCollectorDevice.java rename to numass-control/vac/src/main/java/inr/numass/readvac/VacCollectorDevice.java index ba32cbcf..c696493b 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/devices/VacCollectorDevice.java +++ b/numass-control/vac/src/main/java/inr/numass/readvac/VacCollectorDevice.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass.readvac.devices; +package inr.numass.readvac; import hep.dataforge.control.collectors.PointCollector; import hep.dataforge.control.collectors.ValueCollector; diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/app/ReadVac.java b/numass-control/vac/src/main/java/inr/numass/readvac/app/ReadVac.java deleted file mode 100644 index c84a9a48..00000000 --- a/numass-control/vac/src/main/java/inr/numass/readvac/app/ReadVac.java +++ /dev/null @@ -1,163 +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.app; - -import hep.dataforge.context.Context; -import hep.dataforge.context.Global; -import hep.dataforge.control.measurements.Sensor; -import hep.dataforge.exceptions.StorageException; -import hep.dataforge.io.MetaFileReader; -import hep.dataforge.meta.Meta; -import hep.dataforge.meta.MetaBuilder; -import hep.dataforge.storage.api.PointLoader; -import hep.dataforge.storage.api.Storage; -import hep.dataforge.storage.commons.LoaderFactory; -import hep.dataforge.tables.TableFormatBuilder; -import hep.dataforge.values.ValueType; -import inr.numass.client.ClientUtils; -import inr.numass.readvac.devices.*; -import inr.numass.readvac.fx.VacCollectorController; -import javafx.application.Application; -import javafx.fxml.FXMLLoader; -import javafx.scene.Scene; -import javafx.stage.Stage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; - -/** - * @author Alexander Nozik - */ -public class ReadVac extends Application { - - VacCollectorController controller; - Logger logger = LoggerFactory.getLogger("ReadVac"); - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - launch(args); - } - - @Override - public void start(Stage primaryStage) throws Exception { - String configFileName = getParameters().getNamed().get("config"); - if (configFileName == null) { - configFileName = "vac-config.xml"; - } - File configFile = new File(configFileName); - Meta config; - if (configFile.exists()) { - config = MetaFileReader.read(configFile).build(); - } else { - config = Meta.empty(); - } - - Context context = Global.instance(); - - Meta p1Meta = config.getMeta("p1", - new MetaBuilder("p1") - .setValue("port", "com::/dev/ttyUSB0") - .setValue("name", "P1") - .build() - ); - - Sensor p1 = new MKSVacDevice(context, p1Meta); - - Meta p2Meta = config.getMeta("p2", - new MetaBuilder("p2") - .setValue("port", "tcp::192.168.111.32:4002") - .setValue("name", "P2") - .build() - ); - - Sensor p2 = new CM32Device(context,p2Meta); - - Meta p3Meta = config.getMeta("p3", - new MetaBuilder("p3") - .setValue("port", "tcp::192.168.111.32:4003") - .setValue("name", "P3") - .build() - ); - - Sensor p3 = new CM32Device(context, p3Meta); - - Meta pxMeta = config.getMeta("px", - new MetaBuilder("px") - .setValue("port", "tcp::192.168.111.32:4003") - .setValue("name", "Px") - .build() - ); - - Sensor px = new VITVacDevice(context,pxMeta); - - Meta baratronMeta = config.getMeta("baratron", - new MetaBuilder("baratron") - .setValue("port", "tcp::192.168.111.33:4004") - .setValue("name", "Baratron") - .build() - ); - - Sensor baratron = new MKSBaratronDevice(context,baratronMeta); - - VacCollectorDevice collector = new VacCollectorDevice(); - collector.configure(config); - collector.setSensors(p1, p2, p3, px, baratron); - collector.init(); - - FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/VacCollector.fxml")); - loader.load(); - controller = loader.getController(); - controller.setDevice(collector); - controller.setLogger(logger); - - controller.setLoaderFactory((VacCollectorDevice device, Storage localStorage) -> { - try { - String runName = ClientUtils.getRunName(config); -// String runName = device.meta().getString("numass.run", ""); -// if (config.hasMeta("numass.server")) { -// try { -// logger.info("Obtaining run information from cetral server..."); -// NumassClient client = new NumassClient(get); -// runName = client.getCurrentRun().getString("path", ""); -// logger.info("Run name is '{}'", runName); -// } catch (Exception ex) { -// logger.warn("Failed to download current run information", ex); -// } -// } - - TableFormatBuilder format = new TableFormatBuilder().setType("timestamp", ValueType.TIME); - device.getSensors().stream().forEach((s) -> { - format.setType(s.getName(), ValueType.NUMBER); - }); - - PointLoader pl = LoaderFactory.buildPointLoder(localStorage, "vactms", runName, "timestamp", format.build()); - return pl; - - } catch (StorageException ex) { - throw new RuntimeException(ex); - } - }); - Scene scene = new Scene(loader.getRoot(), 800, 700); - - primaryStage.setTitle("Numass vacuum measurements"); - primaryStage.setScene(scene); - primaryStage.show(); -// controller.startMeasurement(); - } - - @Override - public void stop() throws Exception { - if (controller != null) { - controller.stopMeasurement(); - controller.getDevice().shutdown(); - } - super.stop(); - } - -} diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/app/ConsoleVac.java b/numass-control/vac/src/main/java/inr/numass/readvac/fx/ConsoleVac.java similarity index 95% rename from numass-control/vac/src/main/java/inr/numass/readvac/app/ConsoleVac.java rename to numass-control/vac/src/main/java/inr/numass/readvac/fx/ConsoleVac.java index ad01c4bc..c59c9a38 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/app/ConsoleVac.java +++ b/numass-control/vac/src/main/java/inr/numass/readvac/fx/ConsoleVac.java @@ -1,4 +1,4 @@ -package inr.numass.readvac.app; +package inr.numass.readvac.fx; import hep.dataforge.control.measurements.Sensor; import org.apache.commons.cli.CommandLine; 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 index 604877a7..88446d7f 100644 --- 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 @@ -22,7 +22,7 @@ import java.util.ResourceBundle; public class PoweredVacuumeterView extends VacuumeterView { @FXML - ToggleSwitch powerSwitch; + private ToggleSwitch powerSwitch; @Override diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/fx/ReadVac.java b/numass-control/vac/src/main/java/inr/numass/readvac/fx/ReadVac.java new file mode 100644 index 00000000..383d67b2 --- /dev/null +++ b/numass-control/vac/src/main/java/inr/numass/readvac/fx/ReadVac.java @@ -0,0 +1,207 @@ +/* + * 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 ch.qos.logback.classic.Level; +import hep.dataforge.context.Context; +import hep.dataforge.control.connections.DeviceConnection; +import hep.dataforge.control.connections.Roles; +import hep.dataforge.exceptions.ControlException; +import hep.dataforge.meta.Meta; +import inr.numass.control.DeviceViewConnection; +import inr.numass.control.NumassControlUtils; +import inr.numass.readvac.VacCollectorDevice; +import javafx.application.Application; +import javafx.application.Platform; +import javafx.scene.Scene; +import javafx.stage.Stage; +import org.slf4j.LoggerFactory; + +import java.util.Locale; + +/** + * @author Alexander Nozik + */ +public class ReadVac extends Application { + private VacCollectorDevice device; + + @Override + public void start(Stage primaryStage) throws Exception { + Locale.setDefault(Locale.US);// чтобы отделение десятичных знаков было точкой + ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME); + rootLogger.setLevel(Level.INFO); + + DeviceViewConnection controller = buildView(); + + Scene scene = new Scene(controller.getPane()); + + primaryStage.setScene(scene); + primaryStage.show(); + + device = setupDevice(controller); + primaryStage.setTitle("Numass vacuum measurements"); + } + + + private VacCollectorDevice setupDevice(DeviceConnection controller) { + Meta config = NumassControlUtils.getConfig(this) + .orElseGet(() -> NumassControlUtils.readResourceMeta("/config/devices.xml")); + + Context ctx = NumassControlUtils.setupContext(config); + Meta mspConfig = NumassControlUtils.findDeviceMeta(config, this::acceptDevice) + .orElseThrow(() -> new RuntimeException("Device configuration not found")); + + + try { + D d = getDeviceFactory().build(ctx, mspConfig); + d.init(); + NumassControlUtils.connectStorage(d, config); + Platform.runLater(() -> { + d.connect(controller, Roles.VIEW_ROLE, Roles.DEVICE_LISTENER_ROLE); + }); + return d; + } catch (ControlException e) { + throw new RuntimeException("Failed to build device", e); + } + } + + @Override + public void stop() throws Exception { + super.stop(); + if (device != null) { + device.shutdown(); + device.getContext().close(); + } + } + + +// VacCollectorView controller; +// Logger logger = LoggerFactory.getLogger("ReadVac"); +// +// /** +// * @param args the command line arguments +// */ +// public static void main(String[] args) { +// launch(args); +// } +// +// @Override +// public void start(Stage primaryStage) throws Exception { +// String configFileName = getParameters().getNamed().get("config"); +// if (configFileName == null) { +// configFileName = "vac-config.xml"; +// } +// File configFile = new File(configFileName); +// Meta config; +// if (configFile.exists()) { +// config = MetaFileReader.read(configFile).build(); +// } else { +// config = Meta.empty(); +// } +// +// Context context = Global.instance(); +// +// Meta p1Meta = config.getMeta("p1", +// new MetaBuilder("p1") +// .setValue("port", "com::/dev/ttyUSB0") +// .setValue("name", "P1") +// .build() +// ); +// +// Sensor p1 = new MKSVacDevice(context, p1Meta); +// +// Meta p2Meta = config.getMeta("p2", +// new MetaBuilder("p2") +// .setValue("port", "tcp::192.168.111.32:4002") +// .setValue("name", "P2") +// .build() +// ); +// +// Sensor p2 = new CM32Device(context,p2Meta); +// +// Meta p3Meta = config.getMeta("p3", +// new MetaBuilder("p3") +// .setValue("port", "tcp::192.168.111.32:4003") +// .setValue("name", "P3") +// .build() +// ); +// +// Sensor p3 = new CM32Device(context, p3Meta); +// +// Meta pxMeta = config.getMeta("px", +// new MetaBuilder("px") +// .setValue("port", "tcp::192.168.111.32:4003") +// .setValue("name", "Px") +// .build() +// ); +// +// Sensor px = new VITVacDevice(context,pxMeta); +// +// Meta baratronMeta = config.getMeta("baratron", +// new MetaBuilder("baratron") +// .setValue("port", "tcp::192.168.111.33:4004") +// .setValue("name", "Baratron") +// .build() +// ); +// +// Sensor baratron = new MKSBaratronDevice(context,baratronMeta); +// +// VacCollectorDevice collector = new VacCollectorDevice(); +// collector.configure(config); +// collector.setSensors(p1, p2, p3, px, baratron); +// collector.init(); +// +// FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/VacCollector.fxml")); +// loader.load(); +// controller = loader.getController(); +// controller.setDevice(collector); +// controller.setLogger(logger); +// +// controller.setLoaderFactory((VacCollectorDevice device, Storage localStorage) -> { +// try { +// String runName = ClientUtils.getRunName(config); +//// String runName = device.meta().getString("numass.run", ""); +//// if (config.hasMeta("numass.server")) { +//// try { +//// logger.info("Obtaining run information from cetral server..."); +//// NumassClient client = new NumassClient(get); +//// runName = client.getCurrentRun().getString("path", ""); +//// logger.info("Run name is '{}'", runName); +//// } catch (Exception ex) { +//// logger.warn("Failed to download current run information", ex); +//// } +//// } +// +// TableFormatBuilder format = new TableFormatBuilder().setType("timestamp", ValueType.TIME); +// device.getSensors().stream().forEach((s) -> { +// format.setType(s.getName(), ValueType.NUMBER); +// }); +// +// PointLoader pl = LoaderFactory.buildPointLoder(localStorage, "vactms", runName, "timestamp", format.build()); +// return pl; +// +// } catch (StorageException ex) { +// throw new RuntimeException(ex); +// } +// }); +// Scene scene = new Scene(loader.getRoot(), 800, 700); +// +// primaryStage.setTitle("Numass vacuum measurements"); +// primaryStage.setScene(scene); +// primaryStage.show(); +//// controller.startMeasurement(); +// } +// +// @Override +// public void stop() throws Exception { +// if (controller != null) { +// controller.stopMeasurement(); +// controller.getDevice().shutdown(); +// } +// super.stop(); +// } + +} diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/app/TestVac.java b/numass-control/vac/src/main/java/inr/numass/readvac/fx/TestVac.java similarity index 90% rename from numass-control/vac/src/main/java/inr/numass/readvac/app/TestVac.java rename to numass-control/vac/src/main/java/inr/numass/readvac/fx/TestVac.java index e82f8117..6fbd0ede 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/app/TestVac.java +++ b/numass-control/vac/src/main/java/inr/numass/readvac/fx/TestVac.java @@ -3,25 +3,25 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass.readvac.app; +package inr.numass.readvac.fx; import hep.dataforge.control.measurements.Sensor; import hep.dataforge.control.virtual.Virtual; -import inr.numass.readvac.devices.VacCollectorDevice; -import inr.numass.readvac.fx.VacCollectorController; -import java.time.Duration; +import inr.numass.readvac.VacCollectorDevice; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.stage.Stage; +import java.time.Duration; + /** * * @author Alexander Nozik */ public class TestVac extends Application { - VacCollectorController controller; + VacCollectorView controller; @Override public void start(Stage primaryStage) { @@ -75,7 +75,6 @@ public class TestVac extends Application { @Override public void stop() throws Exception { if (controller != null) { - controller.stopMeasurement(); controller.getDevice().shutdown(); } super.stop(); diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacCollectorController.java b/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacCollectorView.java similarity index 88% rename from numass-control/vac/src/main/java/inr/numass/readvac/fx/VacCollectorController.java rename to numass-control/vac/src/main/java/inr/numass/readvac/fx/VacCollectorView.java index 6d480558..c19d6f8a 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacCollectorController.java +++ b/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacCollectorView.java @@ -31,7 +31,7 @@ import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.TableFormatBuilder; import hep.dataforge.values.Value; import hep.dataforge.values.ValueType; -import inr.numass.readvac.devices.VacCollectorDevice; +import inr.numass.readvac.VacCollectorDevice; import javafx.application.Platform; import javafx.beans.value.ObservableValue; import javafx.collections.FXCollections; @@ -65,19 +65,17 @@ import java.util.function.BiFunction; * * @author Alexander Nozik */ -public class VacCollectorController implements Initializable, DeviceListener, MeasurementListener { +public class VacCollectorView implements Initializable, DeviceListener, MeasurementListener { private final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ISO_LOCAL_DATE_TIME; private final String[] intervalNames = {"1 sec", "5 sec", "10 sec", "30 sec", "1 min"}; private final int[] intervals = {1000, 5000, 10000, 30000, 60000}; private final List views = new ArrayList<>(); - private LogFragment consoleWindow; - private Logger logger; - private LoaderConnection storageConnection; +// private LoaderConnection storageConnection; private VacCollectorDevice device; - private PlotContainer plotContainer; private TimePlottableGroup plottables; - private BiFunction loaderFactory; +// private BiFunction loaderFactory; + @FXML private AnchorPane plotHolder; @FXML @@ -98,7 +96,6 @@ public class VacCollectorController implements Initializable, DeviceListener, Me */ @Override public void initialize(URL url, ResourceBundle rb) { - plotContainer = PlotContainer.anchorTo(plotHolder); intervalSelector.setItems(FXCollections.observableArrayList(intervalNames)); intervalSelector.getSelectionModel().select(1); intervalSelector.getSelectionModel().selectedIndexProperty().addListener((ObservableValue observable, Number oldValue, Number newValue) -> { @@ -111,7 +108,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me } }); - consoleWindow = new LogFragment(); + LogFragment consoleWindow = new LogFragment(); new FragmentWindow(consoleWindow).bindTo(logButton); consoleWindow.hookStd(); } @@ -170,7 +167,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me private void setupView() { vacBoxHolder.getChildren().clear(); plottables = new TimePlottableGroup(); - views.stream().forEach((controller) -> { + views.forEach((controller) -> { vacBoxHolder.getChildren().add(controller.getComponent()); TimePlottable plot = new TimePlottable(controller.getTitle(), controller.getName()); @@ -179,7 +176,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me }); plottables.setValue("thickness", 3); plottables.setMaxAge(java.time.Duration.ofHours(3)); - plotContainer.setPlot(setupPlot(plottables)); + PlotContainer.anchorTo(plotHolder).setPlot(setupPlot(plottables)); } private FXPlotFrame setupPlot(TimePlottableGroup plottables) { @@ -195,12 +192,12 @@ public class VacCollectorController implements Initializable, DeviceListener, Me return frame; } - public void startMeasurement() throws ControlException { + private void startMeasurement() throws ControlException { getDevice().startMeasurement().addListener(this); startStopButton.setSelected(true); } - public void stopMeasurement() { + private void stopMeasurement() { try { getDevice().stopMeasurement(false); for (Sensor sensor : getDevice().getSensors()) { @@ -262,7 +259,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me loader = loaderFactory.apply(device, localStorage); } else { TableFormatBuilder format = new TableFormatBuilder().setType("timestamp", ValueType.TIME); - device.getSensors().stream().forEach((s) -> { + device.getSensors().forEach((s) -> { format.setType(s.getName(), ValueType.NUMBER); }); @@ -284,17 +281,8 @@ public class VacCollectorController implements Initializable, DeviceListener, Me /** * @return the logger */ - public Logger getLogger() { - if (logger == null) { - logger = LoggerFactory.getLogger("ValCollector"); - } - return logger; + private Logger getLogger() { + return device.getLogger(); } - /** - * @param logger the logger to set - */ - public void setLogger(Logger logger) { - this.logger = logger; - } } diff --git a/numass-control/vac/src/main/resources/fxml/VacCollector.fxml b/numass-control/vac/src/main/resources/fxml/VacCollector.fxml index 13f9de23..85ff92e9 100644 --- a/numass-control/vac/src/main/resources/fxml/VacCollector.fxml +++ b/numass-control/vac/src/main/resources/fxml/VacCollector.fxml @@ -1,19 +1,11 @@ - - - - - - - - - - + + - - + +