This commit is contained in:
gac-S_Changer
2018-09-03 15:23:50 +02:00
parent b84b745a49
commit 03a3023b4d
7 changed files with 117 additions and 20 deletions

View File

@@ -1,4 +1,4 @@
#Fri Aug 10 15:19:19 CEST 2018
#Thu Aug 30 15:04:59 CEST 2018
colormap=Grayscale
colormapAutomatic=false
colormapMax=18.133
@@ -9,16 +9,16 @@ grayscale=false
invert=false
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=972
roiWidth=972
roiX=12
roiY=15
rotation=229.8340828443476
roiHeight=887
roiWidth=887
roiX=59
roiY=56
rotation=229.76067253596318
rotationCrop=true
scale=1.0
spatialCalOffsetX=-486.0
spatialCalOffsetY=-486.0
spatialCalScaleX=0.48315133165771174
spatialCalScaleY=0.48314848201202937
spatialCalOffsetX=-444.0
spatialCalOffsetY=-444.0
spatialCalScaleX=0.5295623677991782
spatialCalScaleY=0.5294932790504361
spatialCalUnits=mm
transpose=false

Binary file not shown.

View File

@@ -326,9 +326,17 @@
<Component id="ledSettled" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel9" linkSize="2" min="-2" pref="52" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="ledPosition" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="textTask" max="32767" attributes="0"/>
<Component id="textPosition" max="32767" attributes="0"/>
</Group>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="textTask" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel6" linkSize="2" min="-2" pref="52" max="-2" attributes="0"/>
@@ -371,6 +379,12 @@
<Component id="textTask" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel9" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="ledPosition" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="textPosition" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -448,6 +462,25 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textPosition">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="ch.psi.pshell.swing.Led" name="ledPosition">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="SansSerif" size="18" style="0"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel9">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Position:"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="ch.psi.pshell.swing.DeviceStatePanel" name="panelState">

View File

