From ce5969b2b9dff1099b326afb4002fe1e0b35e078 Mon Sep 17 00:00:00 2001 From: boccioli_m Date: Tue, 15 Sep 2015 10:48:05 +0200 Subject: [PATCH] Improved/fixed Collimator Tests pro/Calibrate/Calibrate.py --- script/tests/devices/DMAF1/.config | 2 +- .../Calibrate/Calibrate.py | 77 +++++----- .../Drive Out/Drive Out.py | 76 +++++---- .../Monitor Movement - Copy.py | 94 ------------ .../Monitor Movement/Monitor Movement.py | 26 ++-- .../Motor Test 1/Motor Test 1.py | 64 ++++---- .../Motor Test 2/Motor Test 2.py | 68 ++++---- .../Motor Test 2/help.html | 15 ++ .../Motor Test 3/Motor Test 3.py | 68 ++++---- .../Move Ref 1/Move Ref 1.py | 76 +++++---- .../Move Ref 2/Move Ref 2.py | 76 +++++---- .../monitorAllParams/.config | 4 + .../monitorAllParams/help.html | 13 ++ .../monitorAllParams/monitorAllParams.py | 145 ++++++++++++++++++ 14 files changed, 462 insertions(+), 342 deletions(-) delete mode 100644 script/tests/tests/Collimator Tests pro/Monitor Movement/Monitor Movement - Copy.py create mode 100644 script/tests/tests/Collimator Tests pro/Motor Test 2/help.html create mode 100644 script/tests/tests/Collimator Tests pro/monitorAllParams/.config create mode 100644 script/tests/tests/Collimator Tests pro/monitorAllParams/help.html create mode 100644 script/tests/tests/Collimator Tests pro/monitorAllParams/monitorAllParams.py diff --git a/script/tests/devices/DMAF1/.config b/script/tests/devices/DMAF1/.config index c6cdc32..e5ad97b 100644 --- a/script/tests/devices/DMAF1/.config +++ b/script/tests/devices/DMAF1/.config @@ -1,3 +1,3 @@ -name=PROF02:DMAF1 +name=DMAF1 description=Collimators tests=Collimator Tests pro diff --git a/script/tests/tests/Collimator Tests pro/Calibrate/Calibrate.py b/script/tests/tests/Collimator Tests pro/Calibrate/Calibrate.py index ecdfb5b..ac5f1fa 100644 --- a/script/tests/tests/Collimator Tests pro/Calibrate/Calibrate.py +++ b/script/tests/tests/Collimator Tests pro/Calibrate/Calibrate.py @@ -18,59 +18,66 @@ def startTest(testName, DEVICE, params): samplePeriod = 0.1 ######### WRITE YOUR CODE HERE BELOW ############# - 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 = ManualScan(['time [1/'+ str(1/samplePeriod) + ' s]'], ['Motor Pos (IST3:2)', 'Poti Position (IST2:1)', + '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)','Poti Pos From Beam (IST1:2)', + 'Poti Raw (POSA: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] + 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) - sleep( samplePeriod ) # Settling time except: ret = 'Unable to create channel - ' + traceback.format_exc() success = False test.sendFeedback( ret, success) return + countDeviceInModeIdle = 0 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() + 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]) + scan.append([setpoint2], [setpoint2], + [MotorPosition, PotiPosition, MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, + MotorPositionRaw, PotiPosFromBeam, PotiRaw, PotiRef1Position, PotiRef2Position]) - if (MotorStatus & int('1',2))==0: #device finished calibration - break + if (MotorStatus & int('1',2))==0: #device finished calibration (bit#1) + #give the device some time before stating that it has really finished + countDeviceInModeIdle = countDeviceInModeIdle +1 + if countDeviceInModeIdle == 10: + break + else: + countDeviceInModeIdle = 0 #check if any error bit is raised if bool(MotorStatus & int('10000',2)): #error: abort test 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 027dd8a..72ca25e 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 @@ -20,26 +20,28 @@ def startTest(testName, DEVICE, params): samplePeriod = 0.1 ######### WRITE YOUR CODE HERE BELOW ############# - 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 = ManualScan(['time [1/'+ str(1/samplePeriod) + ' s]'], ['Motor Pos (IST3:2)', 'Poti Position (IST2:1)', + '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)','Poti Pos From Beam (IST1:2)', + 'Poti Raw (POSA: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] + 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) @@ -53,26 +55,32 @@ def startTest(testName, DEVICE, params): 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() + 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 + scan.append([setpoint2], [setpoint2], + [MotorPosition, PotiPosition, MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, + MotorPositionRaw, PotiPosFromBeam, PotiRaw, PotiRef1Position, PotiRef2Position]) + + if (MotorStatus & int('1',2))==0: #device finished calibration (bit#1) + #give the device some time before stating that it has really finished + countDeviceInModeIdle = countDeviceInModeIdle +1 + if countDeviceInModeIdle == 10: + break + else: + countDeviceInModeIdle = 0 #check if any error bit is raised if bool(MotorStatus & int('10000',2)): #error: abort test 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 deleted file mode 100644 index 1a8f90a..0000000 --- a/script/tests/tests/Collimator Tests pro/Monitor Movement/Monitor Movement - Copy.py +++ /dev/null @@ -1,94 +0,0 @@ - -###### DO NOT MODIFY THE CODE BELOW ###### -global print_log, sendFeedback, inspect, log, sys, inspect, os, traceback -import sys, inspect, os, traceback - -def startTest(testName, DEVICE, params): - #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 ####### - #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.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] - - except: - sendFeedback(testPath, testName, DEVICE, 'Unable to create channel - ' + traceback.format_exc(), False) - #raise Exception('Unable to create channel - ' + traceback.format_exc()) - return - - monitorTime=40 #seconds - print_log(testName, DEVICE, 'Monitoring movement for ' + str(monitorTime) + 's') - #scan quickly the output during some seconds - detector4 = idPotiPosition.get() - detector6 = idPotiRef2Position.get() - timeElapsed=0 - while timeElapsed<(monitorTime*10): - #Detector time - detector1 = float(java.lang.System.currentTimeMillis()) - - 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 - idCom.close() - idMotorStep.close() - idPotiPosFromBeam.close() - idPotiPosition.close() - idPotiRef1Position.close() - idPotiRef2Position.close() - print_log(testName, DEVICE, 'End of Monitoring') - ret = 'End of Monitoring' - success = True -########## END OF YOUR CODE ########### - -###### DO NOT MODIFY THE CODE BELOW ###### - sendFeedback(testPath, testName, DEVICE, ret, success) - -#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, 'Test path: ' + testPath) - print_log(testName, DEVICE, 'Test name: ' + testName ) - print_log(testName, DEVICE, 'Device: ' + DEVICE) - print_log(testName, DEVICE, 'Test passed: ' + str(testPassed)) - print_log(testName, DEVICE, 'Return string: ' + returnString) - ret = [testPath, DEVICE, returnString, testPassed] - set_return(ret) - -def print_log(testName, DEVICE, text): - time.ctime() - now = time.strftime('%Y.%m.%d %H:%M:%S') - print now + ' ' + DEVICE + ' - ' + testName + ': ' + text - log (now + ' ' + DEVICE + ' - ' + testName + ': ' + text ) - -#get test arguments -DEVICE = device -testName = test -params = parameters -#launch the test -startTest(testName, DEVICE, params) 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 5d73c14..34ae97b 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 @@ -25,6 +25,7 @@ def startTest(testName, DEVICE, params): #test.log( 'parameters:' + str( params) ) #test.log( 'device: ' + DEVICE ) monitorTime = float(test.getParam("monitorTime")) + samplePeriod = 0.05 #seconds except: ret = 'Could not retrieve testing parameters - ' + traceback.format_exc() success = False @@ -32,18 +33,19 @@ def startTest(testName, DEVICE, params): return #get parameters from the calling interface - scan = ManualScan(['time'], ['idMotorStep', 'idPotiPosition', 'idPotiRef1Position','idMotorStep-idPotiPosition'] ) + scan = ManualScan(['time [1/'+ str(1/samplePeriod) + ' s]'], + ['Motor Pos (IST3:2)', 'Poti Position (IST2:1)', 'Motor Pos - Poti Pos'] ) 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] + 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] except: test.sendFeedback( 'Unable to create channel - ' + traceback.format_exc(), False) @@ -60,19 +62,19 @@ def startTest(testName, DEVICE, params): #Detector time currentTime = float(java.lang.System.currentTimeMillis()) - motorStep = idMotorStep.get() + motorPosition = idMotorPosition.get() potiPosFromBeam = idPotiPosFromBeam.get() potiPosision = idPotiPosition.get() potiRef1Position = idPotiRef1Position.get() potiRef2Position = idPotiRef2Position.get() - diff1 = motorStep-potiPosision - scan.append ([currentTime], [currentTime], [motorStep, potiPosision, potiRef1Position, diff1]) - sleep( 0.1 ) # Settling time + diff1 = motorPosition-potiPosision + scan.append ([currentTime], [currentTime], [motorPosition, potiPosision, diff1]) + sleep( samplePeriod ) # Settling time timeElapsed=timeElapsed+1 #Closing channels idCom.close() - idMotorStep.close() + idMotorPosition.close() idPotiPosFromBeam.close() idPotiPosition.close() idPotiRef1Position.close() 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 ae6653f..4675f96 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 @@ -36,27 +36,29 @@ def startTest(testName, DEVICE, params): 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 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 = ManualScan(['time [1/'+ str(1/samplePeriod) + ' s]'], ['Motor Pos (IST3:2)', 'Poti Position (IST2:1)', + '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)','Poti Pos From Beam (IST1:2)', + 'Poti Raw (POSA: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 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] - 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] + 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] except: ret = 'Unable to create channel - ' + traceback.format_exc() success = False @@ -79,25 +81,25 @@ def startTest(testName, DEVICE, params): 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() + 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() idDiff01 = PotiPosition - MotorPosition scan.append([setpoint2], [setpoint2], - [MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, MotorStepRaw, MotorStep, - PotiPosFromBeam, PotiRaw, PotiPosition, PotiRef1Position, PotiRef2Position]) + [MotorPosition, PotiPosition, MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, + MotorPositionRaw, PotiPosFromBeam, PotiRaw, PotiRef1Position, PotiRef2Position]) p1.getSeries(count).appendData(currentTime, idDiff01) 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 a2a3217..1d8ce51 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 @@ -35,11 +35,11 @@ def startTest(testName, DEVICE, params): 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 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 = ManualScan(['time [1/'+ str(1/samplePeriod) + ' s]'], ['Motor Pos (IST3:2)', 'Poti Position (IST2:1)', + '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)','Poti Pos From Beam (IST1:2)', + 'Poti Raw (POSA:1)', 'Poti Ref1 Position (REF1:1)', 'Poti Ref2 Position (REF2:1)']) scan.setPlotName(plotName) scan.start() # coloured plot (one colour per scan) @@ -48,19 +48,19 @@ def startTest(testName, DEVICE, params): # 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] - 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] + 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] except: ret = 'Unable to create channel - ' + traceback.format_exc() success = False @@ -96,28 +96,28 @@ def startTest(testName, DEVICE, params): sleep(settlingTime) # Settling time readback2 = idInkr.get() - 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() + 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() idDiff01 = potiPosition - inkrRb # Manipulation idDiff02 # Variable Mappings idDiff02 = potiPosition - MotorPosition countSteps = countSteps + 1 - scan.append([countSteps], [countSteps], - [MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, MotorPositionRaw, MotorPosition, - PotiPosFromBeam, PotiRaw, PotiPosition, PotiRef1Position, PotiRef2Position]) + scan.append([setpoint2], [setpoint2], + [MotorPosition, PotiPosition, MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, + MotorPositionRaw, PotiPosFromBeam, PotiRaw, PotiRef1Position, PotiRef2Position]) p1.getSeries(count).appendData(setpoint2, idDiff01) p2.getSeries(count).appendData(setpoint2, idDiff02) if (direction > 0.0 and setpoint2 >= end - 1): diff --git a/script/tests/tests/Collimator Tests pro/Motor Test 2/help.html b/script/tests/tests/Collimator Tests pro/Motor Test 2/help.html new file mode 100644 index 0000000..a1c8bc0 --- /dev/null +++ b/script/tests/tests/Collimator Tests pro/Motor Test 2/help.html @@ -0,0 +1,15 @@ + + +

