diff --git a/numass-client/src/main/java/inr/numass/client/NumassClient.java b/numass-client/src/main/java/inr/numass/client/NumassClient.java index e3a0fbbf..389d54e6 100644 --- a/numass-client/src/main/java/inr/numass/client/NumassClient.java +++ b/numass-client/src/main/java/inr/numass/client/NumassClient.java @@ -92,18 +92,18 @@ public class NumassClient implements AutoCloseable, Responder { } public Meta getCurrentRun() { - return respond(requestActionBase("numass.run", "get").build()).meta(); + return respond(requestActionBase("numass.run", "get").build()).getMeta(); } public Meta startRun(String name) { return respond(requestActionBase("numass.run", "start") .putMetaValue("path", name) - .build()).meta(); + .build()).getMeta(); } public Meta resetRun() { return respond(requestActionBase("numass.run", "reset") - .build()).meta(); + .build()).getMeta(); } public Meta sendNumassData(String path, String fileName) { @@ -137,7 +137,7 @@ public class NumassClient implements AutoCloseable, Responder { .setData(buffer) .build(); - return respond(bin).meta(); + return respond(bin).getMeta(); } catch (IOException ex) { return StorageUtils.getErrorMeta(ex); } @@ -157,7 +157,7 @@ public class NumassClient implements AutoCloseable, Responder { env.putMetaValue("name", Arrays.asList(stateNames)); } - Meta response = respond(env.build()).meta(); + Meta response = respond(env.build()).getMeta(); if (response.getBoolean("success", true)) { Map res = new HashMap<>(); response.getMetaList("state").stream().forEach((stateMeta) -> { @@ -183,7 +183,7 @@ public class NumassClient implements AutoCloseable, Responder { .setValue("value", value) .build()); - return respond(env.build()).meta(); + return respond(env.build()).getMeta(); } /** @@ -200,7 +200,7 @@ public class NumassClient implements AutoCloseable, Responder { .setValue("value", state.getValue()) .build()); }); - return respond(env.build()).meta(); + return respond(env.build()).getMeta(); } public Meta addNote(String text, Instant time) { @@ -209,7 +209,7 @@ public class NumassClient implements AutoCloseable, Responder { if (time != null) { env.putMetaValue("note.time", time); } - return respond(env.build()).meta(); + return respond(env.build()).getMeta(); } public Meta getNotes(int limit) { @@ -217,7 +217,7 @@ public class NumassClient implements AutoCloseable, Responder { if (limit > 0) { env.putMetaValue("limit", limit); } - return respond(env.build()).meta(); + return respond(env.build()).getMeta(); } /** 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 62f3b02c..a225f7be 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 @@ -55,15 +55,15 @@ internal fun createChannel(meta: Meta): PKT8Channel { class PKT8Channel(private val _meta: Meta, val func: (Double) -> Double) : Named, Metoid { override fun getName(): String { - return meta().getString("name") + return getMeta().getString("name") } - override fun meta(): Meta { + override fun getMeta(): Meta { return _meta } fun description(): String { - return meta().getString("description", "") + return getMeta().getString("description", "") } /** diff --git a/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Device.kt b/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Device.kt index 33799997..9ba9213c 100644 --- a/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Device.kt +++ b/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Device.kt @@ -92,7 +92,7 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor(context, val abuf: String get() = getState(ABUF).stringValue() - private val duration = Duration.parse(meta().getString("averagingDuration", "PT30S")) + private val duration = Duration.parse(getMeta().getString("averagingDuration", "PT30S")) private fun buildLoader(connection: StorageConnection): TableLoader { val storage = connection.storage @@ -110,8 +110,8 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor(context, override fun init() { //read channel configuration - if (meta().hasMeta("channel")) { - for (node in meta().getMetaList("channel")) { + if (getMeta().hasMeta("channel")) { + for (node in getMeta().getMetaList("channel")) { val designation = node.getString("designation", "default") this.channels.put(designation, createChannel(node)) } @@ -137,8 +137,8 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor(context, } - setSPS(meta().getInt("sps", 0)) - setBUF(meta().getInt("abuf", 100)) + setSPS(getMeta().getInt("sps", 0)) + setBUF(getMeta().getInt("abuf", 100)) // setting up the collector storageHelper = StorageHelper(this) { connection: StorageConnection -> this.buildLoader(connection) } @@ -156,7 +156,7 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor(context, //setup connection val handler: Port = if ("virtual" == portName) { logger.info("Starting {} using virtual debug port", name) - PKT8VirtualPort("PKT8", meta().getMetaOrEmpty("debug")) + PKT8VirtualPort("PKT8", getMeta().getMetaOrEmpty("debug")) } else { super.buildPort(portName) } diff --git a/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Display.kt b/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Display.kt index ef072cf1..bcfcb2ac 100644 --- a/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Display.kt +++ b/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Display.kt @@ -171,7 +171,7 @@ class PKT8Display : DeviceDisplay(), MeasurementListener { } init { - if (device.meta().hasMeta("plotConfig")) { + if (device.getMeta().hasMeta("plotConfig")) { with(plotFrame.plots) { //configure(device.meta().getMeta("plotConfig")) TimePlot.setMaxItems(this, 1000) @@ -199,7 +199,7 @@ class PKT8Display : DeviceDisplay(), MeasurementListener { } else { device.channels.values.find { it.name == channelName }?.let { TimePlot(it.name).apply { - configure(it.meta()) + configure(it.getMeta()) plotFrame.add(this) } } diff --git a/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8VirtualPort.kt b/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8VirtualPort.kt index 769d4493..cc706557 100644 --- a/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8VirtualPort.kt +++ b/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8VirtualPort.kt @@ -31,7 +31,7 @@ class PKT8VirtualPort(portName: String, meta: Meta) : VirtualPort(meta), Metoid "s" -> { val letters = arrayOf("a", "b", "c", "d", "e", "f", "g", "h") for (letter in letters) { - val channelMeta = MetaUtils.findNodeByValue(meta(), "channel", "letter", Value.of(letter)).orElse(Meta.empty()) + val channelMeta = MetaUtils.findNodeByValue(getMeta(), "channel", "letter", Value.of(letter)).orElse(Meta.empty()) val average: Double val sigma: Double diff --git a/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/LambdaHub.kt b/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/LambdaHub.kt index 88ee6e38..6649b945 100644 --- a/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/LambdaHub.kt +++ b/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/LambdaHub.kt @@ -8,7 +8,6 @@ import hep.dataforge.control.devices.StateDef import hep.dataforge.control.ports.Port import hep.dataforge.control.ports.PortFactory import hep.dataforge.description.ValueDef -import hep.dataforge.kodex.useEachMeta import hep.dataforge.meta.Meta import hep.dataforge.names.Name import hep.dataforge.values.ValueType diff --git a/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/VirtualLambdaPort.kt b/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/VirtualLambdaPort.kt index e5ac2974..47b09a34 100644 --- a/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/VirtualLambdaPort.kt +++ b/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/VirtualLambdaPort.kt @@ -1,4 +1,4 @@ -/* +/* * Copyright 2015 Alexander Nozik. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,7 +17,6 @@ package inr.numass.control.magnet import hep.dataforge.control.ports.VirtualPort import hep.dataforge.exceptions.PortException -import hep.dataforge.kodex.useEachMeta import hep.dataforge.meta.Meta import org.slf4j.LoggerFactory import java.time.Duration diff --git a/numass-control/msp/src/main/kotlin/inr/numass/control/msp/MspDevice.kt b/numass-control/msp/src/main/kotlin/inr/numass/control/msp/MspDevice.kt index c5af5a72..4b48aa99 100644 --- a/numass-control/msp/src/main/kotlin/inr/numass/control/msp/MspDevice.kt +++ b/numass-control/msp/src/main/kotlin/inr/numass/control/msp/MspDevice.kt @@ -74,7 +74,7 @@ class MspDevice(context: Context, meta: Meta) : PortSensor(context, meta val isFilamentOn: Boolean get() = getState("filamentOn").booleanValue() - private val averagingDuration: Duration = Duration.parse(meta().getString("averagingDuration", "PT30S")) + private val averagingDuration: Duration = Duration.parse(getMeta().getString("averagingDuration", "PT30S")) @Throws(ControlException::class) override fun init() { @@ -140,7 +140,7 @@ class MspDevice(context: Context, meta: Meta) : PortSensor(context, meta @Throws(MeasurementException::class) override fun createMeasurement(): PeakJumpMeasurement { - val measurementMeta = meta().getMeta("peakJump") + val measurementMeta = getMeta().getMeta("peakJump") val s = measurementMeta.getString("type", "peakJump") if (s == "peakJump") { val measurement = PeakJumpMeasurement(measurementMeta) diff --git a/numass-control/msp/src/main/kotlin/inr/numass/control/msp/MspDisplay.kt b/numass-control/msp/src/main/kotlin/inr/numass/control/msp/MspDisplay.kt index 2c25ab4d..959b4b87 100644 --- a/numass-control/msp/src/main/kotlin/inr/numass/control/msp/MspDisplay.kt +++ b/numass-control/msp/src/main/kotlin/inr/numass/control/msp/MspDisplay.kt @@ -71,7 +71,7 @@ class MspDisplay() : DeviceDisplay(), DeviceListener, NamedValueListe inner class MspView : View("Numass mass-spectrometer measurement") { - private val plotFrameMeta: Meta = device.meta().getMeta("plotConfig", device.meta) + private val plotFrameMeta: Meta = device.getMeta().getMeta("plotConfig", device.meta) private val plotFrame: PlotFrame by lazy { val basePlotConfig = MetaBuilder("plotFrame") diff --git a/numass-control/src/main/kotlin/inr/numass/control/ControlExtensions.kt b/numass-control/src/main/kotlin/inr/numass/control/ControlExtensions.kt new file mode 100644 index 00000000..c4fe978e --- /dev/null +++ b/numass-control/src/main/kotlin/inr/numass/control/ControlExtensions.kt @@ -0,0 +1,62 @@ +package inr.numass.control + +import hep.dataforge.control.devices.Stateful +import hep.dataforge.values.Value +import java.time.Instant +import kotlin.reflect.KProperty + +class StateDelegate(private val stateName: String?) { + operator fun getValue(thisRef: Stateful, property: KProperty<*>): Value? = + thisRef.getState(stateName ?: property.name) + + operator fun setValue(thisRef: Stateful, property: KProperty<*>, value: Value?) { + thisRef.setState(stateName ?: property.name, value); + } +} + +class StringStateDelegate(private val stateName: String?) { + operator fun getValue(thisRef: Stateful, property: KProperty<*>): String? = + thisRef.getState(stateName ?: property.name).stringValue() + + operator fun setValue(thisRef: Stateful, property: KProperty<*>, value: String?) { + thisRef.setState(stateName ?: property.name, value); + } +} + +class BooleanStateDelegate(private val stateName: String?) { + operator fun getValue(thisRef: Stateful, property: KProperty<*>): Boolean? = + thisRef.getState(stateName ?: property.name).booleanValue() + + operator fun setValue(thisRef: Stateful, property: KProperty<*>, value: Boolean?) { + thisRef.setState(stateName ?: property.name, value); + } +} + +class TimeStateDelegate(private val stateName: String?) { + operator fun getValue(thisRef: Stateful, property: KProperty<*>): Instant? = + thisRef.getState(stateName ?: property.name).timeValue() + + operator fun setValue(thisRef: Stateful, property: KProperty<*>, value: Instant?) { + thisRef.setState(stateName ?: property.name, value); + } +} + +class NumberStateDelegate(private val stateName: String?) { + operator fun getValue(thisRef: Stateful, property: KProperty<*>): Number? = + thisRef.getState(stateName ?: property.name).numberValue() + + operator fun setValue(thisRef: Stateful, property: KProperty<*>, value: Number?) { + thisRef.setState(stateName ?: property.name, value); + } +} + + +/** + * Delegate states to read/write property + */ +fun Stateful.state(stateName: String? = null) = StateDelegate(stateName) + +fun Stateful.stringState(stateName: String? = null) = StringStateDelegate(stateName) +fun Stateful.booleanState(stateName: String? = null) = BooleanStateDelegate(stateName) +fun Stateful.timeState(stateName: String? = null) = TimeStateDelegate(stateName) +fun Stateful.numberState(stateName: String? = null) = NumberStateDelegate(stateName) diff --git a/numass-control/src/main/kotlin/inr/numass/control/NumassControlUtils.kt b/numass-control/src/main/kotlin/inr/numass/control/NumassControlUtils.kt index 0bbafffa..8e7d6809 100644 --- a/numass-control/src/main/kotlin/inr/numass/control/NumassControlUtils.kt +++ b/numass-control/src/main/kotlin/inr/numass/control/NumassControlUtils.kt @@ -42,7 +42,7 @@ fun connectStorage(device: Device, config: Meta) { if (config.hasMeta("storage") && device.acceptsRole(Roles.STORAGE_ROLE)) { val numassRun = ClientUtils.getRunName(config) config.getMetaList("storage").forEach { node -> - device.context.logger.info("Creating storage for device with meta: {}", node) + device.context.logger.info("Creating storage for device with getMeta: {}", node) //building storage in a separate thread Thread { var storage = StorageFactory.buildStorage(device.context, node) diff --git a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/CM32Device.kt b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/CM32Device.kt index 83d86e6e..5ba26616 100644 --- a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/CM32Device.kt +++ b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/CM32Device.kt @@ -38,7 +38,9 @@ class CM32Device(context: Context, meta: Meta) : PortSensor(context, met override fun createMeasurement(): Measurement = CMVacMeasurement() - override fun getType(): String = meta().getString("type", "numass.vac.CM32") + override fun getType(): String { + return getMeta().getString("type", "Leibold CM32") + } private inner class CMVacMeasurement : SimpleMeasurement() { diff --git a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSBaratronDevice.kt b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSBaratronDevice.kt index b589d15a..c20ec6a2 100644 --- a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSBaratronDevice.kt +++ b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSBaratronDevice.kt @@ -23,12 +23,14 @@ import inr.numass.control.DeviceView @DeviceView(VacDisplay::class) class MKSBaratronDevice(context: Context, meta: Meta) : PortSensor(context, meta) { - private val channel: Int = meta().getInt("channel", 2) + private val channel: Int = getMeta().getInt("channel", 2) override fun createMeasurement(): Measurement = BaratronMeasurement() - override fun getType(): String = meta().getString("type", "numass.vac.baratron") + override fun getType(): String { + return getMeta().getString("type", "MKS baratron") + } @Throws(ControlException::class) override fun buildPort(portName: String): Port { diff --git a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSVacDevice.kt b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSVacDevice.kt index 9aa57e0f..062ed4a6 100644 --- a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSVacDevice.kt +++ b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSVacDevice.kt @@ -22,7 +22,6 @@ import inr.numass.control.DeviceView import javafx.beans.property.BooleanProperty import javafx.beans.property.SimpleBooleanProperty import javafx.beans.property.SimpleIntegerProperty -import javafx.beans.property.SimpleStringProperty import javafx.beans.property.adapter.JavaBeanBooleanPropertyBuilder import tornadofx.* import java.util.regex.Pattern @@ -39,8 +38,8 @@ import java.util.regex.Pattern @DeviceView(VacDisplay::class) class MKSVacDevice(context: Context, meta: Meta) : PortSensor(context, meta) { - val deviceAddressProperty = SimpleStringProperty() - var deviceAddress by deviceAddressProperty + private val deviceAddress: String + get() = getMeta().getString("address", "253") val isPowerOnProperty = SimpleBooleanProperty() @@ -105,7 +104,9 @@ class MKSVacDevice(context: Context, meta: Meta) : PortSensor(context, m } - override fun getType(): String = meta().getString("type", "MKS vacuumeter") + override fun getType(): String { + return getMeta().getString("type", "MKS vacuumeter") + } private inner class MKSVacMeasurement : SimpleMeasurement() { diff --git a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MeradatVacDevice.kt b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MeradatVacDevice.kt index 396e6010..27dbc50e 100644 --- a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MeradatVacDevice.kt +++ b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MeradatVacDevice.kt @@ -35,17 +35,19 @@ class MeradatVacDevice(context: Context, meta: Meta) : PortSensor(contex override fun createMeasurement(): Measurement = MeradatMeasurement() - override fun getType(): String = meta().getString("type", "Vit vacuumeter") + override fun getType(): String { + return getMeta().getString("type", "Vit vacuumeter") + } private inner class MeradatMeasurement : SimpleMeasurement() { - - private val response: Pattern - private val base: String = String.format(":%02d", meta().getInt("address", 1)) private val query: String // ":010300000002FA\r\n"; + private val response: Pattern + private val base: String init { + base = String.format(":%02d", getMeta().getInt("address", 1)) val dataStr = base.substring(1) + REQUEST query = base + REQUEST + calculateLRC(dataStr) + "\r\n" response = Pattern.compile(base + "0304(\\w{4})(\\w{4})..\r\n") diff --git a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacCollectorDevice.kt b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacCollectorDevice.kt index 39e9d891..75066eee 100644 --- a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacCollectorDevice.kt +++ b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacCollectorDevice.kt @@ -52,7 +52,7 @@ class VacCollectorDevice(context: Context, meta: Meta, val sensors: Collection = @@ -114,7 +114,7 @@ class VacCollectorDevice(context: Context, meta: Meta, val sensors: Collection Thread(r, "VacuumMeasurement thread") } - val delay = meta().getInt("delay", 5)!! * 1000 + val delay = getMeta().getInt("delay", 5)!! * 1000 currentTask = executor!!.scheduleWithFixedDelay({ sensors.forEach { sensor -> try { diff --git a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacCollectorDisplay.kt b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacCollectorDisplay.kt index bf390471..49212151 100644 --- a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacCollectorDisplay.kt +++ b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacCollectorDisplay.kt @@ -68,7 +68,7 @@ class VacCollectorDisplay : DeviceDisplay() { private val plottables = TimePlottableGroup().apply { viewList.forEach { val plot = TimePlot(it.getTitle(), it.device.name) - plot.configure(it.device.meta()) + plot.configure(it.device.getMeta()) add(plot) } setValue("thickness", 3) diff --git a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacDisplay.kt b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacDisplay.kt index d8e2e856..2c63deb4 100644 --- a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacDisplay.kt +++ b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacDisplay.kt @@ -78,7 +78,7 @@ open class VacDisplay : DeviceDisplay>(), MeasurementListener { } fun getTitle(): String{ - return device.meta().getString("title", device.name); + return device.getMeta().getString("title", device.name); } inner class VacView : View("Numass vacuumeter ${getTitle()}") { @@ -123,7 +123,7 @@ open class VacDisplay : DeviceDisplay>(), MeasurementListener { prefHeight = 60.0 alignment = Pos.CENTER_RIGHT textProperty().bind(valueProperty) - device.meta().optValue("color").ifPresent { colorValue -> textFill = Color.valueOf(colorValue.stringValue()) } + device.getMeta().optValue("color").ifPresent { colorValue -> textFill = Color.valueOf(colorValue.stringValue()) } style { fontSize = 24.pt fontWeight = FontWeight.BOLD @@ -136,7 +136,7 @@ open class VacDisplay : DeviceDisplay>(), MeasurementListener { prefHeight = 60.0 prefWidth = 75.0 alignment = Pos.CENTER_LEFT - text = device.meta().getString("units", "mbar") + text = device.getMeta().getString("units", "mbar") style { fontSize = 24.pt } diff --git a/numass-core/src/main/java/inr/numass/data/NumassDataUtils.java b/numass-core/src/main/java/inr/numass/data/NumassDataUtils.java index 56f3fe38..f0f50de8 100644 --- a/numass-core/src/main/java/inr/numass/data/NumassDataUtils.java +++ b/numass-core/src/main/java/inr/numass/data/NumassDataUtils.java @@ -35,9 +35,9 @@ public class NumassDataUtils { } @Override - public Meta meta() { + public Meta getMeta() { MetaBuilder metaBuilder = new MetaBuilder(); - sets.forEach(set -> metaBuilder.putNode(set.getName(), set.meta())); + sets.forEach(set -> metaBuilder.putNode(set.getName(), set.getMeta())); return metaBuilder; } diff --git a/numass-core/src/main/java/inr/numass/data/api/NumassPoint.java b/numass-core/src/main/java/inr/numass/data/api/NumassPoint.java index 3134839a..1c71d171 100644 --- a/numass-core/src/main/java/inr/numass/data/api/NumassPoint.java +++ b/numass-core/src/main/java/inr/numass/data/api/NumassPoint.java @@ -24,7 +24,7 @@ public interface NumassPoint extends Metoid, NumassBlock { * @return */ default double getVoltage() { - return meta().getDouble(HV_KEY, 0); + return getMeta().getDouble(HV_KEY, 0); } /** @@ -41,7 +41,7 @@ public interface NumassPoint extends Metoid, NumassBlock { */ @Override default Instant getStartTime() { - return meta().optValue(START_TIME_KEY).map(Value::timeValue).orElseGet(() -> getFirstBlock().getStartTime()); + return getMeta().optValue(START_TIME_KEY).map(Value::timeValue).orElseGet(() -> getFirstBlock().getStartTime()); } /** @@ -52,7 +52,7 @@ public interface NumassPoint extends Metoid, NumassBlock { @Override default Duration getLength() { return Duration.ofNanos( - meta().optValue(LENGTH_KEY).map(Value::longValue) + getMeta().optValue(LENGTH_KEY).map(Value::longValue) .orElseGet(() -> getBlocks().mapToLong(it -> it.getLength().toNanos()).sum()) ); } diff --git a/numass-core/src/main/java/inr/numass/data/api/NumassSet.java b/numass-core/src/main/java/inr/numass/data/api/NumassSet.java index 17bb638e..2d415f3e 100644 --- a/numass-core/src/main/java/inr/numass/data/api/NumassSet.java +++ b/numass-core/src/main/java/inr/numass/data/api/NumassSet.java @@ -33,7 +33,7 @@ public interface NumassSet extends Named, Metoid, Iterable, Provide Stream getPoints(); default String getDescription() { - return meta().getString(DESCRIPTION_KEY, ""); + return getMeta().getString(DESCRIPTION_KEY, ""); } @NotNull @@ -57,7 +57,7 @@ public interface NumassSet extends Named, Metoid, Iterable, Provide * @return */ default Instant getStartTime() { - return meta().optValue(NumassPoint.START_TIME_KEY).map(Value::timeValue).orElseGet(() -> getFirstPoint().getStartTime()); + return getMeta().optValue(NumassPoint.START_TIME_KEY).map(Value::timeValue).orElseGet(() -> getFirstPoint().getStartTime()); } /** diff --git a/numass-core/src/main/java/inr/numass/data/legacy/NumassDatFile.java b/numass-core/src/main/java/inr/numass/data/legacy/NumassDatFile.java index 7c3026fb..ca933a02 100644 --- a/numass-core/src/main/java/inr/numass/data/legacy/NumassDatFile.java +++ b/numass-core/src/main/java/inr/numass/data/legacy/NumassDatFile.java @@ -47,7 +47,7 @@ public class NumassDatFile implements NumassSet { } @Override - public Meta meta() { + public Meta getMeta() { return meta; } @@ -57,11 +57,11 @@ public class NumassDatFile implements NumassSet { } private double getHVdev() { - return meta().getDouble("dat.hvDev", 2.468555393226049); + return getMeta().getDouble("dat.hvDev", 2.468555393226049); } private boolean hasUset() { - return meta().getBoolean("dat.uSet", true); + return getMeta().getBoolean("dat.uSet", true); } private static String readHead(Path path) throws IOException { diff --git a/numass-core/src/main/java/inr/numass/data/storage/ClassicNumassPoint.java b/numass-core/src/main/java/inr/numass/data/storage/ClassicNumassPoint.java index 5f53f372..13486252 100644 --- a/numass-core/src/main/java/inr/numass/data/storage/ClassicNumassPoint.java +++ b/numass-core/src/main/java/inr/numass/data/storage/ClassicNumassPoint.java @@ -33,18 +33,18 @@ public class ClassicNumassPoint implements NumassPoint { public Stream getBlocks() { // double u = envelope.meta().getDouble("external_meta.HV1_value", 0); long length; - if (envelope.meta().hasValue("external_meta.acquisition_time")) { - length = envelope.meta().getValue("external_meta.acquisition_time").longValue(); + if (envelope.getMeta().hasValue("external_meta.acquisition_time")) { + length = envelope.getMeta().getValue("external_meta.acquisition_time").longValue(); } else { - length = envelope.meta().getValue("acquisition_time").longValue(); + length = envelope.getMeta().getValue("acquisition_time").longValue(); } return Stream.of(new ClassicBlock(getStartTime(), Duration.ofSeconds(length))); } @Override public Instant getStartTime() { - if (meta().hasValue("start_time")) { - return meta().getValue("start_time").timeValue(); + if (getMeta().hasValue("start_time")) { + return getMeta().getValue("start_time").timeValue(); } else { return Instant.EPOCH; } @@ -52,12 +52,12 @@ public class ClassicNumassPoint implements NumassPoint { @Override public double getVoltage() { - return meta().getDouble("external_meta.HV1_value", 0); + return getMeta().getDouble("external_meta.HV1_value", 0); } @Override - public Meta meta() { - return envelope.meta(); + public Meta getMeta() { + return envelope.getMeta(); } //TODO split blocks using meta @@ -90,7 +90,7 @@ public class ClassicNumassPoint implements NumassPoint { @NotNull @Override public Iterator iterator() { - double timeCoef = envelope.meta().getDouble("time_coeff", 50); + double timeCoef = envelope.getMeta().getDouble("time_coeff", 50); try { ByteBuffer buffer = ByteBuffer.allocate(7000); buffer.order(ByteOrder.LITTLE_ENDIAN); diff --git a/numass-core/src/main/java/inr/numass/data/storage/NumassDataLoader.java b/numass-core/src/main/java/inr/numass/data/storage/NumassDataLoader.java index 04f3142a..a8fd0a1c 100644 --- a/numass-core/src/main/java/inr/numass/data/storage/NumassDataLoader.java +++ b/numass-core/src/main/java/inr/numass/data/storage/NumassDataLoader.java @@ -148,11 +148,11 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader entry.getKey().startsWith(POINT_FRAGMENT_NAME) && entry.getValue() != null) .map(entry -> entry.getValue().get()) - .sorted(Comparator.comparing(t -> t.meta().getInt("external_meta.point_index", -1))); + .sorted(Comparator.comparing(t -> t.getMeta().getInt("external_meta.point_index", -1))); } @@ -188,7 +188,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader getFrames() { - Duration tickSize = Duration.ofNanos((long) (1e9 / meta().getInt("params.sample_freq"))); + Duration tickSize = Duration.ofNanos((long) (1e9 / getMeta().getInt("params.sample_freq"))); return block.getFramesList().stream().map(frame -> { Instant time = getStartTime().plusNanos(frame.getTime()); ByteBuffer data = frame.getData().asReadOnlyByteBuffer(); diff --git a/numass-main/src/main/java/inr/numass/NumassIO.java b/numass-main/src/main/java/inr/numass/NumassIO.java index 04a104f4..d58fdbbe 100644 --- a/numass-main/src/main/java/inr/numass/NumassIO.java +++ b/numass-main/src/main/java/inr/numass/NumassIO.java @@ -61,7 +61,7 @@ public class NumassIO extends BasicIOManager { ple.setContext(lc); ple.start(); FileAppender appender = new FileAppender<>(); - appender.setFile(new File(getWorkDirectory().toFile(), meta().getString("logFileName", "numass.log")).toString()); + appender.setFile(new File(getWorkDirectory().toFile(), getMeta().getString("logFileName", "numass.log")).toString()); appender.setEncoder(ple); return appender; } diff --git a/numass-main/src/main/kotlin/inr/numass/NumassUtils.kt b/numass-main/src/main/kotlin/inr/numass/NumassUtils.kt index e847d9ed..9eac8e6e 100644 --- a/numass-main/src/main/kotlin/inr/numass/NumassUtils.kt +++ b/numass-main/src/main/kotlin/inr/numass/NumassUtils.kt @@ -138,10 +138,10 @@ object NumassUtils { set.points.forEach { point -> val pointMeta = MetaBuilder("point") .putValue("voltage", point.voltage) - .putValue("index", point.meta().getInt("external_meta.point_index", -1)) - .putValue("run", point.meta().getString("external_meta.session", "")) - .putValue("group", point.meta().getString("external_meta.group", "")) - val pointName = "point_" + point.meta().getInt("external_meta.point_index", point.hashCode())!! + .putValue("index", point.getMeta().getInt("external_meta.point_index", -1)) + .putValue("run", point.getMeta().getString("external_meta.session", "")) + .putValue("group", point.getMeta().getString("external_meta.group", "")) + val pointName = "point_" + point.getMeta().getInt("external_meta.point_index", point.hashCode())!! builder.putData(pointName, point, pointMeta) } set.hvData.ifPresent { hv -> builder.putData("hv", hv, Meta.empty()) } diff --git a/numass-main/src/main/kotlin/inr/numass/actions/MergeDataAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/MergeDataAction.kt index 2f089e2b..20c3102e 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/MergeDataAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/MergeDataAction.kt @@ -41,7 +41,7 @@ class MergeDataAction : ManyToOneAction() { val parnames = arrayOf(NumassPoint.HV_KEY, NumassPoint.LENGTH_KEY, NumassAnalyzer.COUNT_KEY, NumassAnalyzer.COUNT_RATE_KEY, NumassAnalyzer.COUNT_RATE_ERROR_KEY) override fun buildGroups(context: Context, input: DataNode, actionMeta: Meta): List> { - val meta = inputMeta(context, input.meta(), actionMeta) + val meta = inputMeta(context, input.getMeta(), actionMeta) val groups: List> if (meta.hasValue("grouping.byValue")) { groups = super.buildGroups(context, input, actionMeta) diff --git a/numass-main/src/main/kotlin/inr/numass/actions/SummaryAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/SummaryAction.kt index 45995b1c..9eff67f6 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/SummaryAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/SummaryAction.kt @@ -40,7 +40,7 @@ import java.util.* class SummaryAction : ManyToOneAction() { protected override fun buildGroups(context: Context, input: DataNode, actionMeta: Meta): List> { - val meta = inputMeta(context, input.meta(), actionMeta) + val meta = inputMeta(context, input.getMeta(), actionMeta) val groups: List> if (meta.hasValue("grouping.byValue")) { groups = super.buildGroups(context, input, actionMeta) diff --git a/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt b/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt index b0b1a45d..9fe903be 100644 --- a/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt +++ b/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanSummaryTask.kt @@ -30,7 +30,7 @@ class NumassFitScanSummaryTask : AbstractTask
() { val builder = DataSet.builder(Table::class.java) val action = FitSummaryAction() val input = data.checked(FitResult::class.java) - input.nodeStream().filter { it -> it.dataSize(false) > 0 }.forEach { node -> builder.putData(node.name, action.run(model.context, node, model.meta()).data) } + input.nodeStream().filter { it -> it.dataSize(false) > 0 }.forEach { node -> builder.putData(node.name, action.run(model.context, node, model.getMeta()).data) } return builder.build() } diff --git a/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanTask.kt b/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanTask.kt index 9fa11f43..14868de5 100644 --- a/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanTask.kt +++ b/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitScanTask.kt @@ -25,7 +25,7 @@ class NumassFitScanTask : AbstractTask() { override fun run(model: TaskModel, data: DataNode<*>): DataNode { - val config = model.meta() + val config = model.getMeta() val scanParameter = config.getString("parameter", "msterile2") val scanValues: Value = if (config.hasValue("masses")) { diff --git a/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitSummaryTask.kt b/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitSummaryTask.kt index a1471914..a4f80c44 100644 --- a/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitSummaryTask.kt +++ b/numass-main/src/main/kotlin/inr/numass/tasks/NumassFitSummaryTask.kt @@ -42,7 +42,7 @@ class NumassFitSummaryTask : SingleActionTask() { } override fun transformMeta(model: TaskModel): Meta { - return model.meta().getMeta("summary") + return model.getMeta().getMeta("summary") } override fun buildModel(model: TaskModel.Builder, meta: Meta) { diff --git a/numass-server/src/main/java/inr/numass/server/NumassRootHandler.java b/numass-server/src/main/java/inr/numass/server/NumassRootHandler.java index f8a6abaf..6c40e804 100644 --- a/numass-server/src/main/java/inr/numass/server/NumassRootHandler.java +++ b/numass-server/src/main/java/inr/numass/server/NumassRootHandler.java @@ -44,8 +44,8 @@ public class NumassRootHandler implements Handler { Template template = ServletUtils.freemarkerConfig().getTemplate("NumassRoot.ftl"); Map data = new HashMap(6); - if (!server.meta().isEmpty()) { - data.put("serverMeta", writer.writeString(server.meta())); + if (!server.getMeta().isEmpty()) { + data.put("serverMeta", writer.writeString(server.getMeta())); } if (server.getRootState() != null) { @@ -54,8 +54,8 @@ public class NumassRootHandler implements Handler { if (server.getRun() != null) { data.put("runPresent", true); - if (!server.getRun().meta().isEmpty()) { - data.put("runMeta", writer.writeString(server.getRun().meta())); + if (!server.getRun().getMeta().isEmpty()) { + data.put("runMeta", writer.writeString(server.getRun().getMeta())); } StateLoader runState = server.getRun().getStates(); diff --git a/numass-server/src/main/java/inr/numass/server/NumassRun.java b/numass-server/src/main/java/inr/numass/server/NumassRun.java index a4225ca2..81d8b451 100644 --- a/numass-server/src/main/java/inr/numass/server/NumassRun.java +++ b/numass-server/src/main/java/inr/numass/server/NumassRun.java @@ -95,7 +95,7 @@ public class NumassRun implements Metoid, Responder { @Override public Envelope respond(Envelope message) { - Meta meta = message.meta(); + Meta meta = message.getMeta(); String type = meta.getString("type", "numass.run.state"); String action = meta.getString("action"); switch (type) { @@ -135,12 +135,12 @@ public class NumassRun implements Metoid, Responder { private synchronized Envelope pushNote(Envelope message) { try { - if (message.meta().hasMeta("note")) { - for (Meta node : message.meta().getMetaList("note")) { + if (message.getMeta().hasMeta("note")) { + for (Meta node : message.getMeta().getMetaList("note")) { addNote(NumassNote.buildFrom(node)); } } else { - addNote(NumassNote.buildFrom(message.meta())); + addNote(NumassNote.buildFrom(message.getMeta())); } return factory.okResponseBase(message, false, false).build(); } catch (Exception ex) { @@ -151,7 +151,7 @@ public class NumassRun implements Metoid, Responder { private Envelope pullNotes(Envelope message) { EnvelopeBuilder envelope = factory.okResponseBase(message, true, false); - int limit = message.meta().getInt("limit", -1); + int limit = message.getMeta().getInt("limit", -1); //TODO add time window and search conditions here Stream stream = getNotes(noteLoader); if (limit > 0) { @@ -164,8 +164,8 @@ public class NumassRun implements Metoid, Responder { private Envelope pushNumassPoint(Envelope message) { try { - String filePath = message.meta().getString("path", ""); - String fileName = message.meta().getString("name") + String filePath = message.getMeta().getString("path", ""); + String fileName = message.getMeta().getString("name") .replace(NumassStorage.NUMASS_ZIP_EXTENSION, "");// removing .nm.zip if it is present if (storage instanceof NumassStorage) { ((NumassStorage) storage).pushNumassData(filePath, fileName, message.getData().getBuffer()); @@ -181,8 +181,8 @@ public class NumassRun implements Metoid, Responder { } @Override - public Meta meta() { - return storage.meta(); + public Meta getMeta() { + return storage.getMeta(); } public Storage getStorage() { diff --git a/numass-server/src/main/java/inr/numass/server/NumassServer.java b/numass-server/src/main/java/inr/numass/server/NumassServer.java index 0ac97c44..977da72c 100644 --- a/numass-server/src/main/java/inr/numass/server/NumassServer.java +++ b/numass-server/src/main/java/inr/numass/server/NumassServer.java @@ -77,7 +77,7 @@ public class NumassServer extends AbstractNetworkListener implements ContextAwar @Override public void open() throws Exception { super.open(); - int port = meta().getInt("ratpack.port", 8336); + int port = getMeta().getInt("ratpack.port", 8336); // ratpack = RatpackServer.start((RatpackServerSpec server) -> server // .serverConfig((ServerConfigBuilder config) -> config //// .baseDir(Paths.get(getClass().getResource("/ratpack/.ratpack").toURI())) @@ -110,7 +110,7 @@ public class NumassServer extends AbstractNetworkListener implements ContextAwar */ @Override public Envelope respond(Envelope message) { - Meta meta = message.meta(); + Meta meta = message.getMeta(); // ByteBuffer data = message.getData(); //switch message type @@ -155,8 +155,8 @@ public class NumassServer extends AbstractNetworkListener implements ContextAwar public Envelope getCurrentRun() { MetaBuilder runAn = new MetaBuilder("run") .putValue("path", getRun().getRunPath()); - if (!run.meta().isEmpty()) { - runAn.putNode(getRun().meta()); + if (!run.getMeta().isEmpty()) { + runAn.putNode(getRun().getMeta()); } return getResponseFactory().responseBase("numass.run.response") diff --git a/numass-server/src/main/java/inr/numass/server/ServerRunner.java b/numass-server/src/main/java/inr/numass/server/ServerRunner.java index 1518475c..f6ae7b41 100644 --- a/numass-server/src/main/java/inr/numass/server/ServerRunner.java +++ b/numass-server/src/main/java/inr/numass/server/ServerRunner.java @@ -55,7 +55,7 @@ public class ServerRunner extends SimpleConfigurable implements AutoCloseable { public ServerRunner start() throws Exception { // String repoPath = meta().getString(NUMASS_REPO_PATH_PROPERTY, "."); - Meta storageMeta = meta().getMetaOrEmpty(NUMASS_REPO_ELEMENT); + Meta storageMeta = getMeta().getMetaOrEmpty(NUMASS_REPO_ELEMENT); context.getLogger().info("Initializing file storage with meta: {}",storageMeta); root = new NumassStorage(context,storageMeta); @@ -63,8 +63,8 @@ public class ServerRunner extends SimpleConfigurable implements AutoCloseable { if (root != null) { root.open(); Meta listenerConfig = null; - if (meta().hasMeta(LISTENER_ELEMENT)) { - listenerConfig = meta().getMeta(LISTENER_ELEMENT); + if (getMeta().hasMeta(LISTENER_ELEMENT)) { + listenerConfig = getMeta().getMeta(LISTENER_ELEMENT); } listener = new NumassServer(root, listenerConfig); diff --git a/numass-test/src/main/groovy/inr/numass/scripts/TestStorageAccess.groovy b/numass-test/src/main/groovy/inr/numass/scripts/TestStorageAccess.groovy index 8d0f516e..21850ad8 100644 --- a/numass-test/src/main/groovy/inr/numass/scripts/TestStorageAccess.groovy +++ b/numass-test/src/main/groovy/inr/numass/scripts/TestStorageAccess.groovy @@ -51,6 +51,6 @@ new NumassClient("127.0.0.1",8335).withCloseable{ def response = it.respond(bin); - println parser.writeString(response.meta()); + println parser.writeString(response.getMeta()); } \ No newline at end of file diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/NumassDataCache.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/NumassDataCache.kt index 78468b20..c9988efb 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/NumassDataCache.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/NumassDataCache.kt @@ -27,7 +27,7 @@ class NumassDataCache(val data: NumassSet) : NumassSet { return cachedDescription } - override fun meta(): Meta { + override fun getMeta(): Meta { return cachedMeta } diff --git a/numass-viewer/src/main/resources/img/df.png b/numass-viewer/src/main/resources/img/df.png deleted file mode 100644 index 076e26a2..00000000 Binary files a/numass-viewer/src/main/resources/img/df.png and /dev/null differ diff --git a/numass-web/src/main/kotlin/inr/numass/server/Interceptors.kt b/numass-web/src/main/kotlin/inr/numass/server/Interceptors.kt index 009d7d15..0167b59b 100644 --- a/numass-web/src/main/kotlin/inr/numass/server/Interceptors.kt +++ b/numass-web/src/main/kotlin/inr/numass/server/Interceptors.kt @@ -46,7 +46,7 @@ val storageInterceptor = InterceptorFactory { context, meta -> add("name", loader.name) add("path", loader.path.toString()) add("type", loader.type) - add("meta", loader.laminate.asJson()) + add("getMeta", loader.laminate.asJson()) }) } add("loaders", loaders) @@ -96,7 +96,7 @@ val deviceInterceptor = InterceptorFactory { context, meta -> devices.add(jsonObject { add("name", name.toUnescaped()) add("type", device.getType()) - add("meta", device.meta.asJson()) + add("getMeta", device.meta.asJson()) }) } } @@ -112,7 +112,7 @@ val deviceInterceptor = InterceptorFactory { context, meta -> call.json { add("name", deviceName) add("type", device.type) - add("meta", device.meta.asJson()) + add("getMeta", device.meta.asJson()) add("state", jsonObject { for (state in device.listStates()) { add(state, device.getState(state).toString())