Site fixed
This commit is contained in:
parent
3127f1e7be
commit
626cac31a4
@ -14,14 +14,14 @@ description = "A bse package with minimal dependencies for numass"
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile "hep.dataforge:dataforge-storage" //project(':dataforge-storage')
|
compile "hep.dataforge:dataforge-storage" //project(':dataforge-storage')
|
||||||
compile 'com.google.protobuf:protobuf-java:3.2.0'
|
compile 'com.google.protobuf:protobuf-java:3.3.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
protobuf {
|
protobuf {
|
||||||
// Configure the protoc executable
|
// Configure the protoc executable
|
||||||
protoc {
|
protoc {
|
||||||
// Download from repositories
|
// Download from repositories
|
||||||
artifact = 'com.google.protobuf:protoc:3.2.0'
|
artifact = 'com.google.protobuf:protoc:3.3.0'
|
||||||
}
|
}
|
||||||
generatedFilesBaseDir = "$projectDir/gen"
|
generatedFilesBaseDir = "$projectDir/gen"
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
|||||||
package inr.numass.data;
|
package inr.numass.data;
|
||||||
|
|
||||||
|
import inr.numass.data.api.NumassPoint;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -21,9 +22,9 @@ public class PointBuilders {
|
|||||||
int[] spectrum = count(ch.getBlocksList().stream()
|
int[] spectrum = count(ch.getBlocksList().stream()
|
||||||
.flatMapToInt(block -> IntStream.concat(
|
.flatMapToInt(block -> IntStream.concat(
|
||||||
block.getPeaks().getAmplitudesList()
|
block.getPeaks().getAmplitudesList()
|
||||||
.stream().mapToInt(it -> it.intValue()),
|
.stream().mapToInt(Long::intValue),
|
||||||
block.getEventsList().stream()
|
block.getEventsList().stream()
|
||||||
.mapToInt(event -> peakFinder.apply(event))
|
.mapToInt(peakFinder::apply)
|
||||||
)),0
|
)),0
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -52,6 +53,6 @@ public class PointBuilders {
|
|||||||
}
|
}
|
||||||
list.get(i).incrementAndGet();
|
list.get(i).incrementAndGet();
|
||||||
});
|
});
|
||||||
return list.stream().mapToInt(i -> i.get()).toArray();
|
return list.stream().mapToInt(AtomicInteger::get).toArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,16 +21,32 @@ import java.util.stream.StreamSupport;
|
|||||||
/**
|
/**
|
||||||
* Created by darksnake on 08.07.2017.
|
* Created by darksnake on 08.07.2017.
|
||||||
*/
|
*/
|
||||||
public class EnvelopeNumassPoint implements NumassPoint {
|
public class ClassicNumassPoint implements NumassPoint {
|
||||||
private final Envelope envelope;
|
private final Envelope envelope;
|
||||||
|
|
||||||
public EnvelopeNumassPoint(Envelope envelope) {
|
public ClassicNumassPoint(Envelope envelope) {
|
||||||
this.envelope = envelope;
|
this.envelope = envelope;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<NumassBlock> getBlocks() {
|
public Stream<NumassBlock> getBlocks() {
|
||||||
return null;
|
double u = envelope.meta().getDouble("external_meta.HV1_value", 0);
|
||||||
|
long length;
|
||||||
|
if (envelope.meta().hasValue("external_meta.acquisition_time")) {
|
||||||
|
length = envelope.meta().getValue("external_meta.acquisition_time").longValue();
|
||||||
|
} else {
|
||||||
|
length = envelope.meta().getValue("acquisition_time").longValue();
|
||||||
|
}
|
||||||
|
return Stream.of(new ClassicBlock(getStartTime(), Duration.ofNanos(length), 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instant getStartTime() {
|
||||||
|
if (meta().hasValue("start_time")) {
|
||||||
|
return meta().getValue("start_time").timeValue();
|
||||||
|
} else {
|
||||||
|
return Instant.EPOCH;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -38,12 +54,13 @@ public class EnvelopeNumassPoint implements NumassPoint {
|
|||||||
return envelope.meta();
|
return envelope.meta();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class EnvelopeBlock implements NumassBlock, Iterable<NumassEvent> {
|
//TODO split blocks using meta
|
||||||
|
private class ClassicBlock implements NumassBlock, Iterable<NumassEvent> {
|
||||||
private final Instant startTime;
|
private final Instant startTime;
|
||||||
private final Duration length;
|
private final Duration length;
|
||||||
private final long blockOffset;
|
private final long blockOffset;
|
||||||
|
|
||||||
public EnvelopeBlock(Instant startTime, Duration length, long blockOffset) {
|
public ClassicBlock(Instant startTime, Duration length, long blockOffset) {
|
||||||
this.startTime = startTime;
|
this.startTime = startTime;
|
||||||
this.length = length;
|
this.length = length;
|
||||||
this.blockOffset = blockOffset;
|
this.blockOffset = blockOffset;
|
||||||
@ -78,7 +95,7 @@ public class EnvelopeNumassPoint implements NumassPoint {
|
|||||||
try {
|
try {
|
||||||
return stream.available() > 0;
|
return stream.available() > 0;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LoggerFactory.getLogger(EnvelopeNumassPoint.this.getClass()).error("Unexpected IOException " +
|
LoggerFactory.getLogger(ClassicNumassPoint.this.getClass()).error("Unexpected IOException " +
|
||||||
"when reading block", e);
|
"when reading block", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -88,27 +105,29 @@ public class EnvelopeNumassPoint implements NumassPoint {
|
|||||||
public NumassEvent next() {
|
public NumassEvent next() {
|
||||||
try {
|
try {
|
||||||
byte[] bytes = new byte[7];
|
byte[] bytes = new byte[7];
|
||||||
stream.read(bytes);
|
if (stream.read(bytes) < 7) {
|
||||||
|
throw new RuntimeException("Failed to read event");
|
||||||
|
}
|
||||||
ByteBuffer buffer = ByteBuffer.wrap(bytes);
|
ByteBuffer buffer = ByteBuffer.wrap(bytes);
|
||||||
short channel = (short) Short.toUnsignedInt(buffer.getShort());
|
short channel = (short) Short.toUnsignedInt(buffer.getShort());
|
||||||
long time = Integer.toUnsignedLong(buffer.getInt());
|
long time = Integer.toUnsignedLong(buffer.getInt());
|
||||||
byte status = buffer.get(); // status is ignored
|
byte status = buffer.get(); // status is ignored
|
||||||
return new NumassEvent(channel, (long) (time * timeCoef));
|
return new NumassEvent(channel, (long) (time * timeCoef));
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
LoggerFactory.getLogger(EnvelopeNumassPoint.this.getClass()).error("Unexpected IOException " +
|
LoggerFactory.getLogger(ClassicNumassPoint.this.getClass()).error("Unexpected IOException " +
|
||||||
"when reading block", ex);
|
"when reading block", ex);
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} catch (IOException ex){
|
} catch (IOException ex) {
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<NumassFrame> getFrames () {
|
public Stream<NumassFrame> getFrames() {
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -192,7 +192,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<NumassPoint> getPoints() {
|
public Stream<NumassPoint> getPoints() {
|
||||||
return getPointEnvelopes().map(EnvelopeNumassPoint::new);
|
return getPointEnvelopes().map(ClassicNumassPoint::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReversed() {
|
public boolean isReversed() {
|
||||||
|
@ -0,0 +1,78 @@
|
|||||||
|
package inr.numass.data.storage;
|
||||||
|
|
||||||
|
import hep.dataforge.io.envelopes.Envelope;
|
||||||
|
import hep.dataforge.meta.Meta;
|
||||||
|
import inr.numass.data.NumassProto;
|
||||||
|
import inr.numass.data.api.NumassBlock;
|
||||||
|
import inr.numass.data.api.NumassEvent;
|
||||||
|
import inr.numass.data.api.NumassFrame;
|
||||||
|
import inr.numass.data.api.NumassPoint;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by darksnake on 09.07.2017.
|
||||||
|
*/
|
||||||
|
public class ProtoNumassPoint implements NumassPoint {
|
||||||
|
private final Envelope envelope;
|
||||||
|
|
||||||
|
NumassProto.Point point;
|
||||||
|
|
||||||
|
public ProtoNumassPoint(Envelope envelope) {
|
||||||
|
this.envelope = envelope;
|
||||||
|
}
|
||||||
|
|
||||||
|
private NumassProto.Point getPoint() {
|
||||||
|
if (point == null) {
|
||||||
|
try (InputStream stream = envelope.getData().getStream()) {
|
||||||
|
point = NumassProto.Point.parseFrom(stream);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new RuntimeException("Failed to read point via protbuf");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return point;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Stream<NumassBlock> getBlocks() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Meta meta() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ProtoBlock implements NumassBlock {
|
||||||
|
|
||||||
|
final NumassProto.Point.Channel.Block block;
|
||||||
|
|
||||||
|
private ProtoBlock(NumassProto.Point.Channel.Block block) {
|
||||||
|
this.block = block;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instant getStartTime() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Duration getLength() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Stream<NumassEvent> getEvents() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Stream<NumassFrame> getFrames() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,7 +6,7 @@ message Point {
|
|||||||
message Channel {
|
message Channel {
|
||||||
message Block {
|
message Block {
|
||||||
// Необработанное событие
|
// Необработанное событие
|
||||||
message Event {
|
message Frame {
|
||||||
uint64 time = 1; //время в наносекундах от начала блока
|
uint64 time = 1; //время в наносекундах от начала блока
|
||||||
bytes data = 2; // массив кадра события в формате int16
|
bytes data = 2; // массив кадра события в формате int16
|
||||||
// ед. измерения - каналы
|
// ед. измерения - каналы
|
||||||
@ -15,16 +15,16 @@ message Point {
|
|||||||
// Для экономии места при сериализации амплитуды и времена лежат в
|
// Для экономии места при сериализации амплитуды и времена лежат в
|
||||||
// разных массивах. Амплитуда и время имеющие одинаковые индексы
|
// разных массивах. Амплитуда и время имеющие одинаковые индексы
|
||||||
// соответствуют одному событию
|
// соответствуют одному событию
|
||||||
message Peaks {
|
message Events {
|
||||||
repeated uint64 times = 1; //время в наносекундах от начала блока
|
repeated uint64 times = 1; //время в наносекундах от начала блока
|
||||||
repeated uint64 amplitudes = 2; //амплитуда события в каналах
|
repeated uint64 amplitudes = 2; //амплитуда события в каналах
|
||||||
}
|
}
|
||||||
uint64 time = 1; // время начала блока в наносекундах с начала эпохи
|
uint64 time = 1; // время начала блока в наносекундах с начала эпохи
|
||||||
repeated Event events = 2; // массив необработанных событий
|
repeated Frame frames = 2; // массив необработанных событий
|
||||||
Peaks peaks = 3; // массив обработанных событий
|
Events events = 3; // массив обработанных событий
|
||||||
}
|
}
|
||||||
uint64 num = 1; // номер канала
|
uint64 num = 1; // номер канала
|
||||||
repeated Block blocks = 2; // набранные блоки
|
repeated Block blocks = 2; // набранные блоки
|
||||||
}
|
}
|
||||||
repeated Channel channels = 1; // массив событий по каналам
|
repeated Channel channels = 1; // массив данных по каналам
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user