This commit is contained in:
Alexander Nozik 2017-10-19 21:37:57 +03:00
parent 97f27cdad1
commit bb9a3c6fa8
19 changed files with 308 additions and 182 deletions

View File

@ -22,7 +22,7 @@ public abstract class AbstractAnalyzer implements NumassAnalyzer {
public static String TIME_KEY = "timestamp"; public static String TIME_KEY = "timestamp";
public static String[] NAME_LIST = {LENGTH_KEY, COUNT_KEY, COUNT_RATE_KEY, COUNT_RATE_ERROR_KEY, WINDOW_KEY, TIME_KEY}; public static String[] NAME_LIST = {LENGTH_KEY, COUNT_KEY, COUNT_RATE_KEY, COUNT_RATE_ERROR_KEY, WINDOW_KEY, TIME_KEY};
public static String[] NAME_LIST_WITH_HV = {HV_KEY, LENGTH_KEY, COUNT_KEY, COUNT_RATE_KEY, COUNT_RATE_ERROR_KEY, WINDOW_KEY, TIME_KEY}; // public static String[] NAME_LIST_WITH_HV = {HV_KEY, LENGTH_KEY, COUNT_KEY, COUNT_RATE_KEY, COUNT_RATE_ERROR_KEY, WINDOW_KEY, TIME_KEY};
@Nullable @Nullable
private final SignalProcessor processor; private final SignalProcessor processor;

View File

@ -60,7 +60,7 @@ public class NumassPlugin extends BasicPlugin {
public static JFreeChartFrame displayJFreeChart(String title, double width, double height, Meta meta) { public static JFreeChartFrame displayJFreeChart(String title, double width, double height, Meta meta) {
JFreeChartFrame frame = new JFreeChartFrame(meta); JFreeChartFrame frame = new JFreeChartFrame(meta);
frame.configureValue("title", title); frame.configureValue("title", title);
PlotContainer.Companion.display(frame,title,width,height); PlotContainer.Companion.display(frame, title, width, height);
return frame; return frame;
} }
@ -96,6 +96,8 @@ public class NumassPlugin extends BasicPlugin {
actions.putTask(NumassFitScanSummaryTask.class); actions.putTask(NumassFitScanSummaryTask.class);
actions.putTask(NumassFitTask.class); actions.putTask(NumassFitTask.class);
actions.putTask(NumassFitSummaryTask.class); actions.putTask(NumassFitSummaryTask.class);
actions.put(NumassTasksKt.getSelectDataTask());
actions.put(NumassTasksKt.getMonitorTableTask());
} }
@Override @Override

View File

@ -27,7 +27,7 @@ public class AnalyzeDataAction extends OneToOneAction<NumassSet, Table> {
//TODO add processor here //TODO add processor here
NumassAnalyzer analyzer = new SmartAnalyzer(); NumassAnalyzer analyzer = new SmartAnalyzer();
Table res = analyzer.analyzeSet(input, inputMeta); Table res = analyzer.analyzeSet(input, inputMeta);
output(context, name, stream -> NumassUtils.writeSomething(stream, inputMeta, res)); output(context, name, stream -> NumassUtils.write(stream, inputMeta, res));
return res; return res;
} }
} }

View File

