From 6c492ef270d57546865b049cfb861f92377afb2f Mon Sep 17 00:00:00 2001 From: boccioli_m Date: Tue, 4 Aug 2015 14:39:16 +0200 Subject: [PATCH] Closedown --- .../tests/Collimator Tests/Initialise/.config | 8 + .../Collimator Tests/Initialise/Initialise.py | 149 ++++++++++++++++++ .../Collimator Tests/Initialise/help.html | 14 ++ .../Motor Test 1/Motor Test 1.py | 4 +- .../Motor Test 2/Motor Test 2.py | 4 +- .../PS Tests/power-supply-A/power-supply-A.py | 6 +- 6 files changed, 178 insertions(+), 7 deletions(-) create mode 100644 script/tests/tests/Collimator Tests/Initialise/.config create mode 100644 script/tests/tests/Collimator Tests/Initialise/Initialise.py create mode 100644 script/tests/tests/Collimator Tests/Initialise/help.html diff --git a/script/tests/tests/Collimator Tests/Initialise/.config b/script/tests/tests/Collimator Tests/Initialise/.config new file mode 100644 index 0000000..c9ad1dd --- /dev/null +++ b/script/tests/tests/Collimator Tests/Initialise/.config @@ -0,0 +1,8 @@ +name=Initialise +description=Initialises the motor +help = \ +This test sends a INIT command to the device, as many times as configured with the parameter RepeatTimes. + +#optional parameters. Description is compulsory. Syntax: +#parameters=::[;::] +parameters=repeatTimes:1:Repeat N times;delayS:4:Delay between each initialisation [s] \ No newline at end of file diff --git a/script/tests/tests/Collimator Tests/Initialise/Initialise.py b/script/tests/tests/Collimator Tests/Initialise/Initialise.py new file mode 100644 index 0000000..a213625 --- /dev/null +++ b/script/tests/tests/Collimator Tests/Initialise/Initialise.py @@ -0,0 +1,149 @@ + + + +###### DO NOT MODIFY THE CODE BELOW ###### +global print_log, sendFeedback, inspect +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 + +###### WRITE YOUR CODE HERE BELOW ####### + + #Pre-actions + # try: + # caput(DEVICE+':INIT.PROC', '1') + # except: + # ret = 'Unable to create channel - ' + traceback.format_exc() + # success = False + # sendFeedback(testPath, testName, DEVICE, ret, success) + # return + + + #get parameters from the calling interface + try: + print_log(testName, DEVICE, "Running test Initialise with the following parameters:") + print_log(testName, DEVICE, params ) + loopTimes = int(params["repeatTimes"]["value"]) + delaySeconds = int(params["delayS"]["value"]) + except: + ret = 'Could not retrieve testing parameters - ' + traceback.format_exc() + success = False + sendFeedback(testPath, testName, DEVICE, ret, success) + return + + scan = ManualScan(['idX'], ['idMotorPosition', 'idPotiProc', 'idBtvsProc', 'idDiff01', 'idDiff02'] ) + scan.setPlotName(plotName) + scan.start() + #Creating channels: dimension 1 + try: + idInit = Channel(DEVICE+':INIT.PROC', type = 'l') + idReady = Channel(DEVICE+':RDY', type = 'l') + idInterlock = Channel(DEVICE+':ILK', type = 'l') + #ScalarDetector idMotorPosition + #idMotorPosition = Channel(DEVICE+':IST1:2', type = 'd') + idMotorPosition = Channel(DEVICE+':MOTOR.RBV', type = 'd') + #ScalarDetector idPotiProc + #idPotiProc = Channel(DEVICE+':POSA:2', type = 'd') + idPotiProc = Channel(DEVICE+':ENCODER', type = 'd') + #ScalarDetector idBtvsProc + #idBtvsProc = Channel(DEVICE+':IST3:2', type = 'd') + idBtvsProc = Channel(DEVICE+':MOTOR.HLS', type = 'd') + #ScalarDetector idEndSwitchL + #idBtvsRaw = Channel(DEVICE+':IST3:1', type = 'd') + idEndSwitchL = Channel(DEVICE+':MOTOR.LLS', type = 'd') + #ScalarDetector idEndSwitchH + #idBtvsProc = Channel(DEVICE+':IST3:2', type = 'd') + idEndSwitchH = Channel(DEVICE+':MOTOR.HLS', type = 'd') + except: + ret = 'Unable to create channel - ' + traceback.format_exc() + success = False + sendFeedback(testPath, testName, DEVICE, ret, success) + return + + count = 0 + print_log(testName, DEVICE, 'Initialisation sequence') + timeout = 60000 #timeout in ms + for count in range(0, loopTimes): + print_log(testName, DEVICE, 'Initialisation #' + str(count+1) + '/' + str(loopTimes) ) + sleep( delaySeconds ) # Settling time + idInit.put(1, timeout=None) # TODO: Set appropriate timeout + timeStampStart = float(java.lang.System.currentTimeMillis()) + sleep(0.1) + ready = 0 + interlock = idInterlock.get() + timeElapsed = 0 #in ms + while (ready == 0) and timeElapsed<40000: + #Detector time + timeStamp = float(java.lang.System.currentTimeMillis()) + timeElapsed = timeStamp - timeStampStart + ready = idReady.get() + sleep( 0.1 ) + detector4 = idMotorPosition.get() + detector6 = idPotiProc.get() + detector8 = idBtvsProc.get() + ready = idReady.get() + interlock = idInterlock.get() + #end switches + endH = idEndSwitchH.get() + endL = idEndSwitchL.get() + #Manipulation idDiff02 + a = detector4 + b = detector8 + idDiff02 = a-b + #Manipulation idDiff01 + a = detector4 + b = detector6 + idDiff01 = a-b + scan.append ([timeStamp],[timeStamp], [detector4, detector6, detector8, idDiff02, idDiff01]) + if ready == 1 and interlock == 1: + ret = 'Drive initialised ' + str(count) + ' times' + success = True + else: + ret = 'The RDY and ILK signals indicate the drive was NOT ready at the expected time (after ' + str(timeout/1000) + 's).' + success = False + break + + idInit.close() + idReady.close() + idMotorPosition.close() + idPotiProc.close() + idBtvsProc.close() + scan.end() + +############# END OF YOUR CODE ########### +###### DO NOT MODIFY THE CODE BELOW ###### + sendFeedback(testPath, testName, DEVICE, ret, success) + except: + ret = traceback.format_exc() + success = False + sendFeedback(testPath, testName, DEVICE, ret, success) + return + +#launch the test +startTest(test, device, parameters) + \ No newline at end of file diff --git a/script/tests/tests/Collimator Tests/Initialise/help.html b/script/tests/tests/Collimator Tests/Initialise/help.html new file mode 100644 index 0000000..95e072f --- /dev/null +++ b/script/tests/tests/Collimator Tests/Initialise/help.html @@ -0,0 +1,14 @@ + + +

