This commit is contained in:
@@ -8,6 +8,7 @@ import ch.psi.utils.State;
|
||||
import ch.psi.utils.swing.SwingUtils;
|
||||
import java.awt.Color;
|
||||
import java.util.List;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -16,7 +17,7 @@ public class Recovery extends Panel {
|
||||
|
||||
public Recovery() {
|
||||
initComponents();
|
||||
startTimer(1000, 200);
|
||||
startTimer(5000, 200);
|
||||
}
|
||||
|
||||
//Overridable callbacks
|
||||
@@ -27,6 +28,12 @@ public class Recovery extends Panel {
|
||||
|
||||
@Override
|
||||
public void onStateChange(State state, State former) {
|
||||
if (state==State.Ready){
|
||||
SwingUtilities.invokeLater(()->{onTimer();});
|
||||
}
|
||||
textSegment.setEnabled(state == State.Ready);
|
||||
textDistance.setEnabled(state == State.Ready);
|
||||
textPosition.setEnabled(state == State.Ready);
|
||||
updateButton();
|
||||
}
|
||||
|
||||
@@ -40,42 +47,50 @@ public class Recovery extends Panel {
|
||||
@Override
|
||||
public void onExecutedFile(String fileName, Object result) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void onTimer() {
|
||||
Device robot = getContext().getDevicePool().getByName("robot", Device.class);
|
||||
if (!robot.getState().isNormal()){
|
||||
if ((robot==null) || (!robot.getState().isNormal())){
|
||||
ledValidSegment.setColor(Color.BLACK);
|
||||
textSegment.setText("");
|
||||
ledKnownPosition.setColor(Color.BLACK);
|
||||
textPosition.setText("");
|
||||
} else {
|
||||
try{
|
||||
List segment = (List) eval("get_current_segment()", true);
|
||||
ledValidSegment.setColor((segment == null) ? Color.RED : Color.GREEN);
|
||||
textSegment.setText((segment == null) ? "": segment.get(0) + "->" + segment.get(1) + " [" + segment.get(2) + "mm]");
|
||||
|
||||
if (getState()==State.Ready){
|
||||
String point = null;
|
||||
try{
|
||||
Object distance = eval("get_current_distance()", true);
|
||||
textDistance.setText((distance == null) ? "" : String.format("%1.2f",((Number)distance).doubleValue()));
|
||||
point = (String) eval("robot.get_current_point()", true);
|
||||
ledKnownPosition.setColor((point == null) ? Color.RED : Color.GREEN);
|
||||
textPosition.setText((point == null) ? "": point);
|
||||
} catch (Exception ex) {
|
||||
System.out.println(ex);
|
||||
ledKnownPosition.setColor(Color.BLACK);
|
||||
textPosition.setText("");
|
||||
}
|
||||
try{
|
||||
List segment = (List) eval("get_current_segment()", true);
|
||||
ledValidSegment.setColor((segment == null) ? Color.RED : Color.GREEN);
|
||||
textSegment.setText((segment == null) ? "": segment.get(0) + "->" + segment.get(1) + " [" + segment.get(2) + "mm]");
|
||||
if ((segment == null)||(point!=null)){
|
||||
textDistance.setText("");
|
||||
} else {
|
||||
try{
|
||||
Object distance = eval("get_current_distance()", true);
|
||||
textDistance.setText((distance == null) ? "" : String.format("%1.2f",((Number)distance).doubleValue()));
|
||||
} catch (Exception ex) {
|
||||
textDistance.setText("");
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
System.out.println(ex);
|
||||
ledValidSegment.setColor(Color.BLACK);
|
||||
textSegment.setText("");
|
||||
textDistance.setText("");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
System.out.println(ex);
|
||||
ledValidSegment.setColor(Color.BLACK);
|
||||
textSegment.setText("");
|
||||
textDistance.setText("");
|
||||
}
|
||||
try{
|
||||
String point = (String) eval("robot.get_current_point()", true);
|
||||
ledKnownPosition.setColor((point == null) ? Color.RED : Color.GREEN);
|
||||
textPosition.setText((point == null) ? "": point);
|
||||
} catch (Exception ex) {
|
||||
System.out.println(ex);
|
||||
ledKnownPosition.setColor(Color.BLACK);
|
||||
textPosition.setText("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
updateButton();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ 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", "moveGonio","moveHeater", "moveScanner","moveHome"])
|
||||
self.set_known_points(["pPark", "pHome","pDewarHome", "pGonioHome", "pDewarWait", "pGonioGet", "pScanHome", "pHeaterHome", "pHeater", "pHeaterBottom", "pScanStop","pHelium"])
|
||||
self.set_known_points(["pPark", "pGonioHome", "pDewarWait", "pGonioGet", "pScanHome", "pHeaterHome", "pHeater", "pHeaterBottom", "pScanStop","pHelium", "pHome"])
|
||||
self.setPolling(DEFAULT_ROBOT_POLLING)
|
||||
|
||||
def move_dewar(self):
|
||||
@@ -97,7 +97,7 @@ class RobotSC(RobotTCP):
|
||||
def robot_recover(self):
|
||||
self.start_task('robotRecover')
|
||||
self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
|
||||
self.assert_dewar_home()
|
||||
self.assert_home()
|
||||
|
||||
def toSegmentNumber(self, segment):
|
||||
if is_string(segment):
|
||||
@@ -143,7 +143,7 @@ class RobotSC(RobotTCP):
|
||||
return self.is_in_point("pPark")
|
||||
|
||||
def is_home(self):
|
||||
return self.is_in_point("pDewarHome")
|
||||
return self.is_in_point("pHome")
|
||||
|
||||
def is_dewar(self):
|
||||
return self.is_in_point("pDewarWait")
|
||||
@@ -186,7 +186,7 @@ class RobotSC(RobotTCP):
|
||||
self.assert_in_point("pPark")
|
||||
|
||||
def assert_home(self):
|
||||
self.assert_in_point("pDewarHome")
|
||||
self.assert_in_point("pHome")
|
||||
|
||||
def assert_dewar(self):
|
||||
self.assert_in_point("pDewarWait")
|
||||
|
||||
@@ -138,13 +138,16 @@ def set_air_stream(state):
|
||||
set_heater_chrono = None
|
||||
|
||||
def monitor_heater_time():
|
||||
while get_heater():
|
||||
if set_heater_chrono.isTimeout(MAX_HEATER_TIME):
|
||||
set_heater(False)
|
||||
log("Heater timeout expired: turned off", False)
|
||||
return
|
||||
time.sleep(0.1)
|
||||
|
||||
time.sleep(0.5)
|
||||
try:
|
||||
while get_heater():
|
||||
if set_heater_chrono.isTimeout(MAX_HEATER_TIME):
|
||||
set_heater(False)
|
||||
log("Heater timeout expired: turned off", False)
|
||||
return
|
||||
time.sleep(0.1)
|
||||
except:
|
||||
print sys.exc_info()
|
||||
|
||||
def set_heater(state):
|
||||
"""
|
||||
|
||||
@@ -6,14 +6,14 @@ RECOVER_DESC = "mRecovery"
|
||||
RECOVER_TOOL = TOOL_DEFAULT
|
||||
|
||||
known_segments = [ ("pHome", "pPark", 50), \
|
||||
("pHome", "pDewarHome", 30), \
|
||||
("pHome", "pGonioHome", 30), \
|
||||
("pHome", "pScanHome", 25), \
|
||||
("pHome", "pHeaterHome", 25), \
|
||||
("pDewarHome", "pDewarWait", 10), \
|
||||
("pHome", "pHeaterHome", 75), \
|
||||
("pHome", "pDewarWait", 10), \
|
||||
("pHome", "pHelium", 230), \
|
||||
("pGonioHome", "pGonioGet", 10), \
|
||||
("pHeaterHome", "pHeater", 10), \
|
||||
("pHeater", "pHeaterBottom", 10), \
|
||||
("pPark", "pHeater", 40), \
|
||||
("pHeaterHome", "pHeaterBottom", 10), \
|
||||
]
|
||||
|
||||
def get_dist_to_line(segment):
|
||||
@@ -85,6 +85,7 @@ def get_current_distance():
|
||||
|
||||
|
||||
def move_to_segment(segment):
|
||||
tolerance = segment[2]
|
||||
p = robot.get_cartesian_pos()
|
||||
v = Vector3D(p[0], p[1], p[2])
|
||||
lv = get_pojection_at_line(segment)
|
||||
@@ -103,7 +104,8 @@ def move_to_segment(segment):
|
||||
#Moves to first point of the segment ehich is safer, unless in the vicinity of the second
|
||||
def move_to_safest_point(segment, vicinity_tolerance = 100):
|
||||
d1, d2 = robot.get_distance_to_pnt(segment[0]), robot.get_distance_to_pnt(segment[1])
|
||||
if (d2<=d1) and (d2 <= vicinity_tolerance):
|
||||
#Always moving to primary point
|
||||
if False : #(d2<=d1) and (d2 <= vicinity_tolerance):
|
||||
print "Moving to secondary point " + str(segment[1] + " - d1=" + str(d1) + " d2=" + str(d2) )
|
||||
robot.movel(segment[1], tool=RECOVER_TOOL, desc=RECOVER_DESC, sync=True)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user