diff --git a/pom.xml b/pom.xml index 57f33ea..57e6f57 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 ch.psi MXSC - 1.9.0 + 1.10.0 jar diff --git a/src/main/java/ch/psi/mxsc/Controller.java b/src/main/java/ch/psi/mxsc/Controller.java index df8f879..3082aa5 100644 --- a/src/main/java/ch/psi/mxsc/Controller.java +++ b/src/main/java/ch/psi/mxsc/Controller.java @@ -4,19 +4,20 @@ package ch.psi.mxsc; import ch.psi.pshell.core.Context; +import ch.psi.pshell.core.DevicePool; import ch.psi.pshell.core.DevicePoolListener; import ch.psi.pshell.device.Device; import ch.psi.pshell.device.DeviceAdapter; -import ch.psi.pshell.device.DeviceListener; import ch.psi.pshell.device.GenericDevice; import ch.psi.pshell.device.ProcessVariableBase; import ch.psi.pshell.device.ReadbackDevice; import ch.psi.pshell.ui.Panel; -import ch.psi.utils.State; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.script.ScriptException; import javax.swing.JComponent; @@ -28,7 +29,7 @@ public class Controller { static Controller instance; final BasePlate basePlate; final /*Panel*/ MainPanel mainFrame; - Device hexaposi; + Device hexiposi; public static Controller getInstance() { return instance; @@ -69,7 +70,7 @@ public class Controller { } void onInitialize(int runCount) { - GenericDevice former = getMainFrame().getDevice("BasePlate"); + GenericDevice former = getDevice("BasePlate"); if (former != null) { getMainFrame().removeDevice(former); } @@ -101,13 +102,17 @@ public class Controller { detection = new EseraDetection((Device) getMainFrame().getDevice(PUCK_ESERA_DEVICE)); } } - hexaposi = (Device) getMainFrame().getDevice("hexiposi"); - hexaposi.addListener(new DeviceAdapter() { - @Override - public void onValueChanged(Device device, Object value, Object former) { - updateView(); - } - }); + hexiposi = (Device) getMainFrame().getDevice("hexiposi"); + if (hexiposi!=null){ + hexiposi.addListener(new DeviceAdapter() { + @Override + public void onValueChanged(Device device, Object value, Object former) { + updateView(); + } + }); + } else { + Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, "No hexiposi detected."); + } } final PuckState[] puckState; @@ -145,7 +150,7 @@ public class Controller { } public String getHexiposiPosition() { - return (String) ((ReadbackDevice) hexaposi).getReadback().take(); + return (String) ((ReadbackDevice) hexiposi).getReadback().take(); } public Boolean isLedRoomTemp() { @@ -203,5 +208,16 @@ public class Controller { onPuckPressed(sample.getPuck()); } + GenericDevice getDevice(String name){ + return getMainFrame().getDevice(name); + } + DevicePool getDevicePool(){ + return getMainFrame().getContext().getDevicePool(); + } + + Context getContext(){ + return getMainFrame().getContext(); + } + } diff --git a/src/main/java/ch/psi/mxsc/DevicesPanel.form b/src/main/java/ch/psi/mxsc/DevicesPanel.form new file mode 100644 index 0000000..2d5275a --- /dev/null +++ b/src/main/java/ch/psi/mxsc/DevicesPanel.form @@ -0,0 +1,156 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/ch/psi/mxsc/DevicesPanel.java b/src/main/java/ch/psi/mxsc/DevicesPanel.java new file mode 100644 index 0000000..49d5df3 --- /dev/null +++ b/src/main/java/ch/psi/mxsc/DevicesPanel.java @@ -0,0 +1,230 @@ +package ch.psi.mxsc; + +import ch.psi.pshell.device.Device; +import ch.psi.pshell.device.DeviceAdapter; +import ch.psi.pshell.device.GenericDevice; +import ch.psi.pshell.imaging.Data; +import ch.psi.pshell.imaging.ImageListener; +import ch.psi.pshell.swing.Led; +import ch.psi.utils.State; +import java.awt.Color; +import java.awt.image.BufferedImage; + +/** + * + */ +public class DevicesPanel extends javax.swing.JPanel { + + GenericDevice robot; + GenericDevice hexiposi; + GenericDevice microscan; + GenericDevice wago; + GenericDevice laser; + GenericDevice puck_detection; + GenericDevice img; + /** + * Creates new form DevicesPanel + */ + public DevicesPanel() { + initComponents(); + } + + GenericDevice[] getDevices(){ + return new GenericDevice[]{robot, hexiposi, microscan, wago, laser, puck_detection}; + } + + final DeviceAdapter deviceListener = new DeviceAdapter() { + @Override + public void onStateChanged(Device device, State state, State former) { + update(); + } + }; + + + void initialize(){ + for (GenericDevice dev : getDevices()){ + if (dev!=null){ + dev.removeListener(deviceListener); + } + } + robot = Controller.getInstance().getDevice("robot"); + hexiposi = Controller.getInstance().getDevice("hexiposi"); + microscan = Controller.getInstance().getDevice("microscan"); + wago = Controller.getInstance().getDevice("wago"); + laser = Controller.getInstance().getDevice("ue"); + puck_detection = Controller.getInstance().getDevice("puck_detection"); + img = Controller.getInstance().getDevice("img"); + update(); + for (GenericDevice dev : getDevices()){ + if (dev!=null){ + dev.addListener(deviceListener); + } + } + + } + + void update(){ + setLedState(ledBarcodeReader, microscan); + setLedState(ledCamera, img); + setLedState(ledHexiposi, hexiposi); + setLedState(ledLaser, laser); + setLedState(ledPuckDetection, puck_detection); + setLedState(ledRobot, robot); + setLedState(ledWago, wago); + } + + void setLedState(Led led, GenericDevice dev){ + if ((dev==null) || (dev.getState()==null)){ + led.setColor(Color.black); + } else { + switch (dev.getState()){ + case Ready: + led.setColor(Color.green); + break; + case Initializing: + case Paused: + case Busy: + case Disabled: + led.setColor(Color.orange); + break; + case Invalid: + case Closing: + case Fault: + case Offline: + led.setColor(Color.red); + break; + default: + led.setColor(Color.darkGray); + break; + } + } + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel24 = new javax.swing.JLabel(); + ledRobot = new ch.psi.pshell.swing.Led(); + ledWago = new ch.psi.pshell.swing.Led(); + jLabel25 = new javax.swing.JLabel(); + jLabel26 = new javax.swing.JLabel(); + ledLaser = new ch.psi.pshell.swing.Led(); + jLabel27 = new javax.swing.JLabel(); + ledCamera = new ch.psi.pshell.swing.Led(); + jLabel28 = new javax.swing.JLabel(); + ledHexiposi = new ch.psi.pshell.swing.Led(); + jLabel29 = new javax.swing.JLabel(); + ledBarcodeReader = new ch.psi.pshell.swing.Led(); + jLabel30 = new javax.swing.JLabel(); + ledPuckDetection = new ch.psi.pshell.swing.Led(); + + jLabel24.setText("Robot"); + + jLabel25.setText("Wago"); + + jLabel26.setText("Laser"); + + jLabel27.setText("Camera"); + + jLabel28.setText("Hexiposi"); + + jLabel29.setText("Barcode Reader"); + + jLabel30.setText("Puck Detection"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(ledRobot, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel24)) + .addGroup(layout.createSequentialGroup() + .addComponent(ledWago, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel25)) + .addGroup(layout.createSequentialGroup() + .addComponent(ledLaser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel26)) + .addGroup(layout.createSequentialGroup() + .addComponent(ledCamera, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel27)) + .addGroup(layout.createSequentialGroup() + .addComponent(ledHexiposi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel28)) + .addGroup(layout.createSequentialGroup() + .addComponent(ledBarcodeReader, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel29)) + .addGroup(layout.createSequentialGroup() + .addComponent(ledPuckDetection, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel30))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(ledRobot, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel24)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(ledWago, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel25)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(ledLaser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel26)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(ledCamera, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel27)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(ledHexiposi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel28)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(ledBarcodeReader, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel29)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(ledPuckDetection, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel30)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel24; + private javax.swing.JLabel jLabel25; + private javax.swing.JLabel jLabel26; + private javax.swing.JLabel jLabel27; + private javax.swing.JLabel jLabel28; + private javax.swing.JLabel jLabel29; + private javax.swing.JLabel jLabel30; + private ch.psi.pshell.swing.Led ledBarcodeReader; + private ch.psi.pshell.swing.Led ledCamera; + private ch.psi.pshell.swing.Led ledHexiposi; + private ch.psi.pshell.swing.Led ledLaser; + private ch.psi.pshell.swing.Led ledPuckDetection; + private ch.psi.pshell.swing.Led ledRobot; + private ch.psi.pshell.swing.Led ledWago; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/ch/psi/mxsc/MainPanel.form b/src/main/java/ch/psi/mxsc/MainPanel.form index f449694..ff163bb 100644 --- a/src/main/java/ch/psi/mxsc/MainPanel.form +++ b/src/main/java/ch/psi/mxsc/MainPanel.form @@ -33,7 +33,7 @@ - + @@ -50,9 +50,9 @@ - + - + @@ -70,7 +70,7 @@ - + @@ -101,7 +101,7 @@ - + @@ -117,10 +117,10 @@ - - - - + + + + @@ -179,6 +179,11 @@ + + + + + @@ -207,6 +212,11 @@ + + + + + @@ -264,6 +274,19 @@ + + + + + + + + + + + + + @@ -309,7 +332,7 @@ - + @@ -427,11 +450,11 @@ - + - + @@ -530,7 +553,7 @@ - + @@ -538,20 +561,26 @@ - + + + - + - + + + + + @@ -564,6 +593,8 @@ + + @@ -622,7 +653,7 @@ - + @@ -707,7 +738,7 @@ - + @@ -818,7 +849,7 @@ - + @@ -900,7 +931,7 @@ - + @@ -981,7 +1012,7 @@ - + @@ -1030,31 +1061,36 @@ - + + + + + + + + - - - + + + + + + + + + + - - - - - - - - - - - - - + + + + + - @@ -1075,11 +1111,13 @@ + + @@ -1114,6 +1152,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/main/java/ch/psi/mxsc/MainPanel.java b/src/main/java/ch/psi/mxsc/MainPanel.java index 27e89c9..dd22940 100644 --- a/src/main/java/ch/psi/mxsc/MainPanel.java +++ b/src/main/java/ch/psi/mxsc/MainPanel.java @@ -4,10 +4,8 @@ package ch.psi.mxsc; -import ch.psi.pshell.core.Context; import ch.psi.pshell.device.Device; import ch.psi.pshell.device.DeviceAdapter; -import ch.psi.pshell.device.DeviceListener; import ch.psi.pshell.imaging.Renderer; import ch.psi.pshell.imaging.RendererMode; import ch.psi.pshell.imaging.Source; @@ -15,18 +13,10 @@ import ch.psi.pshell.ui.Panel; import ch.psi.utils.State; import ch.psi.utils.swing.SwingUtils; import java.awt.Color; -import java.awt.Component; import java.awt.Dialog; import java.awt.Dimension; -import java.io.IOException; import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.Map; -import java.util.HashMap; -import javax.script.ScriptException; import javax.swing.JComponent; -import javax.swing.JFrame; -import javax.swing.JPanel; import javax.swing.border.TitledBorder; /** @@ -48,70 +38,77 @@ public class MainPanel extends Panel { public void onInitialize(int runCount) { Controller.getInstance().onInitialize(runCount); basePlatePanel.setDevice((Device) getDevice("BasePlate")); - basePlatePanel.getDevice().setSelectable(true); - ((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()); - - ((Device) getDevice("filling_dewar")).addListener(new DeviceAdapter() { - @Override - public void onValueChanged(Device device, Object value, Object former) { - updateFillingDeware(value); - } - }); - updateFillingDeware(((Device) getDevice("filling_dewar")).take()); - - ((Device) getDevice("ln2_main_power")).addListener(new DeviceAdapter() { - @Override - public void onValueChanged(Device device, Object value, Object former) { - updateFillingControl(value); - } - }); - updateFillingControl(((Device) getDevice("ln2_main_power")).take()); - - ((Device) getDevice("hexiposi")).addListener(new DeviceAdapter() { - @Override - public void onStateChanged(Device device, State state, State former) { - updateHexiposiState(state); - } - }); - updateHexiposiState(((Device) getDevice("hexiposi")).getState()); - - ((Device) getDevice("air_pressure_ok")).addListener(new DeviceAdapter() { - @Override - public void onValueChanged(Device device, Object value, Object former) { - updateAirPressure(value); - } - }); - updateAirPressure(((Device) getDevice("air_pressure_ok")).take()); + basePlatePanel.getDevice().setSelectable(true); + try{ + devicesPanel.initialize(); + ((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()); - ((Device) getDevice("n2_pressure_ok")).addListener(new DeviceAdapter() { - @Override - public void onValueChanged(Device device, Object value, Object former) { - updateN2Pressure(value); - } - }); - updateN2Pressure(((Device) getDevice("n2_pressure_ok")).take()); + ((Device) getDevice("filling_dewar")).addListener(new DeviceAdapter() { + @Override + public void onValueChanged(Device device, Object value, Object former) { + updateFillingDeware(value); + } + }); + updateFillingDeware(((Device) getDevice("filling_dewar")).take()); - ((Device) getDevice("feedback_local_safety")).addListener(new DeviceAdapter() { - @Override - public void onValueChanged(Device device, Object value, Object former) { - updateLocalSafety(value); - } - }); - updateLocalSafety(((Device) getDevice("feedback_local_safety")).take()); + ((Device) getDevice("ln2_main_power")).addListener(new DeviceAdapter() { + @Override + public void onValueChanged(Device device, Object value, Object former) { + updateFillingControl(value); + } + }); + updateFillingControl(((Device) getDevice("ln2_main_power")).take()); + + ((Device) getDevice("hexiposi")).addListener(new DeviceAdapter() { + @Override + public void onStateChanged(Device device, State state, State former) { + updateHexiposiState(state); + } + }); + updateHexiposiState(((Device) getDevice("hexiposi")).getState()); + + ((Device) getDevice("air_pressure_ok")).addListener(new DeviceAdapter() { + @Override + public void onValueChanged(Device device, Object value, Object former) { + updateAirPressure(value); + } + }); + updateAirPressure(((Device) getDevice("air_pressure_ok")).take()); + + ((Device) getDevice("n2_pressure_ok")).addListener(new DeviceAdapter() { + @Override + public void onValueChanged(Device device, Object value, Object former) { + updateN2Pressure(value); + } + }); + updateN2Pressure(((Device) getDevice("n2_pressure_ok")).take()); + + ((Device) getDevice("feedback_local_safety")).addListener(new DeviceAdapter() { + @Override + public void onValueChanged(Device device, Object value, Object former) { + updateLocalSafety(value); + } + }); + updateLocalSafety(((Device) getDevice("feedback_local_safety")).take()); + + ((Device) getDevice("feedback_psys_safety")).addListener(new DeviceAdapter() { + @Override + public void onValueChanged(Device device, Object value, Object former) { + updatePsysSafety(value); + } + }); + updatePsysSafety(((Device) getDevice("feedback_psys_safety")).take()); + } catch (Exception ex){ + this.getLogger().log(Level.SEVERE,null, ex); + } + updateCameraView(); - ((Device) getDevice("feedback_psys_safety")).addListener(new DeviceAdapter() { - @Override - public void onValueChanged(Device device, Object value, Object former) { - updatePsysSafety(value); - } - }); - updatePsysSafety(((Device) getDevice("feedback_psys_safety")).take()); } void updateLevel(Object value){ @@ -198,8 +195,40 @@ public class MainPanel extends Panel { } } - + void updateCameraView(){ + Source source = buttonCamera.isSelected() ? (Source)this.getDevice("img"): null; + basePlatePanel.setCameraView(source); + } + void execute(String statement){ + execute(statement, false); + } + + void execute(String statement, boolean background){ + try { + evalAsync(statement, background).handle((ret, ex) -> { + if (ex != null){ + showException((Exception)ex); + } + return ret; + }); + } catch (Exception ex) { + showException(ex); + } + } + + void execute(String script, Object args){ + try { + runAsync(script, args).handle((ret, ex) -> { + if (ex != null){ + showException((Exception)ex); + } + return ret; + }); + } catch (Exception ex) { + showException(ex); + } + } /** This method is called from within the constructor to * initialize the form. @@ -222,6 +251,8 @@ public class MainPanel extends Panel { jLabel19 = new javax.swing.JLabel(); ledLidControlActive4 = new ch.psi.pshell.swing.Led(); ledLidControlActive3 = new ch.psi.pshell.swing.Led(); + ledLidControlActive5 = new ch.psi.pshell.swing.Led(); + jLabel23 = new javax.swing.JLabel(); buttonClearDet = new javax.swing.JButton(); panelDet = new javax.swing.JPanel(); jLabel21 = new javax.swing.JLabel(); @@ -242,6 +273,7 @@ public class MainPanel extends Panel { roomTempBasePlatePanel1 = new ch.psi.mxsc.RoomTempBasePlatePanel(); jPanel5 = new javax.swing.JPanel(); buttonExpert = new javax.swing.JButton(); + devicesPanel = new ch.psi.mxsc.DevicesPanel(); jPanel4 = new javax.swing.JPanel(); ledFillingControl = new ch.psi.pshell.swing.Led(); ledFillingDewar = new ch.psi.pshell.swing.Led(); @@ -286,6 +318,8 @@ public class MainPanel extends Panel { ledLocalSafety = new ch.psi.pshell.swing.Led(); jLabell21 = new javax.swing.JLabel(); ledPsysSafety = new ch.psi.pshell.swing.Led(); + buttonReleaseLocal = new javax.swing.JButton(); + buttonReleasePsys = new javax.swing.JButton(); basePlatePanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Dewar")); @@ -325,6 +359,11 @@ public class MainPanel extends Panel { ledLidControlActive3.setForeground(new java.awt.Color(128, 192, 192)); ledLidControlActive3.setLedSize(20); + ledLidControlActive5.setForeground(new java.awt.Color(192, 152, 45)); + ledLidControlActive5.setLedSize(20); + + jLabel23.setText("Offline"); + javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11); jPanel11.setLayout(jPanel11Layout); jPanel11Layout.setHorizontalGroup( @@ -347,7 +386,11 @@ public class MainPanel extends Panel { .addGroup(jPanel11Layout.createSequentialGroup() .addComponent(ledLidControlActive4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel20))) + .addComponent(jLabel20)) + .addGroup(jPanel11Layout.createSequentialGroup() + .addComponent(ledLidControlActive5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel23))) .addGap(4, 4, 4)) ); jPanel11Layout.setVerticalGroup( @@ -368,7 +411,11 @@ public class MainPanel extends Panel { .addGap(0, 0, 0) .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(ledLidControlActive1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel15))) + .addComponent(jLabel15)) + .addGap(0, 0, Short.MAX_VALUE) + .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(ledLidControlActive5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel23))) ); buttonClearDet.setText("Clear"); @@ -418,7 +465,7 @@ public class MainPanel extends Panel { .addComponent(jLabel22) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(textDetImage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap(18, Short.MAX_VALUE)) ); javax.swing.GroupLayout basePlatePanelLayout = new javax.swing.GroupLayout(basePlatePanel); @@ -436,7 +483,7 @@ public class MainPanel extends Panel { .addComponent(buttonClearDet, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGroup(basePlatePanelLayout.createSequentialGroup() .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 375, Short.MAX_VALUE) .addComponent(panelDet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(4, 4, 4)))) ); @@ -451,10 +498,10 @@ public class MainPanel extends Panel { .addComponent(buttonPuckDet) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(buttonClearDet) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 273, Short.MAX_VALUE) - .addGroup(basePlatePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(panelDet, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(basePlatePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(panelDet, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jPanel11, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(4, 4, 4)) ); @@ -501,11 +548,11 @@ public class MainPanel extends Panel { .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(progressLN2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel3Layout.createSequentialGroup() - .addContainerGap(53, Short.MAX_VALUE) + .addContainerGap(44, Short.MAX_VALUE) .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 53, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE) .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) @@ -558,7 +605,7 @@ public class MainPanel extends Panel { roomTempBasePlatePanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("RT Humidifier Lid States")); - jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Robot Arm")); + jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Devices")); buttonExpert.setText("Expert "); buttonExpert.addActionListener(new java.awt.event.ActionListener() { @@ -571,17 +618,22 @@ public class MainPanel extends Panel { jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel5Layout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup() + .addContainerGap() + .addComponent(devicesPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(buttonExpert) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) ); jPanel5Layout.setVerticalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap() .addComponent(buttonExpert) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(jPanel5Layout.createSequentialGroup() + .addComponent(devicesPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addGap(9, 9, 9)) ); jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("LN2 Control")); @@ -633,7 +685,7 @@ public class MainPanel extends Panel { .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel14) .addComponent(deviceValuePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(23, Short.MAX_VALUE)) + .addContainerGap(31, Short.MAX_VALUE)) ); jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("Lid Motion Control")); @@ -699,7 +751,7 @@ public class MainPanel extends Panel { .addComponent(jLabel7)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(buttonInitHexiposi) - .addContainerGap(18, Short.MAX_VALUE)) + .addContainerGap(26, Short.MAX_VALUE)) .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); @@ -747,7 +799,7 @@ public class MainPanel extends Panel { .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(led7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel10)) - .addContainerGap(26, Short.MAX_VALUE)) + .addContainerGap(34, Short.MAX_VALUE)) ); jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Robot Gripper")); @@ -803,7 +855,7 @@ public class MainPanel extends Panel { .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel13) .addComponent(textSample, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(26, Short.MAX_VALUE)) + .addContainerGap(34, Short.MAX_VALUE)) ); jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder("RT Humidifier Box")); @@ -840,7 +892,7 @@ public class MainPanel extends Panel { .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(led15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel18)) - .addContainerGap(52, Short.MAX_VALUE)) + .addContainerGap(60, Short.MAX_VALUE)) ); panelDewar.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Dewar Light", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION)); @@ -861,30 +913,47 @@ public class MainPanel extends Panel { jLabell21.setText("Psys Safety"); + buttonReleaseLocal.setText("Release"); + buttonReleaseLocal.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonReleaseLocalActionPerformed(evt); + } + }); + + buttonReleasePsys.setText("Release"); + buttonReleasePsys.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonReleasePsysActionPerformed(evt); + } + }); + javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13); jPanel13.setLayout(jPanel13Layout); jPanel13Layout.setHorizontalGroup( jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel13Layout.createSequentialGroup() .addContainerGap() + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(ledAirPressure, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(ledN2Pressure, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(ledLocalSafety, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(ledPsysSafety, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel13Layout.createSequentialGroup() - .addComponent(ledAirPressure, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel24)) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabell21) + .addComponent(jLabel26)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(buttonReleaseLocal) + .addComponent(buttonReleasePsys)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(jPanel13Layout.createSequentialGroup() - .addComponent(ledN2Pressure, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel25)) - .addGroup(jPanel13Layout.createSequentialGroup() - .addComponent(ledLocalSafety, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel26)) - .addGroup(jPanel13Layout.createSequentialGroup() - .addComponent(ledPsysSafety, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabell21))) - .addContainerGap(38, Short.MAX_VALUE)) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel25) + .addComponent(jLabel24)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) ); jPanel13Layout.setVerticalGroup( jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -900,11 +969,13 @@ public class MainPanel extends Panel { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(ledLocalSafety, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel26)) + .addComponent(jLabel26) + .addComponent(buttonReleaseLocal)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(ledPsysSafety, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabell21))) + .addComponent(jLabell21) + .addComponent(buttonReleasePsys))) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); @@ -926,7 +997,7 @@ public class MainPanel extends Panel { .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) @@ -966,8 +1037,7 @@ public class MainPanel extends Panel { private void buttonCameraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCameraActionPerformed try{ - Source source = buttonCamera.isSelected() ? (Source)this.getDevice("img"): null; - basePlatePanel.setCameraView(source); + updateCameraView(); } catch (Exception ex) { showException(ex); } @@ -1031,6 +1101,14 @@ public class MainPanel extends Panel { } }//GEN-LAST:event_buttonClearDetActionPerformed + private void buttonReleaseLocalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReleaseLocalActionPerformed + execute("release_local()", true); + }//GEN-LAST:event_buttonReleaseLocalActionPerformed + + private void buttonReleasePsysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReleasePsysActionPerformed + execute("release_psys()", true); + }//GEN-LAST:event_buttonReleasePsysActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private ch.psi.mxsc.BasePlatePanel basePlatePanel; @@ -1039,7 +1117,10 @@ public class MainPanel extends Panel { private javax.swing.JButton buttonExpert; private javax.swing.JButton buttonInitHexiposi; private javax.swing.JButton buttonPuckDet; + private javax.swing.JButton buttonReleaseLocal; + private javax.swing.JButton buttonReleasePsys; private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel1; + private ch.psi.mxsc.DevicesPanel devicesPanel; private ch.psi.mxsc.HexiposiPanel hexiposiPanel; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; @@ -1056,6 +1137,7 @@ public class MainPanel extends Panel { private javax.swing.JLabel jLabel20; private javax.swing.JLabel jLabel21; private javax.swing.JLabel jLabel22; + private javax.swing.JLabel jLabel23; private javax.swing.JLabel jLabel24; private javax.swing.JLabel jLabel25; private javax.swing.JLabel jLabel26; @@ -1095,6 +1177,7 @@ public class MainPanel extends Panel { private ch.psi.pshell.swing.Led ledLidControlActive2; private ch.psi.pshell.swing.Led ledLidControlActive3; private ch.psi.pshell.swing.Led ledLidControlActive4; + private ch.psi.pshell.swing.Led ledLidControlActive5; private ch.psi.pshell.swing.Led ledLidInitialized; private ch.psi.pshell.swing.Led ledLocalSafety; private ch.psi.pshell.swing.Led ledN2Pressure;