@ -62,7 +62,7 @@ public class MergeDataAction extends ManyToOneAction<Table, Table> {
@Override @Override
protected void afterGroup(Context context, String groupName, Meta outputMeta, Table output) { protected void afterGroup(Context context, String groupName, Meta outputMeta, Table output) {
output(context, groupName, stream -> NumassUtils.writeSomething(stream, outputMeta, output)); output(context, groupName, stream -> NumassUtils.write(stream, outputMeta, output));
} }
private Values mergeDataPoints(Values dp1, Values dp2) { private Values mergeDataPoints(Values dp1, Values dp2) {

View File

@ -136,7 +136,7 @@ public class MonitorCorrectAction extends OneToOneAction<Table, Table> {
// } // }
Table res = new ListTable(dataList); Table res = new ListTable(dataList);
output(context, name, stream -> NumassUtils.writeSomething(stream, meta, res)); output(context, name, stream -> NumassUtils.write(stream, meta, res));
return res; return res;
} }
@ -201,7 +201,7 @@ public class MonitorCorrectAction extends OneToOneAction<Table, Table> {
String monitorFileName = meta.getString("monitorFile", "monitor"); String monitorFileName = meta.getString("monitorFile", "monitor");
ListTable data = new ListTable(monitorPoints); ListTable data = new ListTable(monitorPoints);
output(context, monitorFileName, stream -> NumassUtils.writeSomething(stream, meta, data)); output(context, monitorFileName, stream -> NumassUtils.write(stream, meta, data));
// ColumnedDataWriter.writeTable(stream, TableTransform.sort(data, "Timestamp", true), "Monitor points", monitorNames); // ColumnedDataWriter.writeTable(stream, TableTransform.sort(data, "Timestamp", true), "Monitor points", monitorNames);
} }
} }

View File

@ -47,7 +47,7 @@ public class SubstractSpectrumAction extends OneToOneAction<Table, Table> {
}); });
Table res = builder.build(); Table res = builder.build();
output(context,name, stream -> NumassUtils.writeSomething(stream,inputMeta,res)); output(context,name, stream -> NumassUtils.write(stream,inputMeta,res));
return res; return res;
} catch (IOException ex) { } catch (IOException ex) {
throw new RuntimeException("Could not read reference file", ex); throw new RuntimeException("Could not read reference file", ex);

View File

@ -115,7 +115,7 @@ public class SummaryAction extends ManyToOneAction<FitState, Table> {
@Override @Override
protected void afterGroup(Context context, String groupName, Meta outputMeta, Table output) { protected void afterGroup(Context context, String groupName, Meta outputMeta, Table output) {
output(context, groupName, stream -> NumassUtils.writeSomething(stream, outputMeta, output)); output(context, groupName, stream -> NumassUtils.write(stream, outputMeta, output));
super.afterGroup(context, groupName, outputMeta, output); super.afterGroup(context, groupName, outputMeta, output);
} }

View File

@ -102,7 +102,7 @@ public class TransformDataAction extends OneToOneAction<Table, Table> {
Table res = table.addColumn(ListColumn.build(table.getColumn(COUNT_RATE_KEY).getFormat(), cr.stream())) Table res = table.addColumn(ListColumn.build(table.getColumn(COUNT_RATE_KEY).getFormat(), cr.stream()))
.addColumn(ListColumn.build(table.getColumn(COUNT_RATE_ERROR_KEY).getFormat(), crErr.stream())); .addColumn(ListColumn.build(table.getColumn(COUNT_RATE_ERROR_KEY).getFormat(), crErr.stream()));
output(context, name, stream -> NumassUtils.writeSomething(stream, meta, res)); output(context, name, stream -> NumassUtils.write(stream, meta, res));
return res; return res;
} }

View File

@ -79,7 +79,7 @@ public class NumassFitScanSummaryTask extends AbstractTask<Table> {
pars.getValue("trap")); pars.getValue("trap"));
}); });
Table res = TableTransform.sort(builder.build(), "m", true); Table res = TableTransform.sort(builder.build(), "m", true);
output(context, nodeName, stream -> NumassUtils.writeSomething(stream,meta,res)); output(context, nodeName, stream -> NumassUtils.write(stream,meta,res));
return res; return res;
} }

View File

