From c7e460d43d5196ef50fd2754249e873cbc7e1b0b Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 26 May 2017 22:33:56 +0300 Subject: [PATCH] Numass control room global update --- numass-control/control-room/build.gradle | 16 +++- .../inr/numass/control/BoardController.kt | 85 +++++++++++++++--- .../kotlin/inr/numass/control/BoardView.kt | 79 +++++++++++++++-- .../inr/numass/control/ControlFXExtensions.kt | 82 ++++++++++++++++++ .../inr/numass/control/DeviceInfoView.kt | 47 ---------- .../kotlin/inr/numass/control/Indicator.kt | 74 ---------------- .../kotlin/inr/numass/control/ServerApp.kt | 26 ++++-- .../kotlin/inr/numass/control/ServerView.kt | 86 ------------------- .../src/main/resources/config/server.xml | 15 ++++ .../{ => control}/cryotemp/PKT8App.java | 4 +- .../{ => control}/cryotemp/PKT8Channel.java | 2 +- .../{ => control}/cryotemp/PKT8Device.java | 2 +- .../control/cryotemp/PKT8DeviceFactory.java | 27 ++++++ .../cryotemp/PKT8PlotFragment.java | 2 +- .../{ => control}/cryotemp/PKT8PlotView.java | 2 +- .../{ => control}/cryotemp/PKT8Result.java | 2 +- .../{ => control}/cryotemp/PKT8View.java | 4 +- .../cryotemp/PKT8VirtualPort.java | 2 +- .../numass/cryotemp/PKT8DeviceFactory.java | 21 ----- .../inr.numass.control.DeviceViewFactory | 1 + .../main/resources/fxml/PKT8Indicator.fxml | 2 +- .../src/main/resources/fxml/PKT8Plot.fxml | 2 +- .../inr/numass/control/msp/MspDevice.java | 2 +- .../numass/control/msp/MspDeviceFactory.java | 12 ++- .../inr/numass/control/msp/fx/MspApp.java | 2 +- .../{MspViewController.java => MspView.java} | 6 +- .../inr.numass.control.DeviceViewFactory | 1 + .../msp/src/main/resources/fxml/MspView.fxml | 2 +- .../numass/control/DeviceViewConnection.java | 2 +- .../inr/numass/control/DeviceViewFactory.java | 12 +++ .../control/NumassControlApplication.java | 6 +- .../numass/control/NumassControlUtils.java | 5 +- .../{ => control}/readvac/CM32Device.java | 2 +- .../readvac/MKSBaratronDevice.java | 2 +- .../{ => control}/readvac/MKSVacDevice.java | 2 +- .../readvac/MeradatVacDevice.java | 2 +- .../readvac/VacCollectorDevice.java | 2 +- .../readvac/VacDeviceFactory.java | 14 ++- .../{ => control}/readvac/fx/ConsoleVac.java | 2 +- .../readvac/fx/PoweredVacuumeterView.java | 2 +- .../{ => control}/readvac/fx/ReadVac.java | 6 +- .../{ => control}/readvac/fx/TestVac.java | 4 +- .../readvac/fx/VacCollectorView.java | 4 +- .../readvac/fx/VacuumeterView.java | 2 +- .../inr.numass.control.DeviceViewFactory | 1 + .../src/main/resources/fxml/VacCollector.fxml | 2 +- .../readvac/MeradatVacTest.groovy | 2 +- .../{ => control}/readvac/TestMain.java | 32 +++---- .../{ => control}/readvac/TestRemote.java | 32 +++---- .../{ => control}/readvac/TimeShiftTest.java | 2 +- 50 files changed, 411 insertions(+), 337 deletions(-) create mode 100644 numass-control/control-room/src/main/kotlin/inr/numass/control/ControlFXExtensions.kt delete mode 100644 numass-control/control-room/src/main/kotlin/inr/numass/control/DeviceInfoView.kt delete mode 100644 numass-control/control-room/src/main/kotlin/inr/numass/control/Indicator.kt delete mode 100644 numass-control/control-room/src/main/kotlin/inr/numass/control/ServerView.kt rename numass-control/cryotemp/src/main/java/inr/numass/{ => control}/cryotemp/PKT8App.java (91%) rename numass-control/cryotemp/src/main/java/inr/numass/{ => control}/cryotemp/PKT8Channel.java (95%) rename numass-control/cryotemp/src/main/java/inr/numass/{ => control}/cryotemp/PKT8Device.java (96%) create mode 100644 numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8DeviceFactory.java rename numass-control/cryotemp/src/main/java/inr/numass/{ => control}/cryotemp/PKT8PlotFragment.java (93%) rename numass-control/cryotemp/src/main/java/inr/numass/{ => control}/cryotemp/PKT8PlotView.java (96%) rename numass-control/cryotemp/src/main/java/inr/numass/{ => control}/cryotemp/PKT8Result.java (93%) rename numass-control/cryotemp/src/main/java/inr/numass/{ => control}/cryotemp/PKT8View.java (95%) rename numass-control/cryotemp/src/main/java/inr/numass/{ => control}/cryotemp/PKT8VirtualPort.java (95%) delete mode 100644 numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8DeviceFactory.java create mode 100644 numass-control/cryotemp/src/main/resources/META-INF/services/inr.numass.control.DeviceViewFactory rename numass-control/msp/src/main/java/inr/numass/control/msp/fx/{MspViewController.java => MspView.java} (94%) create mode 100644 numass-control/msp/src/main/resources/META-INF/services/inr.numass.control.DeviceViewFactory create mode 100644 numass-control/src/main/java/inr/numass/control/DeviceViewFactory.java rename numass-control/vac/src/main/java/inr/numass/{ => control}/readvac/CM32Device.java (95%) rename numass-control/vac/src/main/java/inr/numass/{ => control}/readvac/MKSBaratronDevice.java (95%) rename numass-control/vac/src/main/java/inr/numass/{ => control}/readvac/MKSVacDevice.java (96%) rename numass-control/vac/src/main/java/inr/numass/{ => control}/readvac/MeradatVacDevice.java (96%) rename numass-control/vac/src/main/java/inr/numass/{ => control}/readvac/VacCollectorDevice.java (96%) rename numass-control/vac/src/main/java/inr/numass/{ => control}/readvac/VacDeviceFactory.java (74%) rename numass-control/vac/src/main/java/inr/numass/{ => control}/readvac/fx/ConsoleVac.java (95%) rename numass-control/vac/src/main/java/inr/numass/{ => control}/readvac/fx/PoweredVacuumeterView.java (93%) rename numass-control/vac/src/main/java/inr/numass/{ => control}/readvac/fx/ReadVac.java (85%) rename numass-control/vac/src/main/java/inr/numass/{ => control}/readvac/fx/TestVac.java (94%) rename numass-control/vac/src/main/java/inr/numass/{ => control}/readvac/fx/VacCollectorView.java (96%) rename numass-control/vac/src/main/java/inr/numass/{ => control}/readvac/fx/VacuumeterView.java (96%) create mode 100644 numass-control/vac/src/main/resources/META-INF/services/inr.numass.control.DeviceViewFactory rename numass-control/vac/src/test/java/inr/numass/{ => control}/readvac/MeradatVacTest.groovy (86%) rename numass-control/vac/src/test/java/inr/numass/{ => control}/readvac/TestMain.java (97%) rename numass-control/vac/src/test/java/inr/numass/{ => control}/readvac/TestRemote.java (95%) rename numass-control/vac/src/test/java/inr/numass/{ => control}/readvac/TimeShiftTest.java (97%) diff --git a/numass-control/control-room/build.gradle b/numass-control/control-room/build.gradle index d699b932..327b89a5 100644 --- a/numass-control/control-room/build.gradle +++ b/numass-control/control-room/build.gradle @@ -1,5 +1,5 @@ plugins{ - id "org.jetbrains.kotlin.jvm" version '1.1.2' + id "org.jetbrains.kotlin.jvm" version '1.1.2-2' id "application" id 'com.github.johnrengelman.shadow' version '2.0.0' } @@ -10,7 +10,7 @@ if (!hasProperty('mainClass')) { mainClassName = mainClass -version = "0.1.0" +version = "0.2.0" description = "The control room application for numass slow control" @@ -20,11 +20,12 @@ dependencies { compile project(':numass-core') compile project(':numass-control') compile project(':numass-server') + compile project(':numass-control:cryotemp') compile 'org.controlsfx:controlsfx:8.40.12' compile "no.tornado:tornadofx:1.7.4" - compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.2" + compile "org.jetbrains.kotlin:kotlin-stdlib-jre8" } shadowJar{ @@ -32,3 +33,12 @@ shadowJar{ } +task debug(dependsOn: classes, type: JavaExec) { + main mainClass + args "--config.resource=/config/server.xml" + classpath = sourceSets.main.runtimeClasspath + description "Start application in debug mode" + group "debug" +} + + diff --git a/numass-control/control-room/src/main/kotlin/inr/numass/control/BoardController.kt b/numass-control/control-room/src/main/kotlin/inr/numass/control/BoardController.kt index 4f3143be..5b3f9706 100644 --- a/numass-control/control-room/src/main/kotlin/inr/numass/control/BoardController.kt +++ b/numass-control/control-room/src/main/kotlin/inr/numass/control/BoardController.kt @@ -1,33 +1,90 @@ package inr.numass.control import hep.dataforge.context.Context -import hep.dataforge.context.Global -import hep.dataforge.control.devices.Device +import hep.dataforge.control.connections.Roles +import hep.dataforge.control.connections.StorageConnection import hep.dataforge.meta.Meta +import hep.dataforge.server.ServerManager import hep.dataforge.storage.api.Storage import hep.dataforge.storage.commons.StorageFactory import inr.numass.client.ClientUtils +import inr.numass.server.NumassStorageServerObject +import javafx.beans.property.SimpleObjectProperty import javafx.collections.FXCollections import javafx.collections.ObservableList -import javafx.scene.Node import tornadofx.* +import java.util.* /** * Created by darksnake on 12-May-17. */ -class BoardController(val context: Context = Global.instance(), val meta: Meta) : Controller() { - val devices: ObservableList> = FXCollections.observableArrayList>(); +class BoardController() : Controller() { + private val serviceLoader = ServiceLoader.load(DeviceViewFactory::class.java); - val storage: Storage? by lazy { - if (meta.hasMeta("storage")) { - val numassRun = ClientUtils.getRunName(meta) - var storage = StorageFactory.buildStorage(context, meta.getMeta("storage")); - if(! numassRun.isEmpty()){ - storage = storage.buildShelf(numassRun, Meta.empty()); + val devices: ObservableList> = FXCollections.observableArrayList>(); + + val storageProperty = SimpleObjectProperty() + var storage by storageProperty + private set + + val serverManagerProperty = SimpleObjectProperty() + var serverManager: ServerManager by serverManagerProperty + private set + + fun load(context: Context, meta: Meta) { + devices.clear(); + meta.getMetaList("device").forEach { + try { + devices.add(buildDeviceView(context, it)); + } catch (ex: Exception) { + context.logger.error("Can't build device view", ex); } - return@lazy storage; - } else { - return@lazy null; + } + + if(meta.hasMeta("storage")){ + storage = buildStorage(context, meta); + val storageConnection = StorageConnection(storage); + devices.forEach { + if (it.device.acceptsRole(Roles.STORAGE_ROLE)) { + it.device.connect(storageConnection, Roles.STORAGE_ROLE); + } + } + } + + meta.optMeta("server").ifPresent { serverMeta -> + serverManager = context.pluginManager().getOrLoad(ServerManager::class.java); + serverManager.configure(serverMeta) + + serverManager.bind(NumassStorageServerObject(serverManager, storage, "numass-storage")); } } + + private fun buildDeviceView(context: Context, deviceMeta: Meta): DeviceViewConnection<*> { + context.logger.info("Building device with meta: {}", deviceMeta) + val factory = serviceLoader.find { + it.type == deviceMeta.getString("type") + }; + if (factory != null) { + val device = factory.build(context, deviceMeta); + val view = factory.buildView(device); + device.connect(view, Roles.VIEW_ROLE, Roles.DEVICE_LISTENER_ROLE) + device.init(); + return view; + } else { + throw RuntimeException("Device factory not found"); + } + } + + private fun buildStorage(context: Context, meta: Meta): Storage { + val storageMeta = meta.getMeta("storage"); + context.logger.info("Creating storage for server with meta {}", storageMeta) + var storage = StorageFactory.buildStorage(context, storageMeta); + + val numassRun = ClientUtils.getRunName(meta) + if (!numassRun.isEmpty()) { + context.logger.info("Run information found. Selecting run {}", numassRun) + storage = storage.buildShelf(numassRun, Meta.empty()); + } + return storage; + } } \ No newline at end of file diff --git a/numass-control/control-room/src/main/kotlin/inr/numass/control/BoardView.kt b/numass-control/control-room/src/main/kotlin/inr/numass/control/BoardView.kt index 1b939b0e..ef6860c2 100644 --- a/numass-control/control-room/src/main/kotlin/inr/numass/control/BoardView.kt +++ b/numass-control/control-room/src/main/kotlin/inr/numass/control/BoardView.kt @@ -1,21 +1,88 @@ package inr.numass.control -import javafx.scene.layout.VBox +import hep.dataforge.control.devices.Device +import hep.dataforge.fx.fragments.FXFragment +import hep.dataforge.fx.fragments.FragmentWindow +import inr.numass.control.NumassControlUtils.getDFIcon +import javafx.geometry.Orientation +import javafx.geometry.Pos +import javafx.scene.control.Hyperlink +import javafx.scene.image.ImageView +import javafx.scene.layout.Priority import tornadofx.* /** * Created by darksnake on 11-May-17. */ -class BoardView : View("Numass control board") { - private var deviceList: VBox by singleAssign(); +class BoardView : View("Numass control board", ImageView(getDFIcon())) { private val controller: BoardController by inject(); override val root = borderpane { + prefHeight = 200.0 + prefWidth = 200.0 center { - deviceList = vbox { - bindChildren(controller.devices) { DeviceInfoView(it).root } + vbox { + hbox { + alignment = Pos.CENTER + vgrow = Priority.ALWAYS; + prefHeight = 40.0 + text("Server") // TODO add fancy style here + separator(Orientation.VERTICAL) + var serverLabel: Hyperlink by singleAssign(); + togglebutton("Start") { + isSelected = false + disableProperty().bind(controller.serverManagerProperty.isNull) + action { + if (isSelected) { + text = "Stop" + controller.serverManager.startServer() + serverLabel.text = controller.serverManager.link; + } else { + text = "Start" + controller.serverManager.stopServer() + serverLabel.text = "" + } + } + } + indicator { + bind(controller.serverManager.isStarted) + } + serverLabel = hyperlink { + action { + hostServices.showDocument(controller.serverManager.link); + } + } + } + separator(Orientation.HORIZONTAL) + hbox { + alignment = Pos.CENTER + vgrow = Priority.ALWAYS; + prefHeight = 40.0 + text("Storage") + separator(Orientation.VERTICAL) + label(stringBinding(controller.storage) { + controller.storage.fullPath + }) + } + separator(Orientation.HORIZONTAL) + vbox { + vgrow = Priority.ALWAYS; + prefHeight = 40.0 + bindChildren(controller.devices) { connection -> + hbox { + alignment = Pos.CENTER + vgrow = Priority.ALWAYS; + text("Device: " + connection.device.name) + separator(Orientation.VERTICAL) + indicator { + bind(connection, Device.INITIALIZED_STATE) + } + val viewButton = togglebutton("View") + FragmentWindow(FXFragment.buildFromNode(connection.device.name) { connection.fxNode }).bindTo(viewButton) + } + } + } } } } - } diff --git a/numass-control/control-room/src/main/kotlin/inr/numass/control/ControlFXExtensions.kt b/numass-control/control-room/src/main/kotlin/inr/numass/control/ControlFXExtensions.kt new file mode 100644 index 00000000..5d71de4c --- /dev/null +++ b/numass-control/control-room/src/main/kotlin/inr/numass/control/ControlFXExtensions.kt @@ -0,0 +1,82 @@ +package inr.numass.control + +import hep.dataforge.values.Value +import javafx.beans.value.ObservableValue +import javafx.event.EventTarget +import javafx.scene.paint.Color +import javafx.scene.paint.Paint +import javafx.scene.shape.Circle +import javafx.scene.shape.StrokeType +import tornadofx.* + + +/** + * A pin like indicator fx node + */ +class Indicator(radius: Double = 10.0) : Circle(radius, Color.GRAY) { + private var binding: ObservableValue<*>? = null; + + init { + stroke = Color.BLACK; + strokeType = StrokeType.INSIDE; + tooltip { } + } + + /** + * bind this indicator color to given observable + */ + fun bind(observable: ObservableValue, transform: (T) -> Paint) { + if (binding != null) { + throw RuntimeException("Indicator already bound"); + } else { + binding = observable; + } + observable.addListener { _, _, value -> + fill = transform(value); + } + } + + /** + * bind indicator to the boolean value using default colours + */ + fun bind(booleanValue: ObservableValue) { + bind(booleanValue) { + if (it) { + Color.GREEN; + } else { + Color.RED; + } + } + } + + fun unbind() { + this.binding = null; + neutralize(); + } + + /** + * return indicator to the neutral state but do not unbind + */ + fun neutralize() { + fill = Color.GRAY; + } +} + +fun EventTarget.indicator(radius: Double = 10.0, op: (Indicator.() -> Unit)? = null) = opcr(this, Indicator(radius), op) + +fun Indicator.bind(connection: DeviceViewConnection<*>, state: String, transform: ((Value) -> Paint)? = null) { + tooltip(state) + if (transform != null) { + bind(connection.getStateBinding(state), transform); + } else { + bind(connection.getStateBinding(state)) { + if (it.isNull) { + Color.GRAY + } else if (it.booleanValue()) { + Color.GREEN; + } else { + Color.RED; + } + } + } +} \ No newline at end of file diff --git a/numass-control/control-room/src/main/kotlin/inr/numass/control/DeviceInfoView.kt b/numass-control/control-room/src/main/kotlin/inr/numass/control/DeviceInfoView.kt deleted file mode 100644 index ea3abaf5..00000000 --- a/numass-control/control-room/src/main/kotlin/inr/numass/control/DeviceInfoView.kt +++ /dev/null @@ -1,47 +0,0 @@ -package inr.numass.control - -import hep.dataforge.control.devices.Device -import hep.dataforge.fx.FXObject -import hep.dataforge.fx.fragments.FXFragment -import hep.dataforge.fx.fragments.FragmentWindow -import javafx.beans.property.SimpleObjectProperty -import javafx.scene.Node -import javafx.scene.control.ToggleButton -import tornadofx.* - -/** - * A simple device indicator board - * Created by darksnake on 11-May-17. - */ -class DeviceInfoView(val device: Device, node: Node? = null) : Fragment(device.name) { - - constructor(pair: Pair) : this(pair.first, pair.second); - - val deviceNode = SimpleObjectProperty(); - - var viewButton: ToggleButton by singleAssign(); - - override val root = hbox { - label(device.name) - add(Indicator.build(device, Device.INITIALIZED_STATE).fxNode) - viewButton = togglebutton("View") { - disableProperty().bind(deviceNode.isNull); - } - } - - init { - FragmentWindow(FXFragment.buildFromNode(device.name) { deviceNode.get() }) - - if (node != null) { - deviceNode.set(node); - } else if (device is FXObject) { - deviceNode.set(device.fxNode) - } - } - - fun setDeviceView(node: Node) { - deviceNode.set(node); - } -} - - diff --git a/numass-control/control-room/src/main/kotlin/inr/numass/control/Indicator.kt b/numass-control/control-room/src/main/kotlin/inr/numass/control/Indicator.kt deleted file mode 100644 index 9b68c75b..00000000 --- a/numass-control/control-room/src/main/kotlin/inr/numass/control/Indicator.kt +++ /dev/null @@ -1,74 +0,0 @@ -package inr.numass.control - -import hep.dataforge.control.connections.DeviceConnection -import hep.dataforge.control.devices.Device -import hep.dataforge.control.devices.DeviceListener -import hep.dataforge.fx.FXObject -import hep.dataforge.values.Value -import javafx.beans.binding.ObjectBinding -import javafx.scene.Node -import javafx.scene.paint.Color -import javafx.scene.paint.Paint -import javafx.scene.shape.Circle - -/** - * Lamp-like indicator - * - * TODO move to general kotlin FX utils - * Created by darksnake on 12-May-17. - */ -open class Indicator(val state: String) : FXObject, DeviceConnection(), DeviceListener { - private val color = object : ObjectBinding() { - override fun computeValue(): Paint { - val value = device.getState(state); - return compute(value); - } - } - private val indicator = Circle(); - - init { - indicator.fillProperty().bind(color); - } - - protected open fun compute(value: Value): Paint { - if (value.booleanValue()) { - return Color.GREEN; - } else { - return Color.GRAY; - } - } - - override fun getFXNode(): Node { - return indicator; - } - - override fun notifyDeviceStateChanged(device: Device?, name: String?, value: Value?) { - if (name == state) { - color.invalidate(); - } - } - - companion object { - /** - * Build an indicator - */ - fun build(device: Device, state: String): Indicator { - val indicator = Indicator(state); - device.connect(indicator); - return indicator; - } - - /** - * Build an indicator with the custom color builder - */ - fun build(device: Device, state: String, func: (Value)-> Paint): Indicator { - val indicator = object:Indicator(state){ - override fun compute(value: Value): Paint { - return func(value); - } - }; - device.connect(indicator); - return indicator; - } - } -} diff --git a/numass-control/control-room/src/main/kotlin/inr/numass/control/ServerApp.kt b/numass-control/control-room/src/main/kotlin/inr/numass/control/ServerApp.kt index a920e979..e44c4cbf 100644 --- a/numass-control/control-room/src/main/kotlin/inr/numass/control/ServerApp.kt +++ b/numass-control/control-room/src/main/kotlin/inr/numass/control/ServerApp.kt @@ -1,21 +1,31 @@ package inr.numass.control +import hep.dataforge.context.Context import hep.dataforge.context.Global -import javafx.scene.Scene +import javafx.stage.Stage import tornadofx.* /** * Created by darksnake on 19-May-17. */ -class ServerApp : App(ServerView::class) { +class ServerApp : App(BoardView::class) { + val controller: BoardController by inject(); + var context: Context by singleAssign(); - override fun createPrimaryScene(view: UIComponent): Scene { - if (view is ServerView) { - view.context = Global.getContext("NUMASS-SERVER") - NumassControlUtils.getConfig(this).ifPresent { view.configure(it) } + override fun start(stage: Stage) { + NumassControlUtils.getConfig(this).ifPresent { + context = Global.getContext("NUMASS-SERVER"); + controller.load(context, it); } - return super.createPrimaryScene(view) + super.start(stage) + NumassControlUtils.setDFStageIcon(stage) } - + override fun stop() { + controller.devices.forEach { + it.device.shutdown() + } + super.stop() + context.close(); + } } \ No newline at end of file diff --git a/numass-control/control-room/src/main/kotlin/inr/numass/control/ServerView.kt b/numass-control/control-room/src/main/kotlin/inr/numass/control/ServerView.kt deleted file mode 100644 index e2aa5a0d..00000000 --- a/numass-control/control-room/src/main/kotlin/inr/numass/control/ServerView.kt +++ /dev/null @@ -1,86 +0,0 @@ -package inr.numass.control - -import hep.dataforge.context.Context -import hep.dataforge.exceptions.StorageException -import hep.dataforge.meta.Meta -import hep.dataforge.server.ServerManager -import hep.dataforge.storage.commons.StorageFactory -import inr.numass.client.ClientUtils -import inr.numass.server.NumassStorageServerObject -import javafx.beans.property.SimpleObjectProperty -import javafx.event.EventHandler -import javafx.scene.control.Hyperlink -import tornadofx.* - -/** - * Created by darksnake on 18-May-17. - */ -class ServerView() : View("Numass server controller") { - val contextProperty = SimpleObjectProperty() - var context by contextProperty - - val serverManagerProperty = SimpleObjectProperty() - var serverManager: ServerManager by serverManagerProperty - - - var label: Hyperlink by singleAssign(); - override val root = borderpane { - center { - hbox { - togglebutton("Server") { - isSelected = false - disableProperty().bind(serverManagerProperty.isNull) - action { - if (isSelected) { - serverManager.startServer() - label.text = serverManager.link; - } else { - serverManager.stopServer() - label.text = "" - } - } - } - label = hyperlink { - action { - hostServices.showDocument(serverManager.link); - } - } - } - } - } - - init { - NumassControlUtils.setDFStageIcon(primaryStage) - contextProperty.addListener { _, oldValue, newValue -> - if (oldValue != newValue) { - if (newValue != null) { - serverManager = newValue.pluginManager().getOrLoad(ServerManager::class.java); - } else { - serverManagerProperty.set(null); - } - } - } - primaryStage.onCloseRequest = EventHandler { serverManager.stopServer() } - } - - fun configure(meta: Meta) { - meta.optMeta("storage").ifPresent { node -> - context.logger.info("Creating storage for server with meta {}", node) - //building storage in a separate thread - runAsync { - val numassRun = ClientUtils.getRunName(meta) - var storage = StorageFactory.buildStorage(context, node) - if (!numassRun.isEmpty()) { - try { - storage = storage.buildShelf(numassRun, Meta.empty()) - } catch (e: StorageException) { - context.logger.error("Failed to build shelf", e) - } - - } - serverManager.bind(NumassStorageServerObject(serverManager, storage, "numass-storage")); - } - } - } - -} diff --git a/numass-control/control-room/src/main/resources/config/server.xml b/numass-control/control-room/src/main/resources/config/server.xml index 6cea22b0..c8f3f674 100644 --- a/numass-control/control-room/src/main/resources/config/server.xml +++ b/numass-control/control-room/src/main/resources/config/server.xml @@ -1,4 +1,19 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8App.java b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8App.java similarity index 91% rename from numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8App.java rename to numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8App.java index 11052d98..95229eb3 100644 --- a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8App.java +++ b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8App.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package inr.numass.cryotemp; +package inr.numass.control.cryotemp; import hep.dataforge.control.devices.DeviceFactory; import hep.dataforge.meta.Meta; @@ -33,7 +33,7 @@ public class PKT8App extends NumassControlApplication { } @Override - protected DeviceFactory getDeviceFactory() { + protected DeviceFactory getDeviceFactory() { return new PKT8DeviceFactory(); } diff --git a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8Channel.java b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8Channel.java similarity index 95% rename from numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8Channel.java rename to numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8Channel.java index f2ec0919..77a2773d 100644 --- a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8Channel.java +++ b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8Channel.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package inr.numass.cryotemp; +package inr.numass.control.cryotemp; import hep.dataforge.meta.Meta; import hep.dataforge.meta.MetaBuilder; diff --git a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8Device.java b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8Device.java similarity index 96% rename from numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8Device.java rename to numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8Device.java index 09a66e5d..6be434c2 100644 --- a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8Device.java +++ b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8Device.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package inr.numass.cryotemp; +package inr.numass.control.cryotemp; import hep.dataforge.context.Context; import hep.dataforge.control.RoleDef; diff --git a/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8DeviceFactory.java b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8DeviceFactory.java new file mode 100644 index 00000000..0b1de813 --- /dev/null +++ b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8DeviceFactory.java @@ -0,0 +1,27 @@ +package inr.numass.control.cryotemp; + +import hep.dataforge.context.Context; +import hep.dataforge.control.devices.Device; +import hep.dataforge.meta.Meta; +import inr.numass.control.DeviceViewConnection; +import inr.numass.control.DeviceViewFactory; + +/** + * Created by darksnake on 09-May-17. + */ +public class PKT8DeviceFactory implements DeviceViewFactory { + @Override + public String getType() { + return PKT8Device.PKT8_DEVICE_TYPE; + } + + @Override + public PKT8Device build(Context context, Meta meta) { + return new PKT8Device(context, meta); + } + + @Override + public DeviceViewConnection buildView(Device device) { + return PKT8View.build(); + } +} diff --git a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8PlotFragment.java b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8PlotFragment.java similarity index 93% rename from numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8PlotFragment.java rename to numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8PlotFragment.java index 7d97f10d..48e428f9 100644 --- a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8PlotFragment.java +++ b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8PlotFragment.java @@ -1,4 +1,4 @@ -package inr.numass.cryotemp; +package inr.numass.control.cryotemp; import hep.dataforge.control.connections.Roles; import hep.dataforge.fx.fragments.FXFragment; diff --git a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8PlotView.java b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8PlotView.java similarity index 96% rename from numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8PlotView.java rename to numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8PlotView.java index 9d7b993d..a7a5d863 100644 --- a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8PlotView.java +++ b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8PlotView.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package inr.numass.cryotemp; +package inr.numass.control.cryotemp; import hep.dataforge.control.measurements.Measurement; import hep.dataforge.control.measurements.MeasurementListener; diff --git a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8Result.java b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8Result.java similarity index 93% rename from numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8Result.java rename to numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8Result.java index 09cce9da..fc1309b2 100644 --- a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8Result.java +++ b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8Result.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package inr.numass.cryotemp; +package inr.numass.control.cryotemp; /** * Created by darksnake on 28-Sep-16. diff --git a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8View.java b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8View.java similarity index 95% rename from numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8View.java rename to numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8View.java index 7a32b2a8..68178a6a 100644 --- a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8View.java +++ b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8View.java @@ -1,4 +1,4 @@ -package inr.numass.cryotemp; +package inr.numass.control.cryotemp; import hep.dataforge.control.measurements.Measurement; import hep.dataforge.control.measurements.MeasurementListener; @@ -32,7 +32,7 @@ import java.util.ResourceBundle; */ public class PKT8View extends DeviceViewConnection implements Initializable, MeasurementListener { - public static PKT8View build(){ + public static PKT8View build() { try { FXMLLoader loader = new FXMLLoader(PKT8View.class.getResource("/fxml/PKT8Indicator.fxml")); loader.load(); diff --git a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8VirtualPort.java b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8VirtualPort.java similarity index 95% rename from numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8VirtualPort.java rename to numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8VirtualPort.java index 6c1f87fc..b87045ef 100644 --- a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8VirtualPort.java +++ b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8VirtualPort.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass.cryotemp; +package inr.numass.control.cryotemp; import hep.dataforge.control.ports.VirtualPort; import hep.dataforge.meta.Meta; diff --git a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8DeviceFactory.java b/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8DeviceFactory.java deleted file mode 100644 index 6f3274f2..00000000 --- a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8DeviceFactory.java +++ /dev/null @@ -1,21 +0,0 @@ -package inr.numass.cryotemp; - -import hep.dataforge.context.Context; -import hep.dataforge.control.devices.DeviceFactory; -import hep.dataforge.meta.Meta; - -/** - * Created by darksnake on 09-May-17. - */ -public class PKT8DeviceFactory implements DeviceFactory { - @Override - public String getType() { - return PKT8Device.PKT8_DEVICE_TYPE; - } - - @Override - public PKT8Device build(Context context, Meta meta) { - return new PKT8Device(context, meta); - } - -} diff --git a/numass-control/cryotemp/src/main/resources/META-INF/services/inr.numass.control.DeviceViewFactory b/numass-control/cryotemp/src/main/resources/META-INF/services/inr.numass.control.DeviceViewFactory new file mode 100644 index 00000000..965ef7d7 --- /dev/null +++ b/numass-control/cryotemp/src/main/resources/META-INF/services/inr.numass.control.DeviceViewFactory @@ -0,0 +1 @@ +inr.numass.control.cryotemp.PKT8DeviceFactory \ No newline at end of file diff --git a/numass-control/cryotemp/src/main/resources/fxml/PKT8Indicator.fxml b/numass-control/cryotemp/src/main/resources/fxml/PKT8Indicator.fxml index 04c9eb7c..03f91350 100644 --- a/numass-control/cryotemp/src/main/resources/fxml/PKT8Indicator.fxml +++ b/numass-control/cryotemp/src/main/resources/fxml/PKT8Indicator.fxml @@ -4,7 +4,7 @@ + xmlns="http://javafx.com/javafx/8.0.111" fx:controller="inr.numass.control.cryotemp.PKT8View">
diff --git a/numass-control/cryotemp/src/main/resources/fxml/PKT8Plot.fxml b/numass-control/cryotemp/src/main/resources/fxml/PKT8Plot.fxml index 74e68099..cba1b0d6 100644 --- a/numass-control/cryotemp/src/main/resources/fxml/PKT8Plot.fxml +++ b/numass-control/cryotemp/src/main/resources/fxml/PKT8Plot.fxml @@ -21,7 +21,7 @@ limitations under the License. + xmlns="http://javafx.com/javafx/8.0.111" fx:controller="inr.numass.control.cryotemp.PKT8PlotView">
diff --git a/numass-control/msp/src/main/java/inr/numass/control/msp/MspDevice.java b/numass-control/msp/src/main/java/inr/numass/control/msp/MspDevice.java index e45928f2..d47dc4e6 100644 --- a/numass-control/msp/src/main/java/inr/numass/control/msp/MspDevice.java +++ b/numass-control/msp/src/main/java/inr/numass/control/msp/MspDevice.java @@ -343,7 +343,7 @@ public class MspDevice extends SingleMeasurementDevice> data = new ArrayList<>(); diff --git a/numass-control/msp/src/main/java/inr/numass/control/msp/MspDeviceFactory.java b/numass-control/msp/src/main/java/inr/numass/control/msp/MspDeviceFactory.java index fafc22cd..8145ab53 100644 --- a/numass-control/msp/src/main/java/inr/numass/control/msp/MspDeviceFactory.java +++ b/numass-control/msp/src/main/java/inr/numass/control/msp/MspDeviceFactory.java @@ -1,13 +1,16 @@ package inr.numass.control.msp; import hep.dataforge.context.Context; -import hep.dataforge.control.devices.DeviceFactory; +import hep.dataforge.control.devices.Device; import hep.dataforge.meta.Meta; +import inr.numass.control.DeviceViewConnection; +import inr.numass.control.DeviceViewFactory; +import inr.numass.control.msp.fx.MspView; /** * Created by darksnake on 09-May-17. */ -public class MspDeviceFactory implements DeviceFactory { +public class MspDeviceFactory implements DeviceViewFactory { @Override public String getType() { return MspDevice.MSP_DEVICE_TYPE; @@ -18,4 +21,9 @@ public class MspDeviceFactory implements DeviceFactory { MspDevice device = new MspDevice(context,config); return device; } + + @Override + public DeviceViewConnection buildView(Device device) { + return MspView.build(); + } } diff --git a/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspApp.java b/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspApp.java index 228afbfe..e33cfad3 100644 --- a/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspApp.java +++ b/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspApp.java @@ -32,7 +32,7 @@ public class MspApp extends NumassControlApplication { @Override protected DeviceViewConnection buildView() { - return MspViewController.build(); + return MspView.build(); } @Override diff --git a/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspViewController.java b/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspView.java similarity index 94% rename from numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspViewController.java rename to numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspView.java index 0f29fe66..e67056cc 100644 --- a/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspViewController.java +++ b/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspView.java @@ -58,11 +58,11 @@ import java.util.ResourceBundle; * * @author darksnake */ -public class MspViewController extends DeviceViewConnection implements DeviceListener, Initializable, NamedValueListener { +public class MspView extends DeviceViewConnection implements DeviceListener, Initializable, NamedValueListener { - public static MspViewController build() { + public static MspView build() { try { - FXMLLoader loader = new FXMLLoader(MspViewController.class.getResource("/fxml/MspView.fxml")); + FXMLLoader loader = new FXMLLoader(MspView.class.getResource("/fxml/MspView.fxml")); loader.load(); return loader.getController(); } catch (IOException e) { diff --git a/numass-control/msp/src/main/resources/META-INF/services/inr.numass.control.DeviceViewFactory b/numass-control/msp/src/main/resources/META-INF/services/inr.numass.control.DeviceViewFactory new file mode 100644 index 00000000..e6595c0a --- /dev/null +++ b/numass-control/msp/src/main/resources/META-INF/services/inr.numass.control.DeviceViewFactory @@ -0,0 +1 @@ +inr.numass.control.msp.MspDeviceFactory \ No newline at end of file diff --git a/numass-control/msp/src/main/resources/fxml/MspView.fxml b/numass-control/msp/src/main/resources/fxml/MspView.fxml index 1ac7e6ca..dc55355a 100644 --- a/numass-control/msp/src/main/resources/fxml/MspView.fxml +++ b/numass-control/msp/src/main/resources/fxml/MspView.fxml @@ -23,7 +23,7 @@ limitations under the License. - + diff --git a/numass-control/src/main/java/inr/numass/control/DeviceViewConnection.java b/numass-control/src/main/java/inr/numass/control/DeviceViewConnection.java index 7d85d71a..7d8897dd 100644 --- a/numass-control/src/main/java/inr/numass/control/DeviceViewConnection.java +++ b/numass-control/src/main/java/inr/numass/control/DeviceViewConnection.java @@ -23,7 +23,7 @@ public abstract class DeviceViewConnection extends DeviceConne * @param state * @return */ - protected ObjectBinding getStateBinding(String state) { + public ObjectBinding getStateBinding(String state) { return bindings.computeIfAbsent(state, stateName -> new ObjectBinding() { @Override diff --git a/numass-control/src/main/java/inr/numass/control/DeviceViewFactory.java b/numass-control/src/main/java/inr/numass/control/DeviceViewFactory.java new file mode 100644 index 00000000..9f218f83 --- /dev/null +++ b/numass-control/src/main/java/inr/numass/control/DeviceViewFactory.java @@ -0,0 +1,12 @@ +package inr.numass.control; + +import hep.dataforge.control.devices.Device; +import hep.dataforge.control.devices.DeviceFactory; + +public interface DeviceViewFactory extends DeviceFactory { + /** + * Create but do not connect view connection for the device + * @return + */ + DeviceViewConnection buildView(Device device); +} diff --git a/numass-control/src/main/java/inr/numass/control/NumassControlApplication.java b/numass-control/src/main/java/inr/numass/control/NumassControlApplication.java index b844b140..32901ca3 100644 --- a/numass-control/src/main/java/inr/numass/control/NumassControlApplication.java +++ b/numass-control/src/main/java/inr/numass/control/NumassControlApplication.java @@ -36,8 +36,8 @@ public abstract class NumassControlApplication extends Applica primaryStage.show(); device = setupDevice(controller); - NumassControlUtils.setDFStageIcon(primaryStage); setupStage(primaryStage, device); + NumassControlUtils.setDFStageIcon(primaryStage); } /** @@ -52,7 +52,7 @@ public abstract class NumassControlApplication extends Applica * * @return */ - protected abstract DeviceFactory getDeviceFactory(); + protected abstract DeviceFactory getDeviceFactory(); protected abstract void setupStage(Stage stage, D device); @@ -68,7 +68,7 @@ public abstract class NumassControlApplication extends Applica try { - D d = getDeviceFactory().build(ctx, deviceConfig); + D d = (D) getDeviceFactory().build(ctx, deviceConfig); d.init(); NumassControlUtils.connectStorage(d, config); Platform.runLater(() -> { diff --git a/numass-control/src/main/java/inr/numass/control/NumassControlUtils.java b/numass-control/src/main/java/inr/numass/control/NumassControlUtils.java index ef10c214..0a9ff859 100644 --- a/numass-control/src/main/java/inr/numass/control/NumassControlUtils.java +++ b/numass-control/src/main/java/inr/numass/control/NumassControlUtils.java @@ -106,7 +106,10 @@ public class NumassControlUtils { } public static void setDFStageIcon(Stage stage) { - stage.getIcons().add(new Image(NumassControlUtils.class.getResourceAsStream("/img/df.png"))); + stage.getIcons().add(getDFIcon()); + } + public static Image getDFIcon(){ + return new Image(NumassControlUtils.class.getResourceAsStream("/img/df.png")); } } diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/CM32Device.java b/numass-control/vac/src/main/java/inr/numass/control/readvac/CM32Device.java similarity index 95% rename from numass-control/vac/src/main/java/inr/numass/readvac/CM32Device.java rename to numass-control/vac/src/main/java/inr/numass/control/readvac/CM32Device.java index 6d306617..968cbf68 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/CM32Device.java +++ b/numass-control/vac/src/main/java/inr/numass/control/readvac/CM32Device.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass.readvac; +package inr.numass.control.readvac; import hep.dataforge.context.Context; import hep.dataforge.control.devices.Device; diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/MKSBaratronDevice.java b/numass-control/vac/src/main/java/inr/numass/control/readvac/MKSBaratronDevice.java similarity index 95% rename from numass-control/vac/src/main/java/inr/numass/readvac/MKSBaratronDevice.java rename to numass-control/vac/src/main/java/inr/numass/control/readvac/MKSBaratronDevice.java index 7f05b3f8..0b1edae8 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/MKSBaratronDevice.java +++ b/numass-control/vac/src/main/java/inr/numass/control/readvac/MKSBaratronDevice.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass.readvac; +package inr.numass.control.readvac; import hep.dataforge.context.Context; import hep.dataforge.control.devices.Device; diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/MKSVacDevice.java b/numass-control/vac/src/main/java/inr/numass/control/readvac/MKSVacDevice.java similarity index 96% rename from numass-control/vac/src/main/java/inr/numass/readvac/MKSVacDevice.java rename to numass-control/vac/src/main/java/inr/numass/control/readvac/MKSVacDevice.java index 3c5cef09..db0eb5f3 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/MKSVacDevice.java +++ b/numass-control/vac/src/main/java/inr/numass/control/readvac/MKSVacDevice.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass.readvac; +package inr.numass.control.readvac; import hep.dataforge.context.Context; import hep.dataforge.control.devices.Device; diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/MeradatVacDevice.java b/numass-control/vac/src/main/java/inr/numass/control/readvac/MeradatVacDevice.java similarity index 96% rename from numass-control/vac/src/main/java/inr/numass/readvac/MeradatVacDevice.java rename to numass-control/vac/src/main/java/inr/numass/control/readvac/MeradatVacDevice.java index 82a65123..e0760046 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/MeradatVacDevice.java +++ b/numass-control/vac/src/main/java/inr/numass/control/readvac/MeradatVacDevice.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass.readvac; +package inr.numass.control.readvac; import hep.dataforge.context.Context; import hep.dataforge.control.devices.Device; diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/VacCollectorDevice.java b/numass-control/vac/src/main/java/inr/numass/control/readvac/VacCollectorDevice.java similarity index 96% rename from numass-control/vac/src/main/java/inr/numass/readvac/VacCollectorDevice.java rename to numass-control/vac/src/main/java/inr/numass/control/readvac/VacCollectorDevice.java index d50f2f2b..76597ac0 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/VacCollectorDevice.java +++ b/numass-control/vac/src/main/java/inr/numass/control/readvac/VacCollectorDevice.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass.readvac; +package inr.numass.control.readvac; import hep.dataforge.context.Context; import hep.dataforge.control.RoleDef; diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/VacDeviceFactory.java b/numass-control/vac/src/main/java/inr/numass/control/readvac/VacDeviceFactory.java similarity index 74% rename from numass-control/vac/src/main/java/inr/numass/readvac/VacDeviceFactory.java rename to numass-control/vac/src/main/java/inr/numass/control/readvac/VacDeviceFactory.java index 816eb609..1f131646 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/VacDeviceFactory.java +++ b/numass-control/vac/src/main/java/inr/numass/control/readvac/VacDeviceFactory.java @@ -1,9 +1,12 @@ -package inr.numass.readvac; +package inr.numass.control.readvac; import hep.dataforge.context.Context; -import hep.dataforge.control.devices.DeviceFactory; +import hep.dataforge.control.devices.Device; import hep.dataforge.control.measurements.Sensor; import hep.dataforge.meta.Meta; +import inr.numass.control.DeviceViewConnection; +import inr.numass.control.DeviceViewFactory; +import inr.numass.control.readvac.fx.VacCollectorView; import java.util.List; import java.util.stream.Collectors; @@ -12,7 +15,7 @@ import java.util.stream.Collectors; * A factory for vacuum measurements collector * Created by darksnake on 16-May-17. */ -public class VacDeviceFactory implements DeviceFactory { +public class VacDeviceFactory implements DeviceViewFactory { @Override public String getType() { return "numass:vac"; @@ -42,4 +45,9 @@ public class VacDeviceFactory implements DeviceFactory { collector.setSensors(sensors); return collector; } + + @Override + public DeviceViewConnection buildView(Device device) { + return VacCollectorView.build(); + } } diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/fx/ConsoleVac.java b/numass-control/vac/src/main/java/inr/numass/control/readvac/fx/ConsoleVac.java similarity index 95% rename from numass-control/vac/src/main/java/inr/numass/readvac/fx/ConsoleVac.java rename to numass-control/vac/src/main/java/inr/numass/control/readvac/fx/ConsoleVac.java index c59c9a38..92e69ede 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/fx/ConsoleVac.java +++ b/numass-control/vac/src/main/java/inr/numass/control/readvac/fx/ConsoleVac.java @@ -1,4 +1,4 @@ -package inr.numass.readvac.fx; +package inr.numass.control.readvac.fx; import hep.dataforge.control.measurements.Sensor; import org.apache.commons.cli.CommandLine; diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/fx/PoweredVacuumeterView.java b/numass-control/vac/src/main/java/inr/numass/control/readvac/fx/PoweredVacuumeterView.java similarity index 93% rename from numass-control/vac/src/main/java/inr/numass/readvac/fx/PoweredVacuumeterView.java rename to numass-control/vac/src/main/java/inr/numass/control/readvac/fx/PoweredVacuumeterView.java index 985c17ef..5597df8e 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/fx/PoweredVacuumeterView.java +++ b/numass-control/vac/src/main/java/inr/numass/control/readvac/fx/PoweredVacuumeterView.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass.readvac.fx; +package inr.numass.control.readvac.fx; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/fx/ReadVac.java b/numass-control/vac/src/main/java/inr/numass/control/readvac/fx/ReadVac.java similarity index 85% rename from numass-control/vac/src/main/java/inr/numass/readvac/fx/ReadVac.java rename to numass-control/vac/src/main/java/inr/numass/control/readvac/fx/ReadVac.java index d82970ff..b607d6bf 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/fx/ReadVac.java +++ b/numass-control/vac/src/main/java/inr/numass/control/readvac/fx/ReadVac.java @@ -3,14 +3,14 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass.readvac.fx; +package inr.numass.control.readvac.fx; import hep.dataforge.control.devices.DeviceFactory; import hep.dataforge.meta.Meta; import inr.numass.control.DeviceViewConnection; import inr.numass.control.NumassControlApplication; -import inr.numass.readvac.VacCollectorDevice; -import inr.numass.readvac.VacDeviceFactory; +import inr.numass.control.readvac.VacCollectorDevice; +import inr.numass.control.readvac.VacDeviceFactory; import javafx.stage.Stage; import java.util.Objects; diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/fx/TestVac.java b/numass-control/vac/src/main/java/inr/numass/control/readvac/fx/TestVac.java similarity index 94% rename from numass-control/vac/src/main/java/inr/numass/readvac/fx/TestVac.java rename to numass-control/vac/src/main/java/inr/numass/control/readvac/fx/TestVac.java index 6770b1d3..5434aa8c 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/fx/TestVac.java +++ b/numass-control/vac/src/main/java/inr/numass/control/readvac/fx/TestVac.java @@ -3,12 +3,12 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass.readvac.fx; +package inr.numass.control.readvac.fx; import hep.dataforge.control.connections.Roles; import hep.dataforge.control.measurements.Sensor; import hep.dataforge.control.virtual.Virtual; -import inr.numass.readvac.VacCollectorDevice; +import inr.numass.control.readvac.VacCollectorDevice; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacCollectorView.java b/numass-control/vac/src/main/java/inr/numass/control/readvac/fx/VacCollectorView.java similarity index 96% rename from numass-control/vac/src/main/java/inr/numass/readvac/fx/VacCollectorView.java rename to numass-control/vac/src/main/java/inr/numass/control/readvac/fx/VacCollectorView.java index 38e654f9..0b672907 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacCollectorView.java +++ b/numass-control/vac/src/main/java/inr/numass/control/readvac/fx/VacCollectorView.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass.readvac.fx; +package inr.numass.control.readvac.fx; import hep.dataforge.control.connections.Roles; import hep.dataforge.control.devices.Device; @@ -24,7 +24,7 @@ import hep.dataforge.plots.jfreechart.JFreeChartFrame; import hep.dataforge.tables.DataPoint; import hep.dataforge.values.Value; import inr.numass.control.DeviceViewConnection; -import inr.numass.readvac.VacCollectorDevice; +import inr.numass.control.readvac.VacCollectorDevice; import javafx.application.Platform; import javafx.beans.value.ObservableValue; import javafx.collections.FXCollections; diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacuumeterView.java b/numass-control/vac/src/main/java/inr/numass/control/readvac/fx/VacuumeterView.java similarity index 96% rename from numass-control/vac/src/main/java/inr/numass/readvac/fx/VacuumeterView.java rename to numass-control/vac/src/main/java/inr/numass/control/readvac/fx/VacuumeterView.java index 7e3c9563..e77ed203 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacuumeterView.java +++ b/numass-control/vac/src/main/java/inr/numass/control/readvac/fx/VacuumeterView.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass.readvac.fx; +package inr.numass.control.readvac.fx; import hep.dataforge.control.devices.Device; import hep.dataforge.control.measurements.Measurement; diff --git a/numass-control/vac/src/main/resources/META-INF/services/inr.numass.control.DeviceViewFactory b/numass-control/vac/src/main/resources/META-INF/services/inr.numass.control.DeviceViewFactory new file mode 100644 index 00000000..f36271a1 --- /dev/null +++ b/numass-control/vac/src/main/resources/META-INF/services/inr.numass.control.DeviceViewFactory @@ -0,0 +1 @@ +inr.numass.control.readvac.VacDeviceFactory \ No newline at end of file diff --git a/numass-control/vac/src/main/resources/fxml/VacCollector.fxml b/numass-control/vac/src/main/resources/fxml/VacCollector.fxml index baad4a00..98a7dc42 100644 --- a/numass-control/vac/src/main/resources/fxml/VacCollector.fxml +++ b/numass-control/vac/src/main/resources/fxml/VacCollector.fxml @@ -4,7 +4,7 @@ - + diff --git a/numass-control/vac/src/test/java/inr/numass/readvac/MeradatVacTest.groovy b/numass-control/vac/src/test/java/inr/numass/control/readvac/MeradatVacTest.groovy similarity index 86% rename from numass-control/vac/src/test/java/inr/numass/readvac/MeradatVacTest.groovy rename to numass-control/vac/src/test/java/inr/numass/control/readvac/MeradatVacTest.groovy index 9f255e6f..a627c0cb 100644 --- a/numass-control/vac/src/test/java/inr/numass/readvac/MeradatVacTest.groovy +++ b/numass-control/vac/src/test/java/inr/numass/control/readvac/MeradatVacTest.groovy @@ -1,4 +1,4 @@ -package inr.numass.readvac +package inr.numass.control.readvac import spock.lang.Specification diff --git a/numass-control/vac/src/test/java/inr/numass/readvac/TestMain.java b/numass-control/vac/src/test/java/inr/numass/control/readvac/TestMain.java similarity index 97% rename from numass-control/vac/src/test/java/inr/numass/readvac/TestMain.java rename to numass-control/vac/src/test/java/inr/numass/control/readvac/TestMain.java index a2ac1f32..0f6fc0ad 100644 --- a/numass-control/vac/src/test/java/inr/numass/readvac/TestMain.java +++ b/numass-control/vac/src/test/java/inr/numass/control/readvac/TestMain.java @@ -1,19 +1,19 @@ -/* - * Copyright 2015 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.readvac; +/* + * Copyright 2015 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.readvac; /** * diff --git a/numass-control/vac/src/test/java/inr/numass/readvac/TestRemote.java b/numass-control/vac/src/test/java/inr/numass/control/readvac/TestRemote.java similarity index 95% rename from numass-control/vac/src/test/java/inr/numass/readvac/TestRemote.java rename to numass-control/vac/src/test/java/inr/numass/control/readvac/TestRemote.java index ff9581b7..81c17b6b 100644 --- a/numass-control/vac/src/test/java/inr/numass/readvac/TestRemote.java +++ b/numass-control/vac/src/test/java/inr/numass/control/readvac/TestRemote.java @@ -1,19 +1,19 @@ -/* - * Copyright 2015 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.readvac; +/* + * Copyright 2015 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.readvac; /** * diff --git a/numass-control/vac/src/test/java/inr/numass/readvac/TimeShiftTest.java b/numass-control/vac/src/test/java/inr/numass/control/readvac/TimeShiftTest.java similarity index 97% rename from numass-control/vac/src/test/java/inr/numass/readvac/TimeShiftTest.java rename to numass-control/vac/src/test/java/inr/numass/control/readvac/TimeShiftTest.java index ad2d9a5a..db8e890a 100644 --- a/numass-control/vac/src/test/java/inr/numass/readvac/TimeShiftTest.java +++ b/numass-control/vac/src/test/java/inr/numass/control/readvac/TimeShiftTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package inr.numass.readvac; +package inr.numass.control.readvac; import hep.dataforge.utils.DateTimeUtils;