diff --git a/plugins/Kollimators.form b/plugins/Kollimators.form index 7e4fe6b..edc52ef 100644 --- a/plugins/Kollimators.form +++ b/plugins/Kollimators.form @@ -22,20 +22,20 @@ - + - + - + - + @@ -43,12 +43,12 @@ - + - + @@ -56,12 +56,12 @@ - + - + @@ -79,24 +79,24 @@ - + - + - + - + - + - + - + - + @@ -111,7 +111,7 @@ - + @@ -121,7 +121,7 @@ - + @@ -131,7 +131,7 @@ - + @@ -141,7 +141,7 @@ - + @@ -151,7 +151,7 @@ - + @@ -161,7 +161,7 @@ - + @@ -171,15 +171,15 @@ - + - + - + diff --git a/plugins/Kollimators.java b/plugins/Kollimators.java index 9981c5f..49a56e6 100644 --- a/plugins/Kollimators.java +++ b/plugins/Kollimators.java @@ -27,57 +27,57 @@ public class Kollimators extends javax.swing.JPanel { private void initComponents() { jLabel1 = new javax.swing.JLabel(); - jTextField1 = new javax.swing.JTextField(); + jTextSta = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); - jTextField2 = new javax.swing.JTextField(); + jTextIst1 = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); - jTextField3 = new javax.swing.JTextField(); + jTextIst2 = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); - jTextField4 = new javax.swing.JTextField(); + jTextDir = new javax.swing.JTextField(); jLabel5 = new javax.swing.JLabel(); - jTextField5 = new javax.swing.JTextField(); + jTextRef1 = new javax.swing.JTextField(); jLabel6 = new javax.swing.JLabel(); - jTextField6 = new javax.swing.JTextField(); + jTextRef2 = new javax.swing.JTextField(); jLabel7 = new javax.swing.JLabel(); - jTextField7 = new javax.swing.JTextField(); - jTextField8 = new javax.swing.JTextField(); + jTextDist = new javax.swing.JTextField(); + jTextRes = new javax.swing.JTextField(); jLabel8 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); jLabel1.setText("STA:"); - jTextField1.setText("jTextField1"); + jTextSta.setText("jTextField1"); jLabel2.setText("IST1:"); - jTextField2.setText("jTextField1"); + jTextIst1.setText("jTextField1"); jLabel3.setText("IST2:"); - jTextField3.setText("jTextField1"); + jTextIst2.setText("jTextField1"); jLabel4.setText("Direction:"); - jTextField4.setText("jTextField1"); + jTextDir.setText("jTextField1"); jLabel5.setText("REF1:"); - jTextField5.setText("jTextField1"); + jTextRef1.setText("jTextField1"); jLabel6.setText("REF2:"); - jTextField6.setText("jTextField1"); + jTextRef2.setText("jTextField1"); jLabel7.setText("DIST:"); - jTextField7.setText("jTextField1"); - jTextField7.addActionListener(new java.awt.event.ActionListener() { + jTextDist.setText("jTextField1"); + jTextDist.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - jTextField7ActionPerformed(evt); + jTextDistActionPerformed(evt); } }); - jTextField8.setText("jTextField1"); + jTextRes.setText("jTextField1"); jLabel8.setText("Resolution:"); @@ -93,39 +93,39 @@ public class Kollimators extends javax.swing.JPanel { .addGroup(layout.createSequentialGroup() .addComponent(jLabel7) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextDist, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jTextIst2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextSta, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(jTextIst1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createSequentialGroup() .addComponent(jLabel5) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jTextRef1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel6) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jTextField6))) + .addComponent(jTextRef2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jTextDir, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel8) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(jTextRes, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton1) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) @@ -139,31 +139,46 @@ public class Kollimators extends javax.swing.JPanel { .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) - .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextSta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2) - .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextIst1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5) - .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextRef1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4) - .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jTextDir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) - .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextIst2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel6) - .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextRef2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel7) - .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextDist, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel8) - .addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addComponent(jTextRes, 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 - private void jTextField7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField7ActionPerformed + private void jTextDistActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextDistActionPerformed // TODO add your handling code here: - }//GEN-LAST:event_jTextField7ActionPerformed + }//GEN-LAST:event_jTextDistActionPerformed + + /** + * animate the panel (caget/caset). Called from TestingList + * @param deviceName + */ + public void animate(String deviceName){ + this.jTextDir.setText(deviceName+"?"); + this.jTextDist.setText(deviceName+"?"); + this.jTextIst1.setText(deviceName+":IST1:1"); + this.jTextIst2.setText(deviceName+":IST2:1"); + this.jTextRef1.setText(deviceName+":REF1:1"); + this.jTextRef2.setText(deviceName+":REF2:1"); + this.jTextRes.setText(deviceName+"?"); + this.jTextSta.setText(deviceName+":STA:2"); + } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; @@ -175,13 +190,13 @@ public class Kollimators extends javax.swing.JPanel { private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; - private javax.swing.JTextField jTextField1; - private javax.swing.JTextField jTextField2; - private javax.swing.JTextField jTextField3; - private javax.swing.JTextField jTextField4; - private javax.swing.JTextField jTextField5; - private javax.swing.JTextField jTextField6; - private javax.swing.JTextField jTextField7; - private javax.swing.JTextField jTextField8; + private javax.swing.JTextField jTextDir; + private javax.swing.JTextField jTextDist; + private javax.swing.JTextField jTextIst1; + private javax.swing.JTextField jTextIst2; + private javax.swing.JTextField jTextRef1; + private javax.swing.JTextField jTextRef2; + private javax.swing.JTextField jTextRes; + private javax.swing.JTextField jTextSta; // End of variables declaration//GEN-END:variables } diff --git a/plugins/TestingList.java b/plugins/TestingList.java index 673fcd5..1d1c5cf 100644 --- a/plugins/TestingList.java +++ b/plugins/TestingList.java @@ -11,7 +11,9 @@ import ch.psi.pshell.ui.Panel; import ch.psi.pshell.ui.Plugin; import ch.psi.pshell.ui.View; import ch.psi.utils.swing.SwingUtils; +import ch.psi.utils.swing.SwingUtils.OptionType; import ch.psi.wsaf.Task; +import java.awt.Component; import java.awt.Point; import java.io.BufferedReader; import java.io.File; @@ -34,6 +36,7 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; @@ -299,8 +302,7 @@ public class TestingList extends Panel { * initialise panel */ private void initialise(){ - initComponents(); - //closeCustomPanel(); + initComponents(); initLogger(); buildTable(); @@ -441,6 +443,21 @@ public class TestingList extends Panel { } + /** + * get the presently active custom panel + * + * @return custom panel as component + */ + private Component getCustomPanel(){ + Component customPanel = null; + if(this.jPanelCustomFrame.getComponentCount() >0){ + Component components[] = this.jPanelCustomFrame.getComponents(); + //there is only one component + customPanel = components[0]; + } + return customPanel; + } + /** * add custom panel if specified. * Custom panels are java classes. To add a new custom panel MyNewPanel: @@ -453,15 +470,51 @@ public class TestingList extends Panel { */ private void loadCustomPanel(String sPanelClassName){ closeCustomPanel(); - if (sPanelClassName == null || sPanelClassName == "") { + if (sPanelClassName == null || sPanelClassName.trim() == "" || sPanelClassName.isEmpty()) { return; } + + //if a custom panel is shown, the tests cannot be run in parallel, + //they can only be run in series (one after the other). + boolean changeSequenceToAfter = true;// = SwingUtils.OptionResult.No; + for (int row = 0; row < jTable1.getRowCount(); row++) { + try{ + if(jTable1.getValueAt(row, COL.STARTSEQUENCE.ordinal())==null) continue; + String sStartSequence = String.valueOf(jTable1.getValueAt(row, COL.STARTSEQUENCE.ordinal())); + if(sStartSequence.equals(StartSequence.TOGETHER.toString())){ + SwingUtils.OptionResult ret = SwingUtils.showOption(this, "checkDataFields()", + "A custom panel " + + " is active. Tests can only run in sequence (one after the other). \nDo you want to set tests in sequence?", + OptionType.YesNoCancel); + if(ret == SwingUtils.OptionResult.Yes){ + changeSequenceToAfter = true ; + } else { + changeSequenceToAfter = false ; + } + break; + } + } catch (NullPointerException ex){ + continue; + } + } + //Set all active tests sequence to "After previous" + if(changeSequenceToAfter ){ + for (int row = 0; row < jTable1.getRowCount(); row++) { + boolean bSelected = (boolean) jTable1.getValueAt(row, COL.CHECK.ordinal()); + if(bSelected){ + jTable1.setValueAt(StartSequence.AFTER.toString(), row, COL.STARTSEQUENCE.ordinal()); + } + } + } else { //user does not wat to change running sequence from parallel to sequential + return; + } + try { //create a class to visualise the details panel Class panelClass = getController().getClassByName(sPanelClassName); JPanel detailsPanel = (JPanel) panelClass.getConstructor(new Class[]{String.class}).newInstance(new Object[]{""}); this.jPanelCustomFrame.add(detailsPanel); - this.jLabelCustomPanelName.setText(sPanelClassName); + this.jLabelCustomPanelName.setText("Custom panel: "+sPanelClassName); repaint(); revalidate(); //store custom panel in the properties @@ -483,6 +536,8 @@ public class TestingList extends Panel { Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); } } + + /** * write info into a log file * @param text the info to be logged @@ -1270,6 +1325,7 @@ public class TestingList extends Panel { //if only enabled tests are visible, disable the move buttons this.jButtonMoveUp.setEnabled(!show); this.jButtonMoveDown.setEnabled(!show); + //check related checkboxes jCheckBoxMenuShowSelectedTests.setSelected(show); jCheckBoxMenuShowSelectedTests1.setSelected(show); } @@ -1348,6 +1404,7 @@ public class TestingList extends Panel { /** * move selected rows up in table + * */ private void moveUp() { DefaultTableModel model = (DefaultTableModel) jTable1.getModel(); @@ -1443,6 +1500,39 @@ public class TestingList extends Panel { dlg.pack(); dlg.setVisible(true); } + + /** + * Starts animating the custom panel, if present + * + * Note: the custom panel must have the public method "animate(String deviceName)" + * + * @param deviceName name of the device. The panel should then append the epics PV to the device name for caget/caset + */ + public void animateCustomPanel(String deviceName) { + try { + Component customPanel = getCustomPanel(); + //if no custom panel: nothing to do + if(customPanel==null) return; + //call the method "animate" of the custom panel (this function must be there) + Class[] cArg = new Class[1]; + cArg[0] = String.class; + Method animate = customPanel.getClass().getMethod("animate", cArg); + System.out.println("method = " + animate.toString()); + animate.invoke(customPanel, deviceName); + } catch (NoSuchMethodException ex) { + System.out.println("animateCustomPanel(): "+String.valueOf(ex)); + } catch (SecurityException ex) { + System.out.println("animateCustomPanel(): "+String.valueOf(ex)); + } catch (IllegalAccessException ex) { + System.out.println("animateCustomPanel(): "+String.valueOf(ex)); + } catch (IllegalArgumentException ex) { + System.out.println("animateCustomPanel(): "+String.valueOf(ex)); + } catch (InvocationTargetException ex) { + System.out.println("animateCustomPanel(): "+String.valueOf(ex)); + } catch (Exception ex){ + System.out.println("animateCustomPanel(): "+String.valueOf(ex)); + } + } /** * put the test result in table @@ -1708,7 +1798,7 @@ public class TestingList extends Panel { int[] selectedTestsRows = {}; //scan through the table starting from 'position' and execute the first selected test found int row = 0;// position; - if (row >= 0 && row < jTable1.getRowCount()) { + if (row < jTable1.getRowCount()) { for (row = position; row < jTable1.getRowCount(); row++) { bSelected = (boolean) jTable1.getValueAt(row, COL.CHECK.ordinal()); sStartSequence = jTable1.getValueAt(row, COL.STARTSEQUENCE.ordinal()).toString(); @@ -1765,7 +1855,7 @@ public class TestingList extends Panel { testArgs.put(testArgNames.STATUS.toString(), false); return testArgs; - } + } /** * convert HashMap string separators to python dictionary string @@ -1871,7 +1961,7 @@ public class TestingList extends Panel { int i = 0; int iTotalEntries = hTests.entrySet().size(); HashMap args = new HashMap(); - System.out.println("hTests: "+hTests.entrySet().toString()); + //System.out.println("hTests: "+hTests.entrySet().toString()); if(hTests.isEmpty()) return iRet; for (Map.Entry hTest : hTests.entrySet()) { sTestPath = (String) hTest.getValue().get(testArgNames.TEST_PATH.toString()); @@ -1889,7 +1979,10 @@ public class TestingList extends Panel { sParallelizeCommand = sParallelizeCommand + ")))"; //very last part of command "parallelize" } } - System.out.println(sParallelizeCommand); + //animate the custom panel (if present) + animateCustomPanel(sDeviceName); + //System.out.println(sParallelizeCommand); + //run test(s) Object ret = eval(sParallelizeCommand); System.out.println(ret); String sTestResult, sTestStatus; @@ -1986,6 +2079,10 @@ public class TestingList extends Panel { updateStatus(); } + /** + * hide a specific column + * @param column column to hide + */ private void hideColumn(COL column) { jTable1.getColumnModel().getColumn(column.ordinal()).setMinWidth(0); jTable1.getColumnModel().getColumn(column.ordinal()).setMaxWidth(0); diff --git a/script/tests/tests.properties b/script/tests/tests.properties index 769e0c7..6fa6d63 100644 --- a/script/tests/tests.properties +++ b/script/tests/tests.properties @@ -1,5 +1,5 @@ #TestingList for pshell: configuration properties -#Thu Oct 15 11:46:28 CEST 2015 -customPanel= +#Fri Oct 16 08:06:48 CEST 2015 +customPanel=Kollimators showEnabledTestsOnly=true listFilter=parallelizeOneTest