diff --git a/numass-core/src/main/kotlin/inr/numass/data/storage/ProtoNumassPoint.kt b/numass-core/src/main/kotlin/inr/numass/data/storage/ProtoNumassPoint.kt index 7eafeef6..c7cd4017 100644 --- a/numass-core/src/main/kotlin/inr/numass/data/storage/ProtoNumassPoint.kt +++ b/numass-core/src/main/kotlin/inr/numass/data/storage/ProtoNumassPoint.kt @@ -102,6 +102,9 @@ class ProtoBlock(val channel: Int, private val block: NumassProto.Point.Channel. override val events: Stream get() = if (block.hasEvents()) { val events = block.events + if(events.timesCount!= events.amplitudesCount){ + LoggerFactory.getLogger(javaClass).error("The block is broken. Number of times is ${events.timesCount} and number of amplitudes is ${events.amplitudesCount}") + } IntStream.range(0, events.timesCount).mapToObj { i -> NumassEvent(events.getAmplitudes(i).toShort(), events.getTimes(i), this) } } else { Stream.empty() diff --git a/numass-main/src/main/kotlin/inr/numass/scripts/timeanalysis/AnalyzePoint.kt b/numass-main/src/main/kotlin/inr/numass/scripts/timeanalysis/AnalyzePoint.kt index ec907543..3d3d2484 100644 --- a/numass-main/src/main/kotlin/inr/numass/scripts/timeanalysis/AnalyzePoint.kt +++ b/numass-main/src/main/kotlin/inr/numass/scripts/timeanalysis/AnalyzePoint.kt @@ -15,8 +15,8 @@ import inr.numass.data.storage.NumassStorageFactory fun main(args: Array) { val context = buildContext("NUMASS", NumassPlugin::class.java, FXPlotManager::class.java) { - rootDir = "D:\\Work\\Numass\\sterile\\2017_11" - dataDir = "D:\\Work\\Numass\\data\\2017_11" + rootDir = "D:\\Work\\Numass\\sterile\\2018_04" + dataDir = "D:\\Work\\Numass\\data\\2018_04" } val storage = NumassStorageFactory.buildLocal(context, "Fill_2", true, false); diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/Cache.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/Cache.kt index 646d46ca..ebabdbe8 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/Cache.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/Cache.kt @@ -29,21 +29,21 @@ import kotlinx.coroutines.experimental.async private val analyzer = SimpleAnalyzer() -class CachedPoint(point: NumassPoint) : NumassPoint by point { - private val lazyBlocks: () -> List = { point.blocks } +class CachedPoint(val point: NumassPoint) : NumassPoint by point { - override val blocks: List - get() = lazyBlocks() + override val blocks: List by lazy { point.blocks } override val meta: Meta = point.meta - val channelSpectra: Deferred> = async(start = CoroutineStart.LAZY) { - return@async point.channels.mapValues { (_, value) -> analyzer.getAmplitudeSpectrum(value) } - } + val channelSpectra: Deferred> + get() = async(start = CoroutineStart.LAZY) { + return@async point.channels.mapValues { (_, value) -> analyzer.getAmplitudeSpectrum(value) } + } - val spectrum: Deferred = async(start = CoroutineStart.LAZY) { - analyzer.getAmplitudeSpectrum(point) - } + val spectrum: Deferred
+ get() = async(start = CoroutineStart.LAZY) { + analyzer.getAmplitudeSpectrum(point) + } } class CachedSet(set: NumassSet) : NumassSet by set { diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/PointInfoView.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/PointInfoView.kt index b6fbb41e..39d70a7c 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/PointInfoView.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/PointInfoView.kt @@ -2,16 +2,18 @@ package inr.numass.viewer import hep.dataforge.fx.meta.MetaViewer import inr.numass.data.analyzers.NumassAnalyzer -import kotlinx.coroutines.experimental.runBlocking +import javafx.beans.property.SimpleIntegerProperty +import kotlinx.coroutines.experimental.async +import org.controlsfx.glyphfont.FontAwesome import tornadofx.* import tornadofx.controlsfx.borders +import tornadofx.controlsfx.toGlyph class PointInfoView(val point: CachedPoint) : MetaViewer(point.meta) { - private val count: Int by lazy { - runBlocking { - point.spectrum.await().sumBy { it.getValue(NumassAnalyzer.COUNT_KEY).int } - } - } + + val countProperty = SimpleIntegerProperty(0) + var count by countProperty + override val root = super.root.apply { top { @@ -19,16 +21,30 @@ class PointInfoView(val point: CachedPoint) : MetaViewer(point.meta) { borders { lineBorder().build() } + row { + button(graphic = FontAwesome.Glyph.REFRESH.toGlyph()) { + action { + async { + val res = point.spectrum.await().sumBy { it.getValue(NumassAnalyzer.COUNT_KEY).int } + runLater { count = res } + } + } + } + } row { hbox { label("Total number of events: ") - label("$count") + label { + textProperty().bind(countProperty.asString()) + } } } row { hbox { label("Total count rate: ") - label(String.format("%.2f", count.toDouble() / point.length.toMillis() * 1000)) + label { + textProperty().bind(countProperty.stringBinding { String.format("%.2f", it!!.toDouble() / point.length.toMillis() * 1000) }) + } } } }