This commit is contained in:
gac-S_Changer
2018-08-14 14:10:09 +02:00
parent 1709e91d0d
commit 016f0508fe
15 changed files with 216 additions and 32 deletions

View File

@@ -462,12 +462,12 @@ public class Commands extends Panel {
private void buttonGetGonioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonGetGonioActionPerformed
String force = checkForce.isSelected() ? "True" : "False";
execute("get_gonio('force=" + force + ")");
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 + ")");
execute("put_gonio(force=" + force + ")");
}//GEN-LAST:event_buttonPutGonioActionPerformed
private void buttonMoveParkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMoveParkActionPerformed

Binary file not shown.

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>

View File

@@ -39,7 +39,7 @@ public class PuckDetectionPanel extends DevicePanel {
table.getModel().setValueAt(state.mecSwitch, row, 2);
table.getModel().setValueAt(state.indSwitch, row, 3);
table.getModel().setValueAt(puck.getDetection() == null ? "" : puck.getDetection(), row, 4);
table.getModel().setValueAt(puck.getImageDetection() == null ? "" : puck.getImageDetection(), row, 5);
table.getModel().setValueAt(puck.getPuckType() == null ? "" : puck.getPuckType(), row, 5);
} catch (Exception ex) {
ex.printStackTrace();
table.getModel().setValueAt(false, row, 1);

View File

@@ -18,9 +18,12 @@
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" max="32767" attributes="0"/>
<Component id="panelState" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="panelCurrent" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="panelCurrent" max="32767" attributes="0"/>
<Component id="jPanel2" max="32767" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -28,9 +31,11 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="5" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="panelCurrent" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="panelState" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
@@ -165,5 +170,58 @@
<Property name="deviceName" type="java.lang.String" value="smc_current"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel2">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Gonio"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonHoming" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonMount" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonHoming" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonMount" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonHoming">
<Properties>
<Property name="text" type="java.lang.String" value="Home Fast Table"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonHomingActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonMount">
<Properties>
<Property name="text" type="java.lang.String" value="Set Mount Position"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonMountActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@@ -74,6 +74,9 @@ public class SmartMagnetPanel extends DevicePanel {
panelCurrentRb = new ch.psi.pshell.swing.DeviceValuePanel();
panelState = new ch.psi.pshell.swing.DeviceStatePanel();
panelCurrent = new ch.psi.pshell.swing.ProcessVariablePanel();
jPanel2 = new javax.swing.JPanel();
buttonHoming = new javax.swing.JButton();
buttonMount = new javax.swing.JButton();
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Status"));
@@ -148,6 +151,46 @@ public class SmartMagnetPanel extends DevicePanel {
panelCurrent.setBorder(javax.swing.BorderFactory.createTitledBorder("Current"));
panelCurrent.setDeviceName("smc_current");
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Gonio"));
buttonHoming.setText("Home Fast Table");
buttonHoming.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonHomingActionPerformed(evt);
}
});
buttonMount.setText("Set Mount Position");
buttonMount.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonMountActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonHoming)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonMount)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonHoming, buttonMount});
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonHoming)
.addComponent(buttonMount))
.addContainerGap())
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -155,26 +198,63 @@ public class SmartMagnetPanel extends DevicePanel {
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(panelState, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(panelCurrent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(panelCurrent, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(0, 0, 0))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(5, 5, 5)
.addGap(0, 0, 0)
.addComponent(panelCurrent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGap(0, 0, 0)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(panelState, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
}// </editor-fold>//GEN-END:initComponents
private void buttonHomingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonHomingActionPerformed
try{
Context.getInstance().evalLineAsync("home_fast_table()").handle((ret, ex) -> {
if (SmartMagnetPanel.this.isShowing()){
if (ex != null){
showException((Exception)ex);
}
}
return ret;
});
} catch (Exception ex){
this.showException(ex);
}
}//GEN-LAST:event_buttonHomingActionPerformed
private void buttonMountActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMountActionPerformed
try{
Context.getInstance().evalLineAsync("set_mount_position()").handle((ret, ex) -> {
if (SmartMagnetPanel.this.isShowing()){
if (ex != null){
showException((Exception)ex);
}
}
return ret;
});
} catch (Exception ex){
this.showException(ex);
}
}//GEN-LAST:event_buttonMountActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonHoming;
private javax.swing.JButton buttonMount;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private ch.psi.pshell.swing.Led ledMounted;
private ch.psi.pshell.swing.Led ledStatus;
private ch.psi.pshell.swing.ProcessVariablePanel panelCurrent;

View File

@@ -1,7 +1,7 @@
def home_fast_table():
caput ("SAR-EXPMX:ASYN.AOUT", "enable plc 1")
caput ("SAR-EXPMX1:ASYN.AOUT", "enable plc 1")
def get_fx_pos():
return caget("SAR-EXPMX:MOT_FX.RBV", 'f')
@@ -35,3 +35,9 @@ def set_cx_pos(pos):
return caput("SAR-EXPMX:MOT_CX.VAL", float(pos))
def set_mount_position():
set_fx_pos(0.0)
set_fy_pos(0.0)
set_ry_pos(0.0)
set_cz_pos(0.0)
set_cx_pos(0.0)

View File

@@ -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"])
self.set_known_points(["pHome", "pPark", "pDewarHome", "pGonioHome", "pDewarWait", "pGonioGet", "pScanHome", "pHeaterHome", "pHeater", "pHeaterBottom", "pScanStop"])
self.set_known_points(["pHome", "pPark", "pDewarHome", "pGonioHome", "pDewarWait", "pGonioGet", "pScanHome", "pHeaterHome", "pHeater", "pHeaterBottom", "pScanStop","pHelium"])
self.setPolling(DEFAULT_ROBOT_POLLING)
def move_dewar(self):
@@ -161,6 +161,9 @@ class RobotSC(RobotTCP):
def is_gonio(self):
return self.is_in_point("pGonioHome")
def is_helium(self):
return self.is_in_point("pHelium")
def is_scanner(self):
return self.is_in_point("pScanHome")
@@ -194,7 +197,10 @@ class RobotSC(RobotTCP):
self.assert_in_point("pDewarWait")
def assert_gonio(self):
self.assert_in_point("pGonioHome")
self.assert_in_point("pGonioHome")
def assert_helium(self):
self.assert_in_point("pHelium")
def assert_scanner(self):
self.assert_in_point("pScanHome")

View File

@@ -108,7 +108,7 @@ class RobotTCP(TcpDevice, Stoppable):
def _sendReceive(self, msg_id, msg = "", timeout = None):
tx = self.header if (self.header != None) else ""
tx = tx + msg_id + " " + msg
if (len(tx)>127):
if (len(tx)>150):
raise Exception("Exceeded maximum message size")
self.getLogger().finer("TX = '" + str(tx)+ "'")
if (self.trailer != None): tx = tx + self.trailer
@@ -736,7 +736,7 @@ class RobotTCP(TcpDevice, Stoppable):
log("Failed starting : " + str(program) + str(args), False)
print "Failed starting : " + str(program) + str(args)
if self.exception_on_task_start_failure:
raise Exception("Cannot start task: " + program + + str(args))
raise Exception("Cannot start task: " + program + str(args))
log("Task started: " + str(program) + str(args) + " - status: " + str(status) + " (" + str(code) + ")", False)
self.current_task, self.current_task_ret = program, None

View File

@@ -1,6 +1,8 @@
###################################################################################################
# Procedure to detect the cover orientation
###################################################################################################
assert_imaging_enabled()
#Parameters
FRAMES_INTEGRATION = 3
@@ -27,7 +29,7 @@ smooth(ip)
#bandpass_filter(ip, 30, 1000)
edges(ip)
auto_threshold(ip, method = "MaxEntropy")
#binary_erode(ip, False)
#binary_erode(ip, True)
#binary_dilate(ip, True)
ip.getProcessor().erode(1, 255)
cx,cy = int(ip.width/2), int(ip.height/2)
@@ -80,7 +82,7 @@ if angle is not None:
#Plot the correlations values agains angle
if DEBUG:
p = plot(ydata, xdata=xdata)[0]
plot(ydata, xdata=xdata)
#Output results
if DEBUG:

View File

@@ -1,6 +1,8 @@
###################################################################################################
# Procedure to detect the puck light spots.
###################################################################################################
assert_imaging_enabled()
COVER_PRESENT = True
ROOM_TEMP = is_room_temp()

View File

@@ -9,8 +9,6 @@ from ch.psi.pshell.imaging.Overlays import *
import ch.psi.pshell.imaging.Pen as Pen
import java.awt.Rectangle as Rectangle
def get_img_cover_pos():
[position, angle, confidence] = run("imgproc/CoverDetection")
return position

View File

@@ -11,6 +11,37 @@ import ch.psi.pshell.core.Nameable as Nameable
run("setup/Layout")
###################################################################################################
# Configuration
###################################################################################################
def is_imaging_enabled():
setting = get_setting("ImagingEnabled")
return not (str(setting) == 'False')
def set_imaging_enabled(value):
set_setting("ImagingEnabled", True if value else False )
def assert_imaging_enabled():
if is_imaging_enabled() == False:
raise Exception ("Imaging is disabled")
#"unipuck", "minispine" or "mixed"
def set_puck_types(value):
set_setting("ImagingEnabled", True if value else False )
def get_puck_types():
setting = get_setting("ImagingEnabled")
if setting == "unipuck" or setting == "minispine":
return setting
return "mixed"
#In order to apply current config
set_imaging_enabled(is_imaging_enabled())
set_puck_types(get_puck_types())
###################################################################################################
# Scripted devices and pseudo-devices
###################################################################################################

View File

@@ -1,4 +1,4 @@
def put_gonio(segment, puck, sample, force=False):
def put_gonio(force=False):
"""
"""
print "put_gonio: ", force

View File

@@ -65,14 +65,15 @@ def _set_hexiposi(pos):
def visual_check_hexiposi(segment):
#if is_manual_mode(): ?
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
if is_imaging_enabled():
#if is_manual_mode(): ?
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
@@ -82,7 +83,7 @@ def wait_end_of_move():
time.sleep(0.01)
def move_home():
def move_to_home():
#robot.reset_motion("jHome")
robot.movej("pHome", robot.tool , DESC_SCAN)
wait_end_of_move()