From d444f2b12b4b6fcd7992cca212173b8b1b11171a Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 29 Aug 2018 20:23:47 +0300 Subject: [PATCH] Code fixes. --- .../numass/data/storage/NumassDataFactory.kt | 5 +-- .../numass/actions/AdjustErrorsAction.java | 4 +++ .../numass/actions/MonitorCorrectAction.java | 3 ++ .../actions/SubstractSpectrumAction.java | 4 +++ .../main/kotlin/inr/numass/WorkspaceTest.kt | 2 +- .../inr/numass/actions/AnalyzeDataAction.kt | 2 +- .../inr/numass/actions/MergeDataAction.kt | 2 +- .../inr/numass/actions/PlotFitResultAction.kt | 5 ++- .../inr/numass/actions/SummaryAction.kt | 2 +- .../inr/numass/actions/TimeAnalyzerAction.kt | 2 +- .../inr/numass/actions/TimeSpectrumAction.kt | 2 +- .../inr/numass/actions/TransformDataAction.kt | 2 +- .../numass/tasks/NumassFitScanSummaryTask.kt | 2 +- numass-viewer/build.gradle | 2 +- .../main/kotlin/inr/numass/viewer/MainView.kt | 35 +++++++------------ 15 files changed, 37 insertions(+), 37 deletions(-) diff --git a/numass-core/src/main/kotlin/inr/numass/data/storage/NumassDataFactory.kt b/numass-core/src/main/kotlin/inr/numass/data/storage/NumassDataFactory.kt index 95cb0474..7863420e 100644 --- a/numass-core/src/main/kotlin/inr/numass/data/storage/NumassDataFactory.kt +++ b/numass-core/src/main/kotlin/inr/numass/data/storage/NumassDataFactory.kt @@ -9,13 +9,14 @@ import hep.dataforge.storage.Storage import hep.dataforge.storage.StorageElement import hep.dataforge.storage.StorageManager import inr.numass.data.api.NumassSet +import inr.numass.data.storage.NumassDirectory.Companion.NUMASS_DIRECTORY_TYPE import kotlinx.coroutines.experimental.runBlocking import kotlin.coroutines.experimental.buildSequence /** * Created by darksnake on 03-Feb-17. */ -object NumassDataFactory : DataFactory(NumassSet::class.java) { +class NumassDataFactory : DataFactory(NumassSet::class.java) { override val name = "numass" @@ -36,7 +37,7 @@ object NumassDataFactory : DataFactory(NumassSet::class.java) { } override fun fill(builder: DataNodeEditor, context: Context, meta: Meta) { - val newMeta = meta.builder.setValue("type", "numass") + val newMeta = meta.builder.setValue("type", NUMASS_DIRECTORY_TYPE) runBlocking { val storage = context.load(StorageManager::class.java, Meta.empty()).create(newMeta) as Storage storage.sequence().forEach { pair -> diff --git a/numass-main/src/main/java/inr/numass/actions/AdjustErrorsAction.java b/numass-main/src/main/java/inr/numass/actions/AdjustErrorsAction.java index 71afe26d..6780feed 100644 --- a/numass-main/src/main/java/inr/numass/actions/AdjustErrorsAction.java +++ b/numass-main/src/main/java/inr/numass/actions/AdjustErrorsAction.java @@ -26,6 +26,10 @@ import java.util.List; @TypedActionDef(name = "adjustErrors", inputType = Table.class, outputType = Table.class) public class AdjustErrorsAction extends OneToOneAction { + public AdjustErrorsAction() { + super("adjustErrors", Table.class, Table.class); + } + @Override protected Table execute(Context context, String name, Table input, Laminate meta) { List points = new ArrayList<>(); diff --git a/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java b/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java index c58e64d7..23c7b6b6 100644 --- a/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java +++ b/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java @@ -48,6 +48,9 @@ import static hep.dataforge.io.output.Output.TEXT_TYPE; */ @TypedActionDef(name = "monitor", inputType = Table.class, outputType = Table.class) public class MonitorCorrectAction extends OneToOneAction { + public MonitorCorrectAction() { + super("monitor", Table.class, Table.class); + } //private static final String[] monitorNames = {"timestamp", NumassAnalyzer.COUNT_KEY, NumassAnalyzer.COUNT_RATE_KEY, NumassAnalyzer.COUNT_RATE_KEY}; diff --git a/numass-main/src/main/java/inr/numass/actions/SubstractSpectrumAction.java b/numass-main/src/main/java/inr/numass/actions/SubstractSpectrumAction.java index 6424b02f..5c3f0f02 100644 --- a/numass-main/src/main/java/inr/numass/actions/SubstractSpectrumAction.java +++ b/numass-main/src/main/java/inr/numass/actions/SubstractSpectrumAction.java @@ -29,6 +29,10 @@ import static hep.dataforge.io.output.Output.TEXT_TYPE; @TypedActionDef(name = "substractSpectrum", inputType = Table.class, outputType = Table.class, info = "Substract reference spectrum (background)") public class SubstractSpectrumAction extends OneToOneAction { + public SubstractSpectrumAction() { + super("substractSpectrum", Table.class, Table.class); + } + @Override protected Table execute(Context context, String name, Table input, Laminate inputMeta) { try { diff --git a/numass-main/src/main/kotlin/inr/numass/WorkspaceTest.kt b/numass-main/src/main/kotlin/inr/numass/WorkspaceTest.kt index 7e007027..e471b437 100644 --- a/numass-main/src/main/kotlin/inr/numass/WorkspaceTest.kt +++ b/numass-main/src/main/kotlin/inr/numass/WorkspaceTest.kt @@ -25,7 +25,7 @@ object WorkspaceTest { val workspace = BasicWorkspace.builder().apply { this.context = Numass.buildContext() - data("", NumassDataFactory, MetaBuilder("storage").putValue("path", storagepath)) + data("", NumassDataFactory(), MetaBuilder("storage").putValue("path", storagepath)) }.build() } diff --git a/numass-main/src/main/kotlin/inr/numass/actions/AnalyzeDataAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/AnalyzeDataAction.kt index b8434104..d7631c7c 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/AnalyzeDataAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/AnalyzeDataAction.kt @@ -22,7 +22,7 @@ import inr.numass.data.api.NumassSet ValueDef(key = "window.lo", type = arrayOf(NUMBER, STRING), def = "0", info = "Lower bound for window"), ValueDef(key = "window.up", type = arrayOf(NUMBER, STRING), def = "10000", info = "Upper bound for window") ) -object AnalyzeDataAction : OneToOneAction() { +object AnalyzeDataAction : OneToOneAction("numass.analyze", NumassSet::class.java, Table::class.java) { override fun execute(context: Context, name: String, input: NumassSet, inputMeta: Laminate): Table { //TODO add processor here val analyzer = NumassAnalyzer.DEFAULT_ANALYZER diff --git a/numass-main/src/main/kotlin/inr/numass/actions/MergeDataAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/MergeDataAction.kt index 79ee61c6..e82de07c 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/MergeDataAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/MergeDataAction.kt @@ -39,7 +39,7 @@ import java.util.* */ @TypedActionDef(name = "numass.merge", inputType = Table::class, outputType = Table::class, info = "Merge different numass data files into one.") @NodeDef(key = "grouping", info = "The definition of grouping rule for this merge", descriptor = "method::hep.dataforge.actions.GroupBuilder.byMeta") -object MergeDataAction : ManyToOneAction() { +object MergeDataAction : ManyToOneAction("numass.merge", Table::class.java,Table::class.java) { private val parnames = arrayOf(NumassPoint.HV_KEY, NumassPoint.LENGTH_KEY, NumassAnalyzer.COUNT_KEY, NumassAnalyzer.COUNT_RATE_KEY, NumassAnalyzer.COUNT_RATE_ERROR_KEY) diff --git a/numass-main/src/main/kotlin/inr/numass/actions/PlotFitResultAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/PlotFitResultAction.kt index 7b41f5aa..731ceee8 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/PlotFitResultAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/PlotFitResultAction.kt @@ -25,7 +25,6 @@ import hep.dataforge.plots.data.DataPlot import hep.dataforge.plots.data.XYFunctionPlot import hep.dataforge.plots.output.plot import hep.dataforge.stat.fit.FitResult -import hep.dataforge.stat.fit.FitState import hep.dataforge.stat.models.XYModel import hep.dataforge.tables.Adapters import hep.dataforge.tables.ValuesAdapter @@ -34,9 +33,9 @@ import java.util.stream.StreamSupport /** * @author darksnake */ -@TypedActionDef(name = "plotFit", info = "Plot fit result", inputType = FitState::class, outputType = FitState::class) +@TypedActionDef(name = "plotFit", info = "Plot fit result", inputType = FitResult::class, outputType = FitResult::class) @NodeDef(key = "adapter", info = "adapter for DataSet being fitted. By default is taken from model.") -object PlotFitResultAction : OneToOneAction() { +object PlotFitResultAction : OneToOneAction("plotFit", FitResult::class.java, FitResult::class.java) { override fun execute(context: Context, name: String, input: FitResult, metaData: Laminate): FitResult { diff --git a/numass-main/src/main/kotlin/inr/numass/actions/SummaryAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/SummaryAction.kt index a23800e9..2913f0ed 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/SummaryAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/SummaryAction.kt @@ -39,7 +39,7 @@ import kotlin.collections.ArrayList */ @TypedActionDef(name = "summary", inputType = FitState::class, outputType = Table::class, info = "Generate summary for fit results of different datasets.") @ValueDef(key = "parnames", multiple = true, required = true, info = "List of names of parameters for which summary should be done") -object SummaryAction : ManyToOneAction() { +object SummaryAction : ManyToOneAction("summary", FitState::class.java,Table::class.java) { const val SUMMARY_NAME = "sumName" 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 0d61d2d9..4fa68baf 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt @@ -34,7 +34,7 @@ import kotlin.streams.asStream NodeDef(key = "plot", info = "Configuration for stat plots") ) @TypedActionDef(name = "timeSpectrum", inputType = NumassPoint::class, outputType = Table::class) -object TimeAnalyzerAction : OneToOneAction() { +object TimeAnalyzerAction : OneToOneAction("timeSpectrum",NumassPoint::class.java,Table::class.java) { private val analyzer = TimeAnalyzer(); override fun execute(context: Context, name: String, input: NumassPoint, inputMeta: Laminate): Table { diff --git a/numass-main/src/main/kotlin/inr/numass/actions/TimeSpectrumAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/TimeSpectrumAction.kt index 1846ebf9..1763189b 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/TimeSpectrumAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/TimeSpectrumAction.kt @@ -33,7 +33,7 @@ import kotlin.streams.asStream NodeDef(key = "plot", info = "Configuration for stat plots") ) @TypedActionDef(name = "numass.timeSpectrum", inputType = NumassPoint::class, outputType = Table::class) -object TimeSpectrumAction : OneToOneAction() { +object TimeSpectrumAction : OneToOneAction( "numass.timeSpectrum", NumassPoint::class.java, Table::class.java) { private val analyzer = TimeAnalyzer(); override fun execute(context: Context, name: String, input: NumassPoint, inputMeta: Laminate): Table { diff --git a/numass-main/src/main/kotlin/inr/numass/actions/TransformDataAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/TransformDataAction.kt index a8418400..0fc9fa18 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/TransformDataAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/TransformDataAction.kt @@ -35,7 +35,7 @@ import java.util.* ValueDef(key = "utransform", info = "Expression for voltage transformation. Uses U as input") ) @NodeDef(key = "correction", multiple = true, descriptor = "method::inr.numass.actions.TransformDataAction.makeCorrection") -object TransformDataAction : OneToOneAction() { +object TransformDataAction : OneToOneAction("numass.transform", Table::class.java, Table::class.java) { override fun execute(context: Context, name: String, input: Table, meta: Laminate): Table { diff --git a/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt b/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt index 580c844b..75e0b057 100644 --- a/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt +++ b/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt @@ -43,7 +43,7 @@ object NumassFitScanSummaryTask : AbstractTask(Table::class.java) { override val name = "scansum" @TypedActionDef(name = "sterileSummary", inputType = FitResult::class, outputType = Table::class) - private class FitSummaryAction : ManyToOneAction() { + private class FitSummaryAction : ManyToOneAction("sterileSummary",FitResult::class.java,Table::class.java) { override fun execute(context: Context, nodeName: String, input: Map, meta: Laminate): Table { val builder = ListTable.Builder("m", "U2", "U2err", "U2limit", "E0", "trap") diff --git a/numass-viewer/build.gradle b/numass-viewer/build.gradle index 9682eb08..3a4c54b1 100644 --- a/numass-viewer/build.gradle +++ b/numass-viewer/build.gradle @@ -12,7 +12,7 @@ if (!hasProperty('mainClass')) { mainClassName = mainClass -version = "0.5.5" +version = "0.5.6" description = "The viewer for numass data" diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/MainView.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/MainView.kt index 678adbb8..2e47b839 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/MainView.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/MainView.kt @@ -2,9 +2,10 @@ package inr.numass.viewer import hep.dataforge.context.Context import hep.dataforge.context.Global -import hep.dataforge.fx.* -import hep.dataforge.fx.fragments.LogFragment -import hep.dataforge.fx.meta.MetaViewer +import hep.dataforge.fx.dfIconView +import hep.dataforge.fx.except +import hep.dataforge.fx.runGoal +import hep.dataforge.fx.ui import hep.dataforge.storage.Storage import inr.numass.NumassProperties import inr.numass.data.api.NumassPoint @@ -27,9 +28,9 @@ import java.nio.file.Path class MainView(val context: Context = Global.getContext("viewer")) : View(title = "Numass viewer", icon = dfIconView) { private val statusBar = StatusBar(); - private val logFragment = LogFragment().apply { - addLogHandler(context.logger) - } +// private val logFragment = LogFragment().apply { +// addLogHandler(context.logger) +// } private val pathProperty = SimpleObjectProperty() private var path: Path by pathProperty @@ -37,9 +38,6 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title private val contentViewProperty = SimpleObjectProperty() var contentView: UIComponent? by contentViewProperty - private val infoViewProperty = SimpleObjectProperty() - var infoView: UIComponent? by infoViewProperty - override val root = borderpane { prefHeight = 600.0 prefWidth = 800.0 @@ -110,22 +108,17 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title } } - label(pathProperty.asString()) { + label(pathProperty.stringBinding{it?.toString() ?: "NOT LOADED"}) { padding = Insets(0.0, 0.0, 0.0, 10.0); font = Font.font("System Bold", 13.0); } pane { hgrow = Priority.ALWAYS } - button("Info") { - action { - infoView?.openModal(escapeClosesWindow = true) - } - } - togglebutton("Console") { - isSelected = false - logFragment.bindWindow(this@togglebutton) - } +// togglebutton("Console") { +// isSelected = false +// logFragment.bindWindow(this@togglebutton) +// } } } bottom = statusBar @@ -140,7 +133,6 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title private suspend fun load(path: Path) { runLater { contentView = null - infoView = null } if (Files.isDirectory(path)) { if (Files.exists(path.resolve(NumassDataLoader.META_FRAGMENT_NAME))) { @@ -154,7 +146,6 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title clear() set(it.name, CachedSet(it)) } - infoView = MetaViewer(it.meta) } except { alert( type = Alert.AlertType.ERROR, @@ -170,7 +161,6 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title NumassDirectory.INSTANCE.read(context, path) } ui { contentView = StorageView(it as Storage) - infoView = MetaViewer(it.meta) } } } else { @@ -196,7 +186,6 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title contentView = AmplitudeView().apply { set(path.fileName.toString(), CachedPoint(point)) } - infoView = PointInfoView(CachedPoint(point)) } } else { alert(