Removed composite properties
This commit is contained in:
parent
e727235f12
commit
50947c9219
@ -38,13 +38,6 @@ public class PKT8App extends Application {
|
|||||||
|
|
||||||
PKT8MainViewController controller;
|
PKT8MainViewController controller;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param args the command line arguments
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
launch(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) throws IOException, ControlException, ParseException {
|
public void start(Stage primaryStage) throws IOException, ControlException, ParseException {
|
||||||
Locale.setDefault(Locale.US);// чтобы отделение десятичных знаков было точкой
|
Locale.setDefault(Locale.US);// чтобы отделение десятичных знаков было точкой
|
||||||
@ -72,10 +65,12 @@ public class PKT8App extends Application {
|
|||||||
|
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
|
|
||||||
if(getParameters().getNamed().containsKey("cfgFile")){
|
if (getParameters().getNamed().containsKey("cfgFile")) {
|
||||||
controller.setConfig(MetaFileReader.read(new File(getParameters().getNamed().get("cfgFile"))));
|
controller.setConfig(MetaFileReader.read(new File(getParameters().getNamed().get("cfgFile"))));
|
||||||
} else if (Boolean.parseBoolean(getParameters().getNamed().getOrDefault("debug","false"))){
|
} else if (Boolean.parseBoolean(getParameters().getNamed().getOrDefault("debug", "false"))) {
|
||||||
controller.loadTestConfig();
|
controller.loadTestConfig();
|
||||||
|
} else {
|
||||||
|
controller.startConfigDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,4 +84,11 @@ public class PKT8App extends Application {
|
|||||||
// System.exit(0);
|
// System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param args the command line arguments
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
launch(args);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,10 @@
|
|||||||
package inr.numass.cryotemp;
|
package inr.numass.cryotemp;
|
||||||
|
|
||||||
import hep.dataforge.control.collectors.RegularPointCollector;
|
import hep.dataforge.control.collectors.RegularPointCollector;
|
||||||
|
import hep.dataforge.control.connections.LoaderConnection;
|
||||||
|
import hep.dataforge.control.connections.PointListenerConnection;
|
||||||
|
import hep.dataforge.control.connections.Roles;
|
||||||
|
import hep.dataforge.control.connections.StorageConnection;
|
||||||
import hep.dataforge.control.devices.PortSensor;
|
import hep.dataforge.control.devices.PortSensor;
|
||||||
import hep.dataforge.control.measurements.AbstractMeasurement;
|
import hep.dataforge.control.measurements.AbstractMeasurement;
|
||||||
import hep.dataforge.control.measurements.Measurement;
|
import hep.dataforge.control.measurements.Measurement;
|
||||||
@ -26,9 +30,10 @@ import hep.dataforge.exceptions.PortException;
|
|||||||
import hep.dataforge.exceptions.StorageException;
|
import hep.dataforge.exceptions.StorageException;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.storage.api.PointLoader;
|
import hep.dataforge.storage.api.PointLoader;
|
||||||
import hep.dataforge.storage.api.Storage;
|
|
||||||
import hep.dataforge.storage.commons.LoaderFactory;
|
import hep.dataforge.storage.commons.LoaderFactory;
|
||||||
import hep.dataforge.storage.commons.StorageFactory;
|
import hep.dataforge.storage.commons.StorageFactory;
|
||||||
|
import hep.dataforge.tables.DataPoint;
|
||||||
|
import hep.dataforge.tables.PointListener;
|
||||||
import hep.dataforge.tables.TableFormatBuilder;
|
import hep.dataforge.tables.TableFormatBuilder;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
@ -90,6 +95,8 @@ public class PKT8Device extends PortSensor<PKT8Result> {
|
|||||||
setSPS(meta().getInt("sps", 0));
|
setSPS(meta().getInt("sps", 0));
|
||||||
setBUF(meta().getInt("abuf", 100));
|
setBUF(meta().getInt("abuf", 100));
|
||||||
|
|
||||||
|
setupStorage();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -234,39 +241,51 @@ public class PKT8Device extends PortSensor<PKT8Result> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupStorage() {
|
private void setupStorage() {
|
||||||
if (meta().hasNode("storage")) {
|
|
||||||
try {
|
|
||||||
Storage storage = StorageFactory.buildStorage(getContext(), meta().getNode("storage", Meta.empty()));
|
|
||||||
String suffix = Integer.toString((int) Instant.now().toEpochMilli());
|
|
||||||
|
|
||||||
// Building data format
|
// Building data format
|
||||||
TableFormatBuilder TableFormatBuilder = new TableFormatBuilder()
|
TableFormatBuilder tableFormatBuilder = new TableFormatBuilder()
|
||||||
.addTime("timestamp");
|
.addTime("timestamp");
|
||||||
List<String> names = new ArrayList<>();
|
List<String> names = new ArrayList<>();
|
||||||
|
|
||||||
for (PKT8Channel channel : channels.values()) {
|
for (PKT8Channel channel : channels.values()) {
|
||||||
TableFormatBuilder.addNumber(channel.getName());
|
tableFormatBuilder.addNumber(channel.getName());
|
||||||
names.add(channel.getName());
|
names.add(channel.getName());
|
||||||
}
|
|
||||||
|
|
||||||
PointLoader pointLoader = LoaderFactory.buildPointLoder(storage, "cryotemp_" + suffix, "", "timestamp", TableFormatBuilder.build());
|
|
||||||
|
|
||||||
Duration duration = Duration.parse(meta().getString("averagingDuration", "PT30S"));
|
|
||||||
|
|
||||||
collector = new RegularPointCollector((dp) -> {
|
|
||||||
if (pointLoader != null) {
|
|
||||||
try {
|
|
||||||
getLogger().debug("Point measurement complete. Pushing...");
|
|
||||||
pointLoader.push(dp);
|
|
||||||
} catch (StorageException ex) {
|
|
||||||
getLogger().error("Error while pushing point to loader", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, duration, names);
|
|
||||||
} catch (StorageException ex) {
|
|
||||||
getLogger().error("Can't setup storage", ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setting up storage connections
|
||||||
|
if (meta().hasNode("storage")) {
|
||||||
|
meta().getNodes("storage").forEach(node -> {
|
||||||
|
connect(new StorageConnection(StorageFactory.buildStorage(getContext(), node)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// setting up loader for each of storages
|
||||||
|
forEachTypedConnection(Roles.STORAGE_ROLE, StorageConnection.class, connection -> {
|
||||||
|
String suffix = Integer.toString((int) Instant.now().toEpochMilli());
|
||||||
|
|
||||||
|
PointLoader pointLoader = null;
|
||||||
|
try {
|
||||||
|
pointLoader = LoaderFactory.buildPointLoder(connection.getStorage(),
|
||||||
|
"cryotemp_" + suffix, "", "timestamp", tableFormatBuilder.build());
|
||||||
|
this.connect(new LoaderConnection(pointLoader), Roles.POINT_LISTENER_ROLE);
|
||||||
|
} catch (StorageException e) {
|
||||||
|
getLogger().error("Failed to build loader from storage {}", connection.getStorage().getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// setting up the collector
|
||||||
|
Duration duration = Duration.parse(meta().getString("averagingDuration", "PT30S"));
|
||||||
|
collector = new RegularPointCollector((DataPoint dp) -> {
|
||||||
|
forEachTypedConnection(Roles.POINT_LISTENER_ROLE, PointListener.class, listener -> {
|
||||||
|
getLogger().debug("Point measurement complete. Pushing...");
|
||||||
|
listener.accept(dp);
|
||||||
|
});
|
||||||
|
}, duration, names);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void connectPointListener(PointListenerConnection listener){
|
||||||
|
this.connect(listener, Roles.POINT_LISTENER_ROLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -296,9 +315,6 @@ public class PKT8Device extends PortSensor<PKT8Result> {
|
|||||||
getLogger().error("Failed to clear PKT8 port");
|
getLogger().error("Failed to clear PKT8 port");
|
||||||
// throw new MeasurementException(e);
|
// throw new MeasurementException(e);
|
||||||
}
|
}
|
||||||
if (collector == null) {
|
|
||||||
setupStorage();
|
|
||||||
}
|
|
||||||
return super.startMeasurement();
|
return super.startMeasurement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,6 @@ import javafx.beans.Observable;
|
|||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.control.Button;
|
|
||||||
import javafx.scene.control.ToggleButton;
|
import javafx.scene.control.ToggleButton;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.stage.FileChooser;
|
import javafx.stage.FileChooser;
|
||||||
@ -64,8 +63,7 @@ public class PKT8MainViewController implements Initializable, DeviceListener, Me
|
|||||||
private PKT8Device device;
|
private PKT8Device device;
|
||||||
private FXPlotFrame<XYPlottable> plotFrame;
|
private FXPlotFrame<XYPlottable> plotFrame;
|
||||||
private TimePlottableGroup plottables;
|
private TimePlottableGroup plottables;
|
||||||
@FXML
|
|
||||||
private Button loadConfigButton;
|
|
||||||
@FXML
|
@FXML
|
||||||
private ToggleButton startStopButton;
|
private ToggleButton startStopButton;
|
||||||
@FXML
|
@FXML
|
||||||
@ -87,7 +85,7 @@ public class PKT8MainViewController implements Initializable, DeviceListener, Me
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL url, ResourceBundle rb) {
|
public void initialize(URL url, ResourceBundle rb) {
|
||||||
setupPlotFrame(null);
|
// setupPlotFrame(Meta.empty());
|
||||||
this.consoleFragment = new ConsoleFragment();
|
this.consoleFragment = new ConsoleFragment();
|
||||||
consoleFragment.bindTo(consoleButton);
|
consoleFragment.bindTo(consoleButton);
|
||||||
rawDataButton.selectedProperty().addListener(new InvalidationListener() {
|
rawDataButton.selectedProperty().addListener(new InvalidationListener() {
|
||||||
@ -103,8 +101,7 @@ public class PKT8MainViewController implements Initializable, DeviceListener, Me
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
public void startConfigDialog() throws IOException, ParseException, ControlException {
|
||||||
private void onLoadConfigClick(ActionEvent event) throws IOException, ParseException, ControlException {
|
|
||||||
FileChooser fileChooser = new FileChooser();
|
FileChooser fileChooser = new FileChooser();
|
||||||
fileChooser.setTitle("Open configuration file");
|
fileChooser.setTitle("Open configuration file");
|
||||||
fileChooser.setInitialFileName(DEFAULT_CONFIG_LOCATION);
|
fileChooser.setInitialFileName(DEFAULT_CONFIG_LOCATION);
|
||||||
@ -112,7 +109,7 @@ public class PKT8MainViewController implements Initializable, DeviceListener, Me
|
|||||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("xml", "*.xml", "*.XML"));
|
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("xml", "*.xml", "*.XML"));
|
||||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("json", "*.json", "*.JSON"));
|
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("json", "*.json", "*.JSON"));
|
||||||
// fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("all", "*.*"));
|
// fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("all", "*.*"));
|
||||||
File cfgFile = fileChooser.showOpenDialog(loadConfigButton.getScene().getWindow());
|
File cfgFile = fileChooser.showOpenDialog(startStopButton.getScene().getWindow());
|
||||||
|
|
||||||
if (cfgFile != null) {
|
if (cfgFile != null) {
|
||||||
setConfig(MetaFileReader.read(cfgFile));
|
setConfig(MetaFileReader.read(cfgFile));
|
||||||
@ -140,7 +137,7 @@ public class PKT8MainViewController implements Initializable, DeviceListener, Me
|
|||||||
plotConfig = config.getNode("plotConfig");
|
plotConfig = config.getNode("plotConfig");
|
||||||
}
|
}
|
||||||
|
|
||||||
setupPlotFrame(plotConfig.getNode("plotFrame", null));
|
setupPlotFrame(plotConfig.getNode("plotFrame", Meta.empty()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.hasNode("device")) {
|
if (config.hasNode("device")) {
|
||||||
@ -157,8 +154,8 @@ public class PKT8MainViewController implements Initializable, DeviceListener, Me
|
|||||||
*/
|
*/
|
||||||
private synchronized void setupPlotFrame(Meta plotFrameMeta) {
|
private synchronized void setupPlotFrame(Meta plotFrameMeta) {
|
||||||
plottables = new TimePlottableGroup();
|
plottables = new TimePlottableGroup();
|
||||||
plottables.setMaxItems(plotFrameMeta.getInt("maxItems",3000));
|
plottables.setMaxItems(plotFrameMeta.getInt("maxItems", 3000));
|
||||||
plottables.setMaxAge(Duration.parse(plotFrameMeta.getString("maxAge","PT2H")));
|
plottables.setMaxAge(Duration.parse(plotFrameMeta.getString("maxAge", "PT2H")));
|
||||||
plotArea.getChildren().clear();
|
plotArea.getChildren().clear();
|
||||||
plotFrame = new JFreeChartFrame(plotFrameMeta);
|
plotFrame = new JFreeChartFrame(plotFrameMeta);
|
||||||
PlotUtils.setXAxis(plotFrame, "timestamp", null, "time");
|
PlotUtils.setXAxis(plotFrame, "timestamp", null, "time");
|
||||||
@ -209,9 +206,6 @@ public class PKT8MainViewController implements Initializable, DeviceListener, Me
|
|||||||
startStopButton.setDisable(false);
|
startStopButton.setDisable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void applyViewConfig(Meta viewConfig) {
|
|
||||||
// plottables.applyConfig(viewConfig);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyDeviceShutdown(Device device) {
|
public void notifyDeviceShutdown(Device device) {
|
||||||
@ -219,15 +213,9 @@ public class PKT8MainViewController implements Initializable, DeviceListener, Me
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void sendMessage(Device device, int priority, Meta message) {
|
|
||||||
// String tag = message.getString("tag", "");
|
|
||||||
// logArea.appendText(String.format("%s > (%s) [%s] %s%n", device.getName(), Instant.now().toString(), tag, message));
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void onMeasurementResult(Measurement<PKT8Result> measurement, PKT8Result result, Instant time) {
|
public synchronized void onMeasurementResult(Measurement<PKT8Result> measurement, PKT8Result result, Instant time) {
|
||||||
|
//PENDING replace by connection?
|
||||||
if (rawDataButton.isSelected()) {
|
if (rawDataButton.isSelected()) {
|
||||||
plottables.put(result.channel, result.rawValue);
|
plottables.put(result.channel, result.rawValue);
|
||||||
} else {
|
} else {
|
||||||
|
@ -17,22 +17,23 @@ limitations under the License.
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.scene.layout.BorderPane?>
|
<BorderPane prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.60"
|
||||||
<BorderPane xmlns:fx="http://javafx.com/fxml/1" prefHeight="600.0" prefWidth="800.0"
|
xmlns:fx="http://javafx.com/fxml/1" fx:controller="inr.numass.cryotemp.PKT8MainViewController">
|
||||||
xmlns="http://javafx.com/javafx/8.0.60" fx:controller="inr.numass.cryotemp.PKT8MainViewController">
|
<center>
|
||||||
<center>
|
<AnchorPane fx:id="plotArea"/>
|
||||||
<AnchorPane fx:id="plotArea" />
|
</center>
|
||||||
</center>
|
<top>
|
||||||
<top>
|
|
||||||
<ToolBar BorderPane.alignment="CENTER">
|
<ToolBar BorderPane.alignment="CENTER">
|
||||||
<items>
|
<items>
|
||||||
<ToggleButton fx:id="startStopButton" disable="true" mnemonicParsing="false" onAction="#onStartStopClick" prefWidth="50.0" text="Start" />
|
<ToggleButton fx:id="startStopButton" disable="true" mnemonicParsing="false"
|
||||||
|
onAction="#onStartStopClick" prefWidth="50.0" text="Start"/>
|
||||||
<ToggleButton fx:id="rawDataButton" mnemonicParsing="false" text="Raw data"/>
|
<ToggleButton fx:id="rawDataButton" mnemonicParsing="false" text="Raw data"/>
|
||||||
<Separator orientation="VERTICAL" />
|
<Separator orientation="VERTICAL"/>
|
||||||
<Button fx:id="loadConfigButton" mnemonicParsing="false" onAction="#onLoadConfigClick" text="Load config" />
|
<Pane HBox.hgrow = "ALWAYS"/>
|
||||||
<ToggleButton fx:id="consoleButton" contentDisplay="CENTER" mnemonicParsing="false" text="Console" />
|
<Separator orientation="VERTICAL"/>
|
||||||
|
<ToggleButton fx:id="consoleButton" contentDisplay="CENTER" mnemonicParsing="false" text="Console"/>
|
||||||
</items>
|
</items>
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
</top>
|
</top>
|
||||||
</BorderPane>
|
</BorderPane>
|
||||||
|
@ -8,7 +8,7 @@ package inr.numass.utils;
|
|||||||
import groovy.lang.Binding;
|
import groovy.lang.Binding;
|
||||||
import groovy.lang.GroovyShell;
|
import groovy.lang.GroovyShell;
|
||||||
import groovy.lang.Script;
|
import groovy.lang.Script;
|
||||||
import hep.dataforge.utils.CommonUtils;
|
import hep.dataforge.utils.Utils;
|
||||||
import org.codehaus.groovy.control.CompilerConfiguration;
|
import org.codehaus.groovy.control.CompilerConfiguration;
|
||||||
import org.codehaus.groovy.control.customizers.ImportCustomizer;
|
import org.codehaus.groovy.control.customizers.ImportCustomizer;
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ import java.util.Map;
|
|||||||
* @author Alexander Nozik
|
* @author Alexander Nozik
|
||||||
*/
|
*/
|
||||||
public class ExpressionUtils {
|
public class ExpressionUtils {
|
||||||
private static Map<String, Script> cache = CommonUtils.getLRUCache(100);
|
private static Map<String, Script> cache = Utils.getLRUCache(100);
|
||||||
private static GroovyShell shell;
|
private static GroovyShell shell;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
Loading…
Reference in New Issue
Block a user