Script execution

This commit is contained in:
boccioli_m
2015-06-17 16:54:25 +02:00
parent 820ddabfa9
commit 02460dee30

View File

@@ -1,6 +1,7 @@
#Script Motor Test 2
#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
import traceback
#by default, failed
@@ -14,43 +15,45 @@ scan.start()
#Creating channels: dimension 1
try:
##################### beginning of A######################
#RegionPositioner idInkr
#idInkr = Channel(DEVICE+':INKR:2', type = 'd')
idInkr = Channel(DEVICE+':MOTOR.VAL', type = 'd')
#idInkr = 0 #= Channel(DEVICE+':INKR:2', type = 'd')
idInkr = 0 #= Channel(DEVICE+':MOTOR.VAL', type = 'd')
#ScalarDetector idMotorStatus
#idMotorStatus = Channel(DEVICE+':STA:1', type = 'd')
idMotorStatus = Channel(DEVICE+':MOTOR.MSTA', type = 'd')
#idMotorStatus = 0 #= Channel(DEVICE+':STA:1', type = 'd')
idMotorStatus = 0 #= Channel(DEVICE+':MOTOR.MSTA', type = 'd')
#ScalarDetector idLogicalPosition
#idLogicalPosition = Channel(DEVICE+':IST:2', type = 'd')
idLogicalPosition = Channel(DEVICE+':MOTOR.RVAL', type = 'd')
#idLogicalPosition = 0 #= Channel(DEVICE+':IST:2', type = 'd')
idLogicalPosition = 0 #= Channel(DEVICE+':MOTOR.RVAL', type = 'd')
#ScalarDetector idDiameter
#idDiameter = Channel(DEVICE+':DIAM:2', type = 'd')
idDiameter = Channel(DEVICE+':ENCODERoff', type = 'd')
#idDiameter = 0 #= Channel(DEVICE+':DIAM:2', type = 'd')
idDiameter = 0 #= Channel(DEVICE+':ENCODERoff', type = 'd')
#ScalarDetector idMotorPosition
#idMotorPosition = Channel(DEVICE+':IST1:2', type = 'd')
idMotorPosition = Channel(DEVICE+':MOTOR.RBV', type = 'd')
#idMotorPosition = 0 #= Channel(DEVICE+':IST1:2', type = 'd')
idMotorPosition = 0 #= Channel(DEVICE+':MOTOR.RBV', type = 'd')
#ScalarDetector idPotiRaw
#idPotiRaw = Channel(DEVICE+':POSA:1', type = 'd')
idPotiRaw = Channel(DEVICE+':ENCODERraw', type = 'd')
#idPotiRaw = 0 #= Channel(DEVICE+':POSA:1', type = 'd')
idPotiRaw = 0 #= Channel(DEVICE+':ENCODERraw', type = 'd')
#ScalarDetector idPotiProc
#idPotiProc = Channel(DEVICE+':POSA:2', type = 'd')
idPotiProc = Channel(DEVICE+':ENCODER', type = 'd')
#idPotiProc = 0 #= Channel(DEVICE+':POSA:2', type = 'd')
idPotiProc = 0 #= Channel(DEVICE+':ENCODER', type = 'd')
#ScalarDetector idBtvsRaw
#idBtvsRaw = Channel(DEVICE+':IST3:1', type = 'd')
idBtvsRaw = Channel(DEVICE+':MOTOR.LLS', type = 'd')
#idBtvsRaw = 0 #= Channel(DEVICE+':IST3:1', type = 'd')
idBtvsRaw = 0 #= Channel(DEVICE+':MOTOR.LLS', type = 'd')
#ScalarDetector idBtvsProc
#idBtvsProc = Channel(DEVICE+':IST3:2', type = 'd')
idBtvsProc = Channel(DEVICE+':MOTOR.HLS', type = 'd')
#idBtvsProc = 0 #= Channel(DEVICE+':IST3:2', type = 'd')
idBtvsProc = 0 #= Channel(DEVICE+':MOTOR.HLS', type = 'd')
#ScalarDetector idEndSwitchL
#idBtvsRaw = Channel(DEVICE+':IST3:1', type = 'd')
idEndSwitchL = Channel(DEVICE+':MOTOR.LLS', type = 'd')
#idBtvsRaw = 0 #= Channel(DEVICE+':IST3:1', type = 'd')
idEndSwitchL = 0 #= Channel(DEVICE+':MOTOR.LLS', type = 'd')
#ScalarDetector idEndSwitchH
#idBtvsProc = Channel(DEVICE+':IST3:2', type = 'd')
idEndSwitchH = Channel(DEVICE+':MOTOR.HLS', type = 'd')
#idBtvsProc = 0 #= Channel(DEVICE+':IST3:2', type = 'd')
idEndSwitchH = 0 #= Channel(DEVICE+':MOTOR.HLS', type = 'd')
#high position limit
idLimitH = Channel(DEVICE+':MOTOR.HLM', type = 'd')
idLimitH = 0 #= Channel(DEVICE+':MOTOR.HLM', type = 'd')
#low position limit
idLimitL = Channel(DEVICE+':MOTOR.LLM', type = 'd')
idLimitL = 0 #= Channel(DEVICE+':MOTOR.LLM', type = 'd')
######################## end of A ####################
except:
print "Unexpected error:", sys.exc_info()[0]
ret = 'Unable to create channel - ' + traceback.format_exc()
@@ -63,91 +66,91 @@ idLimitH.put(999999.9, timeout=None)
idLimitL.put(-999999.9, timeout=None)
#Dimension 1
mid = 40
span = 10
direction = 1.0;
startDefault = -100.0
endDefault = 1000.0
startDefault = mid - span
endDefault = mid + span
end = endDefault
#find position at Low end switch: it will be the starting point of the test
idInkr.put(-100.0, timeout=None) # TODO: Set appropriate timeout
start = idInkr.get()+direction
#find position: it will be the mid point of the test
loopTimes = 3
################### beginning of B ##################
idInkr = mid #idInkr.put(mid, timeout=None)
start = idInkr #start = idInkr.get()+direction
################### end of B ##################
countSteps = 0
for setpoint1 in range(0, 3):
count = 0
for setpoint1 in range(0, loopTimes):
count = count + 1
sleep( 2 ) # Settling time
#RegionPositioner idInkr
for setpoint2 in frange(start, end, direction):
readback1 = setpoint1
sleep( 0.1 ) # Settling time
idInkr.put(setpoint2, timeout=None) # TODO: Set appropriate timeout
readback2 = idInkr.get()
if abs(readback2 - setpoint2) > 1 : # TODO: Check accuracy
################### beginning of C ##################
i idInkr = setpoint2 # idInkr.put(setpoint2, timeout=None) # TODO: Set appropriate timeout
sleep( 0.2 ) # Settling time
readback2 = idInkr # readback2 = idInkr.get()
################### end of C ##################
i 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
raise Exception(ret)
#Detector idMotorStatus
detector1 = idMotorStatus.get()
################### beginning of D ##################
detector1 = idMotorStatus
#Detector idLogicalPosition
detector2 = idLogicalPosition.get()
detector2 = idLogicalPosition
#Detector idDiameter
detector3 = idDiameter.get()
detector3 = idDiameter
#Detector idMotorPosition
detector4 = idMotorPosition.get()
detector4 = idMotorPosition
#Detector idPotiRaw
detector5 = idPotiRaw.get()
detector5 = idPotiRaw
#Detector idPotiProc
detector6 = idPotiProc.get()
detector6 = idPotiProc
#Detector idBtvsRaw
detector7 = idBtvsRaw.get()
detector7 = idBtvsRaw
#Detector idBtvsProc
detector8 = idBtvsProc.get()
detector8 = idBtvsProc
#end switches
endH = idEndSwitchH.get()
endL = idEndSwitchL.get()
endH = idEndSwitchH
endL = idEndSwitchL
################### end of D ##################
#Manipulation idDiff02
#Variable Mappings
a = detector4
b = detector8
count = setpoint1
idDiff02 = a-b
#Manipulation idDiff01
#Variable Mappings
a = detector4
b = detector6
count = setpoint1
idDiff01 = a-b
countSteps = countSteps + 1
scan.append ([countSteps], [countSteps], [detector1, detector2, detector3, detector4, detector5, detector6, detector7, detector8, idDiff02, idDiff01])
if endH>0.0 :
if endH>0.0 or readback2 >= end :
#invert direction and swap start with end of translation
end = startDefault
start = readback2 - direction
direction = -1.0
print 'End H switch, changing direction to ' + str(direction)
print 'End of span, changing direction to ' + str(direction)
break
if endL>0.0 :
if endL>0.0 or readback2 >= start:
#invert direction and swap start with end of translation
end = endDefault
start = readback2 - direction
direction = 1.0
print 'End L switch, changing direction to ' + str(direction)
print 'End of span, changing direction to ' + str(direction)
break
################### beginning of E ##################
#set limits back
idLimitH.put(145.0, timeout=None)
idLimitL.put(0.0, timeout=None)
#Closing channels
idInkr.close()
idMotorStatus.close()
idLogicalPosition.close()
idDiameter.close()
idMotorPosition.close()
idPotiRaw.close()
idPotiProc.close()
idBtvsRaw.close()
idBtvsProc.close()
################### end of E ##################
scan.end()
ret = 'Test done'
ret = 'Slide moved back and forth (' + str(count) + ' runs)'
status = True