Control update

This commit is contained in:
Alexander Nozik 2018-03-14 21:42:29 +03:00
parent 65d24017d8
commit cf3268244e
3 changed files with 43 additions and 34 deletions

View File

@ -3,9 +3,11 @@ package inr.numass.data
import hep.dataforge.io.envelopes.Envelope
import hep.dataforge.meta.Meta
import hep.dataforge.meta.MetaBuilder
import inr.numass.data.api.NumassBlock
import inr.numass.data.api.NumassPoint
import inr.numass.data.api.NumassSet
import inr.numass.data.api.SimpleNumassPoint
import inr.numass.data.storage.ProtoBlock
import java.io.InputStream
import java.util.stream.Collectors
import java.util.stream.Stream
@ -49,3 +51,10 @@ val Envelope.dataStream : InputStream
} else {
this.data.stream
}
val NumassBlock.channel: Int
get() = if (this is ProtoBlock) {
this.channel
} else {
0
}

View File

@ -43,10 +43,23 @@ class ProtoNumassPoint(private val envelope: Envelope) : NumassPoint {
return envelope.meta
}
companion object {
fun readFile(path: Path): ProtoNumassPoint {
return ProtoNumassPoint(NumassFileEnvelope.open(path, true))
}
fun ofEpochNanos(nanos: Long): Instant {
val seconds = Math.floorDiv(nanos, 1e9.toInt().toLong())
val reminder = (nanos % 1e9).toInt()
return Instant.ofEpochSecond(seconds, reminder.toLong())
}
}
}
class ProtoBlock(val channel: Int, private val block: NumassProto.Point.Channel.Block, private val meta: Meta) : NumassBlock {
override fun getStartTime(): Instant {
return ofEpochNanos(block.time)
return ProtoNumassPoint.ofEpochNanos(block.time)
}
override fun getLength(): Duration {
@ -72,16 +85,3 @@ class ProtoNumassPoint(private val envelope: Envelope) : NumassPoint {
}
}
}
companion object {
fun readFile(path: Path): ProtoNumassPoint {
return ProtoNumassPoint(NumassFileEnvelope.open(path, true))
}
fun ofEpochNanos(nanos: Long): Instant {
val seconds = Math.floorDiv(nanos, 1e9.toInt().toLong())
val reminder = (nanos % 1e9).toInt()
return Instant.ofEpochSecond(seconds, reminder.toLong())
}
}
}

View File

@ -55,7 +55,7 @@ class AmplitudeView(
private val container = PlotContainer(frame).apply {
val binnintSelector: ChoiceBox<Int> = ChoiceBox(FXCollections.observableArrayList(1, 2, 5, 10, 20, 50)).apply {
val binningSelector: ChoiceBox<Int> = ChoiceBox(FXCollections.observableArrayList(1, 2, 5, 10, 20, 50)).apply {
minWidth = 0.0
selectionModel.selectLast()
binningProperty.bind(this.selectionModel.selectedItemProperty())
@ -64,7 +64,7 @@ class AmplitudeView(
minWidth = 0.0
this.selectedProperty().bindBidirectional(normalizeProperty)
}
addToSideBar(0, binnintSelector, normalizeSwitch)
addToSideBar(0, binningSelector, normalizeSwitch)
}
private val data: ObservableMap<String, NumassPoint> = FXCollections.observableHashMap()