This commit is contained in:
gac-S_Changer
2018-08-10 09:56:46 +02:00
parent f268369797
commit 8ee20fa0ca
4 changed files with 56 additions and 16 deletions

View File

@@ -14,6 +14,7 @@ import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Ellipse2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.ArrayList;
@@ -230,6 +231,7 @@ public class BasePlate extends DeviceBase {
boundingBox = new Rectangle((int)(plotRect.x+plotRect.width*0.05), (int)(plotRect.y+plotRect.height * 0.05), (int)(plotRect.width*0.90), (int)(plotRect.height*0.90));
if (img!=null){
img = Utils.stretch(img, boundingBox.width, boundingBox.height);
g.setClip(new Ellipse2D.Float(boundingBox.x, boundingBox.y, boundingBox.width, boundingBox.height));
g.drawImage(img, boundingBox.x, boundingBox.y, null);
}
boolean drawBackground = (img==null);

View File

@@ -173,6 +173,18 @@ public class Controller {
}
}
public String getWorkingMode(){
try {
return String.valueOf(getMainFrame().eval("robot.working_mode", true));
} catch (Exception ex) {
return "Unknown";
}
}
public boolean isLocalMode(){
return getWorkingMode().equals("local");
}
public void imageDetectPucks() throws Context.ContextStateException {
imageDetectPucks(null, null, null);
}

View File

@@ -589,6 +589,7 @@
<Component id="buttonExpertCommands" max="32767" attributes="0"/>
<Component id="checkExpert" max="32767" attributes="0"/>
<Component id="buttonRecovery" max="32767" attributes="0"/>
<Component id="buttonCalibrateImage" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@@ -601,13 +602,15 @@
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="35" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="17" max="-2" attributes="0"/>
<Component id="checkExpert" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonExpertCommands" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="buttonRecovery" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="buttonCalibrateImage" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="49" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -643,6 +646,14 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonRecoveryActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonCalibrateImage">
<Properties>
<Property name="text" type="java.lang.String" value="Calibrate"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCalibrateImageActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel4">

View File

@@ -39,12 +39,7 @@ public class MainPanel extends Panel {
Controller.createInstance(this);
basePlatePanel.setMode(BasePlatePanel.Mode.single);
labelRoomTemperature.setVisible(false);
buttonExpertCommands.setVisible(false);
buttonRecovery.setVisible(false);
buttonReleaseLocal.setVisible(false);
buttonReleasePsys.setVisible(false);
panelViewType.setVisible(false);
panelDetection.setVisible(false);
setExpertMode(false);
setDefaultDetail();
}
@@ -226,7 +221,7 @@ public class MainPanel extends Panel {
if (ex != null){
showException((Exception)ex);
} else if (showReturn){
SwingUtils.showMessage(getTopLevel(), "Return", String.valueOf(ret));
showMessage("Return", String.valueOf(ret));
}
return ret;
});
@@ -236,11 +231,13 @@ public class MainPanel extends Panel {
}
void execute(String script, Object args){
void execute(String script, Object args, boolean background, boolean showReturn){
try {
runAsync(script, args).handle((ret, ex) -> {
runAsync(script, args, background).handle((ret, ex) -> {
if (ex != null){
showException((Exception)ex);
} else if (showReturn){
showMessage("Return", String.valueOf(ret));
}
return ret;
});
@@ -284,6 +281,7 @@ public class MainPanel extends Panel {
void setExpertMode(boolean expert){
buttonExpertCommands.setVisible(expert);
buttonRecovery.setVisible(expert);
buttonCalibrateImage.setVisible(expert);
devicesPanel.setActive(expert);
buttonReleaseLocal.setVisible(expert);
buttonReleasePsys.setVisible(expert);
@@ -311,6 +309,7 @@ public class MainPanel extends Panel {
recoveryPlugin = getContext().getPluginManager().loadInitializePlugin(getContext().getSetup().expandPath("{plugins}/Recovery.java"));
}
void setDefaultDetail() {
JLabel label = new JLabel();
label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/apple_transparent_white_100x50.png")));
@@ -382,6 +381,7 @@ public class MainPanel extends Panel {
checkExpert = new javax.swing.JCheckBox();
buttonExpertCommands = new javax.swing.JButton();
buttonRecovery = new javax.swing.JButton();
buttonCalibrateImage = new javax.swing.JButton();
jPanel4 = new javax.swing.JPanel();
ledFillingControl = new ch.psi.pshell.swing.Led();
ledFillingDewar = new ch.psi.pshell.swing.Led();
@@ -757,6 +757,13 @@ public class MainPanel extends Panel {
}
});
buttonCalibrateImage.setText("Calibrate");
buttonCalibrateImage.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonCalibrateImageActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
@@ -768,7 +775,8 @@ public class MainPanel extends Panel {
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.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(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))
.addContainerGap())
);
jPanel5Layout.setVerticalGroup(
@@ -777,13 +785,15 @@ public class MainPanel extends Panel {
.addComponent(devicesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(9, 9, 9))
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(35, 35, 35)
.addGap(17, 17, 17)
.addComponent(checkExpert)
.addGap(18, 18, 18)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonExpertCommands)
.addGap(18, 18, 18)
.addComponent(buttonRecovery)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addComponent(buttonCalibrateImage)
.addGap(49, 49, 49))
);
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("LN2 Control"));
@@ -1246,11 +1256,16 @@ public class MainPanel extends Panel {
}
}//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
// 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 buttonCalibrateImage;
private javax.swing.JToggleButton buttonCamera;
private javax.swing.JButton buttonClearDet;
private javax.swing.JToggleButton buttonDrawing;