diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 24526447..00000000 --- a/build.gradle +++ /dev/null @@ -1,65 +0,0 @@ -buildscript { - ext.kotlin_version = "1.4.30" - repositories { - mavenCentral() - jcenter() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - -plugins{ - id 'org.openjfx.javafxplugin' version '0.0.9' apply false -} - -allprojects { - apply plugin: 'java' - apply plugin: "org.jetbrains.kotlin.jvm" - - group = 'inr.numass' - version = '1.0.0' - - [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' - - repositories { - mavenCentral() - jcenter() - } - - dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" - compile 'org.jetbrains:annotations:16.0.2' - testImplementation group: 'junit', name: 'junit', version: '4.+' - - //Spock dependencies. To be removed later - testCompile 'org.codehaus.groovy:groovy-all:2.5.+' - testCompile "org.spockframework:spock-core:1.2-groovy-2.5" - } - - compileKotlin { - kotlinOptions { - jvmTarget = "1.8" - javaParameters = true - freeCompilerArgs += [ - '-Xjvm-default=enable', - "-progressive", - "-Xuse-experimental=kotlin.Experimental" - ] - } - } - - compileTestKotlin { - kotlinOptions { - jvmTarget = "1.8" - javaParameters = true - freeCompilerArgs += [ - '-Xjvm-default=enable', - "-progressive", - "-Xuse-experimental=kotlin.Experimental" - ] - } - } -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..e23c6fa9 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,62 @@ +plugins { + kotlin("jvm") version "1.5.31" + id("org.openjfx.javafxplugin") version "0.0.9" apply false + id("com.github.johnrengelman.shadow") version "7.1.0" apply false +} + +allprojects { + apply(plugin = "org.jetbrains.kotlin.jvm") + + group = "inr.numass" + version = "1.1.0" + + repositories { + mavenCentral() + jcenter() + } + + dependencies { + api(kotlin("reflect")) + api("org.jetbrains:annotations:23.0.0") + testImplementation("junit:junit:4.13.2") + + //Spock dependencies. To be removed later + // https://mvnrepository.com/artifact/org.spockframework/spock-core + testImplementation("org.spockframework:spock-core:2.0-groovy-3.0") + + } + + tasks { + compileJava{ + options.encoding = "UTF-8" + } + + compileTestJava{ + options.encoding = "UTF-8" + } + + compileKotlin { + kotlinOptions { + jvmTarget = "16" + javaParameters = true + freeCompilerArgs = freeCompilerArgs + listOf( + "-Xjvm-default=all", + "-progressive", + "-Xuse-experimental=kotlin.Experimental" + ) + } + } + + compileTestKotlin { + kotlinOptions { + jvmTarget = "16" + javaParameters = true + freeCompilerArgs = freeCompilerArgs + listOf( + "-Xjvm-default=all", + "-progressive", + "-Xuse-experimental=kotlin.Experimental" + ) + } + } + } +} \ No newline at end of file diff --git a/dataforge-control/build.gradle b/dataforge-control/build.gradle index c3b47469..56415f0a 100644 --- a/dataforge-control/build.gradle +++ b/dataforge-control/build.gradle @@ -3,8 +3,8 @@ description = 'dataforge-control' dependencies { // Adding dependencies here will add the dependencies to each subproject. - compile project(':dataforge-core') + api project(':dataforge-core') //TODO consider removing storage dependency - compile project(':dataforge-storage') - compile 'org.scream3r:jssc:2.8.0' + api project(':dataforge-storage') + api 'org.scream3r:jssc:2.8.0' } \ No newline at end of file diff --git a/dataforge-control/src/main/kotlin/hep/dataforge/control/devices/Device.kt b/dataforge-control/src/main/kotlin/hep/dataforge/control/devices/Device.kt index f1333f52..69995c59 100644 --- a/dataforge-control/src/main/kotlin/hep/dataforge/control/devices/Device.kt +++ b/dataforge-control/src/main/kotlin/hep/dataforge/control/devices/Device.kt @@ -75,7 +75,6 @@ interface Device : AutoConnectible, Metoid, ContextAware, Named, Stateful { */ val type: String - @JvmDefault override val logger: Logger get() = optConnection(LOGGER_ROLE, Logger::class.java).orElse(context.logger) diff --git a/dataforge-core/build.gradle b/dataforge-core/build.gradle index 85abc9fb..79646b8f 100644 --- a/dataforge-core/build.gradle +++ b/dataforge-core/build.gradle @@ -1,8 +1,7 @@ description = 'dataforge-core' dependencies { - compile 'ch.qos.logback:logback-classic:1.2.3' - compile 'org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.5.0' - compile group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_version - compile group: 'javax.cache', name: 'cache-api', version: '1.1.0' + api 'ch.qos.logback:logback-classic:1.2.3' + api 'org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.5.0' + api group: 'javax.cache', name: 'cache-api', version: '1.1.0' } diff --git a/dataforge-core/dataforge-json/build.gradle b/dataforge-core/dataforge-json/build.gradle index 0ad467d1..cea391d8 100644 --- a/dataforge-core/dataforge-json/build.gradle +++ b/dataforge-core/dataforge-json/build.gradle @@ -17,6 +17,6 @@ description = 'json meta type for dataforge' dependencies { - compile project(":dataforge-core") - compile 'com.github.cliftonlabs:json-simple:3.0.2' + api project(":dataforge-core") + api 'com.github.cliftonlabs:json-simple:3.0.2' } \ No newline at end of file diff --git a/dataforge-core/dataforge-json/src/main/kotlin/hep/dataforge/io/JSONMetaType.kt b/dataforge-core/dataforge-json/src/main/kotlin/hep/dataforge/io/JSONMetaType.kt index 9e574114..a296eae1 100644 --- a/dataforge-core/dataforge-json/src/main/kotlin/hep/dataforge/io/JSONMetaType.kt +++ b/dataforge-core/dataforge-json/src/main/kotlin/hep/dataforge/io/JSONMetaType.kt @@ -22,6 +22,7 @@ package hep.dataforge.io import hep.dataforge.io.envelopes.MetaType +import java.util.* class JSONMetaType : MetaType { override val codes: List = listOf(0x4a53, 1)//JS @@ -32,7 +33,7 @@ class JSONMetaType : MetaType { override val writer: MetaStreamWriter = JSONMetaWriter - override val fileNameFilter: (String) -> Boolean = { it.toLowerCase().endsWith(".json") } + override val fileNameFilter: (String) -> Boolean = { it.lowercase(Locale.getDefault()).endsWith(".json") } } val jsonMetaType = JSONMetaType() diff --git a/dataforge-core/src/main/java/hep/dataforge/meta/Template.java b/dataforge-core/src/main/java/hep/dataforge/meta/Template.java index eaaac16b..e599f623 100644 --- a/dataforge-core/src/main/java/hep/dataforge/meta/Template.java +++ b/dataforge-core/src/main/java/hep/dataforge/meta/Template.java @@ -60,7 +60,7 @@ public class Template implements Metoid, UnaryOperator { } /** - * Compile template using given meta and value providers. + * api template using given meta and value providers. * * @param valueProvider * @param metaProvider @@ -80,7 +80,7 @@ public class Template implements Metoid, UnaryOperator { parent.replaceChildNode(node, def.getMeta(includePath)); } else { LoggerFactory.getLogger(MetaUtils.class) - .warn("Can't compile template meta node with name {} not provided", includePath); + .warn("Can't api template meta node with name {} not provided", includePath); } } }); diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/Misc.kt b/dataforge-core/src/main/kotlin/hep/dataforge/Misc.kt index 33d6a81e..3b3a3e71 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/Misc.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/Misc.kt @@ -3,12 +3,6 @@ package hep.dataforge import hep.dataforge.meta.Meta import hep.dataforge.meta.MetaNode import hep.dataforge.names.Name -import java.util.stream.Collectors -import java.util.stream.Stream - -fun Stream.toList(): List { - return collect(Collectors.toList()) -} fun String?.asName(): Name { return Name.of(this) diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/cache/CachePlugin.kt b/dataforge-core/src/main/kotlin/hep/dataforge/cache/CachePlugin.kt index 51fcd457..afd7d1a5 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/cache/CachePlugin.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/cache/CachePlugin.kt @@ -113,7 +113,7 @@ class CachePlugin(meta: Meta) : BasicPlugin(meta) { private fun evalData() { data.goal.run() - (data.goal as Goal).onComplete { res, err -> + data.goal.onComplete { res, err -> if (err != null) { result.completeExceptionally(err) } else { diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/context/ContextAware.kt b/dataforge-core/src/main/kotlin/hep/dataforge/context/ContextAware.kt index 0f0bcfed..be9a7737 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/context/ContextAware.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/context/ContextAware.kt @@ -36,7 +36,6 @@ interface ContextAware { */ val context: Context - @JvmDefault val logger: Logger get() = if (this is Named) { LoggerFactory.getLogger(context.name + "." + (this as Named).name) diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/context/PluginLoader.kt b/dataforge-core/src/main/kotlin/hep/dataforge/context/PluginLoader.kt index 006f5bff..c1c7a40d 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/context/PluginLoader.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/context/PluginLoader.kt @@ -23,7 +23,6 @@ package hep.dataforge.context import hep.dataforge.meta.Meta import hep.dataforge.nullable -import hep.dataforge.toList import hep.dataforge.utils.MetaFactory import java.util.* import java.util.stream.Stream diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/data/DataNode.kt b/dataforge-core/src/main/kotlin/hep/dataforge/data/DataNode.kt index dc240a9c..f44cafd1 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/data/DataNode.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/data/DataNode.kt @@ -16,7 +16,6 @@ import hep.dataforge.meta.buildMeta import hep.dataforge.nullable import hep.dataforge.providers.Provider import hep.dataforge.providers.Provides -import hep.dataforge.toList import java.util.concurrent.Executor import java.util.function.BiConsumer import java.util.function.Consumer diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/data/DataUtils.kt b/dataforge-core/src/main/kotlin/hep/dataforge/data/DataUtils.kt index 22fe561e..533f9c18 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/data/DataUtils.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/data/DataUtils.kt @@ -28,7 +28,6 @@ import hep.dataforge.io.MetaFileReader import hep.dataforge.io.envelopes.EnvelopeReader import hep.dataforge.meta.Laminate import hep.dataforge.meta.Meta -import hep.dataforge.toList import java.io.IOException import java.nio.file.Files import java.nio.file.Path diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/data/FileDataFactory.kt b/dataforge-core/src/main/kotlin/hep/dataforge/data/FileDataFactory.kt index 14ae1b1a..8de69be8 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/data/FileDataFactory.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/data/FileDataFactory.kt @@ -32,7 +32,6 @@ import hep.dataforge.description.NodeDefs import hep.dataforge.meta.Laminate import hep.dataforge.meta.Meta import hep.dataforge.meta.MetaBuilder -import hep.dataforge.toList import hep.dataforge.utils.NamingUtils.wildcardMatch import java.io.IOException import java.nio.file.Files diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/data/binary/Binary.kt b/dataforge-core/src/main/kotlin/hep/dataforge/data/binary/Binary.kt index 85b2b771..1cb6e1e0 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/data/binary/Binary.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/data/binary/Binary.kt @@ -60,7 +60,6 @@ interface Binary : Serializable { */ val size: Long - @JvmDefault fun stream(offset: Long): InputStream = stream.also { it.skip(offset) } /** @@ -71,7 +70,7 @@ interface Binary : Serializable { * @return * @throws IOException */ - @JvmDefault + fun read(offset: Int, size: Int): ByteBuffer { return buffer.run { position(offset) @@ -84,7 +83,7 @@ interface Binary : Serializable { /** * */ - @JvmDefault + fun read(start: Int): ByteBuffer { return read(start, (size - start).toInt()) } diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/description/Described.kt b/dataforge-core/src/main/kotlin/hep/dataforge/description/Described.kt index 9c86d7b0..615b7239 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/description/Described.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/description/Described.kt @@ -32,7 +32,7 @@ interface Described { * * @return */ - @JvmDefault + val descriptor: NodeDescriptor get() = Descriptors.forJavaType("node", this.javaClass) } diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/io/OutputManager.kt b/dataforge-core/src/main/kotlin/hep/dataforge/io/OutputManager.kt index ea905da7..48bd79d8 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/io/OutputManager.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/io/OutputManager.kt @@ -57,7 +57,7 @@ interface OutputManager : Plugin { /** * */ - @JvmDefault + operator fun get(stage: String, name: String, type: String? = null): Output { return get { OUTPUT_NAME_KEY to name @@ -67,7 +67,7 @@ interface OutputManager : Plugin { } - @JvmDefault + operator fun get(name: String): Output { return get { OUTPUT_NAME_KEY to name diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/BinaryMetaType.kt b/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/BinaryMetaType.kt index 03f0f37b..f113bef0 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/BinaryMetaType.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/BinaryMetaType.kt @@ -21,6 +21,7 @@ import hep.dataforge.io.MetaStreamWriter import hep.dataforge.meta.Meta import hep.dataforge.meta.MetaUtils import java.io.* +import java.util.* val binaryMetaType = BinaryMetaType() @@ -35,7 +36,7 @@ class BinaryMetaType : MetaType { override val name: String = "binary" - override val fileNameFilter: (String)->Boolean = { str -> str.toLowerCase().endsWith(".meta") } + override val fileNameFilter: (String)->Boolean = { str -> str.lowercase(Locale.getDefault()).endsWith(".meta") } override val reader: MetaStreamReader = MetaStreamReader { stream, length -> @@ -55,8 +56,8 @@ class BinaryMetaType : MetaType { @Throws(IOException::class) override fun write(stream: OutputStream, meta: Meta) { MetaUtils.writeMeta(ObjectOutputStream(stream), meta) - stream.write('\r'.toInt()) - stream.write('\n'.toInt()) + stream.write('\r'.code) + stream.write('\n'.code) } } diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/DefaultEnvelopeType.kt b/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/DefaultEnvelopeType.kt index f0061c59..02daa540 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/DefaultEnvelopeType.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/DefaultEnvelopeType.kt @@ -56,7 +56,7 @@ open class DefaultEnvelopeType : EnvelopeType { /** * The set of symbols that separates tag from metadata and data */ - val SEPARATOR = byteArrayOf('\r'.toByte(), '\n'.toByte()) + val SEPARATOR = byteArrayOf('\r'.code.toByte(), '\n'.code.toByte()) } } diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/EnvelopeReader.kt b/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/EnvelopeReader.kt index fe1faa86..28f656cd 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/EnvelopeReader.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/EnvelopeReader.kt @@ -45,7 +45,6 @@ interface EnvelopeReader { /** * Read the envelope from channel */ - @JvmDefault fun read(channel: ReadableByteChannel): Envelope { return read(Channels.newInputStream(channel)) } @@ -53,7 +52,6 @@ interface EnvelopeReader { /** * Read the envelope from buffer (could produce lazy envelope) */ - @JvmDefault fun read(buffer: ByteBuffer): Envelope { return read(BufferChannel(buffer))//read(ByteArrayInputStream(buffer.array())) } @@ -61,7 +59,6 @@ interface EnvelopeReader { /** * Read the envelope from NIO file (could produce lazy envelope) */ - @JvmDefault fun read(file: Path): Envelope { return Files.newByteChannel(file, READ).use { read(it) } } diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/EnvelopeType.kt b/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/EnvelopeType.kt index 00c30449..831dea7d 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/EnvelopeType.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/EnvelopeType.kt @@ -33,11 +33,9 @@ interface EnvelopeType { val name: String - val reader: EnvelopeReader - get() = getReader(emptyMap()) + val reader: EnvelopeReader get() = getReader(emptyMap()) - val writer: EnvelopeWriter - get() = getWriter(emptyMap()) + val writer: EnvelopeWriter get() = getWriter(emptyMap()) fun description(): String @@ -82,7 +80,8 @@ interface EnvelopeType { } } } catch (ex: Exception) { - LoggerFactory.getLogger(EnvelopeType::class.java).warn("Could not infer envelope type of file {} due to exception: {}", path, ex) + LoggerFactory.getLogger(EnvelopeType::class.java) + .warn("Could not infer envelope type of file {} due to exception: {}", path, ex) null } diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/MetaType.kt b/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/MetaType.kt index 1839d3d8..92fe8f1f 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/MetaType.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/MetaType.kt @@ -9,7 +9,6 @@ import hep.dataforge.context.Global import hep.dataforge.io.MetaStreamReader import hep.dataforge.io.MetaStreamWriter import hep.dataforge.io.envelopes.Envelope.Companion.META_TYPE_PROPERTY -import hep.dataforge.toList /** * diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/SimpleEnvelope.kt b/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/SimpleEnvelope.kt index 6170dc6f..03567752 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/SimpleEnvelope.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/SimpleEnvelope.kt @@ -18,7 +18,6 @@ package hep.dataforge.io.envelopes import hep.dataforge.data.binary.Binary import hep.dataforge.meta.Meta -import java.io.IOException import java.io.ObjectInputStream import java.io.ObjectOutputStream @@ -35,14 +34,12 @@ open class SimpleEnvelope(meta: Meta = Meta.empty(), data: Binary = Binary.EMPTY override var data: Binary = data protected set - @Throws(IOException::class) - private fun writeObject(out: ObjectOutputStream) { - DefaultEnvelopeWriter(DefaultEnvelopeType.INSTANCE, binaryMetaType).write(out, this) + private fun writeObject(output: ObjectOutputStream) { + DefaultEnvelopeWriter(DefaultEnvelopeType.INSTANCE, binaryMetaType).write(output, this) } - @Throws(IOException::class, ClassNotFoundException::class) - private fun readObject(`in`: ObjectInputStream) { - val envelope = DefaultEnvelopeReader.INSTANCE.read(`in`) + private fun readObject(input: ObjectInputStream) { + val envelope = DefaultEnvelopeReader.INSTANCE.read(input) this.meta = envelope.meta this.data = envelope.data diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/TaglessEnvelopeType.kt b/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/TaglessEnvelopeType.kt index 640a41fc..5c3e2cc0 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/TaglessEnvelopeType.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/TaglessEnvelopeType.kt @@ -24,7 +24,6 @@ import java.nio.ByteBuffer import java.nio.channels.Channels import java.nio.channels.ReadableByteChannel import java.text.ParseException -import java.util.* import java.util.regex.Pattern /** @@ -40,13 +39,9 @@ class TaglessEnvelopeType : EnvelopeType { return "Tagless envelope. Text only. By default uses XML meta with utf encoding and data end auto-detection." } - override fun getReader(properties: Map): EnvelopeReader { - return TaglessReader(properties) - } + override fun getReader(properties: Map): EnvelopeReader = TaglessReader(properties) - override fun getWriter(properties: Map): EnvelopeWriter { - return TaglessWriter(properties) - } + override fun getWriter(properties: Map): EnvelopeWriter = TaglessWriter(properties) class TaglessWriter(var properties: Map = emptyMap()) : EnvelopeWriter { @@ -88,12 +83,8 @@ class TaglessEnvelopeType : EnvelopeType { class TaglessReader(private val override: Map) : EnvelopeReader { - private val BUFFER_SIZE = 1024 - @Throws(IOException::class) - override fun read(stream: InputStream): Envelope { - return read(Channels.newChannel(stream)) - } + override fun read(stream: InputStream): Envelope = read(Channels.newChannel(stream)) override fun read(channel: ReadableByteChannel): Envelope { val properties = HashMap(override) @@ -106,36 +97,38 @@ class TaglessEnvelopeType : EnvelopeType { /** * Read lines using provided channel and buffer. Buffer state is changed by this operation */ - private fun readLines(channel: ReadableByteChannel, buffer: ByteBuffer): Sequence { - return sequence { - val builder = ByteArrayOutputStream() - while (true) { - if (!buffer.hasRemaining()) { - if (!channel.isOpen) { - break - } - buffer.flip() - val count = channel.read(buffer) - buffer.flip() - if (count < BUFFER_SIZE) { - channel.close() - } + private fun readLines(channel: ReadableByteChannel, buffer: ByteBuffer): Sequence = sequence { + val builder = ByteArrayOutputStream() + while (true) { + if (!buffer.hasRemaining()) { + if (!channel.isOpen) { + break } - val b = buffer.get() - builder.write(b.toInt()) - if (b == '\n'.toByte()) { - yield(String(builder.toByteArray(), Charsets.UTF_8)) - builder.reset() + buffer.flip() + val count = channel.read(buffer) + buffer.flip() + if (count < BUFFER_SIZE) { + channel.close() } } + val b = buffer.get() + builder.write(b.toInt()) + if (b == '\n'.code.toByte()) { + yield(String(builder.toByteArray(), Charsets.UTF_8)) + builder.reset() + } } } @Throws(IOException::class) - private fun readMeta(channel: ReadableByteChannel, buffer: ByteBuffer, properties: MutableMap): Meta { + private fun readMeta( + channel: ReadableByteChannel, + buffer: ByteBuffer, + properties: MutableMap, + ): Meta { val sb = StringBuilder() val metaEnd = properties.getOrDefault(DATA_START_PROPERTY, DEFAULT_DATA_START) - readLines(channel, buffer).takeWhile { it.trim { it <= ' ' } != metaEnd }.forEach { line -> + readLines(channel, buffer).takeWhile { it.trim { char -> char <= ' ' } != metaEnd }.forEach { line -> if (line.startsWith("#?")) { readProperty(line.trim(), properties) } else if (line.isEmpty() || line.startsWith("#~")) { @@ -161,13 +154,19 @@ class TaglessEnvelopeType : EnvelopeType { @Throws(IOException::class) - private fun readData(channel: ReadableByteChannel, buffer: ByteBuffer, properties: Map): ByteBuffer { + private fun readData( + channel: ReadableByteChannel, + buffer: ByteBuffer, + properties: Map, + ): ByteBuffer { val array = ByteArray(buffer.remaining()); buffer.get(array) if (properties.containsKey(DATA_LENGTH_PROPERTY)) { val result = ByteBuffer.allocate(Integer.parseInt(properties[DATA_LENGTH_PROPERTY])) result.put(array)//TODO fix it to not use direct array access - channel.read(result) + if(result.limit() < result.capacity()) { + channel.read(result) + } return result } else { val baos = ByteArrayOutputStream() @@ -209,7 +208,7 @@ class TaglessEnvelopeType : EnvelopeType { const val DEFAULT_META_START = "#~META~#" const val DATA_START_PROPERTY = "dataSeparator" const val DEFAULT_DATA_START = "#~DATA~#" - + private val BUFFER_SIZE = 1024 val INSTANCE = TaglessEnvelopeType() } diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/XMLMetaType.kt b/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/XMLMetaType.kt index 453ffd07..0ed97d83 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/XMLMetaType.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/io/envelopes/XMLMetaType.kt @@ -25,6 +25,7 @@ import hep.dataforge.io.MetaStreamReader import hep.dataforge.io.MetaStreamWriter import hep.dataforge.io.XMLMetaReader import hep.dataforge.io.XMLMetaWriter +import java.util.* val xmlMetaType = XMLMetaType() @@ -38,7 +39,7 @@ class XMLMetaType : MetaType { override val writer: MetaStreamWriter = XMLMetaWriter() - override val fileNameFilter: (String) -> Boolean = { str -> str.toLowerCase().endsWith(".xml") } + override val fileNameFilter: (String) -> Boolean = { str -> str.lowercase(Locale.getDefault()).endsWith(".xml") } companion object { const val XML_META_TYPE = "XML" diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/io/output/TextOutput.kt b/dataforge-core/src/main/kotlin/hep/dataforge/io/output/TextOutput.kt index b217fca4..15168816 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/io/output/TextOutput.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/io/output/TextOutput.kt @@ -61,7 +61,7 @@ interface TextOutput : Output { render("", meta) } - @JvmDefault + fun renderText(text: String, color: Color) { renderText(text, TextColor(color)) } diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/names/Name.kt b/dataforge-core/src/main/kotlin/hep/dataforge/names/Name.kt index 475ac310..d2a6aa7a 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/names/Name.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/names/Name.kt @@ -17,7 +17,6 @@ package hep.dataforge.names import java.util.stream.Stream import java.util.stream.StreamSupport -import kotlin.streams.toList /** * @@ -129,7 +128,7 @@ interface Name : Comparable { * @param name * @return */ - @JvmDefault + operator fun plus(name: Name): Name { return join(this, name) } @@ -140,14 +139,14 @@ interface Name : Comparable { * @param name * @return */ - @JvmDefault + operator fun plus(name: String): Name { return join(this, ofSingle(name)) } fun asArray(): Array - @JvmDefault + fun equals(name: String): Boolean { return this.toString() == name } diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/states/State.kt b/dataforge-core/src/main/kotlin/hep/dataforge/states/State.kt index 24565bb8..72261146 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/states/State.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/states/State.kt @@ -79,7 +79,7 @@ sealed class State( init { if (def != null) { - channel.offer(def) + channel.trySend(def).isSuccess ref.set(def) valid = true } @@ -91,7 +91,7 @@ sealed class State( private fun updateValue(value: T) { ref.set(value) //TODO evict on full - channel.offer(value) + channel.trySend(value).isSuccess valid = true logger.debug("State {} changed to {}", name, value) } diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/tables/Column.kt b/dataforge-core/src/main/kotlin/hep/dataforge/tables/Column.kt index 0f9389b7..15ae83c2 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/tables/Column.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/tables/Column.kt @@ -33,7 +33,7 @@ interface Column : Named, Iterable, Serializable { val format: ColumnFormat - @JvmDefault + override val name: String get() = format.name @@ -62,7 +62,7 @@ interface Column : Named, Iterable, Serializable { * Get the values as a stream * @return */ - @JvmDefault + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/tables/ColumnFormat.kt b/dataforge-core/src/main/kotlin/hep/dataforge/tables/ColumnFormat.kt index d0d2fb44..a580255b 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/tables/ColumnFormat.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/tables/ColumnFormat.kt @@ -4,7 +4,6 @@ import hep.dataforge.Named import hep.dataforge.meta.Meta import hep.dataforge.meta.MetaBuilder import hep.dataforge.meta.SimpleMetaMorph -import hep.dataforge.toList import hep.dataforge.values.Value import hep.dataforge.values.ValueType import java.util.* @@ -69,9 +68,9 @@ class ColumnFormat(meta: Meta) : SimpleMetaMorph(meta), Named { */ fun build(name: String, type: ValueType, vararg tags: String): ColumnFormat { return ColumnFormat(MetaBuilder("column") - .putValue("name", name) - .putValue("type", type) - .putValue(TAG_KEY, Stream.of(*tags).toList()) + .putValue("name", name) + .putValue("type", type) + .putValue(TAG_KEY, Stream.of(*tags).toList()) ) } diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/tables/Tables.kt b/dataforge-core/src/main/kotlin/hep/dataforge/tables/Tables.kt index 93cb2b7d..2f7a86f7 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/tables/Tables.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/tables/Tables.kt @@ -18,7 +18,6 @@ package hep.dataforge.tables import hep.dataforge.exceptions.NamingException import hep.dataforge.nullable -import hep.dataforge.toList import hep.dataforge.values.* import java.util.function.Predicate import java.util.stream.Stream @@ -34,11 +33,11 @@ object Tables { @JvmStatic fun sort(table: Table, name: String, ascending: Boolean): Table { return sort( - table, - Comparator { o1: Values, o2: Values -> - val signum = if (ascending) +1 else -1 - o1.getValue(name).compareTo(o2.getValue(name)) * signum - } + table, + Comparator { o1: Values, o2: Values -> + val signum = if (ascending) +1 else -1 + o1.getValue(name).compareTo(o2.getValue(name)) * signum + } ) } @@ -132,7 +131,8 @@ fun Table.addColumn(format: ColumnFormat, transform: Values.() -> Any): Table { return ColumnTable.copy(this).buildColumn(format, transform) } -fun Table.addColumn(name: String, type: ValueType, transform: Values.() -> Any): Table = addColumn(ColumnFormat.build(name, type), transform) +fun Table.addColumn(name: String, type: ValueType, transform: Values.() -> Any): Table = + addColumn(ColumnFormat.build(name, type), transform) fun Table.replaceColumn(name: String, transform: Values.() -> Any): Table { return ColumnTable.copy(this).replaceColumn(name, transform) @@ -149,19 +149,17 @@ fun Table.sort(comparator: Comparator): Table { } fun Table.sort(name: String = format.first().name, ascending: Boolean = true): Table { - return sort( - Comparator { o1: Values, o2: Values -> - val signum = if (ascending) +1 else -1 - o1.getValue(name).compareTo(o2.getValue(name)) * signum - } - ) + return sort { o1: Values, o2: Values -> + val signum = if (ascending) +1 else -1 + o1.getValue(name).compareTo(o2.getValue(name)) * signum + } } /* Row reduction */ fun Table.reduceRows(format: TableFormat? = null, keySelector: (Values) -> K, mapper: (K, List) -> Values) = - ListTable(format ?: this.format, this.groupBy(keySelector).map { (key, value) -> mapper(key, value) }, false) + ListTable(format ?: this.format, this.groupBy(keySelector).map { (key, value) -> mapper(key, value) }, false) /** * A helper for table row reduction @@ -177,15 +175,13 @@ class RowReducer(val default: (Iterable) -> Value) { reducers[key] = reducer } - fun sumByDouble(key: String) = rule(key) { rows -> rows.sumByDouble { it.double }.asValue() } - fun sumByInt(key: String) = rule(key) { rows -> rows.sumBy { it.int }.asValue() } + fun sumByDouble(key: String) = rule(key) { rows -> rows.sumOf { it.double }.asValue() } + fun sumByInt(key: String) = rule(key) { rows -> rows.sumOf { it.int }.asValue() } fun averageByDouble(key: String) = rule(key) { rows -> rows.map { it.double }.average().asValue() } fun averageByInt(key: String) = rule(key) { rows -> rows.map { it.int }.average().asValue() } - fun reduce(key: String, values: Iterable): Value { - return reducers.getOrDefault(key, default).invoke(values) - } + fun reduce(key: String, values: Iterable): Value = reducers.getOrDefault(key, default).invoke(values) /** * Reduce list of rows to a single row @@ -206,7 +202,7 @@ class RowReducer(val default: (Iterable) -> Value) { fun Table.sumByStep(key: String, step: Double, customizer: (RowReducer) -> Unit = {}): Table { assert(step > 0) { "Step must be positive" } - val reducer = RowReducer { rows -> rows.sumByDouble { it.double }.asValue() }.apply { + val reducer = RowReducer { rows -> rows.sumOf { it.double }.asValue() }.apply { averageByDouble(key) }.apply(customizer) diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/tables/ValuesSource.kt b/dataforge-core/src/main/kotlin/hep/dataforge/tables/ValuesSource.kt index a0ad851f..ae104579 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/tables/ValuesSource.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/tables/ValuesSource.kt @@ -33,7 +33,7 @@ import java.util.stream.StreamSupport */ interface ValuesSource : Iterable { - @JvmDefault + val rows: Stream get() = StreamSupport.stream(this.spliterator(), false) diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/values/Value.kt b/dataforge-core/src/main/kotlin/hep/dataforge/values/Value.kt index b219730f..a54fb5ec 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/values/Value.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/values/Value.kt @@ -24,7 +24,6 @@ import java.time.LocalDateTime import java.time.ZoneOffset import java.time.format.DateTimeParseException import java.util.stream.Stream -import kotlin.streams.toList /** * The list of supported Value types. @@ -61,15 +60,15 @@ interface Value : Serializable, Comparable { */ val boolean: Boolean - @JvmDefault + val double: Double get() = number.toDouble() - @JvmDefault + val int: Int get() = number.toInt() - @JvmDefault + val long: Long get() = number.toLong() @@ -80,7 +79,7 @@ interface Value : Serializable, Comparable { */ val time: Instant - @JvmDefault + val binary: ByteBuffer get() = ByteBuffer.wrap(string.toByteArray()) @@ -100,11 +99,11 @@ interface Value : Serializable, Comparable { * * @return */ - @JvmDefault + val list: List get() = listOf(this) - @JvmDefault + val isNull: Boolean get() = this.type == ValueType.NULL @@ -113,7 +112,7 @@ interface Value : Serializable, Comparable { * * @return */ - @JvmDefault + val isList: Boolean get() = false @@ -122,7 +121,7 @@ interface Value : Serializable, Comparable { */ val value: Any - @JvmDefault + override fun compareTo(other: Value): Int { return when (type) { ValueType.NUMBER -> ValueUtils.NUMBER_COMPARATOR.compare(number, other.number) diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/values/ValueProvider.kt b/dataforge-core/src/main/kotlin/hep/dataforge/values/ValueProvider.kt index 58d87dfa..a0366762 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/values/ValueProvider.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/values/ValueProvider.kt @@ -22,7 +22,7 @@ import java.util.* interface ValueProvider { - @JvmDefault + fun hasValue(path: String): Boolean { return optValue(path).isPresent } @@ -30,113 +30,113 @@ interface ValueProvider { @Provides(VALUE_TARGET) fun optValue(path: String): Optional - @JvmDefault + fun getValue(path: String): Value { return optValue(path).orElseThrow { NameNotFoundException(path) } } @Provides(BOOLEAN_TARGET) - @JvmDefault + fun optBoolean(name: String): Optional { return optValue(name).map { it.boolean } } - @JvmDefault + fun getBoolean(name: String, def: Boolean): Boolean { return optValue(name).map { it.boolean }.orElse(def) } - @JvmDefault + fun getBoolean(name: String, def: () -> Boolean): Boolean { return optValue(name).map { it.boolean }.orElseGet(def) } - @JvmDefault + fun getBoolean(name: String): Boolean { return getValue(name).boolean } @Provides(NUMBER_TARGET) - @JvmDefault + fun optNumber(name: String): Optional { return optValue(name).map { it.number } } - @JvmDefault + fun getDouble(name: String, def: Double): Double { return optValue(name).map { it.double }.orElse(def) } - @JvmDefault + fun getDouble(name: String, def: () -> Double): Double { return optValue(name).map { it.double }.orElseGet(def) } - @JvmDefault + fun getDouble(name: String): Double { return getValue(name).double } - @JvmDefault + fun getInt(name: String, def: Int): Int { return optValue(name).map { it.int }.orElse(def) } - @JvmDefault + fun getInt(name: String, def: () -> Int): Int { return optValue(name).map { it.int }.orElseGet(def) } - @JvmDefault + fun getInt(name: String): Int { return getValue(name).int } - @JvmDefault + @Provides(STRING_TARGET) fun optString(name: String): Optional { return optValue(name).map { it.string } } - @JvmDefault + fun getString(name: String, def: String): String { return optString(name).orElse(def) } - @JvmDefault + fun getString(name: String, def: () -> String): String { return optString(name).orElseGet(def) } - @JvmDefault + fun getString(name: String): String { return getValue(name).string } - @JvmDefault + fun getValue(name: String, def: Any): Value { return optValue(name).orElse(Value.of(def)) } - @JvmDefault + fun getValue(name: String, def: () -> Value): Value { return optValue(name).orElseGet(def) } @Provides(TIME_TARGET) - @JvmDefault + fun optTime(name: String): Optional { return optValue(name).map { it.time } } - @JvmDefault + fun getStringArray(name: String): Array { val vals = getValue(name).list return Array(vals.size) { vals[it].string } } - @JvmDefault + fun getStringArray(name: String, def: () -> Array): Array { return if (this.hasValue(name)) { getStringArray(name) @@ -145,7 +145,7 @@ interface ValueProvider { } } - @JvmDefault + fun getStringArray(name: String, def: Array): Array { return if (this.hasValue(name)) { getStringArray(name) diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/values/ValueUtils.kt b/dataforge-core/src/main/kotlin/hep/dataforge/values/ValueUtils.kt index 0dd97db0..93e9c4aa 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/values/ValueUtils.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/values/ValueUtils.kt @@ -137,40 +137,40 @@ object ValueUtils { @Throws(IOException::class) fun DataOutput.writeValue(value: Value) { if (value.isList) { - writeByte('*'.toInt()) // List designation + writeByte('*'.code) // List designation writeShort(value.list.size) for (subValue in value.list) { writeValue(subValue) } } else { when (value.type) { - ValueType.NULL -> writeChar('0'.toInt()) // null + ValueType.NULL -> writeChar('0'.code) // null ValueType.TIME -> { - writeByte('T'.toInt())//Instant + writeByte('T'.code)//Instant writeLong(value.time.epochSecond) writeLong(value.time.nano.toLong()) } ValueType.STRING -> { - this.writeByte('S'.toInt())//String + this.writeByte('S'.code)//String IOUtils.writeString(this, value.string) } ValueType.NUMBER -> { val num = value.number when (num) { is Double -> { - writeByte('D'.toInt()) // double + writeByte('D'.code) // double writeDouble(num.toDouble()) } is Int -> { - writeByte('I'.toInt()) // integer + writeByte('I'.code) // integer writeInt(num.toInt()) } is Long -> { - writeByte('L'.toInt()) + writeByte('L'.code) writeLong(num.toLong()) } else -> { - writeByte('N'.toInt()) // BigDecimal + writeByte('N'.code) // BigDecimal val decimal = num.toBigDecimal() val bigInt = decimal.unscaledValue().toByteArray() val scale = decimal.scale() @@ -181,13 +181,13 @@ fun DataOutput.writeValue(value: Value) { } } ValueType.BOOLEAN -> if (value.boolean) { - writeByte('+'.toInt()) //true + writeByte('+'.code) //true } else { - writeByte('-'.toInt()) // false + writeByte('-'.code) // false } ValueType.BINARY -> { val binary = value.binary - writeByte('X'.toInt()) + writeByte('X'.code) writeInt(binary.limit()) write(binary.array()) } @@ -199,7 +199,7 @@ fun DataOutput.writeValue(value: Value) { * Value deserialization */ fun DataInput.readValue(): Value { - val type = readByte().toChar() + val type = readByte().toInt().toChar() when (type) { '*' -> { val listSize = readShort() @@ -240,7 +240,7 @@ fun DataInput.readValue(): Value { fun ByteBuffer.getValue(): Value { - val type = get().toChar() + val type = get().toInt().toChar() when (type) { '*' -> { val listSize = getShort() @@ -286,7 +286,7 @@ fun ByteBuffer.getValue(): Value { fun ByteBuffer.putValue(value: Value) { if (value.isList) { - put('*'.toByte()) // List designation + put('*'.code.toByte()) // List designation if (value.list.size > Short.MAX_VALUE) { throw RuntimeException("The array values of size more than ${Short.MAX_VALUE} could not be serialized") } @@ -294,14 +294,14 @@ fun ByteBuffer.putValue(value: Value) { value.list.forEach { putValue(it) } } else { when (value.type) { - ValueType.NULL -> put('0'.toByte()) // null + ValueType.NULL -> put('0'.code.toByte()) // null ValueType.TIME -> { - put('T'.toByte())//Instant + put('T'.code.toByte())//Instant putLong(value.time.epochSecond) putLong(value.time.nano.toLong()) } ValueType.STRING -> { - put('S'.toByte())//String + put('S'.code.toByte())//String if (value.string.length > Int.MAX_VALUE) { throw RuntimeException("The string valuse of size more than ${Int.MAX_VALUE} could not be serialized") } @@ -311,19 +311,19 @@ fun ByteBuffer.putValue(value: Value) { val num = value.number when (num) { is Double -> { - put('D'.toByte()) // double + put('D'.code.toByte()) // double putDouble(num.toDouble()) } is Int -> { - put('I'.toByte()) // integer + put('I'.code.toByte()) // integer putInt(num.toInt()) } is Long -> { - put('L'.toByte()) + put('L'.code.toByte()) putLong(num.toLong()) } is BigDecimal -> { - put('N'.toByte()) // BigDecimal + put('N'.code.toByte()) // BigDecimal val bigInt = num.unscaledValue().toByteArray() val scale = num.scale() if (bigInt.size > Short.MAX_VALUE) { @@ -339,12 +339,12 @@ fun ByteBuffer.putValue(value: Value) { } } ValueType.BOOLEAN -> if (value.boolean) { - put('+'.toByte()) //true + put('+'.code.toByte()) //true } else { - put('-'.toByte()) // false + put('-'.code.toByte()) // false } ValueType.BINARY -> { - put('X'.toByte()) + put('X'.code.toByte()) val binary = value.binary putInt(binary.limit()) put(binary.array()) diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/values/Values.kt b/dataforge-core/src/main/kotlin/hep/dataforge/values/Values.kt index 1e86cb74..7e632615 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/values/Values.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/values/Values.kt @@ -19,7 +19,6 @@ import hep.dataforge.meta.Meta import hep.dataforge.meta.MetaBuilder import hep.dataforge.meta.MetaMorph import hep.dataforge.names.NameSetContainer -import java.util.* /** * A named set of values with fixed name list. @@ -32,7 +31,7 @@ interface Values : NameSetContainer, ValueProvider, MetaMorph, Iterable { val res = HashMap() for (field in this.names) { @@ -66,7 +65,7 @@ interface Values : NameSetContainer, ValueProvider, MetaMorph, Iterable { return names.map { NamedValue(it, get(it)) }.iterator() } @@ -77,12 +76,12 @@ interface Values : NameSetContainer, ValueProvider, MetaMorph, Iterable { return data.getData(dataPath) } @@ -90,7 +90,7 @@ interface Workspace : ContextAware, Provider { * @param taskName * @return */ - @JvmDefault + fun getTask(taskName: String): Task<*> { return optTask(taskName) ?: throw NameNotFoundException(taskName) } @@ -104,7 +104,7 @@ interface Workspace : ContextAware, Provider { * @param overlay use given meta as overaly for existing meta with the same name * @return */ - @JvmDefault + fun runTask(taskName: String, config: Meta, overlay: Boolean): DataNode<*> { val task = getTask(taskName) val taskConfig = if (overlay && hasTarget(config.name)) { @@ -116,7 +116,7 @@ interface Workspace : ContextAware, Provider { return runTask(model) } - @JvmDefault + fun runTask(taskName: String, config: Meta): DataNode<*> { return this.runTask(taskName, config, true) } @@ -127,7 +127,7 @@ interface Workspace : ContextAware, Provider { * @param config * @return */ - @JvmDefault + fun runTask(config: Meta): DataNode<*> { return runTask(config.name, config) } @@ -139,7 +139,7 @@ interface Workspace : ContextAware, Provider { * @param target * @return */ - @JvmDefault + fun runTask(taskName: String, target: String = taskName): DataNode<*> { return runTask(taskName, optTarget(target) ?: Meta.empty()) } @@ -150,7 +150,7 @@ interface Workspace : ContextAware, Provider { * @param model * @return */ - @JvmDefault + fun runTask(model: TaskModel): DataNode<*> { return this.getTask(model.name).run(model) } @@ -169,7 +169,7 @@ interface Workspace : ContextAware, Provider { * @param name * @return */ - @JvmDefault + fun getTarget(name: String): Meta { return optTarget(name) ?: throw NameNotFoundException(name) } @@ -180,7 +180,7 @@ interface Workspace : ContextAware, Provider { * @param name * @return */ - @JvmDefault + fun hasTarget(name: String): Boolean { return optTarget(name) != null } @@ -194,7 +194,7 @@ interface Workspace : ContextAware, Provider { override var context: Context - @JvmDefault + fun loadFrom(meta: Meta): Workspace.Builder { if (meta.hasValue("context")) { context = Global.getContext(meta.getString("context")) @@ -243,7 +243,7 @@ interface Workspace : ContextAware, Provider { * @param dataConfig * @return */ - @JvmDefault + fun data(place: String, dataConfig: Meta): Workspace.Builder { return data(place, DataLoader.SMART.build(context, dataConfig)) } @@ -256,7 +256,7 @@ interface Workspace : ContextAware, Provider { * @param dataConfig * @return */ - @JvmDefault + fun data(place: String, factory: DataLoader, dataConfig: Meta): Workspace.Builder { return data(place, factory.build(context, dataConfig)) } @@ -269,29 +269,29 @@ interface Workspace : ContextAware, Provider { * @param meta * @return */ - @JvmDefault + fun staticData(name: String, obj: Any, meta: Meta): Workspace.Builder { return data(name, Data.buildStatic(obj, meta)) } - @JvmDefault + fun staticData(name: String, obj: Any): Workspace.Builder { return data(name, Data.buildStatic(obj)) } - @JvmDefault + fun fileData(place: String, filePath: String, meta: Meta): Workspace.Builder { return data(place, DataUtils.readFile(context.getFile(filePath), meta)) } - @JvmDefault + fun fileData(dataName: String, filePath: String): Workspace.Builder { return fileData(dataName, filePath, Meta.empty()) } fun target(name: String, meta: Meta): Workspace.Builder - @JvmDefault + fun target(meta: Meta): Workspace.Builder { return target(meta.name, meta) } @@ -299,7 +299,7 @@ interface Workspace : ContextAware, Provider { fun task(task: Task<*>): Workspace.Builder @Throws(IllegalAccessException::class, InstantiationException::class) - @JvmDefault + fun task(type: Class>): Workspace.Builder { return task(type.getConstructor().newInstance()) } diff --git a/dataforge-core/src/main/kotlin/hep/dataforge/workspace/tasks/Task.kt b/dataforge-core/src/main/kotlin/hep/dataforge/workspace/tasks/Task.kt index 7015e6ad..51784a0d 100644 --- a/dataforge-core/src/main/kotlin/hep/dataforge/workspace/tasks/Task.kt +++ b/dataforge-core/src/main/kotlin/hep/dataforge/workspace/tasks/Task.kt @@ -56,7 +56,7 @@ interface Task : Named, Described { * * @param model */ - @JvmDefault + fun validate(model: TaskModel) { //do nothing } diff --git a/dataforge-core/src/test/kotlin/hep/dataforge/io/envelopes/TaglessEnvelopeTest.kt b/dataforge-core/src/test/kotlin/hep/dataforge/io/envelopes/TaglessEnvelopeTest.kt index 34a50294..c71ec642 100644 --- a/dataforge-core/src/test/kotlin/hep/dataforge/io/envelopes/TaglessEnvelopeTest.kt +++ b/dataforge-core/src/test/kotlin/hep/dataforge/io/envelopes/TaglessEnvelopeTest.kt @@ -21,19 +21,17 @@ import org.junit.Assert.assertEquals import org.junit.Test import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream -import java.io.IOException import java.nio.charset.Charset class TaglessEnvelopeTest { private val envelope = EnvelopeBuilder() - .meta(MetaBuilder() - .putValue("myValue", 12) - ).data("Всем привет!".toByteArray(Charset.forName("UTF-8"))) + .meta(MetaBuilder() + .putValue("myValue", 12) + ).data("Всем привет!".toByteArray(Charset.forName("UTF-8"))) private val envelopeType = TaglessEnvelopeType.INSTANCE @Test - @Throws(IOException::class) fun testWriteRead() { val baos = ByteArrayOutputStream() envelopeType.writer.write(baos, envelope) @@ -47,7 +45,6 @@ class TaglessEnvelopeTest { } @Test - @Throws(IOException::class) fun testShortForm() { val envString = "\n" + "#~DATA~#\n" + diff --git a/dataforge-gui/build.gradle b/dataforge-gui/build.gradle index fe5e3a92..c38840ef 100644 --- a/dataforge-gui/build.gradle +++ b/dataforge-gui/build.gradle @@ -8,13 +8,13 @@ description = "A tornadofx based kotlin library" dependencies { - compile project(':dataforge-plots') - compile project(':dataforge-gui:dataforge-html') - compile 'org.controlsfx:controlsfx:8.40.14' - compile "no.tornado:tornadofx:1.7.19" - compile 'no.tornado:tornadofx-controlsfx:0.1.1' - compile group: 'org.fxmisc.richtext', name: 'richtextfx', version: '0.10.2' - compile 'org.jetbrains.kotlinx:kotlinx-coroutines-javafx:1.5.0' + api project(':dataforge-plots') + api project(':dataforge-gui:dataforge-html') + api 'org.controlsfx:controlsfx:8.40.14' + api "no.tornado:tornadofx:1.7.19" + api 'no.tornado:tornadofx-controlsfx:0.1.1' + api group: 'org.fxmisc.richtext', name: 'richtextfx', version: '0.10.2' + api 'org.jetbrains.kotlinx:kotlinx-coroutines-javafx:1.5.0' // optional dependency for JFreeChart //compileOnly project(":dataforge-plots:plots-jfc") diff --git a/dataforge-gui/dataforge-html/build.gradle b/dataforge-gui/dataforge-html/build.gradle index fa65adae..8d337534 100644 --- a/dataforge-gui/dataforge-html/build.gradle +++ b/dataforge-gui/dataforge-html/build.gradle @@ -1,6 +1,6 @@ description = "An html rendering core and HTML output" dependencies { - compile project(':dataforge-core') - compile 'org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.11' + api project(':dataforge-core') + api 'org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.11' } diff --git a/dataforge-gui/gui-demo/build.gradle b/dataforge-gui/gui-demo/build.gradle index 730449f8..d5bc2f99 100644 --- a/dataforge-gui/gui-demo/build.gradle +++ b/dataforge-gui/gui-demo/build.gradle @@ -1,6 +1,6 @@ plugins{ id "application" - id "com.github.johnrengelman.shadow" version "2.0.1" + id "com.github.johnrengelman.shadow" } apply plugin: 'kotlin' @@ -13,8 +13,8 @@ mainClassName = mainClass description = "A demonstration for plots capabilities" dependencies { - compile project(':dataforge-plots:plots-jfc') - compile project(':dataforge-gui') + api project(':dataforge-plots:plots-jfc') + api project(':dataforge-gui') } diff --git a/dataforge-gui/gui-workspace/build.gradle b/dataforge-gui/gui-workspace/build.gradle index dc89ad81..31d0bb0d 100644 --- a/dataforge-gui/gui-workspace/build.gradle +++ b/dataforge-gui/gui-workspace/build.gradle @@ -24,7 +24,7 @@ apply plugin: 'kotlin' description = "A gui for workspace creation and manipulation" dependencies { - compile project(':dataforge-gui') + api project(':dataforge-gui') } application{ diff --git a/dataforge-gui/src/main/kotlin/hep/dataforge/fx/FXPlugin.kt b/dataforge-gui/src/main/kotlin/hep/dataforge/fx/FXPlugin.kt index 80c14d2b..5091a2a2 100644 --- a/dataforge-gui/src/main/kotlin/hep/dataforge/fx/FXPlugin.kt +++ b/dataforge-gui/src/main/kotlin/hep/dataforge/fx/FXPlugin.kt @@ -44,7 +44,7 @@ class FXPlugin(meta: Meta = Meta.empty()) : BasicPlugin(meta) { */ override fun attach(context: Context) { super.attach(context) - if (FX.getApplication(DefaultScope) == null) { + if (FX.getApplication(FX.defaultScope) == null) { if (consoleMode) { Thread { context.logger.debug("Starting FX application surrogate") @@ -70,7 +70,7 @@ class FXPlugin(meta: Meta = Meta.empty()) : BasicPlugin(meta) { * Define an application to use in this context */ fun setApp(app: Application, stage: Stage) { - FX.registerApplication(DefaultScope, app, stage) + FX.registerApplication(FX.defaultScope, app, stage) } /** diff --git a/dataforge-gui/src/main/kotlin/hep/dataforge/fx/meta/MetaViewer.kt b/dataforge-gui/src/main/kotlin/hep/dataforge/fx/meta/MetaViewer.kt index 3532e4f6..e2385faa 100644 --- a/dataforge-gui/src/main/kotlin/hep/dataforge/fx/meta/MetaViewer.kt +++ b/dataforge-gui/src/main/kotlin/hep/dataforge/fx/meta/MetaViewer.kt @@ -18,7 +18,6 @@ package hep.dataforge.fx.meta import hep.dataforge.fx.dfIconView import hep.dataforge.meta.Meta -import hep.dataforge.toList import hep.dataforge.values.Value import javafx.beans.property.SimpleStringProperty import javafx.beans.property.StringProperty @@ -55,8 +54,8 @@ open class MetaViewer(val meta: Meta, title: String = "Meta viewer: ${meta.name} is MetaItem -> { val meta = value.meta Stream.concat( - meta.nodeNames.flatMap { meta.getMetaList(it).stream() }.map { MetaItem(it) }, - meta.valueNames.map { ValueItem(it, meta.getValue(it)) } + meta.nodeNames.flatMap { meta.getMetaList(it).stream() }.map { MetaItem(it) }, + meta.valueNames.map { ValueItem(it, meta.getValue(it)) } ).toList() } is ValueItem -> null diff --git a/dataforge-gui/src/main/kotlin/hep/dataforge/fx/output/FXOuptutManager.kt b/dataforge-gui/src/main/kotlin/hep/dataforge/fx/output/FXOuptutManager.kt index 1f58a888..32b84362 100644 --- a/dataforge-gui/src/main/kotlin/hep/dataforge/fx/output/FXOuptutManager.kt +++ b/dataforge-gui/src/main/kotlin/hep/dataforge/fx/output/FXOuptutManager.kt @@ -131,7 +131,7 @@ class OutputContainer(val context: Context, val meta: Meta) : } override fun computeValue(): ObservableList { - return outputs.keys.toList().observable() + return outputs.keys.toList().asObservable() } } onUserSelect { @@ -169,7 +169,7 @@ class FXOutputManager( viewConsumer: Context.(OutputContainer) -> Unit = { getOrLoad(FXPlugin::class.java).display(it) } ) : OutputManager, BasicPlugin(meta) { - override val tag = PluginTag(name = "output.fx", dependsOn = *arrayOf("hep.dataforge:fx")) + override val tag = PluginTag(name = "output.fx", dependsOn = arrayOf("hep.dataforge:fx")) override fun attach(context: Context) { super.attach(context) diff --git a/dataforge-gui/src/main/kotlin/hep/dataforge/fx/output/FXTextOutput.kt b/dataforge-gui/src/main/kotlin/hep/dataforge/fx/output/FXTextOutput.kt index e9c8a59d..bb35d2ec 100644 --- a/dataforge-gui/src/main/kotlin/hep/dataforge/fx/output/FXTextOutput.kt +++ b/dataforge-gui/src/main/kotlin/hep/dataforge/fx/output/FXTextOutput.kt @@ -152,7 +152,7 @@ class FXTextOutput(context: Context) : FXOutput(context), TextOutput { } private fun countLines(): Int { - return textArea.text.chars().filter { value: Int -> value == '\n'.toInt() }.count().toInt() + return textArea.text.chars().filter { value: Int -> value == '\n'.code }.count().toInt() } /** diff --git a/dataforge-gui/src/main/kotlin/hep/dataforge/fx/table/TableDisplay.kt b/dataforge-gui/src/main/kotlin/hep/dataforge/fx/table/TableDisplay.kt index 478f55cb..590654c5 100644 --- a/dataforge-gui/src/main/kotlin/hep/dataforge/fx/table/TableDisplay.kt +++ b/dataforge-gui/src/main/kotlin/hep/dataforge/fx/table/TableDisplay.kt @@ -58,8 +58,8 @@ class TableDisplay(title: String? = null) : Fragment(title = title, icon = dfIco (0 until table.size()).forEach { i -> rows += (0 until format.count()) - .map { j -> buildCell(i, j, table.get(format.names[j], i)) } - .observable() + .map { j -> buildCell(i, j, table.get(format.names[j], i)) } + .asObservable() } } } diff --git a/dataforge-maths/build.gradle b/dataforge-maths/build.gradle index aaa74a68..b35b8f9b 100644 --- a/dataforge-maths/build.gradle +++ b/dataforge-maths/build.gradle @@ -1,5 +1,5 @@ description = 'Commons math dependency and some useful tools' dependencies { - compile 'org.apache.commons:commons-math3:3.+' - compile project(':dataforge-core') + api 'org.apache.commons:commons-math3:3.+' + api project(':dataforge-core') } diff --git a/dataforge-maths/src/main/kotlin/hep/dataforge/maths/expressions/DSNumber.kt b/dataforge-maths/src/main/kotlin/hep/dataforge/maths/expressions/DSNumber.kt index a877aa5e..2988b070 100644 --- a/dataforge-maths/src/main/kotlin/hep/dataforge/maths/expressions/DSNumber.kt +++ b/dataforge-maths/src/main/kotlin/hep/dataforge/maths/expressions/DSNumber.kt @@ -14,9 +14,9 @@ class DSNumber(val ds: DerivativeStructure, nc: DSField) : FieldCompat(val names: NameList, private val field: Field = BasicExpression { field.one } - override fun transform(n: T): Expression { - return if (n is Expression<*>) { - n as Expression - } else { - BasicExpression { field.transform(n) } - } - } + override fun transform(n: T): Expression = n as? Expression ?: BasicExpression { field.transform(n) } override fun add(a: T, b: T): Expression { TODO("not implemented") //To change body of created functions use File | Settings | File Templates. diff --git a/dataforge-plots/build.gradle b/dataforge-plots/build.gradle index 5f7bea40..e31d8b2a 100644 --- a/dataforge-plots/build.gradle +++ b/dataforge-plots/build.gradle @@ -9,5 +9,5 @@ description = 'dataforge-plots' dependencies { - compile project(':dataforge-core') + api project(':dataforge-core') } diff --git a/dataforge-plots/plots-jfc/build.gradle b/dataforge-plots/plots-jfc/build.gradle index 2ff8e777..7cd2b25c 100644 --- a/dataforge-plots/plots-jfc/build.gradle +++ b/dataforge-plots/plots-jfc/build.gradle @@ -8,9 +8,9 @@ description = 'jFreeChart plugin' dependencies { - compile 'org.jfree:jfreesvg:3.3' + api 'org.jfree:jfreesvg:3.3' // https://mvnrepository.com/artifact/org.jfree/jfreechart-fx - compile group: 'org.jfree', name: 'jfreechart-fx', version: '1.0.1' + api group: 'org.jfree', name: 'jfreechart-fx', version: '1.0.1' - compile project(":dataforge-plots") + api project(":dataforge-plots") } \ No newline at end of file diff --git a/dataforge-plots/plots-jfc/src/main/kotlin/hep/dataforge/plots/jfreechart/JFreeChartFrame.kt b/dataforge-plots/plots-jfc/src/main/kotlin/hep/dataforge/plots/jfreechart/JFreeChartFrame.kt index 7f183d56..a013b1cc 100644 --- a/dataforge-plots/plots-jfc/src/main/kotlin/hep/dataforge/plots/jfreechart/JFreeChartFrame.kt +++ b/dataforge-plots/plots-jfc/src/main/kotlin/hep/dataforge/plots/jfreechart/JFreeChartFrame.kt @@ -151,7 +151,7 @@ class JFreeChartFrame : XYPlotFrame(), FXPlotFrame, Serializable { } private fun getAxis(axisMeta: Meta): ValueAxis { - return when (axisMeta.getString("type", "number").toLowerCase()) { + return when (axisMeta.getString("type", "number").lowercase()) { "log" -> getLogAxis(axisMeta) "time" -> getDateAxis(axisMeta) else -> getNumberAxis(axisMeta) @@ -273,7 +273,7 @@ class JFreeChartFrame : XYPlotFrame(), FXPlotFrame, Serializable { val render: XYLineAndShapeRenderer = if (config.getBoolean("showErrors", true)) { XYErrorRenderer() } else { - when (config.getString("connectionType", "DEFAULT").toUpperCase()) { + when (config.getString("connectionType", "DEFAULT").uppercase()) { "STEP" -> XYStepRenderer() "SPLINE" -> XYSplineRenderer() else -> XYLineAndShapeRenderer() diff --git a/dataforge-plots/plots-viewer/build.gradle b/dataforge-plots/plots-viewer/build.gradle index 4c25fe29..a439114d 100644 --- a/dataforge-plots/plots-viewer/build.gradle +++ b/dataforge-plots/plots-viewer/build.gradle @@ -1,5 +1,5 @@ plugins { - id "com.github.johnrengelman.shadow" version "7.0.0" + id "com.github.johnrengelman.shadow" id 'application' } @@ -19,6 +19,6 @@ compileKotlin { } dependencies { - compile project(':dataforge-plots:plots-jfc') - compile project(':dataforge-gui') + api project(':dataforge-plots:plots-jfc') + api project(':dataforge-gui') } diff --git a/dataforge-plots/src/main/kotlin/hep/dataforge/plots/data/DataPlotUtils.kt b/dataforge-plots/src/main/kotlin/hep/dataforge/plots/data/DataPlotUtils.kt index 00ed5b24..b265df73 100644 --- a/dataforge-plots/src/main/kotlin/hep/dataforge/plots/data/DataPlotUtils.kt +++ b/dataforge-plots/src/main/kotlin/hep/dataforge/plots/data/DataPlotUtils.kt @@ -11,10 +11,8 @@ import hep.dataforge.tables.Adapters import hep.dataforge.tables.ListTable import hep.dataforge.tables.MetaTableFormat import hep.dataforge.tables.Table -import hep.dataforge.toList import hep.dataforge.values.Value import hep.dataforge.values.ValueMap -import java.util.* /** * @author Alexander Nozik @@ -28,19 +26,19 @@ object DataPlotUtils { names.add("x") frame.plots.stream().map { it.second } - .filter {!visibleOnly || it.config.getBoolean("visible", true) } - .forEach { - (it as? Plot)?.let {plot-> - names.add(plot.title) - plot.data.forEach { point -> - val x = Adapters.getXValue(plot.adapter, point) - val mdp: ValueMap.Builder = points.getOrPut(x) { - ValueMap.Builder().apply { putValue("x", x) } - } - mdp.putValue(plot.title, Adapters.getYValue(plot.adapter, point)) + .filter { !visibleOnly || it.config.getBoolean("visible", true) } + .forEach { + (it as? Plot)?.let { plot -> + names.add(plot.title) + plot.data.forEach { point -> + val x = Adapters.getXValue(plot.adapter, point) + val mdp: ValueMap.Builder = points.getOrPut(x) { + ValueMap.Builder().apply { putValue("x", x) } } + mdp.putValue(plot.title, Adapters.getYValue(plot.adapter, point)) } } + } val res = ListTable.Builder(MetaTableFormat.forNames(names)) res.rows(points.values.stream().map { it.build() }.toList()) diff --git a/dataforge-plots/src/main/kotlin/hep/dataforge/plots/data/XYFunctionPlot.kt b/dataforge-plots/src/main/kotlin/hep/dataforge/plots/data/XYFunctionPlot.kt index 39d234f1..9c30d3ec 100644 --- a/dataforge-plots/src/main/kotlin/hep/dataforge/plots/data/XYFunctionPlot.kt +++ b/dataforge-plots/src/main/kotlin/hep/dataforge/plots/data/XYFunctionPlot.kt @@ -24,7 +24,6 @@ import hep.dataforge.meta.* import hep.dataforge.tables.Adapters import hep.dataforge.tables.Adapters.DEFAULT_XY_ADAPTER import hep.dataforge.tables.Adapters.buildXYDataPoint -import hep.dataforge.toList import hep.dataforge.values.Value import hep.dataforge.values.ValueType.BOOLEAN import hep.dataforge.values.ValueType.NUMBER @@ -38,14 +37,15 @@ import kotlin.collections.set * @author Alexander Nozik */ @ValueDefs( - ValueDef(key = "showLine", type = arrayOf(BOOLEAN), def = "true", info = "Show the connecting line."), - ValueDef(key = "showSymbol", type = arrayOf(BOOLEAN), def = "false", info = "Show symbols for data point."), - ValueDef(key = "showErrors", type = arrayOf(BOOLEAN), def = "false", info = "Show errors for points."), - ValueDef(key = "range.from", type = arrayOf(NUMBER), def = "0.0", info = "Lower boundary for calculation range"), - ValueDef(key = "range.to", type = arrayOf(NUMBER), def = "1.0", info = "Upper boundary for calculation range"), - ValueDef(key = "density", type = arrayOf(NUMBER), def = "200", info = "Minimal number of points per plot") + ValueDef(key = "showLine", type = arrayOf(BOOLEAN), def = "true", info = "Show the connecting line."), + ValueDef(key = "showSymbol", type = arrayOf(BOOLEAN), def = "false", info = "Show symbols for data point."), + ValueDef(key = "showErrors", type = arrayOf(BOOLEAN), def = "false", info = "Show errors for points."), + ValueDef(key = "range.from", type = arrayOf(NUMBER), def = "0.0", info = "Lower boundary for calculation range"), + ValueDef(key = "range.to", type = arrayOf(NUMBER), def = "1.0", info = "Upper boundary for calculation range"), + ValueDef(key = "density", type = arrayOf(NUMBER), def = "200", info = "Minimal number of points per plot") ) -class XYFunctionPlot(name: String, meta: Meta = Meta.empty(), val function: (Double) -> Double) : XYPlot(name, meta, Adapters.DEFAULT_XY_ADAPTER) { +class XYFunctionPlot(name: String, meta: Meta = Meta.empty(), val function: (Double) -> Double) : + XYPlot(name, meta, Adapters.DEFAULT_XY_ADAPTER) { private val cache = TreeMap() @@ -71,12 +71,12 @@ class XYFunctionPlot(name: String, meta: Meta = Meta.empty(), val function: (Dou } var range by config.mutableCustomNode( - "range", - read = { Pair(it.getDouble("from"), it.getDouble("to")) }, - write = { - invalidateCache() - buildMeta("range", "from" to it.first, "to" to it.second) - } + "range", + read = { Pair(it.getDouble("from"), it.getDouble("to")) }, + write = { + invalidateCache() + buildMeta("range", "from" to it.first, "to" to it.second) + } ) override fun applyValueChange(name: String, oldValue: Value?, newValue: Value?) { @@ -142,9 +142,9 @@ class XYFunctionPlot(name: String, meta: Meta = Meta.empty(), val function: (Dou override val descriptor: NodeDescriptor by lazy { Descriptors.forType("plot", this::class) - .builder() - .apply { setDefault("connectionType".asName(), ConnectionType.SPLINE) } - .build() + .builder() + .apply { setDefault("connectionType".asName(), ConnectionType.SPLINE) } + .build() } override fun getRawData(query: Meta): List { @@ -160,8 +160,8 @@ class XYFunctionPlot(name: String, meta: Meta = Meta.empty(), val function: (Dou } validateCache() return cache.entries.stream() - .map { entry -> buildXYDataPoint(DEFAULT_XY_ADAPTER, entry.key, entry.value) } - .toList() + .map { entry -> buildXYDataPoint(DEFAULT_XY_ADAPTER, entry.key, entry.value) } + .toList() } companion object { @@ -169,7 +169,14 @@ class XYFunctionPlot(name: String, meta: Meta = Meta.empty(), val function: (Dou const val DEFAULT_DENSITY = 200 @JvmOverloads - fun plot(name: String, from: Double, to: Double, numPoints: Int = DEFAULT_DENSITY, meta: Meta = Meta.empty(), function: (Double) -> Double): XYFunctionPlot { + fun plot( + name: String, + from: Double, + to: Double, + numPoints: Int = DEFAULT_DENSITY, + meta: Meta = Meta.empty(), + function: (Double) -> Double, + ): XYFunctionPlot { val p = XYFunctionPlot(name, meta, function) p.range = Pair(from, to) p.density = numPoints diff --git a/dataforge-plots/src/main/kotlin/hep/dataforge/plots/data/XYPlot.kt b/dataforge-plots/src/main/kotlin/hep/dataforge/plots/data/XYPlot.kt index 416ca859..2c73cf8a 100644 --- a/dataforge-plots/src/main/kotlin/hep/dataforge/plots/data/XYPlot.kt +++ b/dataforge-plots/src/main/kotlin/hep/dataforge/plots/data/XYPlot.kt @@ -24,7 +24,6 @@ import hep.dataforge.meta.MetaBuilder import hep.dataforge.tables.Adapters import hep.dataforge.tables.ValuesAdapter import hep.dataforge.tables.ValuesAdapter.ADAPTER_KEY -import hep.dataforge.toList import hep.dataforge.values.Value import hep.dataforge.values.ValueType import hep.dataforge.values.Values @@ -39,14 +38,17 @@ import java.util.stream.Stream //@ValueDef(name = "symbolSize", type = "NUMBER", info = "The size of the symbols for scatterplot.") //@ValueDef(name = "lineType", info = "The type of the line fill.") @ValueDefs( - ValueDef(key = "color", info = "The color of line or symbol.", tags = ["widget:color"]), - ValueDef(key = "thickness", type = [ValueType.NUMBER], def = "1", info = "Thickness of the line if it is present"), - ValueDef(key = "connectionType", def = "DEFAULT", enumeration = XYPlot.ConnectionType::class, info = "Connection line type") + ValueDef(key = "color", info = "The color of line or symbol.", tags = ["widget:color"]), + ValueDef(key = "thickness", type = [ValueType.NUMBER], def = "1", info = "Thickness of the line if it is present"), + ValueDef(key = "connectionType", + def = "DEFAULT", + enumeration = XYPlot.ConnectionType::class, + info = "Connection line type") ) @NodeDef(key = ADAPTER_KEY, info = "An adapter to interpret the dataset", tags = [FINAL_TAG]) abstract class XYPlot(name: String, meta: Meta, adapter: ValuesAdapter?) : AbstractPlot(name, meta, adapter) { - enum class ConnectionType{ + enum class ConnectionType { DEFAULT, STEP, SPLINE @@ -57,7 +59,8 @@ abstract class XYPlot(name: String, meta: Meta, adapter: ValuesAdapter?) : Abstr } fun getData(from: Value, to: Value, numPoints: Int): List { - return getData(MetaBuilder("").putValue("xRange.from", from).putValue("xRange.to", to).putValue("numPoints", numPoints)) + return getData(MetaBuilder("").putValue("xRange.from", from).putValue("xRange.to", to) + .putValue("numPoints", numPoints)) } /** diff --git a/dataforge-stat/build.gradle b/dataforge-stat/build.gradle index f148efa3..33c0271b 100644 --- a/dataforge-stat/build.gradle +++ b/dataforge-stat/build.gradle @@ -1,5 +1,5 @@ description = 'dataforge-fitting' dependencies { - compile project(':dataforge-maths') + api project(':dataforge-maths') } diff --git a/dataforge-stat/dataforge-minuit/build.gradle b/dataforge-stat/dataforge-minuit/build.gradle index b8a6b2a6..ff10d621 100644 --- a/dataforge-stat/dataforge-minuit/build.gradle +++ b/dataforge-stat/dataforge-minuit/build.gradle @@ -1,5 +1,5 @@ description = 'dataforge-minuit' dependencies { - compile project(':dataforge-stat') + api project(':dataforge-stat') } diff --git a/dataforge-stat/src/main/kotlin/hep/dataforge/stat/fit/Fitter.kt b/dataforge-stat/src/main/kotlin/hep/dataforge/stat/fit/Fitter.kt index f0c48aa5..41baabe5 100644 --- a/dataforge-stat/src/main/kotlin/hep/dataforge/stat/fit/Fitter.kt +++ b/dataforge-stat/src/main/kotlin/hep/dataforge/stat/fit/Fitter.kt @@ -33,7 +33,7 @@ interface Fitter : Named { fun run(state: FitState, parentLog: History?, meta: Meta): FitResult - @JvmDefault + fun run(state: FitState, parentLog: History? = null, meta: KMetaBuilder.() -> Unit): FitResult { return run(state, parentLog, buildMeta("fit", meta)) } diff --git a/dataforge-storage/build.gradle b/dataforge-storage/build.gradle index 0306f047..d5c54158 100644 --- a/dataforge-storage/build.gradle +++ b/dataforge-storage/build.gradle @@ -1,5 +1,5 @@ description = 'New API and implementation of dataforge-storage' dependencies { - compile project(':dataforge-core') + api project(':dataforge-core') } \ No newline at end of file diff --git a/dataforge-storage/src/main/kotlin/hep/dataforge/storage/Storage.kt b/dataforge-storage/src/main/kotlin/hep/dataforge/storage/Storage.kt index 363853bf..0bc50713 100644 --- a/dataforge-storage/src/main/kotlin/hep/dataforge/storage/Storage.kt +++ b/dataforge-storage/src/main/kotlin/hep/dataforge/storage/Storage.kt @@ -54,7 +54,7 @@ interface StorageElement : Named, Metoid, Provider, ContextAware, AutoConnectibl /** * Full name relative to root storage */ - @JvmDefault + val fullName: Name get() = if (parent == null) { Name.empty() @@ -88,7 +88,7 @@ interface Storage : StorageElement { * Get storage element (name notation for recursive calls). Null if not present */ @Provides(STORAGE_TARGET) - @JvmDefault + operator fun get(name: String): StorageElement? { return get(Name.of(name)) } @@ -96,7 +96,7 @@ interface Storage : StorageElement { /** * Resolve storage element by its fully qualified name */ - @JvmDefault + operator fun get(name: Name): StorageElement? { return if (name.length == 1) { children.find { it.name == name.unescaped } @@ -105,13 +105,13 @@ interface Storage : StorageElement { } } - @JvmDefault + override fun getDefaultTarget(): String = STORAGE_TARGET /** * By default closes all children on close. If overridden, children should be closed before parent. */ - @JvmDefault + override fun close() { children.forEach { it.close() } } @@ -201,7 +201,7 @@ interface StorageElementType : Named { */ fun create(context: Context, meta: Meta, parent: StorageElement? = null): StorageElement - @JvmDefault + fun create(parent: StorageElement, meta: Meta): StorageElement { return create(parent.context, meta, parent) } diff --git a/dataforge-storage/src/main/kotlin/hep/dataforge/storage/files/FileTableLoader.kt b/dataforge-storage/src/main/kotlin/hep/dataforge/storage/files/FileTableLoader.kt index 5bff537e..4f7047c9 100644 --- a/dataforge-storage/src/main/kotlin/hep/dataforge/storage/files/FileTableLoader.kt +++ b/dataforge-storage/src/main/kotlin/hep/dataforge/storage/files/FileTableLoader.kt @@ -202,7 +202,7 @@ class AppendableFileTableLoader( private val textTableReader: (ByteBuffer, TableFormat) -> Values = { buffer, format -> val line = buildString { do { - val char = buffer.get().toChar() + val char = buffer.get().toInt().toChar() append(char) } while (char != '\n') } @@ -213,7 +213,7 @@ private val textTableReader: (ByteBuffer, TableFormat) -> Values = { buffer, for private val binaryTableReader: (ByteBuffer, TableFormat) -> Values = { buffer, format -> ValueMap(format.names.associate { it to buffer.getValue() }.toMap()).also { do { - val char = buffer.get().toChar() + val char = buffer.get().toInt().toChar() } while (char != '\n') } } @@ -238,7 +238,7 @@ class TableLoaderType : FileStorageElementType { format.names.map { values[it] }.forEach { stream.writeValue(it) } - stream.writeByte('\n'.toInt()) + stream.writeByte('\n'.code) stream.flush() ByteBuffer.wrap(baos.toByteArray()) } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0f80bbf5..e750102e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/grind/build.gradle b/grind/build.gradle index c9b06aea..1c785067 100644 --- a/grind/build.gradle +++ b/grind/build.gradle @@ -6,8 +6,10 @@ compileGroovy.dependsOn(compileKotlin) compileGroovy.classpath += files(compileKotlin.destinationDir) dependencies { - compile project(":dataforge-core") - compile 'org.codehaus.groovy:groovy-all:2.5+' + api project(":dataforge-core") + // https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all + api 'org.codehaus.groovy:groovy-all:3.0.9' - testCompile project(":dataforge-gui") + + testImplementation project(":dataforge-gui") } \ No newline at end of file diff --git a/grind/grind-terminal/build.gradle b/grind/grind-terminal/build.gradle index 6ecde71b..fd1384b2 100644 --- a/grind/grind-terminal/build.gradle +++ b/grind/grind-terminal/build.gradle @@ -1,7 +1,7 @@ plugins { id 'groovy' id 'application' - id "com.github.johnrengelman.shadow" version "7.0.0" + id "com.github.johnrengelman.shadow" } @@ -16,12 +16,12 @@ plugins { description = 'The grind plugin for dataforge framework' dependencies { - compile project(':grind') - compile project(':dataforge-plots:plots-jfc') - compile project(':dataforge-gui') - compile group: 'org.jline', name: 'jline', version: '3.5.1' -// compile group: 'net.java.dev.jna', name: 'jna', version: '4.4.0' - compile group: 'org.fusesource.jansi', name: 'jansi', version: '1.16' + api project(':grind') + api project(':dataforge-plots:plots-jfc') + api project(':dataforge-gui') + api group: 'org.jline', name: 'jline', version: '3.5.1' +// api group: 'net.java.dev.jna', name: 'jna', version: '4.4.0' + api group: 'org.fusesource.jansi', name: 'jansi', version: '1.16' } task shell(dependsOn: classes, type: JavaExec) { diff --git a/grind/groovymath/build.gradle b/grind/groovymath/build.gradle index 46b05a76..ca7a76af 100644 --- a/grind/groovymath/build.gradle +++ b/grind/groovymath/build.gradle @@ -1,6 +1,6 @@ apply plugin: 'groovy' dependencies { - compile project(':grind') - compile project(':dataforge-maths') + api project(':grind') + api project(':dataforge-maths') } diff --git a/grind/src/main/groovy/hep/dataforge/grind/workspace/GrindWorkspace.groovy b/grind/src/main/groovy/hep/dataforge/grind/workspace/GrindWorkspace.groovy index 0497f620..8a876972 100644 --- a/grind/src/main/groovy/hep/dataforge/grind/workspace/GrindWorkspace.groovy +++ b/grind/src/main/groovy/hep/dataforge/grind/workspace/GrindWorkspace.groovy @@ -7,6 +7,7 @@ import hep.dataforge.meta.Meta import hep.dataforge.workspace.Workspace import hep.dataforge.workspace.tasks.Task import org.jetbrains.annotations.NotNull +import org.slf4j.Logger /** * Workspace wrapper that implements methodMissing for tasks and propertyMissing for targets @@ -20,8 +21,6 @@ class GrindWorkspace implements Workspace { this.workspace = workspace } - - @Override DataNode getData() { return workspace.getData() @@ -57,6 +56,11 @@ class GrindWorkspace implements Workspace { return workspace.context } + @Override + Logger getLogger() { + return workspace.context.getLogger() + } + def methodMissing(String name, Object args) { String str = args.getClass().isArray() ? ((Object[]) args).join(" ") : args.toString() return runTask(name, str) diff --git a/grind/src/main/groovy/hep/dataforge/grind/workspace/WorkspaceSpec.groovy b/grind/src/main/groovy/hep/dataforge/grind/workspace/WorkspaceSpec.groovy index c89d10d9..3898dd75 100644 --- a/grind/src/main/groovy/hep/dataforge/grind/workspace/WorkspaceSpec.groovy +++ b/grind/src/main/groovy/hep/dataforge/grind/workspace/WorkspaceSpec.groovy @@ -55,7 +55,7 @@ class WorkspaceSpec { * @return */ @MethodDescription("Load data via closure") - void data(@DelegatesTo(value = DataNodeSpec, strategy = Closure.DELEGATE_FIRST) Closure cl) { + void data(@DelegatesTo(value = DataNodeSpec, strategy = Closure.DELEGATE_ONLY) Closure cl) { builder.data("", DataNodeSpec.buildNode(builder.context, cl)) } diff --git a/numass-control/build.gradle b/numass-control/build.gradle index 3c5ec191..ebe96e60 100644 --- a/numass-control/build.gradle +++ b/numass-control/build.gradle @@ -1,33 +1,10 @@ -allprojects { - apply plugin: "kotlin" - -// apply plugin: 'org.openjfx.javafxplugin' -// -// javafx { -// modules = [ 'javafx.controls' ] -// } - - compileKotlin { - kotlinOptions { - jvmTarget = "1.8" - javaParameters = true - } - } - - kotlin { - experimental { - coroutines "enable" - } - } -} - dependencies { - compile project(':dataforge-plots:plots-jfc') - compile project(':dataforge-control') - compile project(':dataforge-gui') + api project(':dataforge-plots:plots-jfc') + api project(':dataforge-control') + api project(':dataforge-gui') // https://mvnrepository.com/artifact/commons-cli/commons-cli - compile group: 'commons-cli', name: 'commons-cli', version: '1.4' + api group: 'commons-cli', name: 'commons-cli', version: '1.4' } diff --git a/numass-control/control-room/build.gradle b/numass-control/control-room/build.gradle index 1cb0d9d7..fd11abfc 100644 --- a/numass-control/control-room/build.gradle +++ b/numass-control/control-room/build.gradle @@ -1,6 +1,6 @@ plugins { id "application" - id 'com.github.johnrengelman.shadow' version '2.0.1' + id 'com.github.johnrengelman.shadow' } @@ -22,8 +22,8 @@ configurations { dependencies { //DataForge dependencies - compile project(':numass-control') - //compile project(':numass-server') + api project(':numass-control') + //api project(':numass-server') // optional device classpath devices project(':numass-control:cryotemp') diff --git a/numass-control/cryotemp/build.gradle b/numass-control/cryotemp/build.gradle index ce91400a..0b8ff45f 100644 --- a/numass-control/cryotemp/build.gradle +++ b/numass-control/cryotemp/build.gradle @@ -8,7 +8,7 @@ version = "0.2.0"; //mainClassName = "inr.numass.readvac.Main" dependencies { - compile project(':numass-control') + api project(':numass-control') } application{ diff --git a/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Channel.kt b/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Channel.kt index d6f5558f..08fd93ae 100644 --- a/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Channel.kt +++ b/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Channel.kt @@ -31,7 +31,7 @@ internal fun createChannel(meta: Meta): PKT8Channel { val coefs = meta.getValue("coefs").list val r0 = meta.getDouble("r0", 1000.0) return PKT8Channel(meta) { r -> - coefs.indices.sumByDouble { coefs[it].double * Math.pow(r0 / r, it.toDouble()) } + coefs.indices.sumOf { coefs[it].double * Math.pow(r0 / r, it.toDouble()) } } } else -> throw RuntimeException("Unknown transformation type") diff --git a/numass-control/dante/build.gradle b/numass-control/dante/build.gradle index 5e61a61e..57b232bd 100644 --- a/numass-control/dante/build.gradle +++ b/numass-control/dante/build.gradle @@ -17,6 +17,6 @@ version = "0.1.0" dependencies { - compile project(':numass-control') - compile project(':numass-core') + api project(':numass-control') + api project(':numass-core') } \ No newline at end of file diff --git a/numass-control/dante/src/main/kotlin/inr/numass/control/dante/DanteClient.kt b/numass-control/dante/src/main/kotlin/inr/numass/control/dante/DanteClient.kt index feb048e5..dc8fa69f 100644 --- a/numass-control/dante/src/main/kotlin/inr/numass/control/dante/DanteClient.kt +++ b/numass-control/dante/src/main/kotlin/inr/numass/control/dante/DanteClient.kt @@ -31,7 +31,6 @@ import kotlinx.coroutines.* import kotlinx.coroutines.channels.Channel import java.io.DataInputStream import java.io.OutputStream -import java.lang.Math.pow import java.net.Socket import java.nio.ByteBuffer import java.nio.ByteOrder @@ -39,8 +38,8 @@ import java.time.Duration import java.time.Instant import java.util.* import java.util.concurrent.atomic.AtomicLong -import kotlin.collections.HashMap import kotlin.math.ceil +import kotlin.math.pow internal val Byte.positive get() = toInt() and 0xFF @@ -254,7 +253,7 @@ class DanteClient(override val context: Context,val ip: String, chainLength: In } return sequence { - val intBuffer = ByteBuffer.wrap(message!!.payload).asIntBuffer() + val intBuffer = ByteBuffer.wrap(message.payload).asIntBuffer() while (intBuffer.hasRemaining()) { yield(intBuffer.get()) } @@ -298,7 +297,7 @@ class DanteClient(override val context: Context,val ip: String, chainLength: In assert(en_fil_flattop in 1..15) assert(fast_peak_time in 1..31) assert(fast_flattop in 1..31) - assert(recovery_time in (0.0..pow(2.0, 24.0) - 1)) + assert(recovery_time.toDouble() in (0.0..2.0.pow(24.0) - 1)) assert(zero_peak_rate in 0..500) assert(inverted_input in listOf(0, 1)) assert((en_fil_peak_time + en_fil_flattop) * 2 < 1023) diff --git a/numass-control/gun/build.gradle b/numass-control/gun/build.gradle index 70362097..0ffaeb30 100644 --- a/numass-control/gun/build.gradle +++ b/numass-control/gun/build.gradle @@ -20,5 +20,5 @@ if (!hasProperty('mainClass')) { mainClassName = mainClass dependencies { - compile project(':numass-control') + api project(':numass-control') } \ No newline at end of file diff --git a/numass-control/magnet/build.gradle b/numass-control/magnet/build.gradle index f97d0919..3bc1e6de 100644 --- a/numass-control/magnet/build.gradle +++ b/numass-control/magnet/build.gradle @@ -8,7 +8,7 @@ if (!hasProperty('mainClass')) { mainClassName = mainClass dependencies { - compile project(':numass-control') + api project(':numass-control') } task talkToServer(type: JavaExec) { diff --git a/numass-control/msp/build.gradle b/numass-control/msp/build.gradle index 97bce500..dfe63f8d 100644 --- a/numass-control/msp/build.gradle +++ b/numass-control/msp/build.gradle @@ -9,5 +9,5 @@ mainClassName = mainClass dependencies { - compile project(':numass-control') + api project(':numass-control') } \ No newline at end of file diff --git a/numass-control/src/main/kotlin/inr/numass/control/FXExtensions.kt b/numass-control/src/main/kotlin/inr/numass/control/FXExtensions.kt index c3e6bad9..836c11f1 100644 --- a/numass-control/src/main/kotlin/inr/numass/control/FXExtensions.kt +++ b/numass-control/src/main/kotlin/inr/numass/control/FXExtensions.kt @@ -95,7 +95,7 @@ fun Indicator.bind(connection: DeviceDisplayFX<*>, state: String, transform: ((V fun EventTarget.deviceStateIndicator(connection: DeviceDisplayFX<*>, state: String, showName: Boolean = true, transform: ((Value) -> Paint)? = null) { if (connection.device.stateNames.contains(state)) { if (showName) { - text("${state.toUpperCase()}: ") + text("${state.uppercase()}: ") } indicator { bind(connection, state, transform); diff --git a/numass-control/vac/build.gradle b/numass-control/vac/build.gradle index a36cf0ee..8fc97f47 100644 --- a/numass-control/vac/build.gradle +++ b/numass-control/vac/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'application' version = "0.6.0" dependencies { - compile project(':numass-control') + api project(':numass-control') } application{ diff --git a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/ThyroContVacDevice.kt b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/ThyroContVacDevice.kt index 0bca72be..130cc294 100644 --- a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/ThyroContVacDevice.kt +++ b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/ThyroContVacDevice.kt @@ -23,7 +23,7 @@ class ThyroContVacDevice(context: Context, meta: Meta) : PortSensor(context, met return GenericPortController(context, port) { it.endsWith("\r") } } - private fun String.checksum(): Char = (sumBy { it.toInt() } % 64 + 64).toChar() + private fun String.checksum(): Char = (sumBy { it.code } % 64 + 64).toChar() private fun wrap(str: String): String = buildString { append(str) diff --git a/numass-core/build.gradle b/numass-core/build.gradle index 430c0aff..6971e4b7 100644 --- a/numass-core/build.gradle +++ b/numass-core/build.gradle @@ -2,11 +2,11 @@ description = "A bse package with minimal dependencies for numass" dependencies { - compile project(":numass-core:numass-data-api") - compile project(":numass-core:numass-data-proto") - compile project(":dataforge-storage") - compile project(":dataforge-core:dataforge-json") + api project(":numass-core:numass-data-api") + api project(":numass-core:numass-data-proto") + api project(":dataforge-storage") + api project(":dataforge-core:dataforge-json") // https://mvnrepository.com/artifact/com.github.robtimus/sftp-fs - compile group: 'com.github.robtimus', name: 'sftp-fs', version: '1.1.3' + api group: 'com.github.robtimus', name: 'sftp-fs', version: '1.1.3' } \ No newline at end of file diff --git a/numass-core/numass-data-api/src/main/kotlin/inr/numass/data/api/NumassSet.kt b/numass-core/numass-data-api/src/main/kotlin/inr/numass/data/api/NumassSet.kt index 05a5ddde..593cec34 100644 --- a/numass-core/numass-data-api/src/main/kotlin/inr/numass/data/api/NumassSet.kt +++ b/numass-core/numass-data-api/src/main/kotlin/inr/numass/data/api/NumassSet.kt @@ -71,7 +71,6 @@ interface NumassSet : Named, Metoid, Iterable, Provider { return optPoint(java.lang.Double.parseDouble(voltage)) } - @JvmDefault override fun getDefaultTarget(): String { return NUMASS_POINT_PROVIDER_KEY } diff --git a/numass-core/numass-data-proto/build.gradle.kts b/numass-core/numass-data-proto/build.gradle.kts index 8f9bbdcc..072cd036 100644 --- a/numass-core/numass-data-proto/build.gradle.kts +++ b/numass-core/numass-data-proto/build.gradle.kts @@ -14,7 +14,7 @@ repositories { } dependencies { - implementation("com.google.protobuf:protobuf-java:3.17.1") + api("com.google.protobuf:protobuf-java:3.17.1") api(project(":numass-core:numass-data-api")) api(project(":dataforge-storage")) } diff --git a/numass-core/numass-data-proto/src/main/kotlin/inr/numass/data/NumassEnvelopeType.kt b/numass-core/numass-data-proto/src/main/kotlin/inr/numass/data/NumassEnvelopeType.kt index 7a85fab5..2b6e4221 100644 --- a/numass-core/numass-data-proto/src/main/kotlin/inr/numass/data/NumassEnvelopeType.kt +++ b/numass-core/numass-data-proto/src/main/kotlin/inr/numass/data/NumassEnvelopeType.kt @@ -25,7 +25,6 @@ import java.nio.ByteBuffer import java.nio.channels.FileChannel import java.nio.file.Path import java.nio.file.StandardOpenOption -import java.util.* /** * An envelope type for legacy numass tags. Reads legacy tag and writes DF02 tags @@ -106,8 +105,9 @@ class NumassEnvelopeType : EnvelopeType { companion object { val INSTANCE = NumassEnvelopeType() - val LEGACY_START_SEQUENCE = byteArrayOf('#'.toByte(), '!'.toByte()) - val LEGACY_END_SEQUENCE = byteArrayOf('!'.toByte(), '#'.toByte(), '\r'.toByte(), '\n'.toByte()) + val LEGACY_START_SEQUENCE = byteArrayOf('#'.code.toByte(), '!'.code.toByte()) + val LEGACY_END_SEQUENCE = + byteArrayOf('!'.code.toByte(), '#'.code.toByte(), '\r'.code.toByte(), '\n'.code.toByte()) /** * Replacement for standard type infer to include legacy type @@ -121,10 +121,10 @@ class NumassEnvelopeType : EnvelopeType { val buffer = it.map(FileChannel.MapMode.READ_ONLY, 0, 6) when { //TODO use templates from appropriate types - buffer.get(0) == '#'.toByte() && buffer.get(1) == '!'.toByte() -> INSTANCE - buffer.get(0) == '#'.toByte() && buffer.get(1) == '!'.toByte() && - buffer.get(4) == 'T'.toByte() && buffer.get(5) == 'L'.toByte() -> TaglessEnvelopeType.INSTANCE - buffer.get(0) == '#'.toByte() && buffer.get(1) == '~'.toByte() -> DefaultEnvelopeType.INSTANCE + buffer.get(0) == '#'.code.toByte() && buffer.get(1) == '!'.code.toByte() -> INSTANCE + buffer.get(0) == '#'.code.toByte() && buffer.get(1) == '!'.code.toByte() && + buffer.get(4) == 'T'.code.toByte() && buffer.get(5) == 'L'.code.toByte() -> TaglessEnvelopeType.INSTANCE + buffer.get(0) == '#'.code.toByte() && buffer.get(1) == '~'.code.toByte() -> DefaultEnvelopeType.INSTANCE else -> null } } diff --git a/numass-core/numass-signal-processing/src/main/kotlin/inr/numass/data/ChernovProcessor.kt b/numass-core/numass-signal-processing/src/main/kotlin/inr/numass/data/ChernovProcessor.kt index d0c2c892..597985c5 100644 --- a/numass-core/numass-signal-processing/src/main/kotlin/inr/numass/data/ChernovProcessor.kt +++ b/numass-core/numass-signal-processing/src/main/kotlin/inr/numass/data/ChernovProcessor.kt @@ -69,16 +69,16 @@ class ChernovProcessor( val timeInTicks = (pos + buffer.position() - 1) - val event = OrphanNumassEvent(amp.toShort(), (timeInTicks * tickSize).toLong()) + val event = OrphanNumassEvent(amp.toInt().toShort(), (timeInTicks * tickSize).toLong()) yield(event) //subtracting event from buffer copy - for (x in (signalRange.first + timeInTicks.toInt())..(signalRange.endInclusive + timeInTicks.toInt())) { + for (x in (signalRange.first + timeInTicks.toInt())..(signalRange.last + timeInTicks.toInt())) { //TODO check all roundings if (x >= 0 && x < buffer.limit()) { val oldValue = buffer.get(x) val newValue = oldValue - amp * signal(x - timeInTicks) / signalMax - buffer.put(x, newValue.toShort()) + buffer.put(x, newValue.toInt().toShort()) } } println(buffer.array().joinToString()) diff --git a/numass-core/numass-signal-processing/src/test/kotlin/inr/numass/data/ChernovProcessorTest.kt b/numass-core/numass-signal-processing/src/test/kotlin/inr/numass/data/ChernovProcessorTest.kt index 15d8ad6a..817389f5 100644 --- a/numass-core/numass-signal-processing/src/test/kotlin/inr/numass/data/ChernovProcessorTest.kt +++ b/numass-core/numass-signal-processing/src/test/kotlin/inr/numass/data/ChernovProcessorTest.kt @@ -12,7 +12,7 @@ class ChernovProcessorTest { val events = mapOf(10.0 to 1.0, 16.0 to 0.5) val buffer = ShortArray(40) { i -> - events.entries.sumByDouble { (pos, amp) -> amp * gaussian.value(pos - i.toDouble()) }.toInt().toShort() + events.entries.sumOf { (pos, amp) -> amp * gaussian.value(pos - i.toDouble()) }.toInt().toShort() } @Test diff --git a/numass-core/src/main/kotlin/inr/numass/data/analyzers/AbstractAnalyzer.kt b/numass-core/src/main/kotlin/inr/numass/data/analyzers/AbstractAnalyzer.kt index 4c4b4684..9a288d0f 100644 --- a/numass-core/src/main/kotlin/inr/numass/data/analyzers/AbstractAnalyzer.kt +++ b/numass-core/src/main/kotlin/inr/numass/data/analyzers/AbstractAnalyzer.kt @@ -22,7 +22,6 @@ import hep.dataforge.tables.ListTable import hep.dataforge.tables.Table import hep.dataforge.tables.TableFormat import hep.dataforge.tables.TableFormatBuilder -import hep.dataforge.toList import inr.numass.data.api.NumassBlock import inr.numass.data.api.NumassEvent import inr.numass.data.api.NumassPoint.Companion.HV_KEY diff --git a/numass-core/src/main/kotlin/inr/numass/data/analyzers/NumassAnalyzer.kt b/numass-core/src/main/kotlin/inr/numass/data/analyzers/NumassAnalyzer.kt index 28b14911..930fbe7a 100644 --- a/numass-core/src/main/kotlin/inr/numass/data/analyzers/NumassAnalyzer.kt +++ b/numass-core/src/main/kotlin/inr/numass/data/analyzers/NumassAnalyzer.kt @@ -172,8 +172,8 @@ fun Sequence.getAmplitudeSpectrum( } - val minChannel = config.getInt("window.lo") { spectrum.keys.min() ?: 0 } - val maxChannel = config.getInt("window.up") { spectrum.keys.max() ?: 4096 } + val minChannel = config.getInt("window.lo") { spectrum.keys.minOrNull() ?: 0 } + val maxChannel = config.getInt("window.up") { spectrum.keys.maxOrNull() ?: 4096 } return ListTable.Builder(format) .rows(IntStream.range(minChannel, maxChannel) diff --git a/numass-core/src/main/kotlin/inr/numass/data/analyzers/TimeAnalyzer.kt b/numass-core/src/main/kotlin/inr/numass/data/analyzers/TimeAnalyzer.kt index 303a0dc1..51ad2a04 100644 --- a/numass-core/src/main/kotlin/inr/numass/data/analyzers/TimeAnalyzer.kt +++ b/numass-core/src/main/kotlin/inr/numass/data/analyzers/TimeAnalyzer.kt @@ -30,18 +30,8 @@ import inr.numass.data.analyzers.NumassAnalyzer.Companion.LENGTH_KEY import inr.numass.data.analyzers.TimeAnalyzer.AveragingMethod.* import inr.numass.data.api.* import inr.numass.data.api.NumassPoint.Companion.HV_KEY -import java.util.* import java.util.concurrent.atomic.AtomicLong -import kotlin.collections.List -import kotlin.collections.asSequence -import kotlin.collections.count -import kotlin.collections.first -import kotlin.collections.map import kotlin.collections.set -import kotlin.collections.sortBy -import kotlin.collections.sumBy -import kotlin.collections.sumByDouble -import kotlin.collections.toMutableList import kotlin.math.* import kotlin.streams.asSequence @@ -163,20 +153,20 @@ open class TimeAnalyzer(processor: SignalProcessor? = null) : AbstractAnalyzer(p .build() } - val totalTime = sumByDouble { it.getDouble(LENGTH_KEY) } + val totalTime = sumOf { it.getDouble(LENGTH_KEY) } val (countRate, countRateDispersion) = when (method) { ARITHMETIC -> Pair( - sumByDouble { it.getDouble(COUNT_RATE_KEY) } / size, - sumByDouble { it.getDouble(COUNT_RATE_ERROR_KEY).pow(2.0) } / size / size + sumOf { it.getDouble(COUNT_RATE_KEY) } / size, + sumOf { it.getDouble(COUNT_RATE_ERROR_KEY).pow(2.0) } / size / size ) WEIGHTED -> Pair( - sumByDouble { it.getDouble(COUNT_RATE_KEY) * it.getDouble(LENGTH_KEY) } / totalTime, - sumByDouble { (it.getDouble(COUNT_RATE_ERROR_KEY) * it.getDouble(LENGTH_KEY) / totalTime).pow(2.0) } + sumOf { it.getDouble(COUNT_RATE_KEY) * it.getDouble(LENGTH_KEY) } / totalTime, + sumOf { (it.getDouble(COUNT_RATE_ERROR_KEY) * it.getDouble(LENGTH_KEY) / totalTime).pow(2.0) } ) GEOMETRIC -> { - val mean = exp(sumByDouble { ln(it.getDouble(COUNT_RATE_KEY)) } / size) - val variance = (mean / size).pow(2.0) * sumByDouble { + val mean = exp(sumOf { ln(it.getDouble(COUNT_RATE_KEY)) } / size) + val variance = (mean / size).pow(2.0) * sumOf { (it.getDouble(COUNT_RATE_ERROR_KEY) / it.getDouble( COUNT_RATE_KEY )).pow(2.0) @@ -187,7 +177,7 @@ open class TimeAnalyzer(processor: SignalProcessor? = null) : AbstractAnalyzer(p return ValueMap.Builder(first()) .putValue(LENGTH_KEY, totalTime) - .putValue(COUNT_KEY, sumBy { it.getInt(COUNT_KEY) }) + .putValue(COUNT_KEY, sumOf { it.getInt(COUNT_KEY) }) .putValue(COUNT_RATE_KEY, countRate) .putValue(COUNT_RATE_ERROR_KEY, sqrt(countRateDispersion)) .build() diff --git a/numass-main/build.gradle b/numass-main/build.gradle index 378f8fb6..2e9f254d 100644 --- a/numass-main/build.gradle +++ b/numass-main/build.gradle @@ -5,46 +5,26 @@ plugins { apply plugin: 'kotlin' -//apply plugin: 'org.openjfx.javafxplugin' -// -//javafx { -// modules = [ 'javafx.controls' ] -//} - -//if (!hasProperty('mainClass')) { -// ext.mainClass = 'inr.numass.LaunchGrindShell' -//} mainClassName = 'inr.numass.LaunchGrindShell' description = "Main numass project" -compileKotlin { - kotlinOptions { - jvmTarget = "1.8" - } -} -compileTestKotlin { - kotlinOptions { - jvmTarget = "1.8" - } -} - compileGroovy.dependsOn(compileKotlin) compileGroovy.classpath += files(compileKotlin.destinationDir) dependencies { - compile group: 'commons-cli', name: 'commons-cli', version: '1.+' - compile group: 'commons-io', name: 'commons-io', version: '2.+' - compile project(':numass-core') - compile project(':numass-core:numass-signal-processing') + api group: 'commons-cli', name: 'commons-cli', version: '1.+' + api group: 'commons-io', name: 'commons-io', version: '2.+' + api project(':numass-core') + api project(':numass-core:numass-signal-processing') compileOnly "org.jetbrains.kotlin:kotlin-main-kts:1.3.21" - compile project(':dataforge-stat:dataforge-minuit') - compile project(':grind:grind-terminal') - compile project(":dataforge-gui") - //compile "hep.dataforge:dataforge-html" + api project(':dataforge-stat:dataforge-minuit') + api project(':grind:grind-terminal') + api project(":dataforge-gui") + //api "hep.dataforge:dataforge-html" // https://mvnrepository.com/artifact/org.ehcache/ehcache - //compile group: 'org.ehcache', name: 'ehcache', version: '3.4.0' + //api group: 'org.ehcache', name: 'ehcache', version: '3.4.0' } diff --git a/numass-main/src/main/groovy/inr/numass/LaunchGrindShell.groovy b/numass-main/src/main/groovy/inr/numass/LaunchGrindShell.groovy index a1d7971e..b7be255b 100644 --- a/numass-main/src/main/groovy/inr/numass/LaunchGrindShell.groovy +++ b/numass-main/src/main/groovy/inr/numass/LaunchGrindShell.groovy @@ -1,5 +1,6 @@ package inr.numass +import groovy.cli.picocli.CliBuilder import hep.dataforge.context.Context import hep.dataforge.context.Global import hep.dataforge.fx.output.FXOutputManager @@ -8,7 +9,6 @@ import hep.dataforge.grind.workspace.GrindWorkspace import hep.dataforge.plots.jfreechart.JFreeChartPlugin import hep.dataforge.workspace.FileBasedWorkspace import hep.dataforge.workspace.Workspace -import groovy.cli.commons.CliBuilder /** * Created by darksnake on 29-Aug-16. diff --git a/numass-main/src/main/kotlin/inr/numass/data/NumassGenerator.kt b/numass-main/src/main/kotlin/inr/numass/data/NumassGenerator.kt index 487dc4c3..c72b2074 100644 --- a/numass-main/src/main/kotlin/inr/numass/data/NumassGenerator.kt +++ b/numass-main/src/main/kotlin/inr/numass/data/NumassGenerator.kt @@ -31,7 +31,7 @@ suspend fun Sequence.generateBlock(start: Instant, length: Lo private class MergingState(private val chains: List>) { suspend fun poll(): OrphanNumassEvent { - val next = chains.minBy { it.value.timeOffset } ?: chains.first() + val next = chains.minByOrNull { it.value.timeOffset } ?: chains.first() val res = next.value next.next() return res @@ -64,7 +64,8 @@ fun Chain.withDeadTime(deadTime: (OrphanNumassEvent) -> Long) object NumassGenerator { - val defaultAmplitudeGenerator: RandomGenerator.(OrphanNumassEvent?, Long) -> Short = { _, _ -> ((nextDouble() + 2.0) * 100).toShort() } + val defaultAmplitudeGenerator: RandomGenerator.(OrphanNumassEvent?, Long) -> Short = + { _, _ -> ((nextDouble() + 2.0) * 100).toInt().toShort() } /** * Generate an event chain with fixed count rate @@ -133,6 +134,6 @@ object NumassGenerator { } val distribution = EnumeratedRealDistribution(channels, values) - return generateEvents(cr, rnd) { _, _ -> distribution.sample().toShort() } + return generateEvents(cr, rnd) { _, _ -> distribution.sample().toInt().toShort() } } } \ No newline at end of file diff --git a/numass-main/src/main/kotlin/inr/numass/data/PileUpSimulator.kt b/numass-main/src/main/kotlin/inr/numass/data/PileUpSimulator.kt index b0d924ab..b6498228 100644 --- a/numass-main/src/main/kotlin/inr/numass/data/PileUpSimulator.kt +++ b/numass-main/src/main/kotlin/inr/numass/data/PileUpSimulator.kt @@ -30,7 +30,6 @@ import org.apache.commons.math3.random.RandomGenerator import java.lang.Math.max import java.time.Duration import java.time.Instant -import java.util.* import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.atomic.AtomicReference @@ -91,7 +90,7 @@ class PileUpSimulator { throw Error() } - return (prevChanel + coef * nextChanel).toShort() + return (prevChanel + coef * nextChanel).toInt().toShort() } /** diff --git a/numass-main/src/main/kotlin/inr/numass/models/misc/LossCalculator.kt b/numass-main/src/main/kotlin/inr/numass/models/misc/LossCalculator.kt index 7f82bcc1..64e8a5ed 100644 --- a/numass-main/src/main/kotlin/inr/numass/models/misc/LossCalculator.kt +++ b/numass-main/src/main/kotlin/inr/numass/models/misc/LossCalculator.kt @@ -281,7 +281,7 @@ object LossCalculator { 0.0 } else { val probs = getLossProbabilities(x) - (1 until probs.size).sumByDouble { i -> + (1 until probs.size).sumOf { i -> probs[i] * getLossValue(i, Ei, Ef) } } diff --git a/numass-main/src/main/kotlin/inr/numass/models/sterile/SterileNeutrinoSpectrum.kt b/numass-main/src/main/kotlin/inr/numass/models/sterile/SterileNeutrinoSpectrum.kt index a767adf9..116f0851 100644 --- a/numass-main/src/main/kotlin/inr/numass/models/sterile/SterileNeutrinoSpectrum.kt +++ b/numass-main/src/main/kotlin/inr/numass/models/sterile/SterileNeutrinoSpectrum.kt @@ -116,7 +116,7 @@ class SterileNeutrinoSpectrum @JvmOverloads constructor( return if (fss == null) { sourceFunction.value(0.0, eIn, set) } else { - (0 until fss.size()).sumByDouble { fss.getP(it) * sourceFunction.value(fss.getE(it), eIn, set) } + (0 until fss.size()).sumOf { fss.getP(it) * sourceFunction.value(fss.getE(it), eIn, set) } } } diff --git a/numass-main/src/main/kotlin/inr/numass/scripts/PileupIntensityDependency.kt b/numass-main/src/main/kotlin/inr/numass/scripts/PileupIntensityDependency.kt index e1daa6ed..0c49d5b8 100644 --- a/numass-main/src/main/kotlin/inr/numass/scripts/PileupIntensityDependency.kt +++ b/numass-main/src/main/kotlin/inr/numass/scripts/PileupIntensityDependency.kt @@ -84,20 +84,22 @@ fun main() { val rawSpectrum = analyzer.getAmplitudeSpectrum(point, meta).withBinning(20) group.add(DataPlot.plot("raw", rawSpectrum, AMPLITUDE_ADAPTER)) - val rawNorm = rawSpectrum.getColumn(NumassAnalyzer.COUNT_RATE_KEY).maxBy { it.double }!!.double + val rawNorm = rawSpectrum.getColumn(NumassAnalyzer.COUNT_RATE_KEY).maxByOrNull { it.double }!!.double val normalizedSpectrum = ColumnTable.copy(rawSpectrum) .replaceColumn(NumassAnalyzer.COUNT_RATE_KEY) { it.getDouble(NumassAnalyzer.COUNT_RATE_KEY) / rawNorm } normalizedFrame.add(DataPlot.plot("${setName}_raw", normalizedSpectrum, AMPLITUDE_ADAPTER)) - println("[$setName] Raw spectrum integral: ${rawSpectrum.getColumn(NumassAnalyzer.COUNT_RATE_KEY).sumByDouble { it.double }}") + println("[$setName] Raw spectrum integral: ${ + rawSpectrum.getColumn(NumassAnalyzer.COUNT_RATE_KEY).sumOf { it.double } + }") group.add(DataPlot.plot("filtered", analyzer.getAmplitudeSpectrum(point, metaForChain).withBinning(20), AMPLITUDE_ADAPTER)) val filteredSpectrum = analyzer.getAmplitudeSpectrum(point, metaForChainInverted).withBinning(20) group.add(DataPlot.plot("invertedFilter", filteredSpectrum, AMPLITUDE_ADAPTER)) - val filteredNorm = filteredSpectrum.getColumn(NumassAnalyzer.COUNT_RATE_KEY).maxBy { it.double }!!.double + val filteredNorm = filteredSpectrum.getColumn(NumassAnalyzer.COUNT_RATE_KEY).maxByOrNull { it.double }!!.double val normalizedFilteredSpectrum = ColumnTable.copy(filteredSpectrum) .replaceColumn(NumassAnalyzer.COUNT_RATE_KEY) { it.getDouble(NumassAnalyzer.COUNT_RATE_KEY) / filteredNorm } @@ -112,6 +114,8 @@ fun main() { group.add(DataPlot.plot("pileup", pileupSpectrum, AMPLITUDE_ADAPTER)) - println("[$setName] Pileup spectrum integral: ${pileupSpectrum.getColumn(NumassAnalyzer.COUNT_RATE_KEY).sumByDouble { it.double }}") + println("[$setName] Pileup spectrum integral: ${ + pileupSpectrum.getColumn(NumassAnalyzer.COUNT_RATE_KEY).sumOf { it.double } + }") } } diff --git a/numass-main/src/main/kotlin/inr/numass/scripts/PileupIntensityDependencyGun.kt b/numass-main/src/main/kotlin/inr/numass/scripts/PileupIntensityDependencyGun.kt index 2afacec2..2761f66e 100644 --- a/numass-main/src/main/kotlin/inr/numass/scripts/PileupIntensityDependencyGun.kt +++ b/numass-main/src/main/kotlin/inr/numass/scripts/PileupIntensityDependencyGun.kt @@ -86,20 +86,22 @@ fun main() { val rawSpectrum = analyzer.getAmplitudeSpectrum(point, meta).withBinning(20) group.add(DataPlot.plot("raw", rawSpectrum, AMPLITUDE_ADAPTER)) - val rawNorm = rawSpectrum.getColumn(NumassAnalyzer.COUNT_RATE_KEY).maxBy { it.double }!!.double + val rawNorm = rawSpectrum.getColumn(NumassAnalyzer.COUNT_RATE_KEY).maxByOrNull { it.double }!!.double val normalizedSpectrum = ColumnTable.copy(rawSpectrum) .replaceColumn(NumassAnalyzer.COUNT_RATE_KEY) { it.getDouble(NumassAnalyzer.COUNT_RATE_KEY) / rawNorm } normalizedFrame.add(DataPlot.plot("${setName}_raw", normalizedSpectrum, AMPLITUDE_ADAPTER)) - println("[$setName] Raw spectrum integral: ${rawSpectrum.getColumn(NumassAnalyzer.COUNT_RATE_KEY).sumByDouble { it.double }}") + println("[$setName] Raw spectrum integral: ${ + rawSpectrum.getColumn(NumassAnalyzer.COUNT_RATE_KEY).sumOf { it.double } + }") group.add(DataPlot.plot("filtered", analyzer.getAmplitudeSpectrum(point, metaForChain).withBinning(20), AMPLITUDE_ADAPTER)) val filteredSpectrum = analyzer.getAmplitudeSpectrum(point, metaForChainInverted).withBinning(20) group.add(DataPlot.plot("invertedFilter", filteredSpectrum, AMPLITUDE_ADAPTER)) - val filteredNorm = filteredSpectrum.getColumn(NumassAnalyzer.COUNT_RATE_KEY).maxBy { it.double }!!.double + val filteredNorm = filteredSpectrum.getColumn(NumassAnalyzer.COUNT_RATE_KEY).maxByOrNull { it.double }!!.double val normalizedFilteredSpectrum = ColumnTable.copy(filteredSpectrum) .replaceColumn(NumassAnalyzer.COUNT_RATE_KEY) { it.getDouble(NumassAnalyzer.COUNT_RATE_KEY) / filteredNorm } @@ -114,6 +116,8 @@ fun main() { group.add(DataPlot.plot("pileup", pileupSpectrum, AMPLITUDE_ADAPTER)) - println("[$setName] Pileup spectrum integral: ${pileupSpectrum.getColumn(NumassAnalyzer.COUNT_RATE_KEY).sumByDouble { it.double }}") + println("[$setName] Pileup spectrum integral: ${ + pileupSpectrum.getColumn(NumassAnalyzer.COUNT_RATE_KEY).sumOf { it.double } + }") } } diff --git a/numass-main/src/main/kotlin/inr/numass/scripts/tristan/ProtoPoint.kt b/numass-main/src/main/kotlin/inr/numass/scripts/tristan/ProtoPoint.kt index b21dea19..4a887c97 100644 --- a/numass-main/src/main/kotlin/inr/numass/scripts/tristan/ProtoPoint.kt +++ b/numass-main/src/main/kotlin/inr/numass/scripts/tristan/ProtoPoint.kt @@ -18,7 +18,6 @@ package inr.numass.scripts.tristan import hep.dataforge.context.Global import hep.dataforge.storage.files.FileStorage -import hep.dataforge.toList import inr.numass.data.api.NumassPoint import inr.numass.data.storage.NumassDataLoader import inr.numass.data.storage.NumassDirectory diff --git a/numass-main/src/main/kotlin/inr/numass/subthreshold/Threshold.kt b/numass-main/src/main/kotlin/inr/numass/subthreshold/Threshold.kt index 5f4a7635..ddd1ace1 100644 --- a/numass-main/src/main/kotlin/inr/numass/subthreshold/Threshold.kt +++ b/numass-main/src/main/kotlin/inr/numass/subthreshold/Threshold.kt @@ -10,7 +10,6 @@ import hep.dataforge.nullable import hep.dataforge.storage.Storage import hep.dataforge.tables.ListTable import hep.dataforge.tables.Table -import hep.dataforge.toList import hep.dataforge.values.ValueMap import hep.dataforge.values.Values import inr.numass.data.analyzers.* diff --git a/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt b/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt index 68fa6b82..2e0f49e7 100644 --- a/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt +++ b/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt @@ -43,7 +43,6 @@ import java.util.* import java.util.concurrent.atomic.AtomicLong import java.util.function.Predicate import java.util.stream.StreamSupport -import kotlin.collections.HashMap import kotlin.collections.set private val filterForward = DataFilter.byMetaValue("iteration_info.reverse") { @@ -372,7 +371,7 @@ val histogramTask = task("histogram") { .filter { points == null || points.contains(it.voltage) } .groupBy { it.voltage } .mapValues { - it.value.sumByDouble { it.length.toMillis().toDouble() / 1000 } + it.value.sumOf { it.length.toMillis().toDouble() / 1000 } } val normalize = meta.getBoolean("normalize", true) diff --git a/numass-viewer/build.gradle b/numass-viewer/build.gradle index 470c5a13..ea0b51a2 100644 --- a/numass-viewer/build.gradle +++ b/numass-viewer/build.gradle @@ -23,8 +23,8 @@ description = "The viewer for numass data" dependencies { - compile project(':numass-core') - compile project(':dataforge-plots:plots-jfc') - compile project(':dataforge-gui') + api project(':numass-core') + api project(':dataforge-plots:plots-jfc') + api project(':dataforge-gui') } diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/PointInfoView.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/PointInfoView.kt index 0305e726..c410b73d 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/PointInfoView.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/PointInfoView.kt @@ -26,7 +26,7 @@ class PointInfoView(val point: CachedPoint) : MetaViewer(point.meta) { button(graphic = FontAwesome.Glyph.REFRESH.toGlyph()) { action { GlobalScope.launch { - val res = point.spectrum.await().sumBy { it.getValue(NumassAnalyzer.COUNT_KEY).int } + val res = point.spectrum.await().sumOf { it.getValue(NumassAnalyzer.COUNT_KEY).int } runLater { count = res } } } diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index bb0e40ff..00000000 --- a/settings.gradle +++ /dev/null @@ -1,52 +0,0 @@ -rootProject.name = 'numass' - -include ':dataforge-core' // core classes and data structures -include ':dataforge-core:dataforge-json' // json meta converter -//include ':dataforge-core:osgi' // osgi framework for easy plugin delivery - -include ':dataforge-plots' // plot library -include ':dataforge-plots:plots-viewer' // Viewer application for exported plots -include ':dataforge-plots:plots-jfc' - -include ':dataforge-maths' // mathematical tools - -include ':grind' // GRoovy INteractive Dataforge -include ':grind:groovymath' // groovy mathematical extension -include ':grind:grind-terminal' - -//include 'kodex-server' // ktor based http server -//include ':kodex:dataforge-server' // server base - -include ':dataforge-gui' // javafx based gui -include ':dataforge-gui:dataforge-html' // HTML tools -include ':dataforge-gui:gui-demo' // javafx based gui -include ':dataforge-gui:gui-workspace' // javafx based gui - -include ':dataforge-stat' // fitting tools -include ':dataforge-stat:dataforge-minuit' // MINUIT plugin for fitting - -include ':dataforge-control' // tools for measurement and control applications - -include ':dataforge-storage' // storage2 module - -//include ':site'//the site - -include ":numass-control" -include ":numass-control:cryotemp" -include ":numass-control:magnet" -include ":numass-control:msp" -include ":numass-control:vac" -//include ":numass-control:control-room" -include ":numass-control:dante" -include ":numass-control:gun" -// -include ":numass-main" -// -include ":numass-core" - -include 'numass-core:numass-data-api' -include 'numass-core:numass-data-proto' -include 'numass-core:numass-signal-processing' - -include ":numass-viewer" - diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..0c6bcf85 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,52 @@ +rootProject.name = "numass" + +include(":dataforge-core") // core classes and data structures +include(":dataforge-core:dataforge-json") // json meta converter +//include(":dataforge-core:osgi") // osgi framework for easy plugin delivery + +include(":dataforge-plots") // plot library +include(":dataforge-plots:plots-viewer") // Viewer application for exported plots +include(":dataforge-plots:plots-jfc") + +include(":dataforge-maths") // mathematical tools + +include(":grind") // GRoovy INteractive Dataforge +include(":grind:groovymath") // groovy mathematical extension +include(":grind:grind-terminal") + +//include("kodex-server") // ktor based http server +//include(":kodex:dataforge-server") // server base + +include(":dataforge-gui") // javafx based gui +include(":dataforge-gui:dataforge-html") // HTML tools +include(":dataforge-gui:gui-demo") // javafx based gui +include(":dataforge-gui:gui-workspace") // javafx based gui + +include(":dataforge-stat") // fitting tools +include(":dataforge-stat:dataforge-minuit") // MINUIT plugin for fitting + +include(":dataforge-control") // tools for measurement and control applications + +include(":dataforge-storage") // storage2 module + +//include(":site")//the site + +include(":numass-control") +include(":numass-control:cryotemp") +include(":numass-control:magnet") +include(":numass-control:msp") +include(":numass-control:vac") +//include(":numass-control:control-room") +include(":numass-control:dante") +include(":numass-control:gun") +// +include(":numass-main") +// +include(":numass-core") + +include("numass-core:numass-data-api") +include("numass-core:numass-data-proto") +include("numass-core:numass-signal-processing") + +include(":numass-viewer") + diff --git a/site/build.gradle b/site/build.gradle index a38fb74f..4066a694 100644 --- a/site/build.gradle +++ b/site/build.gradle @@ -21,7 +21,7 @@ repositories { } dependencies { - compile "com.sysgears.grain:grain:0.7.1-SNAPSHOT" + api "com.sysgears.grain:grain:0.7.1-SNAPSHOT" } /**