diff --git a/src/main/java/ch/psi/mxsc/MainPanel.java b/src/main/java/ch/psi/mxsc/MainPanel.java index 7342a3c..6f783ad 100644 --- a/src/main/java/ch/psi/mxsc/MainPanel.java +++ b/src/main/java/ch/psi/mxsc/MainPanel.java @@ -5,8 +5,11 @@ package ch.psi.mxsc; import ch.psi.pshell.device.Device; +import ch.psi.pshell.device.DeviceAdapter; +import ch.psi.pshell.device.DeviceListener; import ch.psi.pshell.imaging.Source; import ch.psi.pshell.ui.Panel; +import ch.psi.utils.State; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JFrame; @@ -30,6 +33,24 @@ public class MainPanel extends Panel { Controller.getInstance().onInitialize(runCount); basePlatePanel.setDevice((Device) getDevice("BasePlate")); basePlatePanel.getDevice().setSelectable(false); + ((Device) getDevice("dewar_level")).addListener(new DeviceAdapter() { + @Override + public void onValueChanged(Device device, Object value, Object former) { + updateLevel(value); + } + }); + updateLevel(((Device) getDevice("dewar_level")).take()); + } + + void updateLevel(Object value){ + if ((value == null) || !(value instanceof Number)){ + progressLN2.setIndeterminate(true); + } else { + progressLN2.setIndeterminate(false); + double val = ((Number)value).doubleValue() * 10.0; + val = Math.min(Math.max((int)(val *10), 0), 1000); + progressLN2.setValue(Math.min(Math.max((int)val, 0), 1000)); + } }