diff --git a/numass-core/src/main/java/inr/numass/data/api/NumassPoint.java b/numass-core/src/main/java/inr/numass/data/api/NumassPoint.java index 1c71d171..c9129a00 100644 --- a/numass-core/src/main/java/inr/numass/data/api/NumassPoint.java +++ b/numass-core/src/main/java/inr/numass/data/api/NumassPoint.java @@ -15,20 +15,31 @@ public interface NumassPoint extends Metoid, NumassBlock { String START_TIME_KEY = "start"; String LENGTH_KEY = "length"; String HV_KEY = "voltage"; + String INDEX_KEY = "index"; Stream getBlocks(); /** * Get the voltage setting for the point + * * @return */ default double getVoltage() { return getMeta().getDouble(HV_KEY, 0); } + /** + * Get the index for this point in the set + * @return + */ + default int getIndex() { + return getMeta().getInt(INDEX_KEY, -1); + } + /** * Get the first block if it exists. Throw runtime exception otherwise. + * * @return */ default NumassBlock getFirstBlock() { @@ -37,6 +48,7 @@ public interface NumassPoint extends Metoid, NumassBlock { /** * Get the starting time from meta or from first block + * * @return */ @Override diff --git a/numass-core/src/main/java/inr/numass/data/storage/ClassicNumassPoint.java b/numass-core/src/main/java/inr/numass/data/storage/ClassicNumassPoint.java index 13486252..a4aaa1be 100644 --- a/numass-core/src/main/java/inr/numass/data/storage/ClassicNumassPoint.java +++ b/numass-core/src/main/java/inr/numass/data/storage/ClassicNumassPoint.java @@ -55,6 +55,11 @@ public class ClassicNumassPoint implements NumassPoint { return getMeta().getDouble("external_meta.HV1_value", 0); } + @Override + public int getIndex() { + return getMeta().getInt("external_meta.point_index", -1); + } + @Override public Meta getMeta() { return envelope.getMeta(); diff --git a/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt b/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt index 28ae6d14..67b78e8c 100644 --- a/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt +++ b/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt @@ -50,7 +50,7 @@ val selectTask = task("select") { } } -@ValueDef(name = "showPlot", type = arrayOf(ValueType.BOOLEAN), info = "Show plot after complete") +@ValueDef(name = "showPlot", type = [ValueType.BOOLEAN], info = "Show plot after complete") val monitorTableTask = task("monitor") { model { meta -> dependsOn(selectTask, meta) @@ -84,7 +84,7 @@ val monitorTableTask = task("monitor") { //add set markers addSetMarkers(frame, data.values) } - context.getIo().out("numass.monitor", name, "dfp").use { + context.io.out("numass.monitor", name, "dfp").use { NumassUtils.writeEnvelope(it, PlotFrame.Wrapper().wrap(frame)) } } diff --git a/numass-viewer/build.gradle b/numass-viewer/build.gradle index 1a51777a..3137acee 100644 --- a/numass-viewer/build.gradle +++ b/numass-viewer/build.gradle @@ -1,7 +1,4 @@ -plugins{ - id "application" -} - +apply plugin: 'application' apply plugin: 'kotlin' repositories { @@ -19,15 +16,10 @@ version = "0.5.0" description = "The viewer for numass data" -compileKotlin.kotlinOptions.jvmTarget = "1.8" dependencies { compile project(':numass-core') compile "hep.dataforge:plots-jfc" //project(':dataforge-plots:plots-jfc') compile "hep.dataforge:dataforge-gui" - compile 'com.jcraft:jsch:0.1.54' } -apply plugin: 'kotlin' - - diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/AmplitudeView.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/AmplitudeView.kt index 57a746c5..c7b93b60 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/AmplitudeView.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/AmplitudeView.kt @@ -90,10 +90,10 @@ class AmplitudeView( } binningProperty.onChange { - reset() + clear() } normalizeProperty.onChange { - reset() + clear() } container.progressProperty.bind(progress) @@ -151,7 +151,7 @@ class AmplitudeView( } } - private fun reset() { + fun clear() { frame.plots.clear() plots.clear() invalidate() diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/HVView.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/HVView.kt index 968b780c..bf776aed 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/HVView.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/HVView.kt @@ -77,5 +77,9 @@ class HVView : View(title = "High voltage time plot", icon = ImageView(dfIcon)) data.remove(id); } + fun clear(){ + data.clear() + } + } diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/SlowControlView.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/SlowControlView.kt index f6945d88..cbc5d687 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/SlowControlView.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/SlowControlView.kt @@ -91,4 +91,8 @@ class SlowControlView : View(title = "Numass slow control view", icon = ImageVie this.data.remove(id) } + fun clear(){ + data.clear() + } + } diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/SpectrumView.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/SpectrumView.kt index 6825f4ed..82c914df 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/SpectrumView.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/SpectrumView.kt @@ -198,4 +198,8 @@ class SpectrumView( fun remove(key: String) { data.remove(key) } + + fun clear(){ + data.clear() + } } diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/StorageView.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/StorageView.kt index 1fe8c48b..f232b046 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/StorageView.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/StorageView.kt @@ -152,44 +152,53 @@ class StorageView(private val context: Context = Global.instance()) : View(title cellFormat { value -> when (value.content) { is Storage -> { - text = value.id + text = value.content.name graphic = null } is NumassSet -> { text = null - graphic = checkbox(value.id, value.checkedProperty) + graphic = checkbox(value.content.name).apply { + selectedProperty().bindBidirectional(value.checkedProperty) + } } is NumassPoint -> { text = null - graphic = checkbox(value.id, value.checkedProperty) + graphic = checkbox("${value.content.voltage}[${value.content.index}]").apply { + selectedProperty().bindBidirectional(value.checkedProperty) + } } is TableLoader -> { text = null - graphic = checkbox(value.id, value.checkedProperty) + graphic = checkbox(value.content.name).apply { + selectedProperty().bindBidirectional(value.checkedProperty) + } } else -> { text = value.id graphic = null } } + contextMenu = ContextMenu() + contextMenu.item("Clear"){ + action { + this@cellFormat.treeItem.uncheckAll() + } + } if (value.content is Metoid) { - contextMenu = ContextMenu().apply { - item("Meta") { - action { - openInternalBuilderWindow(title = "Info: ${value.id}", escapeClosesWindow = true) { - scrollpane { - textarea { - isEditable = false - isWrapText = true - text = value.content.meta.toString().replace(" ", "\n\t") - } + contextMenu.item("Meta") { + action { + openInternalBuilderWindow(title = "Info: ${value.id}", escapeClosesWindow = true) { + scrollpane { + textarea { + isEditable = false + isWrapText = true + text = value.content.meta.toString().replace(" ", "\n\t") } } } } } - } else { - contextMenu = null + } } } @@ -225,6 +234,12 @@ class StorageView(private val context: Context = Global.instance()) : View(title } + private fun TreeItem.uncheckAll(){ + this.value.checked = false + this.children.forEach{it.uncheckAll()} + } + + private fun buildContainer(content: Any, parent: Container): Container = when (content) { is Storage -> { @@ -236,10 +251,10 @@ class StorageView(private val context: Context = Global.instance()) : View(title } else { content.name } - Container(id.toString(), content) + Container(id, content) } is NumassPoint -> { - Container("${parent.id}/${content.voltage}".replace(".", "_"), content) + Container("${parent.id}/${content.voltage}[${content.index}]", content) } is Loader -> { Container(content.path.toString(), content); @@ -261,7 +276,7 @@ class StorageView(private val context: Context = Global.instance()) : View(title title = "Load storage ($path)" progress = -1.0 message = "Building numass storage tree..." - (StorageManager.buildStorage(context,NumassStorageFactory.buildStorageMeta(path, true, true))as NumassStorage).also { + (StorageManager.buildStorage(context, NumassStorageFactory.buildStorageMeta(path, true, true)) as NumassStorage).also { progress = 1.0 } } ui { diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/Viewer.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/Viewer.kt index 0df8625f..19dedb9a 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/Viewer.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/Viewer.kt @@ -3,6 +3,8 @@ package inr.numass.viewer import ch.qos.logback.classic.Level import ch.qos.logback.classic.Logger import hep.dataforge.context.Global +import hep.dataforge.fx.dfIcon +import javafx.stage.Stage import org.slf4j.LoggerFactory import tornadofx.* @@ -14,11 +16,10 @@ class Viewer : App(StorageView::class) { (LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME) as Logger).level = Level.INFO } -// override fun start(stage: Stage) { -// stage.icons += dfIcon -//// (LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME) as Logger).level = Level.INFO -// super.start(stage) -// } + override fun start(stage: Stage) { + stage.icons += dfIcon + super.start(stage) + } override fun stop() { super.stop()