@ -8,8 +8,6 @@ package inr.numass.tasks;
import hep.dataforge.actions.GenericAction; import hep.dataforge.actions.GenericAction;
import hep.dataforge.cache.CachePlugin; import hep.dataforge.cache.CachePlugin;
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.data.CustomDataFilter;
import hep.dataforge.data.DataFilter;
import hep.dataforge.data.DataNode; import hep.dataforge.data.DataNode;
import hep.dataforge.data.DataTree; import hep.dataforge.data.DataTree;
import hep.dataforge.description.NodeDef; import hep.dataforge.description.NodeDef;
@ -33,7 +31,6 @@ import inr.numass.data.api.NumassSet;
@NodeDef(name = "prepare") @NodeDef(name = "prepare")
@NodeDef(name = "monitor") @NodeDef(name = "monitor")
@NodeDef(name = "merge") @NodeDef(name = "merge")
@NodeDef(name = "data")
public class NumassPrepareTask extends AbstractTask<Table> { public class NumassPrepareTask extends AbstractTask<Table> {
@Override @Override
@ -42,15 +39,7 @@ public class NumassPrepareTask extends AbstractTask<Table> {
Context context = model.getContext(); Context context = model.getContext();
//acquiring initial data. Data node could not be empty //acquiring initial data. Data node could not be empty
DataNode<NumassSet> data = input.getCheckedNode("data", NumassSet.class);
DataFilter filter = new CustomDataFilter(config.getMeta("data"));
DataNode<NumassSet> data = filter.filter(input.checked(NumassSet.class));
// Meta dataMeta = config.getMeta("data");
// URI storageUri = input.getCheckedData("dataRoot", URI.class).get();
// DataSet.Builder<NumassData> dataBuilder = readData(getWork(model, input.getName()), context, storageUri, dataMeta);
// DataNode<NumassData> data = dataBuilder.builder();
//preparing table data //preparing table data
Meta prepareMeta = config.getMeta("prepare"); Meta prepareMeta = config.getMeta("prepare");
@ -89,110 +78,22 @@ public class NumassPrepareTask extends AbstractTask<Table> {
protected void buildModel(TaskModel.Builder model, Meta meta) { protected void buildModel(TaskModel.Builder model, Meta meta) {
model.configure( model.configure(
new MetaBuilder() new MetaBuilder()
.putNode(meta.getMetaOrEmpty("data"))
.putNode(meta.getMetaOrEmpty("prepare")) .putNode(meta.getMetaOrEmpty("prepare"))
.putNode(meta.getMetaOrEmpty("monitor")) .putNode(meta.getMetaOrEmpty("monitor"))
.putNode(meta.getMetaOrEmpty("merge")) .putNode(meta.getMetaOrEmpty("merge"))
); );
if (meta.hasValue("data.from")) { model.dependsOn("data", meta.getMetaOrEmpty("data"), "data");
model.data(meta.getString("data.from.*"));
} else {
model.data("*");
}
} }
// private DataSet.Builder<NumassData> readData(Work callback, Context context, URI numassRoot, Meta meta) {
//
// NumassStorage storage = NumassStorage.buildNumassRoot(numassRoot, true, false);
// CustomDataFilter filter = new CustomDataFilter().configure(meta);
//
// boolean forwardOnly = meta.getBoolean("forwardOnly", false);
// boolean reverseOnly = meta.getBoolean("reverseOnly", false);
//// SetDirectionUtility.load(context);
//
// DataSet.Builder<NumassData> builder = DataSet.builder(NumassData.class);
// callback.setMaxProgress(StorageUtils.loaderStream(storage).count());
// StorageUtils.loaderStream(storage).forEach(pair -> {
// Loader loader = pair.getValue();
// if (loader instanceof NumassDataLoader) {
// NumassDataLoader nd = (NumassDataLoader) loader;
// Data<NumassData> datum = buildData(context, nd, meta);
// if (filter.acceptData(pair.getKey(), datum)) {
// boolean accept = true;
// if (forwardOnly || reverseOnly) {
// boolean reversed = nd.isReversed();
// accept = (reverseOnly && reversed) || (forwardOnly && !reversed);
// }
// if (accept) {
// builder.putData(pair.getKey(), datum);
// }
// }
// }
// callback.increaseProgress(1d);
// });
//
// if (meta.getBoolean("loadLegacy", false)) {
// storage.legacyFiles().forEach(nd -> {
// Data<NumassData> datum = Data.buildStatic(nd);
// if (filter.acceptData(nd.getName(), datum)) {
// builder.putData("legacy." + nd.getName(), datum);
// }
// });
// }
// //FIXME remove in later revisions
//// SetDirectionUtility.save(context);
//
// return builder;
// }
// private Data<NumassData> buildData(Context context, NumassDataLoader loader, Meta meta) {
// if (meta.hasNode("debunch")) {
// return Data.buildStatic(loader.applyRawTransformation(rp -> debunch(context, rp, meta.getMeta("debunch"))));
// } else {
// return Data.buildStatic(loader);
// }
// }
//
// private NMPoint debunch(Context context, RawNMPoint point, Meta meta) {
// int upper = meta.getInt("upperchanel", RawNMPoint.MAX_CHANEL);
// int lower = meta.getInt("lowerchanel", 0);
// double rejectionprob = meta.getDouble("rejectprob", 1e-10);
// double framelength = meta.getDouble("framelength", 1);
// double maxCR = meta.getDouble("maxcr", 500d);
//
// double cr = point.selectChanels(lower, upper).getCr();
// if (cr < maxCR) {
// DebunchReport report = new FrameAnalizer(rejectionprob, framelength, lower, upper).debunchPoint(point);
// return new NMPoint(report.getPoint());
// } else {
// return new NMPoint(point);
// }
// }
private <T, R> DataNode<R> runAction(GenericAction<T, R> action, Context context, DataNode<T> data, Meta meta) { private <T, R> DataNode<R> runAction(GenericAction<T, R> action, Context context, DataNode<T> data, Meta meta) {
return action.run(context, data, meta); return action.run(context, data, meta);
} }
// @Override
// public void validate(TaskModel model) {
// if (!model.meta().hasMeta("data")) {
//
// }
// }
@Override @Override
public String getName() { public String getName() {
return "prepare"; return "prepare";
} }
// @Override
// public NodeDescriptor getDescriptor() {
// return new DescriptorBuilder(getName())
// .addNode("prepare", PrepareDataAction.class)
// .addNode("monitor", MonitorCorrectAction.class)
// .addNode("merge", MergeDataAction.class)
// .builder();
// }
} }

View File

@ -117,7 +117,7 @@ public class NumassUtils {
} }
} }
public static void writeSomething(OutputStream stream, Meta meta, Markedup something) { public static void write(OutputStream stream, Meta meta, Markedup something) {
writeEnvelope(stream, meta, out -> new SimpleMarkupRenderer(out).render(something.markup(meta))); writeEnvelope(stream, meta, out -> new SimpleMarkupRenderer(out).render(something.markup(meta)));
} }

