diff --git a/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspViewController.java b/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspViewController.java index a852196d..bafced8c 100644 --- a/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspViewController.java +++ b/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspViewController.java @@ -39,14 +39,6 @@ import hep.dataforge.values.Value; import inr.numass.client.NumassClient; import inr.numass.control.msp.MspDevice; import inr.numass.control.msp.MspListener; -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.net.URL; -import java.text.ParseException; -import java.util.List; -import java.util.Map; -import java.util.ResourceBundle; import javafx.application.Platform; import javafx.beans.value.ObservableValue; import javafx.collections.FXCollections; @@ -66,6 +58,15 @@ import javafx.util.StringConverter; import org.controlsfx.control.ToggleSwitch; import org.slf4j.LoggerFactory; +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.text.ParseException; +import java.util.List; +import java.util.Map; +import java.util.ResourceBundle; + /** * FXML Controller class * @@ -76,19 +77,23 @@ public class MspViewController implements Initializable, MspListener { public static final String MSP_DEVICE_TYPE = "msp"; public static final String DEFAULT_CONFIG_LOCATION = "msp-config.xml"; - - private MspDevice device; - - private Configuration viewConfig; - - private JFreeChartFrame plot; - private final DynamicPlottableSet plottables = new DynamicPlottableSet(); - private final String mspName = "msp"; - + private MspDevice device; + private Configuration viewConfig; + private JFreeChartFrame plot; private ConsoleFragment logArea; - + private StorageConnection connection; + @FXML + private Slider autoRangeSlider; + @FXML + private ToggleSwitch fillamentButton; + @FXML + private Circle fillamentIndicator; + @FXML + private ToggleButton plotButton; + @FXML + private AnchorPane plotPane; private final ConfigChangeListener viewConfigObserver = new ConfigChangeListener() { @Override @@ -102,19 +107,6 @@ public class MspViewController implements Initializable, MspListener { } }; - - private StorageConnection connection; - - @FXML - private Slider autoRangeSlider; - @FXML - private ToggleSwitch fillamentButton; - @FXML - private Circle fillamentIndicator; - @FXML - private ToggleButton plotButton; - @FXML - private AnchorPane plotPane; @FXML private ToggleButton consoleButton; @FXML 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/VacCollectorController.java index 3f794830..08cbf84b 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/VacCollectorController.java @@ -17,9 +17,9 @@ import hep.dataforge.exceptions.MeasurementException; import hep.dataforge.fx.ConsoleFragment; 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.FXPlotFrame; import hep.dataforge.plots.fx.PlotContainer; import hep.dataforge.plots.jfreechart.JFreeChartFrame; import hep.dataforge.storage.api.PointLoader; @@ -31,16 +31,6 @@ import hep.dataforge.tables.TableFormatBuilder; import hep.dataforge.values.Value; import hep.dataforge.values.ValueType; import inr.numass.readvac.devices.VacCollectorDevice; -import java.io.File; -import java.net.URL; -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.List; -import java.util.ResourceBundle; -import java.util.function.BiFunction; import javafx.application.Platform; import javafx.beans.value.ObservableValue; import javafx.collections.FXCollections; @@ -58,6 +48,17 @@ import org.controlsfx.control.Notifications; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.net.URL; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; +import java.util.ResourceBundle; +import java.util.function.BiFunction; + /** * FXML Controller class * @@ -65,23 +66,17 @@ import org.slf4j.LoggerFactory; */ public class VacCollectorController implements Initializable, DeviceListener, MeasurementListener { - private Logger logger; - 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 LoaderConnection storageConnection; - - private VacCollectorDevice device; private final List views = new ArrayList<>(); + ConsoleFragment consoleWindow; + private Logger logger; + private LoaderConnection storageConnection; + private VacCollectorDevice device; private PlotContainer plotContainer; private DynamicPlottableSet plottables; private BiFunction loaderFactory; - - ConsoleFragment consoleWindow; - @FXML private AnchorPane plotHolder; @FXML @@ -129,6 +124,23 @@ public class VacCollectorController implements Initializable, DeviceListener, Me return device; } + public void setDevice(VacCollectorDevice device) { + this.device = device; + device.getSensors().stream().map((sensor) -> { + VacuumeterView controller; + if (sensor.meta().getBoolean("powerButton", false)) { + 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(); + } + @Override public void notifyDeviceStateChanged(Device device, String name, Value state) { @@ -163,7 +175,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me plotContainer.setPlot(setupPlot(plottables)); } - private PlotFrame setupPlot(DynamicPlottableSet plottables) { + private FXPlotFrame setupPlot(DynamicPlottableSet plottables) { Meta plotConfig = new MetaBuilder("plotFrame") .setNode(new MetaBuilder("yAxis") .setValue("type", "log") @@ -176,23 +188,6 @@ public class VacCollectorController implements Initializable, DeviceListener, Me return frame; } - public void setDevice(VacCollectorDevice device) { - this.device = device; - device.getSensors().stream().map((sensor) -> { - VacuumeterView controller; - if (sensor.meta().getBoolean("powerButton", false)) { - 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(); - } - public void startMeasurement() throws ControlException { getDevice().startMeasurement().addListener(this); startStopButton.setSelected(true); diff --git a/numass-viewer/src/main/java/inr/numass/viewer/NumassLoaderViewComponent.java b/numass-viewer/src/main/java/inr/numass/viewer/NumassLoaderViewComponent.java index 2dc6e421..cc63ecfc 100644 --- a/numass-viewer/src/main/java/inr/numass/viewer/NumassLoaderViewComponent.java +++ b/numass-viewer/src/main/java/inr/numass/viewer/NumassLoaderViewComponent.java @@ -26,9 +26,9 @@ import hep.dataforge.context.Context; import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.meta.Meta; import hep.dataforge.meta.MetaBuilder; -import hep.dataforge.plots.PlotFrame; import hep.dataforge.plots.XYPlotFrame; import hep.dataforge.plots.data.*; +import hep.dataforge.plots.fx.FXPlotFrame; import hep.dataforge.plots.fx.PlotContainer; import hep.dataforge.plots.jfreechart.JFreeChartFrame; import hep.dataforge.storage.commons.JSONMetaWriter; @@ -321,7 +321,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab * update detector pane with new data */ private void updateDetectorPane(List points, int binning, boolean normalize) { - PlotFrame detectorPlotFrame; + FXPlotFrame detectorPlotFrame; if (detectorPlot.getPlot() == null) { Meta frameMeta = new MetaBuilder("frame") .setValue("title", "Detector response plot")