diff --git a/devices/led_ctrl_1.properties b/devices/led_ctrl_1.properties index 9f3734a..0679e41 100644 --- a/devices/led_ctrl_1.properties +++ b/devices/led_ctrl_1.properties @@ -1,5 +1,5 @@ -#Thu Oct 25 15:44:44 CEST 2018 -maxValue=0.4 +#Thu Nov 08 11:41:48 CET 2018 +maxValue=1.0 minValue=0.0 offset=0.0 precision=2 diff --git a/devices/led_ctrl_2.properties b/devices/led_ctrl_2.properties index 9f3734a..0679e41 100644 --- a/devices/led_ctrl_2.properties +++ b/devices/led_ctrl_2.properties @@ -1,5 +1,5 @@ -#Thu Oct 25 15:44:44 CEST 2018 -maxValue=0.4 +#Thu Nov 08 11:41:48 CET 2018 +maxValue=1.0 minValue=0.0 offset=0.0 precision=2 diff --git a/devices/led_ctrl_3.properties b/devices/led_ctrl_3.properties index 9f3734a..0679e41 100644 --- a/devices/led_ctrl_3.properties +++ b/devices/led_ctrl_3.properties @@ -1,5 +1,5 @@ -#Thu Oct 25 15:44:44 CEST 2018 -maxValue=0.4 +#Thu Nov 08 11:41:48 CET 2018 +maxValue=1.0 minValue=0.0 offset=0.0 precision=2 diff --git a/plugins/MXSC-1.10.0.jar b/plugins/MXSC-1.10.0.jar index 28a93b8..f695a48 100644 Binary files a/plugins/MXSC-1.10.0.jar and b/plugins/MXSC-1.10.0.jar differ diff --git a/plugins/SmartMagnetPanel.form b/plugins/SmartMagnetPanel.form index 7fc1d97..f9de056 100644 --- a/plugins/SmartMagnetPanel.form +++ b/plugins/SmartMagnetPanel.form @@ -18,12 +18,9 @@ - - - - - - + + + @@ -183,10 +180,10 @@ - - - - + + + + @@ -194,10 +191,10 @@ - - - - + + + + @@ -205,21 +202,18 @@ - + - + + - - - - + - + + + - - - diff --git a/plugins/SmartMagnetPanel.java b/plugins/SmartMagnetPanel.java index 41f1eb2..185028d 100644 --- a/plugins/SmartMagnetPanel.java +++ b/plugins/SmartMagnetPanel.java @@ -27,6 +27,19 @@ public class SmartMagnetPanel extends DevicePanel { } panelState.setDevice(device); + this.startTimer(1000, 100); + } + + @Override + protected void onTimer(){ + Color color = Color.RED; + try{ + if (Context.getInstance().evalLineBackground("in_mount_position").equals(Boolean.TRUE)){ + color = Color.GREEN; + } + } catch (Exception ex){ + } + ledMountPosition.setColor(color); } @Override @@ -75,8 +88,8 @@ public class SmartMagnetPanel extends DevicePanel { 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(); + jLabel2 = new javax.swing.JLabel(); + ledMountPosition = new ch.psi.pshell.swing.Led(); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Status")); @@ -153,41 +166,29 @@ public class SmartMagnetPanel extends DevicePanel { 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); - } - }); + jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel2.setText("Mount Position:"); - buttonMount.setText("Set Mount Position"); - buttonMount.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonMountActionPerformed(evt); - } - }); + ledMountPosition.setFont(new java.awt.Font("SansSerif", 0, 18)); // NOI18N 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() + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(ledMountPosition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .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() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel2) + .addComponent(ledMountPosition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); @@ -197,11 +198,9 @@ public class SmartMagnetPanel extends DevicePanel { layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .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() - .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)) + .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)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -216,45 +215,15 @@ public class SmartMagnetPanel extends DevicePanel { ); }// //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 jLabel2; private javax.swing.JLabel jLabel5; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; + private ch.psi.pshell.swing.Led ledMountPosition; 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/client/TellClient.py b/script/client/TellClient.py index 761f40d..256dbdd 100644 --- a/script/client/TellClient.py +++ b/script/client/TellClient.py @@ -38,7 +38,12 @@ class TellClient(PShellClient): if self.state != "Ready": raise Exception("Invalid state: " + str(self.state)) - + def set_in_mount_position(self, value): + self.eval("in_mount_position = " + str(value) +"&") + + def is_in_mount_position(self): + return self.eval("in_mount_position&").lower()=="true" + def get_samples_info(self): return json.loads(self.eval("get_samples_info()&")) @@ -89,6 +94,11 @@ class TellClient(PShellClient): self.abort() self.eval("robot.stop_task()&") + def set_gonio_mount_position(homing = False): + if homing: + self.eval("home_fast_table()") + self.eval("set_mount_position()") + def get_mounted_sample(self): ret = self.eval("get_setting('mounted_sample_position')&").strip() return None if len(ret)==0 else ret @@ -111,14 +121,21 @@ class TellClient(PShellClient): def get_detected_pucks(self): return self.eval("get_detected_pucks()&") + def set_pin_offset(self, value): + self.eval("set_pin_offset(" + str(value)+ ")&") + + def get_pin_offset(self): + return self.eval("get_pin_offset()&") def print_info(self): print ("State: " + str(self.get_state())) - print ("Mounted Sample: " + str(self.get_mounted_sample())) - print ("System Check: " + str(self.get_system_check())) + print ("Mounted sample: " + str(self.get_mounted_sample())) + print ("System check: " + str(self.get_system_check())) print ("Robot state: " + str(self.get_robot_state())) print ("Robot status: " + str(self.get_robot_status())) - print ("Detected Pucks: " + str(self.get_detected_pucks())) + print ("Detected pucks: " + str(self.get_detected_pucks())) + print ("Pin offset: " + str(self.get_pin_offset())) + print ("Mount position: " + str(self.is_in_mount_position())) print ("") if __name__ == "__main__": diff --git a/script/client/tell.py b/script/client/tell.py index fed5315..56c70b4 100644 --- a/script/client/tell.py +++ b/script/client/tell.py @@ -14,18 +14,20 @@ def info(): def help(): print ("Commands: \n\thelp()\n\tinfo()\n\tmount(segment, puck, sample)\n\tunmount() \n\tdry() " \ - "\n\tscan(segment, puck, sample=None) \n\tmove_cold() \n\ttrash() \n\tabort()\n") + "\n\tscan(segment, puck, sample=None) \n\tmove_cold() \n\ttrash() \n\tabort() " \ + "\n\tset_pin_offset(value)") -def set_gonio(): - pass +def assert_transfer_allowed(): + if not tell.is_in_mount_position(): + raise Exception("Gonio is not in mount position") def mount(segment, puck, sample): - set_gonio() + assert_transfer_allowed() cmd = tell.mount(segment, puck, sample, True, True, True) print (tell.wait_cmd(cmd)) def unmount(): - set_gonio() + assert_transfer_allowed() cmd=tell.unmount(force=True) print (tell.wait_cmd(cmd)) @@ -51,6 +53,9 @@ def scan(segment, puck, sample=None): def abort(): tell.abort_cmd() +def set_pin_offset(value): + tell.set_pin_offset(value) + info() help() diff --git a/script/motion/mount.py b/script/motion/mount.py index 6e3fc1e..05c322d 100644 --- a/script/motion/mount.py +++ b/script/motion/mount.py @@ -23,10 +23,6 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False) assert_valid_address(segment, puck, sample) assert_puck_detected(segment, puck) - if auto_unmount: - if get_setting("mounted_sample_position") is not None: - unmount() - if robot.simulated: time.sleep(3.0) mount_sample_detected = True @@ -41,14 +37,17 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False) robot.assert_cleared() #robot.assert_in_known_point() hexiposi.assert_homed() - - set_status("Mounting: " + str(segment) + str(puck) + str(sample)) + try: smart_magnet.enforce_sample_detection() if smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) == True: - raise Exception("Pin detected on gonio") - + if auto_unmount and (get_setting("mounted_sample_position") is not None): + unmount(force = True) + else: + raise Exception("Pin detected on gonio") + + set_status("Mounting: " + str(segment) + str(puck) + str(sample)) #location = robot.get_current_point() #Enabling diff --git a/script/motion/unmount.py b/script/motion/unmount.py index 358a10b..41b0401 100644 --- a/script/motion/unmount.py +++ b/script/motion/unmount.py @@ -7,7 +7,7 @@ def unmount(segment = None, puck = None, sample = None, force=False): pos = get_setting("mounted_sample_position") if pos is None: raise Exception("Mounted sample position is not defined") - segment, puck , sample = pos[0:1], int(pos[1]), int(pos[2]) + segment, puck , sample = pos[0:1], int(pos[1]), int(pos[2:]) print "Mounted sample position: ", segment, puck , sample is_aux = (segment == AUX_SEGMENT)