From cfce89a25e45911ed1c6de2406d814ba53b5e752 Mon Sep 17 00:00:00 2001 From: boccioli_m Date: Tue, 15 Sep 2015 09:30:57 +0200 Subject: [PATCH] Closedown --- script/tests/templates/testTemplate.py | 10 +- .../Calibrate/Calibrate.py | 196 +++++++++-------- .../Drive Out/Drive Out - Copy.py | 4 +- .../Drive Out/Drive Out.py | 200 ++++++++++-------- .../Monitor Movement - Copy.py | 6 +- .../Monitor Movement/Monitor Movement.py | 79 +++---- .../Collimator Tests pro/Motor Test 1/.config | 14 +- .../Motor Test 1/Motor Test 1.py | 134 +++++++----- .../Motor Test 1/help.html | 28 +-- .../Motor Test 2/Motor Test 2.py | 95 ++++++--- .../Collimator Tests pro/Motor Test 3/.config | 14 +- .../Motor Test 3/Motor Test 3.py | 82 ++++--- .../Motor Test 3/help.html | 26 +-- .../Move Ref 1/Move Ref 1 - Copy.py | 4 +- .../Move Ref 1/Move Ref 1.py | 173 +++++++++------ .../Move Ref 2/Move Ref 2.py | 171 +++++++++------ .../Calibrate test vme/Calibrate test vme.py | 4 +- .../Collimator Tests/Calibrate/Calibrate.py | 4 +- .../Collimator Tests/Check Status/.config | 4 +- .../Collimator Tests/Drive Out/Drive Out.py | 4 +- .../Motor Test 1/Motor Test 1 - Copy.py | 4 +- .../Motor Test 3/Motor Test 3.py | 4 +- .../motor-slide/motor-slide.py | 4 +- .../Check Linearity/Check Linearity.py | 2 +- ...-supply-A - Copy works with testcommons.py | 8 +- .../power-supply-A/power-supply-A - Copy.py | 8 +- .../test without ioc/test without ioc.py | 2 +- .../Range Shifter Tests/Check Status/.config | 2 +- .../Range Shifter Tests/Monitor All/.config | 4 +- .../Monitor All/Monitor All.py | 2 +- 30 files changed, 740 insertions(+), 552 deletions(-) diff --git a/script/tests/templates/testTemplate.py b/script/tests/templates/testTemplate.py index cdf1c04..6dc5bfe 100644 --- a/script/tests/templates/testTemplate.py +++ b/script/tests/templates/testTemplate.py @@ -22,8 +22,8 @@ def startTest(testName, DEVICE, params): # init the testing tool class. It can be sued in the following ways: test = TestingTool(testName, testPath, DEVICE, params) - ################ END OF Init ##################### - ######### WRITE YOUR CODE HERE BELOW ############# +################ END OF Init ##################### +######### WRITE YOUR CODE HERE BELOW ############# """ All the code in this section ###..YOUR CODE..### can be modified/deleted. @@ -66,7 +66,7 @@ def startTest(testName, DEVICE, params): test.log("Example - Test name: " + testName) test.log("Example - Device name: " + DEVICE) try: - test.log("Running test Initialise with the following parameters:") + test.log("Running test with the following parameters:") test.log(params) # If present, use the parameters here below for your test script. You might need to change the casting #$testParameters @@ -123,8 +123,8 @@ def startTest(testName, DEVICE, params): # once the test is finished, no need to do anything. The code below yours will do the rest. ################ End of Example ########## - ################ END OF YOUR CODE ################ - ###### Final - DO NOT MODIFY THE CODE BELOW ###### +################ END OF YOUR CODE ################ +###### Final - DO NOT MODIFY THE CODE BELOW ###### # just in case the feedback was forgotten test.sendFeedback(ret, success) diff --git a/script/tests/tests/Collimator Tests pro/Calibrate/Calibrate.py b/script/tests/tests/Collimator Tests pro/Calibrate/Calibrate.py index 7ca2885..ecdfb5b 100644 --- a/script/tests/tests/Collimator Tests pro/Calibrate/Calibrate.py +++ b/script/tests/tests/Collimator Tests pro/Calibrate/Calibrate.py @@ -1,118 +1,134 @@ -#Script imported from: Calibrate.xml ###### Init - 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) - log (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): + # by default, assume the test failed + ret = 'Test failed' + success = False + # plot name to be given to the scan. Use: scan.setPlotName(plotName) + plotName = DEVICE + ' - ' + testName + # put the whole custom code under try/catch 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. It can be sued in the following ways: + test = TestingTool(testName, testPath, DEVICE, params) + samplePeriod = 0.1 + ######### WRITE YOUR CODE HERE BELOW ############# - scan = ManualScan(['sample'], ['Drive Status: '+DEVICE+':STA:1', 'Logical Pos: '+DEVICE+':IST:2', 'Diameter: '+DEVICE+':DIAM:2 (mm)', 'Cpc: '+DEVICE+':IST1:2 (mm)', 'Pot: '+DEVICE+':IST2:2 (mm)', 'Btvs: '+DEVICE+':IST3:2 (mm)'] , [0.0], [900.0], [900]) + scan = ManualScan(['time [1/'+ str(1/samplePeriod) + ' s]'], ['Motor Status (STA:1)', 'Inkr (INKR:2)', 'InkrRb (INKRRB:2)', 'Diameter (DIAM:2)', 'Com (COM:2)', + 'Logical Position (IST:2)', 'Motor Pos Raw (IST3:1)','Motor Pos (IST3:2)', 'Poti Pos From Beam (IST1:2)', 'Poti Raw (POSA:1)', 'Poti Position (IST2:1)', + 'Poti Ref1 Position (REF1:1)', 'Poti Ref2 Position (REF2:1)']) scan.setPlotName(plotName) scan.start() try: + idMotorStatus = Channel(DEVICE+':STA:1', type = 'd') # DSP device_status reg + idLogicalPosition = Channel(DEVICE+':IST:2', type = 'd') # Shows current position in logical units as calculated from motor step counter [1..n] + idPotiRaw = Channel(DEVICE+':POSA:1', type = 'd') # poti raw data [ADC units] + idMotorPositionRaw = Channel(DEVICE+':IST3:1', type = 'd') # shows current position in steps as as obtained from motor step counter [steps] + idInkr = Channel(DEVICE + ':INKR:2', type='d') # move relative distance (positive means towards R2) [mm] + idInkrRb = Channel(DEVICE + ':INKRRB:2', type='d') # readback of move relative distance (positive means towards R2) [mm] + idDiameter = Channel(DEVICE + ':DIAM:2', type='d') # collimator diameter [mm] + idCom = Channel(DEVICE + ':COM:2', type='d') # current position as from motor step counter [mm] + idMotorPosition = Channel(DEVICE + ':IST3:2', type='d') # current position as from motor step counter [mm] + idPotiPosFromBeam = Channel(DEVICE + ':IST1:2', type='d') # current position from beam as from potentiometer [mm] + idPotiPosition = Channel(DEVICE + ':IST2:1', type='d') # current position as from potentiometer [mm] + idPotiRef1Position = Channel(DEVICE + ':REF1:1', type='d') # R1 position as from potentiometer [mm] + idPotiRef2Position = Channel(DEVICE + ':REF2:1', type='d') # R2 position as from potentiometer [mm] + #Pre-actions: 1 = calibrate caput(DEVICE+':COM:2', 1) - #Creating channels: dimension 1 - #PseudoPositioner id000000 - #ScalarDetector id000001 - id000001 = Channel(DEVICE+':STA:1', type = 'd') - #ScalarDetector id000003 - id000003 = Channel(DEVICE+':IST:2', type = 'd') - #ScalarDetector id000004 - id000004 = Channel(DEVICE+':DIAM:2', type = 'd') - #ScalarDetector id000005 - id000005 = Channel(DEVICE+':IST1:1', type = 'd') - #ScalarDetector id000006 - id000006 = Channel(DEVICE+':IST1:2', type = 'd') - #ScalarDetector id000007 - id000007 = Channel(DEVICE+':IST2:1', type = 'd') - #ScalarDetector id000008 - id000008 = Channel(DEVICE+':IST2:2', type = 'd') - #ScalarDetector id000009 - id000009 = Channel(DEVICE+':IST3:1', type = 'd') - #ScalarDetector id000010 - id000010 = Channel(DEVICE+':IST3:2', type = 'd') + sleep( samplePeriod ) # Settling time 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 - for setpoint1 in range(0, 900): - readback1 = setpoint1 - sleep( 0.1 ) # Settling time - #Detector id000001 - detector1 = id000001.get() - #Detector id000003 - detector2 = id000003.get() - #Detector id000004 - detector3 = id000004.get() - #Detector id000005 - detector4 = id000005.get() - #Detector id000006 - detector5 = id000006.get() - #Detector id000007 - detector6 = id000007.get() - #Detector id000008 - detector7 = id000008.get() - #Detector id000009 - detector8 = id000009.get() - #Detector id000010 - detector9 = id000010.get() - scan.append ([setpoint1], [readback1], [detector1, detector2, detector3, detector5, detector7, detector9]) + + for setpoint1 in range(0, 10000): + sleep( samplePeriod ) # Settling time + + MotorStatus = idMotorStatus.get() + LogicalPosition = idLogicalPosition.get() + PotiRaw = idPotiRaw.get() + MotorPositionRaw = idMotorPositionRaw.get() + Com = idCom.get() + MotorPosition = idMotorPosition.get() + PotiPosFromBeam = idPotiPosFromBeam.get() + PotiPosition = idPotiPosition.get() + PotiRef1Position = idPotiRef1Position.get() + PotiRef2Position = idPotiRef2Position.get() + Diameter = idDiameter.get() + Inkr = idInkr.get() + InkrRb = idInkrRb.get() + + scan.append([setpoint1], [setpoint1], + [MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, MotorPositionRaw, MotorPosition, + PotiPosFromBeam, PotiRaw, PotiPosition, PotiRef1Position, PotiRef2Position]) + + if (MotorStatus & int('1',2))==0: #device finished calibration + break + + #check if any error bit is raised + if bool(MotorStatus & int('10000',2)): #error: abort test + test.sendFeedback('Motor switched off (bit#4)', False) + return + if bool(MotorStatus & int('100000',2)): #error: abort test + test.sendFeedback('No motor link (bit#5)', False) + return + if bool(MotorStatus & int('1000000',2)): #error: abort test + test.sendFeedback('No poti link (bit#6)', False) + return + if bool(MotorStatus & int('10000000',2)): #error: abort test + test.sendFeedback('Calibration error (bit#7)', False) + return + if bool(MotorStatus & int('100000000',2)): #error: abort test + test.sendFeedback('Cannot get to R1 (bit#8)', False) + return + if bool(MotorStatus & int('1000000000',2)): #error: abort test + test.sendFeedback('Cannot get to R2 (bit#9)', False) + return + if bool(MotorStatus & int('10000000000',2)): #error: abort test + test.sendFeedback('Position measurement mismatch (bit#10)', False) + return + if bool(MotorStatus & int('100000000000',2)): #error: abort test + test.sendFeedback('Movement timeout (bit#11)', False) + return #Closing channels - id000001.close() - id000003.close() - id000004.close() - id000005.close() - id000006.close() - id000007.close() - id000008.close() - id000009.close() - id000010.close() - + idMotorStatus.close() + idLogicalPosition.close() + idPotiRaw.close() + idMotorPositionRaw.close() + idCom.close() + idMotorPosition.close() + idPotiPosFromBeam.close() + idPotiPosition.close() + idPotiRef1Position.close() + idPotiRef2Position.close() + idDiameter.close() + idInkr.close() + idInkrRb.close() scan.end() ret = 'Calibration done' - status = True + success = True + scan.end() + ################ END OF YOUR CODE ################ -###### Final - DO NOT MODIFY THE CODE BELOW ###### - sendFeedback(testPath, testName, DEVICE, ret, success) +###### 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 - sendFeedback(testPath, testName, DEVICE, ret, success) - return + test.sendFeedback(ret, success) -#launch the test + +# launch the test startTest(test, device, parameters) - \ No newline at end of file diff --git a/script/tests/tests/Collimator Tests pro/Drive Out/Drive Out - Copy.py b/script/tests/tests/Collimator Tests pro/Drive Out/Drive Out - Copy.py index f197379..704a950 100644 --- a/script/tests/tests/Collimator Tests pro/Drive Out/Drive Out - Copy.py +++ b/script/tests/tests/Collimator Tests pro/Drive Out/Drive Out - Copy.py @@ -3,7 +3,7 @@ import traceback #by default, failed ret = 'Test failed' -status = False +success = False try: #Pre-actions: 2 = drive out @@ -79,4 +79,4 @@ scan.end() #return ok ret = 'Slides moved out' -status = True \ No newline at end of file +success = True \ No newline at end of file diff --git a/script/tests/tests/Collimator Tests pro/Drive Out/Drive Out.py b/script/tests/tests/Collimator Tests pro/Drive Out/Drive Out.py index 5f2dd02..027dd8a 100644 --- a/script/tests/tests/Collimator Tests pro/Drive Out/Drive Out.py +++ b/script/tests/tests/Collimator Tests pro/Drive Out/Drive Out.py @@ -1,118 +1,136 @@ +# Drive Out + ###### Init - 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) - log (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): + # by default, assume the test failed + ret = 'Test failed' + success = False + # plot name to be given to the scan. Use: scan.setPlotName(plotName) + plotName = DEVICE + ' - ' + testName + # put the whole custom code under try/catch 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. It can be sued in the following ways: + test = TestingTool(testName, testPath, DEVICE, params) + samplePeriod = 0.1 + ######### WRITE YOUR CODE HERE BELOW ############# - scan = ManualScan(['sample'], ['Drive Status: '+DEVICE+':STA:1', 'Logical Pos: '+DEVICE+':IST:2', 'Diameter: '+DEVICE+':DIAM:2 (mm)', 'Cpc: '+DEVICE+':IST1:2 (mm)', 'Pot: '+DEVICE+'::IST2:2 (mm)', 'Btvs: '+DEVICE+':IST3:2 (mm)'] ) - scan.setPlotName(plotName); + scan = ManualScan(['time [1/'+ str(1/samplePeriod) + ' s]'], ['Motor Status (STA:1)', 'Inkr (INKR:2)', 'InkrRb (INKRRB:2)', 'Diameter (DIAM:2)', 'Com (COM:2)', + 'Logical Position (IST:2)', 'Motor Pos Raw (IST3:1)','Motor Pos (IST3:2)', 'Poti Pos From Beam (IST1:2)', 'Poti Raw (POSA:1)', 'Poti Position (IST2:1)', + 'Poti Ref1 Position (REF1:1)', 'Poti Ref2 Position (REF2:1)']) + scan.setPlotName(plotName) scan.start() try: + idMotorStatus = Channel(DEVICE+':STA:1', type = 'd') # DSP device_status reg + idLogicalPosition = Channel(DEVICE+':IST:2', type = 'd') # Shows current position in logical units as calculated from motor step counter [1..n] + idPotiRaw = Channel(DEVICE+':POSA:1', type = 'd') # poti raw data [ADC units] + idMotorPositionRaw = Channel(DEVICE+':IST3:1', type = 'd') # shows current position in steps as as obtained from motor step counter [steps] + idInkr = Channel(DEVICE + ':INKR:2', type='d') # move relative distance (positive means towards R2) [mm] + idInkrRb = Channel(DEVICE + ':INKRRB:2', type='d') # readback of move relative distance (positive means towards R2) [mm] + idDiameter = Channel(DEVICE + ':DIAM:2', type='d') # collimator diameter [mm] + idCom = Channel(DEVICE + ':COM:2', type='d') # current position as from motor step counter [mm] + idMotorPosition = Channel(DEVICE + ':IST3:2', type='d') # current position as from motor step counter [mm] + idPotiPosFromBeam = Channel(DEVICE + ':IST1:2', type='d') # current position from beam as from potentiometer [mm] + idPotiPosition = Channel(DEVICE + ':IST2:1', type='d') # current position as from potentiometer [mm] + idPotiRef1Position = Channel(DEVICE + ':REF1:1', type='d') # R1 position as from potentiometer [mm] + idPotiRef2Position = Channel(DEVICE + ':REF2:1', type='d') # R2 position as from potentiometer [mm] + #Pre-actions: 2 = drive out caput(DEVICE+':COM:2', 2) - #Creating channels: dimension 1 - #PseudoPositioner id000000 - #ScalarDetector id000001 - id000001 = Channel(DEVICE+':STA:1', type = 'd') - #ScalarDetector id000003 - id000003 = Channel(DEVICE+':IST:2', type = 'd') - #ScalarDetector id000004 - id000004 = Channel(DEVICE+':DIAM:2', type = 'd') - #ScalarDetector id000005 - id000005 = Channel(DEVICE+':IST1:1', type = 'd') - #ScalarDetector id000006 - id000006 = Channel(DEVICE+':IST1:2', type = 'd') - #ScalarDetector id000007 - id000007 = Channel(DEVICE+':IST2:1', type = 'd') - #ScalarDetector id000008 - id000008 = Channel(DEVICE+':IST2:2', type = 'd') - #ScalarDetector id000009 - id000009 = Channel(DEVICE+':IST3:1', type = 'd') - #ScalarDetector id000010 - id000010 = Channel(DEVICE+':IST3:2', type = 'd') + sleep( samplePeriod ) # Settling time except: ret = 'Unable to create channel - ' + traceback.format_exc() success = False - sendFeedback(testPath, testName, DEVICE, ret, success) + test.sendFeedback( ret, success) return + for setpoint1 in range(0, 10000): + sleep( samplePeriod ) # Settling time - #Dimension 1 - #PseudoPositioner id000000 - for setpoint1 in range(0, 3000): - readback1 = setpoint1 - sleep( 0.1 ) # Settling time - #Detector id000001 - detector1 = id000001.get() - #Detector id000003 - detector2 = id000003.get() - #Detector id000004 - detector3 = id000004.get() - #Detector id000005 - detector4 = id000005.get() - #Detector id000006 - detector5 = id000006.get() - #Detector id000007 - detector6 = id000007.get() - #Detector id000008 - detector7 = id000008.get() - #Detector id000009 - detector8 = id000009.get() - #Detector id000010 - detector9 = id000010.get() - scan.append ([setpoint1], [readback1], [detector1, detector2, detector3, detector5, detector7, detector9]) + MotorStatus = idMotorStatus.get() + LogicalPosition = idLogicalPosition.get() + PotiRaw = idPotiRaw.get() + MotorPositionRaw = idMotorPositionRaw.get() + Com = idCom.get() + MotorPosition = idMotorPosition.get() + PotiPosFromBeam = idPotiPosFromBeam.get() + PotiPosition = idPotiPosition.get() + PotiRef1Position = idPotiRef1Position.get() + PotiRef2Position = idPotiRef2Position.get() + Diameter = idDiameter.get() + Inkr = idInkr.get() + InkrRb = idInkrRb.get() + + scan.append([setpoint1], [setpoint1], + [MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, MotorPositionRaw, MotorPosition, + PotiPosFromBeam, PotiRaw, PotiPosition, PotiRef1Position, PotiRef2Position]) + + if (MotorStatus & int('1',2))==0: #device finished calibration + break + + #check if any error bit is raised + if bool(MotorStatus & int('10000',2)): #error: abort test + test.sendFeedback('Motor switched off (bit#4)', False) + return + if bool(MotorStatus & int('100000',2)): #error: abort test + test.sendFeedback('No motor link (bit#5)', False) + return + if bool(MotorStatus & int('1000000',2)): #error: abort test + test.sendFeedback('No poti link (bit#6)', False) + return + if bool(MotorStatus & int('10000000',2)): #error: abort test + test.sendFeedback('Calibration error (bit#7)', False) + return + if bool(MotorStatus & int('100000000',2)): #error: abort test + test.sendFeedback('Cannot get to R1 (bit#8)', False) + return + if bool(MotorStatus & int('1000000000',2)): #error: abort test + test.sendFeedback('Cannot get to R2 (bit#9)', False) + return + if bool(MotorStatus & int('10000000000',2)): #error: abort test + test.sendFeedback('Position measurement mismatch (bit#10)', False) + return + if bool(MotorStatus & int('100000000000',2)): #error: abort test + test.sendFeedback('Movement timeout (bit#11)', False) + return #Closing channels - id000001.close() - id000003.close() - id000004.close() - id000005.close() - id000006.close() - id000007.close() - id000008.close() - id000009.close() - id000010.close() - + idMotorStatus.close() + idLogicalPosition.close() + idPotiRaw.close() + idMotorPositionRaw.close() + idCom.close() + idMotorPosition.close() + idPotiPosFromBeam.close() + idPotiPosition.close() + idPotiRef1Position.close() + idPotiRef2Position.close() + idDiameter.close() + idInkr.close() + idInkrRb.close() scan.end() - #return ok - ret = 'Slides moved out' - status = True -############# END OF YOUR CODE ########### -###### DO NOT MODIFY THE CODE BELOW ###### - sendFeedback(testPath, testName, DEVICE, ret, success) + ret = 'Drive Out done' + success = True + scan.end() + +################ 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 - sendFeedback(testPath, testName, DEVICE, ret, success) - return + test.sendFeedback(ret, success) -#launch the test + +# launch the test startTest(test, device, parameters) diff --git a/script/tests/tests/Collimator Tests pro/Monitor Movement/Monitor Movement - Copy.py b/script/tests/tests/Collimator Tests pro/Monitor Movement/Monitor Movement - Copy.py index 7a4b934..1a8f90a 100644 --- a/script/tests/tests/Collimator Tests pro/Monitor Movement/Monitor Movement - Copy.py +++ b/script/tests/tests/Collimator Tests pro/Monitor Movement/Monitor Movement - Copy.py @@ -8,7 +8,7 @@ def startTest(testName, DEVICE, params): testPath = inspect.getfile(inspect.currentframe()) #by default, 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 ####### @@ -63,11 +63,11 @@ def startTest(testName, DEVICE, params): idPotiRef2Position.close() print_log(testName, DEVICE, 'End of Monitoring') ret = 'End of Monitoring' - status = True + success = True ########## END OF YOUR CODE ########### ###### DO NOT MODIFY THE CODE BELOW ###### - sendFeedback(testPath, testName, DEVICE, ret, status) + sendFeedback(testPath, testName, DEVICE, ret, success) #prepare and send feedback to calling tool def sendFeedback(testPath, testName, DEVICE, returnString, testPassed): diff --git a/script/tests/tests/Collimator Tests pro/Monitor Movement/Monitor Movement.py b/script/tests/tests/Collimator Tests pro/Monitor Movement/Monitor Movement.py index f1d1076..5d73c14 100644 --- a/script/tests/tests/Collimator Tests pro/Monitor Movement/Monitor Movement.py +++ b/script/tests/tests/Collimator Tests pro/Monitor Movement/Monitor Movement.py @@ -19,8 +19,12 @@ def startTest(testName, DEVICE, params): ######### WRITE YOUR CODE HERE BELOW ############# #get parameters from the calling interface try: - test.log( "Running test Motor Movement for device " + DEVICE + " with the following parameters:\n" + str(params)) - monitorTime = int(test.getParam('monitorTime')) ; samplingDelay = float(test.getParam('samplingDelay')) + test.log( "Running test Motor Test 2 for device " + DEVICE) + #test.log( "with the following parameters:\n" + str(params)) + #test.log( 'testpath: ' + testPath ) + #test.log( 'parameters:' + str( params) ) + #test.log( 'device: ' + DEVICE ) + monitorTime = float(test.getParam("monitorTime")) except: ret = 'Could not retrieve testing parameters - ' + traceback.format_exc() success = False @@ -28,74 +32,51 @@ def startTest(testName, DEVICE, params): return #get parameters from the calling interface - scan = ManualScan(['1/10 s'], ['Motor Status (STA:1)', 'Inkr (INKR:2)', 'InkrRb (INKRRB:2)', 'Diameter (DIAM:2)', 'Com (COM:2)', - 'Logical Position (IST:2)', 'Motor Step Raw (IST3:1)','Motor Step (IST3:2)', 'Poti Pos From Beam (IST1:2)', 'Poti Raw (POSA:1)', 'Poti Position (IST2:1)', - 'Poti Ref1 Position (REF1:1)', 'Poti Ref2 Position (REF2:1)']) + scan = ManualScan(['time'], ['idMotorStep', 'idPotiPosition', 'idPotiRef1Position','idMotorStep-idPotiPosition'] ) scan.setPlotName(plotName) scan.start() - # Creating channels: dimension 1 + + #Creating channels: dimension 1 try: - idMotorStatus = Channel(DEVICE+':STA:1', type = 'd') # DSP device_status reg - idLogicalPosition = Channel(DEVICE+':IST:2', type = 'd') # Shows current position in logical units as calculated from motor step counter [1..n] - idPotiRaw = Channel(DEVICE+':POSA:1', type = 'd') # poti raw data [ADC units] - idMotorStepRaw = Channel(DEVICE+':IST3:1', type = 'd') # shows current position in steps as as obtained from motor step counter [steps] - idInkr = Channel(DEVICE + ':INKR:2', type='d') # move relative distance (positive means towards R2) [mm] - idInkrRb = Channel(DEVICE + ':INKRRB:2', type='d') # readback of move relative distance (positive means towards R2) [mm] - idDiameter = Channel(DEVICE + ':DIAM:2', type='d') # collimator diameter [mm] - idCom = Channel(DEVICE + ':COM:2', type='d') # current position as from motor step counter [mm] - idMotorStep = Channel(DEVICE + ':IST3:2', type='d') # current position as from motor step counter [mm] - idPotiPosFromBeam = Channel(DEVICE + ':IST1:2', type='d') # current position from beam as from potentiometer [mm] - idPotiPosition = Channel(DEVICE + ':IST2:1', type='d') # current position as from potentiometer [mm] - idPotiRef1Position = Channel(DEVICE + ':REF1:1', type='d') # R1 position as from potentiometer [mm] - idPotiRef2Position = Channel(DEVICE + ':REF2:1', type='d') # R2 position as from potentiometer [mm] + idCom = Channel(DEVICE+':COM:2', type = 'd') #current position as from motor step counter [mm] + idMotorStep = Channel(DEVICE+':IST3:2', type = 'd') #current position as from motor step counter [mm] + idPotiPosFromBeam = Channel(DEVICE+':IST1:2', type = 'd') #current position from beam as from potentiometer [mm] + idPotiPosition = Channel(DEVICE+':IST2:1', type = 'd') #current position as from potentiometer [mm] + idPotiRef1Position = Channel(DEVICE+':REF1:1', type = 'd') #R1 position as from potentiometer [mm] + idPotiRef2Position = Channel(DEVICE+':REF2:1', type = 'd') #R2 position as from potentiometer [mm] + except: test.sendFeedback( 'Unable to create channel - ' + traceback.format_exc(), False) + #raise Exception('Unable to create channel - ' + traceback.format_exc()) return + #monitorTime=40 #seconds test.log( 'Monitoring movement for ' + str(monitorTime) + 's') #scan quickly the output during some seconds + potiPosision = idPotiPosition.get() + potiRef2Position = idPotiRef2Position.get() timeElapsed=0 - monitoringTimeWindow = monitorTime*int(1.0/samplingDelay) - while timeElapsed::[;::] -parameters=repeatTimes:1:Repeat N times;delayS:5:Pause delay [s] +name=Motor Test 1 +description=Moves to CW switch then CCW switch N times. + + +#optional parameters. Description is compulsory. Syntax: +#parameters=::[;::] +parameters=repeatTimes:1:Repeat N times;delayS:5:Pause delay [s] diff --git a/script/tests/tests/Collimator Tests pro/Motor Test 1/Motor Test 1.py b/script/tests/tests/Collimator Tests pro/Motor Test 1/Motor Test 1.py index 0a0a8d9..ae6653f 100644 --- a/script/tests/tests/Collimator Tests pro/Motor Test 1/Motor Test 1.py +++ b/script/tests/tests/Collimator Tests pro/Motor Test 1/Motor Test 1.py @@ -10,7 +10,7 @@ import sys, inspect, os, traceback def startTest(testName, DEVICE, params): # 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 # put the whole custom code under try/catch @@ -20,15 +20,16 @@ def startTest(testName, DEVICE, params): # init the testing tool class. It can be sued in the following ways: test = TestingTool(testName, testPath, DEVICE, params) - ######### WRITE YOUR CODE HERE BELOW ############# +######### WRITE YOUR CODE HERE BELOW ############# # DEVICE = 'PO2DV-NCS-LS' # get parameters from the calling interface try: - test.log("Running test Motor Test 1 with the following parameters:") + test.log("Running test with the following parameters:") test.log(params) loopTimes = int(test.getParam("repeatTimes")) delaySeconds = int(test.getParam("delayS")) + samplePeriod = 0.05 #seconds except: ret = 'Could not retrieve testing parameters - ' + traceback.format_exc() success = False @@ -36,8 +37,9 @@ def startTest(testName, DEVICE, params): return scan = ManualScan(['idX'], ['Motor Status (STA:1)', 'Inkr (INKR:2)', 'InkrRb (INKRRB:2)', 'Diameter (DIAM:2)', 'Com (COM:2)', - 'Logical Position (IST:2)', 'Motor Step Raw (IST3:1)','Motor Step (IST3:2)', 'Poti Pos From Beam (IST1:2)', 'Poti Raw (POSA:1)', 'Poti Position (IST2:1)', + 'Logical Position (IST:2)', 'Motor Pos Raw (IST3:1)','Motor Pos (IST3:2)', 'Poti Pos From Beam (IST1:2)', 'Poti Raw (POSA:1)', 'Poti Position (IST2:1)', 'Poti Ref1 Position (REF1:1)', 'Poti Ref2 Position (REF2:1)']) + p1 = plot(None, name = "Poti Pos From Beam - Motor Position", context = plotName + " pos difference")[0] scan.setPlotName(plotName) scan.start() # Creating channels: dimension 1 @@ -50,7 +52,7 @@ def startTest(testName, DEVICE, params): idInkrRb = Channel(DEVICE + ':INKRRB:2', type='d') # readback of move relative distance (positive means towards R2) [mm] idDiameter = Channel(DEVICE + ':DIAM:2', type='d') # collimator diameter [mm] idCom = Channel(DEVICE + ':COM:2', type='d') # current position as from motor step counter [mm] - idMotorStep = Channel(DEVICE + ':IST3:2', type='d') # current position as from motor step counter [mm] + idMotorPosition = Channel(DEVICE + ':IST3:2', type='d') # current position as from motor step counter [mm] idPotiPosFromBeam = Channel(DEVICE + ':IST1:2', type='d') # current position from beam as from potentiometer [mm] idPotiPosition = Channel(DEVICE + ':IST2:1', type='d') # current position as from potentiometer [mm] idPotiRef1Position = Channel(DEVICE + ':REF1:1', type='d') # R1 position as from potentiometer [mm] @@ -60,65 +62,93 @@ def startTest(testName, DEVICE, params): success = False test.sendFeedback(ret, success) return - - # remove limits - # idLimitH.put(999999.9, timeout=None) - # idLimitL.put(-999999.9, timeout=None) - # Dimension 1 - direction = 1.0; - startDefault = -100.0 - endDefault = 1000.0 - end = endDefault - # find position at Low end switch: it will be the starting point of the test - test.log('Homing') - idInkr.put(-100.0, timeout=None) # TODO: Set appropriate timeout - start = startDefault # idInkr.get()+direction + + end = 4 #go to R2 + start = 3 #go to R1 setpoint2 = end count = 0 test.log('Starting test sequence') for setpoint1 in range(0, loopTimes * 2): - sleep(delaySeconds) # Settling time + p1.addSeries(LinePlotSeries("Run"+str(count))) + sleep(delaySeconds) # Settling time between runs # RegionPositioner idInkr idInkr.put(setpoint2, timeout=None) # TODO: Set appropriate timeout - - MotorStatus = idMotorStatus.get() - LogicalPosition = idLogicalPosition.get() - PotiRaw = idPotiRaw.get() - MotorStepRaw = idMotorStepRaw.get() - Com = idCom.get() - MotorStep = idMotorStep.get() - PotiPosFromBeam = idPotiPosFromBeam.get() - PotiPosition = idPotiPosition.get() - PotiRef1Position = idPotiRef1Position.get() - PotiRef2Position = idPotiRef2Position.get() - Diameter = idDiameter.get() - Inkr = idInkr.get() - InkrRb = idInkrRb.get() - count = count + 1 - idDiff01 = a - b - if endH > 0.0: - # invert direction and swap start with end of translation - setpoint2 = start - test.log('End H switch, changing target to ' + str(setpoint2)) - if endL > 0.0: - # invert direction and swap start with end of translation - setpoint2 = end - test.log('End L switch, changing target to ' + str(setpoint2)) - scan.append([setpoint2], [setpoint2], - [MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, MotorStepRaw, MotorStep, - PotiPosFromBeam, PotiRaw, PotiPosition, PotiRef1Position, PotiRef2Position]) + # scan for changes + for scanTimes in range(0, 100000): + sleep(samplePeriod) + currentTime = float(java.lang.System.currentTimeMillis()) + + MotorStatus = idMotorStatus.get() + LogicalPosition = idLogicalPosition.get() + PotiRaw = idPotiRaw.get() + MotorStepRaw = idMotorStepRaw.get() + Com = idCom.get() + MotorPosition = idMotorPosition.get() + PotiPosFromBeam = idPotiPosFromBeam.get() + PotiPosition = idPotiPosition.get() + PotiRef1Position = idPotiRef1Position.get() + PotiRef2Position = idPotiRef2Position.get() + Diameter = idDiameter.get() + Inkr = idInkr.get() + InkrRb = idInkrRb.get() + + idDiff01 = PotiPosition - MotorPosition + + scan.append([setpoint2], [setpoint2], + [MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, MotorStepRaw, MotorStep, + PotiPosFromBeam, PotiRaw, PotiPosition, PotiRef1Position, PotiRef2Position]) + + p1.getSeries(count).appendData(currentTime, idDiff01) + + #extract Status bits + endH = bool(MotorStatus & 8) #Ref2 (high limit) + endL = bool(MotorStatus & 4) #Ref1 (low limit) + + #check if arrived to R1 or R2 + if endH: + # invert direction and swap start with end of translation + setpoint2 = start + test.log('Reached R2 switch, changing target to R1') + break + elif endL: + # invert direction and swap start with end of translation + setpoint2 = end + test.log('Reached R1 switch, changing target to R2') + break + #check if any error bit is raised + if bool(MotorStatus & int('10000',2)): #error: abort test + test.sendFeedback('Motor switched off (bit#4)', False) + return + if bool(MotorStatus & int('100000',2)): #error: abort test + test.sendFeedback('No motor link (bit#5)', False) + return + if bool(MotorStatus & int('1000000',2)): #error: abort test + test.sendFeedback('No poti link (bit#6)', False) + return + if bool(MotorStatus & int('10000000',2)): #error: abort test + test.sendFeedback('Calibration error (bit#7)', False) + return + if bool(MotorStatus & int('100000000',2)): #error: abort test + test.sendFeedback('Cannot get to R1 (bit#8)', False) + return + if bool(MotorStatus & int('1000000000',2)): #error: abort test + test.sendFeedback('Cannot get to R2 (bit#9)', False) + return + if bool(MotorStatus & int('10000000000',2)): #error: abort test + test.sendFeedback('Position measurement mismatch (bit#10)', False) + return + if bool(MotorStatus & int('100000000000',2)): #error: abort test + test.sendFeedback('Movement timeout (bit#11)', False) + return - # set limits back - # idLimitH.put(145.0, timeout=None) - # idLimitL.put(0.0, timeout=None) # Closing channels idMotorStatus.close() idLogicalPosition.close() idPotiRaw.close() idMotorStepRaw.close() idCom.close() - idMotorStep.close() + idMotorPosition.close() idPotiPosFromBeam.close() idPotiPosition.close() idPotiRef1Position.close() @@ -131,8 +161,8 @@ def startTest(testName, DEVICE, params): ret = 'Slide moved back and forth (' + str(count) + ' runs)' success = True - ################ END OF YOUR CODE ################ - ###### Final - DO NOT MODIFY THE CODE BELOW ###### +################ END OF YOUR CODE ################ +###### Final - DO NOT MODIFY THE CODE BELOW ###### # just in case the feedback was forgotten test.sendFeedback(ret, success) diff --git a/script/tests/tests/Collimator Tests pro/Motor Test 1/help.html b/script/tests/tests/Collimator Tests pro/Motor Test 1/help.html index ec5543c..87b5e83 100644 --- a/script/tests/tests/Collimator Tests pro/Motor Test 1/help.html +++ b/script/tests/tests/Collimator Tests pro/Motor Test 1/help.html @@ -1,14 +1,14 @@ - - -

