diff --git a/plugins/TestingList.java b/plugins/TestingList.java index 6375a99..bbc2baa 100644 --- a/plugins/TestingList.java +++ b/plugins/TestingList.java @@ -540,6 +540,7 @@ public class TestingList extends Panel { }//GEN-LAST:event_jButtonMoveUpActionPerformed private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + new Thread(() -> { try { Object ret = eval("parallelize((run,('Motor Test 3 100ms',)), (run,('Motor Test 3 200ms',)))"); @@ -777,7 +778,7 @@ public class TestingList extends Panel { String sTestName; String sTestCaseName; String sTestPath; - HashMap args = new HashMap(); + HashMap args = new HashMap<>(); HashMap mParameters = new HashMap(); //scan through the table starting from 'position' and execute the first selected test found int row = position; @@ -900,23 +901,27 @@ 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(); - args = new HashMap(); args.put("ret", ""); args.put("parameters", mParameters); args.put("device", sDeviceName); args.put("status", false); - Object ret = eval("parallelize((run,(" + sTestPath + "," + ")))"); - Object ret1 = ((ArrayList) ret).get(0); - //Object ret2 = ((ArrayList) ret).get(1); - System.out.println(String.valueOf(ret1)); + System.out.println("A"); + runTest = new RunTest(sTestPath, args); + System.out.println("b"); + Thread t = new Thread(runTest); + System.out.println("c"); + t.start(); + System.out.println("d"); + + +// //Object ret = eval("parallelize((run,(" + sTestPath + "," + ")))"); +// Object ret = eval("parallelize((run,('Motor Test 3 100ms',)), (run,('Motor Test 3 200ms',)))"); +// Object ret1 = ((ArrayList) ret).get(0); +// //Object ret2 = ((ArrayList) ret).get(1); +// System.out.println(String.valueOf(ret1)); //runAsync(sTestPath, args); - - - + iRet = 0; } catch (Exception ex) { SwingUtils.showMessage(this, "executeTest()", ex.toString()); @@ -933,28 +938,43 @@ public class TestingList extends Panel { private String sDeviceName, sTestPath; private HashMap mParameters; + private HashMap args; - public RunTest(String sDeviceName, String sTestPath, HashMap mParameters) { - this.sDeviceName = sDeviceName; + public RunTest(String sTestPath, HashMap args) { + System.out.println("A1"); + this.sDeviceName = args.get("device").toString(); + System.out.println("A2"); this.sTestPath = sTestPath; - this.mParameters = mParameters; + System.out.println("A3"); + this.mParameters = (HashMap) args.get("parameters"); + this.args = args; + } + public RunTest(String sTestPath) { + this.sDeviceName = sTestPath; + this.sTestPath = sTestPath; + this.mParameters.put("a", 1); } 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) { + System.out.println("A4"); + + for (String key:args.keySet()){ + getController().getScriptManager().setVar(key,args.get(key)); + } + + System.out.println("A5"); + //runAsync(sTestPath, args); + Object ret = eval("parallelize((run,('Motor Test 3 100ms'), (run,('Motor Test 3 200ms')))"); + System.out.println("A6"); + Object ret1 = ((ArrayList) ret).get(0); + //Object ret2 = ((ArrayList) ret).get(1); + System.out.println(String.valueOf(ret1)); + } catch (Exception ex) { Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); + SwingUtils.showMessage(TestingList.this.getComponent(), "runTest()", ex.toString()); } } } diff --git a/script/Motor Test 3 100ms.py b/script/Motor Test 3 100ms.py index e48535a..c36cba7 100644 --- a/script/Motor Test 3 100ms.py +++ b/script/Motor Test 3 100ms.py @@ -7,10 +7,13 @@ import traceback ret = 'Test failed' status = False DEVICE="PO2DV-NCS-LS" +params = parameters +print params #TODO: Set the diplay names of positioners and detectors #scan = ManualScan(['idX', 'idInkr'], ['idMotorStatus', 'idLogicalPosition', 'idDiameter', 'idMotorPosition', 'idPotiRaw', 'idPotiProc', 'idBtvsRaw', 'idBtvsProc', 'idDiff01', 'idDiff02'] , [-0.5, 0.0], [4.0, 3000.0], [3000, 20]) -scan = ManualScan(['idX'], ['idMotorStatus', 'idLogicalPosition', 'idDiameter', 'idMotorPosition', 'idPotiRaw', 'idPotiProc', 'idBtvsRaw', 'idBtvsProc', 'idDiff01', 'idDiff02'] , [ 0.0], [ 3000.0], [20] , context='TEST1') +scan = ManualScan(['idX'], ['idMotorStatus', 'idLogicalPosition', 'idDiameter', 'idMotorPosition', 'idPotiRaw', 'idPotiProc', 'idBtvsRaw', 'idBtvsProc', 'idDiff01', 'idDiff02'] , [ 0.0], [ 3000.0], [20]) +scan.setPlotName("Bla") scan.start() #Creating channels: dimension 1