Refactoring in core. Added delegates for values and states
This commit is contained in:
commit
ae17288664
@ -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<String, Value> 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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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", "")
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,7 +92,7 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor<PKT8Result>(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<PKT8Result>(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<PKT8Result>(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<PKT8Result>(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)
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ class PKT8Display : DeviceDisplay<PKT8Device>(), 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<PKT8Device>(), MeasurementListener {
|
||||
} else {
|
||||
device.channels.values.find { it.name == channelName }?.let {
|
||||
TimePlot(it.name).apply {
|
||||
configure(it.meta())
|
||||
configure(it.getMeta())
|
||||
plotFrame.add(this)
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -74,7 +74,7 @@ class MspDevice(context: Context, meta: Meta) : PortSensor<Values>(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<Values>(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)
|
||||
|
@ -71,7 +71,7 @@ class MspDisplay() : DeviceDisplay<MspDevice>(), 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")
|
||||
|
@ -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)
|
@ -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)
|
||||
|
@ -38,7 +38,9 @@ class CM32Device(context: Context, meta: Meta) : PortSensor<Double>(context, met
|
||||
|
||||
override fun createMeasurement(): Measurement<Double> = 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<Double>() {
|
||||
|
||||
|
@ -23,12 +23,14 @@ import inr.numass.control.DeviceView
|
||||
@DeviceView(VacDisplay::class)
|
||||
class MKSBaratronDevice(context: Context, meta: Meta) : PortSensor<Double>(context, meta) {
|
||||
|
||||
private val channel: Int = meta().getInt("channel", 2)
|
||||
private val channel: Int = getMeta().getInt("channel", 2)
|
||||
|
||||
|
||||
override fun createMeasurement(): Measurement<Double> = 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 {
|
||||
|
@ -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<Double>(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<Double>(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<Double>() {
|
||||
|
||||
|
@ -35,17 +35,19 @@ class MeradatVacDevice(context: Context, meta: Meta) : PortSensor<Double>(contex
|
||||
|
||||
override fun createMeasurement(): Measurement<Double> = 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<Double>() {
|
||||
|
||||
|
||||
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")
|
||||
|
@ -52,7 +52,7 @@ class VacCollectorDevice(context: Context, meta: Meta, val sensors: Collection<S
|
||||
private val helper = StorageHelper(this, this::buildLoader)
|
||||
|
||||
private val averagingDuration: Duration
|
||||
get() = Duration.parse(meta().getString("averagingDuration", "PT30S"))
|
||||
get() = Duration.parse(getMeta().getString("averagingDuration", "PT30S"))
|
||||
|
||||
|
||||
override fun optDevice(name: Name): Optional<Device> =
|
||||
@ -114,7 +114,7 @@ class VacCollectorDevice(context: Context, meta: Meta, val sensors: Collection<S
|
||||
|
||||
override fun start() {
|
||||
executor = Executors.newSingleThreadScheduledExecutor { r: Runnable -> 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 {
|
||||
|
@ -68,7 +68,7 @@ class VacCollectorDisplay : DeviceDisplay<VacCollectorDevice>() {
|
||||
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)
|
||||
|
@ -78,7 +78,7 @@ open class VacDisplay : DeviceDisplay<Sensor<Double>>(), 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<Sensor<Double>>(), 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<Sensor<Double>>(), 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
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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())
|
||||
);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public interface NumassSet extends Named, Metoid, Iterable<NumassPoint>, Provide
|
||||
Stream<NumassPoint> 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<NumassPoint>, 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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 {
|
||||
|
@ -33,18 +33,18 @@ public class ClassicNumassPoint implements NumassPoint {
|
||||
public Stream<NumassBlock> 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<NumassEvent> 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);
|
||||
|
@ -148,11 +148,11 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
||||
}
|
||||
|
||||
@Override
|
||||
public Meta meta() {
|
||||
public Meta getMeta() {
|
||||
return getItems()
|
||||
.get(META_FRAGMENT_NAME)
|
||||
.get()
|
||||
.meta();
|
||||
.getMeta();
|
||||
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
||||
return getItems().entrySet().stream()
|
||||
.filter(entry -> 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<Env
|
||||
}
|
||||
|
||||
public boolean isReversed() {
|
||||
return meta().getBoolean("iteration_info.reverse", false);
|
||||
return this.getMeta().getBoolean("iteration_info.reverse", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -219,7 +219,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return meta().getString("description", "").replace("\\n", "\n");
|
||||
return this.getMeta().getString("description", "").replace("\\n", "\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -75,7 +75,7 @@ public class NumassStorage extends FileStorage {
|
||||
NumassDataLoader.fromDir(this, file, null));
|
||||
} else {
|
||||
this.shelves.put(entryName(file),
|
||||
new NumassStorage(this, entryName(file), meta()));
|
||||
new NumassStorage(this, entryName(file), getMeta()));
|
||||
}
|
||||
} else if (file.getFileName().endsWith(NUMASS_ZIP_EXTENSION)) {
|
||||
this.loaders.put(entryName(file), NumassDataLoader.fromFile(this, file));
|
||||
@ -163,7 +163,7 @@ public class NumassStorage extends FileStorage {
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return meta().getString("description", "");
|
||||
return getMeta().getString("description", "");
|
||||
}
|
||||
|
||||
public static class NumassDataPointEvent extends Event {
|
||||
@ -187,11 +187,11 @@ public class NumassStorage extends FileStorage {
|
||||
}
|
||||
|
||||
public int getFileSize() {
|
||||
return meta().getInt(FILE_SIZE_KEY, 0);
|
||||
return getMeta().getInt(FILE_SIZE_KEY, 0);
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return meta().getString(FILE_NAME_KEY);
|
||||
return getMeta().getString(FILE_NAME_KEY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,8 +54,8 @@ public class ProtoNumassPoint implements NumassPoint {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Meta meta() {
|
||||
return envelope.meta();
|
||||
public Meta getMeta() {
|
||||
return envelope.getMeta();
|
||||
}
|
||||
|
||||
public static Instant ofEpochNanos(long nanos) {
|
||||
@ -81,7 +81,7 @@ public class ProtoNumassPoint implements NumassPoint {
|
||||
|
||||
@Override
|
||||
public Duration getLength() {
|
||||
return Duration.ofNanos((long) (meta().getInt("b_size") / meta().getInt("sample_freq") * 1e9));
|
||||
return Duration.ofNanos((long) (getMeta().getInt("b_size") / getMeta().getInt("sample_freq") * 1e9));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -99,7 +99,7 @@ public class ProtoNumassPoint implements NumassPoint {
|
||||
|
||||
@Override
|
||||
public Stream<NumassFrame> 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();
|
||||
|
@ -61,7 +61,7 @@ public class NumassIO extends BasicIOManager {
|
||||
ple.setContext(lc);
|
||||
ple.start();
|
||||
FileAppender<ILoggingEvent> 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;
|
||||
}
|
||||
|
@ -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()) }
|
||||
|
@ -41,7 +41,7 @@ class MergeDataAction : ManyToOneAction<Table, Table>() {
|
||||
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<Table>, actionMeta: Meta): List<DataNode<Table>> {
|
||||
val meta = inputMeta(context, input.meta(), actionMeta)
|
||||
val meta = inputMeta(context, input.getMeta(), actionMeta)
|
||||
val groups: List<DataNode<Table>>
|
||||
if (meta.hasValue("grouping.byValue")) {
|
||||
groups = super.buildGroups(context, input, actionMeta)
|
||||
|
@ -40,7 +40,7 @@ import java.util.*
|
||||
class SummaryAction : ManyToOneAction<FitState, Table>() {
|
||||
|
||||
protected override fun buildGroups(context: Context, input: DataNode<FitState>, actionMeta: Meta): List<DataNode<FitState>> {
|
||||
val meta = inputMeta(context, input.meta(), actionMeta)
|
||||
val meta = inputMeta(context, input.getMeta(), actionMeta)
|
||||
val groups: List<DataNode<FitState>>
|
||||
if (meta.hasValue("grouping.byValue")) {
|
||||
groups = super.buildGroups(context, input, actionMeta)
|
||||
|
@ -30,7 +30,7 @@ class NumassFitScanSummaryTask : AbstractTask<Table>() {
|
||||
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()
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ class NumassFitScanTask : AbstractTask<FitResult>() {
|
||||
|
||||
|
||||
override fun run(model: TaskModel, data: DataNode<*>): DataNode<FitResult> {
|
||||
val config = model.meta()
|
||||
val config = model.getMeta()
|
||||
val scanParameter = config.getString("parameter", "msterile2")
|
||||
|
||||
val scanValues: Value = if (config.hasValue("masses")) {
|
||||
|
@ -42,7 +42,7 @@ class NumassFitSummaryTask : SingleActionTask<FitState, Table>() {
|
||||
}
|
||||
|
||||
override fun transformMeta(model: TaskModel): Meta {
|
||||
return model.meta().getMeta("summary")
|
||||
return model.getMeta().getMeta("summary")
|
||||
}
|
||||
|
||||
override fun buildModel(model: TaskModel.Builder, meta: Meta) {
|
||||
|
@ -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();
|
||||
|
@ -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<NumassNote> 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() {
|
||||
|
@ -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")
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
|
||||
}
|
@ -27,7 +27,7 @@ class NumassDataCache(val data: NumassSet) : NumassSet {
|
||||
return cachedDescription
|
||||
}
|
||||
|
||||
override fun meta(): Meta {
|
||||
override fun getMeta(): Meta {
|
||||
return cachedMeta
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 53 KiB |
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user