From 0bfa6083852f42f6c302998aba1da9c22c19f39e Mon Sep 17 00:00:00 2001 From: boccioli_m Date: Fri, 4 Sep 2015 15:23:01 +0200 Subject: [PATCH] Closedown --- plugins/TestingList.java | 13 +- script/local.py | 4 +- .../PS Tests/power-supply-A/power-supply-A.py | 59 ++++--- .../PS Tests/power-supply-B/power-supply-B.py | 165 ++++++++++-------- 4 files changed, 131 insertions(+), 110 deletions(-) diff --git a/plugins/TestingList.java b/plugins/TestingList.java index bd5df57..9b815a7 100644 --- a/plugins/TestingList.java +++ b/plugins/TestingList.java @@ -1151,7 +1151,7 @@ public class TestingList extends Panel { String sTestName = testPath; //getController().getDataManager().appendLog(str(log)); - System.out.println("Looking for: deviceName: " + deviceName + "; testPath: " + testPath + " in table."); + //System.out.println("Looking for: deviceName: " + deviceName + "; testPath: " + testPath + " in table."); String sStatus; if (status == "true") { @@ -1281,6 +1281,11 @@ public class TestingList extends Panel { } } + /** + * Stop all the tests in progress and return to idle state (no further tests are launched) + * + * @param resultMessage the message that will be shown as Result of each stopped test + */ public void stopAll(String resultMessage){ setToStopped(); String testInProgress[] = getTestInProgress(); @@ -1398,6 +1403,7 @@ 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. + //if the user pressed Stop, exit from run: if(!isTestRunAllowed()) return; //System.out.println(String.valueOf(row) + "\t" + String.valueOf(bSelected) + "\t" + String.valueOf(selectedTestsRows.length) + "\t" + sStartSequence + "\t" + sStatus); @@ -1517,6 +1523,7 @@ public class TestingList extends Panel { showResult(sDeviceName, sTestPath, "Cannot find test script: " + sTestPath, TestStatus.FAILURE.toString()); continue; } + //if the user pressed Stop, exit from run: if(!isTestRunAllowed()) return iRet; showResult(sDeviceName, sTestPath, "Test running", TestStatus.RUNNING.toString()); @@ -1565,10 +1572,10 @@ public class TestingList extends Panel { sParallelizeCommand = sParallelizeCommand + ")))"; //very last part of command "parallelize" } } - System.out.println(sParallelizeCommand); + //System.out.println(sParallelizeCommand); Object ret; ret = eval(sParallelizeCommand); - System.out.println(ret); + //System.out.println(ret); String sTestResult, sTestStatus; if(ret == null){ SwingUtils.showMessage(TestingList.this, "executeParallelTestsGroup()", "The test script(s) did not return any feedback."); diff --git a/script/local.py b/script/local.py index 6dde1ac..51d4467 100644 --- a/script/local.py +++ b/script/local.py @@ -32,7 +32,9 @@ class TestingTool: import time time.ctime() now = time.strftime('%Y.%m.%d %H:%M:%S') - print now + ' ' + self.deviceName + ' - ' + self.testName + ': ' + str(text) + logText = now + ' ' + self.deviceName + ' - ' + self.testName + ': ' + str(text) + print logText + log(logText) #prepare and send feedback to calling tool # returnString = the string containing info on the test result diff --git a/script/tests/tests/PS Tests/power-supply-A/power-supply-A.py b/script/tests/tests/PS Tests/power-supply-A/power-supply-A.py index 39a6095..dc2fa57 100644 --- a/script/tests/tests/PS Tests/power-supply-A/power-supply-A.py +++ b/script/tests/tests/PS Tests/power-supply-A/power-supply-A.py @@ -1,30 +1,30 @@ -######################################### -###### DO NOT MODIFY THE CODE BELOW ##### -######################################### + +###### Init - DO NOT MODIFY THE CODE BELOW ###### global sys, inspect, os, traceback import sys, inspect, os, traceback def startTest(testName, DEVICE, params): - #get the path of this script - testPath = inspect.getfile(inspect.currentframe()) - #init the testing tool class - test = TestingTool(testName, testPath, DEVICE, params) - #by default, failed + #by default, assume the test failed ret = 'Test failed' - status = False + success = False #plot name to be given to the scan. Use: scan.setPlotName(plotName) - plotName = DEVICE + ' - ' + testName -######################################### -###### WRITE YOUR CODE HERE BELOW ####### -######################################### + plotName = DEVICE + ' - ' + testName + #put the whole custom code under try/catch try: - test.log('testpath A: ' + testPath ) - test.log('parameters: ' + str(params) ) - test.log('device: ' + DEVICE ) + #get the path of this script + testPath = inspect.getfile(inspect.currentframe()) + #init the testing tool class. It can be sued in the following ways: + test = TestingTool(testName, testPath, DEVICE, params) + +######### WRITE YOUR CODE HERE BELOW ############# + test.log( 'testpath A: ' + testPath ) + test.log( 'parameters: ' + str(params) ) + test.log( 'device: ' + DEVICE ) #scan = ManualScan(['time'], ['SetV', 'ActualV', 'ActualI'] , [0.0], [30.0], [20]) scan = ManualScan(['time'], ['SetV', 'ActualV', 'ActualI']) scan.setPlotName(plotName) scan.start() + try: #Creating channels: dimension 1 #Ramp rate @@ -41,14 +41,16 @@ def startTest(testName, DEVICE, params): ActualI = Channel(DEVICE + ':Actual-IA', type = 'd') #ActualI = Channel('pw84:ai', type = 'd') except: - test.sendFeedback('Unable to create channel - ' + traceback.format_exc(), False) + import traceback + test.sendFeedback( 'Unable to create channel - ' + traceback.format_exc(), False) + #raise Exception('Unable to create channel - ' + traceback.format_exc()) return #Init SetRamp.put(10.0, timeout=None) #set voltage to 0 - test.log( 'Ramping down power supply A to 0V' ) + test.log( 'Ramping down power supply A to 0V' ) SetV.put(0.0, timeout=None) #wait up to 2 minutes for voltage to be ~0 @@ -60,7 +62,7 @@ def startTest(testName, DEVICE, params): #Dimension 1 #LinearPositioner SetV - test.log( 'Ramping up power supply A' ) + test.log( 'Ramping up power supply A' ) for setpoint1 in frange(0.0, 20.0, 5.0, True): if setpoint1 > 50.0 or setpoint1 < 0.0: break @@ -69,7 +71,7 @@ def startTest(testName, DEVICE, params): if abs(readback1 - setpoint1) > 0.9 : # TODO: Check accuracy raise Exception('SetV could not be set to the value ' + str(setpoint1)) ret = 'SetV could not be set to the value ' + str(setpoint1) + '(measured value: '+str(readback1)+')' - status = False + success = False break #scan quickly the output during some seconds for setpoint2 in range(0, 20): @@ -82,8 +84,6 @@ def startTest(testName, DEVICE, params): #append(setpoints, positions, values) scan.append ([detector1], [detector1], [readback1, detector2, detector3]) sleep( 0.1 ) # Settling time - ret = 'Test ps A completed' - status = True #reset output to 0V SetV.put(0.0, timeout=None) @@ -93,17 +93,18 @@ def startTest(testName, DEVICE, params): ActualI.close() scan.end() -######################################### -############# END OF YOUR CODE ########## -######################################### -###### DO NOT MODIFY THE CODE BELOW ##### -######################################### + ret = 'Test ps A completed' + success = True +################ END OF YOUR CODE ################ +###### Final - DO NOT MODIFY THE CODE BELOW ###### + + #just in case the feedback was forgotten test.sendFeedback(ret, success) except: + #generic error handler ret = traceback.format_exc() success = False test.sendFeedback(ret, success) - return #launch the test -startTest(test, device, parameters) +startTest(test, device, parameters) \ No newline at end of file diff --git a/script/tests/tests/PS Tests/power-supply-B/power-supply-B.py b/script/tests/tests/PS Tests/power-supply-B/power-supply-B.py index d107868..e5826b9 100644 --- a/script/tests/tests/PS Tests/power-supply-B/power-supply-B.py +++ b/script/tests/tests/PS Tests/power-supply-B/power-supply-B.py @@ -1,94 +1,105 @@ + ###### Init - DO NOT MODIFY THE CODE BELOW ###### global sys, inspect, os, traceback import sys, inspect, os, traceback def startTest(testName, DEVICE, params): - #get the path of this script - testPath = inspect.getfile(inspect.currentframe()) - #init the testing tool class - test = TestingTool(testName, testPath, DEVICE, params) - #by default, failed + #by default, assume the test failed ret = 'Test failed' - status = False + success = False #plot name to be given to the scan. Use: scan.setPlotName(plotName) - plotName = DEVICE + ' - ' + testName -######### WRITE YOUR CODE HERE BELOW ############# - test.log('testpath B: ' + testPath ) - test.log('parameters:' + str( params) ) - test.log('device: ' + DEVICE ) - #scan = ManualScan(['time'], ['SetVB', 'ActualVB', 'ActualIB'] , [0.0], [30.0], [20]) - scan = ManualScan(['time'], ['SetVB', 'ActualVB', 'ActualIB'] ) - scan.setPlotName(plotName) - scan.start() - - #Creating channels: dimension 1 + plotName = DEVICE + ' - ' + testName + #put the whole custom code under try/catch try: - #Ramp rate - SetRamp = Channel(DEVICE + ':Set-RampB', type = 'd') - #SetRamp = Channel('pw84:ai', type = 'd') - #LinearPositioner SetVA - SetVA = Channel(DEVICE + ':Set-VB', type = 'd') - #SetVA = Channel('pw84:ai', type = 'd') - #Timestamp time - #ScalarDetector ActualVA - ActualVA = Channel(DEVICE + ':Actual-VB', type = 'd') - #ActualVA = Channel('pw84:ai', type = 'd') - #ScalarDetector ActualIA - ActualIA = Channel(DEVICE + ':Actual-IB', type = 'd') - #ActualIA = Channel('pw84:ai', type = 'd') - except: - test.sendFeedback('Unable to create channel - ' + traceback.format_exc(), False) - return - #Init - SetRamp.put(10.0, timeout=None) + #get the path of this script + testPath = inspect.getfile(inspect.currentframe()) + #init the testing tool class. It can be sued in the following ways: + test = TestingTool(testName, testPath, DEVICE, params) + +######### WRITE YOUR CODE HERE BELOW ############# + test.log( 'testpath B: ' + testPath ) + test.log( 'parameters:' + str( params) ) + test.log( 'device: ' + DEVICE ) + #scan = ManualScan(['time'], ['SetVB', 'ActualVB', 'ActualIB'] , [0.0], [30.0], [20]) + scan = ManualScan(['time'], ['SetVB', 'ActualVB', 'ActualIB'] ) + scan.setPlotName(plotName) + scan.start() - #set voltage to 0 - test.log('Ramping down power supply B to 0V') - SetVA.put(0.0, timeout=None) + #Creating channels: dimension 1 + try: + #Ramp rate + SetRamp = Channel(DEVICE + ':Set-RampB', type = 'd') + #SetRamp = Channel('pw84:ai', type = 'd') + #LinearPositioner SetVA + SetVA = Channel(DEVICE + ':Set-VB', type = 'd') + #SetVA = Channel('pw84:ai', type = 'd') + #Timestamp time + #ScalarDetector ActualVA + ActualVA = Channel(DEVICE + ':Actual-VB', type = 'd') + #ActualVA = Channel('pw84:ai', type = 'd') + #ScalarDetector ActualIA + ActualIA = Channel(DEVICE + ':Actual-IB', type = 'd') + #ActualIA = Channel('pw84:ai', type = 'd') + except: + test.sendFeedback( 'Unable to create channel - ' + traceback.format_exc(), False) + return + #Init + SetRamp.put(10.0, timeout=None) - #wait up to 2 minutes for voltage to be ~0 - for setpoint1 in frange(0.0, 120.0, 1.0, True): - detector2 = ActualVA.get() - if detector2 <= 1.0: - break - sleep(0.5) + #set voltage to 0 + test.log( 'Ramping down power supply B to 0V') + SetVA.put(0.0, timeout=None) - #Dimension 1 - #LinearPositioner SetVA - test.log('Ramping up power supply') - for setpoint1 in frange(0.0, 20.0, 5.0, True): - if setpoint1 > 50.0 or setpoint1 < 0.0: - break - SetVA.put(setpoint1, timeout=None) # TODO: Set appropriate timeout - readback1 = SetVA.get() - if abs(readback1 - setpoint1) > 0.9 : # TODO: Check accuracy - raise Exception('SetVB could not be set to the value ' + str(setpoint1)) - ret = 'SetVB could not be set to the value ' + str(setpoint1) + '(measured value: '+str(readback1)+')' - status = False - break - #scan quickly the output during some seconds - for setpoint2 in range(0, 20): - #Detector time - detector1 = float(java.lang.System.currentTimeMillis()) - #Detector ActualVA + #wait up to 2 minutes for voltage to be ~0 + for setpoint1 in frange(0.0, 120.0, 1.0, True): detector2 = ActualVA.get() - detector3 = ActualIA.get() - #scan.append ([setpoint1], [readback1], [detector1, detector2]) - #append(setpoints, positions, values) - scan.append ([detector1], [detector1], [readback1, detector2, detector3]) - sleep( 0.1 ) # Settling time - ret = 'Test ps B completed' - status = True + if detector2 <= 1.0: + break + sleep(0.5) - #reset output to 0V - SetVA.put(0.0, timeout=None) - #Closing channels - SetVA.close() - ActualVA.close() - ActualIA.close() + #Dimension 1 + #LinearPositioner SetVA + test.log( 'Ramping up power supply') + for setpoint1 in frange(0.0, 20.0, 5.0, True): + if setpoint1 > 50.0 or setpoint1 < 0.0: + break + SetVA.put(setpoint1, timeout=None) # TODO: Set appropriate timeout + readback1 = SetVA.get() + if abs(readback1 - setpoint1) > 0.9 : # TODO: Check accuracy + raise Exception('SetVB could not be set to the value ' + str(setpoint1)) + ret = 'SetVB could not be set to the value ' + str(setpoint1) + '(measured value: '+str(readback1)+')' + success = False + break + #scan quickly the output during some seconds + for setpoint2 in range(0, 20): + #Detector time + detector1 = float(java.lang.System.currentTimeMillis()) + #Detector ActualVA + detector2 = ActualVA.get() + detector3 = ActualIA.get() + #scan.append ([setpoint1], [readback1], [detector1, detector2]) + #append(setpoints, positions, values) + scan.append ([detector1], [detector1], [readback1, detector2, detector3]) + sleep( 0.1 ) # Settling time + + #reset output to 0V + SetVA.put(0.0, timeout=None) + #Closing channels + SetVA.close() + ActualVA.close() + ActualIA.close() + ret = 'Test ps B completed' + success = True ################ END OF YOUR CODE ################ -###### Final - DO NOT MODIFY THE CODE BELOW ###### - test.sendFeedback(ret, status) +###### Final - DO NOT MODIFY THE CODE BELOW ###### + + #just in case the feedback was forgotten + test.sendFeedback(ret, success) + except: + #generic error handler + ret = traceback.format_exc() + success = False + test.sendFeedback(ret, success) #launch the test startTest(test, device, parameters) \ No newline at end of file