From 68fa5c715b7986cce799031310ffbf8114095c25 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Thu, 5 Apr 2018 22:35:56 +0300 Subject: [PATCH] Updating control --- .../kotlin/inr/numass/control/magnet/LambdaHub.kt | 3 ++- .../kotlin/inr/numass/control/magnet/fx/MagnetApp.kt | 4 +--- .../main/kotlin/inr/numass/control/msp/MspDevice.kt | 3 ++- .../kotlin/inr/numass/control/DeviceDisplayFX.kt | 12 +++++++++--- .../kotlin/inr/numass/control/readvac/CM32Device.kt | 7 ++++--- .../inr/numass/control/readvac/MKSBaratronDevice.kt | 7 ++++--- .../inr/numass/control/readvac/MKSVacDevice.kt | 3 ++- .../inr/numass/control/readvac/MeradatVacDevice.kt | 7 ++++--- .../inr/numass/control/readvac/VacCollectorDevice.kt | 3 ++- numass-core/build.gradle | 4 ++++ .../main/kotlin/inr/numass/server/Interceptors.kt | 2 +- 11 files changed, 35 insertions(+), 20 deletions(-) diff --git a/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/LambdaHub.kt b/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/LambdaHub.kt index 4c63010b..d6860251 100644 --- a/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/LambdaHub.kt +++ b/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/LambdaHub.kt @@ -58,5 +58,6 @@ class LambdaHub(context: Context, meta: Meta) : DeviceHub, AbstractDevice(contex override fun optDevice(name: Name): Optional = magnets.stream().filter { it.name == name.toUnescaped() }.map { it as Device }.findFirst() - override fun getDeviceNames(): Stream = magnets.stream().map { Name.ofSingle(it.name) } + override val deviceNames: Stream + get() = magnets.stream().map { Name.ofSingle(it.name) } } \ No newline at end of file diff --git a/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/fx/MagnetApp.kt b/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/fx/MagnetApp.kt index 8c872aaf..c3600428 100644 --- a/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/fx/MagnetApp.kt +++ b/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/fx/MagnetApp.kt @@ -12,9 +12,7 @@ import javafx.stage.Stage class MagnetApp: NumassControlApplication() { override val deviceFactory: DeviceFactory = object :DeviceFactory{ - override fun getType(): String { - return "numass.lambda" - } + override val type: String = "numass.lambda" override fun build(context: Context, meta: Meta): Device { return LambdaHub(context, meta) diff --git a/numass-control/msp/src/main/kotlin/inr/numass/control/msp/MspDevice.kt b/numass-control/msp/src/main/kotlin/inr/numass/control/msp/MspDevice.kt index 9ee8380f..18d8dffa 100644 --- a/numass-control/msp/src/main/kotlin/inr/numass/control/msp/MspDevice.kt +++ b/numass-control/msp/src/main/kotlin/inr/numass/control/msp/MspDevice.kt @@ -124,7 +124,8 @@ class MspDevice(context: Context, meta: Meta) : PortSensor(context, meta) { // else -> super.computeState(stateName) // } - override fun getType(): String = MSP_DEVICE_TYPE + override val type: String + get() = MSP_DEVICE_TYPE /** * Startup MSP: get available sensors, select sensor and control. diff --git a/numass-control/src/main/kotlin/inr/numass/control/DeviceDisplayFX.kt b/numass-control/src/main/kotlin/inr/numass/control/DeviceDisplayFX.kt index 589febb6..de604c63 100644 --- a/numass-control/src/main/kotlin/inr/numass/control/DeviceDisplayFX.kt +++ b/numass-control/src/main/kotlin/inr/numass/control/DeviceDisplayFX.kt @@ -136,9 +136,15 @@ abstract class DeviceDisplayFX : Component(), Connection, DeviceList alignment = Pos.CENTER_LEFT vgrow = Priority.ALWAYS; deviceStateIndicator(this@DeviceDisplayFX, Device.INITIALIZED_STATE) - deviceStateIndicator(this@DeviceDisplayFX, PortSensor.CONNECTED_STATE) - deviceStateIndicator(this@DeviceDisplayFX, Sensor.MEASURING_STATE) - deviceStateIndicator(this@DeviceDisplayFX, "storing") + if(device is PortSensor) { + deviceStateIndicator(this@DeviceDisplayFX, PortSensor.CONNECTED_STATE) + } + if(device is Sensor) { + deviceStateIndicator(this@DeviceDisplayFX, Sensor.MEASURING_STATE) + } + if(device.stateNames.contains("storing")) { + deviceStateIndicator(this@DeviceDisplayFX, "storing") + } pane { hgrow = Priority.ALWAYS } diff --git a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/CM32Device.kt b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/CM32Device.kt index 303e3c83..958cfae8 100644 --- a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/CM32Device.kt +++ b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/CM32Device.kt @@ -52,8 +52,9 @@ class CM32Device(context: Context, meta: Meta) : PortSensor(context, meta) { } } - override fun getType(): String { - return meta.getString("type", "numass.vac.cm32") - } + override val type: String + get() { + return meta.getString("type", "numass.vac.cm32") + } } diff --git a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSBaratronDevice.kt b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSBaratronDevice.kt index e45454f6..d2de665a 100644 --- a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSBaratronDevice.kt +++ b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSBaratronDevice.kt @@ -27,9 +27,10 @@ class MKSBaratronDevice(context: Context, meta: Meta) : PortSensor(context, meta var channel by valueState("channel").intDelegate - override fun getType(): String { - return meta.getString("type", "numass.vac.baratron") - } + override val type: String + get() { + return meta.getString("type", "numass.vac.baratron") + } override fun connect(meta: Meta): GenericPortController { val port: Port = PortFactory.build(meta) diff --git a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSVacDevice.kt b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSVacDevice.kt index dc687f78..ae5750a2 100644 --- a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSVacDevice.kt +++ b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSVacDevice.kt @@ -97,7 +97,8 @@ class MKSVacDevice(context: Context, meta: Meta) : PortSensor(context, meta) { } } - override fun getType(): String = meta.getString("type", "numass.vac.mks") + override val type: String + get() = meta.getString("type", "numass.vac.mks") override fun startMeasurement(oldMeta: Meta?, newMeta: Meta) { measurement { diff --git a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MeradatVacDevice.kt b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MeradatVacDevice.kt index 011070e8..a73e9512 100644 --- a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MeradatVacDevice.kt +++ b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MeradatVacDevice.kt @@ -35,9 +35,10 @@ class MeradatVacDevice(context: Context, meta: Meta) : PortSensor(context, meta) return GenericPortController(context, port) { it.endsWith("\r\n") } } - override fun getType(): String { - return meta.getString("type", "numass.vac.vit") - } + override val type: String + get() { + return meta.getString("type", "numass.vac.vit") + } override fun startMeasurement(oldMeta: Meta?, newMeta: Meta) { measurement{ diff --git a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacCollectorDevice.kt b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacCollectorDevice.kt index ef2ec2b9..03c62449 100644 --- a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacCollectorDevice.kt +++ b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacCollectorDevice.kt @@ -75,7 +75,8 @@ class VacCollectorDevice(context: Context, meta: Meta, val sensors: Collection val device = deviceManager.optDevice(name).get(); devices.add(jsonObject { add("name", name.toUnescaped()) - add("type", device.getType()) + add("type", device.type) add("getMeta", device.meta.asJson()) }) }