[no commit message]

This commit is contained in:
darksnake 2016-05-23 16:59:02 +03:00
parent 3767d13756
commit 091dfd8f8d
6 changed files with 38 additions and 47 deletions

View File

@ -30,8 +30,7 @@ import hep.dataforge.tables.MapPoint;
import hep.dataforge.tables.Table; import hep.dataforge.tables.Table;
import hep.dataforge.values.Value; import hep.dataforge.values.Value;
import java.io.OutputStream; import java.io.OutputStream;
import java.time.LocalDateTime; import java.time.Instant;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -58,7 +57,7 @@ public class MonitorCorrectAction extends OneToOneAction<Table, Table> {
double monitor = meta.getDouble("monitorPoint", Double.NaN); double monitor = meta.getDouble("monitorPoint", Double.NaN);
TreeMap<LocalDateTime, DataPoint> index = getMonitorIndex(monitor, sourceData); TreeMap<Instant, DataPoint> index = getMonitorIndex(monitor, sourceData);
if (index.isEmpty()) { if (index.isEmpty()) {
log.reportError("No monitor points found"); log.reportError("No monitor points found");
return sourceData; return sourceData;
@ -82,9 +81,9 @@ public class MonitorCorrectAction extends OneToOneAction<Table, Table> {
MapPoint.Builder pb = new MapPoint.Builder(dp); MapPoint.Builder pb = new MapPoint.Builder(dp);
pb.putValue("Monitor", 1.0); pb.putValue("Monitor", 1.0);
if (!isMonitorPoint(monitor, dp) || index.isEmpty()) { if (!isMonitorPoint(monitor, dp) || index.isEmpty()) {
LocalDateTime time = getTime(dp); Instant time = getTime(dp);
Entry<LocalDateTime, DataPoint> previousMonitor = index.floorEntry(time); Entry<Instant, DataPoint> previousMonitor = index.floorEntry(time);
Entry<LocalDateTime, DataPoint> nextMonitor = index.ceilingEntry(time); Entry<Instant, DataPoint> nextMonitor = index.ceilingEntry(time);
if (previousMonitor == null) { if (previousMonitor == null) {
previousMonitor = nextMonitor; previousMonitor = nextMonitor;
@ -95,10 +94,14 @@ public class MonitorCorrectAction extends OneToOneAction<Table, Table> {
} }
double p; double p;
// p = (getTime(dp).toEpochMilli() - previousMonitor.getKey().toEpochMilli())/ if (nextMonitor.getKey().isAfter(time) && time.isAfter(previousMonitor.getKey())) {
p = 0.5; p = 1.0 * (time.toEpochMilli() - previousMonitor.getKey().toEpochMilli())
/ (nextMonitor.getKey().toEpochMilli() - previousMonitor.getKey().toEpochMilli());
} else {
p = 0.5;
}
double corrFactor = (getCR(previousMonitor.getValue()) * p + getCR(nextMonitor.getValue()) * (1 - p)) / norm; double corrFactor = (getCR(previousMonitor.getValue()) * (1 - p) + getCR(nextMonitor.getValue()) * p) / norm;
double corrErr = previousMonitor.getValue().getValue("CRerr").doubleValue() / getCR(previousMonitor.getValue()); double corrErr = previousMonitor.getValue().getValue("CRerr").doubleValue() / getCR(previousMonitor.getValue());
double pointErr = dp.getValue("CRerr").doubleValue() / getCR(dp); double pointErr = dp.getValue("CRerr").doubleValue() / getCR(dp);
double err = Math.sqrt(corrErr * corrErr + pointErr * pointErr) * getCR(dp); double err = Math.sqrt(corrErr * corrErr + pointErr * pointErr) * getCR(dp);
@ -156,8 +159,8 @@ public class MonitorCorrectAction extends OneToOneAction<Table, Table> {
return point.getValue("Uset").doubleValue() == monitor; return point.getValue("Uset").doubleValue() == monitor;
} }
private LocalDateTime getTime(DataPoint point) { private Instant getTime(DataPoint point) {
return LocalDateTime.ofInstant(point.getValue("Timestamp").timeValue(), ZoneId.systemDefault()); return point.getValue("Timestamp").timeValue();
} }
private int getTotal(DataPoint point) { private int getTotal(DataPoint point) {
@ -168,8 +171,8 @@ public class MonitorCorrectAction extends OneToOneAction<Table, Table> {
return point.getValue("CR").doubleValue(); return point.getValue("CR").doubleValue();
} }
private TreeMap<LocalDateTime, DataPoint> getMonitorIndex(double monitor, Iterable<DataPoint> data) { private TreeMap<Instant, DataPoint> getMonitorIndex(double monitor, Iterable<DataPoint> data) {
TreeMap<LocalDateTime, DataPoint> res = new TreeMap<>(); TreeMap<Instant, DataPoint> res = new TreeMap<>();
for (DataPoint dp : data) { for (DataPoint dp : data) {
if (isMonitorPoint(monitor, dp)) { if (isMonitorPoint(monitor, dp)) {
res.put(getTime(dp), dp); res.put(getTime(dp), dp);

View File

@ -39,6 +39,7 @@ public class StagePane extends TabPane implements Named {
public synchronized void closeTab(String name) { public synchronized void closeTab(String name) {
tabs.get(name).close(); tabs.get(name).close();
Platform.runLater(() -> getTabs().remove(tabs.get(name))); Platform.runLater(() -> getTabs().remove(tabs.get(name)));
tabs.remove(name);
} }
public synchronized TextOutputTab buildTextOutput(String name) { public synchronized TextOutputTab buildTextOutput(String name) {

View File

@ -26,10 +26,9 @@ import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.storage.api.ObjectLoader; import hep.dataforge.storage.api.ObjectLoader;
import hep.dataforge.storage.api.Storage; import hep.dataforge.storage.api.Storage;
import hep.dataforge.storage.loaders.AbstractLoader; import hep.dataforge.storage.loaders.AbstractLoader;
import hep.dataforge.tables.ListTable;
import hep.dataforge.tables.Table; import hep.dataforge.tables.Table;
import hep.dataforge.values.Value;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;
@ -42,10 +41,9 @@ import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Scanner;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.vfs2.FileObject; import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException; import org.apache.commons.vfs2.FileSystemException;
@ -177,9 +175,9 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
while (buffer.hasRemaining()) { while (buffer.hasRemaining()) {
try { try {
short channel = (short) Short.toUnsignedInt(buffer.getShort()); short channel = (short) Short.toUnsignedInt(buffer.getShort());
long time = Integer.toUnsignedLong(buffer.getInt()); long length = Integer.toUnsignedLong(buffer.getInt());
byte status = buffer.get(); byte status = buffer.get();
NMEvent event = new NMEvent(channel, (double) time * timeCoef * 1e-9); NMEvent event = new NMEvent(channel, (double) length * timeCoef * 1e-9);
events.add(event); events.add(event);
} catch (Exception ex) { } catch (Exception ex) {
//LoggerFactory.getLogger(MainDataReader.class).error("Error in data format", ex); //LoggerFactory.getLogger(MainDataReader.class).error("Error in data format", ex);
@ -333,12 +331,17 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
@Override @Override
public Instant startTime() { public Instant startTime() {
if (meta().hasValue("file.timeCreated")) { //Temporary substitution for meta tag
return meta().getValue("file.timeCreated").timeValue(); Envelope hvEnvelope = getHVEnvelope();
if (hvEnvelope != null) {
try {
return Value.of(new Scanner(hvEnvelope.getData().getStream()).next()).timeValue();
} catch (IOException ex) {
return null;
}
} else { } else {
return null; return null;
} }
} }
@Override @Override

View File

@ -21,7 +21,6 @@ import hep.dataforge.context.ProcessManager;
import hep.dataforge.exceptions.StorageException; import hep.dataforge.exceptions.StorageException;
import hep.dataforge.fx.ConsoleFragment; import hep.dataforge.fx.ConsoleFragment;
import hep.dataforge.fx.ProcessManagerFragment; import hep.dataforge.fx.ProcessManagerFragment;
import inr.numass.NumassContext;
import inr.numass.NumassProperties; import inr.numass.NumassProperties;
import inr.numass.storage.NumassData; import inr.numass.storage.NumassData;
import inr.numass.storage.NumassStorage; import inr.numass.storage.NumassStorage;

View File

@ -38,26 +38,14 @@ import org.slf4j.LoggerFactory;
*/ */
public class NumassLoaderTreeBuilder { public class NumassLoaderTreeBuilder {
// private final TreeTableView<TreeItemValue> numassLoaderDataTree;
// private final NumassStorage rootStorage;
// private final Consumer<NumassData> numassViewBuilder;
//
// public NumassLoaderTreeBuilder(TreeTableView<TreeItemValue> numassLoaderDataTree, NumassStorage rootStorage, Consumer<NumassData> numassViewBuilder) {
// this.numassLoaderDataTree = numassLoaderDataTree;
// this.rootStorage = rootStorage;
// this.numassViewBuilder = numassViewBuilder;
// }
public void build(ProcessManager.Callback callback, public void build(ProcessManager.Callback callback,
TreeTableView<TreeItemValue> numassLoaderDataTree, TreeTableView<TreeItemValue> numassLoaderDataTree,
NumassStorage rootStorage, NumassStorage rootStorage,
Consumer<NumassData> numassViewBuilder) throws StorageException { Consumer<NumassData> numassViewBuilder) throws StorageException {
// callback.updateTitle("Load numass data (" + rootStorage.getName() + ")");
TreeItem<TreeItemValue> root = buildNode(rootStorage, numassViewBuilder, callback); TreeItem<TreeItemValue> root = buildNode(rootStorage, numassViewBuilder, callback);
// callback.updateMessage("finished loading numass tree");
root.setExpanded(true); root.setExpanded(true);
// numassLoaderDataTree.setShowRoot(true);
Platform.runLater(() -> { Platform.runLater(() -> {
numassLoaderDataTree.setRoot(root); numassLoaderDataTree.setRoot(root);
@ -76,6 +64,8 @@ public class NumassLoaderTreeBuilder {
numassLoaderDataTree.getColumns().setAll(numassLoaderNameColumn, numassLoaderTimeColumn, nummassLoaderDescriptionColumn); numassLoaderDataTree.getColumns().setAll(numassLoaderNameColumn, numassLoaderTimeColumn, nummassLoaderDescriptionColumn);
numassLoaderNameColumn.setSortType(TreeTableColumn.SortType.ASCENDING);
numassLoaderDataTree.getSortOrder().addAll(numassLoaderTimeColumn, numassLoaderNameColumn);
numassLoaderDataTree.addEventHandler(MouseEvent.MOUSE_CLICKED, (MouseEvent e) -> { numassLoaderDataTree.addEventHandler(MouseEvent.MOUSE_CLICKED, (MouseEvent e) -> {
if (e.getClickCount() == 2) { if (e.getClickCount() == 2) {
TreeItemValue value = numassLoaderDataTree.getFocusModel().getFocusedCell().getTreeItem().getValue(); TreeItemValue value = numassLoaderDataTree.getFocusModel().getFocusedCell().getTreeItem().getValue();
@ -92,17 +82,6 @@ public class NumassLoaderTreeBuilder {
private TreeItem<TreeItemValue> buildNode(NumassStorage storage, private TreeItem<TreeItemValue> buildNode(NumassStorage storage,
Consumer<NumassData> numassViewBuilder, ProcessManager.Callback callback) throws StorageException { Consumer<NumassData> numassViewBuilder, ProcessManager.Callback callback) throws StorageException {
// CompletableFuture<TreeItem<TreeItemValue>> future = CompletableFuture.supplyAsync(() -> {
// try {
// TreeItem<TreeItemValue> node = new TreeItem<>(buildValue(storage));
// node.getChildren().setAll(buildChildren(storage, numassViewBuilder, callback));
// return node;
// } catch (StorageException ex) {
// throw new RuntimeException(ex);
// }
// });
// callback.getProcess().addChild(storage.getName(), future);
// return future.join();
TreeItem<TreeItemValue> node = new TreeItem<>(buildValue(storage)); TreeItem<TreeItemValue> node = new TreeItem<>(buildValue(storage));
node.getChildren().setAll(buildChildren(storage, numassViewBuilder, callback)); node.getChildren().setAll(buildChildren(storage, numassViewBuilder, callback));
return node; return node;

View File

@ -16,6 +16,12 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<?import java.lang.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<?import org.controlsfx.control.*?>
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?> <?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?> <?import javafx.scene.control.Label?>
@ -32,7 +38,7 @@ limitations under the License.
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<?import org.controlsfx.control.StatusBar?> <?import org.controlsfx.control.StatusBar?>
<AnchorPane id="AnchorPane" prefHeight="768.0" prefWidth="1024.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="inr.numass.viewer.MainViewerController"> <AnchorPane id="AnchorPane" prefHeight="768.0" prefWidth="1024.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="inr.numass.viewer.MainViewerController">
<children> <children>
<BorderPane prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <BorderPane prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<top> <top>