PKT8 fixes
This commit is contained in:
parent
a33457d025
commit
1da1d628c2
@ -42,12 +42,10 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
public class PKT8Device extends PortSensor<PKT8Result> {
|
public class PKT8Device extends PortSensor<PKT8Result> {
|
||||||
|
|
||||||
private static final String[] CHANNEL_DESIGNATIONS = {"a", "b", "c", "d", "e", "f", "g", "h"};
|
|
||||||
|
|
||||||
public static final String PGA = "pga";
|
public static final String PGA = "pga";
|
||||||
public static final String SPS = "sps";
|
public static final String SPS = "sps";
|
||||||
public static final String ABUF = "abuf";
|
public static final String ABUF = "abuf";
|
||||||
|
private static final String[] CHANNEL_DESIGNATIONS = {"a", "b", "c", "d", "e", "f", "g", "h"};
|
||||||
/**
|
/**
|
||||||
* The key is the letter (a,b,c,d...) as in measurements
|
* The key is the letter (a,b,c,d...) as in measurements
|
||||||
*/
|
*/
|
||||||
@ -77,6 +75,7 @@ public class PKT8Device extends PortSensor<PKT8Result> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
super.init();
|
super.init();
|
||||||
|
|
||||||
//update parameters from meta
|
//update parameters from meta
|
||||||
if (meta().hasValue("pga")) {
|
if (meta().hasValue("pga")) {
|
||||||
getLogger().info("Setting dynamic range to " + meta().getInt("pga"));
|
getLogger().info("Setting dynamic range to " + meta().getInt("pga"));
|
||||||
@ -95,9 +94,11 @@ public class PKT8Device extends PortSensor<PKT8Result> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shutdown() throws ControlException {
|
public void shutdown() throws ControlException {
|
||||||
|
if (collector != null) {
|
||||||
|
collector.clear();
|
||||||
|
collector = null;
|
||||||
|
}
|
||||||
super.shutdown();
|
super.shutdown();
|
||||||
collector.clear();
|
|
||||||
collector = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -154,7 +155,7 @@ public class PKT8Device extends PortSensor<PKT8Result> {
|
|||||||
private String spsToStr(int sps) {
|
private String spsToStr(int sps) {
|
||||||
switch (sps) {
|
switch (sps) {
|
||||||
case 0:
|
case 0:
|
||||||
return "2,5 SPS";
|
return "2.5 SPS";
|
||||||
case 1:
|
case 1:
|
||||||
return "5 SPS";
|
return "5 SPS";
|
||||||
case 2:
|
case 2:
|
||||||
@ -196,9 +197,9 @@ public class PKT8Device extends PortSensor<PKT8Result> {
|
|||||||
case 4:
|
case 4:
|
||||||
return "± 312.5 mV";
|
return "± 312.5 mV";
|
||||||
case 5:
|
case 5:
|
||||||
return "± 156,25 mV";
|
return "± 156.25 mV";
|
||||||
case 6:
|
case 6:
|
||||||
return "± 78,125 mV";
|
return "± 78.125 mV";
|
||||||
default:
|
default:
|
||||||
return "unknown value";
|
return "unknown value";
|
||||||
}
|
}
|
||||||
@ -274,6 +275,10 @@ public class PKT8Device extends PortSensor<PKT8Result> {
|
|||||||
return this.getMeasurement();
|
return this.getMeasurement();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
if (getHandler().isLocked()) {
|
||||||
|
getLogger().error("Breaking hold on handler because it is locked");
|
||||||
|
getHandler().breakHold();
|
||||||
|
}
|
||||||
return new PKT8Measurement(getHandler());
|
return new PKT8Measurement(getHandler());
|
||||||
} catch (ControlException e) {
|
} catch (ControlException e) {
|
||||||
throw new MeasurementException(e);
|
throw new MeasurementException(e);
|
||||||
@ -286,11 +291,12 @@ public class PKT8Device extends PortSensor<PKT8Result> {
|
|||||||
//clearing PKT queue
|
//clearing PKT queue
|
||||||
try {
|
try {
|
||||||
getHandler().send("p");
|
getHandler().send("p");
|
||||||
getHandler().sendAndWait("p", null, 1000);
|
getHandler().sendAndWait("p", 400);
|
||||||
} catch (ControlException e) {
|
} catch (ControlException e) {
|
||||||
|
getLogger().error("Failed to clear PKT8 port");
|
||||||
// throw new MeasurementException(e);
|
// throw new MeasurementException(e);
|
||||||
}
|
}
|
||||||
if(collector == null){
|
if (collector == null) {
|
||||||
setupStorage();
|
setupStorage();
|
||||||
}
|
}
|
||||||
return super.startMeasurement();
|
return super.startMeasurement();
|
||||||
@ -307,6 +313,10 @@ public class PKT8Device extends PortSensor<PKT8Result> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start() {
|
||||||
|
if (isStarted()) {
|
||||||
|
getLogger().warn("Trying to start measurement which is already started");
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
handler.holdBy(this);
|
handler.holdBy(this);
|
||||||
handler.send("s");
|
handler.send("s");
|
||||||
@ -314,20 +324,26 @@ public class PKT8Device extends PortSensor<PKT8Result> {
|
|||||||
} catch (PortException ex) {
|
} catch (PortException ex) {
|
||||||
error("Failed to start measurement", ex);
|
error("Failed to start measurement", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stop(boolean force) throws MeasurementException {
|
public boolean stop(boolean force) throws MeasurementException {
|
||||||
|
if (isFinished()) {
|
||||||
|
getLogger().warn("Trying to stop measurement which is already stopped");
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
getHandler().send("p");
|
String response = getHandler().sendAndWait("p", 400).trim();
|
||||||
if (collector != null) {
|
// Должно быть именно с большой буквы!!!
|
||||||
collector.clear();
|
return "Stopped".equals(response) || "stopped".equals(response);
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
error(ex);
|
error(ex);
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
|
if (collector != null) {
|
||||||
|
collector.clear();
|
||||||
|
}
|
||||||
handler.unholdBy(this);
|
handler.unholdBy(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -338,8 +354,8 @@ public class PKT8Device extends PortSensor<PKT8Result> {
|
|||||||
String trimmed = message.trim();
|
String trimmed = message.trim();
|
||||||
|
|
||||||
if (isStarted()) {
|
if (isStarted()) {
|
||||||
if (trimmed.equals("stopped")) {
|
if (trimmed.equals("Stopped") || trimmed.equals("stopped")) {
|
||||||
afterStop();
|
afterPause();
|
||||||
getLogger().info("Measurement stopped");
|
getLogger().info("Measurement stopped");
|
||||||
} else {
|
} else {
|
||||||
String designation = trimmed.substring(0, 1);
|
String designation = trimmed.substring(0, 1);
|
||||||
@ -354,7 +370,6 @@ public class PKT8Device extends PortSensor<PKT8Result> {
|
|||||||
} else {
|
} else {
|
||||||
result(new PKT8Result(designation, rawValue, -1));
|
result(new PKT8Result(designation, rawValue, -1));
|
||||||
}
|
}
|
||||||
setMeasurementState(MeasurementState.OK);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.cryotemp;
|
package inr.numass.cryotemp;
|
||||||
|
|
||||||
import hep.dataforge.context.GlobalContext;
|
|
||||||
import hep.dataforge.control.devices.Device;
|
import hep.dataforge.control.devices.Device;
|
||||||
import hep.dataforge.control.devices.DeviceListener;
|
import hep.dataforge.control.devices.DeviceListener;
|
||||||
import hep.dataforge.control.measurements.Measurement;
|
import hep.dataforge.control.measurements.Measurement;
|
||||||
@ -33,6 +32,8 @@ import hep.dataforge.plots.fx.FXPlotFrame;
|
|||||||
import hep.dataforge.plots.fx.PlotContainer;
|
import hep.dataforge.plots.fx.PlotContainer;
|
||||||
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
|
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
|
||||||
import hep.dataforge.values.Value;
|
import hep.dataforge.values.Value;
|
||||||
|
import javafx.beans.InvalidationListener;
|
||||||
|
import javafx.beans.Observable;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
@ -58,18 +59,17 @@ import java.util.ResourceBundle;
|
|||||||
public class PKT8MainViewController implements Initializable, DeviceListener, MeasurementListener<PKT8Result>, AutoCloseable {
|
public class PKT8MainViewController implements Initializable, DeviceListener, MeasurementListener<PKT8Result>, AutoCloseable {
|
||||||
|
|
||||||
public static final String DEFAULT_CONFIG_LOCATION = "devices.xml";
|
public static final String DEFAULT_CONFIG_LOCATION = "devices.xml";
|
||||||
|
ConsoleFragment consoleFragment;
|
||||||
private PKT8Device device;
|
private PKT8Device device;
|
||||||
private FXPlotFrame<XYPlottable> plotFrame;
|
private FXPlotFrame<XYPlottable> plotFrame;
|
||||||
private TimePlottableGroup plottables;
|
private TimePlottableGroup plottables;
|
||||||
private Meta currentPlotConfig;
|
|
||||||
|
|
||||||
ConsoleFragment consoleFragment;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Button loadConfigButton;
|
private Button loadConfigButton;
|
||||||
@FXML
|
@FXML
|
||||||
private ToggleButton startStopButton;
|
private ToggleButton startStopButton;
|
||||||
@FXML
|
@FXML
|
||||||
|
private ToggleButton rawDataButton;
|
||||||
|
@FXML
|
||||||
private AnchorPane plotArea;
|
private AnchorPane plotArea;
|
||||||
@FXML
|
@FXML
|
||||||
private ToggleButton consoleButton;
|
private ToggleButton consoleButton;
|
||||||
@ -89,6 +89,17 @@ public class PKT8MainViewController implements Initializable, DeviceListener, Me
|
|||||||
setupPlotFrame(null);
|
setupPlotFrame(null);
|
||||||
this.consoleFragment = new ConsoleFragment();
|
this.consoleFragment = new ConsoleFragment();
|
||||||
consoleFragment.bindTo(consoleButton);
|
consoleFragment.bindTo(consoleButton);
|
||||||
|
rawDataButton.selectedProperty().addListener(new InvalidationListener() {
|
||||||
|
@Override
|
||||||
|
public void invalidated(Observable observable) {
|
||||||
|
if (plotFrame != null) {
|
||||||
|
setupPlotFrame(plotFrame.getConfig());
|
||||||
|
if (device != null) {
|
||||||
|
setupChannels();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
@ -96,7 +107,7 @@ public class PKT8MainViewController implements Initializable, DeviceListener, Me
|
|||||||
FileChooser fileChooser = new FileChooser();
|
FileChooser fileChooser = new FileChooser();
|
||||||
fileChooser.setTitle("Open configuration file");
|
fileChooser.setTitle("Open configuration file");
|
||||||
fileChooser.setInitialFileName(DEFAULT_CONFIG_LOCATION);
|
fileChooser.setInitialFileName(DEFAULT_CONFIG_LOCATION);
|
||||||
fileChooser.setInitialDirectory(GlobalContext.instance().io().getRootDirectory());
|
// fileChooser.setInitialDirectory(GlobalContext.instance().io().getRootDirectory());
|
||||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("xml", "*.xml", "*.XML"));
|
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("xml", "*.xml", "*.XML"));
|
||||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("json", "*.json", "*.JSON"));
|
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("json", "*.json", "*.JSON"));
|
||||||
// fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("all", "*.*"));
|
// fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("all", "*.*"));
|
||||||
@ -129,7 +140,6 @@ public class PKT8MainViewController implements Initializable, DeviceListener, Me
|
|||||||
}
|
}
|
||||||
|
|
||||||
setupPlotFrame(plotConfig.getNode("plotFrame", null));
|
setupPlotFrame(plotConfig.getNode("plotFrame", null));
|
||||||
currentPlotConfig = plotConfig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.hasNode("device")) {
|
if (config.hasNode("device")) {
|
||||||
@ -144,7 +154,7 @@ public class PKT8MainViewController implements Initializable, DeviceListener, Me
|
|||||||
/**
|
/**
|
||||||
* Set o reset plot area
|
* Set o reset plot area
|
||||||
*/
|
*/
|
||||||
private void setupPlotFrame(Meta plotFrameMeta) {
|
private synchronized void setupPlotFrame(Meta plotFrameMeta) {
|
||||||
plottables = new TimePlottableGroup();
|
plottables = new TimePlottableGroup();
|
||||||
plotArea.getChildren().clear();
|
plotArea.getChildren().clear();
|
||||||
plotFrame = new JFreeChartFrame(plotFrameMeta);
|
plotFrame = new JFreeChartFrame(plotFrameMeta);
|
||||||
@ -169,8 +179,7 @@ public class PKT8MainViewController implements Initializable, DeviceListener, Me
|
|||||||
device.init();
|
device.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void setupChannels() {
|
||||||
public void notifyDeviceInitialized(Device device) {
|
|
||||||
Collection<PKT8Channel> channels = this.device.getChanels();
|
Collection<PKT8Channel> channels = this.device.getChanels();
|
||||||
|
|
||||||
//plot config from device configuration
|
//plot config from device configuration
|
||||||
@ -188,16 +197,18 @@ public class PKT8MainViewController implements Initializable, DeviceListener, Me
|
|||||||
plottables.addPlottable(plottable);
|
plottables.addPlottable(plottable);
|
||||||
plotFrame.add(plottable);
|
plotFrame.add(plottable);
|
||||||
});
|
});
|
||||||
|
plottables.applyConfig(plotFrame.getConfig());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyDeviceInitialized(Device device) {
|
||||||
|
setupChannels();
|
||||||
startStopButton.setDisable(false);
|
startStopButton.setDisable(false);
|
||||||
|
|
||||||
if (currentPlotConfig != null) {
|
|
||||||
applyViewConfig(currentPlotConfig);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyViewConfig(Meta viewConfig) {
|
// public void applyViewConfig(Meta viewConfig) {
|
||||||
plottables.applyConfig(viewConfig);
|
// plottables.applyConfig(viewConfig);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyDeviceShutdown(Device device) {
|
public void notifyDeviceShutdown(Device device) {
|
||||||
@ -213,8 +224,12 @@ public class PKT8MainViewController implements Initializable, DeviceListener, Me
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMeasurementResult(Measurement<PKT8Result> measurement, PKT8Result result, Instant time) {
|
public synchronized void onMeasurementResult(Measurement<PKT8Result> measurement, PKT8Result result, Instant time) {
|
||||||
plottables.put(result.channel, result.temperature);
|
if (rawDataButton.isSelected()) {
|
||||||
|
plottables.put(result.channel, result.rawValue);
|
||||||
|
} else {
|
||||||
|
plottables.put(result.channel, result.temperature);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<device>
|
||||||
|
<!-- Device configuration -->
|
||||||
|
<storage path="D:\\temp\\cryo"/>
|
||||||
|
<port>192.168.111.36:4001</port>
|
||||||
|
<abuf>1</abuf>
|
||||||
|
<averagingDuration>"PT60S"</averagingDuration>
|
||||||
|
|
||||||
|
<!-- Channel configuration -->
|
||||||
|
<channel designation="a" name="T1" r0="1000" transformationType="hyperbolic"
|
||||||
|
coefs="[17.066, -249.29, 1663.6, -5263.8, 9004.7, -7151.8, 2288.3]"/>
|
||||||
|
<channel designation="b" name="T2" r0="1000" transformationType="hyperbolic"
|
||||||
|
coefs="[73.202, -841.5, 3995.9, -9579.1, 12361.0, -7976.5, 2161.3]"/>
|
||||||
|
<channel designation="c" name="T3" r0="1000" transformationType="hyperbolic"
|
||||||
|
coefs="[52.402, -579.55, 2665.5, -6110.0, 7501.9, -4553.5, 1197.1]"/>
|
||||||
|
<channel designation="d" name="T4" r0="1000" transformationType="hyperbolic"
|
||||||
|
coefs="[17.136, -249.09, 1667.5, -5316.4, 9226.7, -7515.6, 2382.4]"/>
|
||||||
|
<channel designation="e" name="T5" r0="1000" transformationType="hyperbolic"
|
||||||
|
coefs="[58.060, -664.38, 3158.3, -7531.0, 9616.3, -6029.3, 1589.6]"/>
|
||||||
|
<!-- Обрыв -->
|
||||||
|
<!-- <channel designation="f" name="T6" r0="1000" transformationType="hyperbolic" coefs="[989.0, -1040.0, 4958.6, -11980, 15598, -10158, 2728.4]"/>-->
|
||||||
|
<channel designation="g" name="T7" r0="1000" transformationType="hyperbolic"
|
||||||
|
coefs="[71.984, -822.09, 3872.0, -9183.0, 11729.0, -7518.6, 2034.2]"/>
|
||||||
|
<channel designation="h" name="T8" r0="1000" transformationType="hyperbolic"
|
||||||
|
coefs="[23.894, -358.42, 2355.2, -7509.8, 12893.0, -10454.0, 3403.9]"/>
|
||||||
|
|
||||||
|
<!-- Plot configuration -->
|
||||||
|
<plotConfig>
|
||||||
|
<eachPlot thickness="3"/>
|
||||||
|
</plotConfig>
|
||||||
|
</device>
|
@ -16,11 +16,11 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
<?import javafx.scene.layout.BorderPane?>
|
<?import javafx.scene.layout.BorderPane?>
|
||||||
<BorderPane prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="inr.numass.cryotemp.PKT8MainViewController">
|
<BorderPane xmlns:fx="http://javafx.com/fxml/1" prefHeight="600.0" prefWidth="800.0"
|
||||||
|
xmlns="http://javafx.com/javafx/8.0.60" fx:controller="inr.numass.cryotemp.PKT8MainViewController">
|
||||||
<center>
|
<center>
|
||||||
<AnchorPane fx:id="plotArea" />
|
<AnchorPane fx:id="plotArea" />
|
||||||
</center>
|
</center>
|
||||||
@ -28,6 +28,7 @@ limitations under the License.
|
|||||||
<ToolBar BorderPane.alignment="CENTER">
|
<ToolBar BorderPane.alignment="CENTER">
|
||||||
<items>
|
<items>
|
||||||
<ToggleButton fx:id="startStopButton" disable="true" mnemonicParsing="false" onAction="#onStartStopClick" prefWidth="50.0" text="Start" />
|
<ToggleButton fx:id="startStopButton" disable="true" mnemonicParsing="false" onAction="#onStartStopClick" prefWidth="50.0" text="Start" />
|
||||||
|
<ToggleButton fx:id="rawDataButton" mnemonicParsing="false" text="Raw data"/>
|
||||||
<Separator orientation="VERTICAL" />
|
<Separator orientation="VERTICAL" />
|
||||||
<Button fx:id="loadConfigButton" mnemonicParsing="false" onAction="#onLoadConfigClick" text="Load config" />
|
<Button fx:id="loadConfigButton" mnemonicParsing="false" onAction="#onLoadConfigClick" text="Load config" />
|
||||||
<ToggleButton fx:id="consoleButton" contentDisplay="CENTER" mnemonicParsing="false" text="Console" />
|
<ToggleButton fx:id="consoleButton" contentDisplay="CENTER" mnemonicParsing="false" text="Console" />
|
||||||
|
Loading…
Reference in New Issue
Block a user