Code fixes.

This commit is contained in:
Alexander Nozik 2018-08-29 20:23:47 +03:00
parent c8da91b39f
commit d444f2b12b
15 changed files with 37 additions and 37 deletions

View File

@ -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>(NumassSet::class.java) {
class NumassDataFactory : DataFactory<NumassSet>(NumassSet::class.java) {
override val name = "numass"
@ -36,7 +37,7 @@ object NumassDataFactory : DataFactory<NumassSet>(NumassSet::class.java) {
}
override fun fill(builder: DataNodeEditor<NumassSet>, 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 ->

View File

@ -26,6 +26,10 @@ import java.util.List;
@TypedActionDef(name = "adjustErrors", inputType = Table.class, outputType = Table.class)
public class AdjustErrorsAction extends OneToOneAction<Table, Table> {
public AdjustErrorsAction() {
super("adjustErrors", Table.class, Table.class);
}
@Override
protected Table execute(Context context, String name, Table input, Laminate meta) {
List<Values> points = new ArrayList<>();

View File

@ -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<Table, Table> {
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};

View File

@ -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<Table, Table> {
public SubstractSpectrumAction() {
super("substractSpectrum", Table.class, Table.class);
}
@Override
protected Table execute(Context context, String name, Table input, Laminate inputMeta) {
try {

View File

@ -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()
}

View File

@ -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<NumassSet, Table>() {
object AnalyzeDataAction : OneToOneAction<NumassSet, Table>("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

View File

@ -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<Table, Table>() {
object MergeDataAction : ManyToOneAction<Table, Table>("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)

View File

@ -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<FitResult, FitResult>() {
object PlotFitResultAction : OneToOneAction<FitResult, FitResult>("plotFit", FitResult::class.java, FitResult::class.java) {
override fun execute(context: Context, name: String, input: FitResult, metaData: Laminate): FitResult {

View File

@ -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<FitState, Table>() {
object SummaryAction : ManyToOneAction<FitState, Table>("summary", FitState::class.java,Table::class.java) {
const val SUMMARY_NAME = "sumName"

View File

@ -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<NumassPoint, Table>() {
object TimeAnalyzerAction : OneToOneAction<NumassPoint, Table>("timeSpectrum",NumassPoint::class.java,Table::class.java) {
private val analyzer = TimeAnalyzer();
override fun execute(context: Context, name: String, input: NumassPoint, inputMeta: Laminate): Table {

View File

@ -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<NumassPoint, Table>() {
object TimeSpectrumAction : OneToOneAction<NumassPoint, Table>( "numass.timeSpectrum", NumassPoint::class.java, Table::class.java) {
private val analyzer = TimeAnalyzer();
override fun execute(context: Context, name: String, input: NumassPoint, inputMeta: Laminate): Table {

View File

@ -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<Table, Table>() {
object TransformDataAction : OneToOneAction<Table, Table>("numass.transform", Table::class.java, Table::class.java) {
override fun execute(context: Context, name: String, input: Table, meta: Laminate): Table {

View File

@ -43,7 +43,7 @@ object NumassFitScanSummaryTask : AbstractTask<Table>(Table::class.java) {
override val name = "scansum"
@TypedActionDef(name = "sterileSummary", inputType = FitResult::class, outputType = Table::class)
private class FitSummaryAction : ManyToOneAction<FitResult, Table>() {
private class FitSummaryAction : ManyToOneAction<FitResult, Table>("sterileSummary",FitResult::class.java,Table::class.java) {
override fun execute(context: Context, nodeName: String, input: Map<String, FitResult>, meta: Laminate): Table {
val builder = ListTable.Builder("m", "U2", "U2err", "U2limit", "E0", "trap")

View File

@ -12,7 +12,7 @@ if (!hasProperty('mainClass')) {
mainClassName = mainClass
version = "0.5.5"
version = "0.5.6"
description = "The viewer for numass data"

View File

@ -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<Path>()
private var path: Path by pathProperty
@ -37,9 +38,6 @@ class MainView(val context: Context = Global.getContext("viewer")) : View(title
private val contentViewProperty = SimpleObjectProperty<UIComponent>()
var contentView: UIComponent? by contentViewProperty
private val infoViewProperty = SimpleObjectProperty<UIComponent>()
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(