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