Python script improvements
This commit is contained in:
@@ -162,6 +162,7 @@
|
||||
<Font name="Tahoma" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Contact person *"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Write here the user name of the person who can be contacted for any question concerning this test"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="txtTestName">
|
||||
@@ -225,7 +226,7 @@
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Tahoma" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Write a user name"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Write here the user name of the person who can be contacted for any question concerning this test"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
|
||||
@@ -135,6 +135,7 @@ public class NewTest extends javax.swing.JPanel {
|
||||
|
||||
lblContact.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
|
||||
lblContact.setText("Contact person *");
|
||||
lblContact.setToolTipText("Write here the user name of the person who can be contacted for any question concerning this test");
|
||||
|
||||
txtTestName.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
|
||||
txtTestName.setToolTipText("");
|
||||
@@ -156,7 +157,7 @@ public class NewTest extends javax.swing.JPanel {
|
||||
jScrollPane3.setViewportView(txtTestDescription);
|
||||
|
||||
txtContactName.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
|
||||
txtContactName.setToolTipText("Write a user name");
|
||||
txtContactName.setToolTipText("Write here the user name of the person who can be contacted for any question concerning this test");
|
||||
|
||||
jTableParams.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
|
||||
jTableParams.setModel(new javax.swing.table.DefaultTableModel(
|
||||
|
||||
@@ -9,26 +9,37 @@ global print_log, sendFeedback, sys, inspect, os, traceback
|
||||
import sys, inspect, os, traceback
|
||||
|
||||
class TestingTool:
|
||||
|
||||
"""
|
||||
Common tools for running the test
|
||||
"""
|
||||
|
||||
def __init__(self, testName, testPath, deviceName, testParams):
|
||||
"""
|
||||
Init class with test data
|
||||
"""
|
||||
self.deviceName = deviceName
|
||||
self.testName = testName
|
||||
self.testPath = testPath
|
||||
self.testParams = testParams
|
||||
|
||||
#get specific test parameter
|
||||
#paramName = the name of the parameter for which the value must be read
|
||||
|
||||
|
||||
def getParam(self, paramName):
|
||||
"""
|
||||
get specific test parameter
|
||||
paramName = the name of the parameter for which the value must be read
|
||||
"""
|
||||
try:
|
||||
return self.testParams[paramName]["value"]
|
||||
except:
|
||||
self.log('Could not retrieve testing parameter ' + paramName + ' - Details: ' + traceback.format_exc())
|
||||
return None
|
||||
|
||||
#print/log information
|
||||
#text = the string to be printed/logged
|
||||
|
||||
|
||||
def log(self, text):
|
||||
"""
|
||||
Print/log information
|
||||
text = the string to be printed/logged
|
||||
"""
|
||||
import time
|
||||
time.ctime()
|
||||
now = time.strftime('%Y.%m.%d %H:%M:%S')
|
||||
@@ -44,11 +55,14 @@ class TestingTool:
|
||||
except:
|
||||
#cannot write log
|
||||
print now + ' ' + self.deviceName + ' - ' + self.testName + ': ' + 'cannot write Log in Data'
|
||||
|
||||
#prepare and send feedback to calling tool
|
||||
# returnString = the string containing info on the test result
|
||||
# testPassed = true if the test was successful, false if test had a problem
|
||||
|
||||
|
||||
def sendFeedback(self, returnString, testPassed):
|
||||
"""
|
||||
Prepare and send feedback to calling tool
|
||||
returnString = the string containing info on the test result
|
||||
testPassed = true if the test was successful, false if test had a problem
|
||||
"""
|
||||
self.log('End of test. Result:')
|
||||
#self.log('Device: ' + self.deviceName)
|
||||
#self.log('Test name: ' + self.testName)
|
||||
|
||||
@@ -1,25 +1,29 @@
|
||||
#Test name: $testName
|
||||
#$testDescription
|
||||
# Test name: $testName
|
||||
# $testDescription
|
||||
|
||||
###### 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
|
||||
"""
|
||||
Main method running the test
|
||||
"""
|
||||
# by default, assume the test failed
|
||||
ret = 'Test failed'
|
||||
status = False
|
||||
#plot name to be given to the scan. Use: scan.setPlotName(plotName)
|
||||
# plot name to be given to the scan. Use: scan.setPlotName(plotName)
|
||||
plotName = DEVICE + ' - ' + testName
|
||||
#put the whole custom code under try/catch
|
||||
# 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:
|
||||
# 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 #############
|
||||
|
||||
################ END OF Init #####################
|
||||
######### WRITE YOUR CODE HERE BELOW #############
|
||||
|
||||
"""
|
||||
All the code in this section ###..YOUR CODE..### can be modified/deleted.
|
||||
@@ -56,89 +60,89 @@ def startTest(testName, DEVICE, params):
|
||||
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)
|
||||
# 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
|
||||
test.log(params)
|
||||
# If present, use the parameters here below for your test script. You might need to change the casting
|
||||
#$testParameters
|
||||
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)
|
||||
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
|
||||
# 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:
|
||||
|
||||
# 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)
|
||||
# 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')
|
||||
pv_motor_msta = Channel(DEVICE + ':MOTOR.MSTA', type='d')
|
||||
pv_motor_val = Channel(DEVICE + ':MOTOR.VAL', type='d')
|
||||
except:
|
||||
#prepare return information: return text
|
||||
# prepare return information: return text
|
||||
ret = 'Unable to create channel - ' + traceback.format_exc()
|
||||
#prepare return information: return success
|
||||
# prepare return information: return success
|
||||
success = False
|
||||
#send return information
|
||||
test.sendFeedback( ret, success)
|
||||
# send return information
|
||||
test.sendFeedback(ret, success)
|
||||
return
|
||||
#take 100 samples of the channels
|
||||
# take 100 samples of the channels
|
||||
for sample in range(0, 100):
|
||||
readback1 = sample
|
||||
sleep( 0.1 ) # Settling time
|
||||
#get value
|
||||
sleep(0.1) # Settling time
|
||||
# get value
|
||||
motor_msta = pv_motor_msta.get()
|
||||
#get value
|
||||
# get value
|
||||
motor_val = pv_motor_val.get()
|
||||
#add values to plot
|
||||
scan.append ([sample], [readback1], [motor_msta, motor_val] )
|
||||
# add values to plot
|
||||
scan.append([sample], [readback1], [motor_msta, motor_val])
|
||||
|
||||
#Closing channels
|
||||
# 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:
|
||||
|
||||
# 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.
|
||||
# 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
|
||||
|
||||
################ 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
|
||||
# user stop error handler
|
||||
ret = 'Test stopped by user.'
|
||||
success = False
|
||||
test.sendFeedback(ret, success)
|
||||
except:
|
||||
#generic error handler
|
||||
# generic error handler
|
||||
ret = traceback.format_exc()
|
||||
success = False
|
||||
test.sendFeedback(ret, success)
|
||||
|
||||
#launch the test
|
||||
|
||||
# launch the test
|
||||
startTest(test, device, parameters)
|
||||
|
||||
################ END OF Final ####################
|
||||
#### IF NEEDED, ADD YOUR FUNCTIONS HERE BELOW ####
|
||||
#def yourCustomFunction:
|
||||
# def yourCustomFunction:
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#Thu Aug 27 16:00:36 CEST 2015
|
||||
name=Monitor Movement
|
||||
description=Monitor the movements during the specified time interval. No commands are sent.
|
||||
parameters=monitorTime\:40\:Monitor time interval [s];
|
||||
|
||||
|
||||
#optional parameters. Description is compulsory. Syntax:
|
||||
#parameters=<parameter1Name>:<parameter1Value>:<Parameter 1 description>[;<parameter2Name>:<parameter2Value>:<Parameter 2 description>]
|
||||
parameters=monitorTime\:30\:How long the monitoring is performed [s];samplingDelay\:0.1\:Delay between each sample is taken [s];
|
||||
|
||||
@@ -1,96 +1,115 @@
|
||||
|
||||
###### 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
|
||||
#init the testing tool class. It can be sued in the following ways:
|
||||
test = TestingTool(testName, testPath, DEVICE, params)
|
||||
|
||||
######### 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]
|
||||
|
||||
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'))
|
||||
except:
|
||||
sendFeedback(testPath, testName, DEVICE, 'Unable to create channel - ' + traceback.format_exc(), False)
|
||||
#raise Exception('Unable to create channel - ' + traceback.format_exc())
|
||||
ret = 'Could not retrieve testing parameters - ' + traceback.format_exc()
|
||||
success = False
|
||||
test.sendFeedback( ret, success)
|
||||
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())
|
||||
#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.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]
|
||||
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)
|
||||
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
|
||||
test.log( 'Monitoring movement for ' + str(monitorTime) + 's')
|
||||
#scan quickly the output during some seconds
|
||||
timeElapsed=0
|
||||
monitoringTimeWindow = monitorTime*int(1.0/samplingDelay)
|
||||
while timeElapsed<monitoringTimeWindow:
|
||||
#Detector time
|
||||
timestamp = float(java.lang.System.currentTimeMillis())
|
||||
|
||||
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()
|
||||
|
||||
|
||||
diff1 = MotorStep-PotiPosition
|
||||
scan.append([timestamp], [timestamp],
|
||||
[MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, MotorStepRaw, MotorStep,
|
||||
PotiPosFromBeam, PotiRaw, PotiPosition, PotiRef1Position, PotiRef2Position])
|
||||
sleep(samplingDelay) # Settling time
|
||||
timeElapsed=timeElapsed+1
|
||||
|
||||
#Closing channels
|
||||
idMotorStatus.close()
|
||||
idLogicalPosition.close()
|
||||
idPotiRaw.close()
|
||||
idMotorStepRaw.close()
|
||||
idCom.close()
|
||||
idMotorStep.close()
|
||||
idPotiPosFromBeam.close()
|
||||
idPotiPosition.close()
|
||||
idPotiRef1Position.close()
|
||||
idPotiRef2Position.close()
|
||||
print_log(testName, DEVICE, 'End of Monitoring')
|
||||
idDiameter.close()
|
||||
idInkr.close()
|
||||
idInkrRb.close()
|
||||
test.log( 'End of Monitoring')
|
||||
ret = 'End of Monitoring'
|
||||
status = True
|
||||
success = True
|
||||
|
||||
################ 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
|
||||
startTest(test, device, parameters)
|
||||
|
||||
startTest(test, device, parameters)
|
||||
@@ -1,11 +1,10 @@
|
||||
<html>
|
||||
<body>
|
||||
<h2>Short Description</h2>
|
||||
Monitor movements.
|
||||
<h2>Details</h2>
|
||||
<h2>Description</h2>
|
||||
Monitor the movements during the specified time interval. No commands are sent.
|
||||
<h2>Parameters</h2>
|
||||
<code>monitorTime</code> Monitoring time interval [s]
|
||||
<code>monitorTime</code> Monitoring time interval [s] <br/>
|
||||
<code>samplingDelay </code>Delay between each sample is taken [s]
|
||||
<h2>Contact</h2>
|
||||
<a href="https://intranet.psi.ch/Main/MarcoBoccioli">Marco Boccioli </a>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
name=Motor Test 1
|
||||
description=Moves to CW switch then CCW switch N times.
|
||||
|
||||
|
||||
#optional parameters. Description is compulsory. Syntax:
|
||||
#parameters=<parameter1Name>:<parameter1Value>:<Parameter 1 description>[;<parameter2Name>:<parameter2Value>:<Parameter 2 description>]
|
||||
parameters=repeatTimes:1:Repeat N times;delayS:5:Pause delay [s]
|
||||
@@ -0,0 +1,147 @@
|
||||
# Script Motor Test 1
|
||||
# Moves to CCW switch; then for M times moves N times to CW switch then CCW switch; between each M pauses for delay; log at CCW and CW
|
||||
|
||||
|
||||
###### 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'
|
||||
status = 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)
|
||||
|
||||
######### 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(params)
|
||||
loopTimes = int(test.getParam("repeatTimes"))
|
||||
delaySeconds = int(test.getParam("delayS"))
|
||||
except:
|
||||
ret = 'Could not retrieve testing parameters - ' + traceback.format_exc()
|
||||
success = False
|
||||
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)',
|
||||
'Poti Ref1 Position (REF1:1)', 'Poti Ref2 Position (REF2:1)'])
|
||||
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]
|
||||
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:
|
||||
ret = 'Unable to create channel - ' + traceback.format_exc()
|
||||
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
|
||||
setpoint2 = end
|
||||
count = 0
|
||||
test.log('Starting test sequence')
|
||||
for setpoint1 in range(0, loopTimes * 2):
|
||||
sleep(delaySeconds) # Settling time
|
||||
# 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])
|
||||
|
||||
# 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()
|
||||
idPotiPosFromBeam.close()
|
||||
idPotiPosition.close()
|
||||
idPotiRef1Position.close()
|
||||
idPotiRef2Position.close()
|
||||
idDiameter.close()
|
||||
idInkr.close()
|
||||
idInkrRb.close()
|
||||
|
||||
scan.end()
|
||||
ret = 'Slide moved back and forth (' + str(count) + ' runs)'
|
||||
success = True
|
||||
|
||||
################ 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
|
||||
test.sendFeedback(ret, success)
|
||||
|
||||
|
||||
# launch the test
|
||||
startTest(test, device, parameters)
|
||||
@@ -0,0 +1,14 @@
|
||||
<html>
|
||||
<body>
|
||||
<h2>Short Description</h2>
|
||||
Moves to CW switch then CCW switch N times.
|
||||
<h2>Details</h2>
|
||||
Moves to CW switch then CCW switch N times.
|
||||
<h2>Parameters</h2>
|
||||
<code>repeatTimes</code> Repeat the moving N times<br/>
|
||||
<code>delayS</code> Pause delay between each repetition [s]
|
||||
<h2>Contact</h2>
|
||||
<a href="https://intranet.psi.ch/Main/MarcoBoccioli">Marco Boccioli </a>
|
||||
</html>
|
||||
</body>
|
||||
|
||||
@@ -1,158 +1,177 @@
|
||||
#Script Motor Test 2 for production system
|
||||
#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
|
||||
# Script Motor Test 2 for production system
|
||||
# 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
|
||||
|
||||
###### 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
|
||||
# by default, assume the test failed
|
||||
ret = 'Test failed'
|
||||
status = False
|
||||
#plot name to be given to the scan. Use: scan.setPlotName(plotName)
|
||||
# plot name to be given to the scan. Use: scan.setPlotName(plotName)
|
||||
plotName = DEVICE + ' - ' + testName
|
||||
#put the whole custom code under try/catch
|
||||
# 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:
|
||||
# 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)
|
||||
|
||||
######### WRITE YOUR CODE HERE BELOW #############
|
||||
|
||||
#get parameters from the calling interface
|
||||
######### 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 Motor Test 2 for device " + DEVICE + " with the following parameters:\n" + str(params))
|
||||
middle = float(test.getParam("midPoint"))
|
||||
loopTimes = int(test.getParam("repeatTimes"))
|
||||
span = float(test.getParam("spanFromMidPoint"))
|
||||
except:
|
||||
ret = 'Could not retrieve testing parameters - ' + traceback.format_exc()
|
||||
success = False
|
||||
test.sendFeedback( ret, status)
|
||||
test.sendFeedback(ret, status)
|
||||
return
|
||||
|
||||
#scan = ManualScan(['idX', 'idInkr'], ['idMotorStatus', 'idLogicalPosition', 'idDiameter', 'idPotiPosFromBeam', 'idPotiRaw', 'idPotiProc', 'idBtvsRaw', 'idMotorStep', 'idDiff01', 'idDiff02'] , [-0.5, 0.0], [4.0, 3000.0], [3000, 20])
|
||||
#scan = ManualScan(['idX'], ['idMotorStatus', 'idLogicalPosition', 'idDiameter', 'idPotiPosFromBeam', 'idPotiRaw', 'idPotiProc', 'idBtvsRaw', 'idMotorStep', 'idDiff01', 'idDiff02'] , [ 0.0], [ 3000.0], [20])
|
||||
scan = ManualScan(['idX'], ['idInkr', 'idInkrRb', 'idMotorStep', 'idPotiPosFromBeam', 'idPotiPosition', 'idPotiRef1Position', 'idPotiRef2Position', 'idDiameter', 'idPotiPosition-idInkrRb', 'idPortPosition-idMotorStep'] )
|
||||
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)',
|
||||
'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]
|
||||
|
||||
#Creating channels: dimension 1
|
||||
# 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]
|
||||
|
||||
# Creating channels: dimension 1
|
||||
try:
|
||||
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]
|
||||
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]
|
||||
idDiameter = Channel(DEVICE+':DIAM:2', type = 'd') #collimator diameter [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]
|
||||
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]
|
||||
except:
|
||||
ret = 'Unable to create channel - ' + traceback.format_exc()
|
||||
success = False
|
||||
test.sendFeedback( ret, status)
|
||||
test.sendFeedback(ret, status)
|
||||
return
|
||||
|
||||
direction = 1.0
|
||||
startDefault = middle - span
|
||||
startDefault = middle - span
|
||||
endDefault = middle + span
|
||||
end = endDefault+1
|
||||
#find position: it will be the middle point of the test
|
||||
test.log( 'Moving to middle point ' + str(middle) )
|
||||
idInkr.put(middle, timeout=None) # TODO: Set appropriate timeout
|
||||
end = endDefault + 1
|
||||
# find position: it will be the middle point of the test
|
||||
test.log('Moving to middle point ' + str(middle))
|
||||
idInkr.put(middle, timeout=None) # TODO: Set appropriate timeout
|
||||
readback2 = idInkr.get()
|
||||
if abs(readback2 - middle) > 5 : # TODO: Check accuracy
|
||||
ret = 'Actor idInkr could not be set to the value ' + str(middle) + ' (current value: ' + str(readback2) + ')'
|
||||
if abs(readback2 - middle) > 5: # TODO: Check accuracy
|
||||
ret = 'Actor idInkr could not be set to the value ' + str(middle) + ' (current value: ' + str(
|
||||
readback2) + ')'
|
||||
success = False
|
||||
test.sendFeedback( ret, status)
|
||||
return
|
||||
start = readback2+direction
|
||||
test.sendFeedback(ret, status)
|
||||
return
|
||||
start = readback2 + direction
|
||||
countSteps = 0
|
||||
count = 0
|
||||
test.log( 'Moving around middle point (+-' + str(span) + ')' )
|
||||
for setpoint1 in range(0, loopTimes*2):
|
||||
test.log('Moving around middle point (+-' + str(span) + ')')
|
||||
for setpoint1 in range(0, loopTimes * 2):
|
||||
count = count + 1
|
||||
sleep( 5 ) # Settling time
|
||||
p1.addSeries(LinePlotSeries("Run"+str(count)))
|
||||
#RegionPositioner idInkr
|
||||
sleep(5) # Settling time
|
||||
p1.addSeries(LinePlotSeries("Run" + str(count)))
|
||||
# RegionPositioner idInkr
|
||||
for setpoint2 in frange(start, end, direction):
|
||||
readback1 = setpoint1
|
||||
idInkr.put(setpoint2, timeout=None) # TODO: Set appropriate timeout
|
||||
sleep( 0.2 ) # Settling time
|
||||
idInkr.put(setpoint2, timeout=None) # TODO: Set appropriate timeout
|
||||
sleep(0.2) # 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) + ')'
|
||||
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)
|
||||
test.sendFeedback(ret, status)
|
||||
return
|
||||
#Detector idMotorStatus
|
||||
inkrRb = idInkrRb.get()
|
||||
#Detector idLogicalPosition
|
||||
motorStep = idMotorStep.get()
|
||||
#Detector idDiameter
|
||||
potiPosFromBeam = idPotiPosFromBeam.get()
|
||||
#Detector idPotiPosFromBeam
|
||||
potiPosition = idPotiPosition.get()
|
||||
#Detector idPotiRaw
|
||||
potiRef1Position = idPotiRef1Position.get()
|
||||
#Detector idPotiProc
|
||||
potiRef2Position = idPotiRef2Position.get()
|
||||
#Detector idBtvsRaw
|
||||
diameter = idDiameter.get()
|
||||
#Manipulation idDiff01
|
||||
#Variable Mappings
|
||||
idDiff01 = potiPosition-inkrRb
|
||||
#Manipulation idDiff02
|
||||
#Variable Mappings
|
||||
idDiff02 = potiPosition-motorStep
|
||||
|
||||
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()
|
||||
|
||||
idDiff01 = potiPosition - inkrRb
|
||||
# Manipulation idDiff02
|
||||
# Variable Mappings
|
||||
idDiff02 = potiPosition - motorStep
|
||||
countSteps = countSteps + 1
|
||||
scan.append ([countSteps], [countSteps], [inkrRb, motorStep, potiPosFromBeam, potiPosition, potiRef1Position, potiRef2Position, diameter, detector8, idDiff02, idDiff01])
|
||||
p1.getSeries(count).appendData(setpoint2, idDiff01)
|
||||
p2.getSeries(count).appendData(setpoint2, idDiff02)
|
||||
if (direction > 0.0 and setpoint2 >= end -1):
|
||||
#invert direction and swap start with end of translation
|
||||
end = startDefault-1
|
||||
scan.append([countSteps], [countSteps],
|
||||
[MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, MotorStepRaw, MotorStep,
|
||||
PotiPosFromBeam, PotiRaw, PotiPosition, PotiRef1Position, PotiRef2Position])
|
||||
p1.getSeries(count).appendData(setpoint2, idDiff01)
|
||||
p2.getSeries(count).appendData(setpoint2, idDiff02)
|
||||
if (direction > 0.0 and setpoint2 >= end - 1):
|
||||
# invert direction and swap start with end of translation
|
||||
end = startDefault - 1
|
||||
start = setpoint2 - direction
|
||||
direction = -1.0
|
||||
test.log( 'End of span (' + str(setpoint2) + '), changing direction to ' + str(direction) )
|
||||
test.log('End of span (' + str(setpoint2) + '), changing direction to ' + str(direction))
|
||||
break
|
||||
if ( direction < 0.0 and setpoint2 <= end +1):
|
||||
#invert direction and swap start with end of translation
|
||||
end = endDefault+1
|
||||
if (direction < 0.0 and setpoint2 <= end + 1):
|
||||
# invert direction and swap start with end of translation
|
||||
end = endDefault + 1
|
||||
start = setpoint2 - direction
|
||||
direction = 1.0
|
||||
test.log( 'End of span (' + str(setpoint2) + '), changing direction to ' + str(direction) )
|
||||
test.log('End of span (' + str(setpoint2) + '), changing direction to ' + str(direction))
|
||||
break
|
||||
|
||||
|
||||
#Closing channels
|
||||
idInkr.close()
|
||||
idInkrRb.close()
|
||||
# Closing channels
|
||||
idMotorStatus.close()
|
||||
idLogicalPosition.close()
|
||||
idPotiRaw.close()
|
||||
idMotorStepRaw.close()
|
||||
idCom.close()
|
||||
idMotorStep.close()
|
||||
idPotiPosFromBeam.close()
|
||||
idPotiPosition.close()
|
||||
idPotiRef1Position.close()
|
||||
idPotiRef2Position.close()
|
||||
idDiameter.close()
|
||||
|
||||
idInkr.close()
|
||||
idInkrRb.close()
|
||||
|
||||
scan.end()
|
||||
ret = 'Slide moved back and forth (' + str(count) + ' runs)'
|
||||
status = True
|
||||
|
||||
################ END OF YOUR CODE ################
|
||||
###### Final - DO NOT MODIFY THE CODE BELOW ######
|
||||
|
||||
#just in case the feedback was forgotten
|
||||
|
||||
################ 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
|
||||
# generic error handler
|
||||
ret = traceback.format_exc()
|
||||
success = False
|
||||
test.sendFeedback(ret, success)
|
||||
|
||||
#launch the test
|
||||
startTest(test, device, parameters)
|
||||
|
||||
# launch the test
|
||||
startTest(test, device, parameters)
|
||||
|
||||
@@ -0,0 +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=<parameter1Name>:<parameter1Value>:<Parameter 1 description>[;<parameter2Name>:<parameter2Value>:<Parameter 2 description>]
|
||||
parameters=repeatTimes:1:Repeat N times;translation:2:Translation C steps
|
||||
@@ -0,0 +1,165 @@
|
||||
#Script Motor Test 3
|
||||
#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
|
||||
|
||||
###### 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)
|
||||
|
||||
######### WRITE YOUR CODE HERE BELOW #############
|
||||
#get parameters from the calling interface
|
||||
try:
|
||||
test.log("Running test Motor Test 3 with the following parameters:")
|
||||
test.log(params)
|
||||
loopTimes = int(test.getParam("repeatTimes"))
|
||||
direction = int(test.getParam("translation"))
|
||||
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)
|
||||
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)',
|
||||
'Poti Ref1 Position (REF1:1)', 'Poti Ref2 Position (REF2:1)'])
|
||||
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]
|
||||
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:
|
||||
ret = 'Unable to create channel - ' + traceback.format_exc()
|
||||
success = False
|
||||
test.sendFeedback( ret, success)
|
||||
return
|
||||
|
||||
#remove limits
|
||||
#idLimitH.put(999999.9, timeout=None)
|
||||
#idLimitL.put(-999999.9, timeout=None)
|
||||
|
||||
if direction == 0.0 :
|
||||
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=10) # TODO: Set appropriate timeout
|
||||
start = idInkr.get()+direction
|
||||
countSteps = 0
|
||||
test.log('Starting testing sequence')
|
||||
count = 0
|
||||
for setpoint1 in range(0, loopTimes*2):
|
||||
count = count + 1
|
||||
sleep( 2 ) # Settling time
|
||||
#RegionPositioner idInkr
|
||||
for setpoint2 in frange(start, end, direction):
|
||||
readback1 = setpoint1
|
||||
idInkr.put(setpoint2, timeout=10) # TODO: Set appropriate timeout
|
||||
sleep( 0.2 ) # Settling time
|
||||
readback2 = idInkr.get()
|
||||
|
||||
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()
|
||||
|
||||
#Manipulation idDiff02
|
||||
#Variable Mappings
|
||||
a = detector4
|
||||
b = detector8
|
||||
idDiff02 = a-b
|
||||
#Manipulation idDiff01
|
||||
#Variable Mappings
|
||||
a = detector4
|
||||
b = detector6
|
||||
idDiff01 = a-b
|
||||
countSteps = countSteps + 1
|
||||
scan.append([setpoint2], [setpoint2],
|
||||
[MotorStatus, Inkr, InkrRb, Diameter, Com, LogicalPosition, MotorStepRaw, MotorStep,
|
||||
PotiPosFromBeam, PotiRaw, PotiPosition, PotiRef1Position, PotiRef2Position])
|
||||
if endH>0.0 :
|
||||
#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))
|
||||
break
|
||||
if endL>0.0 :
|
||||
#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))
|
||||
break
|
||||
|
||||
#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()
|
||||
idPotiPosFromBeam.close()
|
||||
idPotiPosition.close()
|
||||
idPotiRef1Position.close()
|
||||
idPotiRef2Position.close()
|
||||
idDiameter.close()
|
||||
idInkr.close()
|
||||
idInkrRb.close()
|
||||
|
||||
scan.end()
|
||||
ret = 'Slide moved back and forth (' + str(count) + ' runs)'
|
||||
success = True
|
||||
|
||||
################ 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
|
||||
test.sendFeedback(ret, success)
|
||||
|
||||
#launch the test
|
||||
startTest(test, device, parameters)
|
||||
@@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<body>
|
||||
<h2>Description</h2>
|
||||
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
|
||||
<h2>Parameters</h2>
|
||||
<code>repeatTimes </code>How many N times the test is repeated<br/>
|
||||
<code>translation </code>How many C steps are done for one translation<br/>
|
||||
|
||||
<h2>Contact</h2>
|
||||
<a href="https://intranet.psi.ch/search/#?t=phonebook&q=boccioli_m">boccioli_m</a>
|
||||
</html>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user