Short Description

-Moves to CW switch then CCW switch N times. -

Details

-Moves to CW switch then CCW switch N times. -

Parameters

-repeatTimes Repeat the moving N times
-delayS Pause delay between each repetition [s] -

Contact

-Marco Boccioli - - - + + +

Short Description

+Moves to CW switch then CCW switch N times. +

Details

+Moves to CW switch then CCW switch N times. +

Parameters

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

Contact

+Marco Boccioli + + + diff --git a/script/tests/tests/Collimator Tests pro/Motor Test 2/Motor Test 2.py b/script/tests/tests/Collimator Tests pro/Motor Test 2/Motor Test 2.py index 1239edd..a2a3217 100644 --- a/script/tests/tests/Collimator Tests pro/Motor Test 2/Motor Test 2.py +++ b/script/tests/tests/Collimator Tests pro/Motor Test 2/Motor Test 2.py @@ -9,7 +9,7 @@ import sys, inspect, os, traceback def startTest(testName, DEVICE, params): # 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 # put the whole custom code under try/catch @@ -19,44 +19,44 @@ def startTest(testName, DEVICE, params): # init the testing tool class. It can be sued in the following ways: test = TestingTool(testName, testPath, DEVICE, params) - ######### WRITE YOUR CODE HERE BELOW ############# +######### WRITE YOUR CODE HERE BELOW ############# # get parameters from the calling interface try: - test.log( - "Running test Motor Test 2 for device " + DEVICE + " with the following parameters:\n" + str(params)) + test.log("Running test with the following parameters:") + test.log(params) middle = float(test.getParam("midPoint")) loopTimes = int(test.getParam("repeatTimes")) span = float(test.getParam("spanFromMidPoint")) + settlingTime = 0.2 #seconds except: ret = 'Could not retrieve testing parameters - ' + traceback.format_exc() success = False - test.sendFeedback(ret, status) + test.sendFeedback(ret, success) return scan = ManualScan(['idX'], ['Motor Status (STA:1)', 'Inkr (INKR:2)', 'InkrRb (INKRRB:2)', 'Diameter (DIAM:2)', 'Com (COM:2)', - 'Logical Position (IST:2)', 'Motor Step Raw (IST3:1)', 'Motor Step (IST3:2)', + 'Logical Position (IST:2)', 'Motor Pos Raw (IST3:1)', 'Motor Pos (IST3:2)', 'Poti Pos From Beam (IST1:2)', 'Poti Raw (POSA:1)', 'Poti Position (IST2:1)', 'Poti Ref1 Position (REF1:1)', 'Poti Ref2 Position (REF2:1)']) scan.setPlotName(plotName) scan.start() - # coloured plot (one colour per scan) p1 = plot(None, name="Poti-Increment difference", context=plotName + " difference")[0] - p2 = plot(None, name="Poti-MotorStep difference", context=plotName + " difference")[0] + p2 = plot(None, name="Poti-MotorPosition difference", context=plotName + " difference")[0] # Creating channels: dimension 1 try: idMotorStatus = Channel(DEVICE + ':STA:1', type='d') # DSP device_status reg idLogicalPosition = Channel(DEVICE + ':IST:2', type='d') # Shows current position in logical units as calculated from motor step counter [1..n] idPotiRaw = Channel(DEVICE + ':POSA:1', type='d') # poti raw data [ADC units] - idMotorStepRaw = Channel(DEVICE + ':IST3:1', type='d') # shows current position in steps as as obtained from motor step counter [steps] + idMotorPositionRaw = Channel(DEVICE + ':IST3:1', type='d') # shows current position in steps as as obtained from motor step counter [steps] idInkr = Channel(DEVICE + ':INKR:2', type='d') # move relative distance (positive means towards R2) [mm] idInkrRb = Channel(DEVICE + ':INKRRB:2', type='d') # readback of move relative distance (positive means towards R2) [mm] idDiameter = Channel(DEVICE + ':DIAM:2', type='d') # collimator diameter [mm] idCom = Channel(DEVICE + ':COM:2', type='d') # current position as from motor step counter [mm] - idMotorStep = Channel(DEVICE + ':IST3:2', type='d') # current position as from motor step counter [mm] + idMotorPosition = Channel(DEVICE + ':IST3:2', type='d') # current position as from motor step counter [mm] idPotiPosFromBeam = Channel(DEVICE + ':IST1:2', type='d') # current position from beam as from potentiometer [mm] idPotiPosition = Channel(DEVICE + ':IST2:1', type='d') # current position as from potentiometer [mm] idPotiRef1Position = Channel(DEVICE + ':REF1:1', type='d') # R1 position as from potentiometer [mm] @@ -64,7 +64,7 @@ def startTest(testName, DEVICE, params): except: ret = 'Unable to create channel - ' + traceback.format_exc() success = False - test.sendFeedback(ret, status) + test.sendFeedback(ret, success) return direction = 1.0 @@ -79,7 +79,7 @@ def startTest(testName, DEVICE, params): ret = 'Actor idInkr could not be set to the value ' + str(middle) + ' (current value: ' + str( readback2) + ')' success = False - test.sendFeedback(ret, status) + test.sendFeedback(ret, success) return start = readback2 + direction countSteps = 0 @@ -93,21 +93,15 @@ def startTest(testName, DEVICE, params): for setpoint2 in frange(start, end, direction): readback1 = setpoint1 idInkr.put(setpoint2, timeout=None) # TODO: Set appropriate timeout - sleep(0.2) # Settling time + sleep(settlingTime) # Settling time readback2 = idInkr.get() - if abs(readback2 - setpoint2) > 1: # TODO: Check accuracy - ret = 'Actor idInkr could not be set to the value ' + str(setpoint2) + ' (current value: ' + str( - readback2) + ')' - success = False - test.sendFeedback(ret, status) - return MotorStatus = idMotorStatus.get() LogicalPosition = idLogicalPosition.get() PotiRaw = idPotiRaw.get() - MotorStepRaw = idMotorStepRaw.get() + MotorPositionRaw = idMotorPositionRaw.get() Com = idCom.get() - MotorStep = idMotorStep.get() + MotorPosition = idMotorPosition.get() PotiPosFromBeam = idPotiPosFromBeam.get() PotiPosition = idPotiPosition.get() PotiRef1Position = idPotiRef1Position.get() @@ -119,10 +113,10 @@ def startTest(testName, DEVICE, params): idDiff01 = potiPosition - inkrRb # Manipulation idDiff02 # Variable Mappings - idDiff02 = potiPosition - motorStep + idDiff02 = potiPosition - MotorPosition countSteps = countSteps + 1 scan.append([countSteps], [countSteps], - [MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, MotorStepRaw, MotorStep, + [MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, MotorPositionRaw, MotorPosition, PotiPosFromBeam, PotiRaw, PotiPosition, PotiRef1Position, PotiRef2Position]) p1.getSeries(count).appendData(setpoint2, idDiff01) p2.getSeries(count).appendData(setpoint2, idDiff02) @@ -142,13 +136,58 @@ def startTest(testName, DEVICE, params): break + #extract Status bits + endH = bool(MotorStatus & 8) #Ref2 (high limit) + endL = bool(MotorStatus & 4) #Ref1 (low limit) + + #check if arrived to R1 or R2; if so, invert direction + if endH: + # invert direction and swap start with end of translation + end = startDefault - 1 + start = setpoint2 - direction + direction = -1.0 + test.log('Reached R2 switch, changing direction to ' + str(direction)) + break + elif endL: + # invert direction and swap start with end of translation + end = endDefault + 1 + start = setpoint2 - direction + direction = 1.0 + test.log('Reached R1 switch, changing direction to ' + str(direction)) + break + #check if any error bit is raised + if bool(MotorStatus & int('10000',2)): #error: abort test + test.sendFeedback('Motor switched off (bit#4)', False) + return + if bool(MotorStatus & int('100000',2)): #error: abort test + test.sendFeedback('No motor link (bit#5)', False) + return + if bool(MotorStatus & int('1000000',2)): #error: abort test + test.sendFeedback('No poti link (bit#6)', False) + return + if bool(MotorStatus & int('10000000',2)): #error: abort test + test.sendFeedback('Calibration error (bit#7)', False) + return + if bool(MotorStatus & int('100000000',2)): #error: abort test + test.sendFeedback('Cannot get to R1 (bit#8)', False) + return + if bool(MotorStatus & int('1000000000',2)): #error: abort test + test.sendFeedback('Cannot get to R2 (bit#9)', False) + return + if bool(MotorStatus & int('10000000000',2)): #error: abort test + test.sendFeedback('Position measurement mismatch (bit#10)', False) + return + if bool(MotorStatus & int('100000000000',2)): #error: abort test + test.sendFeedback('Movement timeout (bit#11)', False) + return + # Closing channels idMotorStatus.close() idLogicalPosition.close() idPotiRaw.close() - idMotorStepRaw.close() + idMotorPositionRaw.close() idCom.close() - idMotorStep.close() + idMotorPosition.close() idPotiPosFromBeam.close() idPotiPosition.close() idPotiRef1Position.close() @@ -159,10 +198,10 @@ def startTest(testName, DEVICE, params): scan.end() ret = 'Slide moved back and forth (' + str(count) + ' runs)' - status = True + success = True - ################ END OF YOUR CODE ################ - ###### Final - DO NOT MODIFY THE CODE BELOW ###### +################ END OF YOUR CODE ################ +###### Final - DO NOT MODIFY THE CODE BELOW ###### # just in case the feedback was forgotten test.sendFeedback(ret, success) diff --git a/script/tests/tests/Collimator Tests pro/Motor Test 3/.config b/script/tests/tests/Collimator Tests pro/Motor Test 3/.config index ee1ac77..78fbe26 100644 --- a/script/tests/tests/Collimator Tests pro/Motor Test 3/.config +++ b/script/tests/tests/Collimator Tests pro/Motor Test 3/.config @@ -1,7 +1,7 @@ -name=Motor Test 3 -description=Moves from CCW to CW as a series of discrete translations (C times) logs after each translation. When end switch is encountered change direction. Repeat N times - - -#optional parameters. Description is compulsory. Syntax: -#parameters=::[;::] -parameters=repeatTimes:1:Repeat N times;translation:2:Translation C steps +name=Motor Test 3 +description=Moves from CCW to CW as a series of discrete translations (C times) logs after each translation. When end switch is encountered change direction. Repeat N times + + +#optional parameters. Description is compulsory. Syntax: +#parameters=::[;::] +parameters=repeatTimes:1:Repeat N times;translation:2:Translation C steps diff --git a/script/tests/tests/Collimator Tests pro/Motor Test 3/Motor Test 3.py b/script/tests/tests/Collimator Tests pro/Motor Test 3/Motor Test 3.py index 4ff077f..4014ae5 100644 --- a/script/tests/tests/Collimator Tests pro/Motor Test 3/Motor Test 3.py +++ b/script/tests/tests/Collimator Tests pro/Motor Test 3/Motor Test 3.py @@ -25,29 +25,31 @@ def startTest(testName, DEVICE, params): test.log(params) loopTimes = int(test.getParam("repeatTimes")) direction = int(test.getParam("translation")) + settlingTime = 0.2 #seconds except: test.log("Could not retrieve testing parameters: ", sys.exc_info()[0]) ret = 'Could not retrieve testing parameters - ' + traceback.format_exc() success = False - test.sendFeedback(ret, status) + test.sendFeedback(ret, success) return - scan = ManualScan(['idX'], ['Motor Status (STA:1)', 'Inkr (INKR:2)', 'InkrRb (INKRRB:2)', 'Diameter (DIAM:2)', 'Com (COM:2)', - 'Logical Position (IST:2)', 'Motor Step Raw (IST3:1)','Motor Step (IST3:2)', 'Poti Pos From Beam (IST1:2)', 'Poti Raw (POSA:1)', 'Poti Position (IST2:1)', + scan = ManualScan(['time'], ['Motor Status (STA:1)', 'Inkr (INKR:2)', 'InkrRb (INKRRB:2)', 'Diameter (DIAM:2)', 'Com (COM:2)', + 'Logical Position (IST:2)', 'Motor Pos Raw (IST3:1)','Motor Pos (IST3:2)', 'Poti Pos From Beam (IST1:2)', 'Poti Raw (POSA:1)', 'Poti Position (IST2:1)', 'Poti Ref1 Position (REF1:1)', 'Poti Ref2 Position (REF2:1)']) scan.setPlotName(plotName) scan.start() + p1 = plot(None, name = "Poti Pos From Beam - Motor Position", context = plotName + " pos difference")[0] # Creating channels: dimension 1 try: idMotorStatus = Channel(DEVICE+':STA:1', type = 'd') # DSP device_status reg idLogicalPosition = Channel(DEVICE+':IST:2', type = 'd') # Shows current position in logical units as calculated from motor step counter [1..n] idPotiRaw = Channel(DEVICE+':POSA:1', type = 'd') # poti raw data [ADC units] - idMotorStepRaw = Channel(DEVICE+':IST3:1', type = 'd') # shows current position in steps as as obtained from motor step counter [steps] + idMotorPositionRaw = Channel(DEVICE+':IST3:1', type = 'd') # shows current position in steps as as obtained from motor step counter [steps] idInkr = Channel(DEVICE + ':INKR:2', type='d') # move relative distance (positive means towards R2) [mm] idInkrRb = Channel(DEVICE + ':INKRRB:2', type='d') # readback of move relative distance (positive means towards R2) [mm] idDiameter = Channel(DEVICE + ':DIAM:2', type='d') # collimator diameter [mm] idCom = Channel(DEVICE + ':COM:2', type='d') # current position as from motor step counter [mm] - idMotorStep = Channel(DEVICE + ':IST3:2', type='d') # current position as from motor step counter [mm] + idMotorPosition = Channel(DEVICE + ':IST3:2', type='d') # current position as from motor step counter [mm] idPotiPosFromBeam = Channel(DEVICE + ':IST1:2', type='d') # current position from beam as from potentiometer [mm] idPotiPosition = Channel(DEVICE + ':IST2:1', type='d') # current position as from potentiometer [mm] idPotiRef1Position = Channel(DEVICE + ':REF1:1', type='d') # R1 position as from potentiometer [mm] @@ -77,19 +79,19 @@ def startTest(testName, DEVICE, params): for setpoint1 in range(0, loopTimes*2): count = count + 1 sleep( 2 ) # Settling time - #RegionPositioner idInkr + p1.addSeries(LinePlotSeries("Run"+str(count))) + #go to an end reference for setpoint2 in frange(start, end, direction): - readback1 = setpoint1 idInkr.put(setpoint2, timeout=10) # TODO: Set appropriate timeout - sleep( 0.2 ) # Settling time + sleep(settlingTime) # Settling time readback2 = idInkr.get() MotorStatus = idMotorStatus.get() LogicalPosition = idLogicalPosition.get() PotiRaw = idPotiRaw.get() - MotorStepRaw = idMotorStepRaw.get() + MotorPositionRaw = idMotorPositionRaw.get() Com = idCom.get() - MotorStep = idMotorStep.get() + MotorPosition = idMotorPosition.get() PotiPosFromBeam = idPotiPosFromBeam.get() PotiPosition = idPotiPosition.get() PotiRef1Position = idPotiRef1Position.get() @@ -98,46 +100,66 @@ def startTest(testName, DEVICE, params): Inkr = idInkr.get() InkrRb = idInkrRb.get() - #Manipulation idDiff02 - #Variable Mappings - a = detector4 - b = detector8 - idDiff02 = a-b - #Manipulation idDiff01 - #Variable Mappings - a = detector4 - b = detector6 - idDiff01 = a-b + idDiff01 = PotiPosition-MotorPosition countSteps = countSteps + 1 scan.append([setpoint2], [setpoint2], - [MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, MotorStepRaw, MotorStep, + [MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, MotorPositionRaw, MotorPosition, PotiPosFromBeam, PotiRaw, PotiPosition, PotiRef1Position, PotiRef2Position]) - if endH>0.0 : + p1.getSeries(count).appendData(setpoint2, idDiff01) + + #extract Status bits + endH = bool(MotorStatus & 8) #Ref2 (high limit) + endL = bool(MotorStatus & 4) #Ref1 (low limit) + + #check if arrived to R1 or R2 + if endH: #invert direction and swap start with end of translation end = startDefault start = readback2 - direction direction = -1.0 - test.log('End H switch, changing direction to ' + str(direction)) + test.log('Reached R2 switch, changing target to R1') break - if endL>0.0 : + elif endL: #invert direction and swap start with end of translation end = endDefault start = readback2 - direction direction = 1.0 - test.log('End L switch, changing direction to ' + str(direction)) + test.log('Reached R1 switch, changing target to R2') break - #set limits back - #idLimitH.put(145.0, timeout=None) - #idLimitL.put(0.0, timeout=None) + #check if any error bit is raised + if bool(MotorStatus & int('10000',2)): #error: abort test + test.sendFeedback('Motor switched off (bit#4)', False) + return + if bool(MotorStatus & int('100000',2)): #error: abort test + test.sendFeedback('No motor link (bit#5)', False) + return + if bool(MotorStatus & int('1000000',2)): #error: abort test + test.sendFeedback('No poti link (bit#6)', False) + return + if bool(MotorStatus & int('10000000',2)): #error: abort test + test.sendFeedback('Calibration error (bit#7)', False) + return + if bool(MotorStatus & int('100000000',2)): #error: abort test + test.sendFeedback('Cannot get to R1 (bit#8)', False) + return + if bool(MotorStatus & int('1000000000',2)): #error: abort test + test.sendFeedback('Cannot get to R2 (bit#9)', False) + return + if bool(MotorStatus & int('10000000000',2)): #error: abort test + test.sendFeedback('Position measurement mismatch (bit#10)', False) + return + if bool(MotorStatus & int('100000000000',2)): #error: abort test + test.sendFeedback('Movement timeout (bit#11)', False) + return #Closing channels idMotorStatus.close() idLogicalPosition.close() idPotiRaw.close() - idMotorStepRaw.close() + idMotorPositionRaw.close() idCom.close() - idMotorStep.close() + idMotorPosition.close() idPotiPosFromBeam.close() idPotiPosition.close() idPotiRef1Position.close() diff --git a/script/tests/tests/Collimator Tests pro/Motor Test 3/help.html b/script/tests/tests/Collimator Tests pro/Motor Test 3/help.html index b5239a2..6fef1db 100644 --- a/script/tests/tests/Collimator Tests pro/Motor Test 3/help.html +++ b/script/tests/tests/Collimator Tests pro/Motor Test 3/help.html @@ -1,13 +1,13 @@ - - -

