From 9cee7bc1feeb90a70377a846b6cc47e1bfd3213e Mon Sep 17 00:00:00 2001 From: boccioli_m Date: Wed, 2 Sep 2015 11:01:12 +0200 Subject: [PATCH] Closedown --- script/testcommons.py | 10 ++++---- .../PS Tests/power-supply-A/power-supply-A.py | 25 +++++++------------ 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/script/testcommons.py b/script/testcommons.py index 01760a4..85db0dc 100644 --- a/script/testcommons.py +++ b/script/testcommons.py @@ -20,14 +20,14 @@ class TestingTool: print now + ' ' + DEVICE + ' - ' + testName + ': ' + str(text) #prepare and send feedback to calling tool - def sendFeedback(self, testPath, testName, DEVICE, returnString, testPassed): + def sendFeedback(self, returnString, testPassed): print_log(testName, DEVICE, 'End of test. Result:') - print_log(testName, DEVICE, 'Device: ' + DEVICE) - print_log(testName, DEVICE, 'Test name: ' + testName) - print_log(testName, DEVICE, 'Test path: ' + testPath) + print_log(testName, DEVICE, 'Device: ' + self.deviceName) + print_log(testName, DEVICE, 'Test name: ' + self.testName) + print_log(testName, DEVICE, 'Test path: ' + self.testPath) print_log(testName, DEVICE, 'Test passed: ' + str(testPassed)) print_log(testName, DEVICE, 'Return string: ' + returnString) - ret = [testPath, DEVICE, returnString, testPassed] + ret = [self.testPath, self.deviceName, returnString, testPassed] return ret 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 23cb136..9e8051b 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 @@ -3,21 +3,14 @@ ######################################### global print_log, sendFeedback, sys, inspect, os, traceback, testcommons import sys, inspect, os, traceback, testcommons - -def print_log(testName, DEVICE, text): - testcommons.print_log(testName, DEVICE, text) - -def sendFeedback(testPath, testName, DEVICE, returnString, testPassed): - ret = testcommons.sendFeedback(testPath, testName, DEVICE, returnString, testPassed) - set_return(ret) def startTest(testName, DEVICE, params): #get the path of this script - test = testcommons.TestingTool(testName, DEVICE) - test.print_pio() import inspect testPath = inspect.getfile(inspect.currentframe()) + test = testcommons.TestingTool(testName, DEVICE, testPath) + test.print_pio() #by default, failed ret = 'Test failed' status = False @@ -26,9 +19,9 @@ def startTest(testName, DEVICE, params): ######################################### ###### WRITE YOUR CODE HERE BELOW ####### ######################################### - print_log(testName, DEVICE, 'testpath A: ' + testPath ) - print_log(testName, DEVICE, 'parameters: ' + str(params) ) - print_log(testName, DEVICE, 'device: ' + DEVICE ) + test.print_log('testpath A: ' + testPath ) + test.print_log('parameters: ' + str(params) ) + test.print_log('device: ' + DEVICE ) #scan = ManualScan(['time'], ['SetV', 'ActualV', 'ActualI'] , [0.0], [30.0], [20]) scan = ManualScan(['time'], ['SetV', 'ActualV', 'ActualI']) scan.setPlotName(plotName) @@ -50,7 +43,7 @@ def startTest(testName, DEVICE, params): #ActualI = Channel('pw84:ai', type = 'd') except: import traceback - sendFeedback(testPath, testName, DEVICE, 'Unable to create channel - ' + traceback.format_exc(), False) + test.sendFeedback('Unable to create channel - ' + traceback.format_exc(), False) #raise Exception('Unable to create channel - ' + traceback.format_exc()) return @@ -58,7 +51,7 @@ def startTest(testName, DEVICE, params): SetRamp.put(10.0, timeout=None) #set voltage to 0 - print_log(testName, DEVICE, 'Ramping down power supply A to 0V' ) + test.print_log( 'Ramping down power supply A to 0V' ) SetV.put(0.0, timeout=None) #wait up to 2 minutes for voltage to be ~0 @@ -70,7 +63,7 @@ def startTest(testName, DEVICE, params): #Dimension 1 #LinearPositioner SetV - print_log(testName, DEVICE, 'Ramping up power supply A' ) + test.print_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 @@ -108,7 +101,7 @@ def startTest(testName, DEVICE, params): ######################################### ###### DO NOT MODIFY THE CODE BELOW ##### ######################################### - sendFeedback(testPath, testName, DEVICE, ret, status) + test.sendFeedback(ret, status) #launch the test