diff --git a/.hgignore b/.hgignore index ccb1ce15..d05d0a78 100644 --- a/.hgignore +++ b/.hgignore @@ -11,3 +11,5 @@ private/* .nb-gradle/* .idea/ *.iml + +/numass-core/gen/ diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..b5a3db4d Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..96936931 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Apr 05 18:15:59 MSK 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip diff --git a/gradlew b/gradlew new file mode 100644 index 00000000..4453ccea --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save ( ) { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 00000000..e95643d6 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/numass-storage/numass-client/build.gradle b/numass-client/build.gradle similarity index 82% rename from numass-storage/numass-client/build.gradle rename to numass-client/build.gradle index f727accd..ee95af75 100644 --- a/numass-storage/numass-client/build.gradle +++ b/numass-client/build.gradle @@ -7,7 +7,7 @@ if (!hasProperty('mainClass')) { mainClassName = mainClass dependencies { - compile project(':numass-storage') + compile project(':numass-core') compile 'commons-cli:commons-cli:1.3.1' compile 'org.zeroturnaround:zt-zip:1.9' } \ No newline at end of file diff --git a/numass-storage/numass-client/src/main/java/inr/numass/client/Cli.java b/numass-client/src/main/java/inr/numass/client/Cli.java similarity index 100% rename from numass-storage/numass-client/src/main/java/inr/numass/client/Cli.java rename to numass-client/src/main/java/inr/numass/client/Cli.java diff --git a/numass-storage/numass-client/src/main/java/inr/numass/client/ClientUtils.java b/numass-client/src/main/java/inr/numass/client/ClientUtils.java similarity index 100% rename from numass-storage/numass-client/src/main/java/inr/numass/client/ClientUtils.java rename to numass-client/src/main/java/inr/numass/client/ClientUtils.java diff --git a/numass-storage/numass-client/src/main/java/inr/numass/client/NumassClient.java b/numass-client/src/main/java/inr/numass/client/NumassClient.java similarity index 100% rename from numass-storage/numass-client/src/main/java/inr/numass/client/NumassClient.java rename to numass-client/src/main/java/inr/numass/client/NumassClient.java diff --git a/numass-storage/numass-client/src/main/java/inr/numass/client/RemoteNumassStorage.java b/numass-client/src/main/java/inr/numass/client/RemoteNumassStorage.java similarity index 100% rename from numass-storage/numass-client/src/main/java/inr/numass/client/RemoteNumassStorage.java rename to numass-client/src/main/java/inr/numass/client/RemoteNumassStorage.java diff --git a/numass-control/build.gradle b/numass-control/build.gradle index c95858cc..4e5b9b82 100644 --- a/numass-control/build.gradle +++ b/numass-control/build.gradle @@ -6,7 +6,7 @@ configurations { } dependencies { - compile project(':numass-storage:numass-client') + compile project(':numass-client') compile "hep.dataforge:plots-jfc" // project(':dataforge-plots:plots-jfc') compile "hep.dataforge:dataforge-control" //project(':dataforge-control') compile "hep.dataforge:dataforge-fx" //project(':dataforge-fx') diff --git a/numass-storage/build.gradle b/numass-core/build.gradle similarity index 87% rename from numass-storage/build.gradle rename to numass-core/build.gradle index 6b2a84d6..228afaec 100644 --- a/numass-storage/build.gradle +++ b/numass-core/build.gradle @@ -9,6 +9,8 @@ buildscript { apply plugin: 'com.google.protobuf' +description = "A bse package with minimal dependencies for numass" + dependencies { compile "hep.dataforge:dataforge-storage" //project(':dataforge-storage') diff --git a/numass-storage/docs/server_commands.md b/numass-core/docs/server_commands.md similarity index 100% rename from numass-storage/docs/server_commands.md rename to numass-core/docs/server_commands.md diff --git a/numass-core/gen/main/java/inr/numass/data/NumassProto.java b/numass-core/gen/main/java/inr/numass/data/NumassProto.java new file mode 100644 index 00000000..fbc1e409 --- /dev/null +++ b/numass-core/gen/main/java/inr/numass/data/NumassProto.java @@ -0,0 +1,4450 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: inr/numas/numass-proto.proto + +package inr.numass.data; + +public final class NumassProto { + private NumassProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface PointOrBuilder extends + // @@protoc_insertion_point(interface_extends:inr.numass.data.Point) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     * массив событий по каналам
+     * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + java.util.List + getChannelsList(); + /** + *
+     * массив событий по каналам
+     * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + inr.numass.data.NumassProto.Point.Channel getChannels(int index); + /** + *
+     * массив событий по каналам
+     * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + int getChannelsCount(); + /** + *
+     * массив событий по каналам
+     * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + java.util.List + getChannelsOrBuilderList(); + /** + *
+     * массив событий по каналам
+     * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + inr.numass.data.NumassProto.Point.ChannelOrBuilder getChannelsOrBuilder( + int index); + } + /** + * Protobuf type {@code inr.numass.data.Point} + */ + public static final class Point extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:inr.numass.data.Point) + PointOrBuilder { + // Use Point.newBuilder() to construct. + private Point(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Point() { + channels_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Point( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + channels_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + channels_.add( + input.readMessage(inr.numass.data.NumassProto.Point.Channel.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + channels_ = java.util.Collections.unmodifiableList(channels_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_fieldAccessorTable + .ensureFieldAccessorsInitialized( + inr.numass.data.NumassProto.Point.class, inr.numass.data.NumassProto.Point.Builder.class); + } + + public interface ChannelOrBuilder extends + // @@protoc_insertion_point(interface_extends:inr.numass.data.Point.Channel) + com.google.protobuf.MessageOrBuilder { + + /** + *
+       * номер канала
+       * 
+ * + * uint64 num = 1; + */ + long getNum(); + + /** + *
+       * набранные блоки
+       * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + java.util.List + getBlocksList(); + /** + *
+       * набранные блоки
+       * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + inr.numass.data.NumassProto.Point.Channel.Block getBlocks(int index); + /** + *
+       * набранные блоки
+       * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + int getBlocksCount(); + /** + *
+       * набранные блоки
+       * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + java.util.List + getBlocksOrBuilderList(); + /** + *
+       * набранные блоки
+       * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + inr.numass.data.NumassProto.Point.Channel.BlockOrBuilder getBlocksOrBuilder( + int index); + } + /** + * Protobuf type {@code inr.numass.data.Point.Channel} + */ + public static final class Channel extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:inr.numass.data.Point.Channel) + ChannelOrBuilder { + // Use Channel.newBuilder() to construct. + private Channel(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Channel() { + num_ = 0L; + blocks_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Channel( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 8: { + + num_ = input.readUInt64(); + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + blocks_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + blocks_.add( + input.readMessage(inr.numass.data.NumassProto.Point.Channel.Block.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + blocks_ = java.util.Collections.unmodifiableList(blocks_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_fieldAccessorTable + .ensureFieldAccessorsInitialized( + inr.numass.data.NumassProto.Point.Channel.class, inr.numass.data.NumassProto.Point.Channel.Builder.class); + } + + public interface BlockOrBuilder extends + // @@protoc_insertion_point(interface_extends:inr.numass.data.Point.Channel.Block) + com.google.protobuf.MessageOrBuilder { + + /** + *
+         * время начала блока в наносекундах с начала эпохи
+         * 
+ * + * uint64 time = 1; + */ + long getTime(); + + /** + *
+         * массив необработанных событий
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + java.util.List + getEventsList(); + /** + *
+         * массив необработанных событий
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + inr.numass.data.NumassProto.Point.Channel.Block.Event getEvents(int index); + /** + *
+         * массив необработанных событий
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + int getEventsCount(); + /** + *
+         * массив необработанных событий
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + java.util.List + getEventsOrBuilderList(); + /** + *
+         * массив необработанных событий
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + inr.numass.data.NumassProto.Point.Channel.Block.EventOrBuilder getEventsOrBuilder( + int index); + + /** + *
+         * массив обработанных событий
+         * 
+ * + * .inr.numass.data.Point.Channel.Block.Peaks peaks = 3; + */ + boolean hasPeaks(); + /** + *
+         * массив обработанных событий
+         * 
+ * + * .inr.numass.data.Point.Channel.Block.Peaks peaks = 3; + */ + inr.numass.data.NumassProto.Point.Channel.Block.Peaks getPeaks(); + /** + *
+         * массив обработанных событий
+         * 
+ * + * .inr.numass.data.Point.Channel.Block.Peaks peaks = 3; + */ + inr.numass.data.NumassProto.Point.Channel.Block.PeaksOrBuilder getPeaksOrBuilder(); + } + /** + * Protobuf type {@code inr.numass.data.Point.Channel.Block} + */ + public static final class Block extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:inr.numass.data.Point.Channel.Block) + BlockOrBuilder { + // Use Block.newBuilder() to construct. + private Block(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Block() { + time_ = 0L; + events_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Block( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 8: { + + time_ = input.readUInt64(); + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + events_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + events_.add( + input.readMessage(inr.numass.data.NumassProto.Point.Channel.Block.Event.parser(), extensionRegistry)); + break; + } + case 26: { + inr.numass.data.NumassProto.Point.Channel.Block.Peaks.Builder subBuilder = null; + if (peaks_ != null) { + subBuilder = peaks_.toBuilder(); + } + peaks_ = input.readMessage(inr.numass.data.NumassProto.Point.Channel.Block.Peaks.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(peaks_); + peaks_ = subBuilder.buildPartial(); + } + + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + events_ = java.util.Collections.unmodifiableList(events_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_Block_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_Block_fieldAccessorTable + .ensureFieldAccessorsInitialized( + inr.numass.data.NumassProto.Point.Channel.Block.class, inr.numass.data.NumassProto.Point.Channel.Block.Builder.class); + } + + public interface EventOrBuilder extends + // @@protoc_insertion_point(interface_extends:inr.numass.data.Point.Channel.Block.Event) + com.google.protobuf.MessageOrBuilder { + + /** + *
+           *время в наносекундах от начала блока
+           * 
+ * + * uint64 time = 1; + */ + long getTime(); + + /** + *
+           * массив кадра события в формате int16
+           * 
+ * + * bytes data = 2; + */ + com.google.protobuf.ByteString getData(); + } + /** + *
+         * Необработанное событие
+         * 
+ * + * Protobuf type {@code inr.numass.data.Point.Channel.Block.Event} + */ + public static final class Event extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:inr.numass.data.Point.Channel.Block.Event) + EventOrBuilder { + // Use Event.newBuilder() to construct. + private Event(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Event() { + time_ = 0L; + data_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Event( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 8: { + + time_ = input.readUInt64(); + break; + } + case 18: { + + data_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_Block_Event_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_Block_Event_fieldAccessorTable + .ensureFieldAccessorsInitialized( + inr.numass.data.NumassProto.Point.Channel.Block.Event.class, inr.numass.data.NumassProto.Point.Channel.Block.Event.Builder.class); + } + + public static final int TIME_FIELD_NUMBER = 1; + private long time_; + /** + *
+           *время в наносекундах от начала блока
+           * 
+ * + * uint64 time = 1; + */ + public long getTime() { + return time_; + } + + public static final int DATA_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString data_; + /** + *
+           * массив кадра события в формате int16
+           * 
+ * + * bytes data = 2; + */ + public com.google.protobuf.ByteString getData() { + return data_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (time_ != 0L) { + output.writeUInt64(1, time_); + } + if (!data_.isEmpty()) { + output.writeBytes(2, data_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (time_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeUInt64Size(1, time_); + } + if (!data_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, data_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof inr.numass.data.NumassProto.Point.Channel.Block.Event)) { + return super.equals(obj); + } + inr.numass.data.NumassProto.Point.Channel.Block.Event other = (inr.numass.data.NumassProto.Point.Channel.Block.Event) obj; + + boolean result = true; + result = result && (getTime() + == other.getTime()); + result = result && getData() + .equals(other.getData()); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTime()); + hash = (37 * hash) + DATA_FIELD_NUMBER; + hash = (53 * hash) + getData().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static inr.numass.data.NumassProto.Point.Channel.Block.Event parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static inr.numass.data.NumassProto.Point.Channel.Block.Event parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point.Channel.Block.Event parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static inr.numass.data.NumassProto.Point.Channel.Block.Event parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point.Channel.Block.Event parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static inr.numass.data.NumassProto.Point.Channel.Block.Event parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point.Channel.Block.Event parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static inr.numass.data.NumassProto.Point.Channel.Block.Event parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point.Channel.Block.Event parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static inr.numass.data.NumassProto.Point.Channel.Block.Event parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(inr.numass.data.NumassProto.Point.Channel.Block.Event prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+           * Необработанное событие
+           * 
+ * + * Protobuf type {@code inr.numass.data.Point.Channel.Block.Event} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:inr.numass.data.Point.Channel.Block.Event) + inr.numass.data.NumassProto.Point.Channel.Block.EventOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_Block_Event_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_Block_Event_fieldAccessorTable + .ensureFieldAccessorsInitialized( + inr.numass.data.NumassProto.Point.Channel.Block.Event.class, inr.numass.data.NumassProto.Point.Channel.Block.Event.Builder.class); + } + + // Construct using inr.numass.data.NumassProto.Point.Channel.Block.Event.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + time_ = 0L; + + data_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_Block_Event_descriptor; + } + + public inr.numass.data.NumassProto.Point.Channel.Block.Event getDefaultInstanceForType() { + return inr.numass.data.NumassProto.Point.Channel.Block.Event.getDefaultInstance(); + } + + public inr.numass.data.NumassProto.Point.Channel.Block.Event build() { + inr.numass.data.NumassProto.Point.Channel.Block.Event result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public inr.numass.data.NumassProto.Point.Channel.Block.Event buildPartial() { + inr.numass.data.NumassProto.Point.Channel.Block.Event result = new inr.numass.data.NumassProto.Point.Channel.Block.Event(this); + result.time_ = time_; + result.data_ = data_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof inr.numass.data.NumassProto.Point.Channel.Block.Event) { + return mergeFrom((inr.numass.data.NumassProto.Point.Channel.Block.Event)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(inr.numass.data.NumassProto.Point.Channel.Block.Event other) { + if (other == inr.numass.data.NumassProto.Point.Channel.Block.Event.getDefaultInstance()) return this; + if (other.getTime() != 0L) { + setTime(other.getTime()); + } + if (other.getData() != com.google.protobuf.ByteString.EMPTY) { + setData(other.getData()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + inr.numass.data.NumassProto.Point.Channel.Block.Event parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (inr.numass.data.NumassProto.Point.Channel.Block.Event) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long time_ ; + /** + *
+             *время в наносекундах от начала блока
+             * 
+ * + * uint64 time = 1; + */ + public long getTime() { + return time_; + } + /** + *
+             *время в наносекундах от начала блока
+             * 
+ * + * uint64 time = 1; + */ + public Builder setTime(long value) { + + time_ = value; + onChanged(); + return this; + } + /** + *
+             *время в наносекундах от начала блока
+             * 
+ * + * uint64 time = 1; + */ + public Builder clearTime() { + + time_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString data_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+             * массив кадра события в формате int16
+             * 
+ * + * bytes data = 2; + */ + public com.google.protobuf.ByteString getData() { + return data_; + } + /** + *
+             * массив кадра события в формате int16
+             * 
+ * + * bytes data = 2; + */ + public Builder setData(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + data_ = value; + onChanged(); + return this; + } + /** + *
+             * массив кадра события в формате int16
+             * 
+ * + * bytes data = 2; + */ + public Builder clearData() { + + data_ = getDefaultInstance().getData(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:inr.numass.data.Point.Channel.Block.Event) + } + + // @@protoc_insertion_point(class_scope:inr.numass.data.Point.Channel.Block.Event) + private static final inr.numass.data.NumassProto.Point.Channel.Block.Event DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new inr.numass.data.NumassProto.Point.Channel.Block.Event(); + } + + public static inr.numass.data.NumassProto.Point.Channel.Block.Event getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Event parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Event(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public inr.numass.data.NumassProto.Point.Channel.Block.Event getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface PeaksOrBuilder extends + // @@protoc_insertion_point(interface_extends:inr.numass.data.Point.Channel.Block.Peaks) + com.google.protobuf.MessageOrBuilder { + + /** + *
+           *время в наносекундах от начала блока
+           * 
+ * + * repeated uint64 times = 1; + */ + java.util.List getTimesList(); + /** + *
+           *время в наносекундах от начала блока
+           * 
+ * + * repeated uint64 times = 1; + */ + int getTimesCount(); + /** + *
+           *время в наносекундах от начала блока
+           * 
+ * + * repeated uint64 times = 1; + */ + long getTimes(int index); + + /** + *
+           *амплитуда события в каналах
+           * 
+ * + * repeated uint64 amplitudes = 2; + */ + java.util.List getAmplitudesList(); + /** + *
+           *амплитуда события в каналах
+           * 
+ * + * repeated uint64 amplitudes = 2; + */ + int getAmplitudesCount(); + /** + *
+           *амплитуда события в каналах
+           * 
+ * + * repeated uint64 amplitudes = 2; + */ + long getAmplitudes(int index); + } + /** + *
+         * Обработанные события. Содержат только время и амплитуду сигналов.
+         * Для экономии места при сериализации амплитуды и времена лежат в
+         * разных массивах. Амплитуда и время имеющие одинаковые индексы
+         * соответствуют одному событию
+         * 
+ * + * Protobuf type {@code inr.numass.data.Point.Channel.Block.Peaks} + */ + public static final class Peaks extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:inr.numass.data.Point.Channel.Block.Peaks) + PeaksOrBuilder { + // Use Peaks.newBuilder() to construct. + private Peaks(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Peaks() { + times_ = java.util.Collections.emptyList(); + amplitudes_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Peaks( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 8: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + times_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + times_.add(input.readUInt64()); + break; + } + case 10: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001) && input.getBytesUntilLimit() > 0) { + times_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + while (input.getBytesUntilLimit() > 0) { + times_.add(input.readUInt64()); + } + input.popLimit(limit); + break; + } + case 16: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + amplitudes_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + amplitudes_.add(input.readUInt64()); + break; + } + case 18: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002) && input.getBytesUntilLimit() > 0) { + amplitudes_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + while (input.getBytesUntilLimit() > 0) { + amplitudes_.add(input.readUInt64()); + } + input.popLimit(limit); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + times_ = java.util.Collections.unmodifiableList(times_); + } + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + amplitudes_ = java.util.Collections.unmodifiableList(amplitudes_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_Block_Peaks_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_Block_Peaks_fieldAccessorTable + .ensureFieldAccessorsInitialized( + inr.numass.data.NumassProto.Point.Channel.Block.Peaks.class, inr.numass.data.NumassProto.Point.Channel.Block.Peaks.Builder.class); + } + + public static final int TIMES_FIELD_NUMBER = 1; + private java.util.List times_; + /** + *
+           *время в наносекундах от начала блока
+           * 
+ * + * repeated uint64 times = 1; + */ + public java.util.List + getTimesList() { + return times_; + } + /** + *
+           *время в наносекундах от начала блока
+           * 
+ * + * repeated uint64 times = 1; + */ + public int getTimesCount() { + return times_.size(); + } + /** + *
+           *время в наносекундах от начала блока
+           * 
+ * + * repeated uint64 times = 1; + */ + public long getTimes(int index) { + return times_.get(index); + } + private int timesMemoizedSerializedSize = -1; + + public static final int AMPLITUDES_FIELD_NUMBER = 2; + private java.util.List amplitudes_; + /** + *
+           *амплитуда события в каналах
+           * 
+ * + * repeated uint64 amplitudes = 2; + */ + public java.util.List + getAmplitudesList() { + return amplitudes_; + } + /** + *
+           *амплитуда события в каналах
+           * 
+ * + * repeated uint64 amplitudes = 2; + */ + public int getAmplitudesCount() { + return amplitudes_.size(); + } + /** + *
+           *амплитуда события в каналах
+           * 
+ * + * repeated uint64 amplitudes = 2; + */ + public long getAmplitudes(int index) { + return amplitudes_.get(index); + } + private int amplitudesMemoizedSerializedSize = -1; + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (getTimesList().size() > 0) { + output.writeUInt32NoTag(10); + output.writeUInt32NoTag(timesMemoizedSerializedSize); + } + for (int i = 0; i < times_.size(); i++) { + output.writeUInt64NoTag(times_.get(i)); + } + if (getAmplitudesList().size() > 0) { + output.writeUInt32NoTag(18); + output.writeUInt32NoTag(amplitudesMemoizedSerializedSize); + } + for (int i = 0; i < amplitudes_.size(); i++) { + output.writeUInt64NoTag(amplitudes_.get(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + for (int i = 0; i < times_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeUInt64SizeNoTag(times_.get(i)); + } + size += dataSize; + if (!getTimesList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(dataSize); + } + timesMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + for (int i = 0; i < amplitudes_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeUInt64SizeNoTag(amplitudes_.get(i)); + } + size += dataSize; + if (!getAmplitudesList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(dataSize); + } + amplitudesMemoizedSerializedSize = dataSize; + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof inr.numass.data.NumassProto.Point.Channel.Block.Peaks)) { + return super.equals(obj); + } + inr.numass.data.NumassProto.Point.Channel.Block.Peaks other = (inr.numass.data.NumassProto.Point.Channel.Block.Peaks) obj; + + boolean result = true; + result = result && getTimesList() + .equals(other.getTimesList()); + result = result && getAmplitudesList() + .equals(other.getAmplitudesList()); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getTimesCount() > 0) { + hash = (37 * hash) + TIMES_FIELD_NUMBER; + hash = (53 * hash) + getTimesList().hashCode(); + } + if (getAmplitudesCount() > 0) { + hash = (37 * hash) + AMPLITUDES_FIELD_NUMBER; + hash = (53 * hash) + getAmplitudesList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static inr.numass.data.NumassProto.Point.Channel.Block.Peaks parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static inr.numass.data.NumassProto.Point.Channel.Block.Peaks parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point.Channel.Block.Peaks parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static inr.numass.data.NumassProto.Point.Channel.Block.Peaks parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point.Channel.Block.Peaks parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static inr.numass.data.NumassProto.Point.Channel.Block.Peaks parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point.Channel.Block.Peaks parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static inr.numass.data.NumassProto.Point.Channel.Block.Peaks parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point.Channel.Block.Peaks parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static inr.numass.data.NumassProto.Point.Channel.Block.Peaks parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(inr.numass.data.NumassProto.Point.Channel.Block.Peaks prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+           * Обработанные события. Содержат только время и амплитуду сигналов.
+           * Для экономии места при сериализации амплитуды и времена лежат в
+           * разных массивах. Амплитуда и время имеющие одинаковые индексы
+           * соответствуют одному событию
+           * 
+ * + * Protobuf type {@code inr.numass.data.Point.Channel.Block.Peaks} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:inr.numass.data.Point.Channel.Block.Peaks) + inr.numass.data.NumassProto.Point.Channel.Block.PeaksOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_Block_Peaks_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_Block_Peaks_fieldAccessorTable + .ensureFieldAccessorsInitialized( + inr.numass.data.NumassProto.Point.Channel.Block.Peaks.class, inr.numass.data.NumassProto.Point.Channel.Block.Peaks.Builder.class); + } + + // Construct using inr.numass.data.NumassProto.Point.Channel.Block.Peaks.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + times_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + amplitudes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_Block_Peaks_descriptor; + } + + public inr.numass.data.NumassProto.Point.Channel.Block.Peaks getDefaultInstanceForType() { + return inr.numass.data.NumassProto.Point.Channel.Block.Peaks.getDefaultInstance(); + } + + public inr.numass.data.NumassProto.Point.Channel.Block.Peaks build() { + inr.numass.data.NumassProto.Point.Channel.Block.Peaks result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public inr.numass.data.NumassProto.Point.Channel.Block.Peaks buildPartial() { + inr.numass.data.NumassProto.Point.Channel.Block.Peaks result = new inr.numass.data.NumassProto.Point.Channel.Block.Peaks(this); + int from_bitField0_ = bitField0_; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + times_ = java.util.Collections.unmodifiableList(times_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.times_ = times_; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + amplitudes_ = java.util.Collections.unmodifiableList(amplitudes_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.amplitudes_ = amplitudes_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof inr.numass.data.NumassProto.Point.Channel.Block.Peaks) { + return mergeFrom((inr.numass.data.NumassProto.Point.Channel.Block.Peaks)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(inr.numass.data.NumassProto.Point.Channel.Block.Peaks other) { + if (other == inr.numass.data.NumassProto.Point.Channel.Block.Peaks.getDefaultInstance()) return this; + if (!other.times_.isEmpty()) { + if (times_.isEmpty()) { + times_ = other.times_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureTimesIsMutable(); + times_.addAll(other.times_); + } + onChanged(); + } + if (!other.amplitudes_.isEmpty()) { + if (amplitudes_.isEmpty()) { + amplitudes_ = other.amplitudes_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureAmplitudesIsMutable(); + amplitudes_.addAll(other.amplitudes_); + } + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + inr.numass.data.NumassProto.Point.Channel.Block.Peaks parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (inr.numass.data.NumassProto.Point.Channel.Block.Peaks) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List times_ = java.util.Collections.emptyList(); + private void ensureTimesIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + times_ = new java.util.ArrayList(times_); + bitField0_ |= 0x00000001; + } + } + /** + *
+             *время в наносекундах от начала блока
+             * 
+ * + * repeated uint64 times = 1; + */ + public java.util.List + getTimesList() { + return java.util.Collections.unmodifiableList(times_); + } + /** + *
+             *время в наносекундах от начала блока
+             * 
+ * + * repeated uint64 times = 1; + */ + public int getTimesCount() { + return times_.size(); + } + /** + *
+             *время в наносекундах от начала блока
+             * 
+ * + * repeated uint64 times = 1; + */ + public long getTimes(int index) { + return times_.get(index); + } + /** + *
+             *время в наносекундах от начала блока
+             * 
+ * + * repeated uint64 times = 1; + */ + public Builder setTimes( + int index, long value) { + ensureTimesIsMutable(); + times_.set(index, value); + onChanged(); + return this; + } + /** + *
+             *время в наносекундах от начала блока
+             * 
+ * + * repeated uint64 times = 1; + */ + public Builder addTimes(long value) { + ensureTimesIsMutable(); + times_.add(value); + onChanged(); + return this; + } + /** + *
+             *время в наносекундах от начала блока
+             * 
+ * + * repeated uint64 times = 1; + */ + public Builder addAllTimes( + java.lang.Iterable values) { + ensureTimesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, times_); + onChanged(); + return this; + } + /** + *
+             *время в наносекундах от начала блока
+             * 
+ * + * repeated uint64 times = 1; + */ + public Builder clearTimes() { + times_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + private java.util.List amplitudes_ = java.util.Collections.emptyList(); + private void ensureAmplitudesIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + amplitudes_ = new java.util.ArrayList(amplitudes_); + bitField0_ |= 0x00000002; + } + } + /** + *
+             *амплитуда события в каналах
+             * 
+ * + * repeated uint64 amplitudes = 2; + */ + public java.util.List + getAmplitudesList() { + return java.util.Collections.unmodifiableList(amplitudes_); + } + /** + *
+             *амплитуда события в каналах
+             * 
+ * + * repeated uint64 amplitudes = 2; + */ + public int getAmplitudesCount() { + return amplitudes_.size(); + } + /** + *
+             *амплитуда события в каналах
+             * 
+ * + * repeated uint64 amplitudes = 2; + */ + public long getAmplitudes(int index) { + return amplitudes_.get(index); + } + /** + *
+             *амплитуда события в каналах
+             * 
+ * + * repeated uint64 amplitudes = 2; + */ + public Builder setAmplitudes( + int index, long value) { + ensureAmplitudesIsMutable(); + amplitudes_.set(index, value); + onChanged(); + return this; + } + /** + *
+             *амплитуда события в каналах
+             * 
+ * + * repeated uint64 amplitudes = 2; + */ + public Builder addAmplitudes(long value) { + ensureAmplitudesIsMutable(); + amplitudes_.add(value); + onChanged(); + return this; + } + /** + *
+             *амплитуда события в каналах
+             * 
+ * + * repeated uint64 amplitudes = 2; + */ + public Builder addAllAmplitudes( + java.lang.Iterable values) { + ensureAmplitudesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, amplitudes_); + onChanged(); + return this; + } + /** + *
+             *амплитуда события в каналах
+             * 
+ * + * repeated uint64 amplitudes = 2; + */ + public Builder clearAmplitudes() { + amplitudes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:inr.numass.data.Point.Channel.Block.Peaks) + } + + // @@protoc_insertion_point(class_scope:inr.numass.data.Point.Channel.Block.Peaks) + private static final inr.numass.data.NumassProto.Point.Channel.Block.Peaks DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new inr.numass.data.NumassProto.Point.Channel.Block.Peaks(); + } + + public static inr.numass.data.NumassProto.Point.Channel.Block.Peaks getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Peaks parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Peaks(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public inr.numass.data.NumassProto.Point.Channel.Block.Peaks getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int TIME_FIELD_NUMBER = 1; + private long time_; + /** + *
+         * время начала блока в наносекундах с начала эпохи
+         * 
+ * + * uint64 time = 1; + */ + public long getTime() { + return time_; + } + + public static final int EVENTS_FIELD_NUMBER = 2; + private java.util.List events_; + /** + *
+         * массив необработанных событий
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public java.util.List getEventsList() { + return events_; + } + /** + *
+         * массив необработанных событий
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public java.util.List + getEventsOrBuilderList() { + return events_; + } + /** + *
+         * массив необработанных событий
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public int getEventsCount() { + return events_.size(); + } + /** + *
+         * массив необработанных событий
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public inr.numass.data.NumassProto.Point.Channel.Block.Event getEvents(int index) { + return events_.get(index); + } + /** + *
+         * массив необработанных событий
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public inr.numass.data.NumassProto.Point.Channel.Block.EventOrBuilder getEventsOrBuilder( + int index) { + return events_.get(index); + } + + public static final int PEAKS_FIELD_NUMBER = 3; + private inr.numass.data.NumassProto.Point.Channel.Block.Peaks peaks_; + /** + *
+         * массив обработанных событий
+         * 
+ * + * .inr.numass.data.Point.Channel.Block.Peaks peaks = 3; + */ + public boolean hasPeaks() { + return peaks_ != null; + } + /** + *
+         * массив обработанных событий
+         * 
+ * + * .inr.numass.data.Point.Channel.Block.Peaks peaks = 3; + */ + public inr.numass.data.NumassProto.Point.Channel.Block.Peaks getPeaks() { + return peaks_ == null ? inr.numass.data.NumassProto.Point.Channel.Block.Peaks.getDefaultInstance() : peaks_; + } + /** + *
+         * массив обработанных событий
+         * 
+ * + * .inr.numass.data.Point.Channel.Block.Peaks peaks = 3; + */ + public inr.numass.data.NumassProto.Point.Channel.Block.PeaksOrBuilder getPeaksOrBuilder() { + return getPeaks(); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (time_ != 0L) { + output.writeUInt64(1, time_); + } + for (int i = 0; i < events_.size(); i++) { + output.writeMessage(2, events_.get(i)); + } + if (peaks_ != null) { + output.writeMessage(3, getPeaks()); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (time_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeUInt64Size(1, time_); + } + for (int i = 0; i < events_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, events_.get(i)); + } + if (peaks_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, getPeaks()); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof inr.numass.data.NumassProto.Point.Channel.Block)) { + return super.equals(obj); + } + inr.numass.data.NumassProto.Point.Channel.Block other = (inr.numass.data.NumassProto.Point.Channel.Block) obj; + + boolean result = true; + result = result && (getTime() + == other.getTime()); + result = result && getEventsList() + .equals(other.getEventsList()); + result = result && (hasPeaks() == other.hasPeaks()); + if (hasPeaks()) { + result = result && getPeaks() + .equals(other.getPeaks()); + } + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTime()); + if (getEventsCount() > 0) { + hash = (37 * hash) + EVENTS_FIELD_NUMBER; + hash = (53 * hash) + getEventsList().hashCode(); + } + if (hasPeaks()) { + hash = (37 * hash) + PEAKS_FIELD_NUMBER; + hash = (53 * hash) + getPeaks().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static inr.numass.data.NumassProto.Point.Channel.Block parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static inr.numass.data.NumassProto.Point.Channel.Block parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point.Channel.Block parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static inr.numass.data.NumassProto.Point.Channel.Block parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point.Channel.Block parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static inr.numass.data.NumassProto.Point.Channel.Block parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point.Channel.Block parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static inr.numass.data.NumassProto.Point.Channel.Block parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point.Channel.Block parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static inr.numass.data.NumassProto.Point.Channel.Block parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(inr.numass.data.NumassProto.Point.Channel.Block prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code inr.numass.data.Point.Channel.Block} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:inr.numass.data.Point.Channel.Block) + inr.numass.data.NumassProto.Point.Channel.BlockOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_Block_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_Block_fieldAccessorTable + .ensureFieldAccessorsInitialized( + inr.numass.data.NumassProto.Point.Channel.Block.class, inr.numass.data.NumassProto.Point.Channel.Block.Builder.class); + } + + // Construct using inr.numass.data.NumassProto.Point.Channel.Block.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getEventsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + time_ = 0L; + + if (eventsBuilder_ == null) { + events_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + } else { + eventsBuilder_.clear(); + } + if (peaksBuilder_ == null) { + peaks_ = null; + } else { + peaks_ = null; + peaksBuilder_ = null; + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_Block_descriptor; + } + + public inr.numass.data.NumassProto.Point.Channel.Block getDefaultInstanceForType() { + return inr.numass.data.NumassProto.Point.Channel.Block.getDefaultInstance(); + } + + public inr.numass.data.NumassProto.Point.Channel.Block build() { + inr.numass.data.NumassProto.Point.Channel.Block result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public inr.numass.data.NumassProto.Point.Channel.Block buildPartial() { + inr.numass.data.NumassProto.Point.Channel.Block result = new inr.numass.data.NumassProto.Point.Channel.Block(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.time_ = time_; + if (eventsBuilder_ == null) { + if (((bitField0_ & 0x00000002) == 0x00000002)) { + events_ = java.util.Collections.unmodifiableList(events_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.events_ = events_; + } else { + result.events_ = eventsBuilder_.build(); + } + if (peaksBuilder_ == null) { + result.peaks_ = peaks_; + } else { + result.peaks_ = peaksBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof inr.numass.data.NumassProto.Point.Channel.Block) { + return mergeFrom((inr.numass.data.NumassProto.Point.Channel.Block)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(inr.numass.data.NumassProto.Point.Channel.Block other) { + if (other == inr.numass.data.NumassProto.Point.Channel.Block.getDefaultInstance()) return this; + if (other.getTime() != 0L) { + setTime(other.getTime()); + } + if (eventsBuilder_ == null) { + if (!other.events_.isEmpty()) { + if (events_.isEmpty()) { + events_ = other.events_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureEventsIsMutable(); + events_.addAll(other.events_); + } + onChanged(); + } + } else { + if (!other.events_.isEmpty()) { + if (eventsBuilder_.isEmpty()) { + eventsBuilder_.dispose(); + eventsBuilder_ = null; + events_ = other.events_; + bitField0_ = (bitField0_ & ~0x00000002); + eventsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getEventsFieldBuilder() : null; + } else { + eventsBuilder_.addAllMessages(other.events_); + } + } + } + if (other.hasPeaks()) { + mergePeaks(other.getPeaks()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + inr.numass.data.NumassProto.Point.Channel.Block parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (inr.numass.data.NumassProto.Point.Channel.Block) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private long time_ ; + /** + *
+           * время начала блока в наносекундах с начала эпохи
+           * 
+ * + * uint64 time = 1; + */ + public long getTime() { + return time_; + } + /** + *
+           * время начала блока в наносекундах с начала эпохи
+           * 
+ * + * uint64 time = 1; + */ + public Builder setTime(long value) { + + time_ = value; + onChanged(); + return this; + } + /** + *
+           * время начала блока в наносекундах с начала эпохи
+           * 
+ * + * uint64 time = 1; + */ + public Builder clearTime() { + + time_ = 0L; + onChanged(); + return this; + } + + private java.util.List events_ = + java.util.Collections.emptyList(); + private void ensureEventsIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + events_ = new java.util.ArrayList(events_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + inr.numass.data.NumassProto.Point.Channel.Block.Event, inr.numass.data.NumassProto.Point.Channel.Block.Event.Builder, inr.numass.data.NumassProto.Point.Channel.Block.EventOrBuilder> eventsBuilder_; + + /** + *
+           * массив необработанных событий
+           * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public java.util.List getEventsList() { + if (eventsBuilder_ == null) { + return java.util.Collections.unmodifiableList(events_); + } else { + return eventsBuilder_.getMessageList(); + } + } + /** + *
+           * массив необработанных событий
+           * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public int getEventsCount() { + if (eventsBuilder_ == null) { + return events_.size(); + } else { + return eventsBuilder_.getCount(); + } + } + /** + *
+           * массив необработанных событий
+           * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public inr.numass.data.NumassProto.Point.Channel.Block.Event getEvents(int index) { + if (eventsBuilder_ == null) { + return events_.get(index); + } else { + return eventsBuilder_.getMessage(index); + } + } + /** + *
+           * массив необработанных событий
+           * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public Builder setEvents( + int index, inr.numass.data.NumassProto.Point.Channel.Block.Event value) { + if (eventsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEventsIsMutable(); + events_.set(index, value); + onChanged(); + } else { + eventsBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+           * массив необработанных событий
+           * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public Builder setEvents( + int index, inr.numass.data.NumassProto.Point.Channel.Block.Event.Builder builderForValue) { + if (eventsBuilder_ == null) { + ensureEventsIsMutable(); + events_.set(index, builderForValue.build()); + onChanged(); + } else { + eventsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+           * массив необработанных событий
+           * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public Builder addEvents(inr.numass.data.NumassProto.Point.Channel.Block.Event value) { + if (eventsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEventsIsMutable(); + events_.add(value); + onChanged(); + } else { + eventsBuilder_.addMessage(value); + } + return this; + } + /** + *
+           * массив необработанных событий
+           * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public Builder addEvents( + int index, inr.numass.data.NumassProto.Point.Channel.Block.Event value) { + if (eventsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEventsIsMutable(); + events_.add(index, value); + onChanged(); + } else { + eventsBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+           * массив необработанных событий
+           * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public Builder addEvents( + inr.numass.data.NumassProto.Point.Channel.Block.Event.Builder builderForValue) { + if (eventsBuilder_ == null) { + ensureEventsIsMutable(); + events_.add(builderForValue.build()); + onChanged(); + } else { + eventsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+           * массив необработанных событий
+           * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public Builder addEvents( + int index, inr.numass.data.NumassProto.Point.Channel.Block.Event.Builder builderForValue) { + if (eventsBuilder_ == null) { + ensureEventsIsMutable(); + events_.add(index, builderForValue.build()); + onChanged(); + } else { + eventsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+           * массив необработанных событий
+           * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public Builder addAllEvents( + java.lang.Iterable values) { + if (eventsBuilder_ == null) { + ensureEventsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, events_); + onChanged(); + } else { + eventsBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+           * массив необработанных событий
+           * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public Builder clearEvents() { + if (eventsBuilder_ == null) { + events_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + eventsBuilder_.clear(); + } + return this; + } + /** + *
+           * массив необработанных событий
+           * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public Builder removeEvents(int index) { + if (eventsBuilder_ == null) { + ensureEventsIsMutable(); + events_.remove(index); + onChanged(); + } else { + eventsBuilder_.remove(index); + } + return this; + } + /** + *
+           * массив необработанных событий
+           * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public inr.numass.data.NumassProto.Point.Channel.Block.Event.Builder getEventsBuilder( + int index) { + return getEventsFieldBuilder().getBuilder(index); + } + /** + *
+           * массив необработанных событий
+           * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public inr.numass.data.NumassProto.Point.Channel.Block.EventOrBuilder getEventsOrBuilder( + int index) { + if (eventsBuilder_ == null) { + return events_.get(index); } else { + return eventsBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+           * массив необработанных событий
+           * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public java.util.List + getEventsOrBuilderList() { + if (eventsBuilder_ != null) { + return eventsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(events_); + } + } + /** + *
+           * массив необработанных событий
+           * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public inr.numass.data.NumassProto.Point.Channel.Block.Event.Builder addEventsBuilder() { + return getEventsFieldBuilder().addBuilder( + inr.numass.data.NumassProto.Point.Channel.Block.Event.getDefaultInstance()); + } + /** + *
+           * массив необработанных событий
+           * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public inr.numass.data.NumassProto.Point.Channel.Block.Event.Builder addEventsBuilder( + int index) { + return getEventsFieldBuilder().addBuilder( + index, inr.numass.data.NumassProto.Point.Channel.Block.Event.getDefaultInstance()); + } + /** + *
+           * массив необработанных событий
+           * 
+ * + * repeated .inr.numass.data.Point.Channel.Block.Event events = 2; + */ + public java.util.List + getEventsBuilderList() { + return getEventsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + inr.numass.data.NumassProto.Point.Channel.Block.Event, inr.numass.data.NumassProto.Point.Channel.Block.Event.Builder, inr.numass.data.NumassProto.Point.Channel.Block.EventOrBuilder> + getEventsFieldBuilder() { + if (eventsBuilder_ == null) { + eventsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + inr.numass.data.NumassProto.Point.Channel.Block.Event, inr.numass.data.NumassProto.Point.Channel.Block.Event.Builder, inr.numass.data.NumassProto.Point.Channel.Block.EventOrBuilder>( + events_, + ((bitField0_ & 0x00000002) == 0x00000002), + getParentForChildren(), + isClean()); + events_ = null; + } + return eventsBuilder_; + } + + private inr.numass.data.NumassProto.Point.Channel.Block.Peaks peaks_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + inr.numass.data.NumassProto.Point.Channel.Block.Peaks, inr.numass.data.NumassProto.Point.Channel.Block.Peaks.Builder, inr.numass.data.NumassProto.Point.Channel.Block.PeaksOrBuilder> peaksBuilder_; + /** + *
+           * массив обработанных событий
+           * 
+ * + * .inr.numass.data.Point.Channel.Block.Peaks peaks = 3; + */ + public boolean hasPeaks() { + return peaksBuilder_ != null || peaks_ != null; + } + /** + *
+           * массив обработанных событий
+           * 
+ * + * .inr.numass.data.Point.Channel.Block.Peaks peaks = 3; + */ + public inr.numass.data.NumassProto.Point.Channel.Block.Peaks getPeaks() { + if (peaksBuilder_ == null) { + return peaks_ == null ? inr.numass.data.NumassProto.Point.Channel.Block.Peaks.getDefaultInstance() : peaks_; + } else { + return peaksBuilder_.getMessage(); + } + } + /** + *
+           * массив обработанных событий
+           * 
+ * + * .inr.numass.data.Point.Channel.Block.Peaks peaks = 3; + */ + public Builder setPeaks(inr.numass.data.NumassProto.Point.Channel.Block.Peaks value) { + if (peaksBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + peaks_ = value; + onChanged(); + } else { + peaksBuilder_.setMessage(value); + } + + return this; + } + /** + *
+           * массив обработанных событий
+           * 
+ * + * .inr.numass.data.Point.Channel.Block.Peaks peaks = 3; + */ + public Builder setPeaks( + inr.numass.data.NumassProto.Point.Channel.Block.Peaks.Builder builderForValue) { + if (peaksBuilder_ == null) { + peaks_ = builderForValue.build(); + onChanged(); + } else { + peaksBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + *
+           * массив обработанных событий
+           * 
+ * + * .inr.numass.data.Point.Channel.Block.Peaks peaks = 3; + */ + public Builder mergePeaks(inr.numass.data.NumassProto.Point.Channel.Block.Peaks value) { + if (peaksBuilder_ == null) { + if (peaks_ != null) { + peaks_ = + inr.numass.data.NumassProto.Point.Channel.Block.Peaks.newBuilder(peaks_).mergeFrom(value).buildPartial(); + } else { + peaks_ = value; + } + onChanged(); + } else { + peaksBuilder_.mergeFrom(value); + } + + return this; + } + /** + *
+           * массив обработанных событий
+           * 
+ * + * .inr.numass.data.Point.Channel.Block.Peaks peaks = 3; + */ + public Builder clearPeaks() { + if (peaksBuilder_ == null) { + peaks_ = null; + onChanged(); + } else { + peaks_ = null; + peaksBuilder_ = null; + } + + return this; + } + /** + *
+           * массив обработанных событий
+           * 
+ * + * .inr.numass.data.Point.Channel.Block.Peaks peaks = 3; + */ + public inr.numass.data.NumassProto.Point.Channel.Block.Peaks.Builder getPeaksBuilder() { + + onChanged(); + return getPeaksFieldBuilder().getBuilder(); + } + /** + *
+           * массив обработанных событий
+           * 
+ * + * .inr.numass.data.Point.Channel.Block.Peaks peaks = 3; + */ + public inr.numass.data.NumassProto.Point.Channel.Block.PeaksOrBuilder getPeaksOrBuilder() { + if (peaksBuilder_ != null) { + return peaksBuilder_.getMessageOrBuilder(); + } else { + return peaks_ == null ? + inr.numass.data.NumassProto.Point.Channel.Block.Peaks.getDefaultInstance() : peaks_; + } + } + /** + *
+           * массив обработанных событий
+           * 
+ * + * .inr.numass.data.Point.Channel.Block.Peaks peaks = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + inr.numass.data.NumassProto.Point.Channel.Block.Peaks, inr.numass.data.NumassProto.Point.Channel.Block.Peaks.Builder, inr.numass.data.NumassProto.Point.Channel.Block.PeaksOrBuilder> + getPeaksFieldBuilder() { + if (peaksBuilder_ == null) { + peaksBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + inr.numass.data.NumassProto.Point.Channel.Block.Peaks, inr.numass.data.NumassProto.Point.Channel.Block.Peaks.Builder, inr.numass.data.NumassProto.Point.Channel.Block.PeaksOrBuilder>( + getPeaks(), + getParentForChildren(), + isClean()); + peaks_ = null; + } + return peaksBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:inr.numass.data.Point.Channel.Block) + } + + // @@protoc_insertion_point(class_scope:inr.numass.data.Point.Channel.Block) + private static final inr.numass.data.NumassProto.Point.Channel.Block DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new inr.numass.data.NumassProto.Point.Channel.Block(); + } + + public static inr.numass.data.NumassProto.Point.Channel.Block getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Block parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Block(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public inr.numass.data.NumassProto.Point.Channel.Block getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int NUM_FIELD_NUMBER = 1; + private long num_; + /** + *
+       * номер канала
+       * 
+ * + * uint64 num = 1; + */ + public long getNum() { + return num_; + } + + public static final int BLOCKS_FIELD_NUMBER = 2; + private java.util.List blocks_; + /** + *
+       * набранные блоки
+       * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public java.util.List getBlocksList() { + return blocks_; + } + /** + *
+       * набранные блоки
+       * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public java.util.List + getBlocksOrBuilderList() { + return blocks_; + } + /** + *
+       * набранные блоки
+       * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public int getBlocksCount() { + return blocks_.size(); + } + /** + *
+       * набранные блоки
+       * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public inr.numass.data.NumassProto.Point.Channel.Block getBlocks(int index) { + return blocks_.get(index); + } + /** + *
+       * набранные блоки
+       * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public inr.numass.data.NumassProto.Point.Channel.BlockOrBuilder getBlocksOrBuilder( + int index) { + return blocks_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (num_ != 0L) { + output.writeUInt64(1, num_); + } + for (int i = 0; i < blocks_.size(); i++) { + output.writeMessage(2, blocks_.get(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (num_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeUInt64Size(1, num_); + } + for (int i = 0; i < blocks_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, blocks_.get(i)); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof inr.numass.data.NumassProto.Point.Channel)) { + return super.equals(obj); + } + inr.numass.data.NumassProto.Point.Channel other = (inr.numass.data.NumassProto.Point.Channel) obj; + + boolean result = true; + result = result && (getNum() + == other.getNum()); + result = result && getBlocksList() + .equals(other.getBlocksList()); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NUM_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getNum()); + if (getBlocksCount() > 0) { + hash = (37 * hash) + BLOCKS_FIELD_NUMBER; + hash = (53 * hash) + getBlocksList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static inr.numass.data.NumassProto.Point.Channel parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static inr.numass.data.NumassProto.Point.Channel parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point.Channel parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static inr.numass.data.NumassProto.Point.Channel parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point.Channel parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static inr.numass.data.NumassProto.Point.Channel parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point.Channel parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static inr.numass.data.NumassProto.Point.Channel parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point.Channel parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static inr.numass.data.NumassProto.Point.Channel parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(inr.numass.data.NumassProto.Point.Channel prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code inr.numass.data.Point.Channel} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:inr.numass.data.Point.Channel) + inr.numass.data.NumassProto.Point.ChannelOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_fieldAccessorTable + .ensureFieldAccessorsInitialized( + inr.numass.data.NumassProto.Point.Channel.class, inr.numass.data.NumassProto.Point.Channel.Builder.class); + } + + // Construct using inr.numass.data.NumassProto.Point.Channel.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getBlocksFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + num_ = 0L; + + if (blocksBuilder_ == null) { + blocks_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + } else { + blocksBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_Channel_descriptor; + } + + public inr.numass.data.NumassProto.Point.Channel getDefaultInstanceForType() { + return inr.numass.data.NumassProto.Point.Channel.getDefaultInstance(); + } + + public inr.numass.data.NumassProto.Point.Channel build() { + inr.numass.data.NumassProto.Point.Channel result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public inr.numass.data.NumassProto.Point.Channel buildPartial() { + inr.numass.data.NumassProto.Point.Channel result = new inr.numass.data.NumassProto.Point.Channel(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.num_ = num_; + if (blocksBuilder_ == null) { + if (((bitField0_ & 0x00000002) == 0x00000002)) { + blocks_ = java.util.Collections.unmodifiableList(blocks_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.blocks_ = blocks_; + } else { + result.blocks_ = blocksBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof inr.numass.data.NumassProto.Point.Channel) { + return mergeFrom((inr.numass.data.NumassProto.Point.Channel)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(inr.numass.data.NumassProto.Point.Channel other) { + if (other == inr.numass.data.NumassProto.Point.Channel.getDefaultInstance()) return this; + if (other.getNum() != 0L) { + setNum(other.getNum()); + } + if (blocksBuilder_ == null) { + if (!other.blocks_.isEmpty()) { + if (blocks_.isEmpty()) { + blocks_ = other.blocks_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureBlocksIsMutable(); + blocks_.addAll(other.blocks_); + } + onChanged(); + } + } else { + if (!other.blocks_.isEmpty()) { + if (blocksBuilder_.isEmpty()) { + blocksBuilder_.dispose(); + blocksBuilder_ = null; + blocks_ = other.blocks_; + bitField0_ = (bitField0_ & ~0x00000002); + blocksBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getBlocksFieldBuilder() : null; + } else { + blocksBuilder_.addAllMessages(other.blocks_); + } + } + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + inr.numass.data.NumassProto.Point.Channel parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (inr.numass.data.NumassProto.Point.Channel) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private long num_ ; + /** + *
+         * номер канала
+         * 
+ * + * uint64 num = 1; + */ + public long getNum() { + return num_; + } + /** + *
+         * номер канала
+         * 
+ * + * uint64 num = 1; + */ + public Builder setNum(long value) { + + num_ = value; + onChanged(); + return this; + } + /** + *
+         * номер канала
+         * 
+ * + * uint64 num = 1; + */ + public Builder clearNum() { + + num_ = 0L; + onChanged(); + return this; + } + + private java.util.List blocks_ = + java.util.Collections.emptyList(); + private void ensureBlocksIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + blocks_ = new java.util.ArrayList(blocks_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + inr.numass.data.NumassProto.Point.Channel.Block, inr.numass.data.NumassProto.Point.Channel.Block.Builder, inr.numass.data.NumassProto.Point.Channel.BlockOrBuilder> blocksBuilder_; + + /** + *
+         * набранные блоки
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public java.util.List getBlocksList() { + if (blocksBuilder_ == null) { + return java.util.Collections.unmodifiableList(blocks_); + } else { + return blocksBuilder_.getMessageList(); + } + } + /** + *
+         * набранные блоки
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public int getBlocksCount() { + if (blocksBuilder_ == null) { + return blocks_.size(); + } else { + return blocksBuilder_.getCount(); + } + } + /** + *
+         * набранные блоки
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public inr.numass.data.NumassProto.Point.Channel.Block getBlocks(int index) { + if (blocksBuilder_ == null) { + return blocks_.get(index); + } else { + return blocksBuilder_.getMessage(index); + } + } + /** + *
+         * набранные блоки
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public Builder setBlocks( + int index, inr.numass.data.NumassProto.Point.Channel.Block value) { + if (blocksBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBlocksIsMutable(); + blocks_.set(index, value); + onChanged(); + } else { + blocksBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+         * набранные блоки
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public Builder setBlocks( + int index, inr.numass.data.NumassProto.Point.Channel.Block.Builder builderForValue) { + if (blocksBuilder_ == null) { + ensureBlocksIsMutable(); + blocks_.set(index, builderForValue.build()); + onChanged(); + } else { + blocksBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+         * набранные блоки
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public Builder addBlocks(inr.numass.data.NumassProto.Point.Channel.Block value) { + if (blocksBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBlocksIsMutable(); + blocks_.add(value); + onChanged(); + } else { + blocksBuilder_.addMessage(value); + } + return this; + } + /** + *
+         * набранные блоки
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public Builder addBlocks( + int index, inr.numass.data.NumassProto.Point.Channel.Block value) { + if (blocksBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBlocksIsMutable(); + blocks_.add(index, value); + onChanged(); + } else { + blocksBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+         * набранные блоки
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public Builder addBlocks( + inr.numass.data.NumassProto.Point.Channel.Block.Builder builderForValue) { + if (blocksBuilder_ == null) { + ensureBlocksIsMutable(); + blocks_.add(builderForValue.build()); + onChanged(); + } else { + blocksBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+         * набранные блоки
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public Builder addBlocks( + int index, inr.numass.data.NumassProto.Point.Channel.Block.Builder builderForValue) { + if (blocksBuilder_ == null) { + ensureBlocksIsMutable(); + blocks_.add(index, builderForValue.build()); + onChanged(); + } else { + blocksBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+         * набранные блоки
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public Builder addAllBlocks( + java.lang.Iterable values) { + if (blocksBuilder_ == null) { + ensureBlocksIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, blocks_); + onChanged(); + } else { + blocksBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+         * набранные блоки
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public Builder clearBlocks() { + if (blocksBuilder_ == null) { + blocks_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + blocksBuilder_.clear(); + } + return this; + } + /** + *
+         * набранные блоки
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public Builder removeBlocks(int index) { + if (blocksBuilder_ == null) { + ensureBlocksIsMutable(); + blocks_.remove(index); + onChanged(); + } else { + blocksBuilder_.remove(index); + } + return this; + } + /** + *
+         * набранные блоки
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public inr.numass.data.NumassProto.Point.Channel.Block.Builder getBlocksBuilder( + int index) { + return getBlocksFieldBuilder().getBuilder(index); + } + /** + *
+         * набранные блоки
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public inr.numass.data.NumassProto.Point.Channel.BlockOrBuilder getBlocksOrBuilder( + int index) { + if (blocksBuilder_ == null) { + return blocks_.get(index); } else { + return blocksBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+         * набранные блоки
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public java.util.List + getBlocksOrBuilderList() { + if (blocksBuilder_ != null) { + return blocksBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(blocks_); + } + } + /** + *
+         * набранные блоки
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public inr.numass.data.NumassProto.Point.Channel.Block.Builder addBlocksBuilder() { + return getBlocksFieldBuilder().addBuilder( + inr.numass.data.NumassProto.Point.Channel.Block.getDefaultInstance()); + } + /** + *
+         * набранные блоки
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public inr.numass.data.NumassProto.Point.Channel.Block.Builder addBlocksBuilder( + int index) { + return getBlocksFieldBuilder().addBuilder( + index, inr.numass.data.NumassProto.Point.Channel.Block.getDefaultInstance()); + } + /** + *
+         * набранные блоки
+         * 
+ * + * repeated .inr.numass.data.Point.Channel.Block blocks = 2; + */ + public java.util.List + getBlocksBuilderList() { + return getBlocksFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + inr.numass.data.NumassProto.Point.Channel.Block, inr.numass.data.NumassProto.Point.Channel.Block.Builder, inr.numass.data.NumassProto.Point.Channel.BlockOrBuilder> + getBlocksFieldBuilder() { + if (blocksBuilder_ == null) { + blocksBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + inr.numass.data.NumassProto.Point.Channel.Block, inr.numass.data.NumassProto.Point.Channel.Block.Builder, inr.numass.data.NumassProto.Point.Channel.BlockOrBuilder>( + blocks_, + ((bitField0_ & 0x00000002) == 0x00000002), + getParentForChildren(), + isClean()); + blocks_ = null; + } + return blocksBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:inr.numass.data.Point.Channel) + } + + // @@protoc_insertion_point(class_scope:inr.numass.data.Point.Channel) + private static final inr.numass.data.NumassProto.Point.Channel DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new inr.numass.data.NumassProto.Point.Channel(); + } + + public static inr.numass.data.NumassProto.Point.Channel getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Channel parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Channel(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public inr.numass.data.NumassProto.Point.Channel getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public static final int CHANNELS_FIELD_NUMBER = 1; + private java.util.List channels_; + /** + *
+     * массив событий по каналам
+     * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public java.util.List getChannelsList() { + return channels_; + } + /** + *
+     * массив событий по каналам
+     * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public java.util.List + getChannelsOrBuilderList() { + return channels_; + } + /** + *
+     * массив событий по каналам
+     * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public int getChannelsCount() { + return channels_.size(); + } + /** + *
+     * массив событий по каналам
+     * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public inr.numass.data.NumassProto.Point.Channel getChannels(int index) { + return channels_.get(index); + } + /** + *
+     * массив событий по каналам
+     * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public inr.numass.data.NumassProto.Point.ChannelOrBuilder getChannelsOrBuilder( + int index) { + return channels_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < channels_.size(); i++) { + output.writeMessage(1, channels_.get(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < channels_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, channels_.get(i)); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof inr.numass.data.NumassProto.Point)) { + return super.equals(obj); + } + inr.numass.data.NumassProto.Point other = (inr.numass.data.NumassProto.Point) obj; + + boolean result = true; + result = result && getChannelsList() + .equals(other.getChannelsList()); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getChannelsCount() > 0) { + hash = (37 * hash) + CHANNELS_FIELD_NUMBER; + hash = (53 * hash) + getChannelsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static inr.numass.data.NumassProto.Point parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static inr.numass.data.NumassProto.Point parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static inr.numass.data.NumassProto.Point parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static inr.numass.data.NumassProto.Point parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static inr.numass.data.NumassProto.Point parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static inr.numass.data.NumassProto.Point parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static inr.numass.data.NumassProto.Point parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(inr.numass.data.NumassProto.Point prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code inr.numass.data.Point} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:inr.numass.data.Point) + inr.numass.data.NumassProto.PointOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_fieldAccessorTable + .ensureFieldAccessorsInitialized( + inr.numass.data.NumassProto.Point.class, inr.numass.data.NumassProto.Point.Builder.class); + } + + // Construct using inr.numass.data.NumassProto.Point.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getChannelsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (channelsBuilder_ == null) { + channels_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + channelsBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return inr.numass.data.NumassProto.internal_static_inr_numass_data_Point_descriptor; + } + + public inr.numass.data.NumassProto.Point getDefaultInstanceForType() { + return inr.numass.data.NumassProto.Point.getDefaultInstance(); + } + + public inr.numass.data.NumassProto.Point build() { + inr.numass.data.NumassProto.Point result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public inr.numass.data.NumassProto.Point buildPartial() { + inr.numass.data.NumassProto.Point result = new inr.numass.data.NumassProto.Point(this); + int from_bitField0_ = bitField0_; + if (channelsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + channels_ = java.util.Collections.unmodifiableList(channels_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.channels_ = channels_; + } else { + result.channels_ = channelsBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof inr.numass.data.NumassProto.Point) { + return mergeFrom((inr.numass.data.NumassProto.Point)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(inr.numass.data.NumassProto.Point other) { + if (other == inr.numass.data.NumassProto.Point.getDefaultInstance()) return this; + if (channelsBuilder_ == null) { + if (!other.channels_.isEmpty()) { + if (channels_.isEmpty()) { + channels_ = other.channels_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureChannelsIsMutable(); + channels_.addAll(other.channels_); + } + onChanged(); + } + } else { + if (!other.channels_.isEmpty()) { + if (channelsBuilder_.isEmpty()) { + channelsBuilder_.dispose(); + channelsBuilder_ = null; + channels_ = other.channels_; + bitField0_ = (bitField0_ & ~0x00000001); + channelsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getChannelsFieldBuilder() : null; + } else { + channelsBuilder_.addAllMessages(other.channels_); + } + } + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + inr.numass.data.NumassProto.Point parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (inr.numass.data.NumassProto.Point) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List channels_ = + java.util.Collections.emptyList(); + private void ensureChannelsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + channels_ = new java.util.ArrayList(channels_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + inr.numass.data.NumassProto.Point.Channel, inr.numass.data.NumassProto.Point.Channel.Builder, inr.numass.data.NumassProto.Point.ChannelOrBuilder> channelsBuilder_; + + /** + *
+       * массив событий по каналам
+       * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public java.util.List getChannelsList() { + if (channelsBuilder_ == null) { + return java.util.Collections.unmodifiableList(channels_); + } else { + return channelsBuilder_.getMessageList(); + } + } + /** + *
+       * массив событий по каналам
+       * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public int getChannelsCount() { + if (channelsBuilder_ == null) { + return channels_.size(); + } else { + return channelsBuilder_.getCount(); + } + } + /** + *
+       * массив событий по каналам
+       * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public inr.numass.data.NumassProto.Point.Channel getChannels(int index) { + if (channelsBuilder_ == null) { + return channels_.get(index); + } else { + return channelsBuilder_.getMessage(index); + } + } + /** + *
+       * массив событий по каналам
+       * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public Builder setChannels( + int index, inr.numass.data.NumassProto.Point.Channel value) { + if (channelsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureChannelsIsMutable(); + channels_.set(index, value); + onChanged(); + } else { + channelsBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * массив событий по каналам
+       * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public Builder setChannels( + int index, inr.numass.data.NumassProto.Point.Channel.Builder builderForValue) { + if (channelsBuilder_ == null) { + ensureChannelsIsMutable(); + channels_.set(index, builderForValue.build()); + onChanged(); + } else { + channelsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * массив событий по каналам
+       * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public Builder addChannels(inr.numass.data.NumassProto.Point.Channel value) { + if (channelsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureChannelsIsMutable(); + channels_.add(value); + onChanged(); + } else { + channelsBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * массив событий по каналам
+       * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public Builder addChannels( + int index, inr.numass.data.NumassProto.Point.Channel value) { + if (channelsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureChannelsIsMutable(); + channels_.add(index, value); + onChanged(); + } else { + channelsBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * массив событий по каналам
+       * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public Builder addChannels( + inr.numass.data.NumassProto.Point.Channel.Builder builderForValue) { + if (channelsBuilder_ == null) { + ensureChannelsIsMutable(); + channels_.add(builderForValue.build()); + onChanged(); + } else { + channelsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * массив событий по каналам
+       * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public Builder addChannels( + int index, inr.numass.data.NumassProto.Point.Channel.Builder builderForValue) { + if (channelsBuilder_ == null) { + ensureChannelsIsMutable(); + channels_.add(index, builderForValue.build()); + onChanged(); + } else { + channelsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * массив событий по каналам
+       * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public Builder addAllChannels( + java.lang.Iterable values) { + if (channelsBuilder_ == null) { + ensureChannelsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, channels_); + onChanged(); + } else { + channelsBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * массив событий по каналам
+       * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public Builder clearChannels() { + if (channelsBuilder_ == null) { + channels_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + channelsBuilder_.clear(); + } + return this; + } + /** + *
+       * массив событий по каналам
+       * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public Builder removeChannels(int index) { + if (channelsBuilder_ == null) { + ensureChannelsIsMutable(); + channels_.remove(index); + onChanged(); + } else { + channelsBuilder_.remove(index); + } + return this; + } + /** + *
+       * массив событий по каналам
+       * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public inr.numass.data.NumassProto.Point.Channel.Builder getChannelsBuilder( + int index) { + return getChannelsFieldBuilder().getBuilder(index); + } + /** + *
+       * массив событий по каналам
+       * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public inr.numass.data.NumassProto.Point.ChannelOrBuilder getChannelsOrBuilder( + int index) { + if (channelsBuilder_ == null) { + return channels_.get(index); } else { + return channelsBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * массив событий по каналам
+       * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public java.util.List + getChannelsOrBuilderList() { + if (channelsBuilder_ != null) { + return channelsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(channels_); + } + } + /** + *
+       * массив событий по каналам
+       * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public inr.numass.data.NumassProto.Point.Channel.Builder addChannelsBuilder() { + return getChannelsFieldBuilder().addBuilder( + inr.numass.data.NumassProto.Point.Channel.getDefaultInstance()); + } + /** + *
+       * массив событий по каналам
+       * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public inr.numass.data.NumassProto.Point.Channel.Builder addChannelsBuilder( + int index) { + return getChannelsFieldBuilder().addBuilder( + index, inr.numass.data.NumassProto.Point.Channel.getDefaultInstance()); + } + /** + *
+       * массив событий по каналам
+       * 
+ * + * repeated .inr.numass.data.Point.Channel channels = 1; + */ + public java.util.List + getChannelsBuilderList() { + return getChannelsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + inr.numass.data.NumassProto.Point.Channel, inr.numass.data.NumassProto.Point.Channel.Builder, inr.numass.data.NumassProto.Point.ChannelOrBuilder> + getChannelsFieldBuilder() { + if (channelsBuilder_ == null) { + channelsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + inr.numass.data.NumassProto.Point.Channel, inr.numass.data.NumassProto.Point.Channel.Builder, inr.numass.data.NumassProto.Point.ChannelOrBuilder>( + channels_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + channels_ = null; + } + return channelsBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:inr.numass.data.Point) + } + + // @@protoc_insertion_point(class_scope:inr.numass.data.Point) + private static final inr.numass.data.NumassProto.Point DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new inr.numass.data.NumassProto.Point(); + } + + public static inr.numass.data.NumassProto.Point getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Point parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Point(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public inr.numass.data.NumassProto.Point getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_inr_numass_data_Point_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_inr_numass_data_Point_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_inr_numass_data_Point_Channel_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_inr_numass_data_Point_Channel_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_inr_numass_data_Point_Channel_Block_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_inr_numass_data_Point_Channel_Block_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_inr_numass_data_Point_Channel_Block_Event_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_inr_numass_data_Point_Channel_Block_Event_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_inr_numass_data_Point_Channel_Block_Peaks_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_inr_numass_data_Point_Channel_Block_Peaks_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\034inr/numas/numass-proto.proto\022\017inr.numa" + + "ss.data\"\350\002\n\005Point\0220\n\010channels\030\001 \003(\0132\036.in" + + "r.numass.data.Point.Channel\032\254\002\n\007Channel\022" + + "\013\n\003num\030\001 \001(\004\0224\n\006blocks\030\002 \003(\0132$.inr.numas" + + "s.data.Point.Channel.Block\032\335\001\n\005Block\022\014\n\004" + + "time\030\001 \001(\004\022:\n\006events\030\002 \003(\0132*.inr.numass." + + "data.Point.Channel.Block.Event\0229\n\005peaks\030" + + "\003 \001(\0132*.inr.numass.data.Point.Channel.Bl" + + "ock.Peaks\032#\n\005Event\022\014\n\004time\030\001 \001(\004\022\014\n\004data" + + "\030\002 \001(\014\032*\n\005Peaks\022\r\n\005times\030\001 \003(\004\022\022\n\namplit", + "udes\030\002 \003(\004b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_inr_numass_data_Point_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_inr_numass_data_Point_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_inr_numass_data_Point_descriptor, + new java.lang.String[] { "Channels", }); + internal_static_inr_numass_data_Point_Channel_descriptor = + internal_static_inr_numass_data_Point_descriptor.getNestedTypes().get(0); + internal_static_inr_numass_data_Point_Channel_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_inr_numass_data_Point_Channel_descriptor, + new java.lang.String[] { "Num", "Blocks", }); + internal_static_inr_numass_data_Point_Channel_Block_descriptor = + internal_static_inr_numass_data_Point_Channel_descriptor.getNestedTypes().get(0); + internal_static_inr_numass_data_Point_Channel_Block_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_inr_numass_data_Point_Channel_Block_descriptor, + new java.lang.String[] { "Time", "Events", "Peaks", }); + internal_static_inr_numass_data_Point_Channel_Block_Event_descriptor = + internal_static_inr_numass_data_Point_Channel_Block_descriptor.getNestedTypes().get(0); + internal_static_inr_numass_data_Point_Channel_Block_Event_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_inr_numass_data_Point_Channel_Block_Event_descriptor, + new java.lang.String[] { "Time", "Data", }); + internal_static_inr_numass_data_Point_Channel_Block_Peaks_descriptor = + internal_static_inr_numass_data_Point_Channel_Block_descriptor.getNestedTypes().get(1); + internal_static_inr_numass_data_Point_Channel_Block_Peaks_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_inr_numass_data_Point_Channel_Block_Peaks_descriptor, + new java.lang.String[] { "Times", "Amplitudes", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/numass-main/src/main/java/inr/numass/NumassProperties.java b/numass-core/src/main/java/inr/numass/NumassProperties.java similarity index 100% rename from numass-main/src/main/java/inr/numass/NumassProperties.java rename to numass-core/src/main/java/inr/numass/NumassProperties.java diff --git a/numass-storage/src/main/java/inr/numass/storage/NMEvent.java b/numass-core/src/main/java/inr/numass/data/NMEvent.java similarity index 93% rename from numass-storage/src/main/java/inr/numass/storage/NMEvent.java rename to numass-core/src/main/java/inr/numass/data/NMEvent.java index e7b89851..c1224746 100644 --- a/numass-storage/src/main/java/inr/numass/storage/NMEvent.java +++ b/numass-core/src/main/java/inr/numass/data/NMEvent.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package inr.numass.storage; +package inr.numass.data; /** * diff --git a/numass-storage/src/main/java/inr/numass/storage/NMFile.java b/numass-core/src/main/java/inr/numass/data/NMFile.java similarity index 92% rename from numass-storage/src/main/java/inr/numass/storage/NMFile.java rename to numass-core/src/main/java/inr/numass/data/NMFile.java index 315437bb..50be0479 100644 --- a/numass-storage/src/main/java/inr/numass/storage/NMFile.java +++ b/numass-core/src/main/java/inr/numass/data/NMFile.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package inr.numass.storage; +package inr.numass.data; import hep.dataforge.description.ValueDef; import hep.dataforge.meta.Meta; @@ -42,7 +42,7 @@ public class NMFile extends NamedMetaHolder implements NumassData { super(file.getName(), file.meta()); points = new ArrayList<>(); for (RawNMPoint point : file.getData()) { - points.add(new NMPoint(point)); + points.add(PointBuilders.readRawPoint(point)); } } diff --git a/numass-storage/src/main/java/inr/numass/storage/NMPoint.java b/numass-core/src/main/java/inr/numass/data/NMPoint.java similarity index 69% rename from numass-storage/src/main/java/inr/numass/storage/NMPoint.java rename to numass-core/src/main/java/inr/numass/data/NMPoint.java index af6bcbce..0b82486c 100644 --- a/numass-storage/src/main/java/inr/numass/storage/NMPoint.java +++ b/numass-core/src/main/java/inr/numass/data/NMPoint.java @@ -13,14 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package inr.numass.storage; +package inr.numass.data; import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.MapPoint; import java.time.Instant; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.stream.IntStream; @@ -43,34 +42,6 @@ public class NMPoint implements NumassPoint { this.eventsCount = IntStream.of(spectrum).sum(); } - public NMPoint(RawNMPoint point) { - if (point == null) { - throw new IllegalArgumentException(); - } - - this.pointLength = point.getLength(); - this.u = point.getUset(); -// this.uread = point.getUread(); - this.startTime = point.getStartTime(); - this.eventsCount = point.getEventsCount(); - spectrum = calculateSpectrum(point); - } - - private int[] calculateSpectrum(RawNMPoint point) { - assert point.getEventsCount() > 0; - - int[] result = new int[RawNMPoint.MAX_CHANEL + 1]; - Arrays.fill(result, 0); - point.getEvents().stream().forEach((event) -> { - if (event.getChanel() >= RawNMPoint.MAX_CHANEL) { - result[RawNMPoint.MAX_CHANEL]++; - } else { - result[event.getChanel()]++; - } - }); - return result; - } - /** * @return the absouteTime */ @@ -105,7 +76,6 @@ public class NMPoint implements NumassPoint { List data = new ArrayList<>(); for (int i = 0; i < RawNMPoint.MAX_CHANEL; i++) { data.add(new MapPoint(dataNames, i, spectrum[i])); - } return data; } @@ -121,13 +91,6 @@ public class NMPoint implements NumassPoint { } - /** - * @return the overflow - */ - public int getOverflow() { - return spectrum[RawNMPoint.MAX_CHANEL]; - } - /** * @return the pointLength */ diff --git a/numass-storage/src/main/java/inr/numass/storage/NumassData.java b/numass-core/src/main/java/inr/numass/data/NumassData.java similarity index 98% rename from numass-storage/src/main/java/inr/numass/storage/NumassData.java rename to numass-core/src/main/java/inr/numass/data/NumassData.java index 75099124..a791aac0 100644 --- a/numass-storage/src/main/java/inr/numass/storage/NumassData.java +++ b/numass-core/src/main/java/inr/numass/data/NumassData.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass.storage; +package inr.numass.data; import hep.dataforge.meta.Annotated; import hep.dataforge.meta.Meta; diff --git a/numass-storage/src/main/java/inr/numass/storage/NumassDataReader.java b/numass-core/src/main/java/inr/numass/data/NumassDataReader.java similarity index 95% rename from numass-storage/src/main/java/inr/numass/storage/NumassDataReader.java rename to numass-core/src/main/java/inr/numass/data/NumassDataReader.java index 38abc704..6ed61ea6 100644 --- a/numass-storage/src/main/java/inr/numass/storage/NumassDataReader.java +++ b/numass-core/src/main/java/inr/numass/data/NumassDataReader.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package inr.numass.storage; +package inr.numass.data; import hep.dataforge.data.FileDataFactory; import hep.dataforge.data.binary.Binary; diff --git a/numass-core/src/main/java/inr/numass/data/NumassDataUtils.java b/numass-core/src/main/java/inr/numass/data/NumassDataUtils.java new file mode 100644 index 00000000..5e6627f2 --- /dev/null +++ b/numass-core/src/main/java/inr/numass/data/NumassDataUtils.java @@ -0,0 +1,134 @@ +package inr.numass.data; + +import hep.dataforge.tables.DataPoint; +import hep.dataforge.tables.ListTable; +import hep.dataforge.tables.Table; + +import java.time.Instant; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * Created by darksnake on 30-Jan-17. + */ +public class NumassDataUtils { + + public static Collection joinSpectra(Stream spectra) { + Map map = new LinkedHashMap<>(); + spectra.forEach(datum -> { + datum.forEach(point -> { + double uset = point.getVoltage(); + if (map.containsKey(uset)) { + map.put(uset, join(point, map.get(uset))); + } else { + map.put(uset, point); + } + }); + }); + return map.values(); + } + + /** + * Spectral sum of two points + * + * @param first + * @param second + * @return + */ + public static NumassPoint join(NumassPoint first, NumassPoint second) { + if (first.getVoltage() != second.getVoltage()) { + throw new RuntimeException("Voltage mismatch"); + } + int[] newArray = new int[first.getSpectrum().length]; + Arrays.setAll(newArray, i -> first.getSpectrum()[i] + second.getSpectrum()[i]); + return new NMPoint( + first.getVoltage(), + Instant.EPOCH, + first.getLength() + second.getLength(), + newArray + ); + } + + public static NumassPoint substractPoint(NumassPoint point, NumassPoint reference) { + int[] array = new int[point.getSpectrum().length]; + Arrays.setAll(array, i -> Math.max(0, point.getSpectrum()[i] - reference.getSpectrum()[i])); + return new NMPoint( + point.getVoltage(), + point.getStartTime(), + point.getLength(), + array + ); + } + + public static Collection substractReferencePoint(Collection points, double uset) { + NumassPoint reference = points.stream().filter(it -> it.getVoltage() == uset).findFirst() + .orElseThrow(() -> new RuntimeException("Reference point not found")); + return points.stream().map(it -> substractPoint(it, reference)).collect(Collectors.toList()); + } + + + /** + * Поправка масштаба высокого. + * + * @param data + * @param beta + * @return + */ + public static Table setHVScale(ListTable data, double beta) { + SpectrumDataAdapter reader = adapter(); + ListTable.Builder res = new ListTable.Builder(data.getFormat()); + for (DataPoint dp : data) { + double corrFactor = 1 + beta; + res.row(reader.buildSpectrumDataPoint(reader.getX(dp).doubleValue() * corrFactor, reader.getCount(dp), reader.getTime(dp))); + } + return res.build(); + } + + public static SpectrumDataAdapter adapter() { + return new SpectrumDataAdapter("Uset", "CR", "CRerr", "Time"); + } + + public static Table correctForDeadTime(ListTable data, double dtime) { + return correctForDeadTime(data, adapter(), dtime); + } + + /** + * Коррекция на мертвое время в секундах + * + * @param data + * @param dtime + * @return + */ + public static Table correctForDeadTime(ListTable data, SpectrumDataAdapter adapter, double dtime) { +// SpectrumDataAdapter adapter = adapter(); + ListTable.Builder res = new ListTable.Builder(data.getFormat()); + for (DataPoint dp : data) { + double corrFactor = 1 / (1 - dtime * adapter.getCount(dp) / adapter.getTime(dp)); + res.row(adapter.buildSpectrumDataPoint(adapter.getX(dp).doubleValue(), (long) (adapter.getCount(dp) * corrFactor), adapter.getTime(dp))); + } + return res.build(); + } + + public static double countRateWithDeadTime(NumassPoint p, int from, int to, double deadTime) { + double wind = p.getCountInWindow(from, to) / p.getLength(); + double res; + if (deadTime > 0) { + double total = p.getTotalCount(); +// double time = p.getLength(); +// res = wind / (1 - total * deadTime / time); + double timeRatio = deadTime / p.getLength(); + res = wind / total * (1d - Math.sqrt(1d - 4d * total * timeRatio)) / 2d / timeRatio; + } else { + res = wind; + } + return res; + } + + public static double countRateWithDeadTimeErr(NumassPoint p, int from, int to, double deadTime) { + return Math.sqrt(countRateWithDeadTime(p, from, to, deadTime) / p.getLength()); + } +} diff --git a/numass-storage/src/main/java/inr/numass/storage/NumassPoint.java b/numass-core/src/main/java/inr/numass/data/NumassPoint.java similarity index 94% rename from numass-storage/src/main/java/inr/numass/storage/NumassPoint.java rename to numass-core/src/main/java/inr/numass/data/NumassPoint.java index 51307324..9367eec0 100644 --- a/numass-storage/src/main/java/inr/numass/storage/NumassPoint.java +++ b/numass-core/src/main/java/inr/numass/data/NumassPoint.java @@ -1,4 +1,4 @@ -package inr.numass.storage; +package inr.numass.data; import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.MapPoint; diff --git a/numass-core/src/main/java/inr/numass/data/PointBuilders.java b/numass-core/src/main/java/inr/numass/data/PointBuilders.java new file mode 100644 index 00000000..c6e57ece --- /dev/null +++ b/numass-core/src/main/java/inr/numass/data/PointBuilders.java @@ -0,0 +1,53 @@ +package inr.numass.data; + +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; +import java.io.InputStream; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Function; +import java.util.stream.IntStream; + +/** + * Created by darksnake on 13-Apr-17. + */ +public class PointBuilders { + public static NumassPoint readProtoPoint(double u, Instant startTime, double pointLength, InputStream stream, Function peakFinder) throws IOException { + NumassProto.Point point = NumassProto.Point.parseFrom(stream); + NumassProto.Point.Channel ch = point.getChannels(0); + int[] spectrum = count(ch.getBlocksList().stream() + .flatMapToInt(block -> IntStream.concat( + block.getPeaks().getAmplitudesList() + .stream().mapToInt(it -> it.intValue()), + block.getEventsList().stream() + .mapToInt(event -> peakFinder.apply(event)) + )) + ); + + return new NMPoint(u, startTime, pointLength, spectrum); + } + + private static int[] calculateSpectrum(RawNMPoint point) { + assert point.getEventsCount() > 0; + return count(point.getEvents().stream().mapToInt(event -> event.getChanel())); + } + + @NotNull + public static NumassPoint readRawPoint(@NotNull RawNMPoint point) { + return new NMPoint(point.getUset(), point.getStartTime(), point.getLength(), calculateSpectrum(point)); + } + + private static int[] count(IntStream stream) { + List list = new ArrayList<>(); + stream.forEach(i -> { + while (list.size() <= i) { + list.add(new AtomicInteger(0)); + } + list.get(i).incrementAndGet(); + }); + return list.stream().mapToInt(i -> i.get()).toArray(); + } +} diff --git a/numass-storage/src/main/java/inr/numass/storage/RawNMFile.java b/numass-core/src/main/java/inr/numass/data/RawNMFile.java similarity index 95% rename from numass-storage/src/main/java/inr/numass/storage/RawNMFile.java rename to numass-core/src/main/java/inr/numass/data/RawNMFile.java index 7bdf11f1..86ef7a28 100644 --- a/numass-storage/src/main/java/inr/numass/storage/RawNMFile.java +++ b/numass-core/src/main/java/inr/numass/data/RawNMFile.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package inr.numass.storage; +package inr.numass.data; import hep.dataforge.description.ValueDef; import hep.dataforge.meta.Meta; diff --git a/numass-storage/src/main/java/inr/numass/storage/RawNMPoint.java b/numass-core/src/main/java/inr/numass/data/RawNMPoint.java similarity index 95% rename from numass-storage/src/main/java/inr/numass/storage/RawNMPoint.java rename to numass-core/src/main/java/inr/numass/data/RawNMPoint.java index da652534..a853257d 100644 --- a/numass-storage/src/main/java/inr/numass/storage/RawNMPoint.java +++ b/numass-core/src/main/java/inr/numass/data/RawNMPoint.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package inr.numass.storage; +package inr.numass.data; import java.time.Instant; import java.util.ArrayList; diff --git a/numass-storage/src/main/java/inr/numass/storage/SetDirectionUtility.java b/numass-core/src/main/java/inr/numass/data/SetDirectionUtility.java similarity index 96% rename from numass-storage/src/main/java/inr/numass/storage/SetDirectionUtility.java rename to numass-core/src/main/java/inr/numass/data/SetDirectionUtility.java index 89a8b22f..1b3db017 100644 --- a/numass-storage/src/main/java/inr/numass/storage/SetDirectionUtility.java +++ b/numass-core/src/main/java/inr/numass/data/SetDirectionUtility.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass.storage; +package inr.numass.data; import hep.dataforge.context.Context; import hep.dataforge.context.Global; diff --git a/numass-main/src/main/java/inr/numass/data/SpectrumDataAdapter.java b/numass-core/src/main/java/inr/numass/data/SpectrumDataAdapter.java similarity index 100% rename from numass-main/src/main/java/inr/numass/data/SpectrumDataAdapter.java rename to numass-core/src/main/java/inr/numass/data/SpectrumDataAdapter.java diff --git a/numass-storage/src/main/java/inr/numass/storage/NumassDataFactory.java b/numass-core/src/main/java/inr/numass/storage/NumassDataFactory.java similarity index 93% rename from numass-storage/src/main/java/inr/numass/storage/NumassDataFactory.java rename to numass-core/src/main/java/inr/numass/storage/NumassDataFactory.java index c4da4ba3..13083bca 100644 --- a/numass-storage/src/main/java/inr/numass/storage/NumassDataFactory.java +++ b/numass-core/src/main/java/inr/numass/storage/NumassDataFactory.java @@ -6,6 +6,7 @@ import hep.dataforge.data.DataFilter; import hep.dataforge.data.DataTree; import hep.dataforge.meta.Meta; import hep.dataforge.storage.commons.StorageUtils; +import inr.numass.data.NumassData; /** * Created by darksnake on 03-Feb-17. diff --git a/numass-storage/src/main/java/inr/numass/storage/NumassDataLoader.java b/numass-core/src/main/java/inr/numass/storage/NumassDataLoader.java similarity index 95% rename from numass-storage/src/main/java/inr/numass/storage/NumassDataLoader.java rename to numass-core/src/main/java/inr/numass/storage/NumassDataLoader.java index 544f77b7..23cf402d 100644 --- a/numass-storage/src/main/java/inr/numass/storage/NumassDataLoader.java +++ b/numass-core/src/main/java/inr/numass/storage/NumassDataLoader.java @@ -26,6 +26,7 @@ import hep.dataforge.storage.api.Storage; import hep.dataforge.storage.filestorage.FileEnvelope; import hep.dataforge.storage.loaders.AbstractLoader; import hep.dataforge.tables.Table; +import inr.numass.data.*; import org.apache.commons.vfs2.FileObject; import org.apache.commons.vfs2.VFS; import org.slf4j.LoggerFactory; @@ -44,7 +45,6 @@ import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; -import static inr.numass.storage.RawNMPoint.MAX_EVENTS_PER_POINT; import static org.apache.commons.vfs2.FileType.FOLDER; /** @@ -218,7 +218,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader MAX_EVENTS_PER_POINT) { + if (!segmented && events.size() > RawNMPoint.MAX_EVENTS_PER_POINT) { pointTime = events.get(events.size() - 1).getTime() - events.get(0).getTime(); } @@ -235,7 +235,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader> getItems() { diff --git a/numass-storage/src/main/java/inr/numass/storage/NumassStorage.java b/numass-core/src/main/java/inr/numass/storage/NumassStorage.java similarity index 96% rename from numass-storage/src/main/java/inr/numass/storage/NumassStorage.java rename to numass-core/src/main/java/inr/numass/storage/NumassStorage.java index 49b589f8..9d02c3cb 100644 --- a/numass-storage/src/main/java/inr/numass/storage/NumassStorage.java +++ b/numass-core/src/main/java/inr/numass/storage/NumassStorage.java @@ -23,6 +23,8 @@ import hep.dataforge.meta.MetaBuilder; import hep.dataforge.storage.filestorage.FilePointLoader; import hep.dataforge.storage.filestorage.FileStorage; import hep.dataforge.storage.filestorage.VFSUtils; +import inr.numass.data.NMFile; +import inr.numass.data.NumassData; import org.apache.commons.io.FilenameUtils; import org.apache.commons.vfs2.FileObject; import org.apache.commons.vfs2.FileSystemException; diff --git a/numass-storage/src/main/proto/inr/numas/storage/proto/numass-proto.proto b/numass-core/src/main/proto/inr/numas/numass-proto.proto similarity index 96% rename from numass-storage/src/main/proto/inr/numas/storage/proto/numass-proto.proto rename to numass-core/src/main/proto/inr/numas/numass-proto.proto index 28614ff9..1ce566ef 100644 --- a/numass-storage/src/main/proto/inr/numas/storage/proto/numass-proto.proto +++ b/numass-core/src/main/proto/inr/numas/numass-proto.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package inr.numass.storage; +package inr.numass.data; message Point { message Channel { diff --git a/numass-storage/src/main/resources/META-INF/services/hep.dataforge.data.DataLoader b/numass-core/src/main/resources/META-INF/services/hep.dataforge.data.DataLoader similarity index 100% rename from numass-storage/src/main/resources/META-INF/services/hep.dataforge.data.DataLoader rename to numass-core/src/main/resources/META-INF/services/hep.dataforge.data.DataLoader diff --git a/numass-main/build.gradle b/numass-main/build.gradle index d4a977f5..ea851034 100644 --- a/numass-main/build.gradle +++ b/numass-main/build.gradle @@ -11,7 +11,7 @@ description = "Main numass project" dependencies { compile group: 'commons-cli', name: 'commons-cli', version: '1.+' compile group: 'commons-io', name: 'commons-io', version: '2.+' - compile project(':numass-storage') + compile project(':numass-core') compile "hep.dataforge:dataforge-minuit" //project(':dataforge-stat:dataforge-minuit') compile "hep.dataforge:grind-terminal" //project(':dataforge-grind:grind-terminal') } diff --git a/numass-main/src/main/groovy/inr/numass/scripts/DetectorSpectrumSubstraction.groovy b/numass-main/src/main/groovy/inr/numass/scripts/DetectorSpectrumSubstraction.groovy index bb030571..02d27260 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/DetectorSpectrumSubstraction.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/DetectorSpectrumSubstraction.groovy @@ -10,7 +10,7 @@ import hep.dataforge.io.ColumnedDataWriter import hep.dataforge.tables.ListTable import hep.dataforge.tables.MapPoint import hep.dataforge.tables.TableFormatBuilder -import inr.numass.storage.NumassData +import inr.numass.data.NumassData NumassData.metaClass.findPoint{double u -> delegate.getNMPoints().getWork { it.getVoltage() == u }.getMap(20, true) @@ -56,7 +56,7 @@ NumassData data2 = NMFile.readFile(new File("D:\\Work\\Numass\\transmission 2013 double[] points = [14500,15000,15500,16000,18100,18200,18300] -ColumnedDataWriter.writeDataSet(System.out, buildSet(data1,data2,points), "Detector spectrum substraction"); +ColumnedDataWriter.writeTable(System.out, buildSet(data1,data2,points), "Detector spectrum substraction"); diff --git a/numass-main/src/main/groovy/inr/numass/scripts/FindBorder.groovy b/numass-main/src/main/groovy/inr/numass/scripts/FindBorder.groovy index e4d3859f..5a8db3e5 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/FindBorder.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/FindBorder.groovy @@ -6,12 +6,11 @@ package inr.numass.scripts -import inr.numass.storage.NMFile -import inr.numass.storage.NumassData -import inr.numass.storage.NumassDataLoader +import hep.dataforge.grind.GrindMetaBuilder import hep.dataforge.meta.Meta import inr.numass.actions.FindBorderAction -import hep.dataforge.grind.GrindMetaBuilder +import inr.numass.data.NumassData +import inr.numass.storage.NumassDataLoader File dataDir = new File("D:\\Work\\Numass\\data\\2016_04\\T2_data\\Fill_2_2\\set_6_e26d123e54010000") if(!dataDir.exists()){ diff --git a/numass-main/src/main/groovy/inr/numass/scripts/Loss2014.groovy b/numass-main/src/main/groovy/inr/numass/scripts/Loss2014.groovy deleted file mode 100644 index 2b12c0d6..00000000 --- a/numass-main/src/main/groovy/inr/numass/scripts/Loss2014.groovy +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2015 Alexander Nozik. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package inr.numass.scripts - -import hep.dataforge.context.Context -import hep.dataforge.data.DataNode -import hep.dataforge.stat.fit.FitTaskResult -import inr.numass.Main -import inr.numass.Numass - - -//Main.main("-lc") -Context context = Numass.buildContext(); -context.putValue("integralThreshold", 15d); -DataNode resultPack = Main.run(context, "-c","D:\\sterile-new\\loss2014-11\\d2_19_1.xml") -FitTaskResult result = resultPack.getData().get() -result.print(new PrintWriter(System.out)) diff --git a/numass-main/src/main/groovy/inr/numass/scripts/ReadTextFile.groovy b/numass-main/src/main/groovy/inr/numass/scripts/ReadTextFile.groovy index 8c37ee13..eefff99e 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/ReadTextFile.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/ReadTextFile.groovy @@ -12,4 +12,4 @@ import hep.dataforge.tables.Table File file = new File("D:\\Work\\Numass\\sterile2016\\empty.dat" ) Table referenceTable = new ColumnedDataReader(file).toTable(); -ColumnedDataWriter.writeDataSet(System.out, referenceTable,"") \ No newline at end of file +ColumnedDataWriter.writeTable(System.out, referenceTable,"") \ No newline at end of file diff --git a/numass-main/src/main/groovy/inr/numass/scripts/Simulate.groovy b/numass-main/src/main/groovy/inr/numass/scripts/Simulate.groovy index 99078fd9..e9ef2c18 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/Simulate.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/Simulate.groovy @@ -88,7 +88,7 @@ data = TritiumUtils.correctForDeadTime(data, new SpectrumDataAdapter(), 10e-9); // allPars.setParValue("X", 0.4); -ColumnedDataWriter.writeDataSet(System.out,data,"--- DATA ---"); +ColumnedDataWriter.writeTable(System.out,data,"--- DATA ---"); FitState state = new FitState(data, model, allPars); //new PlotFitResultAction().eval(state); diff --git a/numass-main/src/main/groovy/inr/numass/scripts/SimulatePileup.groovy b/numass-main/src/main/groovy/inr/numass/scripts/SimulatePileup.groovy index bd2c43c2..d579ae6b 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/SimulatePileup.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/SimulatePileup.groovy @@ -8,9 +8,9 @@ package inr.numass.scripts import hep.dataforge.grind.Grind import hep.dataforge.tables.DataPoint -import inr.numass.storage.NMPoint +import inr.numass.data.NMPoint +import inr.numass.data.RawNMPoint import inr.numass.storage.NumassDataLoader -import inr.numass.storage.RawNMPoint import inr.numass.utils.NMEventGeneratorWithPulser import inr.numass.utils.PileUpSimulator import inr.numass.utils.TritiumUtils diff --git a/numass-main/src/main/groovy/inr/numass/scripts/Underflow.groovy b/numass-main/src/main/groovy/inr/numass/scripts/Underflow.groovy index c3e6a54f..f0b5c6d1 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/Underflow.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/Underflow.groovy @@ -9,8 +9,8 @@ package inr.numass.scripts import hep.dataforge.io.ColumnedDataWriter import hep.dataforge.storage.commons.StorageUtils import hep.dataforge.tables.Table -import inr.numass.storage.NMPoint -import inr.numass.storage.NumassDataUtils +import inr.numass.data.NMPoint +import inr.numass.data.NumassDataUtils import inr.numass.storage.NumassStorage import inr.numass.utils.UnderflowCorrection @@ -85,5 +85,5 @@ printPoint(data, [14000d, 14500d, 15000d, 15500d, 16500d]) println() Table t = new UnderflowCorrection().fitAllPoints(data, 400, 600, 3100, 20); -ColumnedDataWriter.writeDataSet(System.out, t, "underflow parameters") +ColumnedDataWriter.writeTable(System.out, t, "underflow parameters") diff --git a/numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java b/numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java index 1e71859a..b4506623 100644 --- a/numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java +++ b/numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java @@ -29,7 +29,7 @@ import hep.dataforge.plots.data.PlottableData; import hep.dataforge.plots.data.PlottableXYFunction; import hep.dataforge.stat.fit.FitState; import hep.dataforge.stat.models.XYModel; -import hep.dataforge.tables.PointSource; +import hep.dataforge.tables.NavigablePointSource; import hep.dataforge.tables.XYAdapter; import java.util.function.Function; @@ -46,7 +46,7 @@ public class PlotFitResultAction extends OneToOneAction { @Override protected FitState execute(Context context, String name, FitState input, Laminate metaData) { - PointSource data = input.getDataSet(); + NavigablePointSource data = input.getDataSet(); if (!(input.getModel() instanceof XYModel)) { getReport(context, name).reportError("The fit model should be instance of XYModel for this action. Action failed!"); return input; diff --git a/numass-main/src/main/java/inr/numass/NumassIO.java b/numass-main/src/main/java/inr/numass/NumassIO.java index 1a3e8190..ee77c034 100644 --- a/numass-main/src/main/java/inr/numass/NumassIO.java +++ b/numass-main/src/main/java/inr/numass/NumassIO.java @@ -20,9 +20,9 @@ import hep.dataforge.data.binary.Binary; import hep.dataforge.io.BasicIOManager; import hep.dataforge.meta.Meta; import hep.dataforge.names.Name; +import inr.numass.data.NumassDataReader; import inr.numass.data.NumassPawReader; -import inr.numass.storage.NumassDataReader; -import inr.numass.storage.RawNMFile; +import inr.numass.data.RawNMFile; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.output.TeeOutputStream; diff --git a/numass-main/src/main/java/inr/numass/NumassPlugin.java b/numass-main/src/main/java/inr/numass/NumassPlugin.java index 5600ed29..3074efbe 100644 --- a/numass-main/src/main/java/inr/numass/NumassPlugin.java +++ b/numass-main/src/main/java/inr/numass/NumassPlugin.java @@ -80,7 +80,6 @@ public class NumassPlugin extends BasicPlugin { ActionManager actions = context.pluginManager().getOrLoad(ActionManager.class); actions.attach(context); - actions.register(SlicingAction.class); actions.register(PrepareDataAction.class); actions.register(ReadLegacyDataAction.class); actions.register(MergeDataAction.class); diff --git a/numass-main/src/main/java/inr/numass/actions/DebunchAction.java b/numass-main/src/main/java/inr/numass/actions/DebunchAction.java index 2893e2a8..535739f6 100644 --- a/numass-main/src/main/java/inr/numass/actions/DebunchAction.java +++ b/numass-main/src/main/java/inr/numass/actions/DebunchAction.java @@ -21,10 +21,10 @@ import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.ValueDef; import hep.dataforge.exceptions.ContentException; import hep.dataforge.meta.Laminate; +import inr.numass.data.RawNMFile; +import inr.numass.data.RawNMPoint; import inr.numass.debunch.DebunchReport; import inr.numass.debunch.FrameAnalizer; -import inr.numass.storage.RawNMFile; -import inr.numass.storage.RawNMPoint; import java.io.PrintWriter; diff --git a/numass-main/src/main/java/inr/numass/actions/FindBorderAction.java b/numass-main/src/main/java/inr/numass/actions/FindBorderAction.java index ad3efb9d..15eea4a8 100644 --- a/numass-main/src/main/java/inr/numass/actions/FindBorderAction.java +++ b/numass-main/src/main/java/inr/numass/actions/FindBorderAction.java @@ -25,9 +25,9 @@ import hep.dataforge.tables.ListTable; import hep.dataforge.tables.MapPoint; import hep.dataforge.tables.Table; import hep.dataforge.values.Value; -import inr.numass.storage.NMFile; -import inr.numass.storage.NumassData; -import inr.numass.storage.NumassPoint; +import inr.numass.data.NMFile; +import inr.numass.data.NumassData; +import inr.numass.data.NumassPoint; import org.apache.commons.math3.analysis.UnivariateFunction; import java.io.OutputStream; @@ -69,7 +69,7 @@ public class FindBorderAction extends OneToOneAction { OutputStream stream = buildActionOutput(context, name); - ColumnedDataWriter.writeDataSet(stream, bData, String.format("%s : lower = %d upper = %d", name, lowerBorder, upperBorder)); + ColumnedDataWriter.writeTable(stream, bData, String.format("%s : lower = %d upper = %d", name, lowerBorder, upperBorder)); report(context, name, "File {} completed", source.getName()); return bData; diff --git a/numass-main/src/main/java/inr/numass/actions/JoinNumassDataAction.java b/numass-main/src/main/java/inr/numass/actions/JoinNumassDataAction.java index 05bf9ef2..7e74937b 100644 --- a/numass-main/src/main/java/inr/numass/actions/JoinNumassDataAction.java +++ b/numass-main/src/main/java/inr/numass/actions/JoinNumassDataAction.java @@ -4,9 +4,9 @@ import hep.dataforge.actions.ManyToOneAction; import hep.dataforge.context.Context; import hep.dataforge.description.TypedActionDef; import hep.dataforge.meta.Laminate; -import inr.numass.storage.NMPoint; -import inr.numass.storage.NumassData; -import inr.numass.storage.NumassPoint; +import inr.numass.data.NMPoint; +import inr.numass.data.NumassData; +import inr.numass.data.NumassPoint; import java.util.Collection; import java.util.Map; diff --git a/numass-main/src/main/java/inr/numass/actions/MergeDataAction.java b/numass-main/src/main/java/inr/numass/actions/MergeDataAction.java index 3e760db8..aefe6852 100644 --- a/numass-main/src/main/java/inr/numass/actions/MergeDataAction.java +++ b/numass-main/src/main/java/inr/numass/actions/MergeDataAction.java @@ -61,7 +61,7 @@ public class MergeDataAction extends ManyToOneAction { @Override protected void afterGroup(Context context, String groupName, Meta outputMeta, Table output) { OutputStream stream = buildActionOutput(context, groupName); - ColumnedDataWriter.writeDataSet(stream, output, outputMeta.toString()); + ColumnedDataWriter.writeTable(stream, output, outputMeta.toString()); } // @Override @@ -135,7 +135,7 @@ public class MergeDataAction extends ManyToOneAction { private Table mergeDataSets(String name, Collection ds) { //Сливаем все точки в один набор данных Map> points = new LinkedHashMap<>(); - for (PointSource d : ds) { + for (Table d : ds) { if (!d.getFormat().names().contains(parnames)) { throw new IllegalArgumentException(); } diff --git a/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java b/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java index 686a6874..aff0cf4a 100644 --- a/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java +++ b/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java @@ -124,7 +124,7 @@ public class MonitorCorrectAction extends OneToOneAction { // // if (!dataList.isEmpty()) { // //Генерируем автоматический формат по первой строчке -// format = DataFormat.of(dataList.getRow(0)); +// format = DataFormat.of(dataList.getPoint(0)); // } else { // format = DataFormat.of(parnames); // } @@ -132,7 +132,7 @@ public class MonitorCorrectAction extends OneToOneAction { OutputStream stream = buildActionOutput(context, name); - ColumnedDataWriter.writeDataSet(stream, data, head); + ColumnedDataWriter.writeTable(stream, data, head); return data; } @@ -197,7 +197,7 @@ public class MonitorCorrectAction extends OneToOneAction { String monitorFileName = meta.getString("monitorFile", "monitor"); OutputStream stream = buildActionOutput(context, monitorFileName); ListTable data = new ListTable(monitorPoints); - ColumnedDataWriter.writeDataSet(stream, TableTransform.sort(data, "Timestamp", true), "Monitor points", monitorNames); + ColumnedDataWriter.writeTable(stream, TableTransform.sort(data, "Timestamp", true), "Monitor points", monitorNames); } } diff --git a/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java b/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java index cab2629b..86d5e411 100644 --- a/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java +++ b/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java @@ -26,9 +26,13 @@ import hep.dataforge.io.XMLMetaWriter; import hep.dataforge.meta.Laminate; import hep.dataforge.meta.Meta; import hep.dataforge.tables.*; +import inr.numass.data.NumassData; +import inr.numass.data.NumassPoint; +import inr.numass.data.PointBuilders; +import inr.numass.data.RawNMPoint; import inr.numass.debunch.DebunchReport; import inr.numass.debunch.FrameAnalizer; -import inr.numass.storage.*; +import inr.numass.storage.NumassDataLoader; import inr.numass.utils.ExpressionUtils; import java.io.OutputStream; @@ -112,7 +116,7 @@ public class PrepareDataAction extends OneToOneAction { long total = point.getTotalCount(); double uset = utransform.apply(point.getVoltage()); - double uread = utransform.apply(point.getUread()); + double uread = utransform.apply(point.getVoltage()); double time = point.getLength(); int a = getLowerBorder(meta, uset); int b = Math.min(upper, RawNMPoint.MAX_CHANEL); @@ -163,7 +167,7 @@ public class PrepareDataAction extends OneToOneAction { OutputStream stream = buildActionOutput(context, name); - ColumnedDataWriter.writeDataSet(stream, data, head); + ColumnedDataWriter.writeTable(stream, data, head); // log.logString("File %s completed", dataFile.getName()); return data; } @@ -201,9 +205,9 @@ public class PrepareDataAction extends OneToOneAction { double cr = point.selectChanels(lower, upper).getCR(); if (cr < maxCR) { DebunchReport report = new FrameAnalizer(rejectionprob, framelength, lower, upper).debunchPoint(point); - return new NMPoint(report.getPoint()); + return PointBuilders.readRawPoint(report.getPoint()); } else { - return new NMPoint(point); + return PointBuilders.readRawPoint(point); } } diff --git a/numass-main/src/main/java/inr/numass/actions/ReadLegacyDataAction.java b/numass-main/src/main/java/inr/numass/actions/ReadLegacyDataAction.java index e0476947..f923bb5e 100644 --- a/numass-main/src/main/java/inr/numass/actions/ReadLegacyDataAction.java +++ b/numass-main/src/main/java/inr/numass/actions/ReadLegacyDataAction.java @@ -23,8 +23,8 @@ import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.ValueDef; import hep.dataforge.exceptions.ContentException; import hep.dataforge.meta.Laminate; -import inr.numass.storage.NMFile; -import inr.numass.storage.RawNMFile; +import inr.numass.data.NMFile; +import inr.numass.data.RawNMFile; import static inr.numass.NumassIO.getNumassData; diff --git a/numass-main/src/main/java/inr/numass/actions/ShowEnergySpectrumAction.java b/numass-main/src/main/java/inr/numass/actions/ShowEnergySpectrumAction.java index b7889bca..2897db84 100644 --- a/numass-main/src/main/java/inr/numass/actions/ShowEnergySpectrumAction.java +++ b/numass-main/src/main/java/inr/numass/actions/ShowEnergySpectrumAction.java @@ -18,8 +18,8 @@ import hep.dataforge.plots.data.PlottableData; import hep.dataforge.plots.data.XYPlottable; import hep.dataforge.tables.*; import hep.dataforge.values.ValueType; -import inr.numass.storage.NumassData; -import inr.numass.storage.NumassPoint; +import inr.numass.data.NumassData; +import inr.numass.data.NumassPoint; import java.io.OutputStream; import java.util.*; @@ -79,7 +79,7 @@ public class ShowEnergySpectrumAction extends OneToOneAction OutputStream out = buildActionOutput(context, name); Table table = builder.build(); - ColumnedDataWriter.writeDataSet(out, table, inputMeta.toString()); + ColumnedDataWriter.writeTable(out, table, inputMeta.toString()); if (inputMeta.hasMeta("plot") || inputMeta.getBoolean("plot", false)) { PlotFrame frame = PlotUtils.getPlotManager(context) diff --git a/numass-main/src/main/java/inr/numass/actions/ShowLossSpectrumAction.java b/numass-main/src/main/java/inr/numass/actions/ShowLossSpectrumAction.java deleted file mode 100644 index e55f9fdd..00000000 --- a/numass-main/src/main/java/inr/numass/actions/ShowLossSpectrumAction.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright 2015 Alexander Nozik. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package inr.numass.actions; - -import hep.dataforge.actions.OneToOneAction; -import hep.dataforge.context.Context; -import hep.dataforge.description.TypedActionDef; -import hep.dataforge.io.ColumnedDataWriter; -import hep.dataforge.io.PrintFunction; -import hep.dataforge.maths.GridCalculator; -import hep.dataforge.maths.NamedMatrix; -import hep.dataforge.maths.integration.UnivariateIntegrator; -import hep.dataforge.meta.Laminate; -import hep.dataforge.meta.MetaBuilder; -import hep.dataforge.plots.PlotFrame; -import hep.dataforge.plots.PlotUtils; -import hep.dataforge.plots.data.PlottableXYFunction; -import hep.dataforge.stat.fit.FitState; -import hep.dataforge.stat.fit.FitTaskResult; -import hep.dataforge.stat.fit.Param; -import hep.dataforge.stat.fit.ParamSet; -import hep.dataforge.stat.simulation.GaussianParameterGenerator; -import hep.dataforge.tables.ListTable; -import hep.dataforge.tables.MapPoint; -import hep.dataforge.tables.Table; -import hep.dataforge.values.NamedValueSet; -import inr.numass.models.ExperimentalVariableLossSpectrum; -import inr.numass.models.LossCalculator; -import inr.numass.utils.NumassIntegrator; -import org.apache.commons.math3.analysis.UnivariateFunction; -import org.apache.commons.math3.analysis.interpolation.LinearInterpolator; -import org.apache.commons.math3.analysis.interpolation.UnivariateInterpolator; -import org.apache.commons.math3.stat.StatUtils; -import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; -import org.slf4j.LoggerFactory; - -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.nio.charset.Charset; -import java.util.Arrays; - -/** - * @author darksnake - */ -@TypedActionDef(name = "showLoss", inputType = FitState.class, outputType = FitState.class, - info = "Show loss spectrum for fit with loss model. Calculate excitation to ionisation ratio.") -@Deprecated -public class ShowLossSpectrumAction extends OneToOneAction { - - private static final String[] names = {"X", "exPos", "ionPos", "exW", "ionW", "exIonRatio"}; - - public static double calcultateIonRatio(NamedValueSet set, double threshold) { - UnivariateIntegrator integrator = NumassIntegrator.getHighDensityIntegrator(); - UnivariateFunction integrand = LossCalculator.getSingleScatterFunction(set); - return 1d - integrator.integrate(integrand, 5d, threshold); - } - - public static Table generateSpread(PrintWriter writer, String name, NamedValueSet parameters, NamedMatrix covariance) { - int numCalls = 1000; - int gridPoints = 200; - double a = 8; - double b = 32; - - double[] grid = GridCalculator.getUniformUnivariateGrid(a, b, gridPoints); - - double[] upper = new double[gridPoints]; - double[] lower = new double[gridPoints]; - double[] dispersion = new double[gridPoints]; - - double[] central = new double[gridPoints]; - - UnivariateFunction func = LossCalculator.getSingleScatterFunction(parameters); - for (int j = 0; j < gridPoints; j++) { - central[j] = func.value(grid[j]); - } - - Arrays.fill(upper, Double.NEGATIVE_INFINITY); - Arrays.fill(lower, Double.POSITIVE_INFINITY); - Arrays.fill(dispersion, 0); - - GaussianParameterGenerator generator = new GaussianParameterGenerator(parameters, covariance); - - for (int i = 0; i < numCalls; i++) { - func = LossCalculator.getSingleScatterFunction(generator.generate()); - for (int j = 0; j < gridPoints; j++) { - double val = func.value(grid[j]); - upper[j] = Math.max(upper[j], val); - lower[j] = Math.min(lower[j], val); - dispersion[j] += (val - central[j]) * (val - central[j]) / numCalls; - } - } - String[] pointNames = {"e", "central", "lower", "upper", "dispersion"}; - ListTable.Builder res = new ListTable.Builder(pointNames); - for (int i = 0; i < gridPoints; i++) { - res.row(new MapPoint(pointNames, grid[i], central[i], lower[i], upper[i], dispersion[i])); - - } - return res.build(); - } - - @Override - protected FitState execute(Context context, String name, FitState input, Laminate meta) { - ParamSet pars = input.getParameters(); - if (!pars.names().contains(names)) { - LoggerFactory.getLogger(getClass()).error("Wrong input FitState. Must be loss spectrum fit."); - throw new RuntimeException("Wrong input FitState"); - } - - UnivariateFunction scatterFunction; - boolean calculateRatio = false; - PlotFrame frame = PlotUtils.getPlotManager(context) - .buildPlotFrame(getName(), name + ".loss", - new MetaBuilder("plot") - .setValue("plotTitle", "Differential scattering crossection for " + name) - ); - switch (input.getModel().meta().getString("name", "")) { - case "scatter-variable": - scatterFunction = LossCalculator.getSingleScatterFunction(pars); - calculateRatio = true; - - LossCalculator.plotScatter(frame, pars); - break; - case "scatter-empiric-experimental": - scatterFunction = new ExperimentalVariableLossSpectrum.Loss(0.3).total(pars); - - frame.add(PlottableXYFunction.plotFunction("Cross-section", (x) -> scatterFunction.value(x), 0, 100, 1000)); - break; - default: - throw new RuntimeException("Can work only with variable loss spectra"); - } - - double threshold = 0; - double ionRatio = -1; - double ionRatioError = -1; - if (calculateRatio) { - threshold = meta.getDouble("ionThreshold", 17); - ionRatio = calcultateIonRatio(pars, threshold); - report(context, name, "The ionization ratio (using threshold {}) is {}", threshold, ionRatio); - ionRatioError = calultateIonRatioError(context, name, input, threshold); - report(context, name, "the ionization ration standard deviation (using threshold {}) is {}", threshold, ionRatioError); - } - - if (meta.getBoolean("printResult", false)) { - PrintWriter writer = new PrintWriter(new OutputStreamWriter(buildActionOutput(context, name), Charset.forName("UTF-8"))); -// writer.println("*** FIT PARAMETERS ***"); - input.print(writer); -// for (Param param : pars.getSubSet(names).getParams()) { -// writer.println(param.toString()); -// } -// writer.println(); -// onComplete.printf("Chi squared over degrees of freedom: %g/%d = %g", input.getChi2(), input.ndf(), chi2 / this.ndf()); - - writer.println(); - - writer.println("*** LOSS SPECTRUM INFORMATION ***"); - writer.println(); - - if (calculateRatio) { - writer.printf("The ionization ratio (using threshold %f) is %f%n", threshold, ionRatio); - writer.printf("The ionization ratio standard deviation (using threshold %f) is %f%n", threshold, ionRatioError); - writer.println(); - } - -// double integralThreshold = reader.getDouble("numass.eGun", 19005d) - reader.getDouble("integralThreshold", 14.82); -// double integralRatio = calculateIntegralExIonRatio(input.getDataSet(), input.getParameters().getDouble("X"), integralThreshold); -// writer.printf("The excitation to ionization ratio from integral spectrum (using threshold %f) is %f%n", integralThreshold, integralRatio); - writer.println(); - - writer.println("*** SUMMARY ***"); - - writer.printf("%s\t", "name"); - - for (String parName : names) { - writer.printf("%s\t%s\t", parName, parName + "_err"); - } - if (calculateRatio) { - writer.printf("%s\t", "ionRatio"); - writer.printf("%s\t", "ionRatioErr"); - } - writer.printf("%s%n", "chi2"); - - writer.printf("%s\t", name); - - for (Param param : pars.getSubSet(names).getParams()) { - writer.printf("%f\t%f\t", param.value(), param.getErr()); - } - - if (calculateRatio) { - writer.printf("%f\t", ionRatio); - writer.printf("%f\t", ionRatioError); - } - - writer.printf("%f%n", input.getChi2() / ((FitTaskResult) input).ndf()); - writer.println(); - - writer.println("***LOSS SPECTRUM***"); - writer.println(); - PrintFunction.printFunctionSimple(writer, scatterFunction, 0, 100, 500); - - if (meta.getBoolean("showSpread", false)) { - writer.println("***SPECTRUM SPREAD***"); - writer.println(); - - ParamSet parameters = input.getParameters().getSubSet("exPos", "ionPos", "exW", "ionW", "exIonRatio"); - NamedMatrix covariance = input.getCovariance(); - Table spreadData = generateSpread(writer, name, parameters, covariance); - ColumnedDataWriter.writeDataSet(System.out, spreadData, "", spreadData.getFormat().namesAsArray()); - } - } - - return input; - } - - private double calculateIntegralExIonRatio(Table data, double X, double integralThreshold) { - double scatterProb = 1 - Math.exp(-X); - - double[] x = data.getColumn("Uset").asList().stream().mapToDouble((val) -> val.doubleValue()).toArray(); - double[] y = data.getColumn("CR").asList().stream().mapToDouble((val) -> val.doubleValue()).toArray(); - - double yMax = StatUtils.max(y); - - UnivariateInterpolator interpolator = new LinearInterpolator(); - UnivariateFunction interpolated = interpolator.interpolate(x, y); - - double thresholdValue = interpolated.value(integralThreshold); - - double one = 1 - X * Math.exp(-X); - - double ionProb = (one - thresholdValue / yMax); - double exProb = (thresholdValue / yMax - one + scatterProb); - return exProb / ionProb; - } - - public double calultateIonRatioError(Context context, String dataNeme, FitState state, double threshold) { - ParamSet parameters = state.getParameters().getSubSet("exPos", "ionPos", "exW", "ionW", "exIonRatio"); - NamedMatrix covariance = state.getCovariance(); - return calultateIonRatioError(context, dataNeme, parameters, covariance, threshold); - } - - @SuppressWarnings("Unchecked") - public double calultateIonRatioError(Context context, String name, NamedValueSet parameters, NamedMatrix covariance, double threshold) { - int number = 10000; - - double[] res = new GaussianParameterGenerator(parameters, covariance) - .generate(number) - .stream() - .mapToDouble((vector) -> calcultateIonRatio(vector, threshold)) - .filter(d -> !Double.isNaN(d)) - .toArray(); - -// Histogram hist = new Histogram(0.3, 0.5, 0.002); -// hist.fill(res); -// PlotFrame frame = PlotUtils.getPlotManager(context) -// .buildPlotFrame(getName(), name + ".ionRatio", -// new MetaBuilder("plot").setValue("plotTitle", "Ion ratio Distribution for " + name) -// ); -// frame.add(PlottableData.plot("ionRatio", new XYAdapter("binCenter", "count"), hist)); - - return new DescriptiveStatistics(res).getStandardDeviation(); - } - -} diff --git a/numass-main/src/main/java/inr/numass/actions/SlicedData.java b/numass-main/src/main/java/inr/numass/actions/SlicedData.java deleted file mode 100644 index 88a4ccee..00000000 --- a/numass-main/src/main/java/inr/numass/actions/SlicedData.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2015 Alexander Nozik. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package inr.numass.actions; - -import hep.dataforge.tables.MapPoint; -import hep.dataforge.tables.SimplePointSource; -import hep.dataforge.tables.TableFormat; -import hep.dataforge.values.Value; -import inr.numass.storage.NMFile; -import inr.numass.storage.NumassPoint; -import org.apache.commons.math3.util.Pair; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -/** - * - * @author Darksnake - */ -public class SlicedData extends SimplePointSource { - private static final String TNAME = "Time"; - //format = {U,username1,username2, ...} - private static final String UNAME = "U"; - - - public SlicedData(NMFile file, Map> intervals, boolean normalize) { - super(prepateFormat(intervals)); - fill(file, intervals, normalize); - } - - private static TableFormat prepateFormat(Map> intervals){ - ArrayList names = new ArrayList<>(intervals.keySet()); - names.add(0, TNAME); - names.add(0, UNAME); - return TableFormat.forNames(names); - } - - private void fill(NMFile file, Map> intervals, boolean normalize){ - for (NumassPoint point : file) { - - //создаем основу для будущей точки - HashMap map = new HashMap<>(); - - //Кладем напряжение - map.put(UNAME, Value.of(point.getVoltage())); - double t = point.getLength(); - map.put(TNAME, Value.of(t)); - - for (Map.Entry> entry : intervals.entrySet()) { - String name = entry.getKey(); - Pair pair = entry.getValue(); - int a = pair.getFirst(); - int b = pair.getSecond(); - - int count; - // проверяем порядок границ и переворачиваем если нужно - if(b>a){ - count = point.getCountInWindow(a, b); - } else if(b { - - public static final String name = "slicing"; - - @Override - public String getName() { - return name; - } - - @Override - protected NMFile execute(Context context, String name, NMFile source, Laminate meta) throws ContentException { - boolean normalize; - Map> slicingConfig; - - LinkedHashMap> res = new LinkedHashMap<>(); - List list = meta.getMeta("sliceconfig").getMetaList("slicepoint"); - - for (Meta slice : list) { - String title = slice.getString("title", slice.getName()); - int from = slice.getInt("from", 0); - int to = slice.getInt("to", RawNMPoint.MAX_CHANEL); - res.put(title, new Pair<>(from, to)); - } - slicingConfig = res; - - normalize = meta.getBoolean("normalize", false); - - if (slicingConfig == null) { - throw new RuntimeException("Slice configuration not defined"); - } - report(context, name, "File {} started", source.getName()); - - SlicedData sData = new SlicedData(source, slicingConfig, normalize); - - OutputStream stream = buildActionOutput(context, name); - - ColumnedDataWriter.writeDataSet(stream, sData, null); - - report(context, name, "File {} completed", source.getName()); - - return source; - } - -} diff --git a/numass-main/src/main/java/inr/numass/actions/SubstractSpectrumAction.java b/numass-main/src/main/java/inr/numass/actions/SubstractSpectrumAction.java index 28247ff6..7c0c5de7 100644 --- a/numass-main/src/main/java/inr/numass/actions/SubstractSpectrumAction.java +++ b/numass-main/src/main/java/inr/numass/actions/SubstractSpectrumAction.java @@ -49,7 +49,7 @@ public class SubstractSpectrumAction extends OneToOneAction { Table res = builder.build(); OutputStream stream = buildActionOutput(context, name); - ColumnedDataWriter.writeDataSet(stream, res, inputMeta.toString()); + ColumnedDataWriter.writeTable(stream, res, inputMeta.toString()); return res; } catch (IOException ex) { throw new RuntimeException("Could not read reference file", ex); diff --git a/numass-main/src/main/java/inr/numass/actions/SummaryAction.java b/numass-main/src/main/java/inr/numass/actions/SummaryAction.java index ae5e338c..033293ea 100644 --- a/numass-main/src/main/java/inr/numass/actions/SummaryAction.java +++ b/numass-main/src/main/java/inr/numass/actions/SummaryAction.java @@ -113,7 +113,7 @@ public class SummaryAction extends ManyToOneAction { @Override protected void afterGroup(Context context, String groupName, Meta outputMeta, Table output) { OutputStream stream = buildActionOutput(context, groupName); - ColumnedDataWriter.writeDataSet(stream, output, groupName); + ColumnedDataWriter.writeTable(stream, output, groupName); super.afterGroup(context, groupName, outputMeta, output); } diff --git a/numass-main/src/main/java/inr/numass/data/ESpectrum.java b/numass-main/src/main/java/inr/numass/data/ESpectrum.java deleted file mode 100644 index fda7264e..00000000 --- a/numass-main/src/main/java/inr/numass/data/ESpectrum.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2015 Alexander Nozik. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package inr.numass.data; - -import hep.dataforge.io.ColumnedDataWriter; -import hep.dataforge.tables.MapPoint; -import hep.dataforge.tables.SimplePointSource; -import hep.dataforge.tables.TableFormat; -import hep.dataforge.tables.TableFormatBuilder; -import hep.dataforge.values.Value; -import hep.dataforge.values.ValueType; -import inr.numass.storage.NumassPoint; - -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * - * @author Darksnake - */ -public class ESpectrum extends SimplePointSource { - - private final static String binCenter = "chanel"; - int binning = 1; - - public ESpectrum(List points, int binning, boolean normalize) { - super(prepareFormat(points)); - this.binning = binning; - fill(points, normalize); - } - - private static TableFormat prepareFormat(List points) { - TableFormatBuilder builder = new TableFormatBuilder(); - - builder.addString(binCenter); - points.stream().forEach((point) -> { - builder.addColumn(format("%.3f", point.getUread()), 10, ValueType.NUMBER); - }); - - return builder.build(); - } - - private void fill(List points, boolean normalize) { - assert !points.isEmpty(); - - List> spectra = new ArrayList<>(); - - for (NumassPoint numassPoint : points) { - spectra.add(numassPoint.getMap(binning, normalize)); - } - - for (Double x : spectra.get(0).keySet()) { - Map res = new HashMap<>(); - res.put(binCenter, Value.of(x)); - for (int j = 0; j < points.size(); j++) { - res.put(format("%.3f", points.get(j).getUread()), Value.of(spectra.get(j).get(x))); - } - this.addRow(new MapPoint(res)); - - } - } - - public void printToFile(OutputStream stream) { - ColumnedDataWriter.writeDataSet(stream, this, null); -// new ColumnedDataWriter(stream, this.getFormat().asArray()).writeDataSet(this, null); - } - -} diff --git a/numass-main/src/main/java/inr/numass/data/ESpectrumUtils.java b/numass-main/src/main/java/inr/numass/data/ESpectrumUtils.java deleted file mode 100644 index db9cc28a..00000000 --- a/numass-main/src/main/java/inr/numass/data/ESpectrumUtils.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2015 Alexander Nozik. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package inr.numass.data; - -import static java.lang.Math.max; - -/** - * инструменты для работы с энергитическим спектром (который в каналах) - * @author Darksnake - */ -public class ESpectrumUtils { - public static int[] substract(int[] sp1, int[] sp2) { - return substract(sp1, sp2, 0, sp1.length); - } - - public static int[] substract(int[] sp1, int[] sp2, int from, int to) { - assert sp1.length == sp2.length; - assert to >= from; - assert to <= sp1.length; - - int[] res = new int[sp1.length]; - for (int i = from; i < to; i++) { - res[i] = max(0, sp1[i]-sp2[i]); - } - return res; - } - - -} diff --git a/numass-main/src/main/java/inr/numass/data/NumassPawReader.java b/numass-main/src/main/java/inr/numass/data/NumassPawReader.java index 4c2b00e3..01c72275 100644 --- a/numass-main/src/main/java/inr/numass/data/NumassPawReader.java +++ b/numass-main/src/main/java/inr/numass/data/NumassPawReader.java @@ -15,8 +15,8 @@ */ package inr.numass.data; -import inr.numass.storage.RawNMFile; import hep.dataforge.data.binary.Binary; + import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; diff --git a/numass-main/src/main/java/inr/numass/data/SpectrumInformation.java b/numass-main/src/main/java/inr/numass/data/SpectrumInformation.java index cd01b1a5..675fa95a 100644 --- a/numass-main/src/main/java/inr/numass/data/SpectrumInformation.java +++ b/numass-main/src/main/java/inr/numass/data/SpectrumInformation.java @@ -15,17 +15,17 @@ */ package inr.numass.data; -import hep.dataforge.stat.parametric.ParametricFunction; -import static hep.dataforge.maths.MatrixOperations.inverse; import hep.dataforge.maths.NamedMatrix; +import hep.dataforge.stat.parametric.ParametricFunction; import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.ListTable; import hep.dataforge.values.NamedValueSet; -import inr.numass.utils.TritiumUtils; import org.apache.commons.math3.analysis.UnivariateFunction; import org.apache.commons.math3.linear.Array2DRowRealMatrix; import org.apache.commons.math3.linear.RealMatrix; +import static hep.dataforge.maths.MatrixOperations.inverse; + /** * * @author Darksnake @@ -57,7 +57,7 @@ public class SpectrumInformation { * @return */ public NamedMatrix getInformationMatrix(NamedValueSet set, ListTable data, String... parNames) { - SpectrumDataAdapter reader = TritiumUtils.adapter(); + SpectrumDataAdapter reader = NumassDataUtils.adapter(); String[] names = parNames; if (names.length == 0) { diff --git a/numass-main/src/main/java/inr/numass/debunch/DebunchData.java b/numass-main/src/main/java/inr/numass/debunch/DebunchData.java index b50a745e..05f1931f 100644 --- a/numass-main/src/main/java/inr/numass/debunch/DebunchData.java +++ b/numass-main/src/main/java/inr/numass/debunch/DebunchData.java @@ -15,8 +15,9 @@ */ package inr.numass.debunch; -import inr.numass.storage.NMEvent; -import inr.numass.storage.RawNMPoint; +import inr.numass.data.NMEvent; +import inr.numass.data.RawNMPoint; + import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; diff --git a/numass-main/src/main/java/inr/numass/debunch/DebunchEvent.java b/numass-main/src/main/java/inr/numass/debunch/DebunchEvent.java index b9f4e54b..85636853 100644 --- a/numass-main/src/main/java/inr/numass/debunch/DebunchEvent.java +++ b/numass-main/src/main/java/inr/numass/debunch/DebunchEvent.java @@ -15,7 +15,7 @@ */ package inr.numass.debunch; -import inr.numass.storage.NMEvent; +import inr.numass.data.NMEvent; /** * diff --git a/numass-main/src/main/java/inr/numass/debunch/DebunchReport.java b/numass-main/src/main/java/inr/numass/debunch/DebunchReport.java index f0445ad4..c6a9e418 100644 --- a/numass-main/src/main/java/inr/numass/debunch/DebunchReport.java +++ b/numass-main/src/main/java/inr/numass/debunch/DebunchReport.java @@ -15,8 +15,9 @@ */ package inr.numass.debunch; -import inr.numass.storage.NMEvent; -import inr.numass.storage.RawNMPoint; +import inr.numass.data.NMEvent; +import inr.numass.data.RawNMPoint; + import java.util.List; /** diff --git a/numass-main/src/main/java/inr/numass/debunch/DebunchReportImpl.java b/numass-main/src/main/java/inr/numass/debunch/DebunchReportImpl.java index 57e00c6b..485ff9f1 100644 --- a/numass-main/src/main/java/inr/numass/debunch/DebunchReportImpl.java +++ b/numass-main/src/main/java/inr/numass/debunch/DebunchReportImpl.java @@ -15,8 +15,9 @@ */ package inr.numass.debunch; -import inr.numass.storage.NMEvent; -import inr.numass.storage.RawNMPoint; +import inr.numass.data.NMEvent; +import inr.numass.data.RawNMPoint; + import java.util.ArrayList; import java.util.List; diff --git a/numass-main/src/main/java/inr/numass/debunch/Debuncher.java b/numass-main/src/main/java/inr/numass/debunch/Debuncher.java index 6f198fd0..27ff0578 100644 --- a/numass-main/src/main/java/inr/numass/debunch/Debuncher.java +++ b/numass-main/src/main/java/inr/numass/debunch/Debuncher.java @@ -15,7 +15,7 @@ */ package inr.numass.debunch; -import inr.numass.storage.RawNMPoint; +import inr.numass.data.RawNMPoint; /** * diff --git a/numass-main/src/main/java/inr/numass/debunch/Frame.java b/numass-main/src/main/java/inr/numass/debunch/Frame.java index 008c3dc8..ef0b88a2 100644 --- a/numass-main/src/main/java/inr/numass/debunch/Frame.java +++ b/numass-main/src/main/java/inr/numass/debunch/Frame.java @@ -15,10 +15,11 @@ */ package inr.numass.debunch; -import inr.numass.storage.NMEvent; +import inr.numass.data.NMEvent; +import org.apache.commons.math3.distribution.PoissonDistribution; + import java.util.ArrayList; import java.util.List; -import org.apache.commons.math3.distribution.PoissonDistribution; /** * diff --git a/numass-main/src/main/java/inr/numass/debunch/FrameAnalizer.java b/numass-main/src/main/java/inr/numass/debunch/FrameAnalizer.java index 5232ec86..7c381af3 100644 --- a/numass-main/src/main/java/inr/numass/debunch/FrameAnalizer.java +++ b/numass-main/src/main/java/inr/numass/debunch/FrameAnalizer.java @@ -15,7 +15,7 @@ */ package inr.numass.debunch; -import inr.numass.storage.RawNMPoint; +import inr.numass.data.RawNMPoint; import org.apache.commons.math3.analysis.UnivariateFunction; import org.apache.commons.math3.analysis.interpolation.LinearInterpolator; import org.apache.commons.math3.util.FastMath; diff --git a/numass-main/src/main/java/inr/numass/tasks/NumassFitScanSummaryTask.java b/numass-main/src/main/java/inr/numass/tasks/NumassFitScanSummaryTask.java index 3284b18d..dccbe48f 100644 --- a/numass-main/src/main/java/inr/numass/tasks/NumassFitScanSummaryTask.java +++ b/numass-main/src/main/java/inr/numass/tasks/NumassFitScanSummaryTask.java @@ -85,7 +85,7 @@ public class NumassFitScanSummaryTask extends AbstractTask
{ try (OutputStream stream = buildActionOutput(context, nodeName)) { String head = "Sterile neutrino mass scan summary\n" + meta.toString(); - ColumnedDataWriter.writeDataSet(stream, res, head); + ColumnedDataWriter.writeTable(stream, res, head); } catch (IOException e) { getLogger(meta).error("Failed to close output stream", e); } diff --git a/numass-main/src/main/java/inr/numass/tasks/NumassPrepareTask.java b/numass-main/src/main/java/inr/numass/tasks/NumassPrepareTask.java index a1b4f630..4e274baa 100644 --- a/numass-main/src/main/java/inr/numass/tasks/NumassPrepareTask.java +++ b/numass-main/src/main/java/inr/numass/tasks/NumassPrepareTask.java @@ -19,7 +19,7 @@ import hep.dataforge.workspace.TaskModel; import inr.numass.actions.MergeDataAction; import inr.numass.actions.MonitorCorrectAction; import inr.numass.actions.PrepareDataAction; -import inr.numass.storage.NumassData; +import inr.numass.data.NumassData; /** * Prepare data task diff --git a/numass-main/src/main/java/inr/numass/tasks/NumassSubstractEmptySourceTask.java b/numass-main/src/main/java/inr/numass/tasks/NumassSubstractEmptySourceTask.java index 240df43c..64dab317 100644 --- a/numass-main/src/main/java/inr/numass/tasks/NumassSubstractEmptySourceTask.java +++ b/numass-main/src/main/java/inr/numass/tasks/NumassSubstractEmptySourceTask.java @@ -53,7 +53,7 @@ public class NumassSubstractEmptySourceTask extends AbstractTask
{ res.getGoal().onComplete((r, err) -> { if (r != null) { OutputStream out = model.getContext().io().out("merge", input.getName() + ".subtract"); - ColumnedDataWriter.writeDataSet(out, r, + ColumnedDataWriter.writeTable(out, r, input.meta().getBuilder().setNode("empty", emptySource.meta()).toString()); } }); diff --git a/numass-main/src/main/java/inr/numass/utils/BunchGenerator.java b/numass-main/src/main/java/inr/numass/utils/BunchGenerator.java index 463ceb02..535353e1 100644 --- a/numass-main/src/main/java/inr/numass/utils/BunchGenerator.java +++ b/numass-main/src/main/java/inr/numass/utils/BunchGenerator.java @@ -15,13 +15,14 @@ */ package inr.numass.utils; -import inr.numass.storage.NMEvent; -import inr.numass.storage.RawNMPoint; -import java.util.ArrayList; +import inr.numass.data.NMEvent; +import inr.numass.data.RawNMPoint; import org.apache.commons.math3.random.MersenneTwister; import org.apache.commons.math3.random.RandomGenerator; import org.apache.commons.math3.random.SynchronizedRandomGenerator; +import java.util.ArrayList; + /** * * @author Darksnake diff --git a/numass-main/src/main/java/inr/numass/utils/NMEventGenerator.java b/numass-main/src/main/java/inr/numass/utils/NMEventGenerator.java index 5c66b941..73d0feef 100644 --- a/numass-main/src/main/java/inr/numass/utils/NMEventGenerator.java +++ b/numass-main/src/main/java/inr/numass/utils/NMEventGenerator.java @@ -16,9 +16,9 @@ package inr.numass.utils; import hep.dataforge.meta.Meta; -import inr.numass.storage.NMEvent; -import inr.numass.storage.NumassPoint; -import inr.numass.storage.RawNMPoint; +import inr.numass.data.NMEvent; +import inr.numass.data.NumassPoint; +import inr.numass.data.RawNMPoint; import org.apache.commons.math3.distribution.EnumeratedRealDistribution; import org.apache.commons.math3.distribution.RealDistribution; import org.apache.commons.math3.random.EmpiricalDistribution; diff --git a/numass-main/src/main/java/inr/numass/utils/NMEventGeneratorWithPulser.java b/numass-main/src/main/java/inr/numass/utils/NMEventGeneratorWithPulser.java index 1cb13f8d..aa47cfe5 100644 --- a/numass-main/src/main/java/inr/numass/utils/NMEventGeneratorWithPulser.java +++ b/numass-main/src/main/java/inr/numass/utils/NMEventGeneratorWithPulser.java @@ -1,7 +1,7 @@ package inr.numass.utils; import hep.dataforge.meta.Meta; -import inr.numass.storage.NMEvent; +import inr.numass.data.NMEvent; import org.apache.commons.math3.distribution.NormalDistribution; import org.apache.commons.math3.distribution.RealDistribution; import org.apache.commons.math3.random.RandomGenerator; diff --git a/numass-main/src/main/java/inr/numass/utils/PileUpSimulator.java b/numass-main/src/main/java/inr/numass/utils/PileUpSimulator.java index 36669ae6..920860e1 100644 --- a/numass-main/src/main/java/inr/numass/utils/PileUpSimulator.java +++ b/numass-main/src/main/java/inr/numass/utils/PileUpSimulator.java @@ -5,10 +5,10 @@ */ package inr.numass.utils; -import inr.numass.storage.NMEvent; -import inr.numass.storage.NMPoint; -import inr.numass.storage.NumassPoint; -import inr.numass.storage.RawNMPoint; +import inr.numass.data.NMEvent; +import inr.numass.data.NumassPoint; +import inr.numass.data.PointBuilders; +import inr.numass.data.RawNMPoint; import org.apache.commons.math3.random.RandomGenerator; import java.util.ArrayList; @@ -55,15 +55,15 @@ public class PileUpSimulator { } public NumassPoint generated() { - return new NMPoint(new RawNMPoint(uSet, generated, pointLength)); + return PointBuilders.readRawPoint(new RawNMPoint(uSet, generated, pointLength)); } public NumassPoint registered() { - return new NMPoint(new RawNMPoint(uSet, registered, pointLength)); + return PointBuilders.readRawPoint(new RawNMPoint(uSet, registered, pointLength)); } public NumassPoint pileup() { - return new NMPoint(new RawNMPoint(uSet, pileup, pointLength)); + return PointBuilders.readRawPoint(new RawNMPoint(uSet, pileup, pointLength)); } /** diff --git a/numass-main/src/main/java/inr/numass/utils/TritiumUtils.java b/numass-main/src/main/java/inr/numass/utils/TritiumUtils.java index fe364172..484b4481 100644 --- a/numass-main/src/main/java/inr/numass/utils/TritiumUtils.java +++ b/numass-main/src/main/java/inr/numass/utils/TritiumUtils.java @@ -15,11 +15,7 @@ */ package inr.numass.utils; -import hep.dataforge.tables.DataPoint; -import hep.dataforge.tables.ListTable; -import hep.dataforge.tables.Table; -import inr.numass.data.SpectrumDataAdapter; -import inr.numass.storage.NumassPoint; +import inr.numass.data.NumassPoint; import org.apache.commons.math3.analysis.UnivariateFunction; import java.util.HashMap; @@ -32,48 +28,6 @@ import static java.lang.Math.*; */ public class TritiumUtils { - public static Table correctForDeadTime(ListTable data, double dtime) { - return correctForDeadTime(data, adapter(), dtime); - } - - /** - * Коррекция на мертвое время в секундах - * - * @param data - * @param dtime - * @return - */ - public static Table correctForDeadTime(ListTable data, SpectrumDataAdapter adapter, double dtime) { -// SpectrumDataAdapter adapter = adapter(); - ListTable.Builder res = new ListTable.Builder(data.getFormat()); - for (DataPoint dp : data) { - double corrFactor = 1 / (1 - dtime * adapter.getCount(dp) / adapter.getTime(dp)); - res.row(adapter.buildSpectrumDataPoint(adapter.getX(dp).doubleValue(), (long) (adapter.getCount(dp) * corrFactor), adapter.getTime(dp))); - } - return res.build(); - } - - /** - * Поправка масштаба высокого. - * - * @param data - * @param beta - * @return - */ - public static Table setHVScale(ListTable data, double beta) { - SpectrumDataAdapter reader = adapter(); - ListTable.Builder res = new ListTable.Builder(data.getFormat()); - for (DataPoint dp : data) { - double corrFactor = 1 + beta; - res.row(reader.buildSpectrumDataPoint(reader.getX(dp).doubleValue() * corrFactor, reader.getCount(dp), reader.getTime(dp))); - } - return res.build(); - } - - public static SpectrumDataAdapter adapter() { - return new SpectrumDataAdapter("Uset", "CR", "CRerr", "Time"); - } - /** * Integral beta spectrum background with given amplitude (total count rate * from) @@ -107,24 +61,6 @@ public class TritiumUtils { return res * 1E-23; } - public static double countRateWithDeadTime(NumassPoint p, int from, int to, double deadTime) { - double wind = p.getCountInWindow(from, to) / p.getLength(); - double res; - if (deadTime > 0) { - double total = p.getTotalCount(); -// double time = p.getLength(); -// res = wind / (1 - total * deadTime / time); - double timeRatio = deadTime / p.getLength(); - res = wind / total * (1d - Math.sqrt(1d - 4d * total * timeRatio)) / 2d / timeRatio; - } else { - res = wind; - } - return res; - } - - public static double countRateWithDeadTimeErr(NumassPoint p, int from, int to, double deadTime) { - return Math.sqrt(countRateWithDeadTime(p, from, to, deadTime) / p.getLength()); - } /** * Evaluate groovy expression using numass point as parameter @@ -136,7 +72,7 @@ public class TritiumUtils { public static double pointExpression(String expression, NumassPoint point) { Map exprParams = new HashMap<>(); exprParams.put("T", point.getLength()); - exprParams.put("U", point.getUread()); + exprParams.put("U", point.getVoltage()); exprParams.put("cr", ((double) point.getTotalCount()) / point.getLength()); exprParams.put("point", point); return ExpressionUtils.function(expression, exprParams); diff --git a/numass-main/src/main/java/inr/numass/utils/UnderflowCorrection.java b/numass-main/src/main/java/inr/numass/utils/UnderflowCorrection.java index 850a2343..e9251335 100644 --- a/numass-main/src/main/java/inr/numass/utils/UnderflowCorrection.java +++ b/numass-main/src/main/java/inr/numass/utils/UnderflowCorrection.java @@ -9,7 +9,7 @@ import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.ListTable; import hep.dataforge.tables.MapPoint; import hep.dataforge.tables.Table; -import inr.numass.storage.NumassPoint; +import inr.numass.data.NumassPoint; import org.apache.commons.math3.analysis.ParametricUnivariateFunction; import org.apache.commons.math3.exception.DimensionMismatchException; import org.apache.commons.math3.fitting.SimpleCurveFitter; diff --git a/numass-storage/numass-server/build.gradle b/numass-server/build.gradle similarity index 89% rename from numass-storage/numass-server/build.gradle rename to numass-server/build.gradle index 7fc3c30a..c203ec7c 100644 --- a/numass-storage/numass-server/build.gradle +++ b/numass-server/build.gradle @@ -17,7 +17,7 @@ apply plugin: 'com.github.johnrengelman.shadow' mainClassName = "inr.numass.server.ServerRunner" dependencies { - compile project(':numass-storage') + compile project(':numass-core') compile "hep.dataforge:storage-servlet" // project(':dataforge-storage:storage-servlet') compile 'commons-daemon:commons-daemon:1.+' } diff --git a/numass-storage/numass-server/src/main/java/inr/numass/server/HandlerUtils.java b/numass-server/src/main/java/inr/numass/server/HandlerUtils.java similarity index 100% rename from numass-storage/numass-server/src/main/java/inr/numass/server/HandlerUtils.java rename to numass-server/src/main/java/inr/numass/server/HandlerUtils.java diff --git a/numass-storage/numass-server/src/main/java/inr/numass/server/NumassNote.java b/numass-server/src/main/java/inr/numass/server/NumassNote.java similarity index 100% rename from numass-storage/numass-server/src/main/java/inr/numass/server/NumassNote.java rename to numass-server/src/main/java/inr/numass/server/NumassNote.java diff --git a/numass-storage/numass-server/src/main/java/inr/numass/server/NumassRootHandler.java b/numass-server/src/main/java/inr/numass/server/NumassRootHandler.java similarity index 100% rename from numass-storage/numass-server/src/main/java/inr/numass/server/NumassRootHandler.java rename to numass-server/src/main/java/inr/numass/server/NumassRootHandler.java diff --git a/numass-storage/numass-server/src/main/java/inr/numass/server/NumassRun.java b/numass-server/src/main/java/inr/numass/server/NumassRun.java similarity index 100% rename from numass-storage/numass-server/src/main/java/inr/numass/server/NumassRun.java rename to numass-server/src/main/java/inr/numass/server/NumassRun.java diff --git a/numass-storage/numass-server/src/main/java/inr/numass/server/NumassServer.java b/numass-server/src/main/java/inr/numass/server/NumassServer.java similarity index 100% rename from numass-storage/numass-server/src/main/java/inr/numass/server/NumassServer.java rename to numass-server/src/main/java/inr/numass/server/NumassServer.java diff --git a/numass-storage/numass-server/src/main/java/inr/numass/server/NumassServerDaemon.java b/numass-server/src/main/java/inr/numass/server/NumassServerDaemon.java similarity index 100% rename from numass-storage/numass-server/src/main/java/inr/numass/server/NumassServerDaemon.java rename to numass-server/src/main/java/inr/numass/server/NumassServerDaemon.java diff --git a/numass-storage/numass-server/src/main/java/inr/numass/server/NumassServerUtils.java b/numass-server/src/main/java/inr/numass/server/NumassServerUtils.java similarity index 100% rename from numass-storage/numass-server/src/main/java/inr/numass/server/NumassServerUtils.java rename to numass-server/src/main/java/inr/numass/server/NumassServerUtils.java diff --git a/numass-storage/numass-server/src/main/java/inr/numass/server/NumassStorageHandler.java b/numass-server/src/main/java/inr/numass/server/NumassStorageHandler.java similarity index 96% rename from numass-storage/numass-server/src/main/java/inr/numass/server/NumassStorageHandler.java rename to numass-server/src/main/java/inr/numass/server/NumassStorageHandler.java index de15c808..b7b45f1f 100644 --- a/numass-storage/numass-server/src/main/java/inr/numass/server/NumassStorageHandler.java +++ b/numass-server/src/main/java/inr/numass/server/NumassStorageHandler.java @@ -12,7 +12,7 @@ import hep.dataforge.storage.api.PointLoader; import hep.dataforge.storage.api.Storage; import hep.dataforge.storage.servlet.ServletUtils; import hep.dataforge.storage.servlet.StorageRatpackHandler; -import inr.numass.storage.NumassData; +import inr.numass.data.NumassData; import org.slf4j.LoggerFactory; import ratpack.handling.Context; diff --git a/numass-storage/numass-server/src/main/java/inr/numass/server/ServerRunner.java b/numass-server/src/main/java/inr/numass/server/ServerRunner.java similarity index 100% rename from numass-storage/numass-server/src/main/java/inr/numass/server/ServerRunner.java rename to numass-server/src/main/java/inr/numass/server/ServerRunner.java diff --git a/numass-storage/numass-server/src/main/java/inr/numass/server/UnknownNumassActionException.java b/numass-server/src/main/java/inr/numass/server/UnknownNumassActionException.java similarity index 100% rename from numass-storage/numass-server/src/main/java/inr/numass/server/UnknownNumassActionException.java rename to numass-server/src/main/java/inr/numass/server/UnknownNumassActionException.java diff --git a/numass-storage/numass-server/src/main/resources/templates/NoteLoader.ftl b/numass-server/src/main/resources/templates/NoteLoader.ftl similarity index 100% rename from numass-storage/numass-server/src/main/resources/templates/NoteLoader.ftl rename to numass-server/src/main/resources/templates/NoteLoader.ftl diff --git a/numass-storage/numass-server/src/main/resources/templates/NumassLoader.ftl b/numass-server/src/main/resources/templates/NumassLoader.ftl similarity index 100% rename from numass-storage/numass-server/src/main/resources/templates/NumassLoader.ftl rename to numass-server/src/main/resources/templates/NumassLoader.ftl diff --git a/numass-storage/numass-server/src/main/resources/templates/NumassRoot.ftl b/numass-server/src/main/resources/templates/NumassRoot.ftl similarity index 100% rename from numass-storage/numass-server/src/main/resources/templates/NumassRoot.ftl rename to numass-server/src/main/resources/templates/NumassRoot.ftl diff --git a/numass-storage/src/main/java/inr/numass/storage/NumassDataUtils.java b/numass-storage/src/main/java/inr/numass/storage/NumassDataUtils.java deleted file mode 100644 index 27b23286..00000000 --- a/numass-storage/src/main/java/inr/numass/storage/NumassDataUtils.java +++ /dev/null @@ -1,69 +0,0 @@ -package inr.numass.storage; - -import java.time.Instant; -import java.util.Arrays; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * Created by darksnake on 30-Jan-17. - */ -public class NumassDataUtils { - - public static Collection joinSpectra(Stream spectra) { - Map map = new LinkedHashMap<>(); - spectra.forEach(datum -> { - datum.forEach(point -> { - double uset = point.getVoltage(); - if (map.containsKey(uset)) { - map.put(uset, join(point, map.get(uset))); - } else { - map.put(uset, point); - } - }); - }); - return map.values(); - } - - /** - * Spectral sum of two points - * - * @param first - * @param second - * @return - */ - public static NumassPoint join(NumassPoint first, NumassPoint second) { - if (first.getVoltage() != second.getVoltage()) { - throw new RuntimeException("Voltage mismatch"); - } - int[] newArray = new int[first.getSpectrum().length]; - Arrays.setAll(newArray, i -> first.getSpectrum()[i] + second.getSpectrum()[i]); - return new NMPoint( - first.getVoltage(), - Instant.EPOCH, - first.getLength() + second.getLength(), - newArray - ); - } - - public static NumassPoint substractPoint(NumassPoint point, NumassPoint reference) { - int[] array = new int[point.getSpectrum().length]; - Arrays.setAll(array, i -> Math.max(0, point.getSpectrum()[i] - reference.getSpectrum()[i])); - return new NMPoint( - point.getVoltage(), - point.getStartTime(), - point.getLength(), - array - ); - } - - public static Collection substractReferencePoint(Collection points, double uset) { - NumassPoint reference = points.stream().filter(it -> it.getVoltage() == uset).findFirst() - .orElseThrow(() -> new RuntimeException("Reference point not found")); - return points.stream().map(it -> substractPoint(it, reference)).collect(Collectors.toList()); - } - -} diff --git a/numass-storage/src/main/java/inr/numass/storage/ProtoUtils.java b/numass-storage/src/main/java/inr/numass/storage/ProtoUtils.java deleted file mode 100644 index 0d682a02..00000000 --- a/numass-storage/src/main/java/inr/numass/storage/ProtoUtils.java +++ /dev/null @@ -1,22 +0,0 @@ -package inr.numass.storage; - -/** - * Created by darksnake on 13-Apr-17. - */ -public class ProtoUtils { -// public static NumassPoint readProtoPoint(InputStream stream, Function peakFinder) throws IOException { -// Point point = NumassProto.Point.parseFrom(stream); -// Channel ch = point.getChannels(0); -// ch.getBlocksList().stream() -// .flatMapToLong(block -> { -// return LongStream.concat( -// block.getPeaks().getAmplitudesList() -// .stream().mapToLong(it -> it.longValue()), -// block.getEventsList().stream() -// .mapToLong(it->) -// ) -// }); -// -// return new NMPoint(); -} -} diff --git a/numass-storage/test/build.gradle b/numass-test/build.gradle similarity index 85% rename from numass-storage/test/build.gradle rename to numass-test/build.gradle index 442b7ef1..280c9304 100644 --- a/numass-storage/test/build.gradle +++ b/numass-test/build.gradle @@ -1,5 +1,8 @@ +apply plugin: 'groovy' + description = "Test module for numass client and server" + task runServer(type: JavaExec) { description 'Start numass server locally' @@ -23,7 +26,7 @@ task runClient(type: JavaExec) { } dependencies { - compile project(':numass-storage:numass-client') - compile project(':numass-storage:numass-server') + compile project(':numass-client') + compile project(':numass-server') compile "hep.dataforge:dataforge-grind" //project(':dataforge-grind') -} \ No newline at end of file +} diff --git a/numass-storage/test/src/main/groovy/inr/numass/scripts/FixStampEndings.groovy b/numass-test/src/main/groovy/inr/numass/scripts/FixStampEndings.groovy similarity index 100% rename from numass-storage/test/src/main/groovy/inr/numass/scripts/FixStampEndings.groovy rename to numass-test/src/main/groovy/inr/numass/scripts/FixStampEndings.groovy diff --git a/numass-storage/test/src/main/groovy/inr/numass/scripts/StartRun.groovy b/numass-test/src/main/groovy/inr/numass/scripts/StartRun.groovy similarity index 100% rename from numass-storage/test/src/main/groovy/inr/numass/scripts/StartRun.groovy rename to numass-test/src/main/groovy/inr/numass/scripts/StartRun.groovy diff --git a/numass-storage/test/src/main/groovy/inr/numass/scripts/TestClient.groovy b/numass-test/src/main/groovy/inr/numass/scripts/TestClient.groovy similarity index 100% rename from numass-storage/test/src/main/groovy/inr/numass/scripts/TestClient.groovy rename to numass-test/src/main/groovy/inr/numass/scripts/TestClient.groovy diff --git a/numass-storage/test/src/main/groovy/inr/numass/scripts/TestFileTransfer.groovy b/numass-test/src/main/groovy/inr/numass/scripts/TestFileTransfer.groovy similarity index 100% rename from numass-storage/test/src/main/groovy/inr/numass/scripts/TestFileTransfer.groovy rename to numass-test/src/main/groovy/inr/numass/scripts/TestFileTransfer.groovy diff --git a/numass-storage/test/src/main/groovy/inr/numass/scripts/TestNotes.groovy b/numass-test/src/main/groovy/inr/numass/scripts/TestNotes.groovy similarity index 100% rename from numass-storage/test/src/main/groovy/inr/numass/scripts/TestNotes.groovy rename to numass-test/src/main/groovy/inr/numass/scripts/TestNotes.groovy diff --git a/numass-storage/test/src/main/groovy/inr/numass/scripts/TestRemoteClient.groovy b/numass-test/src/main/groovy/inr/numass/scripts/TestRemoteClient.groovy similarity index 100% rename from numass-storage/test/src/main/groovy/inr/numass/scripts/TestRemoteClient.groovy rename to numass-test/src/main/groovy/inr/numass/scripts/TestRemoteClient.groovy diff --git a/numass-storage/test/src/main/groovy/inr/numass/scripts/TestServer.groovy b/numass-test/src/main/groovy/inr/numass/scripts/TestServer.groovy similarity index 100% rename from numass-storage/test/src/main/groovy/inr/numass/scripts/TestServer.groovy rename to numass-test/src/main/groovy/inr/numass/scripts/TestServer.groovy diff --git a/numass-storage/test/src/main/groovy/inr/numass/scripts/TestStateChange.groovy b/numass-test/src/main/groovy/inr/numass/scripts/TestStateChange.groovy similarity index 100% rename from numass-storage/test/src/main/groovy/inr/numass/scripts/TestStateChange.groovy rename to numass-test/src/main/groovy/inr/numass/scripts/TestStateChange.groovy diff --git a/numass-storage/test/src/main/groovy/inr/numass/scripts/TestStorageAccess.groovy b/numass-test/src/main/groovy/inr/numass/scripts/TestStorageAccess.groovy similarity index 100% rename from numass-storage/test/src/main/groovy/inr/numass/scripts/TestStorageAccess.groovy rename to numass-test/src/main/groovy/inr/numass/scripts/TestStorageAccess.groovy diff --git a/numass-viewer/build.gradle b/numass-viewer/build.gradle index b425ba63..9b626958 100644 --- a/numass-viewer/build.gradle +++ b/numass-viewer/build.gradle @@ -1,32 +1,27 @@ -apply plugin: 'application' +plugins{ + id "org.jetbrains.kotlin.jvm" version "1.1.1" + id "application" +} if (!hasProperty('mainClass')) { ext.mainClass = 'inr.numass.viewer.Viewer' } mainClassName = mainClass -version = "0.3.7" +version = "0.3.8" description = "The viewer for numass data" -configurations { - compile.exclude module: 'groovy-all' - compile.exclude module: 'groovy' - compile.exclude module: 'fontawesomefx' - compile.exclude module: 'httpclient' - compile.exclude module: 'httpcore' - compile.exclude module: 'shichimifx' - compile.exclude module: 'commons-math3' - compile.exclude module: 'dataforge-fitting' - compile.exclude module: 'dataforge-minuit' - compile.exclude module: 'dataforge-grind' - compile.exclude module: 'grind-terminal' -} +compileKotlin.kotlinOptions.jvmTarget = "1.8" dependencies { - compile project(':numass-main') + compile project(':numass-core') compile "hep.dataforge:plots-jfc" //project(':dataforge-plots:plots-jfc') compile 'com.jcraft:jsch:0.1.54' + + compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.1" + //compile "org.jetbrains.kotlin:kotlin-reflect:1.1.1" + compile "no.tornado:tornadofx:1.7.1" } //shadowJar { diff --git a/numass-viewer/proguard.cfg b/numass-viewer/proguard.cfg deleted file mode 100644 index 7ccc9378..00000000 --- a/numass-viewer/proguard.cfg +++ /dev/null @@ -1,9 +0,0 @@ --injars build\libs\numass-viewer-0.3.1-all.jar --outjars build\libs\numass-viewer-0.3.1-min.jar - --libraryjars 'c:\Program Files\Java\jdk\jre\lib\rt.jar' --libraryjars 'C:\Program Files\Java\jdk\jre\lib\ext\jfxrt.jar' --libraryjars 'C:\Users\darksnake\.posh_gvm\groovy\2.4.6\lib\groovy-2.4.6.jar' - --dontobfuscate --dontwarn \ No newline at end of file diff --git a/numass-viewer/src/main/java/inr/numass/viewer/MainViewerController.java b/numass-viewer/src/main/java/inr/numass/viewer/MainViewerController.java deleted file mode 100644 index d18300cc..00000000 --- a/numass-viewer/src/main/java/inr/numass/viewer/MainViewerController.java +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright 2015 Alexander Nozik. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package inr.numass.viewer; - -import hep.dataforge.context.Context; -import hep.dataforge.context.Global; -import hep.dataforge.exceptions.StorageException; -import hep.dataforge.fx.fragments.FragmentWindow; -import hep.dataforge.fx.fragments.LogFragment; -import hep.dataforge.fx.work.Work; -import hep.dataforge.fx.work.WorkManager; -import hep.dataforge.fx.work.WorkManagerFragment; -import inr.numass.NumassProperties; -import inr.numass.storage.NumassData; -import inr.numass.storage.NumassStorage; -import javafx.application.Platform; -import javafx.event.ActionEvent; -import javafx.fxml.FXML; -import javafx.fxml.Initializable; -import javafx.geometry.Insets; -import javafx.scene.Node; -import javafx.scene.control.*; -import javafx.scene.control.ButtonBar.ButtonData; -import javafx.scene.layout.AnchorPane; -import javafx.scene.layout.GridPane; -import javafx.stage.DirectoryChooser; -import javafx.util.Pair; -import org.controlsfx.control.StatusBar; - -import java.io.File; -import java.net.URL; -import java.util.Optional; -import java.util.ResourceBundle; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * FXML Controller class - * - * @author Alexander Nozik - */ -public class MainViewerController implements Initializable { - - @FXML - private ToggleButton consoleButton; - @FXML - private Button loadDirectoryButton; - - private MspViewController mspController; - - //main pane views - @FXML - private AnchorPane numassLoaderViewContainer; - @FXML - private TreeTableView numassLoaderDataTree; - @FXML - private StatusBar statusBar; - //tabs - @FXML - private TabPane tabPane; - @FXML - private Tab mainTab; - @FXML - private Tab mspTab; - @FXML - private Tab pressuresTab; - @FXML - private Tab temperaturesTab; - @FXML - private Button loadRemoteButton; - @FXML - private Label storagePathLabel; - @FXML - private ToggleButton processManagerButton; - - private WorkManager workManager; - - public static MainViewerController build(NumassStorage root) { - MainViewerController res = new MainViewerController(); - res.setRootStorage(root); - return res; - } - -// private Popup progressPopup; - - /** - * Initializes the controller class. - * - * @param url - * @param rb - */ - @Override - public void initialize(URL url, ResourceBundle rb) { - LogFragment logFragment = new LogFragment(); - logFragment.addRootLogHandler(); - //logFragment.hookStd(); - new FragmentWindow(logFragment).bindTo(consoleButton); - new FragmentWindow(new WorkManagerFragment(getWorkManager())).bindTo(processManagerButton); - - mspController = new MspViewController(getContext()); - this.mspTab.setContent(mspController.getRoot()); - } - - @FXML - private void onLoadDirectory(ActionEvent event) { - - DirectoryChooser chooser = new DirectoryChooser(); - chooser.setTitle("Select numass storage root"); - String storageRoot = NumassProperties.getNumassProperty("numass.storage.root"); - if (storageRoot == null) { - chooser.setInitialDirectory(new File(".").getAbsoluteFile()); - } else { - chooser.setInitialDirectory(new File(storageRoot)); - } - - final File rootDir = chooser.showDialog(((Node) event.getTarget()).getScene().getWindow()); - - if (rootDir != null) { - NumassProperties.setNumassProperty("numass.storage.root", rootDir.getAbsolutePath()); - loadDirectory(rootDir.toURI().toString()); - } - } - - private void loadDirectory(String path) { - getWorkManager().startWork("viewer.loadDirectory", (Work work) -> { - work.setTitle("Load storage (" + path + ")"); - work.setProgress(-1); - work.setStatus("Building numass storage tree..."); - try { - NumassStorage root = NumassStorage.buildNumassRoot(path, true, false); - setRootStorage(root); - Platform.runLater(() -> storagePathLabel.setText("Storage: " + path)); - } catch (Exception ex) { - work.setProgress(0); - work.setStatus("Failed to load storage " + path); - Logger.getLogger(MainViewerController.class.getName()).log(Level.SEVERE, null, ex); - } - }); - } - - private Context getContext() { - return Global.instance(); - } - - private synchronized WorkManager getWorkManager() { - if(workManager == null) { - workManager = new WorkManager(); - workManager.startGlobal(); - } - return workManager; - } - - public void setRootStorage(NumassStorage root) { - - getWorkManager().cleanup(); - getWorkManager().startWork("viewer.storage.load", (Work callback) -> { - callback.setTitle("Fill data to UI (" + root.getName() + ")"); - callback.setProgress(-1); - Platform.runLater(() -> statusBar.setProgress(-1)); - - callback.setStatus("Loading numass storage tree..."); - - try { - new NumassLoaderTreeBuilder().build(callback, numassLoaderDataTree, root, (NumassData loader) -> { - NumassLoaderViewComponent component = new NumassLoaderViewComponent(getContext()); - component.loadData(loader); - numassLoaderViewContainer.getChildren().clear(); - numassLoaderViewContainer.getChildren().add(component); - AnchorPane.setTopAnchor(component, 0.0); - AnchorPane.setRightAnchor(component, 0.0); - AnchorPane.setLeftAnchor(component, 0.0); - AnchorPane.setBottomAnchor(component, 0.0); - numassLoaderViewContainer.requestLayout(); - }); - } catch (StorageException ex) { - Logger.getLogger(MainViewerController.class.getName()).log(Level.SEVERE, null, ex); - } - -// callback.setProgress(1, 1); - Platform.runLater(() -> statusBar.setProgress(0)); - callback.setStatus("Numass storage tree loaded."); - callback.setProgressToMax(); - }); - - - mspController.fillMspData(root); - - pressuresTab.getContent().setVisible(false); - temperaturesTab.getContent().setVisible(false); - - } - - @FXML - private void onLoadRemote(ActionEvent event) { - // Create the custom dialog. - Dialog> dialog = new Dialog<>(); - dialog.setTitle("Remote storage selection"); - dialog.setHeaderText("Select remote storage login options and run"); - - ButtonType loginButtonType = new ButtonType("Load", ButtonData.OK_DONE); - dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL); - - // Create the username and password labels and fields. - GridPane grid = new GridPane(); - grid.setHgap(10); - grid.setVgap(10); - grid.setPadding(new Insets(20, 150, 10, 10)); - - TextField storageText = new TextField(); - storageText.setPrefWidth(350); - storageText.setText("sftp://trdat:Anomaly@192.168.111.1"); - TextField runText = new TextField(); - runText.setPromptText("Run name"); - - grid.add(new Label("Storage path:"), 0, 0); - grid.add(storageText, 1, 0); - grid.add(new Label("Run name:"), 0, 1); - grid.add(runText, 1, 1); - - dialog.getDialogPane().setContent(grid); - - // Request focus on the username field by default. - storageText.requestFocus(); - - // Convert the result to a username-password-pair when the login button is clicked. - dialog.setResultConverter(dialogButton -> { - if (dialogButton == loginButtonType) { - return new Pair<>(storageText.getText(), runText.getText()); - } - return null; - }); - - Optional> result = dialog.showAndWait(); - - if (result.isPresent()) { - String path = result.get().getKey() + "/data/" + result.get().getValue(); - loadDirectory(path); - } - } -} diff --git a/numass-viewer/src/main/java/inr/numass/viewer/NumassLoaderTreeBuilder.java b/numass-viewer/src/main/java/inr/numass/viewer/NumassLoaderTreeBuilder.java deleted file mode 100644 index 6758ed1d..00000000 --- a/numass-viewer/src/main/java/inr/numass/viewer/NumassLoaderTreeBuilder.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright 2015 Alexander Nozik. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package inr.numass.viewer; - -import hep.dataforge.exceptions.StorageException; -import hep.dataforge.fx.work.Work; -import inr.numass.storage.NumassData; -import inr.numass.storage.NumassStorage; -import javafx.application.Platform; -import javafx.beans.property.SimpleStringProperty; -import javafx.scene.control.TreeItem; -import javafx.scene.control.TreeTableColumn; -import javafx.scene.control.TreeTableView; -import javafx.scene.input.MouseEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Consumer; - -/** - * - * @author darksnake - */ -public class NumassLoaderTreeBuilder { - - @SuppressWarnings("unchecked") - public void build(Work callback, - TreeTableView numassLoaderDataTree, - NumassStorage rootStorage, - Consumer numassViewBuilder) throws StorageException { - - TreeItem root = buildNode(rootStorage, numassViewBuilder, callback); - root.setExpanded(true); - - Platform.runLater(() -> { - numassLoaderDataTree.setRoot(root); - - TreeTableColumn numassLoaderNameColumn = new TreeTableColumn<>("name"); - - numassLoaderNameColumn.setCellValueFactory( - (TreeTableColumn.CellDataFeatures param) -> new SimpleStringProperty(param.getValue().getValue().getName())); - - TreeTableColumn numassLoaderTimeColumn = new TreeTableColumn<>("time"); - numassLoaderTimeColumn.setCellValueFactory( - (TreeTableColumn.CellDataFeatures param) -> new SimpleStringProperty(param.getValue().getValue().getTime())); - - TreeTableColumn nummassLoaderDescriptionColumn = new TreeTableColumn<>("description"); - nummassLoaderDescriptionColumn.setCellValueFactory( - (TreeTableColumn.CellDataFeatures param) -> new SimpleStringProperty(param.getValue().getValue().getDescription())); - - numassLoaderDataTree.getColumns().setAll(numassLoaderNameColumn, numassLoaderTimeColumn, nummassLoaderDescriptionColumn); - - numassLoaderNameColumn.setSortType(TreeTableColumn.SortType.ASCENDING); - numassLoaderDataTree.getSortOrder().addAll(numassLoaderTimeColumn, numassLoaderNameColumn); - numassLoaderDataTree.addEventHandler(MouseEvent.MOUSE_CLICKED, (MouseEvent e) -> { - if (e.getClickCount() == 2) { - TreeItemValue value = numassLoaderDataTree.getFocusModel().getFocusedCell().getTreeItem().getValue(); - if (value.isLoader()) { - numassViewBuilder.accept(value.getLoader()); - } - } - }); - numassLoaderTimeColumn.setVisible(false); - nummassLoaderDescriptionColumn.setVisible(false); - }); - - } - - private TreeItem buildNode(NumassStorage storage, - Consumer numassViewBuilder, Work callback) throws StorageException { - TreeItem node = new TreeItem<>(buildValue(storage)); - node.getChildren().setAll(buildChildren(storage, numassViewBuilder, callback)); - return node; - } - - private Logger getLogger() { - return LoggerFactory.getLogger(getClass()); - } - - private List> buildChildren(NumassStorage storage, - Consumer numassViewBuilder, Work callback) throws StorageException { - List> list = new ArrayList<>(); - - storage.shelves().values().stream().forEach(subStorage -> { - if (subStorage instanceof NumassStorage) { - try { - NumassStorage numassSubStorage = (NumassStorage) subStorage; - TreeItem childNode = buildNode(numassSubStorage, numassViewBuilder, callback); - if (!childNode.isLeaf()) { - list.add(buildNode(numassSubStorage, numassViewBuilder, callback)); - } - } catch (StorageException ex) { - getLogger().error("Error while loading numass storage node", ex); - } - } - }); - - callback.setStatus("Building storage " + storage.getName()); - callback.setProgress(0); - callback.setMaxProgress(storage.loaders().size()); - storage.loaders().values().stream() - .forEach(loader -> { - if (loader instanceof NumassData) { - callback.setStatus("Building numass data loader " + loader.getName()); - NumassData numassLoader = (NumassData) loader; - TreeItem numassLoaderTreeItem = new TreeItem<>(buildValue(numassLoader)); - list.add(numassLoaderTreeItem); - } - callback.increaseProgress(1); - }); - - callback.setStatus("Loading legacy DAT files"); - callback.setProgress(0); - List legacyFiles = storage.legacyFiles(); - callback.setMaxProgress(legacyFiles.size()); - //adding legacy data files - for (NumassData legacyDat : legacyFiles) { - callback.setStatus("Loading numass DAT file " + legacyDat.getName()); - TreeItem numassLoaderTreeItem = new TreeItem<>(buildValue(legacyDat)); - callback.increaseProgress(1); - list.add(numassLoaderTreeItem); - } - - return list; - } - - private TreeItemValue buildValue(final NumassStorage storage) { - return new TreeItemValue() { - - @Override - public String getDescription() { - return storage.getDescription(); - } - - @Override - public NumassData getLoader() { - return null; - } - - @Override - public String getName() { - return storage.getName(); - } - - @Override - public NumassStorage getStorage() { - return storage; - } - - @Override - public String getTime() { - if (getStorage().meta().hasValue("file.timeModified")) { - return getStorage().meta().getValue("file.timeModified").stringValue(); - } else { - return null; - } - } - - @Override - public boolean isLoader() { - return false; - } - }; - } - - private TreeItemValue buildValue(final NumassData loader) { - return new TreeItemValue() { - - @Override - public String getDescription() { - return loader.getDescription(); - } - - @Override - public NumassData getLoader() { - return loader; - } - - @Override - public String getName() { -// if (loader.meta().getBoolean("reverse", false)) { -// return loader.getName() + " \u2191"; -// } else { -// return loader.getName(); -// } - return loader.getName(); - } - - @Override - public NumassStorage getStorage() { - return null; - } - - @Override - public String getTime() { - Instant startTime = loader.startTime(); - if (startTime == null || startTime.equals(Instant.EPOCH)) { - return ""; - } else { - return loader.startTime().toString(); - } - } - - @Override - public boolean isLoader() { - return true; - } - }; - } - - public interface TreeItemValue { - - String getName(); - - String getTime(); - - String getDescription(); - - NumassData getLoader(); - - NumassStorage getStorage(); - - boolean isLoader(); - } -} diff --git a/numass-viewer/src/main/java/inr/numass/viewer/NumassLoaderViewComponent.java b/numass-viewer/src/main/java/inr/numass/viewer/NumassLoaderViewComponent.java deleted file mode 100644 index 04f18f47..00000000 --- a/numass-viewer/src/main/java/inr/numass/viewer/NumassLoaderViewComponent.java +++ /dev/null @@ -1,433 +0,0 @@ -/* - * Copyright 2015 Alexander Nozik. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package inr.numass.viewer; - -import hep.dataforge.context.Context; -import hep.dataforge.fx.work.Work; -import hep.dataforge.fx.work.WorkManager; -import hep.dataforge.io.ColumnedDataWriter; -import hep.dataforge.meta.Meta; -import hep.dataforge.meta.MetaBuilder; -import hep.dataforge.plots.XYPlotFrame; -import hep.dataforge.plots.data.PlotDataUtils; -import hep.dataforge.plots.data.PlottableData; -import hep.dataforge.plots.data.PlottableGroup; -import hep.dataforge.plots.data.TimePlottable; -import hep.dataforge.plots.fx.FXPlotFrame; -import hep.dataforge.plots.fx.PlotContainer; -import hep.dataforge.plots.jfreechart.JFreeChartFrame; -import hep.dataforge.storage.commons.JSONMetaWriter; -import hep.dataforge.tables.*; -import inr.numass.storage.NumassData; -import inr.numass.storage.NumassPoint; -import inr.numass.utils.TritiumUtils; -import javafx.application.Platform; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; -import javafx.collections.FXCollections; -import javafx.event.ActionEvent; -import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; -import javafx.fxml.Initializable; -import javafx.geometry.Insets; -import javafx.geometry.Orientation; -import javafx.scene.control.*; -import javafx.scene.layout.AnchorPane; -import javafx.stage.FileChooser; -import javafx.util.converter.NumberStringConverter; -import org.controlsfx.control.RangeSlider; -import org.controlsfx.validation.ValidationSupport; -import org.controlsfx.validation.Validator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.List; -import java.util.ResourceBundle; -import java.util.function.Predicate; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -/** - * FXML Controller class - * - * @author darksnake - */ -public class NumassLoaderViewComponent extends AnchorPane implements Initializable { - - private final Context context; - - Logger logger = LoggerFactory.getLogger(NumassLoaderViewComponent.class); - private NumassData data; - private PlotContainer detectorPlot; - private PlotContainer spectrumPlot; - private PlotContainer hvPlot; - private PlottableData spectrumData; - private List points; - private ChoiceBox detectorBinningSelector; - private CheckBox detectorNormalizeSwitch; - private Button detectorDataExportButton; - - @FXML - private AnchorPane detectorPlotPane; -// @FXML -// private CheckListView detectorPointListView; - @FXML - private Tab detectorTab; -// @FXML -// private Tab hvTab; -// @FXML -// private Tab spectrumTab; - @FXML - private TextArea infoTextBox; - @FXML - private AnchorPane spectrumPlotPane; -// @FXML -// private VBox spectrumOptionsPane; - @FXML - private TextField lowChannelField; - @FXML - private TextField upChannelField; - @FXML - private RangeSlider channelSlider; -// @FXML -// private Button spectrumExportButton; - @FXML - private TextField dTimeField; - @FXML - private AnchorPane hvPane; - - public NumassLoaderViewComponent(Context context) { - this.context = context; - FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/NumassLoaderView.fxml")); - - loader.setRoot(this); - loader.setController(this); - - try { - loader.load(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - - /** - * Initializes the controller class. - * - * @param url - * @param rb - */ - @Override - public void initialize(URL url, ResourceBundle rb) { - //setup detector pane plot and sidebar - Label l = new Label("Bin size:"); - l.setPadding(new Insets(5)); - detectorBinningSelector = new ChoiceBox<>(FXCollections.observableArrayList(1, 2, 5, 10, 20, 50)); - detectorBinningSelector.setMaxWidth(Double.MAX_VALUE); - detectorBinningSelector.getSelectionModel().select(4); - - detectorNormalizeSwitch = new CheckBox("Normailize"); - detectorNormalizeSwitch.setSelected(true); - detectorNormalizeSwitch.setPadding(new Insets(5)); - - detectorPlot = PlotContainer.anchorTo(detectorPlotPane); - detectorPlot.addToSideBar(0, l, detectorBinningSelector, detectorNormalizeSwitch, new Separator(Orientation.HORIZONTAL)); - - detectorDataExportButton = new Button("Export"); - detectorDataExportButton.setMaxWidth(Double.MAX_VALUE); - detectorDataExportButton.setOnAction(this::onExportButtonClick); - detectorPlot.addToSideBar(detectorDataExportButton); - - detectorPlot.setSideBarPosition(0.7); - //setup spectrum pane - spectrumPlot = PlotContainer.anchorTo(spectrumPlotPane); - - Meta spectrumPlotMeta = new MetaBuilder("plot") - .setValue("xAxis.axisTitle", "U") - .setValue("xAxis.axisUnits", "V") - .setValue("yAxis.axisTitle", "count rate") - .setValue("yAxis.axisUnits", "Hz") - .setValue("legend.show", false); - spectrumPlot.setPlot(new JFreeChartFrame(spectrumPlotMeta)); - - lowChannelField.textProperty().bindBidirectional(channelSlider.lowValueProperty(), new NumberStringConverter()); - upChannelField.textProperty().bindBidirectional(channelSlider.highValueProperty(), new NumberStringConverter()); - - channelSlider.setHighValue(1900d); - channelSlider.setLowValue(300d); - - ChangeListener rangeChangeListener = (ObservableValue observable, Number oldValue, Number newValue) -> { - setupSpectrumPane(points); - }; - - dTimeField.textProperty().addListener((ObservableValue observable, String oldValue, String newValue) -> { - setupSpectrumPane(points); - }); - - channelSlider.lowValueProperty().addListener(rangeChangeListener); - channelSlider.highValueProperty().addListener(rangeChangeListener); - - ValidationSupport validationSupport = new ValidationSupport(); - Predicate isNumber = (String t) -> { - try { - Double.parseDouble(t); - return true; - } catch (NumberFormatException | NullPointerException ex) { - return false; - } - }; - - validationSupport.registerValidator(dTimeField, Validator.createPredicateValidator(isNumber, "Must be number")); - - //setup HV plot - hvPlot = PlotContainer.anchorTo(hvPane); - Meta hvPlotMeta = new MetaBuilder("plot") - .setValue("xAxis.axisTitle", "time") - .setValue("xAxis.type", "time") - .setValue("yAxis.axisTitle", "HV"); - hvPlot.setPlot(new JFreeChartFrame(hvPlotMeta)); - } - - public NumassData getData() { - return data; - } - - private WorkManager getWorkManager(){ - return context.getFeature(WorkManager.class); - } - - public void loadData(NumassData data) { - this.data = data; - if (data != null) { - getWorkManager().>startWork("viewer.numass.load", (Work callback) -> { - callback.setTitle("Load numass data (" + data.getName() + ")"); - points = data.getNMPoints(); - - Platform.runLater(() -> { - //setup detector data - setupDetectorPane(points); - //setup spectrum plot - setupSpectrumPane(points); - }); - }); - //setup hv plot - Supplier
hvData = data.getHVData(); - if (hvData != null) { - setupHVPane(hvData); - } - setupInfo(data); - - } else { - logger.error("The data model is null"); - } - detectorTab.getTabPane().getSelectionModel().select(detectorTab); - } - - private void setupHVPane(Supplier
hvData) { - getWorkManager().startWork("viewer.numass.hv", (Work callback) -> { - Table t = hvData.get(); - Platform.runLater(() -> { - if (t != null) { - hvPlot.getPlot().plottables().clear(); - PlottableGroup set = new PlottableGroup<>(); - for (DataPoint dp : t) { - String block = dp.getString("block", "default"); - if (!set.has(block)) { - set.add(new TimePlottable(block, block)); - } - set.get(block).put(dp.getValue("timestamp").timeValue(), dp.getValue("value")); - } - hvPlot.getPlot().addAll(set); - } - }); - }); - } - - /** - * setup detector pane - * - * @param points - */ - private void setupDetectorPane(List points) { - boolean normalize = detectorNormalizeSwitch.isSelected(); - int binning = detectorBinningSelector.getValue(); - updateDetectorPane(points, binning, normalize); - detectorBinningSelector.getSelectionModel().selectedItemProperty() - .addListener((ObservableValue observable, Integer oldValue, Integer newValue) -> { - boolean norm = detectorNormalizeSwitch.isSelected(); - updateDetectorPane(NumassLoaderViewComponent.this.points, newValue, norm); - }); - detectorNormalizeSwitch.selectedProperty().addListener((ObservableValue observable, Boolean oldValue, Boolean newValue) -> { - int bin = detectorBinningSelector.getValue(); - updateDetectorPane(NumassLoaderViewComponent.this.points, bin, newValue); - }); - detectorDataExportButton.setDisable(false); - } - - private void setupInfo(NumassData loader) { - Meta info = loader.meta(); - infoTextBox.setText(new JSONMetaWriter().writeString(info). - replace("\\r", "\r\t").replace("\\n", "\n\t")); - } - - private void setupSpectrumPane(List points) { - if (spectrumData == null) { - spectrumData = new PlottableData("spectrum"); - spectrumPlot.getPlot().add(spectrumData); - } - - int lowChannel = (int) channelSlider.getLowValue(); - int highChannel = (int) channelSlider.getHighValue(); - if (points == null || points.isEmpty()) { - spectrumData.clear(); - } else { - spectrumData.fillData(points.stream() - .map((NumassPoint point) -> getSpectrumPoint(point, lowChannel, highChannel, getDTime())) - .collect(Collectors.toList())); - } - } - - private double getDTime() { - try { - return Double.parseDouble(dTimeField.getText()) * 1e-6; - } catch (NumberFormatException ex) { - return 0; - } - } - - private DataPoint getSpectrumPoint(NumassPoint point, int lowChannel, int upChannel, double dTime) { - double u = point.getUread(); - return new MapPoint(new String[]{XYAdapter.X_VALUE_KEY, XYAdapter.Y_VALUE_KEY, XYAdapter.Y_ERROR_KEY}, u, - TritiumUtils.countRateWithDeadTime(point,lowChannel, upChannel, dTime), - TritiumUtils.countRateWithDeadTimeErr(point,lowChannel, upChannel, dTime)); - } - - /** - * update detector pane with new data - */ - private void updateDetectorPane(List points, int binning, boolean normalize) { - FXPlotFrame detectorPlotFrame; - if (detectorPlot.getPlot() == null) { - Meta frameMeta = new MetaBuilder("frame") - .setValue("title", "Detector response plot") - .setNode(new MetaBuilder("xAxis") - .setValue("axisTitle", "ADC") - .setValue("axisUnits", "channels") - .build()) - .setNode(new MetaBuilder("yAxis") - .setValue("axisTitle", "count rate") - .setValue("axisUnits", "Hz") - .build()) - .setNode(new MetaBuilder("legend") - .setValue("show", false)) - .build(); - detectorPlotFrame = new JFreeChartFrame(frameMeta); - } else { - detectorPlotFrame = detectorPlot.getPlot(); - detectorPlotFrame.clear(); - detectorPlot.removePlot(); - } - - getWorkManager().startWork("viewer.numass.load.detector", (Work callback) -> { - Meta plottableConfig = new MetaBuilder("plot") - .setValue("connectionType", "step") - .setValue("thickness", 2) - .setValue("showLine", true) - .setValue("showSymbol", false) - .setValue("showErrors", false) - .setValue("JFreeChart.cache", true) - .build(); - - callback.setMaxProgress(points.size()); - callback.setProgress(0); - for (NumassPoint point : points) { - String seriesName = String.format("%d: %.2f", points.indexOf(point), point.getVoltage()); - PlottableData datum = PlottableData.plot(seriesName, new XYAdapter("chanel", "count"), point.getData(binning, normalize)); - datum.configure(plottableConfig); - detectorPlotFrame.add(datum); - callback.increaseProgress(1d); - //TODO add update instead of replace action - } - detectorPlot.setPlot(detectorPlotFrame); - callback.setProgressToMax(); - }); - - } - - @FXML - private void onSpectrumExportClick(ActionEvent event) { - if (points != null && !points.isEmpty()) { - FileChooser fileChooser = new FileChooser(); - fileChooser.setTitle("Choose text export destination"); - fileChooser.setInitialFileName(data.getName() + "_spectrum.onComplete"); - File destination = fileChooser.showSaveDialog(spectrumPlotPane.getScene().getWindow()); - if (destination != null) { - String[] names = new String[]{"Uset", "Uread", "Length", "Total", "Window", "CR", "CRerr", "Timestamp"}; - int loChannel = (int) channelSlider.getLowValue(); - int upChannel = (int) channelSlider.getHighValue(); - double dTime = getDTime(); - ListTable.Builder spectrumDataSet = new ListTable.Builder(names); - - for (NumassPoint point : points) { - spectrumDataSet.row(new MapPoint(names, new Object[]{ - point.getVoltage(), - point.getUread(), - point.getLength(), - point.getTotalCount(), - point.getCountInWindow(loChannel, upChannel), - TritiumUtils.countRateWithDeadTime(point,loChannel, upChannel, dTime), - TritiumUtils.countRateWithDeadTimeErr(point,loChannel, upChannel, dTime), - point.getStartTime() - } - )); - } - - try { - String comment = String.format("Numass data viewer spectrum data export for %s%n" - + "Window: (%d, %d)%n" - + "Dead time per event: %g%n", - data.getName(), loChannel, upChannel, dTime); - - ColumnedDataWriter - .writeDataSet(destination, spectrumDataSet.build(), comment, false); - } catch (IOException ex) { - LoggerFactory.getLogger(getClass()).error("Destination file not found", ex); - } - } - } - } - - private void onExportButtonClick(ActionEvent event) { - FileChooser fileChooser = new FileChooser(); - fileChooser.setTitle("Choose text export destination"); - fileChooser.setInitialFileName(data.getName() + "_detector.out"); - File destination = fileChooser.showSaveDialog(detectorPlotPane.getScene().getWindow()); - if (destination != null) { - Table detectorData = PlotDataUtils.collectXYDataFromPlot((XYPlotFrame) detectorPlot.getPlot(), true); - try { - ColumnedDataWriter - .writeDataSet(destination, detectorData, "Numass data viewer detector data export for " + data.getName(), - false); - } catch (IOException ex) { - LoggerFactory.getLogger(getClass()).error("Destination file not found", ex); - } - } - - } - -} diff --git a/numass-viewer/src/main/java/inr/numass/viewer/TestDirectoryViewer.java b/numass-viewer/src/main/java/inr/numass/viewer/TestDirectoryViewer.java index 994393a2..9c4b1dda 100644 --- a/numass-viewer/src/main/java/inr/numass/viewer/TestDirectoryViewer.java +++ b/numass-viewer/src/main/java/inr/numass/viewer/TestDirectoryViewer.java @@ -15,7 +15,6 @@ */ package inr.numass.viewer; -import hep.dataforge.context.Global; import hep.dataforge.storage.commons.StorageManager; import inr.numass.storage.NumassDataLoader; import javafx.application.Application; @@ -38,7 +37,7 @@ public class TestDirectoryViewer extends Application { NumassDataLoader reader = NumassDataLoader.fromLocalDir(null, new File("C:\\Users\\darksnake\\Dropbox\\PlayGround\\data-test\\20150703143643_1\\")); // NumassLoader reader = NumassLoader.fromZip(null, new File("C:\\Users\\darksnake\\Dropbox\\PlayGround\\data-test\\20150703143643_1.zip")); - NumassLoaderViewComponent comp = new NumassLoaderViewComponent(Global.instance()); + NumassLoaderView comp = new NumassLoaderView(); comp.loadData(reader); // FXMLLoader fxml = new FXMLLoader(getClass().getResource("/fxml/DirectoryViewer.fxml")); // @@ -48,7 +47,7 @@ public class TestDirectoryViewer extends Application { // // controller.setModel(reader); - Scene scene = new Scene(comp, 800, 600); + Scene scene = new Scene(comp.getRoot(), 800, 600); primaryStage.setTitle("Detector Visualisation test"); primaryStage.setScene(scene); diff --git a/numass-viewer/src/main/java/inr/numass/viewer/Viewer.java b/numass-viewer/src/main/java/inr/numass/viewer/Viewer.java deleted file mode 100644 index 80b089c7..00000000 --- a/numass-viewer/src/main/java/inr/numass/viewer/Viewer.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2015 Alexander Nozik. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package inr.numass.viewer; - -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.Logger; -import hep.dataforge.exceptions.StorageException; -import hep.dataforge.storage.commons.StorageManager; -import javafx.application.Application; -import javafx.fxml.FXMLLoader; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.stage.Stage; -import org.slf4j.LoggerFactory; - -import java.io.IOException; - -/** - * @author Alexander Nozik - */ -public class Viewer extends Application { - - @Override - public void start(Stage primaryStage) throws StorageException, IOException { - ((Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).setLevel(Level.INFO); - new StorageManager().startGlobal(); - - FXMLLoader fxml = new FXMLLoader(getClass().getResource("/fxml/MainView.fxml")); - - Parent parent = fxml.load(); - - Scene scene = new Scene(parent, 1024, 768); - - primaryStage.setTitle("Numass repository viewer"); - primaryStage.setScene(scene); - primaryStage.show(); - } - - @Override - public void stop() throws Exception { - super.stop(); -// System.exit(0); - } - -// public static void runTask(Task task) { -// Thread th = new Thread(task); -// th.setDaemon(true); -// th.start(); -// } - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - launch(args); - } - -} diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/MainView.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/MainView.kt new file mode 100644 index 00000000..62fc377f --- /dev/null +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/MainView.kt @@ -0,0 +1,228 @@ +package inr.numass.viewer + +import hep.dataforge.context.Context +import hep.dataforge.context.Global +import hep.dataforge.exceptions.StorageException +import hep.dataforge.fx.fragments.FragmentWindow +import hep.dataforge.fx.fragments.LogFragment +import hep.dataforge.fx.work.Work +import hep.dataforge.fx.work.WorkManager +import hep.dataforge.fx.work.WorkManagerFragment +import hep.dataforge.meta.Annotated +import hep.dataforge.names.Named +import hep.dataforge.storage.api.Storage +import inr.numass.NumassProperties +import inr.numass.data.NumassData +import inr.numass.storage.NumassStorage +import javafx.application.Platform +import javafx.beans.property.SimpleObjectProperty +import javafx.geometry.Insets +import javafx.scene.control.* +import javafx.scene.input.MouseEvent +import javafx.scene.layout.AnchorPane +import javafx.scene.layout.BorderPane +import javafx.scene.layout.GridPane +import javafx.stage.DirectoryChooser +import javafx.util.Pair +import org.controlsfx.control.StatusBar +import tornadofx.* +import java.io.File +import java.util.logging.Level + +/** + * Created by darksnake on 14-Apr-17. + */ +class MainView : View() { + override val root: AnchorPane by fxml("/fxml/MainView.fxml"); + + private val numassLoaderView: NumassLoaderView by inject() + + private val consoleButton: ToggleButton by fxid() + private val processManagerButton: ToggleButton by fxid() + private val loadDirectoryButton: Button by fxid() + private val loadRemoteButton: Button by fxid() + private val storagePathLabel: Label by fxid() + + private val loaderPane: BorderPane by fxid() + private val treePane: BorderPane by fxid() + private val statusBar: StatusBar by fxid() + + private val storageProperty = SimpleObjectProperty(); + + init { + loadDirectoryButton.action { + val chooser = DirectoryChooser() + chooser.title = "Select numass storage root" + val storageRoot = NumassProperties.getNumassProperty("numass.storage.root") + if (storageRoot == null) { + chooser.initialDirectory = File(".").absoluteFile + } else { + chooser.initialDirectory = File(storageRoot) + } + + val rootDir = chooser.showDialog(primaryStage.scene.window) + + if (rootDir != null) { + NumassProperties.setNumassProperty("numass.storage.root", rootDir.absolutePath) + loadDirectory(rootDir.toURI().toString()) + } + } + loadRemoteButton.action { onLoadRemote() } + + treePane.center { + treetableview { + column("name", Item::getName) + column("time", Item::getTime) + + addEventHandler(MouseEvent.MOUSE_CLICKED) { e: MouseEvent -> + if (e.clickCount == 2) { + val value = focusModel.focusedCell.treeItem.value + if (value.content is NumassData) { + numassLoaderView.loadData(value.content) + loaderPane.center = numassLoaderView.root + } + } + } + + storageProperty.addListener { ob, old, value -> + if (value != null) { + Platform.runLater { + root = TreeItem(Item(value)); + + populate { parent -> + val value = parent.value.content; + if (value is Storage) { + //TODO add legacy loaders here? + value.shelves().map(::Item) + value.loaders().map(::Item) + } else { + null + } + } + } + } else { + // TODO clear + } + } + + } + } + + val logFragment = LogFragment() + logFragment.addRootLogHandler() + //logFragment.hookStd(); + FragmentWindow(logFragment).bindTo(consoleButton) + FragmentWindow(WorkManagerFragment(getWorkManager())).bindTo(processManagerButton) + } + + private fun loadDirectory(path: String) { + getWorkManager().startWork("viewer.loadDirectory") { work: Work -> + work.title = "Load storage ($path)" + work.progress = -1.0 + work.status = "Building numass storage tree..." + try { + val root = NumassStorage.buildNumassRoot(path, true, false) + setRootStorage(root) + Platform.runLater { storagePathLabel.text = "Storage: " + path } + } catch (ex: Exception) { + work.progress = 0.0 + work.status = "Failed to load storage " + path + log.log(Level.SEVERE, null, ex) + } + } + } + + private val context: Context + get() = Global.instance() + + @Synchronized private fun getWorkManager(): WorkManager { + return Global.instance().getFeature(WorkManager::class.java); + } + + fun setRootStorage(root: NumassStorage) { + + getWorkManager().cleanup() + getWorkManager().startWork("viewer.storage.load") { callback: Work -> + callback.title = "Fill data to UI (" + root.name + ")" + callback.progress = -1.0 + Platform.runLater { statusBar.progress = -1.0 } + + callback.status = "Loading numass storage tree..." + + try { + storageProperty.set(root) + } catch (ex: StorageException) { + log.log(Level.SEVERE, null, ex) + } + + // callback.setProgress(1, 1); + Platform.runLater { statusBar.progress = 0.0 } + callback.status = "Numass storage tree loaded." + callback.setProgressToMax() + } + } + + private fun onLoadRemote() { + // Create the custom dialog. + val dialog = Dialog>() + dialog.title = "Remote storage selection" + dialog.headerText = "Select remote storage login options and run" + + val loginButtonType = ButtonType("Load", ButtonBar.ButtonData.OK_DONE) + dialog.dialogPane.buttonTypes.addAll(loginButtonType, ButtonType.CANCEL) + + // Create the username and password labels and fields. + val grid = GridPane() + grid.hgap = 10.0 + grid.vgap = 10.0 + grid.padding = Insets(20.0, 150.0, 10.0, 10.0) + + val storageText = TextField() + storageText.prefWidth = 350.0 + storageText.text = "sftp://trdat:Anomaly@192.168.111.1" + val runText = TextField() + runText.promptText = "Run name" + + grid.add(Label("Storage path:"), 0, 0) + grid.add(storageText, 1, 0) + grid.add(Label("Run name:"), 0, 1) + grid.add(runText, 1, 1) + + dialog.dialogPane.content = grid + + // Request focus on the username field by default. + storageText.requestFocus() + + // Convert the result to a username-password-pair when the login button is clicked. + dialog.setResultConverter { dialogButton -> + if (dialogButton == loginButtonType) { + Pair(storageText.text, runText.text) + } else { + null; + } + } + + val result = dialog.showAndWait() + + if (result.isPresent) { + val path = result.get().key + "/data/" + result.get().value + loadDirectory(path) + } + } + + class Item(val content: Named) { + fun getName(): String { + return content.name; + } + + fun getTime(): String { + if (content is NumassData) { + return content.startTime().toString(); + } else if (content is Annotated) { + return content.meta().getString("file.timeModified", "") + } else { + return ""; + } + } + + } +} diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/NumassLoaderView.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/NumassLoaderView.kt new file mode 100644 index 00000000..c80d4b07 --- /dev/null +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/NumassLoaderView.kt @@ -0,0 +1,383 @@ +package inr.numass.viewer + +import hep.dataforge.context.Context +import hep.dataforge.context.Global +import hep.dataforge.fx.work.Work +import hep.dataforge.fx.work.WorkManager +import hep.dataforge.io.ColumnedDataWriter +import hep.dataforge.meta.MetaBuilder +import hep.dataforge.plots.XYPlotFrame +import hep.dataforge.plots.data.PlotDataUtils +import hep.dataforge.plots.data.PlottableData +import hep.dataforge.plots.data.PlottableGroup +import hep.dataforge.plots.data.TimePlottable +import hep.dataforge.plots.fx.FXPlotFrame +import hep.dataforge.plots.fx.PlotContainer +import hep.dataforge.plots.jfreechart.JFreeChartFrame +import hep.dataforge.storage.commons.JSONMetaWriter +import hep.dataforge.tables.* +import inr.numass.data.NumassData +import inr.numass.data.NumassDataUtils +import inr.numass.data.NumassPoint +import javafx.application.Platform +import javafx.beans.value.ObservableValue +import javafx.collections.FXCollections +import javafx.event.ActionEvent +import javafx.event.EventHandler +import javafx.fxml.FXMLLoader +import javafx.geometry.Insets +import javafx.geometry.Orientation +import javafx.scene.control.* +import javafx.scene.layout.AnchorPane +import javafx.stage.FileChooser +import javafx.util.converter.NumberStringConverter +import org.controlsfx.control.RangeSlider +import org.controlsfx.validation.ValidationSupport +import org.controlsfx.validation.Validator +import org.slf4j.LoggerFactory +import tornadofx.* +import java.io.IOException +import java.util.function.Supplier +import java.util.logging.Level +import java.util.stream.Collectors + +/** + * Numass loader view + * + * Created by darksnake on 14-Apr-17. + */ +class NumassLoaderView : View() { + override val root: AnchorPane by fxml("/fxml/NumassLoaderView.fxml") + lateinit var main: MainView + + var data: NumassData? = null + + private val detectorPlotPane: AnchorPane by fxid(); + private val tabPane: TabPane by fxid(); + private val infoTextBox: TextArea by fxid(); + private val spectrumPlotPane: AnchorPane by fxid(); + private val lowChannelField: TextField by fxid(); + private val upChannelField: TextField by fxid(); + private val channelSlider: RangeSlider by fxid(); + private val dTimeField: TextField by fxid(); + private val hvPane: AnchorPane by fxid(); + private val spectrumExportButton: Button by fxid(); + + private val detectorPlot: PlotContainer = PlotContainer.anchorTo(detectorPlotPane) + private val spectrumPlot: PlotContainer = PlotContainer.anchorTo(spectrumPlotPane) + private val hvPlot: PlotContainer = PlotContainer.anchorTo(hvPane) + // private var spectrumData: PlottableData? = null + private var points = FXCollections.observableArrayList() + private val detectorBinningSelector: ChoiceBox = ChoiceBox(FXCollections.observableArrayList(1, 2, 5, 10, 20, 50)) + private val detectorNormalizeSwitch: CheckBox = CheckBox("Normailize") + private val detectorDataExportButton: Button = Button("Export") + + init { + val loader = FXMLLoader(javaClass.getResource("/fxml/NumassLoaderView.fxml")) + + loader.setRoot(this) + loader.setController(this) + + try { + loader.load() + } catch (ex: IOException) { + throw RuntimeException(ex) + } + + } + + /** + * Initializes the controller class. + */ + init { + //setup detector pane plot and sidebar + val l = Label("Bin size:") + l.padding = Insets(5.0) + detectorBinningSelector.maxWidth = java.lang.Double.MAX_VALUE + detectorBinningSelector.selectionModel.clearAndSelect(4) + + detectorNormalizeSwitch.isSelected = true + detectorNormalizeSwitch.padding = Insets(5.0) + + detectorPlot.addToSideBar(0, l, detectorBinningSelector, detectorNormalizeSwitch, Separator(Orientation.HORIZONTAL)) + + detectorDataExportButton.maxWidth = java.lang.Double.MAX_VALUE + detectorDataExportButton.onAction = EventHandler { this.onExportButtonClick(it) } + detectorPlot.addToSideBar(detectorDataExportButton) + + detectorPlot.setSideBarPosition(0.7) + //setup spectrum pane + + spectrumExportButton.onAction = EventHandler { this::onSpectrumExportClick } + val spectrumPlotMeta = MetaBuilder("plot") + .setValue("xAxis.axisTitle", "U") + .setValue("xAxis.axisUnits", "V") + .setValue("yAxis.axisTitle", "count rate") + .setValue("yAxis.axisUnits", "Hz") + .setValue("legend.show", false) + spectrumPlot.plot = JFreeChartFrame(spectrumPlotMeta) + + lowChannelField.textProperty().bindBidirectional(channelSlider.lowValueProperty(), NumberStringConverter()) + upChannelField.textProperty().bindBidirectional(channelSlider.highValueProperty(), NumberStringConverter()) + + channelSlider.highValue = 1900.0 + channelSlider.lowValue = 300.0 + + val rangeChangeListener = { _: ObservableValue, _: Number, _: Number -> setupSpectrumPane(points) } + + dTimeField.textProperty().addListener { _: ObservableValue, _: String, _: String -> setupSpectrumPane(points) } + + channelSlider.lowValueProperty().addListener(rangeChangeListener) + channelSlider.highValueProperty().addListener(rangeChangeListener) + + val validationSupport = ValidationSupport() + val isNumber = { t: String -> + try { + java.lang.Double.parseDouble(t) + true + } catch (ex: Exception) { + false + } + } + + validationSupport.registerValidator(dTimeField, Validator.createPredicateValidator(isNumber, "Must be number")) + + //setup HV plot + val hvPlotMeta = MetaBuilder("plot") + .setValue("xAxis.axisTitle", "time") + .setValue("xAxis.type", "time") + .setValue("yAxis.axisTitle", "HV") + hvPlot.plot = JFreeChartFrame(hvPlotMeta) + + } + + fun getContext(): Context { + return Global.getDefaultContext(); + } + + fun getWorkManager(): WorkManager { + return getContext().getFeature(WorkManager::class.java); + } + + fun loadData(data: NumassData?) { + this.data = data + if (data != null) { + getWorkManager().startWork("viewer.numass.load") { work -> + work.title = "Load numass data (" + data.name + ")" + points.setAll(data.nmPoints) + + Platform.runLater { + //setup detector data + setupDetectorPane(points) + //setup spectrum plot + setupSpectrumPane(points) + } + } + + //setup hv plot + val hvData = data.hvData + if (hvData != null) { + setupHVPane(hvData) + } + setupInfo(data) + + } else { + log.severe("The data model is null") + } + tabPane.selectionModel.select(1) + } + + private fun setupHVPane(hvData: Supplier
) { + getWorkManager().startWork("viewer.numass.hv") { callback: Work -> + val t = hvData.get() + Platform.runLater { + hvPlot.plot.plottables().clear() + val set = PlottableGroup() + for (dp in t) { + val block = dp.getString("block", "default") + if (!set.has(block)) { + set.add(TimePlottable(block, block)) + } + set.get(block).put(dp.getValue("timestamp").timeValue(), dp.getValue("value")) + } + hvPlot.plot.addAll(set) + } + } + } + + /** + * setup detector pane + + * @param points + */ + private fun setupDetectorPane(points: List) { + val normalize = detectorNormalizeSwitch.isSelected + val binning = detectorBinningSelector.value + updateDetectorPane(points, binning, normalize) + detectorBinningSelector.selectionModel.selectedItemProperty() + .addListener { observable: ObservableValue, oldValue: Int, newValue: Int -> + val norm = detectorNormalizeSwitch.isSelected + updateDetectorPane(points, newValue, norm) + } + detectorNormalizeSwitch.selectedProperty().addListener { observable: ObservableValue, oldValue: Boolean, newValue: Boolean -> + val bin = detectorBinningSelector.value + updateDetectorPane(points, bin, newValue) + } + detectorDataExportButton.isDisable = false + } + + private fun setupInfo(loader: NumassData) { + val info = loader.meta() + infoTextBox.text = JSONMetaWriter().writeString(info).replace("\\r", "\r\t").replace("\\n", "\n\t") + } + + private fun setupSpectrumPane(points: List) { + val spectrumData = PlottableData("spectrum") + spectrumPlot.plot.add(spectrumData) + + val lowChannel = channelSlider.lowValue.toInt() + val highChannel = channelSlider.highValue.toInt() + + if (points.isEmpty()) { + spectrumData.clear() + } else { + spectrumData.fillData(points.stream() + .map { point: NumassPoint -> getSpectrumPoint(point, lowChannel, highChannel, dTime) } + .collect(Collectors.toList())) + } + } + + private val dTime: Double + get() { + try { + return java.lang.Double.parseDouble(dTimeField.text) * 1e-6 + } catch (ex: NumberFormatException) { + return 0.0 + } + + } + + private fun getSpectrumPoint(point: NumassPoint, lowChannel: Int, upChannel: Int, dTime: Double): DataPoint { + val u = point.voltage + return MapPoint(arrayOf(XYAdapter.X_VALUE_KEY, XYAdapter.Y_VALUE_KEY, XYAdapter.Y_ERROR_KEY), u, + NumassDataUtils.countRateWithDeadTime(point, lowChannel, upChannel, dTime), + NumassDataUtils.countRateWithDeadTimeErr(point, lowChannel, upChannel, dTime)) + } + + /** + * update detector pane with new data + */ + private fun updateDetectorPane(points: List, binning: Int, normalize: Boolean) { + val detectorPlotFrame: FXPlotFrame + if (detectorPlot.plot.config.isEmpty) { + val frameMeta = MetaBuilder("frame") + .setValue("title", "Detector response plot") + .setNode(MetaBuilder("xAxis") + .setValue("axisTitle", "ADC") + .setValue("axisUnits", "channels") + .build()) + .setNode(MetaBuilder("yAxis") + .setValue("axisTitle", "count rate") + .setValue("axisUnits", "Hz") + .build()) + .setNode(MetaBuilder("legend") + .setValue("show", false)) + .build() + detectorPlotFrame = JFreeChartFrame(frameMeta) + } else { + detectorPlotFrame = detectorPlot.plot + detectorPlotFrame.clear() + detectorPlot.removePlot() + } + + getWorkManager().startWork("viewer.numass.load.detector") { callback: Work -> + val plottableConfig = MetaBuilder("plot") + .setValue("connectionType", "step") + .setValue("thickness", 2) + .setValue("showLine", true) + .setValue("showSymbol", false) + .setValue("showErrors", false) + .setValue("JFreeChart.cache", true) + .build() + + callback.maxProgress = points.size.toDouble() + callback.progress = 0.0 + for (point in points) { + val seriesName = String.format("%d: %.2f", points.indexOf(point), point.voltage) + val datum = PlottableData.plot(seriesName, XYAdapter("chanel", "count"), point.getData(binning, normalize)) + datum.configure(plottableConfig) + detectorPlotFrame.add(datum) + callback.increaseProgress(1.0) + //TODO add update instead of replace action + } + detectorPlot.plot = detectorPlotFrame + callback.setProgressToMax() + } + + } + + private fun onSpectrumExportClick(event: ActionEvent) { + if (points.isNotEmpty()) { + val fileChooser = FileChooser() + fileChooser.title = "Choose text export destination" + fileChooser.initialFileName = data!!.name + "_spectrum.onComplete" + val destination = fileChooser.showSaveDialog(spectrumPlotPane.scene.window) + if (destination != null) { + val names = arrayOf("Uset", "Uread", "Length", "Total", "Window", "CR", "CRerr", "Timestamp") + val loChannel = channelSlider.lowValue.toInt() + val upChannel = channelSlider.highValue.toInt() + val dTime = dTime + val spectrumDataSet = ListTable.Builder(*names) + + for (point in points) { + spectrumDataSet.row( + point.voltage, + point.voltage, + point.length, + point.totalCount, + point.getCountInWindow(loChannel, upChannel), + NumassDataUtils.countRateWithDeadTime(point, loChannel, upChannel, dTime), + NumassDataUtils.countRateWithDeadTimeErr(point, loChannel, upChannel, dTime), + point.startTime + ) + } + + try { + val comment = String.format("Numass data viewer spectrum data export for %s%n" + + "Window: (%d, %d)%n" + + "Dead time per event: %g%n", + data!!.name, loChannel, upChannel, dTime) + + ColumnedDataWriter + .writeTable(destination, spectrumDataSet.build(), comment, false) + } catch (ex: IOException) { + log.log(Level.SEVERE, "Destination file not found", ex) + } + + } + } + } + + private fun onExportButtonClick(event: ActionEvent) { + val fileChooser = FileChooser() + fileChooser.title = "Choose text export destination" + fileChooser.initialFileName = data!!.name + "_detector.out" + val destination = fileChooser.showSaveDialog(detectorPlotPane.scene.window) + if (destination != null) { + val detectorData = PlotDataUtils.collectXYDataFromPlot(detectorPlot.plot as XYPlotFrame, true) + try { + ColumnedDataWriter.writeTable( + destination, + detectorData, + "Numass data viewer detector data export for " + data!!.name, + false + ) + } catch (ex: IOException) { + LoggerFactory.getLogger(javaClass).error("Destination file not found", ex) + } + + } + + } + +} diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/TreeBuilder.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/TreeBuilder.kt new file mode 100644 index 00000000..a29889df --- /dev/null +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/TreeBuilder.kt @@ -0,0 +1,120 @@ +/* + * Copyright 2015 Alexander Nozik. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package inr.numass.viewer + +/** + + * @author darksnake + */ +class TreeBuilder { +// @Throws(StorageException::class) +// fun build(callback: Work, +// numassLoaderDataTree: TreeTableView, +// rootStorage: NumassStorage, +// numassViewBuilder: (NumassData) -> Unit) { +// +// val root = buildNode(rootStorage, numassViewBuilder, callback) +// root.isExpanded = true +// +// Platform.runLater { +// numassLoaderDataTree.root = root +// +// val numassLoaderNameColumn = TreeTableColumn("name") +// +// numassLoaderNameColumn.setCellValueFactory { param: TreeTableColumn.CellDataFeatures -> SimpleStringProperty(param.value.value.name) } +// +// val numassLoaderTimeColumn = TreeTableColumn("time") +// numassLoaderTimeColumn.setCellValueFactory { param: TreeTableColumn.CellDataFeatures -> SimpleStringProperty(param.value.value.time) } +// +// val nummassLoaderDescriptionColumn = TreeTableColumn("description") +// nummassLoaderDescriptionColumn.setCellValueFactory { param: TreeTableColumn.CellDataFeatures -> SimpleStringProperty(param.value.value.description) } +// +// numassLoaderDataTree.columns.setAll(numassLoaderNameColumn, numassLoaderTimeColumn, nummassLoaderDescriptionColumn) +// +// numassLoaderNameColumn.sortType = TreeTableColumn.SortType.ASCENDING +// numassLoaderDataTree.sortOrder.addAll(numassLoaderTimeColumn, numassLoaderNameColumn) +// numassLoaderDataTree.addEventHandler(MouseEvent.MOUSE_CLICKED) { e: MouseEvent -> +// if (e.clickCount == 2) { +// val value = numassLoaderDataTree.focusModel.focusedCell.treeItem.value +// if (value.isLoader) { +// numassViewBuilder(value.loader) +// } +// } +// } +// numassLoaderTimeColumn.isVisible = false +// nummassLoaderDescriptionColumn.setVisible(false) +// } +// +// } +// +// @Throws(StorageException::class) +// private fun buildNode(storage: NumassStorage, numassViewBuilder: (NumassData) -> Unit, callback: Work): TreeItem { +// val node = TreeItem(NumassDataItem(storage)) +// node.children.setAll(buildChildren(storage, numassViewBuilder, callback)) +// return node +// } +// +// private val logger: Logger +// get() = LoggerFactory.getLogger(javaClass) +// +// @Throws(StorageException::class) +// private fun buildChildren(storage: NumassStorage, numassViewBuilder: (NumassData) -> Unit, callback: Work): List> { +// val list = ArrayList>() +// +// storage.shelves().stream().forEach { subStorage -> +// if (subStorage is NumassStorage) { +// try { +// val numassSubStorage = subStorage +// val childNode = buildNode(numassSubStorage, numassViewBuilder, callback) +// if (!childNode.isLeaf) { +// list.add(buildNode(numassSubStorage, numassViewBuilder, callback)) +// } +// } catch (ex: StorageException) { +// logger.error("Error while loading numass storage node", ex) +// } +// +// } +// } +// +// callback.status = "Building storage " + storage.name +// callback.progress = 0.0 +// callback.maxProgress = storage.loaders().size.toDouble() +// storage.loaders().stream() +// .forEach { loader -> +// if (loader is NumassData) { +// callback.status = "Building numass data loader " + loader.getName() +// val numassLoaderTreeItem = TreeItem(NumassDataItem(loader)) +// list.add(numassLoaderTreeItem) +// } +// callback.increaseProgress(1.0) +// } +// +// callback.status = "Loading legacy DAT files" +// callback.progress = 0.0 +// val legacyFiles = storage.legacyFiles() +// callback.maxProgress = legacyFiles.size.toDouble() +// //adding legacy data files +// for (legacyDat in legacyFiles) { +// callback.status = "Loading numass DAT file " + legacyDat.name +// val numassLoaderTreeItem = TreeItem(NumassDataItem(legacyDat)) +// callback.increaseProgress(1.0) +// list.add(numassLoaderTreeItem) +// } +// +// return list +// } +// +} diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/Viewer.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/Viewer.kt new file mode 100644 index 00000000..1d230872 --- /dev/null +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/Viewer.kt @@ -0,0 +1,22 @@ +package inr.numass.viewer + +import ch.qos.logback.classic.Level +import ch.qos.logback.classic.Logger +import hep.dataforge.fx.work.WorkManager +import hep.dataforge.storage.commons.StorageManager +import javafx.stage.Stage +import org.slf4j.LoggerFactory +import tornadofx.* + +/** + * Created by darksnake on 14-Apr-17. + */ +class Viewer : App(MainView::class) { + + override fun start(stage: Stage) { + (LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME) as Logger).level = Level.INFO + StorageManager().startGlobal() + WorkManager().startGlobal() + super.start(stage) + } +} \ No newline at end of file diff --git a/numass-viewer/src/main/resources/fxml/MainView.fxml b/numass-viewer/src/main/resources/fxml/MainView.fxml index dbfe5af7..1878aa18 100644 --- a/numass-viewer/src/main/resources/fxml/MainView.fxml +++ b/numass-viewer/src/main/resources/fxml/MainView.fxml @@ -17,29 +17,18 @@ limitations under the License. --> - - - - - - - - - - - - + + - - + -