Short Description

+Oscillate around a specified position +

Details

+Go to absolute position A, then move +B steps, then -2B steps, then +2Bsteps (ie oscillate round centre position, logging after each movement); repeat N times +

Parameters

+repeatTimes Repeat the Initialisation N times
+midPoint Position A +spanFromMidPoint The B steps +

Contact

+Marco Boccioli + + + 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 4014ae5..b562311 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,7 +25,7 @@ def startTest(testName, DEVICE, params): test.log(params) loopTimes = int(test.getParam("repeatTimes")) direction = int(test.getParam("translation")) - settlingTime = 0.2 #seconds + samplePeriod = 0.2 #seconds except: test.log("Could not retrieve testing parameters: ", sys.exc_info()[0]) ret = 'Could not retrieve testing parameters - ' + traceback.format_exc() @@ -33,27 +33,29 @@ def startTest(testName, DEVICE, params): test.sendFeedback(ret, success) return - 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 = ManualScan(['time [1/'+ str(1/samplePeriod) + ' s]'], ['Motor Pos (IST3:2)', 'Poti Position (IST2:1)', + '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)','Poti Pos From Beam (IST1:2)', + 'Poti Raw (POSA: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] - 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] + 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] except: ret = 'Unable to create channel - ' + traceback.format_exc() success = False @@ -83,28 +85,28 @@ def startTest(testName, DEVICE, params): #go to an end reference for setpoint2 in frange(start, end, direction): idInkr.put(setpoint2, timeout=10) # TODO: Set appropriate timeout - sleep(settlingTime) # Settling time + sleep(samplePeriod) # Settling time readback2 = idInkr.get() - 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() + 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() idDiff01 = PotiPosition-MotorPosition countSteps = countSteps + 1 scan.append([setpoint2], [setpoint2], - [MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, MotorPositionRaw, MotorPosition, - PotiPosFromBeam, PotiRaw, PotiPosition, PotiRef1Position, PotiRef2Position]) + [MotorPosition, PotiPosition, MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, + MotorPositionRaw, PotiPosFromBeam, PotiRaw, PotiRef1Position, PotiRef2Position]) p1.getSeries(count).appendData(setpoint2, idDiff01) #extract Status bits 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 48497db..4e1a0cc 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 @@ -21,26 +21,28 @@ def startTest(testName, DEVICE, params): samplePeriod = 0.1 ######### WRITE YOUR CODE HERE BELOW ############# - 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 = ManualScan(['time [1/'+ str(1/samplePeriod) + ' s]'], ['Motor Pos (IST3:2)', 'Poti Position (IST2:1)', + '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)','Poti Pos From Beam (IST1:2)', + 'Poti Raw (POSA: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] + 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 @@ -54,26 +56,32 @@ def startTest(testName, DEVICE, params): 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() + 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 + scan.append([setpoint2], [setpoint2], + [MotorPosition, PotiPosition, MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, + MotorPositionRaw, PotiPosFromBeam, PotiRaw, PotiRef1Position, PotiRef2Position]) + + if (MotorStatus & int('1',2))==0: #device finished calibration (bit#1) + #give the device some time before stating that it has really finished + countDeviceInModeIdle = countDeviceInModeIdle +1 + if countDeviceInModeIdle == 10: + break + else: + countDeviceInModeIdle = 0 #check if any error bit is raised if bool(MotorStatus & int('10000',2)): #error: abort test 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 36fdf6a..b4b3898 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 @@ -21,26 +21,28 @@ def startTest(testName, DEVICE, params): samplePeriod = 0.1 ######### WRITE YOUR CODE HERE BELOW ############# - 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 = ManualScan(['time [1/'+ str(1/samplePeriod) + ' s]'], ['Motor Pos (IST3:2)', 'Poti Position (IST2:1)', + '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)','Poti Pos From Beam (IST1:2)', + 'Poti Raw (POSA: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] + 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 @@ -54,26 +56,32 @@ def startTest(testName, DEVICE, params): 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() + 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 + scan.append([setpoint2], [setpoint2], + [MotorPosition, PotiPosition, MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, + MotorPositionRaw, PotiPosFromBeam, PotiRaw, PotiRef1Position, PotiRef2Position]) + + if (MotorStatus & int('1',2))==0: #device finished calibration (bit#1) + #give the device some time before stating that it has really finished + countDeviceInModeIdle = countDeviceInModeIdle +1 + if countDeviceInModeIdle == 10: + break + else: + countDeviceInModeIdle = 0 #check if any error bit is raised if bool(MotorStatus & int('10000',2)): #error: abort test diff --git a/script/tests/tests/Collimator Tests pro/monitorAllParams/.config b/script/tests/tests/Collimator Tests pro/monitorAllParams/.config new file mode 100644 index 0000000..f4e4c0e --- /dev/null +++ b/script/tests/tests/Collimator Tests pro/monitorAllParams/.config @@ -0,0 +1,4 @@ +#Fri Sep 11 13:31:33 CEST 2015 +name=monitorAllParams +parameters=monitorTime\:0.1\:This is the parameter n.1 with unit [unit];samplingDelay\:30\:This is the parameter n.2 with unit [unit]; +description=d diff --git a/script/tests/tests/Collimator Tests pro/monitorAllParams/help.html b/script/tests/tests/Collimator Tests pro/monitorAllParams/help.html new file mode 100644 index 0000000..3043e89 --- /dev/null +++ b/script/tests/tests/Collimator Tests pro/monitorAllParams/help.html @@ -0,0 +1,13 @@ + + +

