Update Value and State annotations

This commit is contained in:
Alexander Nozik 2017-05-31 22:30:04 +03:00
parent 900e249d5c
commit eb3277f62a
8 changed files with 35 additions and 15 deletions

View File

@ -38,7 +38,7 @@ class BoardController() : Controller(), AutoCloseable {
fun load(app: Application) { fun load(app: Application) {
runAsync { runAsync {
NumassControlUtils.getConfig(app).ifPresent { getConfig(app).ifPresent {
val libDir = File(app.parameters.named.getOrDefault("libPath", "../lib")); val libDir = File(app.parameters.named.getOrDefault("libPath", "../lib"));
val contextBuilder = Context val contextBuilder = Context
.builder("NUMASS-SERVER"); .builder("NUMASS-SERVER");

View File

@ -13,7 +13,7 @@ class ServerApp : App(BoardView::class) {
override fun start(stage: Stage) { override fun start(stage: Stage) {
controller.load(this) controller.load(this)
super.start(stage) super.start(stage)
NumassControlUtils.setDFStageIcon(stage) setDFStageIcon(stage)
} }
override fun stop() { override fun stop() {

View File

@ -47,6 +47,7 @@ import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* A device controller for Dubna PKT 8 cryogenic thermometry device * 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.STORAGE_ROLE)
@RoleDef(name = Roles.VIEW_ROLE) @RoleDef(name = Roles.VIEW_ROLE)
@ValueDef(name = "port", def = "virtual", info = "The name of the port for this PKT8") @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<PKT8Result> { public class PKT8Device extends PortSensor<PKT8Result> {
public static final String PKT8_DEVICE_TYPE = "numass:pkt8"; public static final String PKT8_DEVICE_TYPE = "numass:pkt8";

View File

@ -28,6 +28,7 @@ import hep.dataforge.control.devices.StateDef;
import hep.dataforge.control.measurements.AbstractMeasurement; import hep.dataforge.control.measurements.AbstractMeasurement;
import hep.dataforge.control.ports.PortHandler; import hep.dataforge.control.ports.PortHandler;
import hep.dataforge.control.ports.TcpPortHandler; import hep.dataforge.control.ports.TcpPortHandler;
import hep.dataforge.description.ValueDef;
import hep.dataforge.events.EventBuilder; import hep.dataforge.events.EventBuilder;
import hep.dataforge.exceptions.ControlException; import hep.dataforge.exceptions.ControlException;
import hep.dataforge.exceptions.MeasurementException; 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.STORAGE_ROLE, objectType = StorageConnection.class)
@RoleDef(name = Roles.VIEW_ROLE) @RoleDef(name = Roles.VIEW_ROLE)
@StateDef(name = PortSensor.CONNECTED_STATE, writable = true, info = "Connection with the device itself") @StateDef(
@StateDef(name = "storing", writable = true, info = "Define if this device is currently writes to storage") value = @ValueDef(name = PortSensor.CONNECTED_STATE, info = "Connection with the device itself"),
@StateDef(name = "filamentOn", writable = true, info = "Mass-spectrometer filament on") writable = true
@StateDef(name = "filamentStatus", info = "Filament status") )
@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<DataPoint> implements PortHandler.PortController { public class MspDevice extends Sensor<DataPoint> implements PortHandler.PortController {
public static final String MSP_DEVICE_TYPE = "msp"; public static final String MSP_DEVICE_TYPE = "msp";
@ -104,11 +114,11 @@ public class MspDevice extends Sensor<DataPoint> implements PortHandler.PortCont
// } // }
@Override @Override
protected PeakJumpMeasurement createMeasurement() throws MeasurementException{ protected PeakJumpMeasurement createMeasurement() throws MeasurementException {
Meta measurementMeta =meta().getMeta("peakJump"); Meta measurementMeta = meta().getMeta("peakJump");
String s = measurementMeta.getString("type", "peakJump"); String s = measurementMeta.getString("type", "peakJump");
if (s.equals("peakJump")) { if (s.equals("peakJump")) {
PeakJumpMeasurement measurement = new PeakJumpMeasurement(measurementMeta); PeakJumpMeasurement measurement = new PeakJumpMeasurement(measurementMeta);
this.measurementDelegate = measurement; this.measurementDelegate = measurement;
return measurement; return measurement;
} else { } else {

View File

@ -5,6 +5,7 @@ import hep.dataforge.context.Global
import hep.dataforge.control.connections.Roles import hep.dataforge.control.connections.Roles
import hep.dataforge.control.connections.StorageConnection import hep.dataforge.control.connections.StorageConnection
import hep.dataforge.control.devices.Device import hep.dataforge.control.devices.Device
import hep.dataforge.description.ValueDef
import hep.dataforge.exceptions.StorageException import hep.dataforge.exceptions.StorageException
import hep.dataforge.io.MetaFileReader import hep.dataforge.io.MetaFileReader
import hep.dataforge.io.XMLMetaReader import hep.dataforge.io.XMLMetaReader
@ -26,6 +27,7 @@ import java.util.function.Predicate
* Created by darksnake on 08-May-17. * Created by darksnake on 08-May-17.
*/ */
val DEFAULT_CONFIG_LOCATION = "./numass-control.xml" val DEFAULT_CONFIG_LOCATION = "./numass-control.xml"
val STORING_STATE = "storing"
val dfIcon: Image = Image(Global::class.java.getResourceAsStream("/img/df.png")) val dfIcon: Image = Image(Global::class.java.getResourceAsStream("/img/df.png"))
/** /**
@ -114,4 +116,3 @@ fun setDFStageIcon(stage: Stage) {
stage.icons.add(dfIcon) stage.icons.add(dfIcon)
} }

View File

@ -22,13 +22,15 @@ import javafx.beans.property.adapter.JavaBeanBooleanPropertyBuilder;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static hep.dataforge.values.ValueType.BOOLEAN;
/** /**
* @author Alexander Nozik * @author Alexander Nozik
*/ */
@ValueDef(name = "address", def = "253") @ValueDef(name = "address", def = "253")
@ValueDef(name = "channel", def = "5") @ValueDef(name = "channel", def = "5")
@ValueDef(name = "powerButton", type = "BOOLEAN", def = "true") @ValueDef(name = "powerButton", type = {BOOLEAN}, def = "true")
@StateDef(name = "power", writable = true, info = "Device powered up") @StateDef(value = @ValueDef(name = "power", info = "Device powered up"), writable = true)
public class MKSVacDevice extends PortSensor<Double> { public class MKSVacDevice extends PortSensor<Double> {
public MKSVacDevice() { public MKSVacDevice() {

View File

@ -21,10 +21,12 @@ import java.math.RoundingMode;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static hep.dataforge.values.ValueType.NUMBER;
/** /**
* @author Alexander Nozik * @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<Double> { public class MeradatVacDevice extends PortSensor<Double> {
private static final String REQUEST = "0300000002"; private static final String REQUEST = "0300000002";

View File

@ -16,6 +16,7 @@ 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.measurements.AbstractMeasurement;
import hep.dataforge.control.measurements.Measurement; import hep.dataforge.control.measurements.Measurement;
import hep.dataforge.description.ValueDef;
import hep.dataforge.exceptions.ControlException; import hep.dataforge.exceptions.ControlException;
import hep.dataforge.exceptions.MeasurementException; import hep.dataforge.exceptions.MeasurementException;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
@ -45,7 +46,10 @@ import static hep.dataforge.control.devices.PortSensor.CONNECTED_STATE;
* @author <a href="mailto:altavir@gmail.com">Alexander Nozik</a> * @author <a href="mailto:altavir@gmail.com">Alexander Nozik</a>
*/ */
@RoleDef(name = Roles.STORAGE_ROLE, objectType = StorageConnection.class, info = "Storage for acquired points") @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<DataPoint> { public class VacCollectorDevice extends Sensor<DataPoint> {
private Map<String, Sensor<Double>> sensorMap = new LinkedHashMap<>(); private Map<String, Sensor<Double>> sensorMap = new LinkedHashMap<>();