This commit is contained in:
gac-S_Changer
2018-08-14 14:09:01 +02:00
parent 3d571e8a4e
commit 047fad02d8
4 changed files with 415 additions and 230 deletions

View File

@@ -1,7 +1,6 @@
/*
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
*/
package ch.psi.mxsc;
import ch.psi.pshell.core.Plugin;
@@ -12,53 +11,67 @@ import ch.psi.pshell.imaging.RendererMode;
import ch.psi.pshell.imaging.Source;
import ch.psi.pshell.ui.App;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.Config;
import ch.psi.utils.swing.ConfigDialog;
import ch.psi.utils.swing.PropertiesDialog;
import ch.psi.utils.swing.StandardDialog;
import ch.psi.utils.swing.SwingUtils;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
/**
*
*/
public class MainPanel extends Panel {
/** Creates new form Panel */
public MainPanel() {
initComponents();
/**
* Creates new form Panel
*/
public MainPanel() {
initComponents();
getContext().getPluginManager().addDynamicClass(PuckDetection.class);
Controller.createInstance(this);
basePlatePanel.setMode(BasePlatePanel.Mode.single);
basePlatePanel.setMode(BasePlatePanel.Mode.single);
labelRoomTemperature.setVisible(false);
labeManualMode.setVisible(false);
setExpertMode(false);
setDefaultDetail();
}
@Override
protected void onLoaded(){
if (App.isDetached()){
@Override
protected void onLoaded() {
if (App.isDetached()) {
Image img = new ImageIcon(this.getClass().getResource("/apple_transparent_white_100x50.png")).getImage();
SwingUtils.getWindow(this).setIconImage(img);
SwingUtils.getWindow(this).setIconImage(img);
}
}
@Override
public void onInitialize(int runCount) {
@Override
public void onInitialize(int runCount) {
stopTimer();
Controller.getInstance().onInitialize(runCount);
basePlatePanel.setDevice((Device) getDevice("BasePlate"));
basePlatePanel.getDevice().setSelectable(true);
try{
basePlatePanel.setDevice((Device) getDevice("BasePlate"));
basePlatePanel.getDevice().setSelectable(true);
try {
devicesPanel.initialize();
((Device) getDevice("dewar_level")).addListener(new DeviceAdapter() {
@Override
@@ -74,7 +87,7 @@ public class MainPanel extends Panel {
updateFillingDeware(value);
}
});
updateFillingDeware(((Device) getDevice("filling_dewar")).take());
updateFillingDeware(((Device) getDevice("filling_dewar")).take());
((Device) getDevice("ln2_main_power")).addListener(new DeviceAdapter() {
@Override
@@ -82,7 +95,7 @@ public class MainPanel extends Panel {
updateFillingControl(value);
}
});
updateFillingControl(((Device) getDevice("ln2_main_power")).take());
updateFillingControl(((Device) getDevice("ln2_main_power")).take());
((Device) getDevice("air_pressure_ok")).addListener(new DeviceAdapter() {
@Override
@@ -114,10 +127,11 @@ public class MainPanel extends Panel {
updatePsysSafety(value);
}
});
updatePsysSafety(((Device) getDevice("feedback_psys_safety")).take());
} catch (Exception ex){
this.getLogger().log(Level.SEVERE,null, ex);
updatePsysSafety(((Device) getDevice("feedback_psys_safety")).take());
} catch (Exception ex) {
this.getLogger().log(Level.SEVERE, null, ex);
}
Controller.getInstance().updatePuckTypes();
startTimer(10000, 1000);
updateCameraView();
@@ -126,230 +140,233 @@ public class MainPanel extends Panel {
@Override
protected void onTimer() {
devicesPanel.update();
try{
try {
labelRoomTemperature.setVisible(Controller.getInstance().isRoomTemp());
} catch( Exception ex){
} catch (Exception ex) {
labelRoomTemperature.setVisible(false);
}
try{
try {
labeManualMode.setVisible(Controller.getInstance().isManualMode());
} catch( Exception ex){
} catch (Exception ex) {
labeManualMode.setVisible(false);
}
}
void updateLevel(Object value){
if ((value == null) || !(value instanceof Number)){
}
}
void updateLevel(Object value) {
if ((value == null) || !(value instanceof Number)) {
progressLN2.setIndeterminate(true);
} else {
progressLN2.setIndeterminate(false);
double val = ((Number)value).doubleValue() * 10.0;
progressLN2.setValue(Math.min(Math.max((int)val, 0), 1000));
}
double val = ((Number) value).doubleValue() * 10.0;
progressLN2.setValue(Math.min(Math.max((int) val, 0), 1000));
}
}
void updateFillingDeware(Object value){
if ((value == null) || !(value instanceof Boolean)){
void updateFillingDeware(Object value) {
if ((value == null) || !(value instanceof Boolean)) {
ledFillingDewar.setColor(Color.BLACK);
} else if ((Boolean)value){
} else if ((Boolean) value) {
ledFillingDewar.setColor(Color.GREEN);
} else {
ledFillingDewar.setColor(Color.BLACK);
}
}
void updateFillingControl(Object value){
if ((value == null) || !(value instanceof Boolean)){
}
}
void updateFillingControl(Object value) {
if ((value == null) || !(value instanceof Boolean)) {
ledFillingControl.setColor(Color.BLACK);
} else if ((Boolean)value){
} else if ((Boolean) value) {
ledFillingControl.setColor(Color.GREEN);
} else {
ledFillingControl.setColor(Color.BLACK);
}
}
void updateAirPressure(Object value){
if ((value == null) || !(value instanceof Boolean)){
}
}
void updateAirPressure(Object value) {
if ((value == null) || !(value instanceof Boolean)) {
ledAirPressure.setColor(Color.BLACK);
} else if ((Boolean)value){
} else if ((Boolean) value) {
ledAirPressure.setColor(Color.GREEN);
} else {
ledAirPressure.setColor(Color.RED);
}
}
void updateN2Pressure(Object value){
if ((value == null) || !(value instanceof Boolean)){
}
}
void updateN2Pressure(Object value) {
if ((value == null) || !(value instanceof Boolean)) {
ledN2Pressure.setColor(Color.BLACK);
} else if ((Boolean)value){
} else if ((Boolean) value) {
ledN2Pressure.setColor(Color.GREEN);
} else {
ledN2Pressure.setColor(Color.RED);
}
}
}
}
void updateLocalSafety(Object value){
if ((value == null) || !(value instanceof Boolean)){
void updateLocalSafety(Object value) {
if ((value == null) || !(value instanceof Boolean)) {
ledLocalSafety.setColor(Color.BLACK);
} else if ((Boolean)value){
} else if ((Boolean) value) {
ledLocalSafety.setColor(Color.GREEN);
} else {
ledLocalSafety.setColor(Color.RED);
}
}
}
}
void updatePsysSafety(Object value){
if ((value == null) || !(value instanceof Boolean)){
void updatePsysSafety(Object value) {
if ((value == null) || !(value instanceof Boolean)) {
ledPsysSafety.setColor(Color.BLACK);
} else if ((Boolean)value){
} else if ((Boolean) value) {
ledPsysSafety.setColor(Color.GREEN);
} else {
ledPsysSafety.setColor(Color.RED);
}
}
void updateCameraView(){
Source source = buttonCamera.isSelected() ? (Source)this.getDevice("img"): null;
basePlatePanel.setCameraView(source);
}
}
void execute(String statement){
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){
void execute(String statement, boolean background) {
execute(statement, background, false);
}
void execute(String statement, boolean background, boolean showReturn){
void execute(String statement, boolean background, boolean showReturn) {
try {
evalAsync(statement, background).handle((ret, ex) -> {
if (ex != null){
showException((Exception)ex);
} else if (showReturn){
if (ex != null) {
showException((Exception) ex);
} else if (showReturn) {
showMessage("Return", String.valueOf(ret));
}
return ret;
});
} catch (Exception ex) {
showException(ex);
}
}
}
void execute(String script, Object args, boolean background, boolean showReturn){
void execute(String script, Object args, boolean background, boolean showReturn) {
try {
runAsync(script, args, background).handle((ret, ex) -> {
if (ex != null){
showException((Exception)ex);
} else if (showReturn){
if (ex != null) {
showException((Exception) ex);
} else if (showReturn) {
showMessage("Return", String.valueOf(ret));
}
return ret;
});
} catch (Exception ex) {
showException(ex);
}
}
void updateViewType(){
try{
}
}
void updateViewType() {
try {
updateCameraView();
} catch (Exception ex) {
showException(ex);
}
}
}
boolean viewDewar = true;
RoomTempBasePlatePanel roomTempPanel;
void updateViewMode(){
try{
if (btViewDewar.isSelected() != viewDewar){
void updateViewMode() {
try {
if (btViewDewar.isSelected() != viewDewar) {
viewDewar = btViewDewar.isSelected();
if (viewDewar){
((GroupLayout)getLayout()).replace(roomTempPanel, basePlatePanel);
if (viewDewar) {
((GroupLayout) getLayout()).replace(roomTempPanel, basePlatePanel);
} else {
if (roomTempPanel == null){
if (roomTempPanel == null) {
roomTempPanel = new RoomTempBasePlatePanel();
roomTempPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("RT Humidifier"));
}
((GroupLayout)getLayout()).replace(basePlatePanel, roomTempPanel);
((GroupLayout) getLayout()).replace(basePlatePanel, roomTempPanel);
}
}
} catch (Exception ex) {
showException(ex);
}
}
}
void setExpertMode(boolean expert){
void setExpertMode(boolean expert) {
buttonExpertCommands.setVisible(expert);
buttonRecovery.setVisible(expert);
buttonCalibrateImage.setVisible(expert);
buttonCalibrateCover.setVisible(expert);
devicesPanel.setActive(expert);
buttonRelease.setVisible(expert);
panelViewType.setVisible(expert);
panelDetection.setVisible(expert);
if (checkExpert.isSelected()!=expert){
checkExpert.setSelected(expert);
buttonDetectCover.setVisible(expert);
buttonConfig.setVisible(expert);
if (checkExpert.isSelected() != expert) {
checkExpert.setSelected(expert);
}
if (expert==false){
if (expert == false) {
buttonCamera.setSelected(false);
buttonDrawing.setSelected(true);
updateViewType();
updateViewType();
}
}
Plugin commandsPlugin;
void showCommandsPanel(){
if (commandsPlugin!=null){
void showCommandsPanel() {
if (commandsPlugin != null) {
getContext().getPluginManager().unloadPlugin(commandsPlugin);
}
commandsPlugin = getContext().getPluginManager().loadInitializePlugin(getContext().getSetup().expandPath("{plugins}/Commands.java"));
}
Plugin recoveryPlugin;
void showRecoveryPanel(){
if (recoveryPlugin!=null){
void showRecoveryPanel() {
if (recoveryPlugin != null) {
getContext().getPluginManager().unloadPlugin(recoveryPlugin);
}
recoveryPlugin = getContext().getPluginManager().loadInitializePlugin(getContext().getSetup().expandPath("{plugins}/Recovery.java"));
recoveryPlugin = getContext().getPluginManager().loadInitializePlugin(getContext().getSetup().expandPath("{plugins}/Recovery.java"));
}
void setDefaultDetail() {
void setDefaultDetail() {
JLabel label = new JLabel();
label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/apple_transparent_white_100x50.png")));
JPanel panel = new JPanel();
label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/apple_transparent_white_100x50.png")));
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
panel.add(label);
setDetail(panel);
//setContext(label);
}
void setDetail(Component c) {
panelContext.removeAll();
panelContext.setLayout(new BorderLayout());
panelContext.setLayout(new BorderLayout());
//panelContext.setLayout(new GridBagLayout());
panelContext.add(c);
updateUI();
}
Component getDetail() {
return this.getComponent(0);
}
Dimension getDetailSize(){
Dimension getDetailSize() {
return panelContext.getSize();
}
/** 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.
/**
* 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
@@ -372,6 +389,7 @@ public class MainPanel extends Panel {
buttonPuckDet = new javax.swing.JButton();
panelHexiposi = new javax.swing.JPanel();
hexiposiPanel = new ch.psi.mxsc.HexiposiPanel();
buttonDetectCover = new javax.swing.JButton();
panelViewType = new javax.swing.JPanel();
buttonCamera = new javax.swing.JToggleButton();
buttonDrawing = new javax.swing.JToggleButton();
@@ -392,6 +410,8 @@ public class MainPanel extends Panel {
buttonExpertCommands = new javax.swing.JButton();
buttonRecovery = new javax.swing.JButton();
buttonCalibrateImage = new javax.swing.JButton();
buttonCalibrateCover = new javax.swing.JButton();
buttonConfig = new javax.swing.JButton();
jPanel4 = new javax.swing.JPanel();
ledFillingControl = new ch.psi.pshell.swing.Led();
ledFillingDewar = new ch.psi.pshell.swing.Led();
@@ -533,11 +553,11 @@ public class MainPanel extends Panel {
panelDetectionLayout.setHorizontalGroup(
panelDetectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelDetectionLayout.createSequentialGroup()
.addContainerGap(12, Short.MAX_VALUE)
.addContainerGap(14, Short.MAX_VALUE)
.addGroup(panelDetectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(buttonClearDet, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonPuckDet, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(12, Short.MAX_VALUE))
.addContainerGap(14, Short.MAX_VALUE))
);
panelDetectionLayout.setVerticalGroup(
panelDetectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -550,22 +570,34 @@ public class MainPanel extends Panel {
);
panelHexiposi.setBorder(javax.swing.BorderFactory.createTitledBorder("Cover"));
panelHexiposi.setPreferredSize(new java.awt.Dimension(112, 153));
buttonDetectCover.setText("Image");
buttonDetectCover.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonDetectCoverActionPerformed(evt);
}
});
javax.swing.GroupLayout panelHexiposiLayout = new javax.swing.GroupLayout(panelHexiposi);
panelHexiposi.setLayout(panelHexiposiLayout);
panelHexiposiLayout.setHorizontalGroup(
panelHexiposiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelHexiposiLayout.createSequentialGroup()
.addGap(0, 4, Short.MAX_VALUE)
.addComponent(hexiposiPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 4, Short.MAX_VALUE))
.addContainerGap(13, Short.MAX_VALUE)
.addGroup(panelHexiposiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(buttonDetectCover)
.addComponent(hexiposiPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(14, Short.MAX_VALUE))
);
panelHexiposiLayout.setVerticalGroup(
panelHexiposiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelHexiposiLayout.createSequentialGroup()
.addGap(0, 24, Short.MAX_VALUE)
.addContainerGap(15, Short.MAX_VALUE)
.addComponent(hexiposiPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(35, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
.addComponent(buttonDetectCover)
.addContainerGap())
);
panelViewType.setBorder(javax.swing.BorderFactory.createTitledBorder("View"));
@@ -578,7 +610,7 @@ public class MainPanel extends Panel {
});
buttonDrawing.setSelected(true);
buttonDrawing.setText("Drawing");
buttonDrawing.setText("Design");
buttonDrawing.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonDrawingActionPerformed(evt);
@@ -590,11 +622,11 @@ public class MainPanel extends Panel {
panelViewTypeLayout.setHorizontalGroup(
panelViewTypeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelViewTypeLayout.createSequentialGroup()
.addGap(2, 2, 2)
.addGroup(panelViewTypeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(buttonCamera, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonDrawing))
.addGap(2, 2, 2))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(panelViewTypeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(buttonDrawing)
.addComponent(buttonCamera))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
panelViewTypeLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonCamera, buttonDrawing});
@@ -616,16 +648,16 @@ public class MainPanel extends Panel {
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, basePlatePanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(basePlatePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(panelLegend, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(panelDetection, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(panelDetection, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(panelLegend, 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)
.addGroup(basePlatePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(panelViewType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(panelHexiposi, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(panelHexiposi, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(panelViewType, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
basePlatePanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {panelDetection, panelHexiposi, panelLegend, panelViewType});
basePlatePanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {panelDetection, panelViewType});
basePlatePanelLayout.setVerticalGroup(
basePlatePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -685,11 +717,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(65, Short.MAX_VALUE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, 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, 61, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, 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)
@@ -774,6 +806,20 @@ public class MainPanel extends Panel {
}
});
buttonCalibrateCover.setText("Cover Ref");
buttonCalibrateCover.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonCalibrateCoverActionPerformed(evt);
}
});
buttonConfig.setText("Config");
buttonConfig.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonConfigActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
@@ -786,7 +832,9 @@ public class MainPanel extends Panel {
.addComponent(buttonExpertCommands, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(checkExpert, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonRecovery, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonCalibrateImage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(buttonCalibrateImage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonCalibrateCover, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonConfig, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
jPanel5Layout.setVerticalGroup(
@@ -799,11 +847,15 @@ public class MainPanel extends Panel {
.addComponent(checkExpert)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonExpertCommands)
.addGap(18, 18, 18)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(buttonRecovery)
.addGap(18, 18, 18)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(buttonCalibrateImage)
.addGap(49, 49, 49))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(buttonCalibrateCover)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(buttonConfig)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("LN2 Control"));
@@ -1158,9 +1210,8 @@ public class MainPanel extends Panel {
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel8, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel12, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jPanel8, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel12, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel10, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
@@ -1171,15 +1222,15 @@ public class MainPanel extends Panel {
private void buttonCameraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCameraActionPerformed
buttonDrawing.setSelected(!buttonCamera.isSelected());
updateViewType();
updateViewType();
}//GEN-LAST:event_buttonCameraActionPerformed
private void buttonExpertCommandsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExpertCommandsActionPerformed
try{
try {
showCommandsPanel();
} catch (Exception ex) {
showException(ex);
}
}
}//GEN-LAST:event_buttonExpertCommandsActionPerformed
//Dialog dlgDetPlot;
@@ -1188,9 +1239,9 @@ public class MainPanel extends Panel {
JComponent dlgDetPlotComp;
JComponent dlgDetTextComp;
JComponent dlgDetRendererComp;
private void buttonPuckDetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPuckDetActionPerformed
try{
try {
/*
if ((dlgDetPlot == null) || (!dlgDetPlot.isShowing())){
dlgDetPlotComp = new ch.psi.pshell.plot.LinePlotJFree();
@@ -1202,27 +1253,27 @@ public class MainPanel extends Panel {
((javax.swing.JTextArea)dlgDetTextComp).setEditable(false);
dlgDetText = SwingUtils.showDialog(getTopLevel(), "Puck Detection", new Dimension(600,400), dlgDetTextComp);
}
*/
if (!App.isDetached()){
if ((dlgDetRenderer == null)|| (!dlgDetRenderer.isShowing())){
*/
if (!App.isDetached()) {
if ((dlgDetRenderer == null) || (!dlgDetRenderer.isShowing())) {
dlgDetRendererComp = new Renderer();
((Renderer)dlgDetRendererComp).setMode(RendererMode.Fit);
dlgDetRenderer = SwingUtils.showDialog(getTopLevel(), "Puck Detection", new Dimension(600,400), dlgDetRendererComp);
}
((Renderer) dlgDetRendererComp).setMode(RendererMode.Fit);
dlgDetRenderer = SwingUtils.showDialog(getTopLevel(), "Puck Detection", new Dimension(600, 400), dlgDetRendererComp);
}
}
Controller.getInstance().imageDetectPucks(dlgDetPlotComp, dlgDetRendererComp, dlgDetTextComp);
} catch (Exception ex) {
showException(ex);
}
}
}//GEN-LAST:event_buttonPuckDetActionPerformed
private void buttonClearDetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonClearDetActionPerformed
try{
try {
Controller.getInstance().clearImageDetection();
} catch (Exception ex) {
showException(ex);
}
}
}//GEN-LAST:event_buttonClearDetActionPerformed
private void buttonReleaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReleaseActionPerformed
@@ -1253,25 +1304,78 @@ public class MainPanel extends Panel {
}//GEN-LAST:event_btViewRTActionPerformed
private void buttonRecoveryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRecoveryActionPerformed
try{
try {
showRecoveryPanel();
} catch (Exception ex) {
showException(ex);
}
}
}//GEN-LAST:event_buttonRecoveryActionPerformed
private void buttonCalibrateImageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCalibrateImageActionPerformed
execute("imgproc/CameraCalibration", null, false, true);
}//GEN-LAST:event_buttonCalibrateImageActionPerformed
private void buttonDetectCoverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDetectCoverActionPerformed
try {
execute("cover_detection_debug=True");
runAsync("imgproc/CoverDetection", null, false).handle((ret, ex) -> {
execute("cover_detection_debug=False", true);
if (ex != null) {
showException((Exception) ex);
} else {
showMessage("Return", String.valueOf(ret));
}
return ret;
});
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonDetectCoverActionPerformed
private void buttonCalibrateCoverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCalibrateCoverActionPerformed
execute("imgproc/CoverDetectionCalibration", null, false, true);
}//GEN-LAST:event_buttonCalibrateCoverActionPerformed
private void buttonConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConfigActionPerformed
try {
final PropertiesDialog dlg = new PropertiesDialog((Frame) getTopLevelAncestor(), false);
dlg.setTitle("System Configuration");
Properties props = new Properties();
String fileName = getSessionPath() + "/OpenedFiles.dat";
try (FileInputStream in = new FileInputStream(fileName)) {
props.load(in);
}
dlg.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
dlg.setListener((StandardDialog sd, boolean accepted) -> {
if (sd.getResult()) {
try (FileOutputStream out = new FileOutputStream(fileName);) {
props.store(out, null);
} catch (IOException ex) {
SwingUtils.showException(MainPanel.this, ex);
}
}
});
dlg.setVisible(true);
SwingUtils.centerComponent(getTopLevelAncestor(), dlg);
dlg.requestFocus();
} catch (Exception ex) {
SwingUtils.showException(MainPanel.this, ex);
}
}//GEN-LAST:event_buttonConfigActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private ch.psi.mxsc.BasePlatePanel basePlatePanel;
private javax.swing.JToggleButton btViewDewar;
private javax.swing.JToggleButton btViewRT;
private javax.swing.JButton buttonCalibrateCover;
private javax.swing.JButton buttonCalibrateImage;
private javax.swing.JToggleButton buttonCamera;
private javax.swing.JButton buttonClearDet;
private javax.swing.JButton buttonConfig;
private javax.swing.JButton buttonDetectCover;
private javax.swing.JToggleButton buttonDrawing;
private javax.swing.JButton buttonExpertCommands;
private javax.swing.JButton buttonInitHexiposi1;