diff --git a/plugins/Expert.form b/plugins/Expert.form
index a60bd7a..ad0bdd6 100644
--- a/plugins/Expert.form
+++ b/plugins/Expert.form
@@ -19,13 +19,13 @@
-
+
-
+
-
-
-
+
+
+
@@ -33,23 +33,23 @@
-
-
-
-
+
+
+
+
-
+
-
+
-
+
@@ -115,36 +115,23 @@
-
-
-
-
-
-
+
+
+
-
-
-
+
-
+
-
-
-
-
-
-
-
-
@@ -155,7 +142,7 @@
-
+
@@ -207,7 +194,7 @@
-
+
@@ -223,7 +210,7 @@
-
+
@@ -237,66 +224,49 @@
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
@@ -305,42 +275,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -349,6 +283,154 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/Expert.java b/plugins/Expert.java
index 9cd7d2a..0af247a 100644
--- a/plugins/Expert.java
+++ b/plugins/Expert.java
@@ -5,8 +5,11 @@
import ch.psi.pshell.core.Context;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
+import ch.psi.utils.swing.SwingUtils;
+import java.awt.Component;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.swing.JComponent;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
@@ -29,7 +32,10 @@ public class Expert extends Panel {
@Override
public void onStateChange(State state, State former) {
-
+ for (Component c: SwingUtils.getComponentsByType(panelCommands, JComponent.class)){
+ c.setEnabled(state == State.Ready);
+ }
+ buttonHomingHexiposi.setEnabled(state == State.Ready);
}
@Override
@@ -70,33 +76,41 @@ public class Expert extends Panel {
showException(ex);
}
}
+
+
@SuppressWarnings("unchecked")
// //GEN-BEGIN:initComponents
private void initComponents() {
- jPanel1 = new javax.swing.JPanel();
+ panelRobot = new javax.swing.JPanel();
buttonEnable = new javax.swing.JButton();
buttonDisable = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
- buttonHomingHexiposi = new javax.swing.JButton();
buttonPositionsHexiposi = new javax.swing.JButton();
- jPanel3 = new javax.swing.JPanel();
+ panelSafety = new javax.swing.JPanel();
buttonReleasePsys = new javax.swing.JButton();
buttonEnableAll = new javax.swing.JButton();
buttonReleaseLocal = new javax.swing.JButton();
- jPanel4 = new javax.swing.JPanel();
- spinnerSample = new javax.swing.JSpinner();
- checkForce = new javax.swing.JCheckBox();
+ panelCommands = new javax.swing.JPanel();
buttonMount = new javax.swing.JButton();
- jLabel1 = new javax.swing.JLabel();
- spinnerSegment = new javax.swing.JSpinner();
- jLabel2 = new javax.swing.JLabel();
- spinnerPuck = new javax.swing.JSpinner();
- jLabel3 = new javax.swing.JLabel();
buttonUnmount = new javax.swing.JButton();
+ buttonGetDewar = new javax.swing.JButton();
+ buttonPutDewar = new javax.swing.JButton();
+ buttonGetGonio = new javax.swing.JButton();
+ buttonPutGonio = new javax.swing.JButton();
+ jPanel5 = new javax.swing.JPanel();
+ jLabel4 = new javax.swing.JLabel();
+ checkForce = new javax.swing.JCheckBox();
+ spinnerSample = new javax.swing.JSpinner();
+ spinnerPuck = new javax.swing.JSpinner();
+ jLabel1 = new javax.swing.JLabel();
+ jLabel2 = new javax.swing.JLabel();
+ spinnerSegment = new javax.swing.JSpinner();
+ jLabel3 = new javax.swing.JLabel();
+ buttonHomingHexiposi = new javax.swing.JButton();
- jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Robot"));
+ panelRobot.setBorder(javax.swing.BorderFactory.createTitledBorder("Robot"));
buttonEnable.setText("Enable");
buttonEnable.addActionListener(new java.awt.event.ActionListener() {
@@ -112,23 +126,23 @@ public class Expert extends Panel {
}
});
- javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
- jPanel1.setLayout(jPanel1Layout);
- jPanel1Layout.setHorizontalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
+ javax.swing.GroupLayout panelRobotLayout = new javax.swing.GroupLayout(panelRobot);
+ panelRobot.setLayout(panelRobotLayout);
+ panelRobotLayout.setHorizontalGroup(
+ panelRobotLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelRobotLayout.createSequentialGroup()
.addContainerGap(78, Short.MAX_VALUE)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelRobotLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(buttonEnable)
.addComponent(buttonDisable))
.addContainerGap(79, Short.MAX_VALUE))
);
- jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonDisable, buttonEnable});
+ panelRobotLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonDisable, buttonEnable});
- jPanel1Layout.setVerticalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
+ panelRobotLayout.setVerticalGroup(
+ panelRobotLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelRobotLayout.createSequentialGroup()
.addContainerGap()
.addComponent(buttonEnable)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@@ -138,13 +152,6 @@ public class Expert extends Panel {
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Hexiposi"));
- buttonHomingHexiposi.setText("Homing");
- buttonHomingHexiposi.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- buttonHomingHexiposiActionPerformed(evt);
- }
- });
-
buttonPositionsHexiposi.setText("Positions");
buttonPositionsHexiposi.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@@ -157,26 +164,19 @@ public class Expert extends Panel {
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
- .addContainerGap(75, Short.MAX_VALUE)
- .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(buttonHomingHexiposi)
- .addComponent(buttonPositionsHexiposi))
- .addContainerGap(75, Short.MAX_VALUE))
+ .addContainerGap(76, Short.MAX_VALUE)
+ .addComponent(buttonPositionsHexiposi)
+ .addGap(74, 74, 74))
);
-
- jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonHomingHexiposi, buttonPositionsHexiposi});
-
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(buttonHomingHexiposi)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addContainerGap(19, Short.MAX_VALUE)
.addComponent(buttonPositionsHexiposi)
- .addContainerGap())
+ .addContainerGap(32, Short.MAX_VALUE))
);
- jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Safety"));
+ panelSafety.setBorder(javax.swing.BorderFactory.createTitledBorder("Safety"));
buttonReleasePsys.setText("Release PSYS");
buttonReleasePsys.addActionListener(new java.awt.event.ActionListener() {
@@ -185,7 +185,7 @@ public class Expert extends Panel {
}
});
- buttonEnableAll.setText("Enable All");
+ buttonEnableAll.setText("Enable Motion");
buttonEnableAll.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonEnableAllActionPerformed(evt);
@@ -199,37 +199,33 @@ public class Expert extends Panel {
}
});
- javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
- jPanel3.setLayout(jPanel3Layout);
- jPanel3Layout.setHorizontalGroup(
- jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel3Layout.createSequentialGroup()
+ javax.swing.GroupLayout panelSafetyLayout = new javax.swing.GroupLayout(panelSafety);
+ panelSafety.setLayout(panelSafetyLayout);
+ panelSafetyLayout.setHorizontalGroup(
+ panelSafetyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelSafetyLayout.createSequentialGroup()
.addContainerGap()
- .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addGroup(panelSafetyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(buttonEnableAll, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGroup(jPanel3Layout.createSequentialGroup()
+ .addGroup(panelSafetyLayout.createSequentialGroup()
.addComponent(buttonReleasePsys)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(buttonReleaseLocal)))
.addContainerGap())
);
- jPanel3Layout.setVerticalGroup(
- jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel3Layout.createSequentialGroup()
+ panelSafetyLayout.setVerticalGroup(
+ panelSafetyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelSafetyLayout.createSequentialGroup()
.addContainerGap()
.addComponent(buttonEnableAll)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addGroup(panelSafetyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonReleaseLocal)
.addComponent(buttonReleasePsys))
.addContainerGap())
);
- jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Commands"));
-
- spinnerSample.setModel(new javax.swing.SpinnerNumberModel(1, 1, 16, 1));
-
- checkForce.setText("Force");
+ panelCommands.setBorder(javax.swing.BorderFactory.createTitledBorder("Commands"));
buttonMount.setText("Mount");
buttonMount.addActionListener(new java.awt.event.ActionListener() {
@@ -238,16 +234,6 @@ public class Expert extends Panel {
}
});
- jLabel1.setText("Segment:");
-
- spinnerSegment.setModel(new javax.swing.SpinnerListModel(new String[] {"A", "B", "C", "D", "E", "F"}));
-
- jLabel2.setText("Puck:");
-
- spinnerPuck.setModel(new javax.swing.SpinnerNumberModel(1, 1, 5, 1));
-
- jLabel3.setText("Sample:");
-
buttonUnmount.setText("Unmount");
buttonUnmount.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@@ -255,54 +241,144 @@ public class Expert extends Panel {
}
});
- javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
- jPanel4.setLayout(jPanel4Layout);
- jPanel4Layout.setHorizontalGroup(
- jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel4Layout.createSequentialGroup()
+ buttonGetDewar.setText("Get Dewar");
+ buttonGetDewar.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonGetDewarActionPerformed(evt);
+ }
+ });
+
+ buttonPutDewar.setText("Put Dewar");
+ buttonPutDewar.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonPutDewarActionPerformed(evt);
+ }
+ });
+
+ buttonGetGonio.setText("Get Gonio");
+ buttonGetGonio.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonGetGonioActionPerformed(evt);
+ }
+ });
+
+ buttonPutGonio.setText("Put Gonio");
+ buttonPutGonio.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonPutGonioActionPerformed(evt);
+ }
+ });
+
+ jLabel4.setText("Force:");
+
+ checkForce.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
+
+ spinnerSample.setModel(new javax.swing.SpinnerNumberModel(1, 1, 16, 1));
+
+ spinnerPuck.setModel(new javax.swing.SpinnerNumberModel(1, 1, 5, 1));
+
+ jLabel1.setText("Segment:");
+
+ jLabel2.setText("Puck:");
+
+ spinnerSegment.setModel(new javax.swing.SpinnerListModel(new String[] {"A", "B", "C", "D", "E", "F"}));
+
+ jLabel3.setText("Sample:");
+
+ javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
+ jPanel5.setLayout(jPanel5Layout);
+ jPanel5Layout.setHorizontalGroup(
+ jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap()
- .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(buttonMount, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(buttonUnmount, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(checkForce))
- .addGap(18, 18, 18)
- .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel2)
- .addComponent(jLabel1))
+ .addComponent(jLabel1)
+ .addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(checkForce)
.addComponent(spinnerSample, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerPuck, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerSegment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(13, Short.MAX_VALUE))
+ .addContainerGap())
);
- jPanel4Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3});
+ jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3});
- jPanel4Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerPuck, spinnerSample, spinnerSegment});
+ jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerPuck, spinnerSample, spinnerSegment});
- jPanel4Layout.setVerticalGroup(
- jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel4Layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(buttonMount)
+ jPanel5Layout.setVerticalGroup(
+ jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel5Layout.createSequentialGroup()
+ .addGap(0, 0, 0)
+ .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel1)
.addComponent(spinnerSegment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel2)
- .addComponent(spinnerPuck, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(buttonUnmount))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(spinnerPuck, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel3)
- .addComponent(spinnerSample, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(spinnerSample, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
+ .addComponent(jLabel4)
.addComponent(checkForce))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
+ buttonHomingHexiposi.setText("Homing Hexiposi");
+ buttonHomingHexiposi.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonHomingHexiposiActionPerformed(evt);
+ }
+ });
+
+ javax.swing.GroupLayout panelCommandsLayout = new javax.swing.GroupLayout(panelCommands);
+ panelCommands.setLayout(panelCommandsLayout);
+ panelCommandsLayout.setHorizontalGroup(
+ panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelCommandsLayout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
+ .addComponent(buttonHomingHexiposi, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(buttonGetGonio, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(buttonPutGonio, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(buttonMount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(buttonUnmount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(buttonGetDewar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(buttonPutDewar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addGap(18, 18, 18)
+ .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap())
+ );
+ panelCommandsLayout.setVerticalGroup(
+ panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelCommandsLayout.createSequentialGroup()
+ .addGap(18, 18, 18)
+ .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addGroup(panelCommandsLayout.createSequentialGroup()
+ .addComponent(buttonMount)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(buttonUnmount)
+ .addGap(18, 18, 18)
+ .addComponent(buttonGetDewar)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(buttonPutDewar)
+ .addGap(18, 18, 18)
+ .addComponent(buttonGetGonio)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(buttonPutGonio))
+ .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addGap(18, 18, 18)
+ .addComponent(buttonHomingHexiposi)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -310,31 +386,31 @@ public class Expert extends Panel {
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(panelRobot, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(6, 6, 6)
- .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addComponent(panelSafety, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(panelCommands, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(44, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
- .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
- .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addComponent(panelCommands, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(panelSafety, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addComponent(panelRobot, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addContainerGap(21, Short.MAX_VALUE))
);
}// //GEN-END:initComponents
private void buttonEnableAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonEnableAllActionPerformed
- execute("enable_power()");
+ execute("enable_motion()", true);
}//GEN-LAST:event_buttonEnableAllActionPerformed
private void buttonMountActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMountActionPerformed
@@ -347,23 +423,23 @@ public class Expert extends Panel {
}//GEN-LAST:event_buttonMountActionPerformed
private void buttonEnableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonEnableActionPerformed
- execute("robot.enable()");
+ execute("robot.enable()", true);
}//GEN-LAST:event_buttonEnableActionPerformed
private void buttonDisableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDisableActionPerformed
- execute("robot.disable()");
+ execute("robot.disable()", true);
}//GEN-LAST:event_buttonDisableActionPerformed
private void buttonReleaseLocalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReleaseLocalActionPerformed
- execute("release_local()");
+ execute("release_local()", true);
}//GEN-LAST:event_buttonReleaseLocalActionPerformed
private void buttonReleasePsysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReleasePsysActionPerformed
- execute("release_psys()");
+ execute("release_psys()", true);
}//GEN-LAST:event_buttonReleasePsysActionPerformed
private void buttonHomingHexiposiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonHomingHexiposiActionPerformed
- execute("hexiposi.move_home()");
+ execute("homing_hexiposi()");
}//GEN-LAST:event_buttonHomingHexiposiActionPerformed
private void buttonPositionsHexiposiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPositionsHexiposiActionPerformed
@@ -378,13 +454,43 @@ public class Expert extends Panel {
execute("unmount('" + segment + "'," + puck + "," + sample + ", force=" + force + ")");
}//GEN-LAST:event_buttonUnmountActionPerformed
+ private void buttonGetDewarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonGetDewarActionPerformed
+ String segment = (String) spinnerSegment.getValue();
+ int puck = (Integer) spinnerPuck.getValue();
+ int sample = (Integer) spinnerSample.getValue();
+ String force = checkForce.isSelected() ? "True" : "False";
+ execute("get_dewar('" + segment + "'," + puck + "," + sample + ", force=" + force + ")");
+ }//GEN-LAST:event_buttonGetDewarActionPerformed
+
+ private void buttonPutDewarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPutDewarActionPerformed
+ String segment = (String) spinnerSegment.getValue();
+ int puck = (Integer) spinnerPuck.getValue();
+ int sample = (Integer) spinnerSample.getValue();
+ String force = checkForce.isSelected() ? "True" : "False";
+ execute("put_dewar('" + segment + "'," + puck + "," + sample + ", force=" + force + ")");
+ }//GEN-LAST:event_buttonPutDewarActionPerformed
+
+ private void buttonGetGonioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonGetGonioActionPerformed
+ String force = checkForce.isSelected() ? "True" : "False";
+ execute("get_gonio('force=" + force + ")");
+ }//GEN-LAST:event_buttonGetGonioActionPerformed
+
+ private void buttonPutGonioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPutGonioActionPerformed
+ String force = checkForce.isSelected() ? "True" : "False";
+ execute("put_gonio('force=" + force + ")");
+ }//GEN-LAST:event_buttonPutGonioActionPerformed
+
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonDisable;
private javax.swing.JButton buttonEnable;
private javax.swing.JButton buttonEnableAll;
+ private javax.swing.JButton buttonGetDewar;
+ private javax.swing.JButton buttonGetGonio;
private javax.swing.JButton buttonHomingHexiposi;
private javax.swing.JButton buttonMount;
private javax.swing.JButton buttonPositionsHexiposi;
+ private javax.swing.JButton buttonPutDewar;
+ private javax.swing.JButton buttonPutGonio;
private javax.swing.JButton buttonReleaseLocal;
private javax.swing.JButton buttonReleasePsys;
private javax.swing.JButton buttonUnmount;
@@ -392,10 +498,12 @@ public class Expert extends Panel {
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
- private javax.swing.JPanel jPanel1;
+ private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel2;
- private javax.swing.JPanel jPanel3;
- private javax.swing.JPanel jPanel4;
+ private javax.swing.JPanel jPanel5;
+ private javax.swing.JPanel panelCommands;
+ private javax.swing.JPanel panelRobot;
+ private javax.swing.JPanel panelSafety;
private javax.swing.JSpinner spinnerPuck;
private javax.swing.JSpinner spinnerSample;
private javax.swing.JSpinner spinnerSegment;
diff --git a/script/devices/Hexiposi.py b/script/devices/Hexiposi.py
index 9271b6a..a689677 100644
--- a/script/devices/Hexiposi.py
+++ b/script/devices/Hexiposi.py
@@ -9,7 +9,10 @@ class Hexiposi(DiscretePositionerBase):
url = "http://" + url
if not url.endswith("/"):
url = url + "/"
- self.url = url
+ self.url = url
+ self.moved = True
+ self.homing_state = State.Disabled
+ self.rback = self.UNKNOWN_POSITION
def doInitialize(self):
super(Hexiposi, self).doInitialize()
@@ -31,21 +34,29 @@ class Hexiposi(DiscretePositionerBase):
self.moving = self.status["moving"]
self.offset = self.status["offset"]
self.dpos = self.status["discretePosition"]
- if (self.homed==False): self.rback = self.UNKNOWN_POSITION
- elif self.dpos == 1: self.rback = "A"
- elif self.dpos == 2: self.rback = "B"
- elif self.dpos == 4: self.rback = "C"
- elif self.dpos == 8: self.rback = "D"
- elif self.dpos == 16: self.rback = "E"
- elif self.dpos == 32: self.rback = "F"
- else: self.rback = self.UNKNOWN_POSITION
+ if (self.homed==False): rback = self.UNKNOWN_POSITION
+ elif self.dpos == 1: rback = "A"
+ elif self.dpos == 2: rback = "B"
+ elif self.dpos == 4: rback = "C"
+ elif self.dpos == 8: rback = "D"
+ elif self.dpos == 16: rback = "E"
+ elif self.dpos == 32: rback = "F"
+ else: rback = self.UNKNOWN_POSITION
+ if (rback == self.UNKNOWN_POSITION) or (rback != self.rback):
+ self.moved = True
+ self.rback = rback
return self.status
- def move_pos(self, pos):
+ def move_pos(self, pos):
return self.get_response(requests.get(url=self.url+"set?pos=" + str(pos)))
- def move_home(self):
- return self.get_response(requests.get(url=self.url+"set?home=1"))
+ def move_home(self):
+ ret = self.get_response(requests.get(url=self.url+"set?home=1"))
+ try:
+ self.waitState(self.homing_state,1200)
+ except:
+ pass
+ return ret
def stop_move(self):
return self.get_response(requests.get(url=self.url+"set?stop=1"))
@@ -82,16 +93,26 @@ class Hexiposi(DiscretePositionerBase):
except:
pass
- def assert_in_position(self, pos):
+ def is_in_position(self, pos):
return take() == pos
+
+ def assert_in_position(self, pos):
+ if not is_in_position(pos):
+ raise Exception ("Hexiposi is not in position")
+
+ def assert_homed(self):
+ if self.homed == False:
+ raise Exception ("Hexiposi is not homed")
+
+
#def isReady(self):
# self.get_status()
# return self.moving == False
def updateState(self):
if self.homed == False:
- self.setState(State.Disabled)
+ self.setState(self.homing_state)
elif self.moving:
self.setState(State.Busy)
else:
diff --git a/script/devices/RobotSC.py b/script/devices/RobotSC.py
index 8edd495..6c9a795 100644
--- a/script/devices/RobotSC.py
+++ b/script/devices/RobotSC.py
@@ -23,13 +23,17 @@ joint_forces = False
class RobotSC(RobotTCP):
def __init__(self, name, server, timeout = 1000, retries = 1):
RobotTCP.__init__(self, name, server, timeout, retries)
- self.set_tasks(["getDewar", "putDewar", "putGonio", "getGonio", "robotRecover", "moveDewar", "movePark"])
- self.setPolling(DEFAULT_ROBOT_POLLING)
- self.known_points = ["pHome", "pPark", "pDewarHome", "pGonioHome", "pDewarWait", "pGonioGet", "pScanHome", "pHeaterHome"]
+ self.set_tasks(["getDewar", "putDewar", "putGonio", "getGonio", "robotRecover", "moveDewar", "movePark", "moveGonio","moveHeater"])
+ self.set_known_points(["pHome", "pPark", "pDewarHome", "pGonioHome", "pDewarWait", "pGonioGet", "pScanHome", "pHeaterHome"])
+ self.setPolling(DEFAULT_ROBOT_POLLING)
+ def move_dewar(self):
+ self.start_task('moveDewar')
+ self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
+ self.assert_dewar()
+
def get_dewar(self, segment, puck, sample):
segment = self.toSegmentNumber(segment)
- self.assert_dewar()
self.start_task('getDewar',segment, puck, sample)
self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
self.assert_dewar()
@@ -42,31 +46,38 @@ class RobotSC(RobotTCP):
self.assert_dewar()
def put_gonio(self):
- self.start_task('putGonio',segment, puck, sample)
+ self.start_task('putGonio')
self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
- #TODO
+ self.assert_gonio()
def get_gonio(self):
self.start_task('getGonio')
self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
- #TODO
+ self.assert_gonio()
- def robot_recover(self):
- self.start_task('robotRecover')
+ def move_gonio(self):
+ self.start_task('moveGonio')
self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
-
- def move_dewar_wait(self):
- self.start_task('moveDewar')
- self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
- self.assert_dewar_wait()
+ self.assert_gonio()
def move_park(self):
self.start_task('movePark')
self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
self.assert_park()
+ def move_heater(self):
+ self.start_task('moveHeater')
+ self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
+ self.assert_heater()
+
+
+ def robot_recover(self):
+ self.start_task('robotRecover')
+ self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
+ self.assert_dewar_home()
+
def toSegmentNumber(self, segment):
- if type(segment) == str:
+ if is_string(segment):
segment = ord(segment.upper()) - ord('A') +1
return segment
@@ -74,6 +85,9 @@ class RobotSC(RobotTCP):
def on_event(self,ev):
#print "EVT: " + ev
pass
+ def on_change_working_mode(self, working_mode):
+ if get_device("hexiposi") is not None:
+ hexiposi.moved = True #Force image processing on first sample
def doUpdate(self):
#start = time.time()
@@ -111,17 +125,24 @@ class RobotSC(RobotTCP):
def is_dewar_home(self):
return self.is_in_point("pDewarHome")
- def is_dewar_wait(self):
+ def is_dewar(self):
return self.is_in_point("pDewarWait")
+ def is_heater(self):
+ return self.is_in_point("pHeaterHome")
+
def is_gonio(self):
return self.is_in_point("pGonioHome")
def is_cleared(self):
- return self.is_home() or self.is_park() or self.is_dewarHome() or self.is_dewarWait()
+ #return self.is_home() or self.is_park() or self.is_dewar() or self.is_dewar_home()
+ return self.get_current_point() is not None
def assert_home(self):
- self.assert_in_point("pHome")
+ self.assert_in_point("pHome")
+
+ def assert_heater(self):
+ self.assert_in_point("pHeaterHome")
def assert_park(self):
self.assert_in_point("pPark")
@@ -129,7 +150,7 @@ class RobotSC(RobotTCP):
def assert_dewar_home(self):
self.assert_in_point("pDewarHome")
- def assert_dewar_wait(self):
+ def assert_dewar(self):
self.assert_in_point("pDewarWait")
def assert_gonio(self):
@@ -137,16 +158,7 @@ class RobotSC(RobotTCP):
def assert_cleared(self):
if not self.is_cleared():
- raise Exception("Robot not in cleared position")
-
- def get_current_point(self):
- ret = robot.is_in_points(*self.known_points, tolerance = 20)
- for i in range(len(ret)):
- if ret[i] == True:
- return self.known_points[i]
- return None
-
-
+ raise Exception("Robot not in cleared position")
if simulation:
#add_device(RobotSC("robot","129.129.126.92:1000"),force = True)
diff --git a/script/devices/RobotTCP.py b/script/devices/RobotTCP.py
index 11807ca..2071717 100644
--- a/script/devices/RobotTCP.py
+++ b/script/devices/RobotTCP.py
@@ -27,7 +27,8 @@ class RobotTCP(TcpDevice, Stoppable):
self.joint_forces = None
self.current_task = None
self.current_task_ret = None
- self.high_level_tasks = []
+ self.high_level_tasks = []
+ self.known_points = []
self.cartesian_destination = None
#self.flange_pos = [None] * 6
self.cartesian_pos = [None] * 6
@@ -79,6 +80,23 @@ class RobotTCP(TcpDevice, Stoppable):
def get_tasks(self):
return self.high_level_tasks
+ def set_known_points(self, points):
+ self.known_points=points
+
+ def get_known_points(self):
+ return self.known_points
+
+ def get_current_point(self, tolerance = None):
+ ret = self.is_in_points(*self.known_points, tolerance = tolerance)
+ for i in range(len(ret)):
+ if ret[i] == True:
+ return self.known_points[i]
+ return None
+
+ def assert_in_known_point(self, tolerance = None):
+ if self.get_current_point(tolerance) is None:
+ raise Exception ("Robot not in known point")
+
def _sendReceive(self, msg_id, msg = "", timeout = None):
tx = self.header if (self.header != None) else ""
tx = tx + msg_id + " " + msg
@@ -262,6 +280,7 @@ class RobotTCP(TcpDevice, Stoppable):
if str(ret) != "0": raise Exception("Error saving program: " + str(ret))
def _update_working_mode(self, mode, status):
+ cur_mode = self.working_mode
if mode==1:
self.working_mode = "manual"
self.status = "hold" if status==6 else "move"
@@ -277,6 +296,11 @@ class RobotTCP(TcpDevice, Stoppable):
else:
self.working_mode = "invalid"
self.status = "invalid"
+ if self.working_mode != cur_mode:
+ try:
+ self.on_change_working_mode(self.working_mode)
+ except:
+ pass
def read_working_mode(self):
try:
@@ -422,7 +446,7 @@ class RobotTCP(TcpDevice, Stoppable):
#Task control
def task_create(self, program, *args, **kwargs):
program = str(program)
- priority = 10 if (kwargs is None) or (not kwargs.has_key("priority")) else kwargs["priority"]
+ priority = 10 if (kwargs is None) or (not kwargs.has_key("priority")) or (kwargs["priority"] is None) else kwargs["priority"]
name = str(program if (kwargs is None) or (not kwargs.has_key("name")) else kwargs["name"])
if self.get_task_status(name)[0] != -1:
@@ -549,7 +573,8 @@ class RobotTCP(TcpDevice, Stoppable):
self.get_cartesian_pos()
return self.distance_p("tcp_p", name)
- def is_in_point(self, p, tolerance = 20): #Tolerance in mm
+ def is_in_point(self, p, tolerance = None): #Tolerance in mm
+ tolerance = 10 if tolerance == None else tolerance
d = self.get_distance_to_pnt(p)
if d<0:
raise Exception ("Error calculating distance to " + p + " : " + str(d))
@@ -566,7 +591,7 @@ class RobotTCP(TcpDevice, Stoppable):
return ret
def is_in_points(self, *pars, **kwargs): #Tolerance in mm
- tolerance = 20 if (kwargs is None) or (not kwargs.has_key("tolerance")) else kwargs["tolerance"]
+ tolerance = 10 if (kwargs is None) or (not kwargs.has_key("tolerance")) or (kwargs["tolerance"] is None) else kwargs["tolerance"]
ret = self.get_distance_to_pnts(*pars)
for i in range(len(ret)):
if ret[i]<0:
@@ -575,7 +600,7 @@ class RobotTCP(TcpDevice, Stoppable):
ret[i] = ret[i]=0:
- self.task_kill(task)
-
+ self.task_kill(task)
+ self.reset_motion()
def get_task_ret(self, cached = True):
return self.current_task_ret if cached else self.eval_int("tcp_ret")
@@ -713,8 +738,9 @@ class RobotTCP(TcpDevice, Stoppable):
time.sleep(self.polling_interval)
finally:
if polling is not None:
- self.polling = cur_polling
- return self.get_task_ret()
+ self.polling = cur_polling
+ ret = self.get_task_ret()
+ return ret
def assert_no_task(self):
task = self.check_task()
@@ -723,5 +749,7 @@ class RobotTCP(TcpDevice, Stoppable):
def on_event(self,ev):
pass
-
+
+ def on_change_working_mode(self, working_mode):
+ pass
\ No newline at end of file
diff --git a/script/imgproc/CoverDetection2.py b/script/imgproc/CoverDetection2.py
index 62eebce..315911e 100644
--- a/script/imgproc/CoverDetection2.py
+++ b/script/imgproc/CoverDetection2.py
@@ -9,8 +9,7 @@ POSITION_NAMES = [ 'A','B','C','D', 'E', 'F']
POSITION_ANGLES = [330, 30, 90, 150, 210, 270]
POSITION_TOLERANCE = 3
MINIMUM_CONFIDENCE = 10
-DEBUG = True
-PLOT = True
+DEBUG = cover_detection_debug
REFERENCE_IMG = "ref2"
#Load reference image
@@ -28,7 +27,8 @@ cx,cy = int(ip.width/2), int(ip.height/2)
ip = sub_image(ip, cx-ref.width/2, cy-ref.height/2, ref.width, ref.height)
#Show ROI of pre-processed image
-image_panel = show_panel(ip.bufferedImage)
+if DEBUG:
+ image_panel = show_panel(ip.bufferedImage)
#Calculate correlation between image and reference, rotating the reference from 0 to 360
@@ -43,8 +43,6 @@ for i in xdata:
bi = op.getBufferedImage()
p = integrateVertically(bi)
ydata.append(sum(p))
- #image_panel = show_panel(op.bufferedImage)
- #time.sleep(1.0)
#Calculate angle of the highest correlation, and confidence level
@@ -62,7 +60,7 @@ if angle is not None:
position = POSITION_NAMES[i]
#Plot the correlations values agains angle
-if PLOT:
+if DEBUG:
p = plot(ydata, xdata=xdata)[0]
#Output results
diff --git a/script/imgproc/Utils.py b/script/imgproc/Utils.py
index 57acc3b..cf7b7f5 100644
--- a/script/imgproc/Utils.py
+++ b/script/imgproc/Utils.py
@@ -18,9 +18,13 @@ def get_img_cover_pos():
def assert_img_in_cover_pos(pos = None):
if pos==None:
pos = hexiposi.take()
+ elif type(pos) is int:
+ pos = chr( ord('A') + (pos-1))
+ elif type(pos) is str:
+ pos = pos.upper()
img_segment = get_img_cover_pos()
- if img_segment != segment:
- raise Excepton ("Image detection of cover does not match hexiposi: " + str(img_segment))
+ if img_segment != pos:
+ raise Exception ("Image detection of cover does not match position: " + str(img_segment))
def in_roi(x,y):
diff --git a/script/local.py b/script/local.py
index 0e87ed0..6be6910 100644
--- a/script/local.py
+++ b/script/local.py
@@ -31,6 +31,11 @@ add_device(img.getCamera(), force = True)
run("motion/tools")
run("motion/mount")
run("motion/unmount")
+run("motion/get_dewar")
+run("motion/put_dewar")
+run("motion/get_gonio")
+run("motion/put_gonio")
+run("motion/homing_hexiposi")
run("imgproc/Utils")
run("tools/Math")
@@ -56,8 +61,8 @@ try:
release_local_safety.write(False)
release_psys_safety.write(False)
except:
- print >> sys.stderr, traceback.format_exc()
-
+ print >> sys.stderr, traceback.format_exc()
+
try:
hexiposi.polling=500
except:
@@ -103,6 +108,8 @@ except:
context = get_context()
+cover_detection_debug = False
+
update()
diff --git a/script/motion/get_dewar.py b/script/motion/get_dewar.py
new file mode 100644
index 0000000..cd2b598
--- /dev/null
+++ b/script/motion/get_dewar.py
@@ -0,0 +1,28 @@
+def get_dewar(segment, puck, sample, force=False):
+ """
+ """
+ print "get_dewar: ", segment, puck, sample, force
+
+ #Initial checks
+ assertValidAddress(segment, puck, sample)
+ robot.assert_no_task()
+ robot.reset_motion()
+ robot.state.assertReady()
+ robot.assert_cleared()
+ #robot.assert_in_known_point()
+ hexiposi.assert_homed()
+ #location = robot.get_current_point()
+
+
+ #Enabling
+ enable_motion()
+
+ set_hexiposi(segment)
+
+ if not force:
+ visual_check_hexiposi(segment)
+
+ if not robot.is_dewar():
+ robot.move_dewar()
+
+ robot.get_dewar(segment, puck, sample)
diff --git a/script/motion/get_gonio.py b/script/motion/get_gonio.py
new file mode 100644
index 0000000..bd0f768
--- /dev/null
+++ b/script/motion/get_gonio.py
@@ -0,0 +1,20 @@
+def get_gonio(force=False):
+ """
+ """
+ print "get_gonio: ", force
+
+ #Initial checks
+ robot.assert_no_task()
+ robot.reset_motion()
+ robot.state.assertReady()
+ robot.assert_cleared()
+ #robot.assert_in_known_point()
+
+ #Enabling
+ enable_motion()
+
+
+ if not robot.is_gonio():
+ robot.move_gonio()
+
+ robot.get_gonio()
diff --git a/script/motion/homing_hexiposi.py b/script/motion/homing_hexiposi.py
new file mode 100644
index 0000000..a13af94
--- /dev/null
+++ b/script/motion/homing_hexiposi.py
@@ -0,0 +1,15 @@
+def homing_hexiposi():
+ """
+ """
+ print "homing_hexiposi"
+
+ #Initial checks
+ robot.assert_no_task()
+ robot.state.assertReady()
+ robot.assert_cleared()
+ #robot.assert_in_known_point()
+ #location = robot.get_current_point()
+
+ hexiposi.move_home()
+ hexiposi.waitState(State.Ready,-1)
+
\ No newline at end of file
diff --git a/script/motion/mount.py b/script/motion/mount.py
index 92fb98b..b28cd68 100644
--- a/script/motion/mount.py
+++ b/script/motion/mount.py
@@ -6,35 +6,25 @@ def mount(segment, puck, sample, force=False):
#Initial checks
assertValidAddress(segment, puck, sample)
robot.assert_no_task()
+ robot.reset_motion()
robot.state.assertReady()
robot.assert_cleared()
-
- if hexiposi.homed == False:
- raise Exception ("Hexiposi is not homed")
+ #robot.assert_in_known_point()
+ hexiposi.assert_homed()
+ #location = robot.get_current_point()
#Enabling
enable_motion()
set_hexiposi(segment)
-
- if not force:
- #Clearing for image processing
- robot.move_park()
- assert_img_in_cover_pos(segment)
-
- location = robot.get_current_point()
- print "Location: " + location
+ if not force:
+ visual_check_hexiposi(segment)
- robot.move_dewar_wait()
- try:
- robot.get_dewar(segment, puck, sample)
- except:
- #robot.move_dewar()
- raise
-
- try:
- robot.put_gonio()
- except:
- #TODO: recover
- raise
+ if not robot.is_dewar():
+ robot.move_dewar()
+
+ robot.get_dewar(segment, puck, sample)
+ robot.move_gonio()
+ robot.put_gonio()
+ robot.move_dewar()
diff --git a/script/motion/put_dewar.py b/script/motion/put_dewar.py
new file mode 100644
index 0000000..aa3760d
--- /dev/null
+++ b/script/motion/put_dewar.py
@@ -0,0 +1,28 @@
+def put_dewar(segment, puck, sample, force=False):
+ """
+ """
+ print "put_dewar: ", segment, puck, sample, force
+
+ #Initial checks
+ assertValidAddress(segment, puck, sample)
+ robot.assert_no_task()
+ robot.reset_motion()
+ robot.state.assertReady()
+ robot.assert_cleared()
+ #robot.assert_in_known_point()
+ hexiposi.assert_homed()
+
+ #Enabling
+ enable_motion()
+
+ set_hexiposi(segment)
+
+ if not force:
+ visual_check_hexiposi(segment)
+
+ #location = robot.get_current_point()
+
+ if not robot.is_dewar():
+ robot.move_dewar()
+
+ robot.put_dewar(segment, puck, sample)
diff --git a/script/motion/put_gonio.py b/script/motion/put_gonio.py
new file mode 100644
index 0000000..b5e9f11
--- /dev/null
+++ b/script/motion/put_gonio.py
@@ -0,0 +1,18 @@
+def put_gonio(segment, puck, sample, force=False):
+ """
+ """
+ print "put_gonio: ", force
+
+ #Initial checks
+ robot.assert_no_task()
+ robot.reset_motion()
+ robot.state.assertReady()
+ robot.assert_cleared()
+ #robot.assert_in_known_point()
+
+ #Enabling
+ enable_motion()
+
+ if not robot.is_gonio():
+ robot.move_gonio()
+ robot.put_gonio()
diff --git a/script/motion/tools.py b/script/motion/tools.py
index 17292cc..7a7fe88 100644
--- a/script/motion/tools.py
+++ b/script/motion/tools.py
@@ -34,7 +34,17 @@ def set_hexiposi(pos):
set_status(None)
else:
hexiposi.move(pos)
-
+
+def visual_check_hexiposi(segment):
+ #if robot.working_mode == "manual" ?
+ if hexiposi.moved:
+ #Clearing for image processing
+ if not robot.is_park():
+ print "Moving robot to park to clear camera view..."
+ robot.move_park()
+ assert_img_in_cover_pos(segment)
+ hexiposi.moved = False
+
def wait_end_of_move():
@@ -88,12 +98,12 @@ def update_tool(tool=None, x_offset=0.0, y_offset=0.0, z_offset=0.0):
def assertValidAddress(segment, puck, sample):
- if type(segment) == str:
+ if is_string(segment):
segment = ord(segment.upper()) - ord('A') +1
if segment<=0 or segment >6:
- raise Excepton ("Invalid segment")
+ raise Exception ("Invalid segment")
if puck<=0 or puck >5:
- raise Excepton ("Invalid puck")
+ raise Exception ("Invalid puck")
if sample<=0 or sample >16:
- raise Excepton ("Invalid sample")
+ raise Exception ("Invalid sample")
\ No newline at end of file
diff --git a/script/motion/unmount.py b/script/motion/unmount.py
index aada773..9275ca4 100644
--- a/script/motion/unmount.py
+++ b/script/motion/unmount.py
@@ -6,39 +6,25 @@ def unmount(segment, puck, sample, force=False):
#Initial checks
assertValidAddress(segment, puck, sample)
robot.assert_no_task()
+ robot.reset_motion()
robot.state.assertReady()
robot.assert_cleared()
-
- if hexiposi.homed == False:
- raise Exception ("Hexiposi is not homed")
+ #robot.assert_in_known_point()
+ hexiposi.assert_homed()
#Enabling
enable_motion()
set_hexiposi(segment)
- if not force:
- #Clearing for image processing
- robot.move_park()
- assert_img_in_cover_pos(segment)
+ if not force:
+ visual_check_hexiposi(segment)
- location = robot.get_current_point()
+ #location = robot.get_current_point()
-
- try:
- robot.get_gonio()
- except:
- #TODO: recover
- raise
-
- try:
- robot.move_dewar_wait()
- except:
- #TODO: recover
- raise
-
- try:
- robot.put_dewar(segment, puck, sample)
- except:
- #robot.move_dewar()
- raise
\ No newline at end of file
+ if not robot.is_gonio():
+ robot.move_gonio()
+
+ robot.get_gonio()
+ robot.move_dewar()
+ robot.put_dewar(segment, puck, sample)
diff --git a/script/test/TestCmdSynchronization.py b/script/test/TestCmdSynchronization.py
index 7ba26d5..098998d 100644
--- a/script/test/TestCmdSynchronization.py
+++ b/script/test/TestCmdSynchronization.py
@@ -8,7 +8,7 @@ enable_motion()
get_context().setLogLevel(java.util.logging.Level.FINER)
try:
while True:
- #robot.move_dewar_wait()
+ #robot.move_dewar()
#robot.move_park()
log("Moving dewar", False)
@@ -17,7 +17,7 @@ try:
log("Waiting", False)
ret = robot.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
log("Moving dewar finished (" + str(ret) + ") - pos: " + get_pos_str(), False)
- robot.assert_dewar_wait()
+ robot.assert_dewar()
log("Moving park", False)