From 669766e816c483aaec6c1b71c11a9649c9d9ed5e Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Mon, 26 Nov 2018 21:16:29 +0300 Subject: [PATCH] Monitor for IT6800 --- numass-control/gun/build.gradle | 2 +- .../kotlin/inr/numass/control/gun/EGun.kt | 40 +++++++++++++++++ .../inr/numass/control/gun/EGunApplication.kt | 43 +++++++++++++++++++ .../kotlin/inr/numass/control/gun/EGunView.kt | 37 ++++++++++++++++ .../inr/numass/control/magnet/LambdaHub.kt | 5 +-- .../inr/numass/control/magnet/LambdaMagnet.kt | 1 + .../inr/numass/control/magnet/fx/MagnetApp.kt | 1 - .../control/readvac/VacCollectorDevice.kt | 5 +-- 8 files changed, 126 insertions(+), 8 deletions(-) create mode 100644 numass-control/gun/src/main/kotlin/inr/numass/control/gun/EGun.kt create mode 100644 numass-control/gun/src/main/kotlin/inr/numass/control/gun/EGunApplication.kt create mode 100644 numass-control/gun/src/main/kotlin/inr/numass/control/gun/EGunView.kt diff --git a/numass-control/gun/build.gradle b/numass-control/gun/build.gradle index 46e88a86..38371017 100644 --- a/numass-control/gun/build.gradle +++ b/numass-control/gun/build.gradle @@ -19,7 +19,7 @@ apply plugin: 'application' version = "0.1.0" if (!hasProperty('mainClass')) { - ext.mainClass = 'inr.numass.control.magnet.fx.MagnetApp' + ext.mainClass = 'inr.numass.control.gun.EGunApplicationkt' } mainClassName = mainClass diff --git a/numass-control/gun/src/main/kotlin/inr/numass/control/gun/EGun.kt b/numass-control/gun/src/main/kotlin/inr/numass/control/gun/EGun.kt new file mode 100644 index 00000000..da808b9a --- /dev/null +++ b/numass-control/gun/src/main/kotlin/inr/numass/control/gun/EGun.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2018 Alexander Nozik. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package inr.numass.control.gun + +import hep.dataforge.context.Context +import hep.dataforge.context.ContextAware +import hep.dataforge.control.devices.AbstractDevice +import hep.dataforge.control.devices.Device +import hep.dataforge.control.devices.DeviceHub +import hep.dataforge.meta.Meta +import hep.dataforge.meta.Metoid +import hep.dataforge.names.Name +import hep.dataforge.optional +import java.util.* + +class EGun(context: Context, meta: Meta) : AbstractDevice(context, meta), DeviceHub, ContextAware, Metoid { + val sources: List by lazy { + meta.getMetaList("source").map {IT6800Device(context, it) } + } + + override val deviceNames: List by lazy{ sources.map { Name.of(it.name) }} + + override fun optDevice(name: Name): Optional { + return sources.find { it.name == name.toString() }.optional + } +} \ No newline at end of file diff --git a/numass-control/gun/src/main/kotlin/inr/numass/control/gun/EGunApplication.kt b/numass-control/gun/src/main/kotlin/inr/numass/control/gun/EGunApplication.kt new file mode 100644 index 00000000..a3b9d698 --- /dev/null +++ b/numass-control/gun/src/main/kotlin/inr/numass/control/gun/EGunApplication.kt @@ -0,0 +1,43 @@ +/* + * Copyright 2018 Alexander Nozik. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package inr.numass.control.gun + +import hep.dataforge.context.Context +import hep.dataforge.control.devices.Device +import hep.dataforge.control.devices.DeviceFactory +import hep.dataforge.meta.Meta +import hep.dataforge.meta.MetaUtils +import inr.numass.control.NumassControlApplication +import javafx.stage.Stage + +class EGunApplication: NumassControlApplication() { + override val deviceFactory: DeviceFactory = object :DeviceFactory{ + override val type: String = "numass.lambda" + + override fun build(context: Context, meta: Meta): Device { + return EGun(context, meta) + } + } + + override fun setupStage(stage: Stage, device: EGun) { + stage.title = "Numass gun control" + } + + override fun getDeviceMeta(config: Meta): Meta { + return MetaUtils.findNode(config,"device"){it.getString("name") == "numass.gun"}.orElseThrow{RuntimeException("Gun configuration not found")} + } +} \ No newline at end of file diff --git a/numass-control/gun/src/main/kotlin/inr/numass/control/gun/EGunView.kt b/numass-control/gun/src/main/kotlin/inr/numass/control/gun/EGunView.kt new file mode 100644 index 00000000..172eac6d --- /dev/null +++ b/numass-control/gun/src/main/kotlin/inr/numass/control/gun/EGunView.kt @@ -0,0 +1,37 @@ +/* + * Copyright 2018 Alexander Nozik. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package inr.numass.control.gun + +import hep.dataforge.fx.asDoubleProperty +import tornadofx.* + +class EGunView(gun: EGun) : View() { + override val root = borderpane { + center { + vbox { + gun.sources.forEach { device -> + hbox { + label(device.name) + slider(range = 0.0..5.0, value = 0){ + valueProperty().bindBidirectional(device.currentState.asDoubleProperty()) + } + } + } + } + } + } +} \ No newline at end of file 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 5e06e38a..ce3bb807 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 @@ -18,7 +18,6 @@ import inr.numass.control.getDisplay import javafx.scene.Parent import tornadofx.* import java.util.* -import java.util.stream.Stream import kotlin.collections.ArrayList @StateDef(value = ValueDef(key = "address", type = arrayOf(ValueType.NUMBER), info = "Current active magnet")) @@ -78,8 +77,8 @@ class LambdaHub(context: Context, meta: Meta) : DeviceHub, AbstractDevice(contex override fun optDevice(name: Name): Optional = magnets.stream().filter { it.name == name.unescaped }.map { it as Device }.findFirst() - override val deviceNames: Stream - get() = magnets.stream().map { Name.ofSingle(it.name) } + override val deviceNames: List + get() = magnets.map { Name.ofSingle(it.name) } } class LambdaHubDisplay : DeviceDisplayFX() { diff --git a/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/LambdaMagnet.kt b/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/LambdaMagnet.kt index 0f3cd091..ca52f053 100644 --- a/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/LambdaMagnet.kt +++ b/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/LambdaMagnet.kt @@ -17,6 +17,7 @@ package inr.numass.control.magnet import hep.dataforge.context.Context import hep.dataforge.control.devices.AbstractDevice +import hep.dataforge.control.devices.notifyError import hep.dataforge.control.ports.Port import hep.dataforge.control.ports.PortFactory import hep.dataforge.description.ValueDef 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 c3600428..aace1156 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 @@ -17,7 +17,6 @@ class MagnetApp: NumassControlApplication() { override fun build(context: Context, meta: Meta): Device { return LambdaHub(context, meta) } - } override fun setupStage(stage: Stage, device: LambdaHub) { 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 b29ecef6..2918729a 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 @@ -36,7 +36,6 @@ import kotlinx.coroutines.time.delay import java.time.Duration import java.time.Instant import java.util.* -import java.util.stream.Stream /** * @author [Alexander Nozik](mailto:altavir@gmail.com) @@ -65,8 +64,8 @@ class VacCollectorDevice(context: Context, meta: Meta, val sensors: Collection = Optional.ofNullable(sensors.find { it.name == name.unescaped }) - override val deviceNames: Stream - get() = sensors.stream().map { Name.ofSingle(it.name) } + override val deviceNames: List + get() = sensors.map { Name.ofSingle(it.name) } override fun init() {