From a3dfc537fec9673e7f715a405d62d537a6cb921e Mon Sep 17 00:00:00 2001 From: boccioli_m Date: Wed, 2 Sep 2015 15:05:54 +0200 Subject: [PATCH] Closedown --- script/local.py | 16 +- .../devices/Production/PO2TC-NCS-RS/.config | 3 - .../PS Tests/power-supply-A/power-supply-A.py | 150 +++++++++--------- .../PS Tests/power-supply-B/power-supply-B.py | 3 +- .../Monitor All/Monitor All.py | 62 +++----- 5 files changed, 114 insertions(+), 120 deletions(-) delete mode 100644 script/tests/devices/Production/PO2TC-NCS-RS/.config diff --git a/script/local.py b/script/local.py index e98eed1..d77da67 100644 --- a/script/local.py +++ b/script/local.py @@ -2,7 +2,6 @@ # Deployment specific global definitions - executed after startup.py ################################################################################################### - #Uncomment this line to create the simulated devices needed to the tutorial scripts. #run("tutorial/devices") @@ -19,7 +18,18 @@ class TestingTool: self.deviceName = deviceName self.testName = testName self.testPath = testPath - + + #get specific test parameter + #paramName = the name of the parameter for which the value must be read + def getParam(self, paramName): + try: + return params[paramName]["value"] + except: + ret = 'Could not retrieve testing parameter ' + paramName + ' - Details: ' + traceback.format_exc() + return None + + #print/log information + #test = the string to be printed/logged def log(self, text): import time time.ctime() @@ -27,6 +37,8 @@ class TestingTool: print now + ' ' + self.deviceName + ' - ' + self.testName + ': ' + str(text) #prepare and send feedback to calling tool + # returnString = the string containing info on the test result + # testPassed = true if the test was successful, false if test had a problem def sendFeedback(self, returnString, testPassed): self.log('End of test. Result:') self.log('Device: ' + self.deviceName) diff --git a/script/tests/devices/Production/PO2TC-NCS-RS/.config b/script/tests/devices/Production/PO2TC-NCS-RS/.config deleted file mode 100644 index 44d7c4d..0000000 --- a/script/tests/devices/Production/PO2TC-NCS-RS/.config +++ /dev/null @@ -1,3 +0,0 @@ -name=PO2TC-NCS-RS -description=RS: Range Shifter -tests=Range Shifter Tests 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 208a407..a3f7733 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 @@ -6,10 +6,9 @@ import sys, inspect, os, traceback def startTest(testName, DEVICE, params): #get the path of this script - import inspect testPath = inspect.getfile(inspect.currentframe()) + #init the testing tool class test = TestingTool(testName, testPath, DEVICE) - test.print_pio() #by default, failed ret = 'Test failed' status = False @@ -18,90 +17,93 @@ def startTest(testName, 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 - SetRamp = Channel(DEVICE + ':Set-RampA', type = 'd') - #SetRamp = Channel('pw84:ai', type = 'd') - #LinearPositioner SetV - SetV = Channel(DEVICE + ':Set-VA', type = 'd') - #SetV = Channel('pw84:ai', type = 'd') - #Timestamp time - #ScalarDetector ActualV - ActualV = Channel(DEVICE + ':Actual-VA', type = 'd') - #ActualV = Channel('pw84:ai', type = 'd') - #ScalarDetector ActualI - ActualI = Channel(DEVICE + ':Actual-IA', type = 'd') - #ActualI = Channel('pw84:ai', type = 'd') - except: - import traceback - test.sendFeedback('Unable to create channel - ' + traceback.format_exc(), False) - #raise Exception('Unable to create channel - ' + traceback.format_exc()) - return + 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 + SetRamp = Channel(DEVICE + ':Set-RampA', type = 'd') + #SetRamp = Channel('pw84:ai', type = 'd') + #LinearPositioner SetV + SetV = Channel(DEVICE + ':Set-VA', type = 'd') + #SetV = Channel('pw84:ai', type = 'd') + #Timestamp time + #ScalarDetector ActualV + ActualV = Channel(DEVICE + ':Actual-VA', type = 'd') + #ActualV = Channel('pw84:ai', type = 'd') + #ScalarDetector ActualI + ActualI = Channel(DEVICE + ':Actual-IA', type = 'd') + #ActualI = Channel('pw84:ai', type = 'd') + except: + test.sendFeedback('Unable to create channel - ' + traceback.format_exc(), False) + return - #Init - SetRamp.put(10.0, timeout=None) + #Init + SetRamp.put(10.0, timeout=None) - #set voltage to 0 - test.log( 'Ramping down power supply A to 0V' ) - SetV.put(0.0, timeout=None) + #set voltage to 0 + 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 - for setpoint1 in frange(0.0, 120.0, 1.0, True): - detector2 = ActualV.get() - if detector2 <= 1.0: - break - sleep(0.5) - - #Dimension 1 - #LinearPositioner SetV - 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 - SetV.put(setpoint1, timeout=None) # TODO: Set appropriate timeout - readback1 = SetV.get() - 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 - break - #scan quickly the output during some seconds - for setpoint2 in range(0, 20): - #Detector time - detector1 = float(java.lang.System.currentTimeMillis()) - #Detector ActualV + #wait up to 2 minutes for voltage to be ~0 + for setpoint1 in frange(0.0, 120.0, 1.0, True): detector2 = ActualV.get() - detector3 = ActualI.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 A completed' - status = True + if detector2 <= 1.0: + break + sleep(0.5) - #reset output to 0V - SetV.put(0.0, timeout=None) - #Closing channels - SetV.close() - ActualV.close() - ActualI.close() + #Dimension 1 + #LinearPositioner SetV + 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 + SetV.put(setpoint1, timeout=None) # TODO: Set appropriate timeout + readback1 = SetV.get() + 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 + break + #scan quickly the output during some seconds + for setpoint2 in range(0, 20): + #Detector time + detector1 = float(java.lang.System.currentTimeMillis()) + #Detector ActualV + detector2 = ActualV.get() + detector3 = ActualI.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 A completed' + status = True - scan.end() + #reset output to 0V + SetV.put(0.0, timeout=None) + #Closing channels + SetV.close() + ActualV.close() + ActualI.close() + + scan.end() ######################################### ############# END OF YOUR CODE ########## ######################################### ###### DO NOT MODIFY THE CODE BELOW ##### ######################################### - test.sendFeedback(ret, status) - + test.sendFeedback(ret, success) + except: + ret = traceback.format_exc() + success = False + test.sendFeedback(ret, success) + return #launch the test startTest(test, device, parameters) 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 a3a263a..09b00c6 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 @@ -4,10 +4,9 @@ import sys, inspect, os, traceback def startTest(testName, DEVICE, params): #get the path of this script - import inspect testPath = inspect.getfile(inspect.currentframe()) + #init the testing tool class test = TestingTool(testName, testPath, DEVICE) - test.print_pio() #by default, failed ret = 'Test failed' status = False diff --git a/script/tests/tests/Range Shifter Tests/Monitor All/Monitor All.py b/script/tests/tests/Range Shifter Tests/Monitor All/Monitor All.py index 2604c1b..3ad7467 100644 --- a/script/tests/tests/Range Shifter Tests/Monitor All/Monitor All.py +++ b/script/tests/tests/Range Shifter Tests/Monitor All/Monitor All.py @@ -2,50 +2,34 @@ ###### DO NOT MODIFY THE CODE BELOW ###### -global print_log, sendFeedback, inspect, log, 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 + ': ' + str(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): - try: - import traceback - #get the path of this script - testPath = inspect.getfile(inspect.currentframe()) - #by default, failed - ret = 'Test failed' - success = False - #plot name to be given to the scan. Use: scan.setPlotName(plotName) - plotName = DEVICE + ' - ' + testName - + #get the path of this script + testPath = inspect.getfile(inspect.currentframe()) + #init the testing tool class + test = TestingTool(testName, testPath, DEVICE) + #by default, failed + ret = 'Test failed' + status = False + #plot name to be given to the scan. Use: scan.setPlotName(plotName) + plotName = DEVICE + ' - ' + testName ###### WRITE YOUR CODE HERE BELOW ####### - + try: #get parameters from the calling interface try: - print_log(testName, DEVICE, "Running test Initialise with the following parameters:") - print_log(testName, DEVICE, params ) - samplingTimeWindow = int(params["timeWindowS"]["value"]) - samplingTime = float(params["samplingTimeS"]["value"]) + test.log("Running test Initialise with the following parameters:") + test.log(params) +# samplingTimeWindow = int(params["timeWindowS"]["value"]) +# samplingTime = float(params["samplingTimeS"]["value"]) + samplingTimeWindow = int(test.getParam(timeWindowS)) ; samplingTime = float(test.getParam("samplingTimeS")) ; if samplingTime<0.001: samplingTime=0.001 except: ret = 'Could not retrieve testing parameters - ' + traceback.format_exc() success = False - sendFeedback(testPath, testName, DEVICE, ret, success) + test.sendFeedback( ret, success) return scan = ManualScan(['id000000'], ['Motor Status (MSTA)', 'Motor Step Count (RVAL)', 'Motor Position (VAL)', 'Motor Home Switch (ATHM)', 'Encoder Count (ENCODERraw)', 'Encoder Position (ENCODER)', 'Motor/Encoder Diff', 'Drive Ready (RDY)', 'Drive interlock (ILK)', 'CAD_VALA', 'MOTOR_ATHM', 'MOTOR_LLS', 'MOTOR_HLS', 'MOTOR_DMOV', 'CAD_ODIR', 'MOTOR_HOMF', 'MOTOR_RLV', 'MOTOR_STOP', 'MOTOR_SET', 'MOTOR_OFF', 'MOTOR_VAL', 'MOTOR_DVAL', 'MOTOR_DLLM', 'MOTOR_DHLM', 'CAD_VALB', 'CAR_IVAL', 'CAR_IERR', 'SIR_VAL', 'ENCODERraw', 'ENCODERscale', 'ENCODER_oEN', 'ENCODER_HFF', 'FIRST_INIT'] ) scan.setPlotName(plotName) @@ -97,12 +81,12 @@ def startTest(testName, DEVICE, params): except: ret = 'Unable to create channel - ' + traceback.format_exc() success = False - sendFeedback(testPath, testName, DEVICE, ret, success) + test.sendFeedback( ret, success) return #Dimension 1 #PseudoPositioner id000000 samplingRange = int(float(samplingTimeWindow) / samplingTime) - print_log(testName, DEVICE, 'Start monitoring during ' + samplingTimeWindow + 's') + test.log('Start monitoring during ' + samplingTimeWindow + 's') for setpoint1 in range(0, samplingRange): readback1 = setpoint1 sleep( samplingTime ) # Settling time @@ -182,14 +166,14 @@ def startTest(testName, DEVICE, params): success = True ret = 'Monitoring completed' - print_log(testName, DEVICE, ret) + test.log(ret) ############# END OF YOUR CODE ########### ###### DO NOT MODIFY THE CODE BELOW ###### - sendFeedback(testPath, testName, DEVICE, ret, success) + test.sendFeedback(ret, success) except: ret = traceback.format_exc() success = False - sendFeedback(testPath, testName, DEVICE, ret, success) + test.sendFeedback(ret, success) return #launch the test