diff --git a/config/settings.properties b/config/settings.properties index df0af8a..67c8b1d 100644 --- a/config/settings.properties +++ b/config/settings.properties @@ -1,4 +1,4 @@ -#Thu Feb 14 11:00:38 CET 2019 +#Thu Feb 14 11:23:32 CET 2019 barcode_reader_scan_pucks=true dry_mount_counter=0 dry_timestamp=1.543854393748E9 diff --git a/plugins/BarcodeReaderPanel.form b/plugins/BarcodeReaderPanel.form index 3e615f6..1d2c4af 100644 --- a/plugins/BarcodeReaderPanel.form +++ b/plugins/BarcodeReaderPanel.form @@ -100,9 +100,6 @@ - - - @@ -111,7 +108,6 @@ - diff --git a/plugins/BarcodeReaderPanel.java b/plugins/BarcodeReaderPanel.java index cb269c2..d6dabed 100644 --- a/plugins/BarcodeReaderPanel.java +++ b/plugins/BarcodeReaderPanel.java @@ -1,4 +1,5 @@ import ch.psi.pshell.core.Context; +import ch.psi.pshell.device.Device; import ch.psi.pshell.swing.DevicePanel; import ch.psi.utils.swing.SwingUtils; import java.util.concurrent.CompletableFuture; @@ -17,11 +18,21 @@ public class BarcodeReaderPanel extends DevicePanel { CompletableFuture future; + + @Override + public void setDevice(Device device){ + super.setDevice(device); + if (device != null){ + deviceStatePanel1.setDevice(device); + deviceValuePanel1.setDevice(device); + } + } + @Override public void onTimer(){ if ((getDevice()!=null) && enabled){ if ((future==null) || (future.isDone())){ - future = Context.getInstance().evalLineBackgroundAsync("barcode_reader.get()"); + future = Context.getInstance().evalLineBackgroundAsync(getDevice().getName() + ".get()"); } } } @@ -109,10 +120,7 @@ public class BarcodeReaderPanel extends DevicePanel { .addContainerGap()) ); - deviceStatePanel1.setDeviceName("barcode_reader"); - deviceValuePanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Value")); - deviceValuePanel1.setDeviceName("barcode_reader"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); @@ -135,18 +143,18 @@ public class BarcodeReaderPanel extends DevicePanel { }// //GEN-END:initComponents private void buttonEnableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonEnableActionPerformed - execute("barcode_reader.enable()", false); + execute(getDevice().getName() + ".enable()", false); enabled = true; }//GEN-LAST:event_buttonEnableActionPerformed private void buttonDisableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDisableActionPerformed enabled = false; - execute("barcode_reader.disable()", false); + execute(getDevice().getName() + ".disable()", false); }//GEN-LAST:event_buttonDisableActionPerformed private void buttonReadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReadActionPerformed enabled = false; - execute("barcode_reader.read(5.0) ", true); + execute(getDevice().getName() + ".read(5.0) ", true); }//GEN-LAST:event_buttonReadActionPerformed diff --git a/plugins/Commands.form b/plugins/Commands.form index 70c71b4..add3c8a 100644 --- a/plugins/Commands.form +++ b/plugins/Commands.form @@ -132,7 +132,7 @@ - + @@ -150,7 +150,7 @@ - + diff --git a/plugins/Commands.java b/plugins/Commands.java index f861b06..c1f41b5 100644 --- a/plugins/Commands.java +++ b/plugins/Commands.java @@ -172,7 +172,7 @@ public class Commands extends Panel { jLabel6.setText("Heat time(s):"); - spinnerDryTime.setModel(new javax.swing.SpinnerNumberModel(30.0d, 1.0d, 30.0d, 1.0d)); + spinnerDryTime.setModel(new javax.swing.SpinnerNumberModel(30.0d, 1.0d, 50.0d, 1.0d)); buttonDry.setText("Dry"); buttonDry.addActionListener(new java.awt.event.ActionListener() { @@ -181,7 +181,7 @@ public class Commands extends Panel { } }); - spinnerDrySpeed.setModel(new javax.swing.SpinnerNumberModel(0.5d, 0.1d, 10.0d, 1.0d)); + spinnerDrySpeed.setModel(new javax.swing.SpinnerNumberModel(0.4d, 0.1d, 1.0d, 0.1d)); jLabel7.setText("Speed(%):"); diff --git a/plugins/PuckDetectionPanel.form b/plugins/PuckDetectionPanel.form index 9d644a4..550d155 100644 --- a/plugins/PuckDetectionPanel.form +++ b/plugins/PuckDetectionPanel.form @@ -116,12 +116,19 @@ + + + + + - + + + @@ -173,6 +180,14 @@ + + + + + + + + diff --git a/plugins/PuckDetectionPanel.java b/plugins/PuckDetectionPanel.java index e36c4db..1326665 100644 --- a/plugins/PuckDetectionPanel.java +++ b/plugins/PuckDetectionPanel.java @@ -78,6 +78,7 @@ public class PuckDetectionPanel extends DevicePanel { jPanel1 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); table = new javax.swing.JTable(); + buttonConfigure = new javax.swing.JButton(); deviceStatePanel1 = new ch.psi.pshell.swing.DeviceStatePanel(); jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Raspberry Pi ")); @@ -186,6 +187,13 @@ public class PuckDetectionPanel extends DevicePanel { }); jScrollPane1.setViewportView(table); + buttonConfigure.setText("Configure"); + buttonConfigure.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonConfigureActionPerformed(evt); + } + }); + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( @@ -194,11 +202,17 @@ public class PuckDetectionPanel extends DevicePanel { .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addContainerGap()) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonConfigure) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 282, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonConfigure) .addContainerGap()) ); @@ -236,9 +250,24 @@ public class PuckDetectionPanel extends DevicePanel { execute("start_puck_detection()", false); }//GEN-LAST:event_buttonPuckDetStartActionPerformed + private void buttonConfigureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConfigureActionPerformed + try { + if (table.getSelectedRow()<0){ + throw new Exception("Select a puck"); + } + String name = table.getModel().getValueAt(table.getSelectedRow(), 0).toString(); + Puck puck = getDevice().getPuck(name); + DevicePanel.showConfigEditor(this, puck, true, false); + } catch (Exception ex) { + showException(ex); + } + + }//GEN-LAST:event_buttonConfigureActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton buttonConfigure; private javax.swing.JButton buttonPuckDetCheck; private javax.swing.JButton buttonPuckDetStart; private javax.swing.JButton buttonPuckDetStop; diff --git a/plugins/Recovery.java b/plugins/Recovery.java index 7b6381b..844c3c1 100644 --- a/plugins/Recovery.java +++ b/plugins/Recovery.java @@ -17,7 +17,7 @@ public class Recovery extends Panel { public Recovery() { initComponents(); - startTimer(5000, 200); + startTimer(2500, 200); } //Overridable callbacks diff --git a/plugins/SmartMagnetPanel.form b/plugins/SmartMagnetPanel.form index f9de056..432e7bd 100644 --- a/plugins/SmartMagnetPanel.form +++ b/plugins/SmartMagnetPanel.form @@ -18,10 +18,9 @@ - - - - + + + @@ -33,6 +32,8 @@ + + @@ -171,7 +172,7 @@ - + @@ -183,7 +184,11 @@ - + + + + + @@ -194,7 +199,9 @@ - + + + @@ -205,16 +212,72 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/SmartMagnetPanel.java b/plugins/SmartMagnetPanel.java index 2108837..589fb82 100644 --- a/plugins/SmartMagnetPanel.java +++ b/plugins/SmartMagnetPanel.java @@ -5,8 +5,12 @@ import ch.psi.pshell.swing.DevicePanel; import ch.psi.pshell.core.Context; import ch.psi.utils.State; import java.awt.Color; +import java.io.IOException; import java.lang.reflect.Method; import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.script.ScriptException; /** * @@ -30,38 +34,37 @@ public class SmartMagnetPanel extends DevicePanel { 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 protected void onDeviceStateChanged(State state, State former) { switch(state){ + case Paused: + ledSupressed.setColor(Color.ORANGE); + ledStatus.setColor(Color.GREEN); + ledMounted.setColor(Color.RED); + break; case Ready: + ledSupressed.setColor(Color.BLACK); ledStatus.setColor(Color.GREEN); ledMounted.setColor(Color.GREEN); break; case Busy: + ledSupressed.setColor(Color.BLACK); ledStatus.setColor(Color.GREEN); ledMounted.setColor(Color.ORANGE); break; case Fault: + ledSupressed.setColor(Color.RED); ledStatus.setColor(Color.RED); ledMounted.setColor(Color.RED); break; default: + ledSupressed.setColor(Color.BLACK); ledStatus.setColor(Color.BLACK); ledMounted.setColor(Color.BLACK); break; } + buttonSupressOn.setEnabled((state==State.Ready) || (state == State.Busy)); + buttonSupressOff.setEnabled(state == State.Paused); } @Override @@ -89,7 +92,11 @@ public class SmartMagnetPanel extends DevicePanel { panelCurrent = new ch.psi.pshell.swing.ProcessVariablePanel(); jPanel2 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); - ledMountPosition = new ch.psi.pshell.swing.Led(); + ledSupressed = new ch.psi.pshell.swing.Led(); + buttonSupressOn = new javax.swing.JButton(); + buttonSupressOff = new javax.swing.JButton(); + jPanel3 = new javax.swing.JPanel(); + buttonConfiguration = new javax.swing.JButton(); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Status")); @@ -164,12 +171,26 @@ public class SmartMagnetPanel extends DevicePanel { panelCurrent.setBorder(javax.swing.BorderFactory.createTitledBorder("Current")); panelCurrent.setDeviceName("smc_current"); - jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Gonio")); + jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Supress")); jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); - jLabel2.setText("Mount Position:"); + jLabel2.setText("Supressed:"); - ledMountPosition.setFont(new java.awt.Font("SansSerif", 0, 18)); // NOI18N + ledSupressed.setFont(new java.awt.Font("SansSerif", 0, 18)); // NOI18N + + buttonSupressOn.setText("On"); + buttonSupressOn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonSupressOnActionPerformed(evt); + } + }); + + buttonSupressOff.setText("Off"); + buttonSupressOff.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonSupressOffActionPerformed(evt); + } + }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); @@ -179,16 +200,51 @@ public class SmartMagnetPanel extends DevicePanel { .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) + .addComponent(ledSupressed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonSupressOn) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(buttonSupressOff) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); + + jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonSupressOff, buttonSupressOn}); + jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .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)) + .addComponent(ledSupressed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonSupressOn) + .addComponent(buttonSupressOff)) + .addContainerGap()) + ); + + jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Configuration")); + + buttonConfiguration.setText("Configuration"); + buttonConfiguration.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonConfigurationActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonConfiguration) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addComponent(buttonConfiguration) .addContainerGap()) ); @@ -198,9 +254,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.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)) + .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) + .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -211,21 +267,51 @@ public class SmartMagnetPanel extends DevicePanel { .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(jPanel3, 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 buttonSupressOnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSupressOnActionPerformed + try { + Context.getInstance().evalLineBackground("smart_magnet.set_supress(True)"); + } catch (Exception ex) { + Logger.getLogger(SmartMagnetPanel.class.getName()).log(Level.SEVERE, null, ex); + } + }//GEN-LAST:event_buttonSupressOnActionPerformed + + private void buttonSupressOffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSupressOffActionPerformed + try { + Context.getInstance().evalLineBackground("smart_magnet.set_supress(False)"); + } catch (Exception ex) { + Logger.getLogger(SmartMagnetPanel.class.getName()).log(Level.SEVERE, null, ex); + } + }//GEN-LAST:event_buttonSupressOffActionPerformed + + private void buttonConfigurationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConfigurationActionPerformed + try { + this.showConfigEditor(true, false); + } catch (Exception ex) { + Logger.getLogger(SmartMagnetPanel.class.getName()).log(Level.SEVERE, null, ex); + } + }//GEN-LAST:event_buttonConfigurationActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton buttonConfiguration; + private javax.swing.JButton buttonSupressOff; + private javax.swing.JButton buttonSupressOn; 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 javax.swing.JPanel jPanel3; private ch.psi.pshell.swing.Led ledMounted; private ch.psi.pshell.swing.Led ledStatus; + private ch.psi.pshell.swing.Led ledSupressed; private ch.psi.pshell.swing.ProcessVariablePanel panelCurrent; private ch.psi.pshell.swing.DeviceValuePanel panelCurrentRb; private javax.swing.JPanel panelPowerCtr; diff --git a/script/devices/Hexiposi.py b/script/devices/Hexiposi.py index de958ed..5359532 100644 --- a/script/devices/Hexiposi.py +++ b/script/devices/Hexiposi.py @@ -154,7 +154,7 @@ class Hexiposi(DiscretePositionerBase): #http://myriotell:8003/hexiposi/get dev = Hexiposi("hexiposi", "myriotell") #If no Rotation Lid is mounted set it to simulated -#dev.setSimulated() +dev.setSimulated() add_device(dev, True) hexiposi.polling=1000