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,12 +81,11 @@ object NumassDataUtils {
return SpectrumAdapter("Uset", "CR", "CRerr", "Time") return SpectrumAdapter("Uset", "CR", "CRerr", "Time")
} }
fun read(envelope: Envelope): NumassPoint { fun read(envelope: Envelope): NumassPoint =
return if (envelope.dataType?.startsWith("numass.point.classic") ?: envelope.meta.hasValue("split")) { if (envelope.meta.hasMeta("dpp_params") || envelope.meta.hasMeta("tqdc")) {
ClassicNumassPoint(envelope)
} else {
ProtoNumassPoint.fromEnvelope(envelope) ProtoNumassPoint.fromEnvelope(envelope)
} } else {
ClassicNumassPoint(envelope)
} }
} }

View File

@ -35,7 +35,6 @@ import java.nio.file.Files
import java.nio.file.Path import java.nio.file.Path
import java.time.Instant import java.time.Instant
import kotlin.reflect.KClass import kotlin.reflect.KClass
import kotlin.streams.toList
/** /**
@ -47,7 +46,7 @@ class NumassDataLoader(
override val context: Context, override val context: Context,
override val parent: StorageElement?, override val parent: StorageElement?,
override val name: String, override val name: String,
override val path: Path override val path: Path,
) : Loader<NumassPoint>, NumassSet, Provider, FileStorageElement { ) : Loader<NumassPoint>, NumassSet, Provider, FileStorageElement {
override val type: KClass<NumassPoint> = NumassPoint::class override val type: KClass<NumassPoint> = NumassPoint::class
@ -97,7 +96,7 @@ class NumassDataLoader(
override val startTime: Instant 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() { override fun close() {
//do nothing //do nothing

View File

@ -187,7 +187,6 @@ class MainView : View(title = "Numass viewer", icon = dfIconView) {
} }
envelope?.let { envelope?.let {
if (it.meta.hasMeta("external_meta")) {
//try to read as point //try to read as point
val point = NumassDataUtils.read(it) val point = NumassDataUtils.read(it)
runLater { runLater {
@ -195,12 +194,6 @@ class MainView : View(title = "Numass viewer", icon = dfIconView) {
set(path.fileName.toString(), point) set(path.fileName.toString(), point)
} }
} }
} else {
alert(
type = Alert.AlertType.ERROR,
header = "Unknown envelope content: $path"
).show()
}
} }
} }
} }