diff --git a/numass-core/src/main/kotlin/inr/numass/data/analyzers/AbstractAnalyzer.kt b/numass-core/src/main/kotlin/inr/numass/data/analyzers/AbstractAnalyzer.kt index c2931380..834def81 100644 --- a/numass-core/src/main/kotlin/inr/numass/data/analyzers/AbstractAnalyzer.kt +++ b/numass-core/src/main/kotlin/inr/numass/data/analyzers/AbstractAnalyzer.kt @@ -87,7 +87,7 @@ abstract class AbstractAnalyzer @JvmOverloads constructor(private val processor: val format = getTableFormat(config) return ListTable.Builder(format) - .rows(set.points.map { point -> analyzePoint(point, config) }) + .rows(set.points.map { point -> analyzeParent(point, config) }) .build() } diff --git a/numass-core/src/main/kotlin/inr/numass/data/analyzers/NumassAnalyzer.kt b/numass-core/src/main/kotlin/inr/numass/data/analyzers/NumassAnalyzer.kt index 8999e434..667abf26 100644 --- a/numass-core/src/main/kotlin/inr/numass/data/analyzers/NumassAnalyzer.kt +++ b/numass-core/src/main/kotlin/inr/numass/data/analyzers/NumassAnalyzer.kt @@ -22,11 +22,8 @@ import hep.dataforge.tables.Adapters.* import hep.dataforge.values.Value import hep.dataforge.values.ValueMap import hep.dataforge.values.Values -import inr.numass.data.api.NumassBlock -import inr.numass.data.api.NumassEvent -import inr.numass.data.api.NumassPoint +import inr.numass.data.api.* import inr.numass.data.api.NumassPoint.Companion.HV_KEY -import inr.numass.data.api.NumassSet import java.util.* import java.util.concurrent.atomic.AtomicLong import java.util.concurrent.atomic.AtomicReference @@ -55,9 +52,11 @@ interface NumassAnalyzer { * @param config * @return */ - fun analyzePoint(point: NumassPoint, config: Meta = Meta.empty()): Values { + fun analyzeParent(point: ParentBlock, config: Meta = Meta.empty()): Values { val map = HashMap(analyze(point, config).asMap()) - map[HV_KEY] = Value.of(point.voltage) + if(point is NumassPoint) { + map[HV_KEY] = Value.of(point.voltage) + } return ValueMap(map) } diff --git a/numass-core/src/main/kotlin/inr/numass/data/analyzers/TimeAnalyzer.kt b/numass-core/src/main/kotlin/inr/numass/data/analyzers/TimeAnalyzer.kt index f3caff9c..faab3a07 100644 --- a/numass-core/src/main/kotlin/inr/numass/data/analyzers/TimeAnalyzer.kt +++ b/numass-core/src/main/kotlin/inr/numass/data/analyzers/TimeAnalyzer.kt @@ -26,11 +26,8 @@ import hep.dataforge.values.Value import hep.dataforge.values.ValueMap import hep.dataforge.values.ValueType import hep.dataforge.values.Values -import inr.numass.data.api.NumassBlock -import inr.numass.data.api.NumassEvent -import inr.numass.data.api.NumassPoint +import inr.numass.data.api.* import inr.numass.data.api.NumassPoint.Companion.HV_KEY -import inr.numass.data.api.SignalProcessor import java.util.* import java.util.concurrent.atomic.AtomicLong import java.util.stream.Stream @@ -45,8 +42,8 @@ class TimeAnalyzer @JvmOverloads constructor(private val processor: SignalProces override fun analyze(block: NumassBlock, config: Meta): Values { //In case points inside points - if (block is NumassPoint) { - return analyzePoint(block, config) + if (block is ParentBlock) { + return analyzeParent(block, config) } @@ -81,7 +78,7 @@ class TimeAnalyzer @JvmOverloads constructor(private val processor: SignalProces ) } - override fun analyzePoint(point: NumassPoint, config: Meta): Values { + override fun analyzeParent(point: ParentBlock, config: Meta): Values { //Average count rates, do not sum events val res = point.blocks.stream() .filter { it.events.findAny().isPresent }// filter for empty blocks @@ -89,7 +86,9 @@ class TimeAnalyzer @JvmOverloads constructor(private val processor: SignalProces .reduce(null) { v1, v2 -> this.combineBlockResults(v1, v2) } val map = HashMap(res.asMap()) - map[HV_KEY] = Value.of(point.voltage) + if(point is NumassPoint) { + map[HV_KEY] = Value.of(point.voltage) + } return ValueMap(map) } diff --git a/numass-core/src/main/kotlin/inr/numass/data/api/MetaBlock.kt b/numass-core/src/main/kotlin/inr/numass/data/api/MetaBlock.kt index 36142bc5..4381978e 100644 --- a/numass-core/src/main/kotlin/inr/numass/data/api/MetaBlock.kt +++ b/numass-core/src/main/kotlin/inr/numass/data/api/MetaBlock.kt @@ -5,13 +5,17 @@ import java.time.Instant import java.util.* import java.util.stream.Stream +interface ParentBlock: NumassBlock{ + val blocks: Collection +} + /** * A block constructed from a set of other blocks. Internal blocks are not necessary subsequent. Blocks are automatically sorted. * Created by darksnake on 16.07.2017. */ -class MetaBlock(blocks: Collection) : NumassBlock { +class MetaBlock(blocks: Collection) : ParentBlock { - private val blocks = TreeSet(Comparator.comparing{ it.startTime }) + override val blocks = TreeSet(Comparator.comparing{ it.startTime }) init{ this.blocks.addAll(blocks) diff --git a/numass-core/src/main/kotlin/inr/numass/data/api/NumassPoint.kt b/numass-core/src/main/kotlin/inr/numass/data/api/NumassPoint.kt index 403e03e9..2dae90cb 100644 --- a/numass-core/src/main/kotlin/inr/numass/data/api/NumassPoint.kt +++ b/numass-core/src/main/kotlin/inr/numass/data/api/NumassPoint.kt @@ -14,10 +14,10 @@ import java.util.stream.Stream /** * Created by darksnake on 06-Jul-17. */ -interface NumassPoint : Metoid, NumassBlock, Provider { +interface NumassPoint : Metoid, ParentBlock, Provider { - val blocks: List + override val blocks: List /** * Provides block with given number (starting with 0) diff --git a/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt index bb348a18..2b2b37ad 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt @@ -76,8 +76,8 @@ class TimeAnalyzerAction : OneToOneAction() { "showErrors" to false "connectionType" to "step" }.apply { - configure(inputMeta.getMetaOrEmpty("histogram")) - }.fillData(histogram) + configure(inputMeta.getMetaOrEmpty("histogram")) + }.fillData(histogram) histPlot.add(histogramPlot) } @@ -103,7 +103,9 @@ class TimeAnalyzerAction : OneToOneAction() { } else { 1.0 } - + if(Thread.currentThread().isInterrupted){ + throw InterruptedException() + } statPlot.append( Adapters.buildXYDataPoint( t / 1000.0, 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 6b7e8db6..c55afbf8 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 @@ -19,19 +19,20 @@ fun main(args: Array) { dataDir = "D:\\Work\\Numass\\data\\2018_04" } - val storage = NumassStorageFactory.buildLocal(context, "Fill_2", true, false); + val storage = NumassStorageFactory.buildLocal(context, "Fill_3", true, false); val meta = buildMeta { "binNum" to 200 + "t0Step" to 100 node("window") { - "lo" to 0 + "lo" to 500 "up" to 4000 } - "plot.showErrors" to false + //"plot.showErrors" to false } //def sets = ((2..14) + (22..31)).collect { "set_$it" } - val sets = (2..14).map { "set_$it" } + val sets = (13..14).map { "set_$it" } //def sets = (16..31).collect { "set_$it" } //def sets = (20..28).collect { "set_$it" } @@ -39,7 +40,7 @@ fun main(args: Array) { storage.provide("loader::$set", NumassSet::class.java).orElse(null) }.filter { it != null } - val hvs = listOf(14000.0, 14200.0, 14600.0, 14800.0)//, 15000d, 15200d, 15400d, 15600d, 15800d] + val hvs = listOf(12000.0, 13000.0, 14000.0, 15000.0)//, 15000d, 15200d, 15400d, 15600d, 15800d] val all = NumassDataUtils.join("sum", loaders) @@ -60,7 +61,9 @@ fun main(args: Array) { val result = TimeAnalyzerAction().run(context, data, meta); - result.computeAll(); + result.nodeGoal().run() readLine() + println("Canceling task") + result.nodeGoal().cancel() } \ No newline at end of file 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 f2a5bbb9..fd1b10e0 100644 --- a/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt +++ b/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt @@ -87,7 +87,7 @@ val monitorTableTask = task("monitor") { data.values.stream().parallel() .flatMap { it.points.stream() } .filter { it.voltage == monitorVoltage } - .map { it -> analyzer.analyzePoint(it, analyzerMeta) } + .map { it -> analyzer.analyzeParent(it, analyzerMeta) } ).build() if (meta.getBoolean("showPlot", true)) {