Cosmetic changes in meta structure. JSON changed to json-simple and moved to separate module.

This commit is contained in:
Alexander Nozik 2018-04-19 16:24:35 +03:00
parent 859b2ec1d4
commit 8a45cc4517
46 changed files with 100 additions and 107 deletions

View File

@ -69,7 +69,7 @@ public class Cli {
String stateName = args[1];
Map<String, Value> states = client.getStates(stateName);
if (states != null) {
System.out.println(states.get(stateName).stringValue());
System.out.println(states.get(stateName).getString());
} else {
System.out.println("Error: operaton failed");
}

View File

@ -32,10 +32,10 @@ internal fun createChannel(meta: Meta): PKT8Channel {
if (meta.hasValue("coefs")) {
when (transformationType) {
"default", "hyperbolic" -> {
val coefs = meta.getValue("coefs").listValue()
val coefs = meta.getValue("coefs").getList()
val r0 = meta.getDouble("r0", 1000.0)
return PKT8Channel(meta) { r ->
coefs?.indices?.sumByDouble { coefs[it].doubleValue() * Math.pow(r0 / r, it.toDouble()) } ?: -1.0
coefs?.indices?.sumByDouble { coefs[it].getDouble() * Math.pow(r0 / r, it.toDouble()) } ?: -1.0
}
}
else -> throw RuntimeException("Unknown transformation type")

View File

@ -122,8 +122,8 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor(context, meta) {
//update parameters from meta
meta.optValue("pga").ifPresent {
logger.info("Setting dynamic range to " + it.intValue())
val response = sendAndWait("g" + it.intValue()).trim { it <= ' ' }
logger.info("Setting dynamic range to " + it.getInt())
val response = sendAndWait("g" + it.getInt()).trim { it <= ' ' }
if (response.contains("=")) {
updateState(PGA, Integer.parseInt(response.substring(4)))
} else {

View File

@ -284,7 +284,7 @@ class DanteClient(val ip: String, chainLength: Int) : AutoCloseable {
val en_fil_flattop = meta.getInt("energy_filter.flat_top")
val fast_peak_time = meta.getInt("fast_filter.peaking_time")
val fast_flattop = meta.getInt("fast_filter.flat_top")
val recovery_time = meta.getValue("recovery_time").longValue()
val recovery_time = meta.getValue("recovery_time").getLong()
val zero_peak_rate = meta.getInt("zero_peak_rate")
val inverted_input = meta.getInt("inverted_input", 0)

View File

@ -84,26 +84,26 @@ class LambdaMagnet(private val controller: LambdaPortController, meta: Meta) : A
//output values of current and voltage
private var outCurrent by valueState("outCurrent", getter = { s2d(controller.getParameter(address, "PC")) }) { _, value ->
setCurrent(value.doubleValue())
setCurrent(value.getDouble())
return@valueState value
}.doubleDelegate
private var outVoltage = valueState("outVoltage", getter = { s2d(controller.getParameter(address, "PV")) }) { _, value ->
if (!controller.setParameter(address, "PV", value.doubleValue())) {
if (!controller.setParameter(address, "PV", value.getDouble())) {
notifyError("Can't set the target voltage")
}
return@valueState value
}.doubleDelegate
val output = valueState("output", getter = { controller.talk(address, "OUT?") == "OK" }) { _, value ->
setOutputMode(value.booleanValue())
if (!value.booleanValue()) {
setOutputMode(value.getBoolean())
if (!value.getBoolean()) {
status = MagnetStatus.OFF
}
}
val monitoring = valueState("monitoring", getter = { monitorTask != null }) { _, value ->
if (value.booleanValue()) {
if (value.getBoolean()) {
startMonitorTask()
} else {
stopMonitorTask()
@ -115,7 +115,7 @@ class LambdaMagnet(private val controller: LambdaPortController, meta: Meta) : A
*
*/
val updating = valueState("updating", getter = { updateTask != null }) { _, value ->
if (value.booleanValue()) {
if (value.getBoolean()) {
startUpdateTask()
} else {
stopUpdateTask()
@ -235,7 +235,7 @@ class LambdaMagnet(private val controller: LambdaPortController, meta: Meta) : A
stopUpdateTask()
updateTask = repeatOnDeviceThread(Duration.ofMillis(delay)) {
try {
val measuredI = current.readBlocking().doubleValue()
val measuredI = current.readBlocking().getDouble()
val targetI = target.doubleValue
if (Math.abs(measuredI - targetI) > CURRENT_PRECISION) {
val nextI = nextI(measuredI, targetI)

View File

@ -90,13 +90,13 @@ class MagnetDisplay : DeviceDisplayFX<LambdaMagnet>() {
device.states.getState<ValueState>("status")?.onChange{
runLater {
this.statusLabel.text = it.stringValue()
this.statusLabel.text = it.getString()
}
}
device.output.onChange {
Platform.runLater {
if (it.booleanValue()) {
if (it.getBoolean()) {
this.statusLabel.textFill = Color.BLUE
} else {
this.statusLabel.textFill = Color.BLACK
@ -105,7 +105,7 @@ class MagnetDisplay : DeviceDisplayFX<LambdaMagnet>() {
}
device.updating.onChange {
val updateTaskRunning = it.booleanValue()
val updateTaskRunning = it.getBoolean()
runLater {
this.setButton.isSelected = updateTaskRunning
targetIField.isDisable = updateTaskRunning
@ -114,7 +114,7 @@ class MagnetDisplay : DeviceDisplayFX<LambdaMagnet>() {
device.monitoring.onChange {
runLater {
monitorButton.isScaleShape = it.booleanValue()
monitorButton.isScaleShape = it.getBoolean()
}
}

View File

@ -69,17 +69,17 @@ class MspDevice(context: Context, meta: Meta) : PortSensor(context, meta) {
val controlled = valueState(CONTROLLED_STATE) { value ->
runOnDeviceThread {
val res = control(value.booleanValue())
val res = control(value.getBoolean())
updateState(CONTROLLED_STATE, res)
}
}
val filament = valueState("filament") { value ->
selectFilament(value.intValue())
selectFilament(value.getInt())
}
val filamentOn = valueState("filamentOn") { value ->
setFilamentOn(value.booleanValue())
setFilamentOn(value.getBoolean())
}
var peakJumpZero: Double by valueState("peakJump.zero").doubleDelegate

View File

@ -141,7 +141,7 @@ class MspDisplay() : DeviceDisplayFX<MspDevice>(), NamedValueListener {
device.filamentOn.asBooleanProperty().bindBidirectional(selectedProperty())
}
deviceStateIndicator(this@MspDisplay, "filamentStatus", false) {
when (it.stringValue()) {
when (it.getString()) {
"ON" -> Paint.valueOf("red")
"OFF" -> Paint.valueOf("blue")
"WARM-UP", "COOL-DOWN" -> Paint.valueOf("yellow")
@ -185,13 +185,13 @@ class MspDisplay() : DeviceDisplayFX<MspDevice>(), NamedValueListener {
val pl = plottables[change.key] as TimePlot?
val value = change.valueAdded
if (pl != null) {
if (value.doubleValue() > 0) {
if (value.getDouble() > 0) {
pl.put(value)
} else {
pl.put(Value.NULL)
}
val titleBase = pl.config.getString("titleBase")
val title = String.format("%s (%.4g)", titleBase, value.doubleValue())
val title = String.format("%s (%.4g)", titleBase, value.getDouble())
pl.configureValue("title", title)
}
}

View File

@ -81,7 +81,7 @@ fun Indicator.bind(connection: DeviceDisplayFX<*>, state: String, transform: ((V
bind(connection.valueStateProperty(state)) {
when {
it.isNull -> Color.GRAY
it.booleanValue() -> Color.GREEN
it.getBoolean() -> Color.GREEN
else -> Color.RED
}
}
@ -119,7 +119,7 @@ fun Node.deviceStateToggle(connection: DeviceDisplayFX<*>, state: String, title:
}
connection.valueStateProperty(state).onChange {
runLater {
isSelected = it?.booleanValue() ?: false
isSelected = it?.getBoolean() ?: false
}
}
}

View File

@ -41,7 +41,7 @@ class MKSVacDevice(context: Context, meta: Meta) : PortSensor(context, meta) {
var power by valueState("power", getter = { talk("FP?") == "ON" }) { old, value ->
if (old != value) {
setPowerOn(value.booleanValue())
setPowerOn(value.getBoolean())
}
}.booleanDelegate

View File

@ -67,7 +67,7 @@ open class VacDisplay : DeviceDisplayFX<Sensor>() {
// Sensor.MEASUREMENT_RESULT_STATE -> {
// if(state.getBoolean(Sensor.RESULT_SUCCESS)) {
// val res by state.value(Sensor.RESULT_VALUE)
// val time by state.timeValue(Sensor.RESULT_TIMESTAMP)
// val time by state.getTime(Sensor.RESULT_TIMESTAMP)
// onResult(res, time)
// } else{
// Platform.runLater {
@ -76,7 +76,7 @@ open class VacDisplay : DeviceDisplayFX<Sensor>() {
// }
// }
// Sensor.MEASUREMENT_ERROR_STATE -> {
// val message by state.stringValue("message")
// val message by state.getString("message")
// message(message)
// }
// }
@ -135,7 +135,7 @@ open class VacDisplay : DeviceDisplayFX<Sensor>() {
prefHeight = 60.0
alignment = Pos.CENTER_RIGHT
textProperty().bind(valueProperty)
device.meta.optValue("color").ifPresent { colorValue -> textFill = Color.valueOf(colorValue.stringValue()) }
device.meta.optValue("color").ifPresent { colorValue -> textFill = Color.valueOf(colorValue.getString()) }
style {
fontSize = 24.pt
fontWeight = FontWeight.BOLD

View File

@ -67,7 +67,7 @@ val NumassBlock.channel: Int?
get() = if (this is ProtoBlock) {
this.channel
} else {
this.meta.optValue("channel").map { it.intValue() }.nullable
this.meta.optValue("channel").map { it.getInt() }.nullable
}

View File

@ -51,7 +51,7 @@ class SpectrumAdapter : BasicAdapter {
}
fun getTime(point: Values): Double {
return this.optComponent(point, POINT_LENGTH_NAME).map<Double> { it.doubleValue() }.orElse(1.0)
return this.optComponent(point, POINT_LENGTH_NAME).map<Double> { it.getDouble() }.orElse(1.0)
}
fun buildSpectrumDataPoint(x: Double, count: Long, t: Double): Values {
@ -69,14 +69,14 @@ class SpectrumAdapter : BasicAdapter {
when (component) {
"count" -> return super.optComponent(values, Y_VALUE_KEY)
Y_VALUE_KEY -> return super.optComponent(values, Y_VALUE_KEY)
.map { it -> it.doubleValue() / getTime(values) }
.map { it -> it.getDouble() / getTime(values) }
.map { Value.of(it) }
Y_ERROR_KEY -> {
val err = super.optComponent(values, Y_ERROR_KEY)
return if (err.isPresent) {
Optional.of(Value.of(err.get().doubleValue() / getTime(values)))
Optional.of(Value.of(err.get().getDouble() / getTime(values)))
} else {
val y = getComponent(values, Y_VALUE_KEY).doubleValue()
val y = getComponent(values, Y_VALUE_KEY).getDouble()
if (y < 0) {
Optional.empty()
} else if (y == 0.0) {

View File

@ -85,7 +85,7 @@ interface NumassAnalyzer {
* @return
*/
fun getCount(block: NumassBlock, config: Meta): Long {
return analyze(block, config).getValue(COUNT_KEY).numberValue().toLong()
return analyze(block, config).getValue(COUNT_KEY).getNumber().toLong()
}
/**
@ -96,7 +96,7 @@ interface NumassAnalyzer {
* @return
*/
fun getLength(block: NumassBlock, config: Meta): Long {
return analyze(block, config).getValue(LENGTH_KEY).numberValue().toLong()
return analyze(block, config).getValue(LENGTH_KEY).getNumber().toLong()
}
fun getAmplitudeSpectrum(block: NumassBlock, config: Meta): Table {
@ -133,7 +133,7 @@ interface NumassAnalyzer {
fun Table.countInWindow(loChannel: Short, upChannel: Short): Long {
return this.rows.filter { row ->
row.getInt(NumassAnalyzer.CHANNEL_KEY) in loChannel..(upChannel - 1)
}.mapToLong { it -> it.getValue(NumassAnalyzer.COUNT_KEY).numberValue().toLong() }.sum()
}.mapToLong { it -> it.getValue(NumassAnalyzer.COUNT_KEY).getNumber().toLong() }.sum()
}
/**
@ -200,10 +200,10 @@ fun Table.withBinning(binSize: Int, loChannel: Int? = null, upChannel: Int? = nu
val builder = ListTable.Builder(format)
var chan = loChannel
?: this.getColumn(NumassAnalyzer.CHANNEL_KEY).stream().mapToInt { it.intValue() }.min().orElse(0)
?: this.getColumn(NumassAnalyzer.CHANNEL_KEY).stream().mapToInt { it.getInt() }.min().orElse(0)
val top = upChannel
?: this.getColumn(NumassAnalyzer.CHANNEL_KEY).stream().mapToInt { it.intValue() }.max().orElse(1)
?: this.getColumn(NumassAnalyzer.CHANNEL_KEY).stream().mapToInt { it.getInt() }.max().orElse(1)
while (chan < top - binSize) {
val count = AtomicLong(0)
@ -216,7 +216,7 @@ fun Table.withBinning(binSize: Int, loChannel: Int? = null, upChannel: Int? = nu
this.rows.filter { row ->
row.getInt(NumassAnalyzer.CHANNEL_KEY) in binLo..(binUp - 1)
}.forEach { row ->
count.addAndGet(row.getValue(NumassAnalyzer.COUNT_KEY, 0).longValue())
count.addAndGet(row.getValue(NumassAnalyzer.COUNT_KEY, 0).getLong())
countRate.accumulateAndGet(row.getDouble(NumassAnalyzer.COUNT_RATE_KEY, 0.0)) { d1, d2 -> d1 + d2 }
countRateDispersion.accumulateAndGet(Math.pow(row.getDouble(NumassAnalyzer.COUNT_RATE_ERROR_KEY, 0.0), 2.0)) { d1, d2 -> d1 + d2 }
}

View File

@ -45,7 +45,7 @@ interface NumassPoint : Metoid, NumassBlock {
* @return
*/
override val startTime: Instant
get() = meta.optValue(START_TIME_KEY).map<Instant> { it.timeValue() }.orElseGet { firstBlock.startTime }
get() = meta.optValue(START_TIME_KEY).map<Instant> { it.getTime() }.orElseGet { firstBlock.startTime }
/**
* Get the length key of meta or calculate length as a sum of block lengths. The latter could be a bit slow
@ -54,7 +54,7 @@ interface NumassPoint : Metoid, NumassBlock {
*/
override val length: Duration
get() = Duration.ofNanos(
meta.optValue(LENGTH_KEY).map<Long> { it.longValue() }
meta.optValue(LENGTH_KEY).map<Long> { it.getLong() }
.orElseGet { blocks.mapToLong { it -> it.length.toNanos() }.sum() }
)

View File

@ -39,7 +39,7 @@ interface NumassSet : Named, Metoid, Iterable<NumassPoint>, Provider {
* @return
*/
val startTime: Instant
get() = meta.optValue(NumassPoint.START_TIME_KEY).map<Instant>{ it.timeValue() }.orElseGet { firstPoint.startTime }
get() = meta.optValue(NumassPoint.START_TIME_KEY).map<Instant>{ it.getTime() }.orElseGet { firstPoint.startTime }
val hvData: Optional<Table>
get() = Optional.empty()

View File

@ -31,16 +31,16 @@ class ClassicNumassPoint(private val envelope: Envelope) : NumassPoint {
override val blocks: Stream<NumassBlock>
get() {
val length: Long = if (envelope.meta.hasValue("external_meta.acquisition_time")) {
envelope.meta.getValue("external_meta.acquisition_time").longValue()
envelope.meta.getValue("external_meta.acquisition_time").getLong()
} else {
envelope.meta.getValue("acquisition_time").longValue()
envelope.meta.getValue("acquisition_time").getLong()
}
return Stream.of(ClassicBlock(startTime, Duration.ofSeconds(length)))
}
override val startTime: Instant
get() = if (meta.hasValue("start_time")) {
meta.getValue("start_time").timeValue()
meta.getValue("start_time").getTime()
} else {
super.startTime
}

View File

@ -111,7 +111,7 @@ class NumassDataLoader(
}
override val startTime: Instant
get() = meta.optValue("start_time").map<Instant> { it.timeValue() }.orElseGet { super.startTime }
get() = meta.optValue("start_time").map<Instant> { it.getTime() }.orElseGet { super.startTime }
override val isOpen: Boolean
@ -178,7 +178,7 @@ class NumassDataLoader(
*/
private fun readTime(meta: Meta): Instant {
return if (meta.hasValue("start_time")) {
meta.getValue("start_time").timeValue()
meta.getValue("start_time").getTime()
} else {
Instant.EPOCH
}

View File

@ -42,7 +42,7 @@ class ProtoNumassPoint(val proto: NumassProto.Point, override val meta: Meta) :
override val startTime: Instant
get() = if (meta.hasValue("start_time")) {
meta.getValue("start_time").timeValue()
meta.getValue("start_time").getTime()
} else {
super.startTime
}

View File

@ -30,8 +30,8 @@ Table.metaClass.withBinning { int binning ->
}
Table.metaClass.withDeadTime { double dt = 6.5 ->
double totalCR = delegate.getColumn(NumassAnalyzer.COUNT_RATE_KEY).stream().mapToDouble { it.doubleValue() }.sum()
// long totalCount = delegate.getColumn(NumassAnalyzer.COUNT_RATE_KEY).stream().mapToLong() { it.longValue() }.sum()
double totalCR = delegate.getColumn(NumassAnalyzer.COUNT_RATE_KEY).stream().mapToDouble { it.getDouble() }.sum()
// long totalCount = delegate.getColumn(NumassAnalyzer.COUNT_RATE_KEY).stream().mapToLong() { it.getLong() }.sum()
// double time = totalCount / totalCR
double factor = 1d / (1d - dt * 1e-6 * totalCR)
return ColumnTable.copy(delegate)

View File

@ -71,7 +71,7 @@ public class PlotFitResultAction extends OneToOneAction<FitResult, FitResult> {
fit.setSmoothing(true);
// ensuring all data points are calculated explicitly
StreamSupport.stream(data.spliterator(), false)
.map(dp -> Adapters.getXValue(adapter, dp).doubleValue()).sorted().forEach(fit::calculateIn);
.map(dp -> Adapters.getXValue(adapter, dp).getDouble()).sorted().forEach(fit::calculateIn);
frame.add(fit);

View File

@ -89,21 +89,21 @@ public class MonitorCorrectAction extends OneToOneAction<Table, Table> {
double corrFactor = corr.getKey();
double corrErr = corr.getValue();
double pointErr = dp.getValue(NumassAnalyzer.COUNT_RATE_ERROR_KEY).doubleValue() / getCR(dp);
double pointErr = dp.getValue(NumassAnalyzer.COUNT_RATE_ERROR_KEY).getDouble() / getCR(dp);
double err = Math.sqrt(corrErr * corrErr + pointErr * pointErr) * getCR(dp);
if (dp.getNames().contains("Monitor")) {
pb.putValue("Monitor", Value.of(dp.getValue("Monitor").doubleValue() / corrFactor));
pb.putValue("Monitor", Value.of(dp.getValue("Monitor").getDouble() / corrFactor));
} else {
pb.putValue("Monitor", corrFactor);
}
pb.putValue(NumassAnalyzer.COUNT_RATE_KEY, Value.of(dp.getValue(NumassAnalyzer.COUNT_RATE_KEY).doubleValue() / corrFactor));
pb.putValue(NumassAnalyzer.COUNT_RATE_KEY, Value.of(dp.getValue(NumassAnalyzer.COUNT_RATE_KEY).getDouble() / corrFactor));
pb.putValue(NumassAnalyzer.COUNT_RATE_ERROR_KEY, Value.of(err));
} else {
double corrFactor = dp.getValue(NumassAnalyzer.COUNT_RATE_KEY).doubleValue() / norm;
double corrFactor = dp.getValue(NumassAnalyzer.COUNT_RATE_KEY).getDouble() / norm;
if (dp.getNames().contains("Monitor")) {
pb.putValue("Monitor", Value.of(dp.getValue("Monitor").doubleValue() / corrFactor));
pb.putValue("Monitor", Value.of(dp.getValue("Monitor").getDouble() / corrFactor));
} else {
pb.putValue("Monitor", corrFactor);
}
@ -112,8 +112,8 @@ public class MonitorCorrectAction extends OneToOneAction<Table, Table> {
}
if (meta.getBoolean("calculateRelative", false)) {
pb.putValue("relCR", pb.build().getValue(NumassAnalyzer.COUNT_RATE_KEY).doubleValue() / norm);
pb.putValue("relCRerr", pb.build().getValue(NumassAnalyzer.COUNT_RATE_ERROR_KEY).doubleValue() / norm);
pb.putValue("relCR", pb.build().getValue(NumassAnalyzer.COUNT_RATE_KEY).getDouble() / norm);
pb.putValue("relCRerr", pb.build().getValue(NumassAnalyzer.COUNT_RATE_ERROR_KEY).getDouble() / norm);
}
dataList.add(pb.build());
@ -179,7 +179,7 @@ public class MonitorCorrectAction extends OneToOneAction<Table, Table> {
}
double corrFactor = (getCR(previousMonitor.getValue()) * (1 - p) + getCR(nextMonitor.getValue()) * p) / norm;
double corrErr = previousMonitor.getValue().getValue(NumassAnalyzer.COUNT_RATE_ERROR_KEY).doubleValue() / getCR(previousMonitor.getValue()) / Math.sqrt(2);
double corrErr = previousMonitor.getValue().getValue(NumassAnalyzer.COUNT_RATE_ERROR_KEY).getDouble() / getCR(previousMonitor.getValue()) / Math.sqrt(2);
return new Pair<>(corrFactor, corrErr);
}
@ -200,19 +200,19 @@ public class MonitorCorrectAction extends OneToOneAction<Table, Table> {
}
private boolean isMonitorPoint(double monitor, Values point) {
return point.getValue(NumassPoint.HV_KEY).doubleValue() == monitor;
return point.getValue(NumassPoint.HV_KEY).getDouble() == monitor;
}
private Instant getTime(Values point) {
return point.getValue(NumassAnalyzer.TIME_KEY).timeValue();
return point.getValue(NumassAnalyzer.TIME_KEY).getTime();
}
private int getTotal(Values point) {
return point.getValue(NumassAnalyzer.COUNT_KEY).intValue();
return point.getValue(NumassAnalyzer.COUNT_KEY).getInt();
}
private double getCR(Values point) {
return point.getValue(NumassAnalyzer.COUNT_RATE_KEY).doubleValue();
return point.getValue(NumassAnalyzer.COUNT_RATE_KEY).getDouble();
}
private TreeMap<Instant, Values> getMonitorIndex(double monitor, Iterable<Values> data) {

View File

@ -173,7 +173,7 @@ public class SpectrumGenerator implements Generator {
}
private double getX(Values point) {
return Adapters.getXValue(adapter,point).doubleValue();
return Adapters.getXValue(adapter,point).getDouble();
}
public void setGeneratorType(GeneratorType type) {

View File

@ -73,7 +73,7 @@ public class SpectrumInformation {
* Нужно вычислять сразу всю матрицу для каждой точки, тогда количество
* вызовов производных будет строго равно 1.
*/
res = res.add(getPointInfoMatrix(set, Adapters.getXValue(adapter,dp).doubleValue(), adapter.getTime(dp), names).getMatrix());
res = res.add(getPointInfoMatrix(set, Adapters.getXValue(adapter,dp).getDouble(), adapter.getTime(dp), names).getMatrix());
}
return new NamedMatrix(names, res);

View File

@ -79,7 +79,7 @@ public class UnderflowCorrection {
double norm = spectrum.getRows().filter(row -> {
int channel = row.getInt(CHANNEL_KEY);
return channel > xLow && channel < upper;
}).mapToDouble(it -> it.getValue(COUNT_RATE_KEY).numberValue().longValue()).sum();
}).mapToDouble(it -> it.getValue(COUNT_RATE_KEY).getNumber().longValue()).sum();
double[] fitRes = getUnderflowExpParameters(spectrum, xLow, xHigh, binning);
double a = fitRes[0];

View File

@ -210,7 +210,7 @@ fun addSetMarkers(frame: JFreeChartFrame, sets: Collection<NumassSet>) {
val paint = Color(0.0f, 0.0f, 1.0f, 0.1f)
sets.stream().forEach {
val start = it.startTime;
val stop = it.meta.optValue("end_time").map { it.timeValue() }
val stop = it.meta.optValue("end_time").map { it.getTime() }
.orElse(start.plusSeconds(300))
.minusSeconds(60)
val marker = IntervalMarker(start.toEpochMilli().toDouble(), stop.toEpochMilli().toDouble(), paint)
@ -252,10 +252,10 @@ fun Values.unbox(): Map<String, Any?> {
for (field in this.names) {
val value = this.getValue(field)
val obj: Any? = when (value.type) {
ValueType.BOOLEAN -> value.booleanValue()
ValueType.NUMBER -> value.doubleValue()
ValueType.STRING -> value.stringValue()
ValueType.TIME -> value.timeValue()
ValueType.BOOLEAN -> value.getBoolean()
ValueType.NUMBER -> value.getDouble()
ValueType.STRING -> value.getString()
ValueType.TIME -> value.getTime()
ValueType.NULL -> null
}
res.put(field, obj)

View File

@ -68,15 +68,15 @@ class MergeDataAction : ManyToOneAction<Table, Table>() {
return dp1
}
val voltage = dp1.getValue(NumassPoint.HV_KEY).doubleValue()
val t1 = dp1.getValue(NumassPoint.LENGTH_KEY).doubleValue()
val t2 = dp2.getValue(NumassPoint.LENGTH_KEY).doubleValue()
val voltage = dp1.getValue(NumassPoint.HV_KEY).getDouble()
val t1 = dp1.getValue(NumassPoint.LENGTH_KEY).getDouble()
val t2 = dp2.getValue(NumassPoint.LENGTH_KEY).getDouble()
val time = t1 + t2
val total = (dp1.getValue(NumassAnalyzer.COUNT_KEY).intValue() + dp2.getValue(NumassAnalyzer.COUNT_KEY).intValue()).toLong()
val total = (dp1.getValue(NumassAnalyzer.COUNT_KEY).getInt() + dp2.getValue(NumassAnalyzer.COUNT_KEY).getInt()).toLong()
val cr1 = dp1.getValue(NumassAnalyzer.COUNT_RATE_KEY).doubleValue()
val cr2 = dp2.getValue(NumassAnalyzer.COUNT_RATE_KEY).doubleValue()
val cr1 = dp1.getValue(NumassAnalyzer.COUNT_RATE_KEY).getDouble()
val cr2 = dp2.getValue(NumassAnalyzer.COUNT_RATE_KEY).getDouble()
val cr = (cr1 * t1 + cr2 * t2) / (t1 + t2)
@ -97,7 +97,7 @@ class MergeDataAction : ManyToOneAction<Table, Table>() {
throw IllegalArgumentException()
}
for (dp in d) {
val uset = dp.getValue(NumassPoint.HV_KEY).doubleValue()
val uset = dp.getValue(NumassPoint.HV_KEY).getDouble()
if (!points.containsKey(uset)) {
points.put(uset, ArrayList())
}

View File

@ -82,8 +82,8 @@ object SummaryAction : ManyToOneAction<FitState, Table>() {
values[2 * i + 1] = `val`
val err = Value.of(value.parameters.getError(parNames[i]))
values[2 * i + 2] = err
val weight = 1.0 / err.doubleValue() / err.doubleValue()
av[i] += `val`.doubleValue() * weight
val weight = 1.0 / err.getDouble() / err.getDouble()
av[i] += `val`.getDouble() * weight
weights[i] += weight
}
values[values.size - 1] = Value.of(value.chi2)

View File

@ -60,8 +60,8 @@ fun generateEvents(
val channels = DoubleArray(spectrum.size())
val values = DoubleArray(spectrum.size())
for (i in 0 until spectrum.size()) {
channels[i] = spectrum.get(CHANNEL_KEY, i).doubleValue()
values[i] = spectrum.get(COUNT_RATE_KEY, i).doubleValue()
channels[i] = spectrum.get(CHANNEL_KEY, i).getDouble()
values[i] = spectrum.get(COUNT_RATE_KEY, i).getDouble()
}
val distribution = EnumeratedRealDistribution(channels, values)

View File

@ -81,7 +81,7 @@ fun main(args: Array<String>) {
val res = subtractAmplitudeSpectrum(spectrum1, spectrum0)
val norm = res.getColumn(COUNT_RATE_KEY).stream().mapToDouble { it.doubleValue() }.sum()
val norm = res.getColumn(COUNT_RATE_KEY).stream().mapToDouble { it.getDouble() }.sum()
integralFrame.add(DataPlot.plot("point_$hv", AMPLITUDE_ADAPTER, spectrum0))

View File

@ -42,11 +42,11 @@ private fun createSummaryNode(storage: Storage): MetaBuilder {
// .setNode("meta", point.meta)
point.meta.useValue("acquisition_time") {
pointBuilder.setValue("length", it.doubleValue())
pointBuilder.setValue("length", it.getDouble())
}
point.meta.useValue("events") {
pointBuilder.setValue("count", it.listValue().stream().mapToInt { it.intValue() }.sum())
pointBuilder.setValue("count", it.getList().stream().mapToInt { it.getInt() }.sum())
}
setBuilder.putNode(pointBuilder)

View File

@ -98,7 +98,7 @@ object Threshold {
private fun norm(spectrum: Table, xLow: Int, upper: Int): Double {
return spectrum.rows.filter { row ->
row.getInt(CHANNEL_KEY) in (xLow + 1)..(upper - 1)
}.mapToDouble { it.getValue(COUNT_RATE_KEY).doubleValue() }.sum()
}.mapToDouble { it.getValue(COUNT_RATE_KEY).getDouble() }.sum()
}
private val expPointNames = arrayOf("U", "amp", "expConst", "correction");

View File

@ -60,7 +60,7 @@ object NumassFitScanSummaryTask : AbstractTask<Table>() {
}
builder.row(
Math.sqrt(pars.getValue("msterile2").doubleValue()),
Math.sqrt(pars.getValue("msterile2").getDouble()),
pars.getValue("U2"),
pars.getError("U2"),
limit,

View File

@ -30,12 +30,12 @@ object NumassFitScanTask : AbstractTask<FitResult>() {
val scanValues: Value = if (config.hasValue("masses")) {
ListValue(config.getValue("masses")
.listValue().stream()
.map { it -> Math.pow(it.doubleValue() * 1000, 2.0) }
.getList().stream()
.map { it -> Math.pow(it.getDouble() * 1000, 2.0) }
.collect(Collectors.toList<Any>())
)
} else {
config.getValue("values", Value.of("[2.5e5, 1e6, 2.25e6, 4e6, 6.25e6, 9e6]"))
config.getValue("hep/dataforge/values", Value.of("[2.5e5, 1e6, 2.25e6, 4e6, 6.25e6, 9e6]"))
}
val action = FitAction()
@ -46,12 +46,12 @@ object NumassFitScanTask : AbstractTask<FitResult>() {
val fitConfig = config.getMeta("fit")
sourceNode.dataStream().forEach { table ->
for (i in 0 until scanValues.listValue().size) {
val `val` = scanValues.listValue()[i]
for (i in 0 until scanValues.getList().size) {
val `val` = scanValues.getList()[i]
val overrideMeta = MetaBuilder(fitConfig)
val resultName = String.format("%s[%s=%s]", table.name, scanParameter, `val`.stringValue())
// overrideMeta.setValue("@resultName", String.format("%s[%s=%s]", table.getName(), scanParameter, val.stringValue()));
val resultName = String.format("%s[%s=%s]", table.name, scanParameter, `val`.getString())
// overrideMeta.setValue("@resultName", String.format("%s[%s=%s]", table.getName(), scanParameter, val.getString()));
if (overrideMeta.hasMeta("params.$scanParameter")) {
overrideMeta.setValue("params.$scanParameter.value", `val`)

View File

@ -259,7 +259,7 @@ val plotFitTask = task("plotFit") {
// ensuring all data points are calculated explicitly
StreamSupport.stream<Values>(data.spliterator(), false)
.map { dp -> Adapters.getXValue(adapter, dp).doubleValue() }.sorted().forEach { fit.calculateIn(it) }
.map { dp -> Adapters.getXValue(adapter, dp).getDouble() }.sorted().forEach { fit.calculateIn(it) }
frame.add(DataPlot.plot("data", adapter, data))

View File

@ -33,7 +33,7 @@ public class HandlerUtils {
}
b.append(String.format("<p> <strong>%s</strong> : <font color= \"%s\">%s</font> </p>%n",
pair.getFirst(), color, pair.getSecond().stringValue()));
pair.getFirst(), color, pair.getSecond().getString()));
});
b.append("</div>\n");
return b.toString();

View File

@ -37,7 +37,7 @@ public class NumassNote implements Serializable {
public static NumassNote buildFrom(Meta meta) {
String text = meta.getString("text", "");
if (meta.hasValue("time")) {
Instant time = meta.getValue("time").timeValue();
Instant time = meta.getValue("time").getTime();
return new NumassNote(text, time);
} else {
return new NumassNote(text);

View File

@ -11,7 +11,6 @@ import hep.dataforge.server.ServletUtils;
import hep.dataforge.storage.api.Loader;
import hep.dataforge.storage.api.StateLoader;
import hep.dataforge.storage.api.Storage;
import hep.dataforge.storage.commons.JSONMetaWriter;
import org.slf4j.LoggerFactory;
import ratpack.handling.Context;
import ratpack.handling.Handler;

View File

@ -16,7 +16,6 @@
package inr.numass.scripts
import hep.dataforge.io.MetaStreamWriter
import hep.dataforge.storage.commons.JSONMetaWriter
import hep.dataforge.storage.commons.StorageManager
new StorageManager().startGlobal();

View File

@ -8,7 +8,6 @@ package inr.numass.scripts
import hep.dataforge.io.MetaStreamWriter
import hep.dataforge.meta.Meta
import hep.dataforge.storage.commons.JSONMetaWriter
import hep.dataforge.storage.commons.StorageManager
import inr.numass.client.NumassClient

View File

@ -7,7 +7,6 @@
package inr.numass.scripts
import hep.dataforge.io.MetaStreamWriter
import hep.dataforge.storage.commons.JSONMetaWriter
import hep.dataforge.storage.commons.StorageManager
import inr.numass.client.NumassClient

View File

@ -16,7 +16,6 @@
package inr.numass.scripts
import hep.dataforge.io.MetaStreamWriter
import hep.dataforge.storage.commons.JSONMetaWriter
import hep.dataforge.storage.commons.StorageManager
import inr.numass.client.NumassClient

View File

@ -8,7 +8,6 @@ package inr.numass.scripts
import hep.dataforge.io.MetaStreamWriter
import hep.dataforge.meta.Meta
import hep.dataforge.storage.commons.JSONMetaWriter
import hep.dataforge.storage.commons.StorageManager
import inr.numass.client.NumassClient

View File

@ -10,7 +10,6 @@ import hep.dataforge.io.MetaStreamWriter
import hep.dataforge.io.envelopes.Envelope
import hep.dataforge.meta.Meta
import hep.dataforge.meta.MetaBuilder
import hep.dataforge.storage.commons.JSONMetaWriter
import hep.dataforge.storage.commons.LoaderFactory
import hep.dataforge.storage.commons.StorageManager
import hep.dataforge.tables.ValueMap

View File

@ -58,7 +58,7 @@ class HVView : View(title = "High voltage time plot", icon = ImageView(dfIcon))
hvData.ifPresent {
for (dp in it) {
val plot: TimePlot = frame[change.key] as TimePlot? ?: TimePlot(change.key).apply { frame.add(this) }
plot.put(dp.getValue("timestamp").timeValue(), dp.getValue("value"))
plot.put(dp.getValue("timestamp").getTime(), dp.getValue("value"))
}
}
container.progress = 1.0;

View File

@ -154,7 +154,7 @@ class SpectrumView(
}
fun add(key: String, value: NumassSet) {
data.put(key, NumassDataCache(value))
data[key] = NumassDataCache(value)
}
fun remove(key: String) {