Fixed port controller
This commit is contained in:
parent
3965b04297
commit
885b87f87f
@ -26,7 +26,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.control.ports.PortHandler
|
import hep.dataforge.control.ports.Port
|
||||||
import hep.dataforge.description.ValueDef
|
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
|
||||||
@ -155,9 +155,9 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor<PKT8Result>(context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Throws(ControlException::class)
|
@Throws(ControlException::class)
|
||||||
override fun buildHandler(portName: String): PortHandler {
|
override fun buildHandler(portName: String): Port {
|
||||||
//setup connection
|
//setup connection
|
||||||
val handler: PortHandler = if ("virtual" == portName) {
|
val handler: Port = if ("virtual" == portName) {
|
||||||
logger.info("Starting {} using virtual debug port", name)
|
logger.info("Starting {} using virtual debug port", name)
|
||||||
PKT8VirtualPort("PKT8", meta().getMetaOrEmpty("debug"))
|
PKT8VirtualPort("PKT8", meta().getMetaOrEmpty("debug"))
|
||||||
} else {
|
} else {
|
||||||
@ -257,11 +257,11 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor<PKT8Result>(context,
|
|||||||
this.measurement
|
this.measurement
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
if (handler.isLocked) {
|
if (port.isLocked) {
|
||||||
logger.error("Breaking hold on handler because it is locked")
|
logger.error("Breaking hold on handler because it is locked")
|
||||||
handler.breakHold()
|
port.breakHold()
|
||||||
}
|
}
|
||||||
PKT8Measurement(handler)
|
PKT8Measurement(port)
|
||||||
} catch (e: ControlException) {
|
} catch (e: ControlException) {
|
||||||
throw MeasurementException(e)
|
throw MeasurementException(e)
|
||||||
}
|
}
|
||||||
@ -284,7 +284,7 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor<PKT8Result>(context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inner class PKT8Measurement(private val handler: PortHandler) : AbstractMeasurement<PKT8Result>(), PortHandler.PortController {
|
inner class PKT8Measurement(private val handler: Port) : AbstractMeasurement<PKT8Result>(), Port.PortController {
|
||||||
|
|
||||||
override fun getDevice(): Device = this@PKT8Device
|
override fun getDevice(): Device = this@PKT8Device
|
||||||
|
|
||||||
@ -321,12 +321,12 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor<PKT8Result>(context,
|
|||||||
} finally {
|
} finally {
|
||||||
collector?.clear()
|
collector?.clear()
|
||||||
logger.debug("Removing port lock")
|
logger.debug("Removing port lock")
|
||||||
handler.unholdBy(this)
|
handler.releaseBy(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun acceptPortPhrase(message: String) {
|
override fun acceptPhrase(message: String) {
|
||||||
val trimmed = message.trim { it <= ' ' }
|
val trimmed = message.trim { it <= ' ' }
|
||||||
|
|
||||||
if (isStarted) {
|
if (isStarted) {
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.control.magnet;
|
package inr.numass.control.magnet;
|
||||||
|
|
||||||
import hep.dataforge.control.ports.PortHandler;
|
import hep.dataforge.control.ports.GenericPortController;
|
||||||
|
import hep.dataforge.control.ports.Port;
|
||||||
import hep.dataforge.control.ports.PortTimeoutException;
|
import hep.dataforge.control.ports.PortTimeoutException;
|
||||||
import hep.dataforge.control.ports.SyncPortController;
|
|
||||||
import hep.dataforge.exceptions.PortException;
|
import hep.dataforge.exceptions.PortException;
|
||||||
import hep.dataforge.utils.DateTimeUtils;
|
import hep.dataforge.utils.DateTimeUtils;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -34,7 +34,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
/**
|
/**
|
||||||
* @author Polina
|
* @author Polina
|
||||||
*/
|
*/
|
||||||
public class MagnetController implements PortHandler.PortController {
|
public class MagnetController implements Port.PortController {
|
||||||
|
|
||||||
private static final DecimalFormat LAMBDAformat = new DecimalFormat("###.##");
|
private static final DecimalFormat LAMBDAformat = new DecimalFormat("###.##");
|
||||||
public static double CURRENT_PRECISION = 0.05;
|
public static double CURRENT_PRECISION = 0.05;
|
||||||
@ -47,8 +47,8 @@ public class MagnetController implements PortHandler.PortController {
|
|||||||
public static double MAX_SPEED = 5d; // 5 A per minute
|
public static double MAX_SPEED = 5d; // 5 A per minute
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
private final PortHandler port;
|
private final Port port;
|
||||||
private final SyncPortController controller = new SyncPortController(this);
|
private final GenericPortController controller = new GenericPortController(this);
|
||||||
|
|
||||||
private final int address;
|
private final int address;
|
||||||
private final ScheduledExecutorService scheduler = new ScheduledThreadPoolExecutor(1);
|
private final ScheduledExecutorService scheduler = new ScheduledThreadPoolExecutor(1);
|
||||||
@ -71,7 +71,7 @@ public class MagnetController implements PortHandler.PortController {
|
|||||||
* @param address number of TDK - Lambda
|
* @param address number of TDK - Lambda
|
||||||
* @param timeout waiting time for response
|
* @param timeout waiting time for response
|
||||||
*/
|
*/
|
||||||
public MagnetController(String name, PortHandler port, int address, int timeout) {
|
public MagnetController(String name, Port port, int address, int timeout) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.port.setDelimiter("\r");//PENDING меняем состояние внешнего объекта?
|
this.port.setDelimiter("\r");//PENDING меняем состояние внешнего объекта?
|
||||||
@ -79,15 +79,15 @@ public class MagnetController implements PortHandler.PortController {
|
|||||||
this.timeout = Duration.ofMillis(timeout);
|
this.timeout = Duration.ofMillis(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MagnetController(PortHandler port, int address, int timeout) {
|
public MagnetController(Port port, int address, int timeout) {
|
||||||
this(null, port, address, timeout);
|
this(null, port, address, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MagnetController(PortHandler port, int address) {
|
public MagnetController(Port port, int address) {
|
||||||
this(null, port, address);
|
this(null, port, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MagnetController(String name, PortHandler port, int address) {
|
public MagnetController(String name, Port port, int address) {
|
||||||
this(name, port, address, 300);
|
this(name, port, address, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ public class MagnetController implements PortHandler.PortController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void acceptPortPhrase(String message) {
|
public void acceptPhrase(String message) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ public class MagnetController implements PortHandler.PortController {
|
|||||||
}
|
}
|
||||||
return monitor;
|
return monitor;
|
||||||
} finally {
|
} finally {
|
||||||
port.unholdBy(controller);
|
port.releaseBy(controller);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ public class MagnetController implements PortHandler.PortController {
|
|||||||
portError("Error in update task", ex);
|
portError("Error in update task", ex);
|
||||||
stopUpdateTask();
|
stopUpdateTask();
|
||||||
} finally {
|
} finally {
|
||||||
port.unholdBy(controller);
|
port.releaseBy(controller);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -311,7 +311,7 @@ public class MagnetController implements PortHandler.PortController {
|
|||||||
listener.outputModeChanged(getName(), out);
|
listener.outputModeChanged(getName(), out);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
port.unholdBy(controller);
|
port.releaseBy(controller);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,7 +407,7 @@ public class MagnetController implements PortHandler.PortController {
|
|||||||
}
|
}
|
||||||
return talk(message);
|
return talk(message);
|
||||||
} finally {
|
} finally {
|
||||||
port.unholdBy(controller);
|
port.releaseBy(controller);
|
||||||
}
|
}
|
||||||
} catch (PortException ex) {
|
} catch (PortException ex) {
|
||||||
portError("Can not send message to the port", ex);
|
portError("Can not send message to the port", ex);
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.control.magnet;
|
package inr.numass.control.magnet;
|
||||||
|
|
||||||
import hep.dataforge.control.ports.PortHandler;
|
import hep.dataforge.control.ports.Port;
|
||||||
import hep.dataforge.exceptions.PortException;
|
import hep.dataforge.exceptions.PortException;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -32,12 +32,12 @@ public class SafeMagnetController extends MagnetController {
|
|||||||
|
|
||||||
private final Set<SafeMagnetCondition> safeConditions = new HashSet<>();
|
private final Set<SafeMagnetCondition> safeConditions = new HashSet<>();
|
||||||
|
|
||||||
public SafeMagnetController(String name, PortHandler port, int address, int timeout, SafeMagnetCondition... safeConditions) {
|
public SafeMagnetController(String name, Port port, int address, int timeout, SafeMagnetCondition... safeConditions) {
|
||||||
super(name, port, address, timeout);
|
super(name, port, address, timeout);
|
||||||
this.safeConditions.addAll(Arrays.asList(safeConditions));
|
this.safeConditions.addAll(Arrays.asList(safeConditions));
|
||||||
}
|
}
|
||||||
|
|
||||||
public SafeMagnetController(String name, PortHandler port, int address, SafeMagnetCondition... safeConditions) {
|
public SafeMagnetController(String name, Port port, int address, SafeMagnetCondition... safeConditions) {
|
||||||
super(name, port, address);
|
super(name, port, address);
|
||||||
this.safeConditions.addAll(Arrays.asList(safeConditions));
|
this.safeConditions.addAll(Arrays.asList(safeConditions));
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.control.magnet;
|
package inr.numass.control.magnet;
|
||||||
|
|
||||||
import hep.dataforge.control.ports.ComPortHandler;
|
import hep.dataforge.control.ports.ComPort;
|
||||||
import hep.dataforge.control.ports.PortHandler;
|
import hep.dataforge.control.ports.Port;
|
||||||
import jssc.SerialPortException;
|
import jssc.SerialPortException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,7 +36,7 @@ public class SetCurrent {
|
|||||||
int lambdaaddress = Integer.valueOf(args[1]);
|
int lambdaaddress = Integer.valueOf(args[1]);
|
||||||
double current = Double.valueOf(args[2]);
|
double current = Double.valueOf(args[2]);
|
||||||
|
|
||||||
PortHandler handler = new ComPortHandler(comName);
|
Port handler = new ComPort(comName);
|
||||||
|
|
||||||
MagnetController controller = new MagnetController(handler, lambdaaddress);
|
MagnetController controller = new MagnetController(handler, lambdaaddress);
|
||||||
|
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
package inr.numass.control.magnet;
|
package inr.numass.control.magnet;
|
||||||
|
|
||||||
import ch.qos.logback.classic.Level;
|
import ch.qos.logback.classic.Level;
|
||||||
|
import hep.dataforge.control.ports.GenericPortController;
|
||||||
|
import hep.dataforge.control.ports.Port;
|
||||||
import hep.dataforge.control.ports.PortFactory;
|
import hep.dataforge.control.ports.PortFactory;
|
||||||
import hep.dataforge.control.ports.PortHandler;
|
|
||||||
import hep.dataforge.control.ports.SyncPortController;
|
|
||||||
import hep.dataforge.exceptions.PortException;
|
import hep.dataforge.exceptions.PortException;
|
||||||
import hep.dataforge.utils.DateTimeUtils;
|
import hep.dataforge.utils.DateTimeUtils;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -47,7 +47,7 @@ public class Talk {
|
|||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
portName = args[0];
|
portName = args[0];
|
||||||
}
|
}
|
||||||
PortHandler handler;
|
Port handler;
|
||||||
handler = PortFactory.getPort(portName);
|
handler = PortFactory.getPort(portName);
|
||||||
handler.setPhraseCondition((String str) -> str.endsWith("\r"));
|
handler.setPhraseCondition((String str) -> str.endsWith("\r"));
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ public class Talk {
|
|||||||
while (!"exit".equals(nextString)) {
|
while (!"exit".equals(nextString)) {
|
||||||
try {
|
try {
|
||||||
Instant start = DateTimeUtils.now();
|
Instant start = DateTimeUtils.now();
|
||||||
String answer = SyncPortController.sendAndWait(handler, nextString + "\r", Duration.ofSeconds(1));
|
String answer = GenericPortController.sendAndWait(handler, nextString + "\r", Duration.ofSeconds(1));
|
||||||
//String answer = controller.request(nextString);
|
//String answer = controller.request(nextString);
|
||||||
System.out.printf("ANSWER (latency = %s): %s;%n", Duration.between(start, DateTimeUtils.now()), answer.trim());
|
System.out.printf("ANSWER (latency = %s): %s;%n", Duration.between(start, DateTimeUtils.now()), answer.trim());
|
||||||
} catch (PortException ex) {
|
} catch (PortException ex) {
|
||||||
|
@ -15,7 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.control.magnet;
|
package inr.numass.control.magnet;
|
||||||
|
|
||||||
import hep.dataforge.control.ports.PortHandler;
|
import hep.dataforge.control.ports.Port;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,12 +34,12 @@ public class TestController {
|
|||||||
// ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
|
// ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
|
||||||
// rootLogger.setLevel(Level.INFO);
|
// rootLogger.setLevel(Level.INFO);
|
||||||
|
|
||||||
PortHandler handler;
|
Port handler;
|
||||||
MagnetController firstController;
|
MagnetController firstController;
|
||||||
MagnetController secondController;
|
MagnetController secondController;
|
||||||
|
|
||||||
// String comName = "COM12";
|
// String comName = "COM12";
|
||||||
// handler = new ComPortHandler(comName);
|
// handler = new ComPort(comName);
|
||||||
handler = new VirtualLambdaPort("COM12", 1, 2, 3, 4);
|
handler = new VirtualLambdaPort("COM12", 1, 2, 3, 4);
|
||||||
|
|
||||||
firstController = new MagnetController(handler, 1);
|
firstController = new MagnetController(handler, 1);
|
||||||
|
@ -16,10 +16,11 @@
|
|||||||
package inr.numass.control.magnet;
|
package inr.numass.control.magnet;
|
||||||
|
|
||||||
import ch.qos.logback.classic.Level;
|
import ch.qos.logback.classic.Level;
|
||||||
import hep.dataforge.control.ports.PortHandler;
|
import hep.dataforge.control.ports.Port;
|
||||||
import java.util.Locale;
|
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Alexander Nozik
|
* @author Alexander Nozik
|
||||||
@ -37,12 +38,12 @@ public class TestSynch {
|
|||||||
ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
|
ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
|
||||||
rootLogger.setLevel(Level.INFO);
|
rootLogger.setLevel(Level.INFO);
|
||||||
|
|
||||||
PortHandler handler;
|
Port handler;
|
||||||
MagnetController firstController;
|
MagnetController firstController;
|
||||||
MagnetController secondController;
|
MagnetController secondController;
|
||||||
|
|
||||||
// String comName = "COM12";
|
// String comName = "COM12";
|
||||||
// handler = new ComPortHandler(comName);
|
// handler = new ComPort(comName);
|
||||||
handler = new VirtualLambdaPort("COM12", 1, 2, 3, 4);
|
handler = new VirtualLambdaPort("COM12", 1, 2, 3, 4);
|
||||||
|
|
||||||
firstController = new MagnetController(handler, 1);
|
firstController = new MagnetController(handler, 1);
|
||||||
|
@ -18,8 +18,8 @@ package inr.numass.control.magnet.fx;
|
|||||||
import ch.qos.logback.classic.Level;
|
import ch.qos.logback.classic.Level;
|
||||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||||
import ch.qos.logback.core.FileAppender;
|
import ch.qos.logback.core.FileAppender;
|
||||||
|
import hep.dataforge.control.ports.Port;
|
||||||
import hep.dataforge.control.ports.PortFactory;
|
import hep.dataforge.control.ports.PortFactory;
|
||||||
import hep.dataforge.control.ports.PortHandler;
|
|
||||||
import hep.dataforge.exceptions.ControlException;
|
import hep.dataforge.exceptions.ControlException;
|
||||||
import inr.numass.control.magnet.MagnetController;
|
import inr.numass.control.magnet.MagnetController;
|
||||||
import inr.numass.control.magnet.SafeMagnetController;
|
import inr.numass.control.magnet.SafeMagnetController;
|
||||||
@ -41,7 +41,7 @@ import java.util.Locale;
|
|||||||
*/
|
*/
|
||||||
public class MagnetControllerApp extends Application {
|
public class MagnetControllerApp extends Application {
|
||||||
|
|
||||||
PortHandler handler;
|
Port handler;
|
||||||
SafeMagnetController sourceController;
|
SafeMagnetController sourceController;
|
||||||
SafeMagnetController pinchController;
|
SafeMagnetController pinchController;
|
||||||
SafeMagnetController conusController;
|
SafeMagnetController conusController;
|
||||||
|
@ -23,9 +23,9 @@ import hep.dataforge.control.collectors.RegularPointCollector
|
|||||||
import hep.dataforge.control.connections.Roles
|
import hep.dataforge.control.connections.Roles
|
||||||
import hep.dataforge.control.devices.*
|
import hep.dataforge.control.devices.*
|
||||||
import hep.dataforge.control.measurements.AbstractMeasurement
|
import hep.dataforge.control.measurements.AbstractMeasurement
|
||||||
import hep.dataforge.control.ports.PortHandler
|
import hep.dataforge.control.ports.GenericPortController
|
||||||
import hep.dataforge.control.ports.SyncPortController
|
import hep.dataforge.control.ports.Port
|
||||||
import hep.dataforge.control.ports.TcpPortHandler
|
import hep.dataforge.control.ports.TcpPort
|
||||||
import hep.dataforge.description.ValueDef
|
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
|
||||||
@ -61,10 +61,10 @@ import java.util.function.Consumer
|
|||||||
StateDef(ValueDef(name = "filamentStatus", info = "Filament status"))
|
StateDef(ValueDef(name = "filamentStatus", info = "Filament status"))
|
||||||
)
|
)
|
||||||
@DeviceView(MspDisplay::class)
|
@DeviceView(MspDisplay::class)
|
||||||
class MspDevice(context: Context, meta: Meta) : Sensor<Values>(context, meta), PortHandler.PortController {
|
class MspDevice(context: Context, meta: Meta) : Sensor<Values>(context, meta), Port.PortController {
|
||||||
|
|
||||||
private var handler: TcpPortHandler? = null
|
private var handler: TcpPort? = null
|
||||||
private val controller = SyncPortController(this)
|
private val controller = GenericPortController(this)
|
||||||
private var measurementDelegate: Consumer<MspResponse>? = null
|
private var measurementDelegate: Consumer<MspResponse>? = null
|
||||||
|
|
||||||
val isConnected: Boolean
|
val isConnected: Boolean
|
||||||
@ -91,7 +91,7 @@ class MspDevice(context: Context, meta: Meta) : Sensor<Values>(context, meta), P
|
|||||||
val ip = meta().getString("connection.ip", "127.0.0.1")
|
val ip = meta().getString("connection.ip", "127.0.0.1")
|
||||||
val port = meta().getInt("connection.port", 10014)!!
|
val port = meta().getInt("connection.port", 10014)!!
|
||||||
logger.info("Connection to MKS mass-spectrometer on {}:{}...", ip, port)
|
logger.info("Connection to MKS mass-spectrometer on {}:{}...", ip, port)
|
||||||
handler = TcpPortHandler(ip, port)
|
handler = TcpPort(ip, port)
|
||||||
handler!!.setDelimiter("\r\r")
|
handler!!.setDelimiter("\r\r")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ class MspDevice(context: Context, meta: Meta) : Sensor<Values>(context, meta), P
|
|||||||
updateState(PortSensor.CONNECTED_STATE, true)
|
updateState(PortSensor.CONNECTED_STATE, true)
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
getHandler().unholdBy(controller)
|
getHandler().releaseBy(controller)
|
||||||
return !sendAndWait("Release").isOK
|
return !sendAndWait("Release").isOK
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +299,7 @@ class MspDevice(context: Context, meta: Meta) : Sensor<Values>(context, meta), P
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun acceptPortPhrase(message: String) {
|
override fun acceptPhrase(message: String) {
|
||||||
dispatchEvent(
|
dispatchEvent(
|
||||||
EventBuilder
|
EventBuilder
|
||||||
.make("msp")
|
.make("msp")
|
||||||
@ -324,7 +324,7 @@ class MspDevice(context: Context, meta: Meta) : Sensor<Values>(context, meta), P
|
|||||||
notifyError(errorMessage, error)
|
notifyError(errorMessage, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getHandler(): TcpPortHandler {
|
private fun getHandler(): TcpPort {
|
||||||
return handler ?: throw RuntimeException("Device not initialized")
|
return handler ?: throw RuntimeException("Device not initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@ import hep.dataforge.control.devices.Device
|
|||||||
import hep.dataforge.control.devices.PortSensor
|
import hep.dataforge.control.devices.PortSensor
|
||||||
import hep.dataforge.control.measurements.Measurement
|
import hep.dataforge.control.measurements.Measurement
|
||||||
import hep.dataforge.control.measurements.SimpleMeasurement
|
import hep.dataforge.control.measurements.SimpleMeasurement
|
||||||
import hep.dataforge.control.ports.ComPortHandler
|
import hep.dataforge.control.ports.ComPort
|
||||||
|
import hep.dataforge.control.ports.Port
|
||||||
import hep.dataforge.control.ports.PortFactory
|
import hep.dataforge.control.ports.PortFactory
|
||||||
import hep.dataforge.control.ports.PortHandler
|
|
||||||
import hep.dataforge.exceptions.ControlException
|
import hep.dataforge.exceptions.ControlException
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
import inr.numass.control.DeviceView
|
import inr.numass.control.DeviceView
|
||||||
@ -24,16 +24,16 @@ import inr.numass.control.DeviceView
|
|||||||
class CM32Device(context: Context, meta: Meta) : PortSensor<Double>(context, meta) {
|
class CM32Device(context: Context, meta: Meta) : PortSensor<Double>(context, meta) {
|
||||||
|
|
||||||
@Throws(ControlException::class)
|
@Throws(ControlException::class)
|
||||||
override fun buildHandler(portName: String): PortHandler {
|
override fun buildHandler(portName: String): Port {
|
||||||
logger.info("Connecting to port {}", portName)
|
logger.info("Connecting to port {}", portName)
|
||||||
val newHandler: PortHandler
|
val new: Port
|
||||||
if (portName.startsWith("com")) {
|
if (portName.startsWith("com")) {
|
||||||
newHandler = ComPortHandler(portName, 2400, 8, 1, 0)
|
new = ComPort(portName, 2400, 8, 1, 0)
|
||||||
} else {
|
} else {
|
||||||
newHandler = PortFactory.getPort(portName)
|
new = PortFactory.getPort(portName)
|
||||||
}
|
}
|
||||||
newHandler.setDelimiter("T--\r")
|
new.setDelimiter("T--\r")
|
||||||
return newHandler
|
return new
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createMeasurement(): Measurement<Double> {
|
override fun createMeasurement(): Measurement<Double> {
|
||||||
|
@ -10,7 +10,7 @@ import hep.dataforge.control.devices.Device
|
|||||||
import hep.dataforge.control.devices.PortSensor
|
import hep.dataforge.control.devices.PortSensor
|
||||||
import hep.dataforge.control.measurements.Measurement
|
import hep.dataforge.control.measurements.Measurement
|
||||||
import hep.dataforge.control.measurements.SimpleMeasurement
|
import hep.dataforge.control.measurements.SimpleMeasurement
|
||||||
import hep.dataforge.control.ports.PortHandler
|
import hep.dataforge.control.ports.Port
|
||||||
import hep.dataforge.description.ValueDef
|
import hep.dataforge.description.ValueDef
|
||||||
import hep.dataforge.exceptions.ControlException
|
import hep.dataforge.exceptions.ControlException
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
@ -35,7 +35,7 @@ class MKSBaratronDevice(context: Context, meta: Meta) : PortSensor<Double>(conte
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Throws(ControlException::class)
|
@Throws(ControlException::class)
|
||||||
override fun buildHandler(portName: String): PortHandler {
|
override fun buildHandler(portName: String): Port {
|
||||||
val handler = super.buildHandler(portName)
|
val handler = super.buildHandler(portName)
|
||||||
handler.setDelimiter("\r")
|
handler.setDelimiter("\r")
|
||||||
return handler
|
return handler
|
||||||
|
@ -11,7 +11,7 @@ import hep.dataforge.control.devices.PortSensor
|
|||||||
import hep.dataforge.control.devices.StateDef
|
import hep.dataforge.control.devices.StateDef
|
||||||
import hep.dataforge.control.measurements.Measurement
|
import hep.dataforge.control.measurements.Measurement
|
||||||
import hep.dataforge.control.measurements.SimpleMeasurement
|
import hep.dataforge.control.measurements.SimpleMeasurement
|
||||||
import hep.dataforge.control.ports.PortHandler
|
import hep.dataforge.control.ports.Port
|
||||||
import hep.dataforge.description.ValueDef
|
import hep.dataforge.description.ValueDef
|
||||||
import hep.dataforge.description.ValueDefs
|
import hep.dataforge.description.ValueDefs
|
||||||
import hep.dataforge.exceptions.ControlException
|
import hep.dataforge.exceptions.ControlException
|
||||||
@ -77,7 +77,7 @@ class MKSVacDevice(context: Context, meta: Meta) : PortSensor<Double>(context, m
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Throws(ControlException::class)
|
@Throws(ControlException::class)
|
||||||
override fun buildHandler(portName: String): PortHandler {
|
override fun buildHandler(portName: String): Port {
|
||||||
val handler = super.buildHandler(portName)
|
val handler = super.buildHandler(portName)
|
||||||
handler.setDelimiter(";FF")
|
handler.setDelimiter(";FF")
|
||||||
return handler
|
return handler
|
||||||
|
@ -10,7 +10,7 @@ import hep.dataforge.control.devices.Device
|
|||||||
import hep.dataforge.control.devices.PortSensor
|
import hep.dataforge.control.devices.PortSensor
|
||||||
import hep.dataforge.control.measurements.Measurement
|
import hep.dataforge.control.measurements.Measurement
|
||||||
import hep.dataforge.control.measurements.SimpleMeasurement
|
import hep.dataforge.control.measurements.SimpleMeasurement
|
||||||
import hep.dataforge.control.ports.PortHandler
|
import hep.dataforge.control.ports.Port
|
||||||
import hep.dataforge.description.ValueDef
|
import hep.dataforge.description.ValueDef
|
||||||
import hep.dataforge.exceptions.ControlException
|
import hep.dataforge.exceptions.ControlException
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
@ -27,7 +27,7 @@ import java.util.regex.Pattern
|
|||||||
class MeradatVacDevice(context: Context, meta: Meta) : PortSensor<Double>(context, meta) {
|
class MeradatVacDevice(context: Context, meta: Meta) : PortSensor<Double>(context, meta) {
|
||||||
|
|
||||||
@Throws(ControlException::class)
|
@Throws(ControlException::class)
|
||||||
override fun buildHandler(portName: String): PortHandler {
|
override fun buildHandler(portName: String): Port {
|
||||||
val newHandler = super.buildHandler(portName)
|
val newHandler = super.buildHandler(portName)
|
||||||
newHandler.setDelimiter("\r\n")
|
newHandler.setDelimiter("\r\n")
|
||||||
return newHandler
|
return newHandler
|
||||||
|
Loading…
Reference in New Issue
Block a user