Description

+d +

Parameters

+monitorTime This is the parameter n.1 with unit [unit]
+samplingDelay This is the parameter n.2 with unit [unit]
+ +

Contact

+boccioli_m + + + diff --git a/script/tests/tests/Collimator Tests pro/monitorAllParams/monitorAllParams.py b/script/tests/tests/Collimator Tests pro/monitorAllParams/monitorAllParams.py new file mode 100644 index 0000000..b7576c6 --- /dev/null +++ b/script/tests/tests/Collimator Tests pro/monitorAllParams/monitorAllParams.py @@ -0,0 +1,145 @@ +# Test name: monitorAllParams +# d + +###### Init - DO NOT MODIFY THE CODE BELOW ###### +global sys, inspect, os, traceback +import sys, inspect, os, traceback + + +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: + # 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) + + ################ END OF Init ##################### + ######### WRITE YOUR CODE HERE BELOW ############# + + """ + All the code in this section ###..YOUR CODE..### can be modified/deleted. + It must be indented to the same level as this comment + ----------------------------------- + GETTING INPUTS: + If needed, the following variables are available: + testPath string, path of this test file + testName string, name of this test + DEVICE string, device for which the test must run (typically it is the beginning of a process variable name) + ----------------------------------- + GETTING TEST PARAMETERS: + if you need to get parameters for the test, use (casting may be necessary): + myParamValue = test.getParam('myParamName') + see the test config for the list of parameters specific to the test. + ----------------------------------- + SETTING OUTPUTS: + ret string, a text summarizing the result of the test. It must be set before the end of your code. + success bool, True = test successful. It must be set before the end of your code. + test.sendFeedback(ret,success) method that ends the testing script and gives the report to the calling application. + Examples: + + whenever the code must quit (i.e. after an error), you must end with: + ret = 'here is some info on what failed on the test' + success = false + test.sendFeedback(ret, success) + + whenever the code is finished successfully, you must end with: + ret = 'here is some info on the success of the test' + success = true + test.sendFeedback(ret, success) + ----------------------------------- + LOG INFO: + when some information must be shown on the log, use: + test.log('test to log') + """ + + ########## Example (can be removed) ###### + # print the list of parameters passed. If any error, stop and send feedback + test.log("Example - Test name: " + testName) + test.log("Example - Device name: " + DEVICE) + try: + test.log("Running test Initialise 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 + monitorTime = float(test.getParam('monitorTime')) ; samplingDelay = float(test.getParam('samplingDelay')) ; + except: + ret = 'Could not retrieve testing parameters - ' + traceback.format_exc() + success = False + test.sendFeedback(ret, success) + return + + # loop to read channels for a while and plot the channels values. + # initialise plot tab with 2 plots + scan = ManualScan(['sample'], ['Motor Status (MSTA)', 'Motor Position (VAL)']) + # set plot name(tab title) + scan.setPlotName(plotName) + # start plots. See further below how to add points to the plots + scan.start() + + # IMPORTANT: if the test failed, write the report into the variables ret and success. + # for example, write the following: + ret = "Example - Error, the test failed because...." + success = False + # set up connection to channels. "type" of data can be "d" (= double), "l" (= long) + try: + pv_motor_msta = Channel(DEVICE + ':MOTOR.MSTA', type='d') + pv_motor_val = Channel(DEVICE + ':MOTOR.VAL', type='d') + except: + # prepare return information: return text + ret = 'Unable to create channel - ' + traceback.format_exc() + # prepare return information: return success + success = False + # send return information + test.sendFeedback(ret, success) + return + # take 100 samples of the channels + for sample in range(0, 100): + readback1 = sample + sleep(0.1) # Settling time + # get value + motor_msta = pv_motor_msta.get() + # get value + motor_val = pv_motor_val.get() + # add values to plot + scan.append([sample], [readback1], [motor_msta, motor_val]) + + # Closing channels + pv_motor_msta.close() + pv_motor_val.close() + + # IMPORTANT: if the test was successful, write the report into the variables ret and success. + # for example, write the following: + ret = "Example - Test successful, here some detail: ..." + success = True + test.sendFeedback(ret, success) + # 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 ###### + + # just in case the feedback was forgotten + test.sendFeedback(ret, success) + except (KeyboardInterrupt): + # user stop error handler + ret = 'Test stopped by user.' + success = False + test.sendFeedback(ret, success) + except: + # generic error handler + ret = traceback.format_exc() + success = False + test.sendFeedback(ret, success) + + +# launch the test +startTest(test, device, parameters) + +################ END OF Final #################### +#### IF NEEDED, ADD YOUR FUNCTIONS HERE BELOW #### +# def yourCustomFunction: