From 44b9bc2438e3ec215fee5f26dd4456f778f7ba3e Mon Sep 17 00:00:00 2001 From: boccioli_m Date: Wed, 2 Sep 2015 11:32:35 +0200 Subject: [PATCH] Closedown --- script/local.py | 17 +++---- .../PS Tests/power-supply-A/power-supply-A.py | 17 +++---- .../PS Tests/power-supply-B/power-supply-B.py | 45 ++++++------------- 3 files changed, 28 insertions(+), 51 deletions(-) diff --git a/script/local.py b/script/local.py index b15ff9c..e98eed1 100644 --- a/script/local.py +++ b/script/local.py @@ -11,7 +11,6 @@ import sys, inspect, os, traceback class TestingTool: - pippo = 'pippo' deviceName = '' testName = '' testPath = '' @@ -21,7 +20,7 @@ class TestingTool: self.testName = testName self.testPath = testPath - def print_log(self, text): + def log(self, text): import time time.ctime() now = time.strftime('%Y.%m.%d %H:%M:%S') @@ -29,16 +28,14 @@ class TestingTool: #prepare and send feedback to calling tool def sendFeedback(self, returnString, testPassed): - self.print_log('End of test. Result:') - self.print_log('Device: ' + self.deviceName) - self.print_log('Test name: ' + self.testName) - self.print_log('Test path: ' + self.testPath) - self.print_log('Test passed: ' + str(testPassed)) - self.print_log('Return string: ' + returnString) + self.log('End of test. Result:') + self.log('Device: ' + self.deviceName) + self.log('Test name: ' + self.testName) + self.log('Test path: ' + self.testPath) + self.log('Test passed: ' + str(testPassed)) + self.log('Return string: ' + returnString) ret = [self.testPath, self.deviceName, returnString, testPassed] set_return( ret) - - def print_pio(self): print 'piopio' \ No newline at end of file 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 4f17226..208a407 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,15 +1,14 @@ ######################################### ###### DO NOT MODIFY THE CODE BELOW ##### ######################################### -global sendFeedback, sys, inspect, os, traceback +global sys, inspect, os, traceback import sys, inspect, os, traceback def startTest(testName, DEVICE, params): #get the path of this script - import inspect testPath = inspect.getfile(inspect.currentframe()) - test = TestingTool(testName, DEVICE, testPath) + test = TestingTool(testName, testPath, DEVICE) test.print_pio() #by default, failed ret = 'Test failed' @@ -19,9 +18,9 @@ def startTest(testName, DEVICE, params): ######################################### ###### WRITE YOUR CODE HERE BELOW ####### ######################################### - test.print_log('testpath A: ' + testPath ) - test.print_log('parameters: ' + str(params) ) - test.print_log('device: ' + DEVICE ) + 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) @@ -51,7 +50,7 @@ def startTest(testName, DEVICE, params): SetRamp.put(10.0, timeout=None) #set voltage to 0 - test.print_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 @@ -63,7 +62,7 @@ def startTest(testName, DEVICE, params): #Dimension 1 #LinearPositioner SetV - test.print_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 @@ -105,6 +104,4 @@ def startTest(testName, DEVICE, params): #launch the test -#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 946b473..a3a263a 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,37 +1,22 @@ - ###### Init - DO NOT MODIFY THE CODE BELOW ###### -global print_log, sendFeedback, sys, inspect, os, traceback +global sys, inspect, os, traceback import sys, inspect, os, traceback - -def print_log(testName, DEVICE, text): - time.ctime() - now = time.strftime('%Y.%m.%d %H:%M:%S') - print now + ' ' + DEVICE + ' - ' + testName + ': ' + text - -#prepare and send feedback to calling tool -def sendFeedback(testPath, testName, DEVICE, 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, 'Test passed: ' + str(testPassed)) - print_log(testName, DEVICE, 'Return string: ' + returnString) - ret = [testPath, DEVICE, returnString, testPassed] - set_return(ret) - + def startTest(testName, DEVICE, params): #get the path of this script import inspect testPath = inspect.getfile(inspect.currentframe()) + test = TestingTool(testName, testPath, DEVICE) + test.print_pio() #by default, failed ret = 'Test failed' - status = False + status = False #plot name to be given to the scan. Use: scan.setPlotName(plotName) - plotName = DEVICE + ' - ' + testName + plotName = DEVICE + ' - ' + testName ######### WRITE YOUR CODE HERE BELOW ############# - print_log(testName, DEVICE, 'testpath B: ' + testPath ) - print_log(testName, DEVICE, 'parameters:' + str( params) ) - print_log(testName, DEVICE, 'device: ' + DEVICE ) + 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) @@ -53,13 +38,13 @@ def startTest(testName, DEVICE, params): ActualIA = Channel(DEVICE + ':Actual-IB', type = 'd') #ActualIA = Channel('pw84:ai', type = 'd') except: - sendFeedback(testPath, testName, DEVICE, 'Unable to create channel - ' + traceback.format_exc(), False) + test.sendFeedback('Unable to create channel - ' + traceback.format_exc(), False) return #Init SetRamp.put(10.0, timeout=None) #set voltage to 0 - print_log(testName, DEVICE, 'Ramping down power supply B to 0V') + test.log('Ramping down power supply B to 0V') SetVA.put(0.0, timeout=None) #wait up to 2 minutes for voltage to be ~0 @@ -71,7 +56,7 @@ def startTest(testName, DEVICE, params): #Dimension 1 #LinearPositioner SetVA - print_log(testName, DEVICE, 'Ramping up power supply') + 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 @@ -104,9 +89,7 @@ def startTest(testName, DEVICE, params): ActualIA.close() ################ END OF YOUR CODE ################ ###### Final - DO NOT MODIFY THE CODE BELOW ###### - sendFeedback(testPath, testName, DEVICE, ret, status) + test.sendFeedback(ret, status) #launch the test -parameters = {} -startTest(test, device, parameters) - +startTest(test, device, parameters) \ No newline at end of file