This commit is contained in:
@@ -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 {
|
||||
}// </editor-fold>//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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user