Site fixed

This commit is contained in:
Alexander Nozik 2017-07-09 22:05:29 +03:00
parent 3127f1e7be
commit 626cac31a4
7 changed files with 684 additions and 531 deletions

View File

@ -14,14 +14,14 @@ description = "A bse package with minimal dependencies for numass"
dependencies {
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 {
// Configure the protoc executable
protoc {
// Download from repositories
artifact = 'com.google.protobuf:protoc:3.2.0'
artifact = 'com.google.protobuf:protoc:3.3.0'
}
generatedFilesBaseDir = "$projectDir/gen"
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
package inr.numass.data;
import inr.numass.data.api.NumassPoint;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
@ -21,9 +22,9 @@ public class PointBuilders {
int[] spectrum = count(ch.getBlocksList().stream()
.flatMapToInt(block -> IntStream.concat(
block.getPeaks().getAmplitudesList()
.stream().mapToInt(it -> it.intValue()),
.stream().mapToInt(Long::intValue),
block.getEventsList().stream()
.mapToInt(event -> peakFinder.apply(event))
.mapToInt(peakFinder::apply)
)),0
);
@ -52,6 +53,6 @@ public class PointBuilders {
}
list.get(i).incrementAndGet();
});
return list.stream().mapToInt(i -> i.get()).toArray();
return list.stream().mapToInt(AtomicInteger::get).toArray();
}
}

View File

@ -21,16 +21,32 @@ import java.util.stream.StreamSupport;
/**
* Created by darksnake on 08.07.2017.
*/
public class EnvelopeNumassPoint implements NumassPoint {
public class ClassicNumassPoint implements NumassPoint {
private final Envelope envelope;
public EnvelopeNumassPoint(Envelope envelope) {
public ClassicNumassPoint(Envelope envelope) {
this.envelope = envelope;
}
@Override
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
@ -38,12 +54,13 @@ public class EnvelopeNumassPoint implements NumassPoint {
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 Duration length;
private final long blockOffset;
public EnvelopeBlock(Instant startTime, Duration length, long blockOffset) {
public ClassicBlock(Instant startTime, Duration length, long blockOffset) {
this.startTime = startTime;
this.length = length;
this.blockOffset = blockOffset;
@ -78,7 +95,7 @@ public class EnvelopeNumassPoint implements NumassPoint {
try {
return stream.available() > 0;
} catch (IOException e) {
LoggerFactory.getLogger(EnvelopeNumassPoint.this.getClass()).error("Unexpected IOException " +
LoggerFactory.getLogger(ClassicNumassPoint.this.getClass()).error("Unexpected IOException " +
"when reading block", e);
return false;
}
@ -88,27 +105,29 @@ public class EnvelopeNumassPoint implements NumassPoint {
public NumassEvent next() {
try {
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);
short channel = (short) Short.toUnsignedInt(buffer.getShort());
long time = Integer.toUnsignedLong(buffer.getInt());
byte status = buffer.get(); // status is ignored
return new NumassEvent(channel, (long) (time * timeCoef));
} catch (IOException ex) {
LoggerFactory.getLogger(EnvelopeNumassPoint.this.getClass()).error("Unexpected IOException " +
LoggerFactory.getLogger(ClassicNumassPoint.this.getClass()).error("Unexpected IOException " +
"when reading block", ex);
throw new RuntimeException(ex);
}
}
};
} catch (IOException ex){
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
@Override
public Stream<NumassFrame> getFrames () {
return Stream.empty();
}
@Override
public Stream<NumassFrame> getFrames() {
return Stream.empty();
}
}
}

View File

@ -192,7 +192,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
@Override
public Stream<NumassPoint> getPoints() {
return getPointEnvelopes().map(EnvelopeNumassPoint::new);
return getPointEnvelopes().map(ClassicNumassPoint::new);
}
public boolean isReversed() {

View File

@ -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;
}
}
}

View File

@ -6,7 +6,7 @@ message Point {
message Channel {
message Block {
// Необработанное событие
message Event {
message Frame {
uint64 time = 1; //время в наносекундах от начала блока
bytes data = 2; // массив кадра события в формате int16
// ед. измерения - каналы
@ -15,16 +15,16 @@ message Point {
// Для экономии места при сериализации амплитуды и времена лежат в
// разных массивах. Амплитуда и время имеющие одинаковые индексы
// соответствуют одному событию
message Peaks {
message Events {
repeated uint64 times = 1; //время в наносекундах от начала блока
repeated uint64 amplitudes = 2; //амплитуда события в каналах
}
uint64 time = 1; // время начала блока в наносекундах с начала эпохи
repeated Event events = 2; // массив необработанных событий
Peaks peaks = 3; // массив обработанных событий
repeated Frame frames = 2; // массив необработанных событий
Events events = 3; // массив обработанных событий
}
uint64 num = 1; // номер канала
repeated Block blocks = 2; // набранные блоки
}
repeated Channel channels = 1; // массив событий по каналам
repeated Channel channels = 1; // массив данных по каналам
}