diff --git a/plugins/Commands.java b/plugins/Commands.java index b11a50b..d9b42e2 100644 --- a/plugins/Commands.java +++ b/plugins/Commands.java @@ -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 diff --git a/plugins/MXSC-1.10.0.jar b/plugins/MXSC-1.10.0.jar index 0fbc961..3f40c45 100644 Binary files a/plugins/MXSC-1.10.0.jar and b/plugins/MXSC-1.10.0.jar differ diff --git a/plugins/PuckDetectionPanel.form b/plugins/PuckDetectionPanel.form index 9e5eb14..ddf0eb7 100644 --- a/plugins/PuckDetectionPanel.form +++ b/plugins/PuckDetectionPanel.form @@ -1,6 +1,6 @@ -
+ diff --git a/plugins/PuckDetectionPanel.java b/plugins/PuckDetectionPanel.java index f17059a..fe33ec5 100644 --- a/plugins/PuckDetectionPanel.java +++ b/plugins/PuckDetectionPanel.java @@ -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); diff --git a/plugins/SmartMagnetPanel.form b/plugins/SmartMagnetPanel.form index 1e84613..7fc1d97 100644 --- a/plugins/SmartMagnetPanel.form +++ b/plugins/SmartMagnetPanel.form @@ -18,9 +18,12 @@ - - - + + + + + + @@ -28,9 +31,11 @@ - + - + + + @@ -165,5 +170,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/SmartMagnetPanel.java b/plugins/SmartMagnetPanel.java index 98f5bff..41f1eb2 100644 --- a/plugins/SmartMagnetPanel.java +++ b/plugins/SmartMagnetPanel.java @@ -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)) ); }// //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; diff --git a/script/devices/Gonio.py b/script/devices/Gonio.py index cf006b2..0f264f5 100644 --- a/script/devices/Gonio.py +++ b/script/devices/Gonio.py @@ -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) \ No newline at end of file diff --git a/script/devices/RobotSC.py b/script/devices/RobotSC.py index 7bd8b14..b8f2de9 100644 --- a/script/devices/RobotSC.py +++ b/script/devices/RobotSC.py @@ -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") diff --git a/script/devices/RobotTCP.py b/script/devices/RobotTCP.py index fb8616c..40910a2 100644 --- a/script/devices/RobotTCP.py +++ b/script/devices/RobotTCP.py @@ -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 diff --git a/script/imgproc/CoverDetection.py b/script/imgproc/CoverDetection.py index 1398a07..904837a 100644 --- a/script/imgproc/CoverDetection.py +++ b/script/imgproc/CoverDetection.py @@ -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: diff --git a/script/imgproc/LedDetectionProc.py b/script/imgproc/LedDetectionProc.py index 37728d9..c01673d 100644 --- a/script/imgproc/LedDetectionProc.py +++ b/script/imgproc/LedDetectionProc.py @@ -1,6 +1,8 @@ ################################################################################################### # Procedure to detect the puck light spots. ################################################################################################### +assert_imaging_enabled() + COVER_PRESENT = True ROOM_TEMP = is_room_temp() diff --git a/script/imgproc/Utils.py b/script/imgproc/Utils.py index c5ed223..30af7bd 100644 --- a/script/imgproc/Utils.py +++ b/script/imgproc/Utils.py @@ -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 diff --git a/script/local.py b/script/local.py index d0251f8..d1f3a45 100644 --- a/script/local.py +++ b/script/local.py @@ -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 ################################################################################################### diff --git a/script/motion/put_gonio.py b/script/motion/put_gonio.py index 1044a14..a29e1db 100644 --- a/script/motion/put_gonio.py +++ b/script/motion/put_gonio.py @@ -1,4 +1,4 @@ -def put_gonio(segment, puck, sample, force=False): +def put_gonio(force=False): """ """ print "put_gonio: ", force diff --git a/script/motion/tools.py b/script/motion/tools.py index 277924b..148c54e 100644 --- a/script/motion/tools.py +++ b/script/motion/tools.py @@ -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()