From 51858eb819f0776b93f6764f80871409fc27c44c Mon Sep 17 00:00:00 2001 From: gac-S_Changer Date: Fri, 22 Jun 2018 11:09:37 +0200 Subject: [PATCH] --- config/devices.properties | 25 +-- config/plugins.properties | 2 + devices/dewar_level.properties | 3 +- devices/led_ctrl_1.properties | 5 +- devices/led_ctrl_2.properties | 5 +- devices/led_ctrl_3.properties | 5 +- devices/led_level.properties | 3 +- devices/phase_separator_level.properties | 3 +- devices/rim_heater_temp.properties | 3 +- devices/robot_j1.properties | 3 +- devices/robot_j2.properties | 3 +- devices/robot_j3.properties | 3 +- devices/robot_j4.properties | 3 +- devices/robot_j5.properties | 3 +- devices/robot_j6.properties | 3 +- devices/robot_rx.properties | 3 +- devices/robot_ry.properties | 3 +- devices/robot_rz.properties | 3 +- devices/robot_x.properties | 3 +- devices/robot_y.properties | 3 +- devices/robot_z.properties | 3 +- devices/smart_magnet.properties | 6 + devices/smc_current.properties | 9 ++ devices/smc_current_rb.properties | 6 + plugins/SmartMagnetConfig.java | 14 ++ plugins/SmartMagnetPanel.form | 169 +++++++++++++++++++++ plugins/SmartMagnetPanel.java | 185 +++++++++++++++++++++++ script/devices/BarcodeReader.py | 55 +++++-- script/devices/Hexiposi.py | 6 + script/devices/SmartMagnet.py | 107 +++++++++++++ script/local.py | 2 +- script/motion/mount.py | 15 +- 32 files changed, 621 insertions(+), 43 deletions(-) create mode 100644 devices/smart_magnet.properties create mode 100644 devices/smc_current.properties create mode 100644 devices/smc_current_rb.properties create mode 100644 plugins/SmartMagnetConfig.java create mode 100644 plugins/SmartMagnetPanel.form create mode 100644 plugins/SmartMagnetPanel.java create mode 100644 script/devices/SmartMagnet.py diff --git a/config/devices.properties b/config/devices.properties index bd8c792..de674d5 100644 --- a/config/devices.properties +++ b/config/devices.properties @@ -1,7 +1,7 @@ img=ch.psi.pshell.prosilica.Prosilica|25001 "PacketSize=1522;PixelFormat=Mono8;BinningX=1;BinningY=1;RegionX=300;RegionY=200;Width=1000;Height=1000"|||false gripper_cam=ch.psi.pshell.imaging.MjpegSource|http://129.129.110.114/axis-cgi/mjpg/video.cgi||100| -microscan=ch.psi.pshell.serial.TcpDevice|129.129.100.200:2001||| -microscan_cmd=ch.psi.pshell.serial.TcpDevice|129.129.100.200:2003||| +microscan=ch.psi.pshell.serial.TcpDevice|129.129.110.200:2001||| +microscan_cmd=ch.psi.pshell.serial.TcpDevice|129.129.110.200:2003||| ue=LaserUE|COM4|||false #robot=RobotTcp|127.0.0.1:1000||| #onewire=ch.psi.pshell.serial.TcpDevice|129.129.126.83:5000||| @@ -32,8 +32,15 @@ dewar_level_high_alarm=ch.psi.pshell.modbus.DigitalInput|wago 7||1000| guiding_tool_park=ch.psi.pshell.modbus.DigitalInput|wago 8||1000| air_pressure_ok=ch.psi.pshell.modbus.DigitalInput|wago 9||1000|false n2_pressure_ok=ch.psi.pshell.modbus.DigitalInput|wago 10||1000| +#spare_di_1=ch.psi.pshell.modbus.DigitalInput|wago 11||| +#spare_di_2=ch.psi.pshell.modbus.DigitalInput|wago 12||| +#spare_di_3=ch.psi.pshell.modbus.DigitalInput|wago 13||| +#spare_di_4=ch.psi.pshell.modbus.DigitalInput|wago 14||| he_chamber_valve_1=ch.psi.pshell.modbus.DigitalInput|wago 15||1000| he_chamber_valve_2=ch.psi.pshell.modbus.DigitalInput|wago 16||1000| +smc_magnet_status=ch.psi.pshell.modbus.DigitalInput|wago 17||1000| +smc_mounted_1=ch.psi.pshell.modbus.DigitalInput|wago 18||1000| +smc_mounted_2=ch.psi.pshell.modbus.DigitalInput|wago 19||1000| relays=ch.psi.pshell.modbus.DigitalOutputArray|wago 0 16||1000| release_local_safety=ch.psi.pshell.modbus.DigitalOutput|wago 0||| release_psys_safety=ch.psi.pshell.modbus.DigitalOutput|wago 1||| @@ -48,20 +55,20 @@ valve_2=ch.psi.pshell.modbus.DigitalOutput|wago 9||| valve_3=ch.psi.pshell.modbus.DigitalOutput|wago 10||| valve_4=ch.psi.pshell.modbus.DigitalOutput|wago 11||| #spare_do_1=ch.psi.pshell.modbus.DigitalOutput|wago 12||| -#spare_do_2=ch.psi.pshell.modbus.DigitalOutput|wago 13||| +smc_sup_det=ch.psi.pshell.modbus.DigitalOutput|wago 13||| #spare_do_3=ch.psi.pshell.modbus.DigitalOutput|wago 14||| #spare_do_4=ch.psi.pshell.modbus.DigitalOutput|wago 15||| phase_separator_level=ch.psi.pshell.modbus.ReadonlyProcessVariable|wago 0||10000| dewar_level=ch.psi.pshell.modbus.ReadonlyProcessVariable|wago 1||10000| rim_heater_temp=ch.psi.pshell.modbus.ReadonlyProcessVariable|wago 2||10000| -air_pressure=ch.psi.pshell.modbus.ReadonlyProcessVariable|wago 3||10000| -n2_pressure=ch.psi.pshell.modbus.ReadonlyProcessVariable|wago 4||10000| -#spare_ai_1=ch.psi.pshell.modbus.AnalogInput|wago 5||| -#spare_ai_2=ch.psi.pshell.modbus.AnalogInput|wago 6||| -#spare_ai_3=ch.psi.pshell.modbus.AnalogInput|wago 7||| +#spare_ai_1=ch.psi.pshell.modbus.AnalogInput|wago 3|||true +smc_current_rb=ch.psi.pshell.modbus.ReadonlyProcessVariable|wago 4||1000| +#spare_ai_3=ch.psi.pshell.modbus.AnalogInput|wago 5||| +#spare_ai_4=ch.psi.pshell.modbus.AnalogInput|wago 6||| +#spare_ai_5=ch.psi.pshell.modbus.AnalogInput|wago 7||| led_ctrl_1=ch.psi.pshell.modbus.ProcessVariable|wago 0||| led_ctrl_2=ch.psi.pshell.modbus.ProcessVariable|wago 1||| led_ctrl_3=ch.psi.pshell.modbus.ProcessVariable|wago 2||| -#spare_ao_3=ch.psi.pshell.modbus.AnalogOutput|wago 3||| +smc_current=ch.psi.pshell.modbus.ProcessVariable|wago 3||| #cam=ch.psi.pshell.epics.AreaDetector|MX-SAMCAM||| #img_back=ch.psi.pshell.imaging.CameraSource|cam||-100| diff --git a/config/plugins.properties b/config/plugins.properties index 976e538..ded1585 100644 --- a/config/plugins.properties +++ b/config/plugins.properties @@ -5,6 +5,8 @@ NewJPanel.java=disabled Expert.java=disabled RobotPanel.java=enabled Wayne.java=disabled +SmartMagnetConfig.java=disabled +SmartMagnetPanel.java=enabled LaserUE.java=enabled PuckDetection.java=disabled TestZMQ.java=disabled diff --git a/devices/dewar_level.properties b/devices/dewar_level.properties index 098b613..92a5279 100644 --- a/devices/dewar_level.properties +++ b/devices/dewar_level.properties @@ -1,5 +1,6 @@ -#Mon Apr 23 09:19:43 CEST 2018 +#Tue Jun 19 16:41:20 CEST 2018 offset=-25.81632 precision=2 scale=0.003888 +sign_bit=0 unit=% diff --git a/devices/led_ctrl_1.properties b/devices/led_ctrl_1.properties index c6fe6fa..efe6ed5 100644 --- a/devices/led_ctrl_1.properties +++ b/devices/led_ctrl_1.properties @@ -1,8 +1,9 @@ -#Thu Jun 14 15:23:57 CEST 2018 -maxValue=1.0 +#Tue Jun 19 16:41:20 CEST 2018 +maxValue=0.4 minValue=0.0 offset=0.0 precision=2 resolution=NaN scale=3.0E-4 +sign_bit=0 unit=V diff --git a/devices/led_ctrl_2.properties b/devices/led_ctrl_2.properties index c6fe6fa..efe6ed5 100644 --- a/devices/led_ctrl_2.properties +++ b/devices/led_ctrl_2.properties @@ -1,8 +1,9 @@ -#Thu Jun 14 15:23:57 CEST 2018 -maxValue=1.0 +#Tue Jun 19 16:41:20 CEST 2018 +maxValue=0.4 minValue=0.0 offset=0.0 precision=2 resolution=NaN scale=3.0E-4 +sign_bit=0 unit=V diff --git a/devices/led_ctrl_3.properties b/devices/led_ctrl_3.properties index c6fe6fa..efe6ed5 100644 --- a/devices/led_ctrl_3.properties +++ b/devices/led_ctrl_3.properties @@ -1,8 +1,9 @@ -#Thu Jun 14 15:23:57 CEST 2018 -maxValue=1.0 +#Tue Jun 19 16:41:20 CEST 2018 +maxValue=0.4 minValue=0.0 offset=0.0 precision=2 resolution=NaN scale=3.0E-4 +sign_bit=0 unit=V diff --git a/devices/led_level.properties b/devices/led_level.properties index a187950..52dee03 100644 --- a/devices/led_level.properties +++ b/devices/led_level.properties @@ -1,8 +1,9 @@ -#Mon Apr 23 08:19:24 CEST 2018 +#Tue Jun 19 16:41:24 CEST 2018 maxValue=NaN minValue=NaN offset=0.0 precision=-1 resolution=NaN scale=1.0 +sign_bit=0 unit=null diff --git a/devices/phase_separator_level.properties b/devices/phase_separator_level.properties index 5e72524..92a5279 100644 --- a/devices/phase_separator_level.properties +++ b/devices/phase_separator_level.properties @@ -1,5 +1,6 @@ -#Thu Mar 01 15:21:07 CET 2018 +#Tue Jun 19 16:41:20 CEST 2018 offset=-25.81632 precision=2 scale=0.003888 +sign_bit=0 unit=% diff --git a/devices/rim_heater_temp.properties b/devices/rim_heater_temp.properties index 534b987..e1c3b95 100644 --- a/devices/rim_heater_temp.properties +++ b/devices/rim_heater_temp.properties @@ -1,5 +1,6 @@ -#Thu Mar 01 15:51:40 CET 2018 +#Tue Jun 19 16:41:20 CEST 2018 offset=-25.81632 precision=2 scale=0.003888 +sign_bit=0 unit=C diff --git a/devices/robot_j1.properties b/devices/robot_j1.properties index 0977d42..bc3a381 100644 --- a/devices/robot_j1.properties +++ b/devices/robot_j1.properties @@ -1,4 +1,4 @@ -#Tue Nov 28 17:23:41 CET 2017 +#Tue Jun 19 16:41:28 CEST 2018 maxValue=180.0 minValue=-180.0 offset=0.0 @@ -6,4 +6,5 @@ precision=2 resolution=0.1 rotation=false scale=1.0 +sign_bit=0 unit=deg diff --git a/devices/robot_j2.properties b/devices/robot_j2.properties index 00e1ce2..6a892bc 100644 --- a/devices/robot_j2.properties +++ b/devices/robot_j2.properties @@ -1,4 +1,4 @@ -#Tue Nov 28 17:23:45 CET 2017 +#Tue Jun 19 16:41:28 CEST 2018 maxValue=127.5 minValue=-127.5 offset=0.0 @@ -6,4 +6,5 @@ precision=2 resolution=0.1 rotation=false scale=1.0 +sign_bit=0 unit=deg diff --git a/devices/robot_j3.properties b/devices/robot_j3.properties index 9ea7576..07bff75 100644 --- a/devices/robot_j3.properties +++ b/devices/robot_j3.properties @@ -1,4 +1,4 @@ -#Tue Nov 28 17:23:40 CET 2017 +#Tue Jun 19 16:41:28 CEST 2018 maxValue=152.5 minValue=-152.5 offset=0.0 @@ -6,4 +6,5 @@ precision=2 resolution=0.1 rotation=false scale=1.0 +sign_bit=0 unit=deg diff --git a/devices/robot_j4.properties b/devices/robot_j4.properties index 0354887..41d8586 100644 --- a/devices/robot_j4.properties +++ b/devices/robot_j4.properties @@ -1,4 +1,4 @@ -#Tue Nov 28 17:23:44 CET 2017 +#Tue Jun 19 16:41:28 CEST 2018 maxValue=270.0 minValue=-270.0 offset=0.0 @@ -6,4 +6,5 @@ precision=2 resolution=0.1 rotation=false scale=1.0 +sign_bit=0 unit=deg diff --git a/devices/robot_j5.properties b/devices/robot_j5.properties index 4bb81fd..dab429f 100644 --- a/devices/robot_j5.properties +++ b/devices/robot_j5.properties @@ -1,4 +1,4 @@ -#Tue Nov 28 17:23:42 CET 2017 +#Tue Jun 19 16:41:28 CEST 2018 maxValue=132.5 minValue=-122.5 offset=0.0 @@ -6,4 +6,5 @@ precision=2 resolution=0.1 rotation=false scale=1.0 +sign_bit=0 unit=deg diff --git a/devices/robot_j6.properties b/devices/robot_j6.properties index 54507e0..41d8586 100644 --- a/devices/robot_j6.properties +++ b/devices/robot_j6.properties @@ -1,4 +1,4 @@ -#Tue Nov 28 17:23:43 CET 2017 +#Tue Jun 19 16:41:28 CEST 2018 maxValue=270.0 minValue=-270.0 offset=0.0 @@ -6,4 +6,5 @@ precision=2 resolution=0.1 rotation=false scale=1.0 +sign_bit=0 unit=deg diff --git a/devices/robot_rx.properties b/devices/robot_rx.properties index 69e8d2c..df63f03 100644 --- a/devices/robot_rx.properties +++ b/devices/robot_rx.properties @@ -1,4 +1,4 @@ -#Thu Nov 23 17:23:52 CET 2017 +#Tue Jun 19 16:41:28 CEST 2018 maxValue=180.0 minValue=-180.0 offset=0.0 @@ -6,4 +6,5 @@ precision=2 resolution=0.05 rotation=true scale=1.0 +sign_bit=0 unit=deg diff --git a/devices/robot_ry.properties b/devices/robot_ry.properties index 51daa4a..a789ebf 100644 --- a/devices/robot_ry.properties +++ b/devices/robot_ry.properties @@ -1,4 +1,4 @@ -#Thu Nov 23 17:23:32 CET 2017 +#Tue Jun 19 16:41:28 CEST 2018 maxValue=180.0 minValue=-180.0 offset=0.0 @@ -6,4 +6,5 @@ precision=-2 resolution=0.05 rotation=true scale=1.0 +sign_bit=0 unit=deg diff --git a/devices/robot_rz.properties b/devices/robot_rz.properties index 11604f5..2b88035 100644 --- a/devices/robot_rz.properties +++ b/devices/robot_rz.properties @@ -1,4 +1,4 @@ -#Tue Nov 28 16:56:22 CET 2017 +#Tue Jun 19 16:41:28 CEST 2018 maxValue=360.0 minValue=-360.0 offset=0.0 @@ -6,4 +6,5 @@ precision=2 resolution=0.1 rotation=true scale=1.0 +sign_bit=0 unit=deg diff --git a/devices/robot_x.properties b/devices/robot_x.properties index 4dbffac..5cdadcc 100644 --- a/devices/robot_x.properties +++ b/devices/robot_x.properties @@ -1,4 +1,4 @@ -#Tue Sep 12 15:07:33 CEST 2017 +#Tue Jun 19 16:41:28 CEST 2018 maxValue=1000.0 minValue=-1000.0 offset=0.0 @@ -6,4 +6,5 @@ precision=2 resolution=0.05 rotation=false scale=1.0 +sign_bit=0 unit=mm diff --git a/devices/robot_y.properties b/devices/robot_y.properties index 4bc4e79..eb8022e 100644 --- a/devices/robot_y.properties +++ b/devices/robot_y.properties @@ -1,4 +1,4 @@ -#Tue Sep 12 15:07:33 CEST 2017 +#Tue Jun 19 16:41:28 CEST 2018 maxValue=1000.0 minValue=-1000.0 offset=0.0 @@ -6,4 +6,5 @@ precision=2 resolution=0.05 rotation=false scale=1.0 +sign_bit=0 unit=null diff --git a/devices/robot_z.properties b/devices/robot_z.properties index a3126c5..eb8022e 100644 --- a/devices/robot_z.properties +++ b/devices/robot_z.properties @@ -1,4 +1,4 @@ -#Tue Sep 12 15:07:32 CEST 2017 +#Tue Jun 19 16:41:28 CEST 2018 maxValue=1000.0 minValue=-1000.0 offset=0.0 @@ -6,4 +6,5 @@ precision=2 resolution=0.05 rotation=false scale=1.0 +sign_bit=0 unit=null diff --git a/devices/smart_magnet.properties b/devices/smart_magnet.properties new file mode 100644 index 0000000..a37208e --- /dev/null +++ b/devices/smart_magnet.properties @@ -0,0 +1,6 @@ +#Fri Jun 22 11:07:01 CEST 2018 +holdingCurrent=10.0 +mountCurrent=35.0 +remanenceCurrent=-10.0 +restingCurrent=5.0 +unmountCurrent=2.5 diff --git a/devices/smc_current.properties b/devices/smc_current.properties new file mode 100644 index 0000000..aa71f58 --- /dev/null +++ b/devices/smc_current.properties @@ -0,0 +1,9 @@ +#Tue Jun 19 16:41:20 CEST 2018 +maxValue=50.0 +minValue=-50.0 +offset=0.0 +precision=2 +resolution=NaN +scale=0.003 +sign_bit=0 +unit=mA diff --git a/devices/smc_current_rb.properties b/devices/smc_current_rb.properties new file mode 100644 index 0000000..7709ada --- /dev/null +++ b/devices/smc_current_rb.properties @@ -0,0 +1,6 @@ +#Tue Jun 19 16:45:06 CEST 2018 +offset=0.0 +precision=2 +scale=0.003 +sign_bit=15 +unit=mA diff --git a/plugins/SmartMagnetConfig.java b/plugins/SmartMagnetConfig.java new file mode 100644 index 0000000..2c6213c --- /dev/null +++ b/plugins/SmartMagnetConfig.java @@ -0,0 +1,14 @@ + +import ch.psi.pshell.device.DeviceConfig; + +/** + * + */ +public class SmartMagnetConfig extends DeviceConfig{ + public double holdingCurrent; + public double restingCurrent; + public double mountCurrent; + public double unmountCurrent; + public double remanenceCurrent; + +} diff --git a/plugins/SmartMagnetPanel.form b/plugins/SmartMagnetPanel.form new file mode 100644 index 0000000..1e84613 --- /dev/null +++ b/plugins/SmartMagnetPanel.form @@ -0,0 +1,169 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/SmartMagnetPanel.java b/plugins/SmartMagnetPanel.java new file mode 100644 index 0000000..98f5bff --- /dev/null +++ b/plugins/SmartMagnetPanel.java @@ -0,0 +1,185 @@ + +import ch.psi.pshell.device.Device; +import ch.psi.pshell.ui.App; +import ch.psi.pshell.swing.DevicePanel; +import ch.psi.pshell.core.Context; +import ch.psi.utils.State; +import java.awt.Color; +import java.lang.reflect.Method; +import java.util.Map; + +/** + * + */ +public class SmartMagnetPanel extends DevicePanel { + + /** + * Creates new form RobotPanel + */ + public SmartMagnetPanel() { + initComponents(); + } + + @Override + public void setDevice(Device device) { + super.setDevice(device); + if (device == null) { + + } + panelState.setDevice(device); + } + + @Override + protected void onDeviceStateChanged(State state, State former) { + switch(state){ + case Ready: + ledStatus.setColor(Color.GREEN); + ledMounted.setColor(Color.BLACK); + break; + case Busy: + ledStatus.setColor(Color.GREEN); + ledMounted.setColor(Color.GREEN); + break; + case Fault: + ledStatus.setColor(Color.RED); + ledMounted.setColor(Color.RED); + break; + default: + ledStatus.setColor(Color.BLACK); + ledMounted.setColor(Color.BLACK); + break; + } + } + + @Override + protected void onDeviceCacheChanged(Object value, Object former, long timestamp, boolean valueChange) { + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + ledStatus = new ch.psi.pshell.swing.Led(); + jLabel1 = new javax.swing.JLabel(); + panelPowerCtr = new javax.swing.JPanel(); + jLabel5 = new javax.swing.JLabel(); + ledMounted = new ch.psi.pshell.swing.Led(); + jLabel10 = new javax.swing.JLabel(); + panelCurrentRb = new ch.psi.pshell.swing.DeviceValuePanel(); + panelState = new ch.psi.pshell.swing.DeviceStatePanel(); + panelCurrent = new ch.psi.pshell.swing.ProcessVariablePanel(); + + jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Status")); + + ledStatus.setFont(new java.awt.Font("SansSerif", 0, 18)); // NOI18N + + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel1.setText("Status:"); + + javax.swing.GroupLayout panelPowerCtrLayout = new javax.swing.GroupLayout(panelPowerCtr); + panelPowerCtr.setLayout(panelPowerCtrLayout); + panelPowerCtrLayout.setHorizontalGroup( + panelPowerCtrLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 150, Short.MAX_VALUE) + ); + panelPowerCtrLayout.setVerticalGroup( + panelPowerCtrLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 23, Short.MAX_VALUE) + ); + + jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel5.setText("Mounted:"); + + ledMounted.setFont(new java.awt.Font("SansSerif", 0, 18)); // NOI18N + + jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel10.setText("Current:"); + + panelCurrentRb.setDeviceName("smc_current_rb"); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(ledStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(panelPowerCtr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(ledMounted, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(panelCurrentRb, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(4, 4, 4) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel1) + .addComponent(ledStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(panelPowerCtr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel5) + .addComponent(ledMounted, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel10) + .addComponent(panelCurrentRb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + panelCurrent.setBorder(javax.swing.BorderFactory.createTitledBorder("Current")); + panelCurrent.setDeviceName("smc_current"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + 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() + .addComponent(panelCurrent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + ); + 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) + .addComponent(panelCurrent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(panelState, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + ); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel5; + private javax.swing.JPanel jPanel1; + private ch.psi.pshell.swing.Led ledMounted; + private ch.psi.pshell.swing.Led ledStatus; + private ch.psi.pshell.swing.ProcessVariablePanel panelCurrent; + private ch.psi.pshell.swing.DeviceValuePanel panelCurrentRb; + private javax.swing.JPanel panelPowerCtr; + private ch.psi.pshell.swing.DeviceStatePanel panelState; + // End of variables declaration//GEN-END:variables +} diff --git a/script/devices/BarcodeReader.py b/script/devices/BarcodeReader.py index 06ef873..fdbbc3a 100644 --- a/script/devices/BarcodeReader.py +++ b/script/devices/BarcodeReader.py @@ -1,11 +1,48 @@ -def enable_barcode_reader(): - microscan_cmd.write("") -def disable_barcode_reader(): - microscan_cmd.write("") -def read_barcode(timeout): - try: - return microscan.waitString(int(timeout * 1000)) - except: - return None \ No newline at end of file +class BarcodeReader(DeviceBase): + + def doInitialize(self): + self.disable() + + def enable(self): + microscan_cmd.write("") + self.setState(State.Ready) + + def disable(self): + microscan_cmd.write("") + self.setState(State.Disabled) + + def get(self,timeout=1.0): + self.state.assertReady() + try: + self.setState(State.Busy) + ret = microscan.waitString(int(timeout * 1000)) + self.setCache(ret, None) + return ret + except: + self.setCache(None, None) + return None + finally: + self.setState(State.Ready) + + def doUpdate(self): + self.get() + + + def read(self,timeout=1.0): + initial = self.state + if initial == State.Disabled: + self.enable() + try: + return self.get() + finally: + if initial == State.Disabled: + self.disable() + + + + + +add_device(BarcodeReader("barcode_reader"), force = True) + \ No newline at end of file diff --git a/script/devices/Hexiposi.py b/script/devices/Hexiposi.py index f1f3010..77794db 100644 --- a/script/devices/Hexiposi.py +++ b/script/devices/Hexiposi.py @@ -48,6 +48,12 @@ class Hexiposi(DiscretePositionerBase): self.rback = rback return self.status + def set_deadband(self, value = 0.1): #degrees + ret = self.get_response(requests.get(url=self.url+"setDeadband?deadband=" + str(value), timeout=self.timeout)) + if ret["deadbandOutput"] == value: + return value + raise Excepiton("Error setting deadband: " + str(ret)) + def move_pos(self, pos): return self.get_response(requests.get(url=self.url+"set?pos=" + str(pos), timeout=self.timeout)) diff --git a/script/devices/SmartMagnet.py b/script/devices/SmartMagnet.py new file mode 100644 index 0000000..523fc65 --- /dev/null +++ b/script/devices/SmartMagnet.py @@ -0,0 +1,107 @@ +class SmartMagnet(DeviceBase): + def __init__(self, name): + #DeviceBase.__init__(self, name, get_context().pluginManager.getDynamicClass("SmartMagnetConfig")()) + DeviceBase.__init__(self, name, DeviceConfig({ + "holdingCurrent":0.0, + "restingCurrent":0.0, + "mountCurrent":0.0, + "unmountCurrent":0.0, + "remanenceCurrent":0.0, + })) + + def doInitialize(self): + DeviceBase.doInitialize(self) + self.get_current() + + def set_current(self, current): + self.setCache(current, None) + smc_current.write(current) + + def get_current(self): + cur = smc_current.read() + self.setCache(cur, None) + return cur + + def get_current_rb(self): + self.assert_status() + return smc_current_rb.read() + + def get_status(self): + return smc_magnet_status.read() + + def assert_status(self): + if self.get_status() == False: + raise Exception("Smart Magnet is in faulty status.") + + def is_mounted(self): + self.assert_status() + m1 = smc_mounted_1.read() + m2 = smc_mounted_2.read() + if m2==m1: + raise Exception("Smart Magnet has invalid detection.") + return m2 + + def set_supress(self, value): + smc_sup_det.write(value) + + def get_supress(self): + return smc_sup_det.read() + + def check_mounted(self, idle_time =1.0, timeout = -1): + self.assert_status() + start = time.time() + last = None + while True: + try: + det = self.is_mounted() + except: + det = None + if det != last: + settling_timestamp = time.time() + last = det + else: + if det is not None: + if (time.time()-settling_timestamp > idle_time): + return det + if timeout >= 0: + if (time.time() - start) > timeout: + raise Exception("Timeout waiting for Smart Magnet detection.") + time.sleep(0.01) + + + def doUpdate(self): + try: + if self.is_mounted(): + self.setState(State.Busy) + else: + self.setState(State.Ready) + except: + self.setState(State.Fault) + + def set_holding_current(self): + self.set_current(self.config.getFieldValue("holdingCurrent")) + + def set_resting_current(self): + self.set_current(self.config.getFieldValue("restingCurrent")) + + def set_mount_current(self): + self.set_current(self.config.getFieldValue("mountCurrent")) + + def set_unmount_current(self): + self.set_current(self.config.getFieldValue("unmountCurrent")) + + def set_remanence_current(self): + self.set_current(self.config.getFieldValue("remanenceCurrent")) + + def set_default_current(): + if self.is_mounted(): + self.set_holding_current() + else: + self.set_resting_current() + + +add_device(SmartMagnet("smart_magnet"), force = True) + +smart_magnet.polling = 1000 + +smart_magnet.set_default_current() diff --git a/script/local.py b/script/local.py index 8e7a0a0..83a42d9 100644 --- a/script/local.py +++ b/script/local.py @@ -14,7 +14,7 @@ run("setup/Layout") ################################################################################################### for script in ["devices/RobotSC", "devices/Wago", "devices/BarcodeReader", "devices/LaserDistance", \ - "devices/LedCtrl", "devices/HexiPosi"]: + "devices/LedCtrl", "devices/SmartMagnet", "devices/HexiPosi"]: try: run(script) except: diff --git a/script/motion/mount.py b/script/motion/mount.py index a6cd30c..7cb614c 100644 --- a/script/motion/mount.py +++ b/script/motion/mount.py @@ -11,6 +11,10 @@ def mount(segment, puck, sample, force=False): robot.assert_cleared() #robot.assert_in_known_point() hexiposi.assert_homed() + + if smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) == True: + raise Exception("Pin detected on gonio") + #location = robot.get_current_point() #Enabling @@ -26,5 +30,12 @@ def mount(segment, puck, sample, force=False): robot.get_dewar(segment, puck, sample) robot.move_gonio() - robot.put_gonio() - robot.move_dewar() + + smart_magnet.set_mount_current() + try: + robot.put_gonio() + robot.move_dewar() + if smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) == False: + raise Exception("No pin detected on gonio") + finally: + smart_magnet.set_default_current()