This commit is contained in:
boccioli_m
2015-07-02 09:15:14 +02:00
parent edcc5cb443
commit e5355b7000
4 changed files with 320 additions and 267 deletions
@@ -1,11 +1,20 @@
#TODO: Set the diplay names of positioners and detectors
#ManualScan(writables, readables, start = None, end = None, steps = None, relative = False)
#by default, failed
def test(testPath, DEVICE, params):
###### DO NOT MODIFY THE CODE BELOW ######
def startTest(testName, DEVICE, params):
#get the path of this script
testPath = inspect.getfile(inspect.currentframe())
#by default, failed
ret = 'Test failed'
status = False
#plot name to be given to the scan. Use: scan.setPlotName(plotName)
plotName = DEVICE + ' - ' + testName
###### WRITE YOUR CODE HERE BELOW #######
print 'testpath A: ' + testPath
print 'parameters:'
print params
print 'device: ' + DEVICE
scan = ManualScan(['time'], ['SetV', 'ActualV', 'ActualI'] , [0.0], [30.0], [20])
scan.setPlotName("A")
scan.setPlotName(plotName)
scan.start()
try:
@@ -24,8 +33,9 @@ def test(testPath, DEVICE, params):
ActualI = Channel(DEVICE + ':Actual-IA', type = 'd')
#ActualI = Channel('pw84:ai', type = 'd')
except:
sendFeedback( 'Unable to create channel - ' + traceback.format_exc(), False)
#raise Exception('Unable to create channel - ' + traceback.format_exc())
sendFeedback(testPath, DEVICE, 'Unable to create channel - ' + traceback.format_exc(), False)
#raise Exception('Unable to create channel - ' + traceback.format_exc())
return
#Init
SetRamp.put(10.0, timeout=None)
@@ -43,7 +53,7 @@ def test(testPath, DEVICE, params):
#Dimension 1
#LinearPositioner SetV
print 'Ramping up power supply'
print 'Ramping up power supply A'
for setpoint1 in frange(0.0, 20.0, 5.0, True):
if setpoint1 > 50.0 or setpoint1 < 0.0:
break
@@ -65,11 +75,9 @@ def test(testPath, DEVICE, params):
#append(setpoints, positions, values)
scan.append ([detector1], [detector1], [readback1, detector2, detector3])
sleep( 0.1 ) # Settling time
ret = 'Test completed'
ret = 'Test ps A completed'
status = True
print 'Ramping test done'
#reset output to 0V
SetV.put(0.0, timeout=None)
#Closing channels
@@ -78,30 +86,31 @@ def test(testPath, DEVICE, params):
ActualI.close()
scan.end()
sendFeedback( 'Ramping A test done', True)
########## END OF YOUR CODE ###########
#ret = [testPath, True, 'Ramping A test done']
#print 'testpath A: ' + testPath
#set_return(ret)
def sendFeedback(returnString, testPassed):
ret = [testPath, testPassed, returnString]
print 'testpath A: ', testPath, returnString
###### DO NOT MODIFY THE CODE BELOW ######
sendFeedback(testPath, testName, DEVICE, ret, status)
#prepare and send feedback to calling tool
def sendFeedback(testPath, testName, DEVICE, returnString, testPassed):
print 'Test path: ' + testPath
print 'Test name: ' + testName
print 'Device: ' + DEVICE
print 'Test passed: ' + str(testPassed)
print 'Return string: ' + returnString
ret = [testPath, DEVICE, returnString, testPassed]
set_return(ret)
sys.exit()
def print_log(testName, DEVICE, text):
time.ctime()
now = time.strftime('%Y.%m.%d %H:%M:%S')
print now + ' ' + DEVICE + ' - ' + testName + ': ' + text
import sys, inspect, os
testPath = inspect.getfile(inspect.currentframe()) # script filename (usually with path)
print 'testpath A: ' + testPath
ret = 'Test failed'
status = False
import sys, inspect, os, traceback
#get test arguments
DEVICE = device
testName = test
params = parameters
print 'parameters:'
print params
print 'device:'
print DEVICE
test(testPath, DEVICE, params)
#launch the test
startTest(testName, DEVICE, params)
@@ -1,29 +1,41 @@
#TODO: Set the diplay names of positioners and detectors
#ManualScan(writables, readables, start = None, end = None, steps = None, relative = False)
def test(testPath, DEVICE, params):
###### DO NOT MODIFY THE CODE BELOW ######
def startTest(testName, DEVICE, params):
#get the path of this script
testPath = inspect.getfile(inspect.currentframe())
#by default, failed
ret = 'Test failed'
status = False
#plot name to be given to the scan. Use: scan.setPlotName(plotName)
plotName = DEVICE + ' - ' + testName
###### WRITE YOUR CODE HERE BELOW #######
print 'testpath B: ' + testPath
print 'parameters:'
print params
print 'device: ' + DEVICE
scan = ManualScan(['time'], ['SetVB', 'ActualVB', 'ActualIB'] , [0.0], [30.0], [20])
scan.setPlotName("B")
scan.setPlotName(plotName)
scan.start()
#Creating channels: dimension 1
#Ramp rate
SetRamp = Channel(DEVICE + ':Set-RampB', type = 'd')
#SetRamp = Channel('pw84:ai', type = 'd')
#LinearPositioner SetVA
SetVA = Channel(DEVICE + ':Set-VB', type = 'd')
#SetVA = Channel('pw84:ai', type = 'd')
#Timestamp time
#ScalarDetector ActualVA
ActualVA = Channel(DEVICE + ':Actual-VB', type = 'd')
#ActualVA = Channel('pw84:ai', type = 'd')
#ScalarDetector ActualIA
ActualIA = Channel(DEVICE + ':Actual-IB', type = 'd')
#ActualIA = Channel('pw84:ai', type = 'd')
try:
#Ramp rate
SetRamp = Channel(DEVICE + ':Set-RampB', type = 'd')
#SetRamp = Channel('pw84:ai', type = 'd')
#LinearPositioner SetVA
SetVA = Channel(DEVICE + ':Set-VB', type = 'd')
#SetVA = Channel('pw84:ai', type = 'd')
#Timestamp time
#ScalarDetector ActualVA
ActualVA = Channel(DEVICE + ':Actual-VB', type = 'd')
#ActualVA = Channel('pw84:ai', type = 'd')
#ScalarDetector ActualIA
ActualIA = Channel(DEVICE + ':Actual-IB', type = 'd')
#ActualIA = Channel('pw84:ai', type = 'd')
except:
sendFeedback(testPath, DEVICE, 'Unable to create channel - ' + traceback.format_exc(), False)
#raise Exception('Unable to create channel - ' + traceback.format_exc())
return
#Init
SetRamp.put(10.0, timeout=None)
@@ -62,35 +74,40 @@ def test(testPath, DEVICE, params):
#append(setpoints, positions, values)
scan.append ([detector1], [detector1], [readback1, detector2, detector3])
sleep( 0.1 ) # Settling time
ret = 'Test completed'
ret = 'Test ps B completed'
status = True
print 'Raming test done'
#reset output to 0V
SetVA.put(0.0, timeout=None)
#Closing channels
SetVA.close()
ActualVA.close()
ActualIA.close()
########## END OF YOUR CODE ###########
ret = [testPath, True, 'Ramping B test done']
print 'testpath B: ' + testPath
scan.end()
###### DO NOT MODIFY THE CODE BELOW ######
sendFeedback(testPath, testName, DEVICE, ret, status)
#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)
#by default, failed
import sys, inspect, os
testPath = inspect.getfile(inspect.currentframe()) # script filename (usually with path)
print 'testpath B: ' + testPath
ret = 'Test failed'
status = False
def print_log(testName, DEVICE, text):
time.ctime()
now = time.strftime('%Y.%m.%d %H:%M:%S')
print now + ' ' + DEVICE + ' - ' + testName + ': ' + text
import sys, inspect, os, traceback
#get test arguments
DEVICE = device
testName = test
params = parameters
print 'parameters:'
print params
print 'device:'
print DEVICE
#print os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) # script directory
test(testPath, DEVICE, params)
#launch the test
startTest(testName, DEVICE, params)