Short Description

+Initialise N times. +

Details

+This test sends a INIT command to the device, as many times as configured with the parameter repeatTimes. +

Parameters

+repeatTimes Repeat the Initialisation N times
+delayS Pause delay between each Initialisation [s] +

Contact

+Marco Boccioli + + + diff --git a/script/tests/tests/Collimator Tests/Motor Test 1/Motor Test 1.py b/script/tests/tests/Collimator Tests/Motor Test 1/Motor Test 1.py index 7108e23..cc7fa1f 100644 --- a/script/tests/tests/Collimator Tests/Motor Test 1/Motor Test 1.py +++ b/script/tests/tests/Collimator Tests/Motor Test 1/Motor Test 1.py @@ -19,8 +19,8 @@ def sendFeedback(testPath, testName, DEVICE, returnString, testPassed): def print_log(testName, DEVICE, text): time.ctime() now = time.strftime('%Y.%m.%d %H:%M:%S') - print now + ' ' + DEVICE + ' - ' + testName + ': ' + text - + print now + ' ' + DEVICE + ' - ' + testName + ': ' + str(text) + def startTest(testName, DEVICE, params): try: import traceback diff --git a/script/tests/tests/Collimator Tests/Motor Test 2/Motor Test 2.py b/script/tests/tests/Collimator Tests/Motor Test 2/Motor Test 2.py index cd96ea9..4687da7 100644 --- a/script/tests/tests/Collimator Tests/Motor Test 2/Motor Test 2.py +++ b/script/tests/tests/Collimator Tests/Motor Test 2/Motor Test 2.py @@ -202,8 +202,8 @@ def sendFeedback(testPath, testName, DEVICE, returnString, testPassed): def print_log(testName, DEVICE, text): time.ctime() now = time.strftime('%Y.%m.%d %H:%M:%S') - print now + ' ' + DEVICE + ' - ' + testName + ': ' + text - + print now + ' ' + DEVICE + ' - ' + testName + ': ' + str(text) + #launch the test #from pshellTestGeneral import testUtils #testUtil = testUtils() 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 af33e11..7caf586 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,8 +6,8 @@ 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 - + 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:') @@ -113,6 +113,6 @@ def startTest(testName, DEVICE, params): #launch the test -parameters = {} +#parameters = {} startTest(test, device, parameters) \ No newline at end of file