Fixing workspace

This commit is contained in:
Alexander Nozik 2018-05-07 17:01:55 +03:00
parent ce25ac24b1
commit 682c8805a2
13 changed files with 66 additions and 34 deletions

View File

@ -47,6 +47,7 @@ allprojects {
compileTestKotlin { compileTestKotlin {
kotlinOptions { kotlinOptions {
freeCompilerArgs = ['-Xenable-jvm-default']
jvmTarget = "1.8" jvmTarget = "1.8"
javaParameters = true javaParameters = true
} }

View File

@ -54,7 +54,17 @@ val Envelope.dataStream: InputStream
get() = if (this.meta.getString("compression", "none") == "zlib") { get() = if (this.meta.getString("compression", "none") == "zlib") {
//TODO move to new type of data //TODO move to new type of data
val inflatter = Inflater() val inflatter = Inflater()
inflatter.setInput(data.read.array()) val array: ByteArray = with(data.buffer) {
if (hasArray()) {
array()
} else {
ByteArray(this.limit()).also {
this.position(0)
get(it)
}
}
}
inflatter.setInput(array)
val bos = ByteArrayOutputStream() val bos = ByteArrayOutputStream()
val buffer = ByteArray(8192) val buffer = ByteArray(8192)
while (!inflatter.finished()) { while (!inflatter.finished()) {

View File

@ -98,7 +98,8 @@ class ClassicNumassPoint(private val envelope: Envelope) : NumassPoint {
} }
override val frames: Stream<NumassFrame> = Stream.empty() override val frames: Stream<NumassFrame>
get() = Stream.empty()
} }
companion object { companion object {

View File

@ -119,7 +119,7 @@ class MergeDataAction : ManyToOneAction<Table, Table>() {
curPoint curPoint
}.forEach { res.add(it) } }.forEach { res.add(it) }
return ListTable(MetaTableFormat.forNames(parnames), res) return ListTable(MetaTableFormat.forNames(*parnames), res)
} }

View File

@ -7,6 +7,7 @@ package inr.numass.tasks
import hep.dataforge.data.DataNode import hep.dataforge.data.DataNode
import hep.dataforge.data.DataTree import hep.dataforge.data.DataTree
import hep.dataforge.kodex.useMeta
import hep.dataforge.meta.Meta import hep.dataforge.meta.Meta
import hep.dataforge.meta.MetaBuilder import hep.dataforge.meta.MetaBuilder
import hep.dataforge.stat.fit.FitAction import hep.dataforge.stat.fit.FitAction
@ -71,7 +72,9 @@ object NumassFitScanTask : AbstractTask<FitResult>() {
override fun buildModel(model: TaskModel.Builder, meta: Meta) { override fun buildModel(model: TaskModel.Builder, meta: Meta) {
model.configure(meta.getMetaOrEmpty("scan")) model.configure(meta.getMetaOrEmpty("scan"))
model.configure { it -> it.putNode(meta.getMetaOrEmpty("fit")) } model.configure {
meta.useMeta("fit"){putNode(it)}
}
model.dependsOn("filter", meta) model.dependsOn("filter", meta)
} }

View File

@ -5,11 +5,13 @@ import hep.dataforge.data.DataSet
import hep.dataforge.data.DataTree import hep.dataforge.data.DataTree
import hep.dataforge.data.DataUtils import hep.dataforge.data.DataUtils
import hep.dataforge.description.ValueDef import hep.dataforge.description.ValueDef
import hep.dataforge.description.ValueDefs
import hep.dataforge.fx.plots.FXPlotManager import hep.dataforge.fx.plots.FXPlotManager
import hep.dataforge.fx.plots.plus import hep.dataforge.fx.plots.plus
import hep.dataforge.kodex.buildMeta import hep.dataforge.kodex.buildMeta
import hep.dataforge.kodex.configure import hep.dataforge.kodex.configure
import hep.dataforge.kodex.task import hep.dataforge.kodex.task
import hep.dataforge.kodex.useMeta
import hep.dataforge.meta.Meta import hep.dataforge.meta.Meta
import hep.dataforge.meta.MetaUtils import hep.dataforge.meta.MetaUtils
import hep.dataforge.plots.PlotFrame import hep.dataforge.plots.PlotFrame
@ -50,11 +52,30 @@ val selectTask = task("select") {
} }
} }
@ValueDef(name = "showPlot", type = [ValueType.BOOLEAN], info = "Show plot after complete") val analyzeTask = task("analyze") {
model { meta ->
dependsOn(selectTask, meta);
configure(MetaUtils.optEither(meta, "analyzer", "prepare").orElse(Meta.empty()))
}
pipe<NumassSet, Table> { set ->
SmartAnalyzer().analyzeSet(set, meta).also { res ->
val outputMeta = meta.builder.putNode("data", set.meta)
context.io.output(name, stage = "numass.analyze").push(NumassUtils.wrap(res, outputMeta))
}
}
}
@ValueDefs(
ValueDef(name = "showPlot", type = [ValueType.BOOLEAN], info = "Show plot after complete"),
ValueDef(name = "monitorVoltage", type = [ValueType.NUMBER], info = "The voltage for monitor point")
)
val monitorTableTask = task("monitor") { val monitorTableTask = task("monitor") {
model { meta -> model { meta ->
dependsOn(selectTask, meta) dependsOn(selectTask, meta)
configure(meta.getMetaOrEmpty("analyzer")) configure(meta.getMetaOrEmpty("monitor"))
configure{
meta.useMeta("analyzer"){putNode(it)}
}
} }
join<NumassSet, Table> { data -> join<NumassSet, Table> { data ->
val monitorVoltage = meta.getDouble("monitorVoltage", 16000.0); val monitorVoltage = meta.getDouble("monitorVoltage", 16000.0);
@ -96,19 +117,6 @@ val monitorTableTask = task("monitor") {
} }
} }
val analyzeTask = task("analyze") {
model { meta ->
dependsOn(selectTask, meta);
configure(MetaUtils.optEither(meta, "analyzer", "prepare").orElse(Meta.empty()))
}
pipe<NumassSet, Table> { set ->
SmartAnalyzer().analyzeSet(set, meta).also { res ->
val outputMeta = meta.builder.putNode("data", set.meta)
context.io.output(name, stage = "numass.analyze").push(NumassUtils.wrap(res, outputMeta))
}
}
}
val mergeTask = task("merge") { val mergeTask = task("merge") {
model { meta -> model { meta ->
dependsOn(analyzeTask, meta) dependsOn(analyzeTask, meta)
@ -127,7 +135,7 @@ val mergeEmptyTask = task("empty") {
.removeNode("data") .removeNode("data")
.removeNode("empty") .removeNode("empty")
.setNode("data", meta.getMeta("empty")) .setNode("data", meta.getMeta("empty"))
.setValue("merge." + MERGE_NAME, meta.getString("merge." + MERGE_NAME, "") + "_empty"); .setValue("merge.$MERGE_NAME", meta.getString("merge.$MERGE_NAME", "") + "_empty");
dependsOn(mergeTask, newMeta) dependsOn(mergeTask, newMeta)
} }
transform<Table> { data -> transform<Table> { data ->
@ -185,7 +193,7 @@ val transformTask = task("transform") {
} }
configure(MetaUtils.optEither(meta, "transform", "prepare").orElse(Meta.empty())) configure(MetaUtils.optEither(meta, "transform", "prepare").orElse(Meta.empty()))
} }
action<Table, Table>(TransformDataAction()); action<Table, Table>(TransformDataAction())
} }
val filterTask = task("filter") { val filterTask = task("filter") {

View File

@ -1,6 +1,7 @@
package inr.numass.viewer package inr.numass.viewer
import hep.dataforge.fx.dfIcon import hep.dataforge.fx.dfIcon
import hep.dataforge.fx.except
import hep.dataforge.fx.plots.PlotContainer import hep.dataforge.fx.plots.PlotContainer
import hep.dataforge.fx.runGoal import hep.dataforge.fx.runGoal
import hep.dataforge.fx.ui import hep.dataforge.fx.ui
@ -72,7 +73,7 @@ class AmplitudeView : View(title = "Numass amplitude spectrum plot", icon = Imag
private val data: ObservableMap<String, CachedPoint> = FXCollections.observableHashMap() private val data: ObservableMap<String, CachedPoint> = FXCollections.observableHashMap()
private val plots: ObservableMap<String, Goal<Plottable>> = FXCollections.observableHashMap() private val plots: ObservableMap<String, Goal<Plottable>> = FXCollections.observableHashMap()
val isEmpty = booleanBinding(data) { data.isEmpty() } val isEmpty = booleanBinding(data) { isEmpty() }
private val progress = object : DoubleBinding() { private val progress = object : DoubleBinding() {
init { init {
@ -107,7 +108,7 @@ class AmplitudeView : View(title = "Numass amplitude spectrum plot", icon = Imag
/** /**
* Put or replace current plot with name `key` * Put or replace current plot with name `key`
*/ */
fun add(key: String, point: CachedPoint) { operator fun set(key: String, point: CachedPoint) {
data[key] = point data[key] = point
} }
@ -116,6 +117,7 @@ class AmplitudeView : View(title = "Numass amplitude spectrum plot", icon = Imag
} }
private fun invalidate() { private fun invalidate() {
isEmpty.invalidate()
data.forEach { key, point -> data.forEach { key, point ->
plots.computeIfAbsent(key) { plots.computeIfAbsent(key) {
runGoal<Plottable>("loadAmplitudeSpectrum_$key") { runGoal<Plottable>("loadAmplitudeSpectrum_$key") {
@ -149,6 +151,8 @@ class AmplitudeView : View(title = "Numass amplitude spectrum plot", icon = Imag
} ui { plot -> } ui { plot ->
frame.add(plot) frame.add(plot)
progress.invalidate() progress.invalidate()
} except {
throw it
} }
} }
plots.keys.filter { !data.containsKey(it) }.forEach { remove(it) } plots.keys.filter { !data.containsKey(it) }.forEach { remove(it) }

View File

@ -47,6 +47,7 @@ class HVView : View(title = "High voltage time plot", icon = ImageView(dfIcon))
init { init {
data.addListener { change: MapChangeListener.Change<out String, out NumassSet> -> data.addListener { change: MapChangeListener.Change<out String, out NumassSet> ->
isEmpty.invalidate()
if (change.wasRemoved()) { if (change.wasRemoved()) {
frame.remove(change.key) frame.remove(change.key)
} }
@ -69,8 +70,8 @@ class HVView : View(title = "High voltage time plot", icon = ImageView(dfIcon))
} }
fun add(id: String, set: NumassSet) { operator fun set(id: String, set: NumassSet) {
data.put(id, set) data[id] = set
} }
fun remove(id: String) { fun remove(id: String) {

View File

@ -195,7 +195,7 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title
val point = NumassPoint.read(it) val point = NumassPoint.read(it)
runLater { runLater {
contentView = AmplitudeView().apply { contentView = AmplitudeView().apply {
add(path.toString(), CachedPoint(point)) set(path.toString(), CachedPoint(point))
} }
infoView = PointInfoView(CachedPoint(point)) infoView = PointInfoView(CachedPoint(point))
} }

View File

@ -36,7 +36,9 @@ class SlowControlView : View(title = "Numass slow control view", icon = ImageVie
} }
val data: ObservableMap<String, TableLoader> = FXCollections.observableHashMap(); val data: ObservableMap<String, TableLoader> = FXCollections.observableHashMap();
val isEmpty = booleanBinding(data) { data.isEmpty() } val isEmpty = booleanBinding(data) {
data.isEmpty()
}
init { init {
data.addListener { change: MapChangeListener.Change<out String, out TableLoader> -> data.addListener { change: MapChangeListener.Change<out String, out TableLoader> ->
@ -64,6 +66,7 @@ class SlowControlView : View(title = "Numass slow control view", icon = ImageVie
plot.add(it); plot.add(it);
} }
} }
isEmpty.invalidate()
} }
} }
@ -83,8 +86,8 @@ class SlowControlView : View(title = "Numass slow control view", icon = ImageVie
} }
} }
fun add(id: String, loader: TableLoader) { operator fun set(id: String, loader: TableLoader) {
this.data.put(id, loader) this.data[id] = loader
} }
fun remove(id: String) { fun remove(id: String) {

View File

@ -106,6 +106,7 @@ class SpectrumView : View(title = "Numass spectrum plot", icon = ImageView(dfIco
if (change.wasAdded()) { if (change.wasAdded()) {
updateView() updateView()
} }
isEmpty.invalidate()
} }
} }

View File

@ -39,15 +39,15 @@ class StorageView(val storage: Storage) : View(title = "Numass storage", icon =
when (content) { when (content) {
is CachedPoint -> { is CachedPoint -> {
if (selected) { if (selected) {
ampView.add(id, content) ampView[id] = content
} else { } else {
ampView.remove(id) ampView.remove(id)
} }
} }
is CachedSet -> { is CachedSet -> {
if (selected) { if (selected) {
spectrumView.set(id, content) spectrumView[id] = content
hvView.add(id, content) hvView[id] = content
} else { } else {
spectrumView.remove(id) spectrumView.remove(id)
hvView.remove(id) hvView.remove(id)
@ -55,7 +55,7 @@ class StorageView(val storage: Storage) : View(title = "Numass storage", icon =
} }
is TableLoader -> { is TableLoader -> {
if (selected) { if (selected) {
scView.add(id, content) scView.set(id, content)
} else { } else {
scView.remove(id) scView.remove(id)
} }

View File

@ -52,7 +52,7 @@ class ViewerComponentsTest : View(title = "Numass viewer test", icon = ImageView
fun update(set: NumassSet) { fun update(set: NumassSet) {
amp.setAll(set.points.filter { it.voltage != 16000.0 }.associateBy({ "point_${it.voltage}" }) { CachedPoint(it) }); amp.setAll(set.points.filter { it.voltage != 16000.0 }.associateBy({ "point_${it.voltage}" }) { CachedPoint(it) });
sp.set("test", CachedSet(set)); sp.set("test", CachedSet(set));
hv.add(set.name, set) hv.set(set.name, set)
} }
} }