@@ -58,6 +58,7 @@ public class RobotPanel extends DevicePanel {
Integer speed = null;
String task = null;
String mode = null;
String position = null;
if ((value != null) && (value instanceof Map)) {
Map status = (Map) value;
@@ -81,6 +82,13 @@ public class RobotPanel extends DevicePanel {
speed = (Integer) status.get("speed");
} catch (Exception ex) {
}
try {
position = (String) status.get("pos");
if (position==null){
position = "";
}
} catch (Exception ex) {
}
try {
task = ((status.containsKey("task")) && (status.get("task") == null)) ? "" : ((String) status.get("task")).trim();
} catch (Exception ex) {
@@ -120,6 +128,8 @@ public class RobotPanel extends DevicePanel {
ledMoving.setColor((moving == null) ? Color.GRAY : (moving ? Color.YELLOW : Color.DARK_GRAY));
textTask.setText((task == null) ? "" : task);
ledTask.setColor((task == null) ? Color.GRAY : (task.isEmpty() ? Color.DARK_GRAY : Color.YELLOW));
textPosition.setText((position == null) ? "" : position);
ledPosition.setColor((position == null) ? Color.GRAY : (position.isEmpty() ? Color.DARK_GRAY : Color.GREEN));
//buttonAbort.setEnabled(!textTask.getText().isEmpty());
spinnerSpeed.setEnabled(speed != null);
if (speed == null) {
@@ -171,6 +181,9 @@ public class RobotPanel extends DevicePanel {
jLabel8 = new javax.swing.JLabel();
ledTask = new ch.psi.pshell.swing.Led();
ledMode = new ch.psi.pshell.swing.Led();
textPosition = new javax.swing.JTextField();
ledPosition = new ch.psi.pshell.swing.Led();
jLabel9 = new javax.swing.JLabel();
panelState = new ch.psi.pshell.swing.DeviceStatePanel();
jPanel4 = new javax.swing.JPanel();
ledOpen = new ch.psi.pshell.swing.Led();
@@ -380,6 +393,14 @@ public class RobotPanel extends DevicePanel {
ledMode.setFont(new java.awt.Font("SansSerif", 0, 18)); // NOI18N
textPosition.setEditable(false);
textPosition.setHorizontalAlignment(javax.swing.JTextField.CENTER);
ledPosition.setFont(new java.awt.Font("SansSerif", 0, 18)); // NOI18N
jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel9.setText("Position:");
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
@@ -401,9 +422,15 @@ public class RobotPanel extends DevicePanel {
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(ledSettled, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addComponent(ledSettled, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(ledPosition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(textTask))
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(textTask)
.addComponent(textPosition)))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@@ -415,7 +442,7 @@ public class RobotPanel extends DevicePanel {
.addContainerGap())
);
jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel3, jLabel4, jLabel6, jLabel8});
jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel3, jLabel4, jLabel6, jLabel8, jLabel9});
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -439,6 +466,11 @@ public class RobotPanel extends DevicePanel {
.addComponent(jLabel8)
.addComponent(ledTask, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(textTask, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(2, 2, 2)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel9)
.addComponent(ledPosition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(textPosition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(2, 2, 2))
);
@@ -628,6 +660,7 @@ public class RobotPanel extends DevicePanel {
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
@@ -636,6 +669,7 @@ public class RobotPanel extends DevicePanel {
private ch.psi.pshell.swing.Led ledMode;
private ch.psi.pshell.swing.Led ledMoving;
private ch.psi.pshell.swing.Led ledOpen;
private ch.psi.pshell.swing.Led ledPosition;
private ch.psi.pshell.swing.Led ledPowered;
private ch.psi.pshell.swing.Led ledSettled;
private ch.psi.pshell.swing.Led ledTask;
@@ -645,6 +679,7 @@ public class RobotPanel extends DevicePanel {
private ch.psi.pshell.swing.DeviceStatePanel panelState;
private javax.swing.JSpinner spinnerSpeed;
private javax.swing.JTextField textMode;
private javax.swing.JTextField textPosition;
private javax.swing.JTextField textTask;
// End of variables declaration//GEN-END:variables
}

View File

@@ -224,7 +224,7 @@ robot.default_speed = 20
robot.set_tool(TOOL_DEFAULT)
robot.setPolling(DEFAULT_ROBOT_POLLING)
robot.get_current_point() #TODO: REMOVE WHEN CURRENT POINT REPORTED BY POLLING MESSAGE
class jf1(ReadonlyRegisterBase):
def doRead(self):

View File

@@ -30,6 +30,7 @@ class RobotTCP(TcpDevice, Stoppable):
self.current_task_ret = None
self.high_level_tasks = []
self.known_points = []
self.current_points = []
self.cartesian_destination = None
#self.flange_pos = [None] * 6
self.cartesian_pos = [None] * 6
@@ -94,13 +95,28 @@ class RobotTCP(TcpDevice, Stoppable):
def get_known_points(self):
return self.known_points
def get_current_point(self, tolerance = None):
def get_current_points(self, tolerance = None):
ret = self.is_in_points(*self.known_points, tolerance = tolerance)
current_points = []
for i in range(len(ret)):
if ret[i] == True:
return self.known_points[i]
current_points.append(self.known_points[i])
return current_points
def get_current_point(self, tolerance = None):
current_points = self.get_current_points(tolerance)
if (current_points is not None) and ( len(current_points) >0):
return current_points[0]
return None
def get_current_points_cached(self):
return self.current_points
def get_current_point_cached(self):
if (self.current_points is not None) and (len (self.current_points) >0):
return self.current_points[0]
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")
@@ -585,7 +601,8 @@ class RobotTCP(TcpDevice, Stoppable):
"task": cur_task,
"mode": self.working_mode,
"status": self.status,
"open": self.tool_open
"open": self.tool_open,
"pos": self.get_current_point_cached() if self.state==State.Ready else None #TODO: make it calculated in robot by possiung funtion
}, None)
if self.cartesian_motors_enabled:
for m in self.cartesian_motors:
@@ -620,6 +637,9 @@ class RobotTCP(TcpDevice, Stoppable):
return self.distance_p("tcp_p", name)
def is_in_point(self, p, tolerance = None): #Tolerance in mm
if (tolerance is None) and p in self.known_points:
#If checking a known point with default tolerance, updates the position cache
return p in self.get_current_points()
tolerance = self.default_tolerance if tolerance == None else tolerance
d = self.get_distance_to_pnt(p)
if d<0:
@@ -644,6 +664,12 @@ class RobotTCP(TcpDevice, Stoppable):
ret[i] = None
else:
ret[i] = ret[i]<tolerance
if (tolerance == self.default_tolerance) and (set(self.known_points).issubset(set(pars))): #Only update cache if tolerance is default
current_points = []
for i in range(len(ret)):
if ret[i] == True:
current_points.append(self.known_points[i])
self.current_points = current_points
return ret
def assert_in_point(self, p, tolerance = None): #Tolerance in mm

View File

@@ -207,7 +207,7 @@ dewar_level_listener.onValueChanged(dewar_level, dewar_level.take(), None)
###################################################################################################
# Global variables
# Global variables & application state
###################################################################################################
@@ -216,6 +216,9 @@ context = get_context()
cover_detection_debug = False
def is_puck_loading():
return robot.state == State.Ready and robot.take()["pos"] == 'pPark' and feedback_psys_safety.take() == False
update()