View File

@ -0,0 +1,38 @@
package inr.numass.tasks
import hep.dataforge.data.CustomDataFilter
import hep.dataforge.kodex.task
import hep.dataforge.tables.ListTable
import hep.dataforge.tables.Table
import inr.numass.data.analyzers.SmartAnalyzer
import inr.numass.data.api.NumassSet
import inr.numass.utils.NumassUtils
val selectDataTask = task("data") {
transform { data ->
CustomDataFilter(meta).filter<NumassSet>(data.checked(NumassSet::class.java))
}
}
val monitorTableTask = task("monitor") {
join<NumassSet, Table> {
result { data ->
val monitorVoltage = meta.getDouble("monitorVoltage", 16000.0);
val analyzer = SmartAnalyzer()
val analyzerMeta = meta.getMetaOrEmpty("analyzer")
val builder = ListTable.Builder("timestamp", "count", "cr", "crErr")
.rows(
data.values.stream().parallel()
.flatMap { it.points }
.filter { it.voltage == monitorVoltage }
.map { it -> analyzer.analyzePoint(it, analyzerMeta) }
)
context.io().out("numass.monitor",name).use {
NumassUtils.write(it, meta, builder.build())
}
return@result builder.build();
}
}
}

View File

@ -13,15 +13,17 @@ import inr.numass.data.NumassDataUtils
import inr.numass.data.analyzers.SimpleAnalyzer import inr.numass.data.analyzers.SimpleAnalyzer
import inr.numass.data.api.NumassAnalyzer import inr.numass.data.api.NumassAnalyzer
import inr.numass.data.api.NumassPoint import inr.numass.data.api.NumassPoint
import javafx.beans.Observable
import javafx.beans.property.SimpleBooleanProperty import javafx.beans.property.SimpleBooleanProperty
import javafx.beans.property.SimpleObjectProperty import javafx.beans.property.SimpleObjectProperty
import javafx.collections.FXCollections import javafx.collections.FXCollections
import javafx.collections.ObservableMap
import javafx.concurrent.Task
import javafx.scene.control.CheckBox import javafx.scene.control.CheckBox
import javafx.scene.control.ChoiceBox import javafx.scene.control.ChoiceBox
import javafx.scene.image.ImageView import javafx.scene.image.ImageView
import tornadofx.* import tornadofx.*
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.AtomicInteger
class AmplitudeView( class AmplitudeView(
private val analyzer: NumassAnalyzer = SimpleAnalyzer(), private val analyzer: NumassAnalyzer = SimpleAnalyzer(),
@ -63,61 +65,109 @@ class AmplitudeView(
} }
private val data: MutableMap<String, NumassPoint> = HashMap(); private val data: MutableMap<String, NumassPoint> = HashMap();
private val taskMap: ObservableMap<String, Task<DataPlot>> = FXCollections.observableHashMap();
init {
binningProperty.onChange {
putAll(data)
}
normalizeProperty.onChange {
putAll(data)
}
taskMap.addListener { _: Observable ->
runLater {
val running = taskMap.values.count { it.isRunning }
if (running == 0) {
container.progress = 1.0
} else {
container.progress = running.toDouble() / taskMap.size
}
}
}
}
override val root = borderpane { override val root = borderpane {
center = container.root center = container.root
} }
/**
* Calculate or get spectrum from the cache
*/
private fun getSpectrum(point: NumassPoint): Table { private fun getSpectrum(point: NumassPoint): Table {
return cache.computeIfAbsent(point) { analyzer.getSpectrum(point, Meta.empty()) } return cache.computeIfAbsent(point) { analyzer.getSpectrum(point, Meta.empty()) }
} }
private fun updateView() { fun cleanTasks() {
runLater {
taskMap.entries.filter { !it.value.isRunning }.forEach { taskMap.remove(it.key) }
}
}
/**
* Put or replace current plot with name `key`
*/
fun putOne(key: String, point: NumassPoint): Task<DataPlot> {
val valueAxis = if (normalize) { val valueAxis = if (normalize) {
NumassAnalyzer.COUNT_RATE_KEY NumassAnalyzer.COUNT_RATE_KEY
} else { } else {
NumassAnalyzer.COUNT_KEY NumassAnalyzer.COUNT_KEY
} }
val progress = AtomicInteger(0); data.put(key, point)
runLater { container.progress = 0.0 }
runAsync { val res = runAsync {
val totalCount = data.size val seriesName = String.format("%s: %.2f", key, point.voltage)
DataPlot.plot(
data.map { entry -> seriesName,
val seriesName = String.format("%s: %.2f", entry.key, entry.value.voltage) XYAdapter(NumassAnalyzer.CHANNEL_KEY, valueAxis),
DataPlot.plot( NumassDataUtils.spectrumWithBinning(getSpectrum(point), binning)
seriesName, ).configure {
XYAdapter(NumassAnalyzer.CHANNEL_KEY, valueAxis), "connectionType" to "step"
NumassDataUtils.spectrumWithBinning(getSpectrum(entry.value), binning) "thickness" to 2
).configure { "showLine" to true
"connectionType" to "step" "showSymbol" to false
"thickness" to 2 "showErrors" to false
"showLine" to true "JFreeChart.cache" to true
"showSymbol" to false
"showErrors" to false
"JFreeChart.cache" to true
}.also {
runLater { container.progress = progress.incrementAndGet().toDouble() / data.size }
}
} }
} ui { plots -> } ui { plot ->
frame.setAll(plots) frame.add(plot)
//detectorDataExportButton.isDisable = false //detectorDataExportButton.isDisable = false
} }
taskMap.put(key, res);
return res;
} }
fun update(map: Map<String, NumassPoint>) { fun putAll(data: Map<String, NumassPoint>): Map<String, Task<DataPlot>> {
synchronized(data) { cleanTasks()
//Remove obsolete keys return data.mapValues { entry ->
data.keys.filter { !map.containsKey(it) }.forEach { putOne(entry.key, entry.value)
data.remove(it)
frame.remove(it);
}
this.data.putAll(map);
updateView()
} }
} }
/**
* Remove the plot and cancel loading task if it is in progress.
*/
fun remove(name: String) {
frame.remove(name);
taskMap[name]?.cancel();
taskMap.remove(name);
data.remove(name)
}
/**
* Set frame content to the given map. All keys not in the map are removed.
*/
fun setAll(map: Map<String, NumassPoint>) {
taskMap.clear();
//Remove obsolete keys
data.keys.filter { !map.containsKey(it) }.forEach {
remove(it)
}
this.putAll(map);
}
} }

