Vac in progress

This commit is contained in:
Alexander Nozik 2017-05-17 16:50:00 +03:00
parent cdf4ee3018
commit a606777120
7 changed files with 20 additions and 22 deletions

View File

@ -114,7 +114,7 @@ public class PKT8Device extends PortSensor<PKT8Result> {
//update parameters from meta
if (meta().hasValue("pga")) {
getLogger().info("Setting dynamic range to " + meta().getInt("pga"));
String response = getHandler().sendAndWait("g" + meta().getInt("pga"), 400, null).trim();
String response = getHandler().sendAndWait("g" + meta().getInt("pga"), 400).trim();
if (response.contains("=")) {
updateState(PGA, Integer.parseInt(response.substring(4)));
} else {
@ -182,7 +182,7 @@ public class PKT8Device extends PortSensor<PKT8Result> {
getLogger().info("Setting avaraging buffer size to " + buf);
String response;
try {
response = getHandler().sendAndWait("b" + buf, 400, null).trim();
response = getHandler().sendAndWait("b" + buf, 400).trim();
} catch (Exception ex) {
response = ex.getMessage();
}
@ -271,7 +271,7 @@ public class PKT8Device extends PortSensor<PKT8Result> {
getLogger().info("Setting sampling rate to " + spsToStr(sps));
String response;
try {
response = getHandler().sendAndWait("v" + sps, 400, null).trim();
response = getHandler().sendAndWait("v" + sps, 400).trim();
} catch (Exception ex) {
response = ex.getMessage();
}
@ -326,7 +326,6 @@ public class PKT8Device extends PortSensor<PKT8Result> {
}
public class PKT8Measurement extends AbstractMeasurement<PKT8Result> implements PortHandler.PortController {
final PortHandler handler;

View File

@ -30,8 +30,6 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
*
*
* @author Polina
*/
public class MagnetController implements PortHandler.PortController {
@ -122,11 +120,11 @@ public class MagnetController implements PortHandler.PortController {
private String talk(String request) throws PortException {
try {
return port.sendAndWait(request + "\r", timeout, null).trim();
return port.sendAndWait(request + "\r", timeout).trim();
} catch (PortTimeoutException tex) {
//Single retry on timeout
LoggerFactory.getLogger(getClass()).warn("A timeout exception for request '" + request + "'. Making another atempt.");
return port.sendAndWait(request + "\r", timeout, null).trim();
return port.sendAndWait(request + "\r", timeout).trim();
}
}

View File

@ -48,7 +48,7 @@ public class Talk {
portName = args[0];
}
PortHandler handler;
handler = PortFactory.getdPort(portName);
handler = PortFactory.getPort(portName);
handler.setPhraseCondition((String str) -> str.endsWith("\r"));
// MagnetController controller = new MagnetController(handler, 1);
@ -60,7 +60,7 @@ public class Talk {
while (!"exit".equals(nextString)) {
try {
Instant start = DateTimeUtils.now();
String answer = handler.sendAndWait(nextString + "\r", 1000, null);
String answer = handler.sendAndWait(nextString + "\r", null, 1000);
//String answer = controller.request(nextString);
System.out.printf("ANSWER (latency = %s): %s;%n", Duration.between(start, DateTimeUtils.now()), answer.trim());
} catch (PortException ex) {

View File

@ -24,16 +24,17 @@ import hep.dataforge.exceptions.ControlException;
import inr.numass.control.magnet.MagnetController;
import inr.numass.control.magnet.SafeMagnetController;
import inr.numass.control.magnet.VirtualLambdaPort;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
/**
*
* @author Alexander Nozik
@ -71,7 +72,7 @@ public class MagnetControllerApp extends Application {
if(portName.equals("virtual")){
handler = new VirtualLambdaPort("COM12", 1, 2, 3, 4);
} else {
handler = PortFactory.getdPort(portName);
handler = PortFactory.getPort(portName);
//TODO add meta reader here
}

View File

@ -260,7 +260,8 @@ public class MspDevice extends SingleMeasurementDevice implements PortHandler.Po
String response = getHandler().sendAndWait(
request,
TIMEOUT, (String str) -> str.trim().startsWith(commandName)
TIMEOUT,
(String str) -> str.trim().startsWith(commandName)
);
return new MspResponse(response);
}

View File

@ -38,7 +38,7 @@ public class CM32Device extends PortSensor<Double> {
if (portName.startsWith("com")) {
newHandler = new ComPortHandler(portName, 2400, 8, 1, 0);
} else {
newHandler = PortFactory.getdPort(portName);
newHandler = PortFactory.getPort(portName);
}
newHandler.setDelimeter("T--\r");
return newHandler;

View File

@ -50,11 +50,10 @@ public class MeradatVacDevice extends PortSensor<Double> {
return meta().getString("type", "Vit vacuumeter");
}
private class MeradatMeasurement extends SimpleMeasurement<Double> {
// private static final String VIT_QUERY = ":010300000002FA\r\n";
private final String query;
private final String query; // ":010300000002FA\r\n";
private final Pattern response;
private final String base;