numass fixes
This commit is contained in:
parent
2fb2a6ca4a
commit
852efe7131
@ -5,6 +5,7 @@
|
||||
*/
|
||||
package inr.numass.data;
|
||||
|
||||
import hep.dataforge.data.Data;
|
||||
import hep.dataforge.meta.Annotated;
|
||||
import hep.dataforge.meta.Meta;
|
||||
import hep.dataforge.names.Named;
|
||||
@ -13,7 +14,6 @@ import hep.dataforge.tables.Table;
|
||||
import java.time.Instant;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ -42,8 +42,8 @@ public interface NumassData extends Named, Annotated, Iterable<NumassPoint> {
|
||||
|
||||
Instant startTime();
|
||||
|
||||
default Supplier<Table> getHVData() {
|
||||
return () -> null;
|
||||
default Data<Table> getHVData() {
|
||||
return Data.buildStatic(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,6 +16,7 @@
|
||||
package inr.numass.storage;
|
||||
|
||||
import hep.dataforge.context.Global;
|
||||
import hep.dataforge.data.Data;
|
||||
import hep.dataforge.exceptions.StorageException;
|
||||
import hep.dataforge.io.ColumnedDataReader;
|
||||
import hep.dataforge.io.envelopes.Envelope;
|
||||
@ -257,19 +258,20 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
||||
}
|
||||
|
||||
@Override
|
||||
public Supplier<Table> getHVData() {
|
||||
public Data<Table> getHVData() {
|
||||
Envelope hvEnvelope = getHVEnvelope();
|
||||
if (hvEnvelope == null) {
|
||||
return () -> null;
|
||||
return Data.buildStatic(null);
|
||||
} else {
|
||||
return Data.generate(Table.class, hvEnvelope.meta(), () -> {
|
||||
try {
|
||||
return new ColumnedDataReader(hvEnvelope.getData().getStream(), "timestamp", "block", "value").toTable();
|
||||
} catch (IOException ex) {
|
||||
LoggerFactory.getLogger(getClass()).error("Failed to load HV data from file", ex);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
return () -> {
|
||||
try {
|
||||
return new ColumnedDataReader(hvEnvelope.getData().getStream(), "timestamp", "block", "value").toTable();
|
||||
} catch (IOException ex) {
|
||||
LoggerFactory.getLogger(getClass()).error("Failed to load HV data from file", ex);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private Envelope getHVEnvelope() {
|
||||
|
@ -2,6 +2,7 @@ package inr.numass.viewer
|
||||
|
||||
import hep.dataforge.context.Context
|
||||
import hep.dataforge.context.Global
|
||||
import hep.dataforge.data.Data
|
||||
import hep.dataforge.fx.work.Work
|
||||
import hep.dataforge.fx.work.WorkManager
|
||||
import hep.dataforge.io.ColumnedDataWriter
|
||||
@ -36,7 +37,6 @@ import org.controlsfx.validation.Validator
|
||||
import org.slf4j.LoggerFactory
|
||||
import tornadofx.*
|
||||
import java.io.IOException
|
||||
import java.util.function.Supplier
|
||||
import java.util.logging.Level
|
||||
import java.util.stream.Collectors
|
||||
|
||||
@ -51,6 +51,7 @@ class NumassLoaderView : View() {
|
||||
|
||||
var data: NumassData? = null
|
||||
val spectrumData = PlottableData("spectrum")
|
||||
val hvPlotData = PlottableGroup<TimePlottable>()
|
||||
|
||||
private val detectorPlotPane: AnchorPane by fxid();
|
||||
private val tabPane: TabPane by fxid();
|
||||
@ -172,20 +173,21 @@ class NumassLoaderView : View() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupHVPane(hvData: Supplier<Table>) {
|
||||
getWorkManager().startWork("viewer.numass.hv") { callback: Work ->
|
||||
val t = hvData.get()
|
||||
Platform.runLater {
|
||||
val set = PlottableGroup<TimePlottable>()
|
||||
for (dp in t) {
|
||||
val block = dp.getString("block", "default")
|
||||
if (!set.has(block)) {
|
||||
set.add(TimePlottable(block))
|
||||
}
|
||||
set.get(block).put(dp.getValue("timestamp").timeValue(), dp.getValue("value"))
|
||||
}
|
||||
hvPlot.plot.addAll(set)
|
||||
private fun setupHVPane(hvData: Data<Table>) {
|
||||
runAsync {
|
||||
hvData.get()
|
||||
} ui {
|
||||
for (pl in hvPlotData){
|
||||
pl.clear()
|
||||
}
|
||||
for (dp in it) {
|
||||
val block = dp.getString("block", "default")
|
||||
if (!hvPlotData.has(block)) {
|
||||
hvPlotData.add(TimePlottable(block))
|
||||
}
|
||||
hvPlotData.get(block).put(dp.getValue("timestamp").timeValue(), dp.getValue("value"))
|
||||
}
|
||||
hvPlot.plot.addAll(hvPlotData)
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,7 +296,7 @@ class NumassLoaderView : View() {
|
||||
callback.increaseProgress(1.0)
|
||||
datum;
|
||||
}
|
||||
} ui{
|
||||
} ui {
|
||||
detectorPlotFrame.setAll(it)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user