Merged kodex into core
This commit is contained in:
parent
804221c859
commit
8fa0c651ff
@ -18,19 +18,14 @@ package inr.numass.control.cryotemp
|
|||||||
import hep.dataforge.context.Context
|
import hep.dataforge.context.Context
|
||||||
import hep.dataforge.control.RoleDef
|
import hep.dataforge.control.RoleDef
|
||||||
import hep.dataforge.control.RoleDefs
|
import hep.dataforge.control.RoleDefs
|
||||||
import hep.dataforge.control.collectors.RegularPointCollector
|
|
||||||
import hep.dataforge.control.connections.Roles
|
import hep.dataforge.control.connections.Roles
|
||||||
import hep.dataforge.control.devices.Device
|
|
||||||
import hep.dataforge.control.devices.PortSensor
|
import hep.dataforge.control.devices.PortSensor
|
||||||
import hep.dataforge.control.devices.Sensor
|
import hep.dataforge.control.devices.Sensor
|
||||||
import hep.dataforge.control.devices.StateDef
|
import hep.dataforge.control.devices.StateDef
|
||||||
import hep.dataforge.control.measurements.AbstractMeasurement
|
import hep.dataforge.control.devices.stringState
|
||||||
import hep.dataforge.control.measurements.Measurement
|
|
||||||
import hep.dataforge.control.ports.GenericPortController
|
|
||||||
import hep.dataforge.control.ports.Port
|
import hep.dataforge.control.ports.Port
|
||||||
import hep.dataforge.description.ValueDef
|
import hep.dataforge.description.ValueDef
|
||||||
import hep.dataforge.exceptions.ControlException
|
import hep.dataforge.exceptions.ControlException
|
||||||
import hep.dataforge.exceptions.MeasurementException
|
|
||||||
import hep.dataforge.exceptions.StorageException
|
import hep.dataforge.exceptions.StorageException
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
import hep.dataforge.storage.api.TableLoader
|
import hep.dataforge.storage.api.TableLoader
|
||||||
@ -39,12 +34,10 @@ import hep.dataforge.storage.commons.StorageConnection
|
|||||||
import hep.dataforge.tables.TableFormat
|
import hep.dataforge.tables.TableFormat
|
||||||
import hep.dataforge.tables.TableFormatBuilder
|
import hep.dataforge.tables.TableFormatBuilder
|
||||||
import hep.dataforge.utils.DateTimeUtils
|
import hep.dataforge.utils.DateTimeUtils
|
||||||
import hep.dataforge.values.Values
|
|
||||||
import inr.numass.control.DeviceView
|
import inr.numass.control.DeviceView
|
||||||
import inr.numass.control.StorageHelper
|
import inr.numass.control.StorageHelper
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.function.BiConsumer
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,14 +76,11 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor<PKT8Result>(context,
|
|||||||
tableFormatBuilder.build()
|
tableFormatBuilder.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
val sps: String
|
val sps: String by stringState(SPS)
|
||||||
get() = getState(SPS).stringValue()
|
|
||||||
|
|
||||||
val pga: String
|
val pga: String by stringState(PGA)
|
||||||
get() = getState(PGA).stringValue()
|
|
||||||
|
|
||||||
val abuf: String
|
val abuf: String by stringState(ABUF)
|
||||||
get() = getState(ABUF).stringValue()
|
|
||||||
|
|
||||||
private val duration = Duration.parse(getMeta().getString("averagingDuration", "PT30S"))
|
private val duration = Duration.parse(getMeta().getString("averagingDuration", "PT30S"))
|
||||||
|
|
||||||
@ -137,8 +127,8 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor<PKT8Result>(context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
setSPS(getMeta().getInt("sps", 0))
|
setSPS(meta.getInt("sps", 0))
|
||||||
setBUF(getMeta().getInt("abuf", 100))
|
setBUF(meta.getInt("abuf", 100))
|
||||||
|
|
||||||
// setting up the collector
|
// setting up the collector
|
||||||
storageHelper = StorageHelper(this) { connection: StorageConnection -> this.buildLoader(connection) }
|
storageHelper = StorageHelper(this) { connection: StorageConnection -> this.buildLoader(connection) }
|
||||||
@ -146,11 +136,11 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor<PKT8Result>(context,
|
|||||||
|
|
||||||
@Throws(ControlException::class)
|
@Throws(ControlException::class)
|
||||||
override fun shutdown() {
|
override fun shutdown() {
|
||||||
measurement?.stop(true)
|
|
||||||
storageHelper?.close()
|
storageHelper?.close()
|
||||||
super.shutdown()
|
super.shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Throws(ControlException::class)
|
@Throws(ControlException::class)
|
||||||
override fun buildPort(portName: String): Port {
|
override fun buildPort(portName: String): Port {
|
||||||
//setup connection
|
//setup connection
|
||||||
@ -184,7 +174,7 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor<PKT8Result>(context,
|
|||||||
|
|
||||||
@Throws(ControlException::class)
|
@Throws(ControlException::class)
|
||||||
fun changeParameters(sps: Int, abuf: Int) {
|
fun changeParameters(sps: Int, abuf: Int) {
|
||||||
stopMeasurement(false)
|
stopCurrentMeasurement()
|
||||||
//setting sps
|
//setting sps
|
||||||
setSPS(sps)
|
setSPS(sps)
|
||||||
//setting buffer
|
//setting buffer
|
||||||
@ -233,72 +223,14 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor<PKT8Result>(context,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setSPS(sps: Int) {
|
|
||||||
logger.info("Setting sampling rate to " + spsToStr(sps))
|
|
||||||
val response: String = try {
|
|
||||||
sendAndWait("v" + sps).trim { it <= ' ' }
|
|
||||||
} catch (ex: Exception) {
|
|
||||||
ex.message ?: ""
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response.contains("=")) {
|
override fun startMeasurement(oldMeta: Meta, newMeta: Meta) {
|
||||||
updateLogicalState(SPS, Integer.parseInt(response.substring(4)))
|
if (!oldMeta.isEmpty) {
|
||||||
} else {
|
|
||||||
logger.error("Setting sps failed with message: " + response)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Throws(MeasurementException::class)
|
|
||||||
override fun createMeasurement(): Measurement<PKT8Result> {
|
|
||||||
return if (this.measurement != null) {
|
|
||||||
this.measurement
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
PKT8Measurement(connection)
|
|
||||||
} catch (e: ControlException) {
|
|
||||||
throw MeasurementException(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Throws(MeasurementException::class)
|
|
||||||
override fun startMeasurement(): Measurement<PKT8Result> {
|
|
||||||
//clearing PKT queue
|
|
||||||
try {
|
|
||||||
send("p")
|
|
||||||
sendAndWait("p")
|
|
||||||
} catch (e: ControlException) {
|
|
||||||
logger.error("Failed to clear PKT8 port")
|
|
||||||
// throw new MeasurementException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.startMeasurement()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inner class PKT8Measurement(private val controller: GenericPortController) : AbstractMeasurement<PKT8Result>() {
|
|
||||||
|
|
||||||
override fun getDevice(): Device = this@PKT8Device
|
|
||||||
|
|
||||||
private var collector: RegularPointCollector = RegularPointCollector(duration, channels.values.map { it.name }) { dp: Values ->
|
|
||||||
logger.debug("Point measurement complete. Pushing...")
|
|
||||||
storageHelper?.push(dp)
|
|
||||||
}
|
|
||||||
|
|
||||||
var errorListener: BiConsumer<String, Throwable>? = null
|
|
||||||
var stopListener: GenericPortController.PhraseListener? = null;
|
|
||||||
var valueListener: GenericPortController.PhraseListener? = null;
|
|
||||||
|
|
||||||
override fun start() {
|
|
||||||
if (isStarted) {
|
|
||||||
logger.warn("Trying to start measurement which is already started")
|
logger.warn("Trying to start measurement which is already started")
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.info("Starting measurement")
|
logger.info("Starting measurement")
|
||||||
//add weak error listener
|
|
||||||
errorListener = controller.onError(this::onError)
|
|
||||||
|
|
||||||
//add weak stop listener
|
//add weak stop listener
|
||||||
stopListener = controller.onPhrase("[Ss]topped\\s*") {
|
stopListener = controller.onPhrase("[Ss]topped\\s*") {
|
||||||
@ -329,11 +261,9 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor<PKT8Result>(context,
|
|||||||
} catch (ex: ControlException) {
|
} catch (ex: ControlException) {
|
||||||
onError("Failed to start measurement", ex)
|
onError("Failed to start measurement", ex)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
override fun stopMeasurement(meta: Meta) {
|
||||||
|
|
||||||
@Throws(MeasurementException::class)
|
|
||||||
override fun stop(force: Boolean): Boolean {
|
|
||||||
if (isFinished) {
|
if (isFinished) {
|
||||||
logger.warn("Trying to stop measurement which is already stopped")
|
logger.warn("Trying to stop measurement which is already stopped")
|
||||||
return true
|
return true
|
||||||
@ -356,9 +286,134 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor<PKT8Result>(context,
|
|||||||
logger.debug("Collector stopped")
|
logger.debug("Collector stopped")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setSPS(sps: Int) {
|
||||||
|
logger.info("Setting sampling rate to " + spsToStr(sps))
|
||||||
|
val response: String = try {
|
||||||
|
sendAndWait("v" + sps).trim { it <= ' ' }
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
ex.message ?: ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.contains("=")) {
|
||||||
|
updateLogicalState(SPS, Integer.parseInt(response.substring(4)))
|
||||||
|
} else {
|
||||||
|
logger.error("Setting sps failed with message: " + response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Throws(MeasurementException::class)
|
||||||
|
// override fun createMeasurement(): Measurement<PKT8Result> {
|
||||||
|
// return if (this.measurement != null) {
|
||||||
|
// this.measurement
|
||||||
|
// } else {
|
||||||
|
// try {
|
||||||
|
// PKT8Measurement(connection)
|
||||||
|
// } catch (e: ControlException) {
|
||||||
|
// throw MeasurementException(e)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Throws(MeasurementException::class)
|
||||||
|
// override fun startMeasurement(): Measurement<PKT8Result> {
|
||||||
|
// //clearing PKT queue
|
||||||
|
// try {
|
||||||
|
// send("p")
|
||||||
|
// sendAndWait("p")
|
||||||
|
// } catch (e: ControlException) {
|
||||||
|
// logger.error("Failed to clear PKT8 port")
|
||||||
|
// // throw new MeasurementException(e);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return super.startMeasurement()
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// inner class PKT8Measurement(private val controller: GenericPortController) : AbstractMeasurement<PKT8Result>() {
|
||||||
|
//
|
||||||
|
// override fun getDevice(): Device = this@PKT8Device
|
||||||
|
//
|
||||||
|
// private var collector: RegularPointCollector = RegularPointCollector(duration, channels.values.map { it.name }) { dp: Values ->
|
||||||
|
// logger.debug("Point measurement complete. Pushing...")
|
||||||
|
// storageHelper?.push(dp)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// var errorListener: BiConsumer<String, Throwable>? = null
|
||||||
|
// var stopListener: GenericPortController.PhraseListener? = null;
|
||||||
|
// var valueListener: GenericPortController.PhraseListener? = null;
|
||||||
|
//
|
||||||
|
// override fun start() {
|
||||||
|
// if (isStarted) {
|
||||||
|
// logger.warn("Trying to start measurement which is already started")
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
// logger.info("Starting measurement")
|
||||||
|
// //add weak error listener
|
||||||
|
// errorListener = controller.onError(this::onError)
|
||||||
|
//
|
||||||
|
// //add weak stop listener
|
||||||
|
// stopListener = controller.onPhrase("[Ss]topped\\s*") {
|
||||||
|
// afterPause()
|
||||||
|
// updateLogicalState(Sensor.MEASURING_STATE, false)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //add weak measurement listener
|
||||||
|
// valueListener = controller.onPhrase("[a-f].*") {
|
||||||
|
// val trimmed = it.trim()
|
||||||
|
// val designation = trimmed.substring(0, 1)
|
||||||
|
// val rawValue = java.lang.Double.parseDouble(trimmed.substring(1)) / 100
|
||||||
|
//
|
||||||
|
// val channel = this@PKT8Device.channels[designation]
|
||||||
|
//
|
||||||
|
// if (channel != null) {
|
||||||
|
// result(channel.evaluate(rawValue))
|
||||||
|
// collector.put(channel.name, channel.getTemperature(rawValue))
|
||||||
|
// } else {
|
||||||
|
// result(PKT8Result(designation, rawValue, -1.0))
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //send start signal
|
||||||
|
// controller.send("s")
|
||||||
|
//
|
||||||
|
// afterStart()
|
||||||
|
// } catch (ex: ControlException) {
|
||||||
|
// onError("Failed to start measurement", ex)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Throws(MeasurementException::class)
|
||||||
|
// override fun stop(force: Boolean): Boolean {
|
||||||
|
// if (isFinished) {
|
||||||
|
// logger.warn("Trying to stop measurement which is already stopped")
|
||||||
|
// return true
|
||||||
|
// } else {
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
// logger.info("Stopping measurement")
|
||||||
|
// val response = sendAndWait("p").trim()
|
||||||
|
// // Должно быть именно с большой буквы!!!
|
||||||
|
// return "Stopped" == response || "stopped" == response
|
||||||
|
// } catch (ex: Exception) {
|
||||||
|
// onError("Failed to stop measurement", ex)
|
||||||
|
// return false
|
||||||
|
// } finally {
|
||||||
|
// afterStop()
|
||||||
|
// errorListener?.let { controller.removeErrorListener(it) }
|
||||||
|
// stopListener?.let { controller.removePhraseListener(it) }
|
||||||
|
// valueListener?.let { controller.removePhraseListener(it) }
|
||||||
|
// collector.stop()
|
||||||
|
// logger.debug("Collector stopped")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
companion object {
|
companion object {
|
||||||
val PKT8_DEVICE_TYPE = "numass.pkt8"
|
val PKT8_DEVICE_TYPE = "numass.pkt8"
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class LambdaHub(context: Context, meta: Meta) : DeviceHub, AbstractDevice(contex
|
|||||||
return if(portName.startsWith("virtual")){
|
return if(portName.startsWith("virtual")){
|
||||||
VirtualLambdaPort(meta)
|
VirtualLambdaPort(meta)
|
||||||
} else{
|
} else{
|
||||||
PortFactory.getPort(portName);
|
PortFactory.build(portName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,11 +16,8 @@
|
|||||||
package inr.numass.control.magnet
|
package inr.numass.control.magnet
|
||||||
|
|
||||||
import hep.dataforge.context.Context
|
import hep.dataforge.context.Context
|
||||||
import hep.dataforge.control.devices.AbstractDevice
|
import hep.dataforge.control.devices.*
|
||||||
import hep.dataforge.control.devices.StateDef
|
|
||||||
import hep.dataforge.control.devices.StateDefs
|
|
||||||
import hep.dataforge.control.ports.PortFactory
|
import hep.dataforge.control.ports.PortFactory
|
||||||
import hep.dataforge.control.ports.PortTimeoutException
|
|
||||||
import hep.dataforge.description.ValueDef
|
import hep.dataforge.description.ValueDef
|
||||||
import hep.dataforge.exceptions.ControlException
|
import hep.dataforge.exceptions.ControlException
|
||||||
import hep.dataforge.exceptions.PortException
|
import hep.dataforge.exceptions.PortException
|
||||||
@ -28,9 +25,6 @@ import hep.dataforge.meta.Meta
|
|||||||
import hep.dataforge.utils.DateTimeUtils
|
import hep.dataforge.utils.DateTimeUtils
|
||||||
import hep.dataforge.values.Value
|
import hep.dataforge.values.Value
|
||||||
import hep.dataforge.values.ValueType.*
|
import hep.dataforge.values.ValueType.*
|
||||||
import hep.dataforge.control.devices.booleanState
|
|
||||||
import hep.dataforge.control.devices.doubleState
|
|
||||||
import hep.dataforge.control.devices.timeState
|
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
@ -97,7 +91,7 @@ open class LambdaMagnet(context: Context, meta: Meta, private val controller: La
|
|||||||
* @throws ControlException
|
* @throws ControlException
|
||||||
*/
|
*/
|
||||||
@Throws(ControlException::class)
|
@Throws(ControlException::class)
|
||||||
constructor(context: Context, meta: Meta) : this(context, meta, LambdaPortController(context, PortFactory.getPort(meta.getString("port")))) {
|
constructor(context: Context, meta: Meta) : this(context, meta, LambdaPortController(context, PortFactory.build(meta.getString("port")))) {
|
||||||
closePortOnShutDown = true
|
closePortOnShutDown = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ object Talk {
|
|||||||
portName = args[0]
|
portName = args[0]
|
||||||
}
|
}
|
||||||
val handler: Port
|
val handler: Port
|
||||||
handler = PortFactory.getPort(portName)
|
handler = PortFactory.build(portName)
|
||||||
handler.setPhraseCondition { str: String -> str.endsWith("\r") }
|
handler.setPhraseCondition { str: String -> str.endsWith("\r") }
|
||||||
|
|
||||||
// LambdaMagnet controller = new LambdaMagnet(handler, 1);
|
// LambdaMagnet controller = new LambdaMagnet(handler, 1);
|
||||||
|
@ -131,7 +131,7 @@ class MspDevice(context: Context, meta: Meta) : PortSensor<Values>(context, meta
|
|||||||
@Throws(ControlException::class)
|
@Throws(ControlException::class)
|
||||||
override fun shutdown() {
|
override fun shutdown() {
|
||||||
super.stopMeasurement(true)
|
super.stopMeasurement(true)
|
||||||
if (isConnected) {
|
if (connected) {
|
||||||
setFilamentOn(false)
|
setFilamentOn(false)
|
||||||
setConnected(false)
|
setConnected(false)
|
||||||
}
|
}
|
||||||
@ -183,7 +183,7 @@ class MspDevice(context: Context, meta: Meta) : PortSensor<Values>(context, meta
|
|||||||
@Throws(ControlException::class)
|
@Throws(ControlException::class)
|
||||||
private fun setConnected(connected: Boolean): Boolean {
|
private fun setConnected(connected: Boolean): Boolean {
|
||||||
val sensorName: String
|
val sensorName: String
|
||||||
if (isConnected != connected) {
|
if (this.connected != connected) {
|
||||||
if (connected) {
|
if (connected) {
|
||||||
connection.open()
|
connection.open()
|
||||||
var response = commandAndWait("Sensors")
|
var response = commandAndWait("Sensors")
|
||||||
|
@ -7,6 +7,7 @@ import hep.dataforge.control.devices.DeviceListener
|
|||||||
import hep.dataforge.control.devices.PortSensor
|
import hep.dataforge.control.devices.PortSensor
|
||||||
import hep.dataforge.control.devices.Sensor
|
import hep.dataforge.control.devices.Sensor
|
||||||
import hep.dataforge.fx.bindWindow
|
import hep.dataforge.fx.bindWindow
|
||||||
|
import hep.dataforge.meta.Meta
|
||||||
import hep.dataforge.values.Value
|
import hep.dataforge.values.Value
|
||||||
import javafx.beans.binding.BooleanBinding
|
import javafx.beans.binding.BooleanBinding
|
||||||
import javafx.beans.binding.ObjectBinding
|
import javafx.beans.binding.ObjectBinding
|
||||||
@ -48,6 +49,7 @@ fun Device.getDisplay(): DeviceDisplay<*> {
|
|||||||
abstract class DeviceDisplay<D : Device> : Component(), Connection, DeviceListener {
|
abstract class DeviceDisplay<D : Device> : Component(), Connection, DeviceListener {
|
||||||
|
|
||||||
private val bindings = HashMap<String, ObjectBinding<Value>>()
|
private val bindings = HashMap<String, ObjectBinding<Value>>()
|
||||||
|
private val metaBindings = HashMap<String, ObjectBinding<Meta>>()
|
||||||
|
|
||||||
private val deviceProperty = SimpleObjectProperty<D>(this, "device", null)
|
private val deviceProperty = SimpleObjectProperty<D>(this, "device", null)
|
||||||
val device: D by deviceProperty
|
val device: D by deviceProperty
|
||||||
@ -99,6 +101,20 @@ abstract class DeviceDisplay<D : Device> : Component(), Connection, DeviceListen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getMetaStateBinding(state: String): ObjectBinding<Meta> {
|
||||||
|
return metaBindings.computeIfAbsent(state) { stateName ->
|
||||||
|
object : ObjectBinding<Meta>() {
|
||||||
|
override fun computeValue(): Meta {
|
||||||
|
return if (isOpen) {
|
||||||
|
device.getMetaState(stateName)
|
||||||
|
} else {
|
||||||
|
Meta.empty()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun getBooleanStateBinding(state: String): BooleanBinding =
|
fun getBooleanStateBinding(state: String): BooleanBinding =
|
||||||
getStateBinding(state).booleanBinding { it?.booleanValue() ?: false }
|
getStateBinding(state).booleanBinding { it?.booleanValue() ?: false }
|
||||||
|
|
||||||
@ -131,6 +147,10 @@ abstract class DeviceDisplay<D : Device> : Component(), Connection, DeviceListen
|
|||||||
bindings[name]?.invalidate()
|
bindings[name]?.invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun notifyDeviceStateChanged(device: Device, name: String, state: Meta) {
|
||||||
|
metaBindings[name]?.invalidate()
|
||||||
|
}
|
||||||
|
|
||||||
open fun getBoardView(): Parent {
|
open fun getBoardView(): Parent {
|
||||||
return HBox().apply {
|
return HBox().apply {
|
||||||
alignment = Pos.CENTER_LEFT
|
alignment = Pos.CENTER_LEFT
|
||||||
|
@ -72,7 +72,7 @@ class Indicator(radius: Double = 10.0) : Circle(radius, Color.GRAY) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun EventTarget.indicator(radius: Double = 10.0, op: (Indicator.() -> Unit)? = null) = opcr(this, Indicator(radius), op)
|
fun EventTarget.indicator(radius: Double = 10.0, op: (Indicator.() -> Unit) = {}): Indicator = opcr(this, Indicator(radius), op)
|
||||||
|
|
||||||
fun Indicator.bind(connection: DeviceDisplay<*>, state: String, transform: ((Value) -> Paint)? = null) {
|
fun Indicator.bind(connection: DeviceDisplay<*>, state: String, transform: ((Value) -> Paint)? = null) {
|
||||||
tooltip(state)
|
tooltip(state)
|
||||||
@ -130,7 +130,7 @@ fun Node.deviceStateToggle(connection: DeviceDisplay<*>, state: String, title: S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun EventTarget.switch(text: String = "", op: (ToggleSwitch.() -> Unit)? = null): ToggleSwitch {
|
fun EventTarget.switch(text: String = "", op: (ToggleSwitch.() -> Unit) = {}): ToggleSwitch {
|
||||||
val switch = ToggleSwitch(text)
|
val switch = ToggleSwitch(text)
|
||||||
return opcr(this, switch, op)
|
return opcr(this, switch, op)
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ fun connectStorage(device: Device, config: Meta) {
|
|||||||
device.context.logger.info("Creating storage for device with getMeta: {}", node)
|
device.context.logger.info("Creating storage for device with getMeta: {}", node)
|
||||||
//building storage in a separate thread
|
//building storage in a separate thread
|
||||||
Thread {
|
Thread {
|
||||||
var storage = StorageFactory.buildStorage(device.context, node)
|
var storage = StorageManager.buildStorage(device.context, node)
|
||||||
if (!numassRun.isEmpty()) {
|
if (!numassRun.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
storage = storage.buildShelf(numassRun, Meta.empty())
|
storage = storage.buildShelf(numassRun, Meta.empty())
|
||||||
|
@ -30,7 +30,7 @@ class CM32Device(context: Context, meta: Meta) : PortSensor<Double>(context, met
|
|||||||
if (portName.startsWith("com")) {
|
if (portName.startsWith("com")) {
|
||||||
new = ComPort(portName, 2400, 8, 1, 0)
|
new = ComPort(portName, 2400, 8, 1, 0)
|
||||||
} else {
|
} else {
|
||||||
new = PortFactory.getPort(portName)
|
new = PortFactory.build(portName)
|
||||||
}
|
}
|
||||||
new.setDelimiter("T--\r")
|
new.setDelimiter("T--\r")
|
||||||
return new
|
return new
|
||||||
|
@ -87,7 +87,7 @@ class MKSVacDevice(context: Context, meta: Meta) : PortSensor<Double>(context, m
|
|||||||
|
|
||||||
@Throws(ControlException::class)
|
@Throws(ControlException::class)
|
||||||
override fun shutdown() {
|
override fun shutdown() {
|
||||||
if (isConnected) {
|
if (connected) {
|
||||||
setState("power", false)
|
setState("power", false)
|
||||||
}
|
}
|
||||||
super.shutdown()
|
super.shutdown()
|
||||||
|
@ -3,7 +3,6 @@ package inr.numass.control.readvac
|
|||||||
import hep.dataforge.context.Context
|
import hep.dataforge.context.Context
|
||||||
import hep.dataforge.control.devices.DeviceFactory
|
import hep.dataforge.control.devices.DeviceFactory
|
||||||
import hep.dataforge.control.devices.Sensor
|
import hep.dataforge.control.devices.Sensor
|
||||||
import hep.dataforge.control.virtual.VirtualDevice
|
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
import java.util.stream.Collectors
|
import java.util.stream.Collectors
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ description = "A bse package with minimal dependencies for numass"
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile "hep.dataforge:dataforge-storage" //project(':dataforge-storage')
|
compile "hep.dataforge:dataforge-storage" //project(':dataforge-storage')
|
||||||
compile "hep.dataforge:kodex"
|
|
||||||
compile 'com.google.protobuf:protobuf-java:3.5.0'
|
compile 'com.google.protobuf:protobuf-java:3.5.0'
|
||||||
|
|
||||||
// https://mvnrepository.com/artifact/com.github.robtimus/sftp-fs
|
// https://mvnrepository.com/artifact/com.github.robtimus/sftp-fs
|
||||||
|
@ -32,7 +32,6 @@ dependencies {
|
|||||||
compile project(':numass-core')
|
compile project(':numass-core')
|
||||||
compile "hep.dataforge:dataforge-minuit" //project(':dataforge-stat:dataforge-minuit')
|
compile "hep.dataforge:dataforge-minuit" //project(':dataforge-stat:dataforge-minuit')
|
||||||
compile "hep.dataforge:grind-terminal" //project(':dataforge-grind:grind-terminal')
|
compile "hep.dataforge:grind-terminal" //project(':dataforge-grind:grind-terminal')
|
||||||
compile "hep.dataforge:kmath"
|
|
||||||
compile "hep.dataforge:dataforge-gui"
|
compile "hep.dataforge:dataforge-gui"
|
||||||
|
|
||||||
// https://mvnrepository.com/artifact/org.ehcache/ehcache
|
// https://mvnrepository.com/artifact/org.ehcache/ehcache
|
||||||
|
@ -62,7 +62,7 @@ public class SpectrumGenerator implements Generator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SpectrumGenerator(XYModel source, ParamSet params) {
|
public SpectrumGenerator(XYModel source, ParamSet params) {
|
||||||
this(source, params, getDefaultRandomGenerator());
|
this(source, params, INSTANCE.getDefaultRandomGenerator());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -121,9 +121,9 @@ class NumassBeta : AbstractParametricBiFunction(list) {
|
|||||||
val ve = pe / eTot
|
val ve = pe / eTot
|
||||||
val yfactor = 2.0 * 2.0 * 1.0 / 137.039 * Math.PI
|
val yfactor = 2.0 * 2.0 * 1.0 / 137.039 * Math.PI
|
||||||
val y = yfactor / ve
|
val y = yfactor / ve
|
||||||
val Fn = y / abs(1.0 - exp(-y))
|
val fn = y / abs(1.0 - exp(-y))
|
||||||
val Fermi = Fn * (1.002037 - 0.001427 * ve)
|
val fermi = fn * (1.002037 - 0.001427 * ve)
|
||||||
val res = Fermi * pe * eTot
|
val res = fermi * pe * eTot
|
||||||
return K * res
|
return K * res
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,22 +141,17 @@ class NumassBeta : AbstractParametricBiFunction(list) {
|
|||||||
*/
|
*/
|
||||||
private fun root(E0: Double, mnu2: Double, E: Double): Double {
|
private fun root(E0: Double, mnu2: Double, E: Double): Double {
|
||||||
//bare beta-spectrum
|
//bare beta-spectrum
|
||||||
val delta = E0 - E//E0-E
|
val delta = E0 - E
|
||||||
val res: Double
|
|
||||||
val bare = factor(E) * delta * sqrt(Math.max(delta * delta - mnu2, 0.0))
|
val bare = factor(E) * delta * sqrt(Math.max(delta * delta - mnu2, 0.0))
|
||||||
if (delta == 0.0) {
|
return when {
|
||||||
return 0.0
|
mnu2 >= 0 -> Math.max(bare, 0.0)
|
||||||
}
|
delta == 0.0 -> 0.0
|
||||||
if (mnu2 >= 0) {
|
delta + 0.812 * sqrt(-mnu2) <= 0 -> 0.0 //sqrt(0.66)
|
||||||
res = Math.max(bare, 0.0)
|
else -> {
|
||||||
} else {
|
val aux = sqrt(-mnu2 * 0.66) / delta
|
||||||
if (delta + 0.812 * sqrt(-mnu2) <= 0) {
|
Math.max(bare * (1 + aux * exp(-1 - 1 / aux)), 0.0)
|
||||||
return 0.0 //sqrt(0.66)
|
|
||||||
}
|
}
|
||||||
val aux = sqrt(-mnu2 * 0.66) / delta
|
|
||||||
res = Math.max(bare * (1 + aux * exp(-1 - 1 / aux)), 0.0)
|
|
||||||
}
|
}
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -181,9 +176,9 @@ class NumassBeta : AbstractParametricBiFunction(list) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getDefaultParameter(name: String): Double {
|
override fun getDefaultParameter(name: String): Double {
|
||||||
when (name) {
|
return when (name) {
|
||||||
"mnu2", "U2", "msterile2" -> return 0.0
|
"mnu2", "U2", "msterile2" -> 0.0
|
||||||
else -> return super.getDefaultParameter(name)
|
else -> super.getDefaultParameter(name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user