View File

@ -34,6 +34,7 @@ import java.util.logging.Level
/** /**
* Created by darksnake on 14-Apr-17. * Created by darksnake on 14-Apr-17.
*/ */
@Deprecated("obsolete")
class MainView : View("Numass data viewer") { class MainView : View("Numass data viewer") {
override val root: AnchorPane by fxml("/fxml/MainView.fxml"); override val root: AnchorPane by fxml("/fxml/MainView.fxml");

View File

@ -51,6 +51,7 @@ import java.util.stream.Collectors
* *
* Created by darksnake on 14-Apr-17. * Created by darksnake on 14-Apr-17.
*/ */
@Deprecated("obsolete")
class NumassLoaderView : View() { class NumassLoaderView : View() {
override val root: AnchorPane by fxml("/fxml/NumassLoaderView.fxml") override val root: AnchorPane by fxml("/fxml/NumassLoaderView.fxml")
// lateinit var main: MainView // lateinit var main: MainView
@ -252,7 +253,7 @@ class NumassLoaderView : View() {
} ui { hvData -> } ui { hvData ->
hvData.ifPresent { hvData.ifPresent {
for (dp in it) { for (dp in it) {
val block = dp.getString("block", "default") val block = dp.getString("block", "default").replace(".","_")
if (!hvPlotData.has(block)) { if (!hvPlotData.has(block)) {
hvPlotData.add(TimePlot(block)) hvPlotData.add(TimePlot(block))
} }

View File

@ -14,6 +14,7 @@ import inr.numass.data.api.NumassAnalyzer
import inr.numass.data.api.NumassPoint import inr.numass.data.api.NumassPoint
import inr.numass.data.api.NumassSet import inr.numass.data.api.NumassSet
import javafx.beans.property.SimpleIntegerProperty import javafx.beans.property.SimpleIntegerProperty
import javafx.geometry.Insets
import javafx.geometry.Orientation import javafx.geometry.Orientation
import javafx.scene.image.ImageView import javafx.scene.image.ImageView
import javafx.util.converter.IntegerStringConverter import javafx.util.converter.IntegerStringConverter
@ -98,11 +99,14 @@ class SpectrumView(
vbox { vbox {
label("Lo channel") label("Lo channel")
textfield { textfield {
prefWidth= 60.0
textProperty().bindBidirectional(loChannelProperty.asObject(), IntegerStringConverter()) textProperty().bindBidirectional(loChannelProperty.asObject(), IntegerStringConverter())
} }
} }
items += RangeSlider().apply { items += RangeSlider().apply {
padding = Insets(0.0, 10.0, 0.0, 10.0)
prefWidth = 300.0
lowValue = 500.0 lowValue = 500.0
highValue = 3100.0 highValue = 3100.0
highValueProperty().bindBidirectional(upChannelProperty) highValueProperty().bindBidirectional(upChannelProperty)
@ -118,6 +122,7 @@ class SpectrumView(
vbox { vbox {
label("Up channel") label("Up channel")
textfield { textfield {
prefWidth= 60.0
textProperty().bindBidirectional(upChannelProperty.asObject(), IntegerStringConverter()) textProperty().bindBidirectional(upChannelProperty.asObject(), IntegerStringConverter())
} }
} }

View File

@ -0,0 +1,130 @@
package inr.numass.viewer
import hep.dataforge.context.Context
import hep.dataforge.context.Global
import hep.dataforge.exceptions.StorageException
import hep.dataforge.kodex.fx.dfIcon
import hep.dataforge.storage.filestorage.FileStorageFactory
import inr.numass.NumassProperties
import inr.numass.data.storage.NumassStorage
import javafx.application.Platform
import javafx.beans.property.SimpleObjectProperty
import javafx.beans.property.SimpleStringProperty
import javafx.collections.FXCollections
import javafx.collections.ObservableList
import javafx.geometry.Insets
import javafx.scene.image.ImageView
import javafx.scene.layout.Priority
import javafx.scene.text.Font
import javafx.stage.DirectoryChooser
import org.controlsfx.control.StatusBar
import tornadofx.*
import java.io.File
import java.net.URI
class StorageView : View(title = "Numass storage", icon = ImageView(dfIcon)) {
val selected: ObservableList<Any> = FXCollections.observableArrayList();
private val context: Context
get() = Global.instance()
val storageProperty = SimpleObjectProperty<NumassStorage>()
var storage by storageProperty
val storageNameProperty = SimpleStringProperty("")
var storageName by storageNameProperty
val statusBar = StatusBar();
override val root = borderpane {
top {
toolbar {
prefHeight = 40.0
button("load") {
action {
val chooser = DirectoryChooser()
chooser.title = "Select numass storage root"
val storageRoot = NumassProperties.getNumassProperty("numass.storage.root")
try {
if (storageRoot == null) {
chooser.initialDirectory = File(".").absoluteFile
} else {
chooser.initialDirectory = File(storageRoot)
}
} catch (ex: Exception) {
NumassProperties.setNumassProperty("numass.storage.root", null)
}
val rootDir = chooser.showDialog(primaryStage.scene.window)
if (rootDir != null) {
NumassProperties.setNumassProperty("numass.storage.root", rootDir.absolutePath)
loadDirectory(rootDir.toURI())
}
}
}
}
label(storageNameProperty) {
padding = Insets(0.0, 0.0, 0.0, 10.0);
font = Font.font("System Bold", 13.0);
}
pane {
hgrow = Priority.ALWAYS
}
togglebutton("Console") {
}
}
center {
splitpane {
// treetableview {
//
// }
tabpane {
}
setDividerPosition(0, 0.3);
}
}
bottom = statusBar;
}
private fun loadDirectory(path: URI) {
runAsync {
updateTitle("Load storage ($path)")
updateProgress(-1.0, -1.0);
updateMessage("Building numass storage tree...")
val root = NumassStorage(context, FileStorageFactory.buildStorageMeta(path, true, true));
setRootStorage(root)
Platform.runLater { storageName = "Storage: " + path }
updateProgress(1.0, 1.0)
}
}
fun setRootStorage(root: NumassStorage) {
runAsync {
updateTitle("Fill data to UI (" + root.name + ")")
updateProgress(-1.0, 1.0)
Platform.runLater { statusBar.progress = -1.0 }
updateMessage("Loading numass storage tree...")
try {
storageProperty.set(root)
} catch (ex: StorageException) {
context.logger.error("Could not load the storage", ex);
}
// callback.setProgress(1, 1);
Platform.runLater { statusBar.progress = 0.0 }
updateMessage("Numass storage tree loaded.")
updateProgress(1.0, 1.0)
}
}
}

View File

@ -59,9 +59,9 @@ class ViewerTest : View(title = "Numass viewer test", icon = ImageView(dfIcon))
} }
fun update(set: NumassSet) { fun update(set: NumassSet) {
amp.update(set.points.filter { it.voltage != 16000.0 }.collect(Collectors.toMap({ "point_${it.voltage}" }, { it }))); amp.setAll(set.points.filter { it.voltage != 16000.0 }.collect(Collectors.toMap({ "point_${it.voltage}" }, { it })));
//sp.update(mapOf("test" to set)); sp.update(mapOf("test" to set));
//hv.update(set) hv.update(set)
} }
} }

View File

@ -21,38 +21,36 @@ limitations under the License.
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<?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.111" xmlns:fx="http://javafx.com/fxml/1"> <AnchorPane id="AnchorPane" prefHeight="768.0" prefWidth="1024.0" xmlns="http://javafx.com/javafx/8.0.111"
<children> xmlns:fx="http://javafx.com/fxml/1">
<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"
<top> AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<top>
<ToolBar nodeOrientation="LEFT_TO_RIGHT" prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER"> <ToolBar nodeOrientation="LEFT_TO_RIGHT" prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<items> <Button fx:id="loadDirectoryButton" mnemonicParsing="false" text="Load directory"/>
<Button fx:id="loadDirectoryButton" mnemonicParsing="false" text="Load directory" /> <Button fx:id="loadRemoteButton" mnemonicParsing="false" text="Remote storage"/>
<Button fx:id="loadRemoteButton" mnemonicParsing="false" text="Remote storage" /> <Label fx:id="storagePathLabel" text="Storage:" textFill="BLUE" textOverrun="CENTER_ELLIPSIS">
<Label fx:id="storagePathLabel" text="Storage:" textFill="BLUE" textOverrun="CENTER_ELLIPSIS"> <font>
<font> <Font name="System Bold" size="13.0"/>
<Font name="System Bold" size="13.0" /> </font>
</font> <padding>
<padding> <Insets left="10.0"/>
<Insets left="10.0" /> </padding>
</padding></Label> </Label>
<Pane HBox.hgrow="ALWAYS" /> <Pane HBox.hgrow="ALWAYS"/>
<!--<ToggleButton fx:id="processManagerButton" mnemonicParsing="false" text="ProcessManager" />--> <!--<ToggleButton fx:id="processManagerButton" mnemonicParsing="false" text="ProcessManager" />-->
<ToggleButton fx:id="consoleButton" contentDisplay="CENTER" mnemonicParsing="false" text="Console" /> <ToggleButton fx:id="consoleButton" contentDisplay="CENTER" mnemonicParsing="false" text="Console"/>
</items>
</ToolBar> </ToolBar>
</top> </top>
<bottom> <bottom>
<StatusBar fx:id="statusBar" BorderPane.alignment="CENTER" /> <StatusBar fx:id="statusBar" BorderPane.alignment="CENTER"/>
</bottom> </bottom>
<center> <center>
<SplitPane dividerPositions="0.2984344422700587" prefHeight="160.0" prefWidth="200.0" BorderPane.alignment="CENTER"> <SplitPane dividerPositions="0.2984344422700587" prefHeight="160.0" prefWidth="200.0"
<items> BorderPane.alignment="CENTER">
<BorderPane fx:id="treePane" prefHeight="200.0" prefWidth="200.0" /> <BorderPane fx:id="treePane" prefHeight="200.0" prefWidth="200.0"/>
<BorderPane fx:id="loaderPane" prefHeight="200.0" prefWidth="200.0" /> <BorderPane fx:id="loaderPane" prefHeight="200.0" prefWidth="200.0"/>
</items> </SplitPane>
</SplitPane> </center>
</center> </BorderPane>
</BorderPane>
</children>
</AnchorPane> </AnchorPane>