diff --git a/plugins/TestingList.java b/plugins/TestingList.java index fe32851..13ac919 100644 --- a/plugins/TestingList.java +++ b/plugins/TestingList.java @@ -2,6 +2,7 @@ * Copyright (c) 2015 Paul Scherrer Institute. All rights reserved. */ +import ch.psi.pshell.core.Controller; import ch.psi.utils.swing.MonitoredPanel; import ch.psi.pshell.ui.Panel; import ch.psi.utils.swing.SwingUtils; @@ -816,7 +817,8 @@ public class TestingList extends Panel { //collect tests to be launched in parallel //the test must be: selected, set as start with previous, pending. //alternatively, the test must be: selected, first of the list. - System.out.println(String.valueOf(row) +"\t"+ String.valueOf(bSelected) +"\t"+ String.valueOf(selectedTestsRows.length) +"\t"+ sStartSequence +"\t"+ sStatus); + + //System.out.println(String.valueOf(row) +"\t"+ String.valueOf(bSelected) +"\t"+ String.valueOf(selectedTestsRows.length) +"\t"+ sStartSequence +"\t"+ sStatus); if( bSelected && sStatus.equals(TestStatus.PENDING.toString()) && @@ -844,8 +846,8 @@ public class TestingList extends Panel { //start all the tests in the rowsToExecute private int executeParallelTestsGroup(int[] rowsToExecute){ - HashMap args = new HashMap(); int iRet = -1; + RunTest runTest; for(int row: rowsToExecute){ String sDeviceName = jTable1.getValueAt(row, COL.DEVICENAME.ordinal()).toString(); String sTestName = jTable1.getValueAt(row, COL.TESTNAME.ordinal()).toString(); @@ -870,16 +872,24 @@ public class TestingList extends Panel { logger.log(Level.INFO, "Running Test '" + sTestName + "'. No parameters found."); System.out.println("Running test '"+sTestName + "'. No parameters found."); } +// runTest = new RunTest(sDeviceName, sTestPath, mParameters); +// Thread t = new Thread(runTest); +// t.start(); + HashMap args = new HashMap(); + Object ret = eval("ret"); + for(int i=0 ; i<1000000 ; i++){ + ret = eval("ret"); + if(String.valueOf(ret) != "") break; + } args.put("parameters", mParameters); args.put("device", sDeviceName); args.put("ret", ""); args.put("status", false); System.out.println("Parameters passed: "+ String.valueOf(mParameters)); - runAsync(sTestPath, args); - try { - Thread.sleep(100); //1000 milliseconds is one second. - } catch(InterruptedException ex) { - Thread.currentThread().interrupt(); + try { + runAsync(sTestPath, args); + } catch (Controller.ControllerStateException ex) { + Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); } iRet = 0; } catch (Exception ex) { @@ -892,6 +902,53 @@ public class TestingList extends Panel { return iRet; } + + + public class RunTest implements Runnable { + + private String sDeviceName, sTestPath; + private HashMap mParameters; + + public RunTest(String sDeviceName, String sTestPath, HashMap mParameters ){ + this.sDeviceName = sDeviceName; + this.sTestPath = sTestPath; + this.mParameters = mParameters; + } + + public void run() { + // code in the other thread, can reference "var" variable + HashMap args = new HashMap(); + try { + Thread.sleep(1000); + args.put("parameters", mParameters); + args.put("device", sDeviceName); + args.put("ret", ""); + args.put("status", false); + System.out.println("Parameters passed: "+ String.valueOf(mParameters)); + runAsync(sTestPath, args); + } catch (Controller.ControllerStateException ex) { + Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); + } catch (InterruptedException ex) { + Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); + } + } + } + + //delete this + private void runTest(String sDeviceName, String sTestPath, HashMap mParameters ){ + HashMap args = new HashMap(); + args.put("parameters", mParameters); + args.put("device", sDeviceName); + args.put("ret", ""); + args.put("status", false); + System.out.println("Parameters passed: "+ String.valueOf(mParameters)); + try { + runAsync(sTestPath, args); + } catch (Controller.ControllerStateException ex) { + Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); + } + } + /** *table management */