From eb3277f62a779725581e657c5979b752be694a10 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 31 May 2017 22:30:04 +0300 Subject: [PATCH] Update Value and State annotations --- .../inr/numass/control/BoardController.kt | 2 +- .../kotlin/inr/numass/control/ServerApp.kt | 2 +- .../numass/control/cryotemp/PKT8Device.java | 3 ++- .../inr/numass/control/msp/MspDevice.java | 24 +++++++++++++------ .../inr/numass/control/NumassControlUtils.kt | 3 ++- .../numass/control/readvac/MKSVacDevice.java | 6 +++-- .../control/readvac/MeradatVacDevice.java | 4 +++- .../control/readvac/VacCollectorDevice.java | 6 ++++- 8 files changed, 35 insertions(+), 15 deletions(-) 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 117d5d82..79c72607 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 @@ -38,7 +38,7 @@ class BoardController() : Controller(), AutoCloseable { fun load(app: Application) { runAsync { - NumassControlUtils.getConfig(app).ifPresent { + getConfig(app).ifPresent { val libDir = File(app.parameters.named.getOrDefault("libPath", "../lib")); val contextBuilder = Context .builder("NUMASS-SERVER"); 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 7e07eb56..2d4f0555 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 @@ -13,7 +13,7 @@ class ServerApp : App(BoardView::class) { override fun start(stage: Stage) { controller.load(this) super.start(stage) - NumassControlUtils.setDFStageIcon(stage) + setDFStageIcon(stage) } override fun stop() { diff --git a/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8Device.java b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8Device.java index 6be434c2..39f0489d 100644 --- a/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8Device.java +++ b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8Device.java @@ -47,6 +47,7 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.stream.Collectors; + /** * A device controller for Dubna PKT 8 cryogenic thermometry device * @@ -55,7 +56,7 @@ import java.util.stream.Collectors; @RoleDef(name = Roles.STORAGE_ROLE) @RoleDef(name = Roles.VIEW_ROLE) @ValueDef(name = "port", def = "virtual", info = "The name of the port for this PKT8") -@StateDef(name = "storing") +@StateDef(@ValueDef(name = "storing")) public class PKT8Device extends PortSensor { public static final String PKT8_DEVICE_TYPE = "numass:pkt8"; 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 ba7b5e67..10dda0cc 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 @@ -28,6 +28,7 @@ import hep.dataforge.control.devices.StateDef; import hep.dataforge.control.measurements.AbstractMeasurement; import hep.dataforge.control.ports.PortHandler; import hep.dataforge.control.ports.TcpPortHandler; +import hep.dataforge.description.ValueDef; import hep.dataforge.events.EventBuilder; import hep.dataforge.exceptions.ControlException; import hep.dataforge.exceptions.MeasurementException; @@ -54,10 +55,19 @@ import java.util.function.Consumer; */ @RoleDef(name = Roles.STORAGE_ROLE, objectType = StorageConnection.class) @RoleDef(name = Roles.VIEW_ROLE) -@StateDef(name = PortSensor.CONNECTED_STATE, writable = true, info = "Connection with the device itself") -@StateDef(name = "storing", writable = true, info = "Define if this device is currently writes to storage") -@StateDef(name = "filamentOn", writable = true, info = "Mass-spectrometer filament on") -@StateDef(name = "filamentStatus", info = "Filament status") +@StateDef( + value = @ValueDef(name = PortSensor.CONNECTED_STATE, info = "Connection with the device itself"), + writable = true +) +@StateDef( + value = @ValueDef(name = "storing", info = "Define if this device is currently writes to storage"), + writable = true +) +@StateDef( + value = @ValueDef(name = "filamentOn", info = "Mass-spectrometer filament on"), + writable = true +) +@StateDef(@ValueDef(name = "filamentStatus", info = "Filament status")) public class MspDevice extends Sensor implements PortHandler.PortController { public static final String MSP_DEVICE_TYPE = "msp"; @@ -104,11 +114,11 @@ public class MspDevice extends Sensor implements PortHandler.PortCont // } @Override - protected PeakJumpMeasurement createMeasurement() throws MeasurementException{ - Meta measurementMeta =meta().getMeta("peakJump"); + protected PeakJumpMeasurement createMeasurement() throws MeasurementException { + Meta measurementMeta = meta().getMeta("peakJump"); String s = measurementMeta.getString("type", "peakJump"); if (s.equals("peakJump")) { - PeakJumpMeasurement measurement = new PeakJumpMeasurement(measurementMeta); + PeakJumpMeasurement measurement = new PeakJumpMeasurement(measurementMeta); this.measurementDelegate = measurement; return measurement; } else { diff --git a/numass-control/src/main/kotlin/inr/numass/control/NumassControlUtils.kt b/numass-control/src/main/kotlin/inr/numass/control/NumassControlUtils.kt index 06b35874..171fb3f7 100644 --- a/numass-control/src/main/kotlin/inr/numass/control/NumassControlUtils.kt +++ b/numass-control/src/main/kotlin/inr/numass/control/NumassControlUtils.kt @@ -5,6 +5,7 @@ import hep.dataforge.context.Global import hep.dataforge.control.connections.Roles import hep.dataforge.control.connections.StorageConnection import hep.dataforge.control.devices.Device +import hep.dataforge.description.ValueDef import hep.dataforge.exceptions.StorageException import hep.dataforge.io.MetaFileReader import hep.dataforge.io.XMLMetaReader @@ -26,6 +27,7 @@ import java.util.function.Predicate * Created by darksnake on 08-May-17. */ val DEFAULT_CONFIG_LOCATION = "./numass-control.xml" +val STORING_STATE = "storing" val dfIcon: Image = Image(Global::class.java.getResourceAsStream("/img/df.png")) /** @@ -114,4 +116,3 @@ fun setDFStageIcon(stage: Stage) { stage.icons.add(dfIcon) } - diff --git a/numass-control/vac/src/main/java/inr/numass/control/readvac/MKSVacDevice.java b/numass-control/vac/src/main/java/inr/numass/control/readvac/MKSVacDevice.java index db0eb5f3..82016141 100644 --- a/numass-control/vac/src/main/java/inr/numass/control/readvac/MKSVacDevice.java +++ b/numass-control/vac/src/main/java/inr/numass/control/readvac/MKSVacDevice.java @@ -22,13 +22,15 @@ import javafx.beans.property.adapter.JavaBeanBooleanPropertyBuilder; import java.util.regex.Matcher; import java.util.regex.Pattern; +import static hep.dataforge.values.ValueType.BOOLEAN; + /** * @author Alexander Nozik */ @ValueDef(name = "address", def = "253") @ValueDef(name = "channel", def = "5") -@ValueDef(name = "powerButton", type = "BOOLEAN", def = "true") -@StateDef(name = "power", writable = true, info = "Device powered up") +@ValueDef(name = "powerButton", type = {BOOLEAN}, def = "true") +@StateDef(value = @ValueDef(name = "power", info = "Device powered up"), writable = true) public class MKSVacDevice extends PortSensor { public MKSVacDevice() { diff --git a/numass-control/vac/src/main/java/inr/numass/control/readvac/MeradatVacDevice.java b/numass-control/vac/src/main/java/inr/numass/control/readvac/MeradatVacDevice.java index e0760046..bf08c85c 100644 --- a/numass-control/vac/src/main/java/inr/numass/control/readvac/MeradatVacDevice.java +++ b/numass-control/vac/src/main/java/inr/numass/control/readvac/MeradatVacDevice.java @@ -21,10 +21,12 @@ import java.math.RoundingMode; import java.util.regex.Matcher; import java.util.regex.Pattern; +import static hep.dataforge.values.ValueType.NUMBER; + /** * @author Alexander Nozik */ -@ValueDef(name = "address", type = "NUMBER", def = "1", info = "A modbus address") +@ValueDef(name = "address", type = {NUMBER}, def = "1", info = "A modbus address") public class MeradatVacDevice extends PortSensor { private static final String REQUEST = "0300000002"; diff --git a/numass-control/vac/src/main/java/inr/numass/control/readvac/VacCollectorDevice.java b/numass-control/vac/src/main/java/inr/numass/control/readvac/VacCollectorDevice.java index 3010760d..38eb5f8a 100644 --- a/numass-control/vac/src/main/java/inr/numass/control/readvac/VacCollectorDevice.java +++ b/numass-control/vac/src/main/java/inr/numass/control/readvac/VacCollectorDevice.java @@ -16,6 +16,7 @@ import hep.dataforge.control.devices.Sensor; import hep.dataforge.control.devices.StateDef; import hep.dataforge.control.measurements.AbstractMeasurement; import hep.dataforge.control.measurements.Measurement; +import hep.dataforge.description.ValueDef; import hep.dataforge.exceptions.ControlException; import hep.dataforge.exceptions.MeasurementException; import hep.dataforge.meta.Meta; @@ -45,7 +46,10 @@ import static hep.dataforge.control.devices.PortSensor.CONNECTED_STATE; * @author Alexander Nozik */ @RoleDef(name = Roles.STORAGE_ROLE, objectType = StorageConnection.class, info = "Storage for acquired points") -@StateDef(name = "storing", writable = true, info = "Define if this device is currently writes to storage") +@StateDef( + value = @ValueDef(name = "storing", info = "Define if this device is currently writes to storage"), + writable = true +) public class VacCollectorDevice extends Sensor { private Map> sensorMap = new LinkedHashMap<>();