diff --git a/devices/smart_magnet.properties b/devices/smart_magnet.properties index f8c2f31..5484332 100644 --- a/devices/smart_magnet.properties +++ b/devices/smart_magnet.properties @@ -1,5 +1,5 @@ -#Fri Sep 21 16:29:05 CEST 2018 -holdingCurrent=30.0 +#Wed Oct 03 14:07:43 CEST 2018 +holdingCurrent=50.0 mountCurrent=10.0 remanenceCurrent=-10.0 restingCurrent=10.0 diff --git a/plugins/Commands.form b/plugins/Commands.form index ff1764c..c7911a6 100644 --- a/plugins/Commands.form +++ b/plugins/Commands.form @@ -16,24 +16,36 @@ - - - - + + + + + - + + + + + + + + + + + + - + - + @@ -41,50 +53,21 @@ - + - - - - - - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -92,46 +75,8 @@ - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - @@ -142,21 +87,105 @@ + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + - + @@ -170,46 +199,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -221,16 +210,16 @@ - - + + - + - - + + @@ -272,11 +261,13 @@ + + @@ -302,11 +293,13 @@ + + @@ -329,11 +322,13 @@ + + @@ -344,6 +339,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -352,108 +447,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -462,6 +455,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -480,5 +590,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/Commands.java b/plugins/Commands.java index e5ddfdb..8a73abc 100644 --- a/plugins/Commands.java +++ b/plugins/Commands.java @@ -50,7 +50,7 @@ public class Commands extends Panel { @Override public void onStateChange(State state, State former) { - for (Component c: SwingUtils.getComponentsByType(panelCommands, JComponent.class)){ + for (Component c: SwingUtils.getComponentsByType(this, JComponent.class)){ c.setEnabled(state == State.Ready); } buttonHomingHexiposi.setEnabled(state == State.Ready); @@ -113,13 +113,15 @@ public class Commands extends Panel { // //GEN-BEGIN:initComponents private void initComponents() { - panelCommands = new javax.swing.JPanel(); + pnDry = new javax.swing.JPanel(); + jLabel6 = new javax.swing.JLabel(); + spinnerDryTime = new ch.psi.utils.swing.HorizontalSpinner(); + buttonDry = new javax.swing.JButton(); + spinnerDrySpeed = new ch.psi.utils.swing.HorizontalSpinner(); + jLabel7 = new javax.swing.JLabel(); + ckeckParkOnDry = new javax.swing.JCheckBox(); + pnTransfer = new javax.swing.JPanel(); buttonMount = new javax.swing.JButton(); - buttonUnmount = new javax.swing.JButton(); - buttonGetDewar = new javax.swing.JButton(); - buttonPutDewar = new javax.swing.JButton(); - buttonGetGonio = new javax.swing.JButton(); - buttonPutGonio = new javax.swing.JButton(); jPanel5 = new javax.swing.JPanel(); jLabel4 = new javax.swing.JLabel(); checkForce = new javax.swing.JCheckBox(); @@ -131,25 +133,89 @@ public class Commands extends Panel { jLabel3 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); checkDatamatrix = new javax.swing.JCheckBox(); + buttonUnmount = new javax.swing.JButton(); + buttonScanPin = new javax.swing.JButton(); + buttonScanPin1 = new javax.swing.JButton(); + pnLowLevel = new javax.swing.JPanel(); buttonMovePark = new javax.swing.JButton(); - buttonHomingHexiposi = new javax.swing.JButton(); - buttonMoveHome = new javax.swing.JButton(); - buttonMoveGonio = new javax.swing.JButton(); - buttonMoveDewar = new javax.swing.JButton(); - buttonMoveScanner = new javax.swing.JButton(); - buttonMoveHeater = new javax.swing.JButton(); - buttonDry = new javax.swing.JButton(); - spinnerDryTime = new ch.psi.utils.swing.HorizontalSpinner(); - jLabel6 = new javax.swing.JLabel(); - jLabel7 = new javax.swing.JLabel(); - spinnerDrySpeed = new ch.psi.utils.swing.HorizontalSpinner(); - buttonRecover = new javax.swing.JButton(); - buttonEnableAll = new javax.swing.JButton(); buttonMoveCold = new javax.swing.JButton(); + buttonMoveGonio = new javax.swing.JButton(); + buttonMoveHeater = new javax.swing.JButton(); + buttonGetGonio = new javax.swing.JButton(); + buttonPutGonio = new javax.swing.JButton(); + buttonMoveDewar = new javax.swing.JButton(); + buttonMoveHome = new javax.swing.JButton(); + buttonMoveScanner = new javax.swing.JButton(); + buttonGetDewar = new javax.swing.JButton(); + buttonPutDewar = new javax.swing.JButton(); + buttonHomingHexiposi = new javax.swing.JButton(); + pnDatabase = new javax.swing.JPanel(); buttonClearSampleDb = new javax.swing.JButton(); buttonResetPuckIds = new javax.swing.JButton(); + pnMotion = new javax.swing.JPanel(); + buttonRecover = new javax.swing.JButton(); + buttonEnableAll = new javax.swing.JButton(); - panelCommands.setBorder(javax.swing.BorderFactory.createTitledBorder("Commands")); + pnDry.setBorder(javax.swing.BorderFactory.createTitledBorder("Drying")); + + jLabel6.setText("Heat time(s):"); + + spinnerDryTime.setModel(new javax.swing.SpinnerNumberModel(30.0d, 1.0d, 30.0d, 1.0d)); + + buttonDry.setText("Dry"); + buttonDry.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonDryActionPerformed(evt); + } + }); + + spinnerDrySpeed.setModel(new javax.swing.SpinnerNumberModel(0.5d, 0.1d, 10.0d, 1.0d)); + + jLabel7.setText("Speed(%):"); + + ckeckParkOnDry.setText("Park on finish"); + + javax.swing.GroupLayout pnDryLayout = new javax.swing.GroupLayout(pnDry); + pnDry.setLayout(pnDryLayout); + pnDryLayout.setHorizontalGroup( + pnDryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnDryLayout.createSequentialGroup() + .addContainerGap() + .addGroup(pnDryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(buttonDry, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(ckeckParkOnDry)) + .addGap(18, 18, Short.MAX_VALUE) + .addGroup(pnDryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel6) + .addComponent(jLabel7)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(pnDryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(spinnerDrySpeed, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(spinnerDryTime, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + pnDryLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonDry, spinnerDrySpeed, spinnerDryTime}); + + pnDryLayout.setVerticalGroup( + pnDryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnDryLayout.createSequentialGroup() + .addContainerGap() + .addGroup(pnDryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnDryLayout.createSequentialGroup() + .addGroup(pnDryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(buttonDry) + .addComponent(spinnerDryTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(pnDryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(spinnerDrySpeed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel7) + .addComponent(ckeckParkOnDry))) + .addComponent(jLabel6)) + .addContainerGap()) + ); + + pnTransfer.setBorder(javax.swing.BorderFactory.createTitledBorder("Sample Transfer")); buttonMount.setText("Mount"); buttonMount.addActionListener(new java.awt.event.ActionListener() { @@ -158,57 +224,28 @@ public class Commands extends Panel { } }); - buttonUnmount.setText("Unmount"); - buttonUnmount.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonUnmountActionPerformed(evt); - } - }); - - buttonGetDewar.setText("Get Dewar"); - buttonGetDewar.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonGetDewarActionPerformed(evt); - } - }); - - buttonPutDewar.setText("Put Dewar"); - buttonPutDewar.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonPutDewarActionPerformed(evt); - } - }); - - buttonGetGonio.setText("Get Gonio"); - buttonGetGonio.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonGetGonioActionPerformed(evt); - } - }); - - buttonPutGonio.setText("Put Gonio"); - buttonPutGonio.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonPutGonioActionPerformed(evt); - } - }); - + jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); jLabel4.setText("Force:"); + checkForce.setSelected(true); checkForce.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING); spinnerSample.setModel(new javax.swing.SpinnerNumberModel(1, 1, 16, 1)); spinnerPuck.setModel(new javax.swing.SpinnerNumberModel(1, 1, 5, 1)); + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); jLabel1.setText("Segment:"); + jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); jLabel2.setText("Puck:"); spinnerSegment.setModel(new javax.swing.SpinnerListModel(new String[] {"A", "B", "C", "D", "E", "F"})); + jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); jLabel3.setText("Sample:"); + jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); jLabel5.setText("Read DM:"); checkDatamatrix.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING); @@ -227,15 +264,17 @@ public class Commands extends Panel { .addComponent(jLabel5)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(spinnerPuck) + .addComponent(spinnerPuck, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(checkForce) .addComponent(checkDatamatrix) - .addComponent(spinnerSample, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE) - .addComponent(spinnerSegment)) + .addComponent(spinnerSample, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(spinnerSegment, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(0, 0, 0)) ); - jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3}); + jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3, jLabel4, jLabel5}); + + jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerPuck, spinnerSample, spinnerSegment}); jPanel5Layout.setVerticalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -263,6 +302,64 @@ public class Commands extends Panel { .addGap(0, 0, 0)) ); + buttonUnmount.setText("Unmount"); + buttonUnmount.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonUnmountActionPerformed(evt); + } + }); + + buttonScanPin.setText("Scan Pin"); + buttonScanPin.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonScanPinActionPerformed(evt); + } + }); + + buttonScanPin1.setText("Scan Puck"); + buttonScanPin1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonScanPin1ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout pnTransferLayout = new javax.swing.GroupLayout(pnTransfer); + pnTransfer.setLayout(pnTransferLayout); + pnTransferLayout.setHorizontalGroup( + pnTransferLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnTransferLayout.createSequentialGroup() + .addContainerGap() + .addGroup(pnTransferLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(buttonMount, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonUnmount, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonScanPin, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonScanPin1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 31, Short.MAX_VALUE) + .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + + pnTransferLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonMount, buttonScanPin, buttonUnmount}); + + pnTransferLayout.setVerticalGroup( + pnTransferLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnTransferLayout.createSequentialGroup() + .addContainerGap() + .addGroup(pnTransferLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnTransferLayout.createSequentialGroup() + .addComponent(buttonMount) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(buttonUnmount) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(buttonScanPin) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(buttonScanPin1)) + .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + pnLowLevel.setBorder(javax.swing.BorderFactory.createTitledBorder("Low-level Motion Commands")); + buttonMovePark.setText("Move Park"); buttonMovePark.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -270,17 +367,10 @@ public class Commands extends Panel { } }); - buttonHomingHexiposi.setText("Homing Hexiposi"); - buttonHomingHexiposi.addActionListener(new java.awt.event.ActionListener() { + buttonMoveCold.setText("Move Cold"); + buttonMoveCold.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonHomingHexiposiActionPerformed(evt); - } - }); - - buttonMoveHome.setText("Move Home"); - buttonMoveHome.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonMoveHomeActionPerformed(evt); + buttonMoveColdActionPerformed(evt); } }); @@ -291,6 +381,27 @@ public class Commands extends Panel { } }); + buttonMoveHeater.setText("Move Heater"); + buttonMoveHeater.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonMoveHeaterActionPerformed(evt); + } + }); + + buttonGetGonio.setText("Get Gonio"); + buttonGetGonio.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonGetGonioActionPerformed(evt); + } + }); + + buttonPutGonio.setText("Put Gonio"); + buttonPutGonio.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonPutGonioActionPerformed(evt); + } + }); + buttonMoveDewar.setText("Move Dewar"); buttonMoveDewar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -298,6 +409,13 @@ public class Commands extends Panel { } }); + buttonMoveHome.setText("Move Home"); + buttonMoveHome.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonMoveHomeActionPerformed(evt); + } + }); + buttonMoveScanner.setText("Move Scanner"); buttonMoveScanner.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -305,48 +423,84 @@ public class Commands extends Panel { } }); - buttonMoveHeater.setText("Move Heater"); - buttonMoveHeater.addActionListener(new java.awt.event.ActionListener() { + buttonGetDewar.setText("Get Dewar"); + buttonGetDewar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonMoveHeaterActionPerformed(evt); + buttonGetDewarActionPerformed(evt); } }); - buttonDry.setText("Dry"); - buttonDry.addActionListener(new java.awt.event.ActionListener() { + buttonPutDewar.setText("Put Dewar"); + buttonPutDewar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonDryActionPerformed(evt); + buttonPutDewarActionPerformed(evt); } }); - spinnerDryTime.setModel(new javax.swing.SpinnerNumberModel(30.0d, 1.0d, 30.0d, 1.0d)); - - jLabel6.setText("Heat time(s):"); - - jLabel7.setText("Speed(%):"); - - spinnerDrySpeed.setModel(new javax.swing.SpinnerNumberModel(0.5d, 0.1d, 10.0d, 1.0d)); - - buttonRecover.setText("Recover"); - buttonRecover.addActionListener(new java.awt.event.ActionListener() { + buttonHomingHexiposi.setText("Homing Hexiposi"); + buttonHomingHexiposi.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonRecoverActionPerformed(evt); + buttonHomingHexiposiActionPerformed(evt); } }); - buttonEnableAll.setText("Enable Motion"); - buttonEnableAll.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonEnableAllActionPerformed(evt); - } - }); + javax.swing.GroupLayout pnLowLevelLayout = new javax.swing.GroupLayout(pnLowLevel); + pnLowLevel.setLayout(pnLowLevelLayout); + pnLowLevelLayout.setHorizontalGroup( + pnLowLevelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnLowLevelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(pnLowLevelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(buttonMovePark, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonHomingHexiposi) + .addComponent(buttonMoveCold, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonMoveHeater) + .addComponent(buttonGetGonio) + .addComponent(buttonGetDewar, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(pnLowLevelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(buttonPutDewar, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonPutGonio, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonMoveGonio, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonMoveHome, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonMoveDewar, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonMoveScanner)) + .addContainerGap()) + ); - buttonMoveCold.setText("Move Cold"); - buttonMoveCold.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonMoveColdActionPerformed(evt); - } - }); + pnLowLevelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonGetDewar, buttonGetGonio, buttonHomingHexiposi, buttonMoveCold, buttonMoveDewar, buttonMoveGonio, buttonMoveHeater, buttonMoveHome, buttonMovePark, buttonMoveScanner, buttonPutDewar, buttonPutGonio}); + + pnLowLevelLayout.setVerticalGroup( + pnLowLevelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnLowLevelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(pnLowLevelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(buttonGetDewar) + .addComponent(buttonPutDewar)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(pnLowLevelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(buttonGetGonio) + .addComponent(buttonPutGonio)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(pnLowLevelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(buttonMoveGonio) + .addComponent(buttonHomingHexiposi)) + .addGap(18, 18, 18) + .addGroup(pnLowLevelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(buttonMovePark) + .addComponent(buttonMoveHome)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(pnLowLevelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(buttonMoveDewar) + .addComponent(buttonMoveCold)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(pnLowLevelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(buttonMoveHeater) + .addComponent(buttonMoveScanner)) + .addContainerGap()) + ); + + pnDatabase.setBorder(javax.swing.BorderFactory.createTitledBorder("Database")); buttonClearSampleDb.setText("Clear Sample Db"); buttonClearSampleDb.addActionListener(new java.awt.event.ActionListener() { @@ -362,119 +516,93 @@ public class Commands extends Panel { } }); - javax.swing.GroupLayout panelCommandsLayout = new javax.swing.GroupLayout(panelCommands); - panelCommands.setLayout(panelCommandsLayout); - panelCommandsLayout.setHorizontalGroup( - panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(panelCommandsLayout.createSequentialGroup() + javax.swing.GroupLayout pnDatabaseLayout = new javax.swing.GroupLayout(pnDatabase); + pnDatabase.setLayout(pnDatabaseLayout); + pnDatabaseLayout.setHorizontalGroup( + pnDatabaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnDatabaseLayout.createSequentialGroup() .addContainerGap() - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(buttonMoveHeater, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE) - .addComponent(buttonClearSampleDb, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonGetDewar, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE) - .addComponent(buttonDry, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonPutDewar, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE) - .addComponent(buttonGetGonio, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE) - .addComponent(buttonPutGonio, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE) - .addComponent(buttonMovePark, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE) - .addComponent(buttonRecover, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonMoveCold, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonMount, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE) - .addComponent(buttonUnmount, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)) + .addComponent(buttonClearSampleDb) .addGap(18, 18, Short.MAX_VALUE) - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelCommandsLayout.createSequentialGroup() - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(buttonMoveScanner, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE) - .addComponent(buttonMoveHome, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE) - .addComponent(buttonMoveDewar, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE) - .addComponent(buttonHomingHexiposi, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)) - .addGap(1, 1, 1)) - .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonEnableAll, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGroup(panelCommandsLayout.createSequentialGroup() - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel6) - .addComponent(jLabel7)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(spinnerDrySpeed, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE) - .addComponent(spinnerDryTime)))) - .addComponent(buttonMoveGonio, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE) - .addComponent(buttonResetPuckIds, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(buttonResetPuckIds) .addContainerGap()) ); - panelCommandsLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonClearSampleDb, buttonDry, buttonEnableAll, buttonGetDewar, buttonGetGonio, buttonHomingHexiposi, buttonMount, buttonMoveCold, buttonMoveDewar, buttonMoveGonio, buttonMoveHeater, buttonMoveHome, buttonMovePark, buttonMoveScanner, buttonPutDewar, buttonPutGonio, buttonRecover, buttonResetPuckIds, buttonUnmount}); + pnDatabaseLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonClearSampleDb, buttonResetPuckIds}); - panelCommandsLayout.setVerticalGroup( - panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(panelCommandsLayout.createSequentialGroup() - .addGap(18, 18, 18) - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addGroup(panelCommandsLayout.createSequentialGroup() - .addComponent(buttonMount) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonUnmount) - .addGap(18, 18, 18) - .addComponent(buttonGetDewar) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonPutDewar)) - .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGap(18, 18, 18) - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(buttonGetGonio) - .addComponent(buttonHomingHexiposi)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(buttonPutGonio) - .addComponent(buttonMoveGonio)) - .addGap(18, 18, 18) - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(buttonMovePark) - .addComponent(buttonMoveHome)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(buttonMoveDewar) - .addComponent(buttonMoveCold)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(buttonMoveHeater) - .addComponent(buttonMoveScanner)) - .addGap(18, 18, 18) - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(panelCommandsLayout.createSequentialGroup() - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(buttonDry) - .addComponent(spinnerDryTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(spinnerDrySpeed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel7))) - .addComponent(jLabel6)) - .addGap(18, 18, 18) - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + pnDatabaseLayout.setVerticalGroup( + pnDatabaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnDatabaseLayout.createSequentialGroup() + .addContainerGap() + .addGroup(pnDatabaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(buttonClearSampleDb) .addComponent(buttonResetPuckIds)) - .addGap(18, 18, 18) - .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addContainerGap()) + ); + + pnMotion.setBorder(javax.swing.BorderFactory.createTitledBorder("Motion")); + + buttonRecover.setText("Dewar Recovery"); + buttonRecover.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonRecoverActionPerformed(evt); + } + }); + + buttonEnableAll.setText("Enable Motion"); + buttonEnableAll.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonEnableAllActionPerformed(evt); + } + }); + + javax.swing.GroupLayout pnMotionLayout = new javax.swing.GroupLayout(pnMotion); + pnMotion.setLayout(pnMotionLayout); + pnMotionLayout.setHorizontalGroup( + pnMotionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnMotionLayout.createSequentialGroup() + .addContainerGap() + .addComponent(buttonRecover) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonEnableAll) + .addContainerGap()) + ); + + pnMotionLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonEnableAll, buttonRecover}); + + pnMotionLayout.setVerticalGroup( + pnMotionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnMotionLayout.createSequentialGroup() + .addContainerGap() + .addGroup(pnMotionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(buttonRecover) .addComponent(buttonEnableAll)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(panelCommands, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(pnDry, javax.swing.GroupLayout.PREFERRED_SIZE, 314, Short.MAX_VALUE) + .addComponent(pnMotion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(pnDatabase, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(pnLowLevel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(pnTransfer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(panelCommands, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addComponent(pnDry, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, 0) + .addComponent(pnTransfer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, 0) + .addComponent(pnLowLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, 0) + .addComponent(pnDatabase, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, 0) + .addComponent(pnMotion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); }// //GEN-END:initComponents @@ -557,8 +685,9 @@ public class Commands extends Panel { private void buttonDryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDryActionPerformed double dryTime = (Double) spinnerDryTime.getValue(); double streamTime = (Double) spinnerDrySpeed.getValue(); + boolean park = ckeckParkOnDry.isSelected(); - execute("dry(" + dryTime + ", " + streamTime + ")"); + execute("dry(" + dryTime + ", " + streamTime + (park ? ", wait_cold=-1": "") + ")"); }//GEN-LAST:event_buttonDryActionPerformed private void buttonRecoverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRecoverActionPerformed @@ -577,6 +706,21 @@ public class Commands extends Panel { execute("reset_puck_datamatrix()", true); }//GEN-LAST:event_buttonResetPuckIdsActionPerformed + private void buttonScanPinActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonScanPinActionPerformed + String segment = (String) spinnerSegment.getValue(); + int puck = (Integer) spinnerPuck.getValue(); + int sample = (Integer) spinnerSample.getValue(); + String force = checkForce.isSelected() ? "True" : "False"; + execute("scan_pin('" + segment + "'," + puck + "," + sample + ", force=" + force + ")", false, true); + }//GEN-LAST:event_buttonScanPinActionPerformed + + private void buttonScanPin1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonScanPin1ActionPerformed + String segment = (String) spinnerSegment.getValue(); + int puck = (Integer) spinnerPuck.getValue(); + String force = checkForce.isSelected() ? "True" : "False"; + execute("scan_puck('" + segment + "'," + puck + ", force=" + force + ")", false, true); + }//GEN-LAST:event_buttonScanPin1ActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton buttonClearSampleDb; private javax.swing.JButton buttonDry; @@ -596,9 +740,12 @@ public class Commands extends Panel { private javax.swing.JButton buttonPutGonio; private javax.swing.JButton buttonRecover; private javax.swing.JButton buttonResetPuckIds; + private javax.swing.JButton buttonScanPin; + private javax.swing.JButton buttonScanPin1; private javax.swing.JButton buttonUnmount; private javax.swing.JCheckBox checkDatamatrix; private javax.swing.JCheckBox checkForce; + private javax.swing.JCheckBox ckeckParkOnDry; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; @@ -607,7 +754,11 @@ public class Commands extends Panel { private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JPanel jPanel5; - private javax.swing.JPanel panelCommands; + private javax.swing.JPanel pnDatabase; + private javax.swing.JPanel pnDry; + private javax.swing.JPanel pnLowLevel; + private javax.swing.JPanel pnMotion; + private javax.swing.JPanel pnTransfer; private javax.swing.JSpinner spinnerDrySpeed; private javax.swing.JSpinner spinnerDryTime; private javax.swing.JSpinner spinnerPuck; diff --git a/plugins/LaserUE.java b/plugins/LaserUE.java index ad0c03e..37dd6ee 100644 --- a/plugins/LaserUE.java +++ b/plugins/LaserUE.java @@ -3,6 +3,7 @@ import ch.psi.pshell.device.Readable; import ch.psi.pshell.serial.SerialPortDevice; import ch.psi.pshell.serial.SerialPortDeviceConfig; import static ch.psi.utils.BitMask.*; +import ch.psi.utils.State; import java.io.IOException; /* @@ -35,6 +36,8 @@ public class LaserUE extends SerialPortDevice{ protected void doInitialize() throws IOException, InterruptedException{ super.doInitialize(); //TODO: Start DAQ in ILD1320: http://www.micro-epsilon.com/download/manuals/man--optoNCDT-1320--en.pdf + setState(State.Ready); + write("OUTPUT RS422\n\r"); } public Readable getReadable(){ diff --git a/plugins/MXSC-1.10.0.jar b/plugins/MXSC-1.10.0.jar index d19a2d9..28a93b8 100644 Binary files a/plugins/MXSC-1.10.0.jar and b/plugins/MXSC-1.10.0.jar differ diff --git a/script/calibration/ScanX.py b/script/calibration/ScanX.py new file mode 100644 index 0000000..e72350d --- /dev/null +++ b/script/calibration/ScanX.py @@ -0,0 +1,81 @@ +import plotutils +from mathutils import fit_gaussian, Gaussian + + +d = robot.get_distance_to_pnt("pLaser") +if d<0: + raise Exception ("Error calculating distance to laser: " + str(d)) + +if d>20: + raise Exception ("Should be near the laser position to perform the scan") + +RANGE = [-2.0, 2.0] #[-1.5, 1.5] +STEP = 0.02 +Z_OFFSET = 0 #-1.0 +LATENCY = 0.025 +BORDER_SIZE = 0.15 + +robot.enable() +robot.set_motors_enabled(True) +current_positon = robot_x.getPosition() +robot_z.moveRel(Z_OFFSET) + +robot.setPolling(25) +try: + ret = lscan(robot_x, ue.readable, RANGE[0], RANGE[1], STEP, latency = LATENCY, relative = True) +finally: + robot.setPolling(DEFAULT_ROBOT_POLLING) + +d = ret.getReadable(0) + +first_index = -1 +last_index = -1 +for i in range(len(d)): + if not math.isnan(d[i]): + if first_index<0: + first_index = i + last_index = i + +if first_index == -1 or last_index < first_index: + raise Exception("Invalid range") + + +remove = int(max(BORDER_SIZE, STEP) / STEP) + +_range = [first_index+remove, last_index-remove] +if _range[1] <= _range[0]: + raise Exception("Invalid range: " + str(_range)) + + +center_index = int((_range[0] + _range[1])/2) +center_positon = ret.getPositions(0)[center_index] + + + + +y = ret.getReadable(0)[_range[0] : _range[1]] +x = ret.getPositions(0)[_range[0]: _range[1]] +#x = enforce_monotonic(x) +#(normalization, mean_val, sigma) = fit_gaussian([-v for v in y], x) + + +closest_x = x[y.indexOf(min(y))] +closest_y = y[y.indexOf(min(y))] + + + +if closest_x is None or closest_x <= ret.getPositions(0)[first_index] or closest_x >= ret.getPositions(0)[last_index]: + raise Exception("Invalid Fit") + + + +center_offset = center_positon-closest_y +#center_offset = current_positon-closest_y + + + +p=get_plots()[0] +p.addMarker(closest_y, p.AxisId.X, str(closest_y), Color.GREEN) + +robot.set_motors_enabled(True) +robot_x.move(closest_x) diff --git a/script/calibration/ScanY.py b/script/calibration/ScanY.py index 8793019..17252f1 100644 --- a/script/calibration/ScanY.py +++ b/script/calibration/ScanY.py @@ -37,14 +37,14 @@ for i in range(len(d)): last_index = i if first_index == -1 or last_index < first_index: - raise Exception("Invalid X detection") + raise Exception("Invalid range") remove = int(max(BORDER_SIZE, STEP) / STEP) _range = [first_index+remove, last_index-remove] if _range[1] <= _range[0]: - raise Exception("invalid range: " + str(_range)) + raise Exception("Invalid range: " + str(_range)) center_index = int((_range[0] + _range[1])/2) diff --git a/script/calibration/ToolCalibration3.py b/script/calibration/ToolCalibration3.py new file mode 100644 index 0000000..e1ee185 --- /dev/null +++ b/script/calibration/ToolCalibration3.py @@ -0,0 +1,65 @@ +import plotutils +from mathutils import fit_gaussian, Gaussian + +cal_tool = TOOL_CALIBRATION + +robot.set_tool(cal_tool) +robot.enable() +move_to_laser() + + +robot.set_motors_enabled(True) +robot.set_joint_motors_enabled(True) +initial_pos = robot.get_cartesian_pos() + +#robot.align() + +run("calibration/ScanX") + +pos1 = robot.get_cartesian_pos() +x1, l1 = closest_x, closest_y + +print "Closest 1: ", [x1, l1] +print "Position 1: ", pos1 + + +pj6 = robot_j6.position +if pj6>0: + robot_j6.move(pj6 - 180.0) +else: + robot_j6.move(pj6 + 180.0) + + +run("calibration/ScanX") + + +x2, l2 = closest_x, closest_y +pos2 = robot.get_cartesian_pos() + +print "Closest 2: ", [x2, l2] +print "Position 2: ", pos2 + + +#Updates the tool +t=robot.get_tool_trsf(TOOL_DEFAULT) + +xoff = (x1-x2)/2 +yoff = (l2 - l1)/2 +xrot = math.degrees(math.atan(yoff/t[2])) +yrot = math.degrees(math.atan(xoff/t[2])) + +print "Former tool: " + str(t) +t[0]=xoff +t[1]=-yoff +print "Offset: ", [t[0], t[1]] + +print "CALIBRATED tool: " + str(t) +#robot.set_tool_trsf(t, TOOL_DEFAULT) + +robot.set_tool(TOOL_DEFAULT) +d = robot.get_distance_to_pnt("pLaser") +if d5: - raise Exception("Invlid pin offset: " + str(val)) + raise Exception("Invalid pin offset: " + str(val)) try: set_setting("pin_offset",float(val)) except: @@ -250,12 +251,31 @@ def get_pin_offset(): try: ret = float(get_setting("pin_offset")) if abs(ret) >5: - raise Exception("Invlid configured pin offset: " + str(ret)) + raise Exception("Invalid configured pin offset: " + str(ret)) return ret except: log("Error getting pin offset: " + str(sys.exc_info()[1]), False) return 0.0 + +def set_pin_angle_offset(val): + if (abs(val) > 180.0) or (abs(val) < -180.0): + raise Exception("Invalid pin angle offset: " + str(val)) + try: + set_setting("pin_angle_offset",float(val)) + except: + log("Error setting pin angle offset: " + str(sys.exc_info()[1]), False) + +def get_pin_angle_offset(): + try: + ret = float(get_setting("pin_angle_offset")) + if (abs(ret) > 180.0) or (abs(ret) < -180.0): + raise Exception("Invalid configured pin angle offset: " + str(ret)) + return ret + except: + log("Error getting pin angle offset: " + str(sys.exc_info()[1]), False) + return 0.0 + def is_force_dry(): try: dry_mount_counter = int(get_setting("dry_mount_counter")) diff --git a/script/motion/dry.py b/script/motion/dry.py index edaae41..1f606ee 100644 --- a/script/motion/dry.py +++ b/script/motion/dry.py @@ -1,6 +1,6 @@ -def dry(heat_time=30.0, speed=0.5, wait_cold = 30.0): +def dry(heat_time=30.0, speed=0.4, wait_cold = 30.0): """ heat_time (float): in seconds speed (float): % of nominal speed @@ -9,7 +9,7 @@ def dry(heat_time=30.0, speed=0.5, wait_cold = 30.0): """ print "dry" - #Initial checks + #Initial chec robot.assert_no_task() robot.reset_motion() robot.wait_ready() @@ -40,4 +40,4 @@ def dry(heat_time=30.0, speed=0.5, wait_cold = 30.0): robot.move_cold() time.sleep(wait_cold) else: - robot.move_dewar() \ No newline at end of file + robot.move_park() \ No newline at end of file diff --git a/script/motion/mount.py b/script/motion/mount.py index ec460db..ca4fbb0 100644 --- a/script/motion/mount.py +++ b/script/motion/mount.py @@ -56,7 +56,7 @@ def mount(segment, puck, sample, force=False, read_dm=False): if read_dm: barcode_reader.start_read(10.0) robot.move_scanner() - time.sleep(1.0) + #time.sleep(1.0) robot.move_gonio() diff --git a/script/motion/move_scanner.py b/script/motion/move_scanner.py index 791e634..b8fe41f 100644 --- a/script/motion/move_scanner.py +++ b/script/motion/move_scanner.py @@ -1,3 +1,4 @@ + def move_scanner(): """ """ @@ -13,14 +14,17 @@ def move_scanner(): #Enabling enable_motion() - #barcode_reader.start_read(20.0) - + barcode_reader.start_read(10.0) if not robot.is_scanner(): robot.move_scanner() - #robot.do_scan() - #dm = barcode_reader.get_readout() - dm = barcode_reader.read(0.5) + time.sleep(0.25) + dm = barcode_reader.get_readout() + if dm is None: + detected = is_pin_detected_in_scanner() + else: + detected = True - print "Datamatrix: " , dm - #print "Datamatrix: " , barcode_reader.wait_readout() \ No newline at end of file + print ("Detected: " + str( detected) + " - Datamatrix: " + str(dm)) + + return (detected, dm) diff --git a/script/motion/scan_pin.py b/script/motion/scan_pin.py index 9824652..7e35def 100644 --- a/script/motion/scan_pin.py +++ b/script/motion/scan_pin.py @@ -1,48 +1,42 @@ -segment, puck, sample, force = "B",1,1, True -pin_name = get_sample_name(segment, puck, sample) +def scan_pin(segment, puck, sample, force=False): + pin_name = get_sample_name(segment, puck, sample) + + print "scan pin", pin_name + #Initial checks + assert_valid_address(segment, puck, sample) + assert_puck_detected(segment, puck) + + robot.assert_no_task() + robot.reset_motion() + robot.wait_ready() + robot.assert_cleared() + #robot.assert_in_known_point() + + #Enabling + + set_status("Scanning pin: " + str(pin_name)) + + enable_motion() + set_hexiposi(segment) + if not force: + visual_check_hexiposi(segment) + + if not robot.is_dewar(): + robot.move_dewar() + + robot.get_dewar(segment, puck, sample) + + (detected, dm) = move_scanner() + update_samples_info_sample_scan(get_puck_name(segment, puck), sample, detected, dm) + + robot.move_dewar() + robot.put_dewar(segment, puck, sample) + return (detected, dm) -print "scan pin", pin_name -#Initial checks -robot.assert_no_task() -robot.reset_motion() -robot.wait_ready() -robot.assert_cleared() -#robot.assert_in_known_point() - -#Enabling - -set_status("Scanning pin: " + str(pin_name)) - -enable_motion() -set_hexiposi(segment) -if not force: - visual_check_hexiposi(segment) - - -robot.move_park() - -gripper_cam.update() -background_img = gripper_cam.getImage() - - -if not robot.is_dewar(): - robot.move_dewar() - -robot.get_dewar(segment, puck, sample) - -robot.move_park() -gripper_cam.update() -sample_img = gripper_cam.getImage() - -barcode_reader.start_read(10.0) -robot.move_scanner() -time.sleep(1.0) - -mount_sample_id = barcode_reader.get_readout() -print "Datamatrix: " , mount_sample_id - -robot.move_dewar() -robot.put_dewar(segment, puck, sample) - - \ No newline at end of file + +def scan_puck(segment, puck, force=False): + ret = [] + for i in range(16): + ret.append(scan_pin (segment, puck, i+1, force)) + return ret diff --git a/script/motion/tools.py b/script/motion/tools.py index b2aefb2..40e141e 100644 --- a/script/motion/tools.py +++ b/script/motion/tools.py @@ -155,4 +155,16 @@ def get_sample_name(segment, puck, sample): puck_name = get_puck_name(segment, puck) return None if (puck_name is None) else puck_name + str(sample) - \ No newline at end of file + +def is_pin_detected_in_scanner(): + samples = [] + for i in range(10): + samples.append(laser_distance.read()) + time.sleep(0.05) + av = mean(samples) + for s in samples: + if s<=1: + return False + if abs(s-av) > 0.1: + return False + return True \ No newline at end of file