diff --git a/build.gradle.kts b/build.gradle.kts index 4324cd9..c42d342 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ allprojects { } group = "ru.inr.mass" - version = "0.1.1" + version = "0.1.2" } val dataforgeVersion by extra("0.5.2") diff --git a/numass-workspace/src/main/kotlin/ru/inr/mass/notebook/NumassJupyter.kt b/numass-workspace/src/main/kotlin/ru/inr/mass/notebook/NumassJupyter.kt index 1120daf..c660607 100644 --- a/numass-workspace/src/main/kotlin/ru/inr/mass/notebook/NumassJupyter.kt +++ b/numass-workspace/src/main/kotlin/ru/inr/mass/notebook/NumassJupyter.kt @@ -1,6 +1,9 @@ package ru.inr.mass.notebook +import kotlinx.coroutines.runBlocking +import kotlinx.html.* +import kotlinx.html.stream.createHTML import org.jetbrains.kotlinx.jupyter.api.HTML import org.jetbrains.kotlinx.jupyter.api.libraries.JupyterIntegration import ru.inr.mass.data.api.NumassBlock @@ -11,6 +14,7 @@ import ru.inr.mass.workspace.Numass import ru.inr.mass.workspace.plotNumassBlock import ru.inr.mass.workspace.plotNumassSet import space.kscience.dataforge.data.DataTree +import space.kscience.dataforge.data.DataTreeItem import space.kscience.plotly.Plotly import space.kscience.plotly.scatter import space.kscience.plotly.toHTML @@ -56,7 +60,23 @@ internal class NumassJupyter : JupyterIntegration() { } render> { tree -> - HTML("TODO: render repository tree") + HTML(createHTML().div { numassTree(tree)}) + } + } +} + +private fun FlowContent.numassTree(tree: DataTree) { + ul { + runBlocking { + tree.items().forEach { (token, treeItem) -> + li { + p { +token.toString() } + when (treeItem) { + is DataTreeItem.Leaf -> {} + is DataTreeItem.Node -> numassTree(treeItem.tree) + } + } + } } } } \ No newline at end of file diff --git a/numass-workspace/src/main/kotlin/ru/inr/mass/workspace/NumassPlugin.kt b/numass-workspace/src/main/kotlin/ru/inr/mass/workspace/NumassPlugin.kt index 374172f..63fdded 100644 --- a/numass-workspace/src/main/kotlin/ru/inr/mass/workspace/NumassPlugin.kt +++ b/numass-workspace/src/main/kotlin/ru/inr/mass/workspace/NumassPlugin.kt @@ -5,7 +5,11 @@ import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.PluginFactory import space.kscience.dataforge.context.PluginTag import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.values.Value +import space.kscience.dataforge.workspace.TaskReference import space.kscience.dataforge.workspace.WorkspacePlugin +import space.kscience.dataforge.workspace.task +import space.kscience.tables.Table import kotlin.reflect.KClass class NumassPlugin : WorkspacePlugin() { @@ -48,6 +52,64 @@ class NumassPlugin : WorkspacePlugin() { // } // } + val monitorTableTask: TaskReference> by task { + +// descriptor { +// value("showPlot", types = listOf(ValueType.BOOLEAN), info = "Show plot after complete") +// value("monitorPoint", types = listOf(ValueType.NUMBER), info = "The voltage for monitor point") +// } +// model { meta -> +// dependsOn(selectTask, meta) +//// if (meta.getBoolean("monitor.correctForThreshold", false)) { +//// dependsOn(subThresholdTask, meta, "threshold") +//// } +// configure(meta.getMetaOrEmpty("monitor")) +// configure { +// meta.useMeta("analyzer") { putNode(it) } +// setValue("@target", meta.getString("@target", meta.name)) +// } +// } +// join { data -> +// val monitorVoltage = meta.getDouble("monitorPoint", 16000.0); +// val analyzer = SmartAnalyzer() +// val analyzerMeta = meta.getMetaOrEmpty("analyzer") +// +// //val thresholdCorrection = da +// //TODO add separator labels +// val res = ListTable.Builder("timestamp", "count", "cr", "crErr", "index", "set") +// .rows( +// data.values.stream().flatMap { set -> +// set.points.stream() +// .filter { it.voltage == monitorVoltage } +// .parallel() +// .map { point -> +// analyzer.analyzeParent(point, analyzerMeta).edit { +// "index" to point.index +// "set" to set.name +// } +// } +// } +// +// ).build() +// +// if (meta.getBoolean("showPlot", true)) { +// val plot = DataPlot.plot(name, res, Adapters.buildXYAdapter("timestamp", "cr", "crErr")) +// context.plot(plot, name, "numass.monitor") { +// "xAxis.title" to "time" +// "xAxis.type" to "time" +// "yAxis.title" to "Count rate" +// "yAxis.units" to "Hz" +// } +// +// ((context.output["numass.monitor", name] as? PlotOutput)?.frame as? JFreeChartFrame)?.addSetMarkers(data.values) +// } +// +// context.output.render(res, stage = "numass.monitor", name = name, meta = meta) +// +// return@join res; +// } + } + companion object : PluginFactory { override val tag: PluginTag = PluginTag("numass", "ru.mipt.npm") override val type: KClass = NumassPlugin::class