Description

-Moves from CCW to CW as a series of discrete translations (C steps) logs after each translation. When end switch is encountered change direction. Repeat N times -

Parameters

-repeatTimes How many N times the test is repeated
-translation How many C steps are done for one translation
- -

Contact

-boccioli_m - - - + + +

Description

+Moves from CCW to CW as a series of discrete translations (C steps) logs after each translation. When end switch is encountered change direction. Repeat N times +

Parameters

+repeatTimes How many N times the test is repeated
+translation How many C steps are done for one translation
+ +

Contact

+boccioli_m + + + diff --git a/script/tests/tests/Collimator Tests pro/Move Ref 1/Move Ref 1 - Copy.py b/script/tests/tests/Collimator Tests pro/Move Ref 1/Move Ref 1 - Copy.py index 5042996..9272085 100644 --- a/script/tests/tests/Collimator Tests pro/Move Ref 1/Move Ref 1 - Copy.py +++ b/script/tests/tests/Collimator Tests pro/Move Ref 1/Move Ref 1 - Copy.py @@ -5,7 +5,7 @@ def startTest(testName, DEVICE, params): testPath = inspect.getfile(inspect.currentframe()) #by default, 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 ####### @@ -63,7 +63,7 @@ def startTest(testName, DEVICE, params): ########## END OF YOUR CODE ########### ###### DO NOT MODIFY THE CODE BELOW ###### - sendFeedback(testPath, testName, DEVICE, ret, status) + sendFeedback(testPath, testName, DEVICE, ret, success) #prepare and send feedback to calling tool def sendFeedback(testPath, testName, DEVICE, returnString, testPassed): diff --git a/script/tests/tests/Collimator Tests pro/Move Ref 1/Move Ref 1.py b/script/tests/tests/Collimator Tests pro/Move Ref 1/Move Ref 1.py index 728675d..48497db 100644 --- a/script/tests/tests/Collimator Tests pro/Move Ref 1/Move Ref 1.py +++ b/script/tests/tests/Collimator Tests pro/Move Ref 1/Move Ref 1.py @@ -1,95 +1,136 @@ +# Drive to R1 + ###### Init - 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) - log (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): + # by default, assume the test failed + ret = 'Test failed' + success = False + # plot name to be given to the scan. Use: scan.setPlotName(plotName) + plotName = DEVICE + ' - ' + testName + # put the whole custom code under try/catch 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. It can be sued in the following ways: + test = TestingTool(testName, testPath, DEVICE, params) + samplePeriod = 0.1 + ######### WRITE YOUR CODE HERE BELOW ############# - #get parameters from the calling interface - print_log(testName, DEVICE, 'testpath: ' + testPath ) - print_log(testName, DEVICE, 'parameters:' + str( params) ) - print_log(testName, DEVICE, 'device: ' + DEVICE ) - scan = ManualScan(['time'], ['idMotorStep', 'idPotiPosition', 'idPotiRef1Position','idMotorStep-idPotiPosition'] , [0.0], [30.0], [20]) + scan = ManualScan(['time [1/'+ str(1/samplePeriod) + ' s]'], ['Motor Status (STA:1)', 'Inkr (INKR:2)', 'InkrRb (INKRRB:2)', 'Diameter (DIAM:2)', 'Com (COM:2)', + 'Logical Position (IST:2)', 'Motor Pos Raw (IST3:1)','Motor Pos (IST3:2)', 'Poti Pos From Beam (IST1:2)', 'Poti Raw (POSA:1)', 'Poti Position (IST2:1)', + 'Poti Ref1 Position (REF1:1)', 'Poti Ref2 Position (REF2:1)']) scan.setPlotName(plotName) scan.start() - #Creating channels: dimension 1 try: - idCom = Channel(DEVICE+':COM:2', type = 'd') #current position as from motor step counter [mm] - idMotorStep = Channel(DEVICE+':IST3:2', type = 'd') #current position as from motor step counter [mm] - idPotiPosFromBeam = Channel(DEVICE+':IST1:2', type = 'd') #current position from beam as from potentiometer [mm] - idPotiPosition = Channel(DEVICE+':IST2:1', type = 'd') #current position as from potentiometer [mm] - idPotiRef1Position = Channel(DEVICE+':REF1:1', type = 'd') #R1 position as from potentiometer [mm] - idPotiRef2Position = Channel(DEVICE+':REF2:1', type = 'd') #R2 position as from potentiometer [mm] + idMotorStatus = Channel(DEVICE+':STA:1', type = 'd') # DSP device_status reg + idLogicalPosition = Channel(DEVICE+':IST:2', type = 'd') # Shows current position in logical units as calculated from motor step counter [1..n] + idPotiRaw = Channel(DEVICE+':POSA:1', type = 'd') # poti raw data [ADC units] + idMotorPositionRaw = Channel(DEVICE+':IST3:1', type = 'd') # shows current position in steps as as obtained from motor step counter [steps] + idInkr = Channel(DEVICE + ':INKR:2', type='d') # move relative distance (positive means towards R2) [mm] + idInkrRb = Channel(DEVICE + ':INKRRB:2', type='d') # readback of move relative distance (positive means towards R2) [mm] + idDiameter = Channel(DEVICE + ':DIAM:2', type='d') # collimator diameter [mm] + idCom = Channel(DEVICE + ':COM:2', type='d') # current position as from motor step counter [mm] + idMotorPosition = Channel(DEVICE + ':IST3:2', type='d') # current position as from motor step counter [mm] + idPotiPosFromBeam = Channel(DEVICE + ':IST1:2', type='d') # current position from beam as from potentiometer [mm] + idPotiPosition = Channel(DEVICE + ':IST2:1', type='d') # current position as from potentiometer [mm] + idPotiRef1Position = Channel(DEVICE + ':REF1:1', type='d') # R1 position as from potentiometer [mm] + idPotiRef2Position = Channel(DEVICE + ':REF2:1', type='d') # R2 position as from potentiometer [mm] + idCom.put('3', timeout=None) # go to R1 + sleep( samplePeriod ) # Settling time except: - sendFeedback(testPath, testName, DEVICE, 'Unable to create channel - ' + traceback.format_exc(), False) - #raise Exception('Unable to create channel - ' + traceback.format_exc()) + ret = 'Unable to create channel - ' + traceback.format_exc() + success = False + test.sendFeedback( ret, success) return - idCom.put('3', timeout=None) # go to R1 - print_log(testName, DEVICE, 'Moving to reference point') - #scan quickly the output during some seconds - detector4 = idPotiPosition.get() - detector6 = idPotiRef2Position.get() - timeElapsed=0 - while detector4>detector6 and timeElapsed<600: - #Detector time - detector1 = float(java.lang.System.currentTimeMillis()) + #scan for a while to collect data + for setpoint1 in range(0, 10000): + sleep( samplePeriod ) # Settling time + + MotorStatus = idMotorStatus.get() + LogicalPosition = idLogicalPosition.get() + PotiRaw = idPotiRaw.get() + MotorPositionRaw = idMotorPositionRaw.get() + Com = idCom.get() + MotorPosition = idMotorPosition.get() + PotiPosFromBeam = idPotiPosFromBeam.get() + PotiPosition = idPotiPosition.get() + PotiRef1Position = idPotiRef1Position.get() + PotiRef2Position = idPotiRef2Position.get() + Diameter = idDiameter.get() + Inkr = idInkr.get() + InkrRb = idInkrRb.get() + + scan.append([setpoint1], [setpoint1], + [MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, MotorPositionRaw, MotorPosition, + PotiPosFromBeam, PotiRaw, PotiPosition, PotiRef1Position, PotiRef2Position]) + + if (MotorStatus & int('1',2))==0: #device finished calibration + break + + #check if any error bit is raised + if bool(MotorStatus & int('10000',2)): #error: abort test + test.sendFeedback('Motor switched off (bit#4)', False) + return + if bool(MotorStatus & int('100000',2)): #error: abort test + test.sendFeedback('No motor link (bit#5)', False) + return + if bool(MotorStatus & int('1000000',2)): #error: abort test + test.sendFeedback('No poti link (bit#6)', False) + return + if bool(MotorStatus & int('10000000',2)): #error: abort test + test.sendFeedback('Calibration error (bit#7)', False) + return + if bool(MotorStatus & int('100000000',2)): #error: abort test + test.sendFeedback('Cannot get to R1 (bit#8)', False) + return + if bool(MotorStatus & int('1000000000',2)): #error: abort test + test.sendFeedback('Cannot get to R2 (bit#9)', False) + return + if bool(MotorStatus & int('10000000000',2)): #error: abort test + test.sendFeedback('Position measurement mismatch (bit#10)', False) + return + if bool(MotorStatus & int('100000000000',2)): #error: abort test + test.sendFeedback('Movement timeout (bit#11)', False) + return - detector2 = idMotorStep.get() - detector3 = idPotiPosFromBeam.get() - detector4 = idPotiPosition.get() - detector5 = idPotiRef1Position.get() - detector6 = idPotiRef2Position.get() - diff1 = detector2-detector4 - scan.append ([detector1], [detector1], [detector2, detector4, detector5, diff1]) - sleep( 0.1 ) # Settling time - timeElapsed=timeElapsed+1 - #Closing channels + idMotorStatus.close() + idLogicalPosition.close() + idPotiRaw.close() + idMotorPositionRaw.close() idCom.close() - idMotorStep.close() + idMotorPosition.close() idPotiPosFromBeam.close() idPotiPosition.close() idPotiRef1Position.close() idPotiRef2Position.close() - print_log(testName, DEVICE, ' Reference point reached') - + idDiameter.close() + idInkr.close() + idInkrRb.close() + scan.end() + + ret = 'Moved to R1' + success = True + scan.end() + ################ END OF YOUR CODE ################ -###### Final - DO NOT MODIFY THE CODE BELOW ###### - sendFeedback(testPath, testName, DEVICE, ret, success) +###### 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 - sendFeedback(testPath, testName, DEVICE, ret, success) - return + test.sendFeedback(ret, success) -#launch the test +# launch the test startTest(test, device, parameters) diff --git a/script/tests/tests/Collimator Tests pro/Move Ref 2/Move Ref 2.py b/script/tests/tests/Collimator Tests pro/Move Ref 2/Move Ref 2.py index 5942590..36fdf6a 100644 --- a/script/tests/tests/Collimator Tests pro/Move Ref 2/Move Ref 2.py +++ b/script/tests/tests/Collimator Tests pro/Move Ref 2/Move Ref 2.py @@ -1,95 +1,136 @@ +# Drive to R2 + ###### Init - 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) - log (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): + # by default, assume the test failed + ret = 'Test failed' + success = False + # plot name to be given to the scan. Use: scan.setPlotName(plotName) + plotName = DEVICE + ' - ' + testName + # put the whole custom code under try/catch 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. It can be sued in the following ways: + test = TestingTool(testName, testPath, DEVICE, params) + samplePeriod = 0.1 + ######### WRITE YOUR CODE HERE BELOW ############# - #get parameters from the calling interface - print_log(testName, DEVICE, 'testpath: ' + testPath ) - print_log(testName, DEVICE, 'parameters:' + str( params) ) - print_log(testName, DEVICE, 'device: ' + DEVICE ) - scan = ManualScan(['time'], ['idMotorStep', 'idPotiPosition', 'idPotiRef2Position','idMotorStep-idPotiPosition'] , [0.0], [30.0], [20]) + scan = ManualScan(['time [1/'+ str(1/samplePeriod) + ' s]'], ['Motor Status (STA:1)', 'Inkr (INKR:2)', 'InkrRb (INKRRB:2)', 'Diameter (DIAM:2)', 'Com (COM:2)', + 'Logical Position (IST:2)', 'Motor Pos Raw (IST3:1)','Motor Pos (IST3:2)', 'Poti Pos From Beam (IST1:2)', 'Poti Raw (POSA:1)', 'Poti Position (IST2:1)', + 'Poti Ref1 Position (REF1:1)', 'Poti Ref2 Position (REF2:1)']) scan.setPlotName(plotName) scan.start() - #Creating channels: dimension 1 try: - idCom = Channel(DEVICE+':COM:2', type = 'd') #current position as from motor step counter [mm] - idMotorStep = Channel(DEVICE+':IST3:2', type = 'd') #current position as from motor step counter [mm] - idPotiPosFromBeam = Channel(DEVICE+':IST1:2', type = 'd') #current position from beam as from potentiometer [mm] - idPotiPosition = Channel(DEVICE+':IST2:1', type = 'd') #current position as from potentiometer [mm] - idPotiRef1Position = Channel(DEVICE+':REF1:1', type = 'd') #R1 position as from potentiometer [mm] - idPotiRef2Position = Channel(DEVICE+':REF2:1', type = 'd') #R2 position as from potentiometer [mm] + idMotorStatus = Channel(DEVICE+':STA:1', type = 'd') # DSP device_status reg + idLogicalPosition = Channel(DEVICE+':IST:2', type = 'd') # Shows current position in logical units as calculated from motor step counter [1..n] + idPotiRaw = Channel(DEVICE+':POSA:1', type = 'd') # poti raw data [ADC units] + idMotorPositionRaw = Channel(DEVICE+':IST3:1', type = 'd') # shows current position in steps as as obtained from motor step counter [steps] + idInkr = Channel(DEVICE + ':INKR:2', type='d') # move relative distance (positive means towards R2) [mm] + idInkrRb = Channel(DEVICE + ':INKRRB:2', type='d') # readback of move relative distance (positive means towards R2) [mm] + idDiameter = Channel(DEVICE + ':DIAM:2', type='d') # collimator diameter [mm] + idCom = Channel(DEVICE + ':COM:2', type='d') # current position as from motor step counter [mm] + idMotorPosition = Channel(DEVICE + ':IST3:2', type='d') # current position as from motor step counter [mm] + idPotiPosFromBeam = Channel(DEVICE + ':IST1:2', type='d') # current position from beam as from potentiometer [mm] + idPotiPosition = Channel(DEVICE + ':IST2:1', type='d') # current position as from potentiometer [mm] + idPotiRef1Position = Channel(DEVICE + ':REF1:1', type='d') # R1 position as from potentiometer [mm] + idPotiRef2Position = Channel(DEVICE + ':REF2:1', type='d') # R2 position as from potentiometer [mm] + idCom.put('4', timeout=None) # go to R2 + sleep( samplePeriod ) # Settling time except: - sendFeedback(testPath, testName, DEVICE, 'Unable to create channel - ' + traceback.format_exc(), False) - #raise Exception('Unable to create channel - ' + traceback.format_exc()) + ret = 'Unable to create channel - ' + traceback.format_exc() + success = False + test.sendFeedback( ret, success) return - idCom.put(4.0, timeout=None) # go to R2 - print_log(testName, DEVICE, 'Moving to reference point') - #scan quickly the output during some seconds - detector4 = idPotiPosition.get() - detector5 = idPotiRef1Position.get() - timeElapsed=0 - while detector4 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): @@ -91,7 +91,7 @@ def startTest(testName, DEVICE, params): scan.append ([detector1], [detector1], [readback1, detector2, detector3]) sleep( 0.1 ) # Settling time ret = 'Test ps A completed' - status = True + success = True #reset output to 0V SetV.put(0.0, timeout=None) @@ -106,7 +106,7 @@ def startTest(testName, DEVICE, params): ######################################### ###### DO NOT MODIFY THE CODE BELOW ##### ######################################### - sendFeedback(testPath, testName, DEVICE, ret, status) + sendFeedback(testPath, testName, DEVICE, ret, success) #launch the test diff --git a/script/tests/tests/PS Tests/power-supply-A/power-supply-A - Copy.py b/script/tests/tests/PS Tests/power-supply-A/power-supply-A - Copy.py index 2981542..1a9bb16 100644 --- a/script/tests/tests/PS Tests/power-supply-A/power-supply-A - Copy.py +++ b/script/tests/tests/PS Tests/power-supply-A/power-supply-A - Copy.py @@ -26,7 +26,7 @@ def startTest(testName, DEVICE, params): testPath = inspect.getfile(inspect.currentframe()) #by default, failed ret = 'Test failed' - status = False + success = False #plot name to be given to the scan. Use: scan.setPlotName(plotName) plotName = DEVICE + ' - ' + testName ######################################### @@ -86,7 +86,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): @@ -100,7 +100,7 @@ def startTest(testName, DEVICE, params): scan.append ([detector1], [detector1], [readback1, detector2, detector3]) sleep( 0.1 ) # Settling time ret = 'Test ps A completed' - status = True + success = True #reset output to 0V SetV.put(0.0, timeout=None) @@ -115,7 +115,7 @@ def startTest(testName, DEVICE, params): ######################################### ###### DO NOT MODIFY THE CODE BELOW ##### ######################################### - sendFeedback(testPath, testName, DEVICE, ret, status) + sendFeedback(testPath, testName, DEVICE, ret, success) #launch the test diff --git a/script/tests/tests/PS Tests/test without ioc/test without ioc.py b/script/tests/tests/PS Tests/test without ioc/test without ioc.py index 582614b..c9ebf4d 100644 --- a/script/tests/tests/PS Tests/test without ioc/test without ioc.py +++ b/script/tests/tests/PS Tests/test without ioc/test without ioc.py @@ -8,7 +8,7 @@ import sys, inspect, os, traceback def startTest(testName, DEVICE, params): #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 #put the whole custom code under try/catch diff --git a/script/tests/tests/Range Shifter Tests/Check Status/.config b/script/tests/tests/Range Shifter Tests/Check Status/.config index 35dbf62..c84634c 100644 --- a/script/tests/tests/Range Shifter Tests/Check Status/.config +++ b/script/tests/tests/Range Shifter Tests/Check Status/.config @@ -1,3 +1,3 @@ name=Check Status -description=Checks the drive status +description=Checks the drive success filename=Check Status.xml diff --git a/script/tests/tests/Range Shifter Tests/Monitor All/.config b/script/tests/tests/Range Shifter Tests/Monitor All/.config index 3cfe38a..9e4a776 100644 --- a/script/tests/tests/Range Shifter Tests/Monitor All/.config +++ b/script/tests/tests/Range Shifter Tests/Monitor All/.config @@ -1,7 +1,7 @@ name=Monitor All -description=Monitor drive all status pv. No commands are sent +description=Monitor drive all success pv. No commands are sent #optional parameters. Description is compulsory. Syntax: #parameters=::[;::] -parameters=samplingTimeS:0.1:Sampling Time;timeWindowS:30:Duration of the monitoring time window (For how long the check status must be performed) [s] +parameters=samplingTimeS:0.1:Sampling Time;timeWindowS:30:Duration of the monitoring time window (For how long the check success must be performed) [s] 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 0324623..65cb18c 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 @@ -8,7 +8,7 @@ import sys, inspect, os, traceback def startTest(testName, DEVICE, params): #by default, failed ret = 'Test failed' - status = False + success = False #plot name to be given to the scan. Use: scan.setPlotName(plotName) plotName = DEVICE + ' - ' + testName try: