This commit is contained in:
boccioli_m
2015-07-01 09:19:02 +02:00
parent 86d98e0c2f
commit edcc5cb443
4 changed files with 222 additions and 447 deletions
@@ -4,4 +4,4 @@ description=Go to absolute position A, then move +B steps, then -2B steps, then
#optional parameters. Description is compulsory. Syntax:
#parameters=<parameter1Name>:<parameter1Value>:<Parameter 1 description>[;<parameter2Name>:<parameter2Value>:<Parameter 2 description>]
parameters=repeatTimes:1:Repeat N times;midPoint:41.0:Middle point A;spanFromMidPoint:5.0:B steps around middle point A
parameters=repeatTimes:1:Repeat N times;midPoint:41.0:Middle point A;spanFromMidPoint:2.0:B steps around middle point A
@@ -2,8 +2,98 @@
#ManualScan(writables, readables, start = None, end = None, steps = None, relative = False)
#by default, failed
def test(testPath, DEVICE, params):
scan = ManualScan(['time'], ['SetV', 'ActualV', 'ActualI'] , [0.0], [30.0], [20])
scan.setPlotName("A")
scan.start()
try:
#Creating channels: dimension 1
#Ramp rate
SetRamp = Channel(DEVICE + ':Set-RampA', type = 'd')
#SetRamp = Channel('pw84:ai', type = 'd')
#LinearPositioner SetV
SetV = Channel(DEVICE + ':Set-VA', type = 'd')
#SetV = Channel('pw84:ai', type = 'd')
#Timestamp time
#ScalarDetector ActualV
ActualV = Channel(DEVICE + ':Actual-VA', type = 'd')
#ActualV = Channel('pw84:ai', type = 'd')
#ScalarDetector ActualI
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())
#Init
SetRamp.put(10.0, timeout=None)
#set voltage to 0
print 'Ramping down power supply A to 0V'
SetV.put(0.0, timeout=None)
#wait up to 2 minutes for voltage to be ~0
for setpoint1 in frange(0.0, 120.0, 1.0, True):
detector2 = ActualV.get()
if detector2 <= 1.0:
break
sleep(0.5)
#Dimension 1
#LinearPositioner SetV
print 'Ramping up power supply'
for setpoint1 in frange(0.0, 20.0, 5.0, True):
if setpoint1 > 50.0 or setpoint1 < 0.0:
break
SetV.put(setpoint1, timeout=None) # TODO: Set appropriate timeout
readback1 = SetV.get()
if abs(readback1 - setpoint1) > 0.9 : # TODO: Check accuracy
raise Exception('SetV could not be set to the value ' + str(setpoint1))
ret = 'SetV could not be set to the value ' + str(setpoint1) + '(measured value: '+str(readback1)+')'
status = False
break
#scan quickly the output during some seconds
for setpoint2 in range(0, 20):
#Detector time
detector1 = float(java.lang.System.currentTimeMillis())
#Detector ActualV
detector2 = ActualV.get()
detector3 = ActualI.get()
#scan.append ([setpoint1], [readback1], [detector1, detector2])
#append(setpoints, positions, values)
scan.append ([detector1], [detector1], [readback1, detector2, detector3])
sleep( 0.1 ) # Settling time
ret = 'Test completed'
status = True
print 'Ramping test done'
#reset output to 0V
SetV.put(0.0, timeout=None)
#Closing channels
SetV.close()
ActualV.close()
ActualI.close()
scan.end()
sendFeedback( 'Ramping A test done', True)
#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
set_return(ret)
sys.exit()
import sys, inspect, os
testPath = inspect.getfile(inspect.currentframe()) # script filename (usually with path)
print 'testpath A: ' + testPath
ret = 'Test failed'
status = False
DEVICE = device
@@ -13,77 +103,5 @@ print params
print 'device:'
print DEVICE
scan = ManualScan(['time'], ['SetV', 'ActualV', 'ActualI'] , [0.0], [30.0], [20])
scan.setPlotName("A")
scan.start()
#Creating channels: dimension 1
#Ramp rate
SetRamp = Channel(DEVICE + ':Set-RampA', type = 'd')
#SetRamp = Channel('pw84:ai', type = 'd')
#LinearPositioner SetV
SetV = Channel(DEVICE + ':Set-VA', type = 'd')
#SetV = Channel('pw84:ai', type = 'd')
#Timestamp time
#ScalarDetector ActualV
ActualV = Channel(DEVICE + ':Actual-VA', type = 'd')
#ActualV = Channel('pw84:ai', type = 'd')
#ScalarDetector ActualI
ActualI = Channel(DEVICE + ':Actual-IA', type = 'd')
#ActualI = Channel('pw84:ai', type = 'd')
#Init
SetRamp.put(10.0, timeout=None)
#set voltage to 0
print 'Ramping down power supply A to 0V'
SetV.put(0.0, timeout=None)
#wait up to 2 minutes for voltage to be ~0
for setpoint1 in frange(0.0, 120.0, 1.0, True):
detector2 = ActualV.get()
if detector2 <= 1.0:
break
sleep(0.5)
#Dimension 1
#LinearPositioner SetV
print 'Ramping up power supply'
for setpoint1 in frange(0.0, 20.0, 5.0, True):
if setpoint1 > 50.0 or setpoint1 < 0.0:
break
SetV.put(setpoint1, timeout=None) # TODO: Set appropriate timeout
readback1 = SetV.get()
if abs(readback1 - setpoint1) > 0.9 : # TODO: Check accuracy
raise Exception('SetV could not be set to the value ' + str(setpoint1))
ret = 'SetV could not be set to the value ' + str(setpoint1) + '(measured value: '+str(readback1)+')'
status = False
break
#scan quickly the output during some seconds
for setpoint2 in range(0, 20):
#Detector time
detector1 = float(java.lang.System.currentTimeMillis())
#Detector ActualV
detector2 = ActualV.get()
detector3 = ActualI.get()
#scan.append ([setpoint1], [readback1], [detector1, detector2])
#append(setpoints, positions, values)
scan.append ([detector1], [detector1], [readback1, detector2, detector3])
sleep( 0.1 ) # Settling time
ret = 'Test completed'
status = True
print 'Ramping test done'
#reset output to 0V
SetV.put(0.0, timeout=None)
#Closing channels
SetV.close()
ActualV.close()
ActualI.close()
scan.end()
ret = [testPath, True, 'Ramping A test done']
set_return(ret)
test(testPath, DEVICE, params)
@@ -1,9 +1,88 @@
#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):
scan = ManualScan(['time'], ['SetVB', 'ActualVB', 'ActualIB'] , [0.0], [30.0], [20])
scan.setPlotName("B")
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')
#Init
SetRamp.put(10.0, timeout=None)
#set voltage to 0
print 'Ramping down power supply B to 0V'
SetVA.put(0.0, timeout=None)
#wait up to 2 minutes for voltage to be ~0
for setpoint1 in frange(0.0, 120.0, 1.0, True):
detector2 = ActualVA.get()
if detector2 <= 1.0:
break
sleep(0.5)
#Dimension 1
#LinearPositioner SetVA
print 'Ramping up power supply'
for setpoint1 in frange(0.0, 20.0, 5.0, True):
if setpoint1 > 50.0 or setpoint1 < 0.0:
break
SetVA.put(setpoint1, timeout=None) # TODO: Set appropriate timeout
readback1 = SetVA.get()
if abs(readback1 - setpoint1) > 0.9 : # TODO: Check accuracy
raise Exception('SetVB could not be set to the value ' + str(setpoint1))
ret = 'SetVB could not be set to the value ' + str(setpoint1) + '(measured value: '+str(readback1)+')'
status = False
break
#scan quickly the output during some seconds
for setpoint2 in range(0, 20):
#Detector time
detector1 = float(java.lang.System.currentTimeMillis())
#Detector ActualVA
detector2 = ActualVA.get()
detector3 = ActualIA.get()
#scan.append ([setpoint1], [readback1], [detector1, detector2])
#append(setpoints, positions, values)
scan.append ([detector1], [detector1], [readback1, detector2, detector3])
sleep( 0.1 ) # Settling time
ret = 'Test 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()
ret = [testPath, True, 'Ramping B test done']
print 'testpath B: ' + testPath
scan.end()
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
DEVICE = device
@@ -11,80 +90,7 @@ params = parameters
print 'parameters:'
print params
print 'device:'
print DEVICE
print DEVICE
#print os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) # script directory
scan = ManualScan(['time'], ['SetVB', 'ActualVB', 'ActualIB'] , [0.0], [30.0], [20])
scan.setPlotName("B")
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')
#Init
SetRamp.put(10.0, timeout=None)
#set voltage to 0
print 'Ramping down power supply B to 0V'
SetVA.put(0.0, timeout=None)
#wait up to 2 minutes for voltage to be ~0
for setpoint1 in frange(0.0, 120.0, 1.0, True):
detector2 = ActualVA.get()
if detector2 <= 1.0:
break
sleep(0.5)
#Dimension 1
#LinearPositioner SetVA
print 'Ramping up power supply'
for setpoint1 in frange(0.0, 20.0, 5.0, True):
if setpoint1 > 50.0 or setpoint1 < 0.0:
break
SetVA.put(setpoint1, timeout=None) # TODO: Set appropriate timeout
readback1 = SetVA.get()
if abs(readback1 - setpoint1) > 0.9 : # TODO: Check accuracy
raise Exception('SetVB could not be set to the value ' + str(setpoint1))
ret = 'SetVB could not be set to the value ' + str(setpoint1) + '(measured value: '+str(readback1)+')'
status = False
break
#scan quickly the output during some seconds
for setpoint2 in range(0, 20):
#Detector time
detector1 = float(java.lang.System.currentTimeMillis())
#Detector ActualVA
detector2 = ActualVA.get()
detector3 = ActualIA.get()
#scan.append ([setpoint1], [readback1], [detector1, detector2])
#append(setpoints, positions, values)
scan.append ([detector1], [detector1], [readback1, detector2, detector3])
sleep( 0.1 ) # Settling time
ret = 'Test 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()
ret = [testPath, True, 'Ramping B test done']
scan.end()
set_return(ret)
test(testPath, DEVICE, params)