diff --git a/config/settings.properties b/config/settings.properties index 4b49a46..cc13f59 100644 --- a/config/settings.properties +++ b/config/settings.properties @@ -1,4 +1,4 @@ -#Tue Jul 23 10:58:33 CEST 2019 +#Tue Jul 23 15:28:01 CEST 2019 barcode_reader_scan_pucks=false beamline_status_enabled=false cold_position_timeout=3600 diff --git a/plugins/Commands.java b/plugins/Commands.java index 46bcbbb..1867bcb 100644 --- a/plugins/Commands.java +++ b/plugins/Commands.java @@ -9,6 +9,9 @@ import ch.psi.pshell.ui.Panel; import ch.psi.utils.State; import ch.psi.utils.swing.SwingUtils; import java.awt.Component; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.JComponent; import javax.swing.JSpinner; import javax.swing.JTextField; @@ -86,7 +89,12 @@ public class Commands extends Panel { try { evalAsync(statement, background).handle((ret, ex) -> { if (ex != null){ - showException((Exception)ex); + try { + if (getContext().getSetting("recovering") == null) { + showException((Exception)ex); + } + } catch (IOException e) { + } } else if (showReturn){ SwingUtils.showMessage(getTopLevel(), "Return", String.valueOf(ret)); } diff --git a/plugins/Recovery.java b/plugins/Recovery.java index 4967e94..118fe5f 100644 --- a/plugins/Recovery.java +++ b/plugins/Recovery.java @@ -7,7 +7,10 @@ import ch.psi.pshell.ui.Panel; import ch.psi.utils.State; import ch.psi.utils.swing.SwingUtils; import java.awt.Color; +import java.io.IOException; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.SwingUtilities; /** @@ -38,7 +41,7 @@ public class Recovery extends Panel { } void updateButton(){ - buttonRecover.setEnabled((getContext().getState() == State.Ready) && + buttonRecover.setEnabled((getContext().getState().isNormal()) && (textPosition.getText().trim().isEmpty()) && ((!textSegment.getText().trim().isEmpty()) || (ledIsInDewar.getColor()==Color.GREEN)) ); @@ -53,15 +56,17 @@ public class Recovery extends Panel { @Override protected void onTimer() { + System.out.println("."); Device robot = getContext().getDevicePool().getByName("robot", Device.class); if ((robot==null) || (!robot.getState().isNormal())){ + System.out.println("*"); ledValidSegment.setColor(Color.BLACK); textSegment.setText(""); ledKnownPosition.setColor(Color.BLACK); textPosition.setText(""); ledIsInDewar.setColor(Color.BLACK); } else { - if (getState()==State.Ready){ + if (getState().isNormal()){ String point = null; try{ point = (String) eval("robot.get_current_point()", true); @@ -227,19 +232,34 @@ public class Recovery extends Panel { }// //GEN-END:initComponents private void buttonRecoverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRecoverActionPerformed - try{ + try{ buttonAbort.setEnabled(true); + getContext().setSetting("recovering", "true"); + Device robot = getContext().getDevicePool().getByName("robot", Device.class); + abort(); + getContext().waitState(State.Ready, 5000); + eval("robot.stop_task()", false); + robot.waitReady(5000); evalAsync("recover()", false).handle((ret, ex) -> { if (ex != null){ showException((Exception)ex); } else { SwingUtils.showMessage(getTopLevel(), "Return", String.valueOf(ret)); } + try { + getContext().setSetting("recovering", null); + } catch (IOException e) { + } buttonAbort.setEnabled(false); return ret; }); } catch (Exception ex) { showException(ex); + try { + getContext().setSetting("recovering", null); + } catch (IOException e) { + } + buttonAbort.setEnabled(false); } }//GEN-LAST:event_buttonRecoverActionPerformed diff --git a/script/motion/recover.py b/script/motion/recover.py index cf0b498..984e2da 100644 --- a/script/motion/recover.py +++ b/script/motion/recover.py @@ -119,7 +119,7 @@ def move_to_safest_point(segment, vicinity_tolerance = 100): def is_in_dewar(): z_hom = robot.get_pnt('pHome')[2] - z_cur=robot.get_cartesian_pos()[2] + z_cur=get_robot_position()[2] if z_cur > (z_hom - 30): return False d_dwr = robot.get_distance_to_pnt('pDewar') @@ -129,7 +129,7 @@ def is_in_dewar(): def recover(move_park = True): - #Initial checks + #Initial checks robot.assert_no_task() robot.reset_motion() robot.wait_ready()