Add trigger for tqdc reader

This commit is contained in:
Alexander Nozik 2021-11-15 22:22:04 +03:00
parent 35a29e983e
commit 78ff8d4f6e
3 changed files with 14 additions and 23 deletions

View File

@ -81,13 +81,12 @@ object NumassDataUtils {
return SpectrumAdapter("Uset", "CR", "CRerr", "Time")
}
fun read(envelope: Envelope): NumassPoint {
return if (envelope.dataType?.startsWith("numass.point.classic") ?: envelope.meta.hasValue("split")) {
ClassicNumassPoint(envelope)
} else {
fun read(envelope: Envelope): NumassPoint =
if (envelope.meta.hasMeta("dpp_params") || envelope.meta.hasMeta("tqdc")) {
ProtoNumassPoint.fromEnvelope(envelope)
} else {
ClassicNumassPoint(envelope)
}
}
}
suspend fun NumassBlock.transformChain(transform: (NumassEvent, NumassEvent) -> OrphanNumassEvent?): NumassBlock {

View File

@ -35,7 +35,6 @@ import java.nio.file.Files
import java.nio.file.Path
import java.time.Instant
import kotlin.reflect.KClass
import kotlin.streams.toList
/**
@ -47,7 +46,7 @@ class NumassDataLoader(
override val context: Context,
override val parent: StorageElement?,
override val name: String,
override val path: Path
override val path: Path,
) : Loader<NumassPoint>, NumassSet, Provider, FileStorageElement {
override val type: KClass<NumassPoint> = NumassPoint::class
@ -97,7 +96,7 @@ class NumassDataLoader(
override val startTime: Instant
get() = meta.optValue("start_time").map<Instant> { it.time }.orElseGet { super.startTime }
get() = meta.optValue("start_time").map { it.time }.orElseGet { super.startTime }
override fun close() {
//do nothing
@ -187,8 +186,8 @@ class NumassDataLoader(
}
fun Context.readNumassSet(path:Path):NumassDataLoader{
return NumassDataLoader(this,null,path.fileName.toString(),path)
fun Context.readNumassSet(path: Path): NumassDataLoader {
return NumassDataLoader(this, null, path.fileName.toString(), path)
}

View File

@ -165,7 +165,7 @@ class MainView : View(title = "Numass viewer", icon = dfIconView) {
//build storage
app.context.launch {
val storageElement = NumassDirectory.INSTANCE.read(app.context, path) as Storage
withContext(Dispatchers.JavaFx){
withContext(Dispatchers.JavaFx) {
contentView = storageView
storageView.storageProperty.set(storageElement)
}
@ -187,19 +187,12 @@ class MainView : View(title = "Numass viewer", icon = dfIconView) {
}
envelope?.let {
if (it.meta.hasMeta("external_meta")) {
//try to read as point
val point = NumassDataUtils.read(it)
runLater {
contentView = AmplitudeView().apply {
set(path.fileName.toString(), point)
}
//try to read as point
val point = NumassDataUtils.read(it)
runLater {
contentView = AmplitudeView().apply {
set(path.fileName.toString(), point)
}
} else {
alert(
type = Alert.AlertType.ERROR,
header = "Unknown envelope content: $path"
).show()
}
}
}