Closedown

This commit is contained in:
boccioli_m
2015-08-04 14:39:16 +02:00
parent fd4179f803
commit 6c492ef270
6 changed files with 178 additions and 7 deletions
@@ -0,0 +1,8 @@
name=Initialise
description=Initialises the motor
help = \
This test sends a INIT command to the device, as many times as configured with the parameter RepeatTimes.
#optional parameters. Description is compulsory. Syntax:
#parameters=<parameter1Name>:<parameter1Value>:<Parameter 1 description>[;<parameter2Name>:<parameter2Value>:<Parameter 2 description>]
parameters=repeatTimes:1:Repeat N times;delayS:4:Delay between each initialisation [s]
@@ -0,0 +1,149 @@
###### DO NOT MODIFY THE CODE BELOW ######
global print_log, sendFeedback, inspect
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)
#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):
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
###### WRITE YOUR CODE HERE BELOW #######
#Pre-actions
# try:
# caput(DEVICE+':INIT.PROC', '1')
# except:
# ret = 'Unable to create channel - ' + traceback.format_exc()
# success = False
# sendFeedback(testPath, testName, DEVICE, ret, success)
# return
#get parameters from the calling interface
try:
print_log(testName, DEVICE, "Running test Initialise with the following parameters:")
print_log(testName, DEVICE, params )
loopTimes = int(params["repeatTimes"]["value"])
delaySeconds = int(params["delayS"]["value"])
except:
ret = 'Could not retrieve testing parameters - ' + traceback.format_exc()
success = False
sendFeedback(testPath, testName, DEVICE, ret, success)
return
scan = ManualScan(['idX'], ['idMotorPosition', 'idPotiProc', 'idBtvsProc', 'idDiff01', 'idDiff02'] )
scan.setPlotName(plotName)
scan.start()
#Creating channels: dimension 1
try:
idInit = Channel(DEVICE+':INIT.PROC', type = 'l')
idReady = Channel(DEVICE+':RDY', type = 'l')
idInterlock = Channel(DEVICE+':ILK', type = 'l')
#ScalarDetector idMotorPosition
#idMotorPosition = Channel(DEVICE+':IST1:2', type = 'd')
idMotorPosition = Channel(DEVICE+':MOTOR.RBV', type = 'd')
#ScalarDetector idPotiProc
#idPotiProc = Channel(DEVICE+':POSA:2', type = 'd')
idPotiProc = Channel(DEVICE+':ENCODER', type = 'd')
#ScalarDetector idBtvsProc
#idBtvsProc = Channel(DEVICE+':IST3:2', type = 'd')
idBtvsProc = Channel(DEVICE+':MOTOR.HLS', type = 'd')
#ScalarDetector idEndSwitchL
#idBtvsRaw = Channel(DEVICE+':IST3:1', type = 'd')
idEndSwitchL = Channel(DEVICE+':MOTOR.LLS', type = 'd')
#ScalarDetector idEndSwitchH
#idBtvsProc = Channel(DEVICE+':IST3:2', type = 'd')
idEndSwitchH = Channel(DEVICE+':MOTOR.HLS', type = 'd')
except:
ret = 'Unable to create channel - ' + traceback.format_exc()
success = False
sendFeedback(testPath, testName, DEVICE, ret, success)
return
count = 0
print_log(testName, DEVICE, 'Initialisation sequence')
timeout = 60000 #timeout in ms
for count in range(0, loopTimes):
print_log(testName, DEVICE, 'Initialisation #' + str(count+1) + '/' + str(loopTimes) )
sleep( delaySeconds ) # Settling time
idInit.put(1, timeout=None) # TODO: Set appropriate timeout
timeStampStart = float(java.lang.System.currentTimeMillis())
sleep(0.1)
ready = 0
interlock = idInterlock.get()
timeElapsed = 0 #in ms
while (ready == 0) and timeElapsed<40000:
#Detector time
timeStamp = float(java.lang.System.currentTimeMillis())
timeElapsed = timeStamp - timeStampStart
ready = idReady.get()
sleep( 0.1 )
detector4 = idMotorPosition.get()
detector6 = idPotiProc.get()
detector8 = idBtvsProc.get()
ready = idReady.get()
interlock = idInterlock.get()
#end switches
endH = idEndSwitchH.get()
endL = idEndSwitchL.get()
#Manipulation idDiff02
a = detector4
b = detector8
idDiff02 = a-b
#Manipulation idDiff01
a = detector4
b = detector6
idDiff01 = a-b
scan.append ([timeStamp],[timeStamp], [detector4, detector6, detector8, idDiff02, idDiff01])
if ready == 1 and interlock == 1:
ret = 'Drive initialised ' + str(count) + ' times'
success = True
else:
ret = 'The RDY and ILK signals indicate the drive was NOT ready at the expected time (after ' + str(timeout/1000) + 's).'
success = False
break
idInit.close()
idReady.close()
idMotorPosition.close()
idPotiProc.close()
idBtvsProc.close()
scan.end()
############# END OF YOUR CODE ###########
###### DO NOT MODIFY THE CODE BELOW ######
sendFeedback(testPath, testName, DEVICE, ret, success)
except:
ret = traceback.format_exc()
success = False
sendFeedback(testPath, testName, DEVICE, ret, success)
return
#launch the test
startTest(test, device, parameters)
@@ -0,0 +1,14 @@
<html>
<body>
<h2>Short Description</h2>
Initialise N times.
<h2>Details</h2>
This test sends a INIT command to the device, as many times as configured with the parameter repeatTimes.
<h2>Parameters</h2>
<code>repeatTimes</code> Repeat the Initialisation N times<br/>
<code>delayS</code> Pause delay between each Initialisation [s]
<h2>Contact</h2>
<a href="https://intranet.psi.ch/Main/MarcoBoccioli">Marco Boccioli </a>
</html>
</body>
@@ -19,8 +19,8 @@ def sendFeedback(testPath, testName, DEVICE, returnString, testPassed):
def print_log(testName, DEVICE, text):
time.ctime()
now = time.strftime('%Y.%m.%d %H:%M:%S')
print now + ' ' + DEVICE + ' - ' + testName + ': ' + text
print now + ' ' + DEVICE + ' - ' + testName + ': ' + str(text)
def startTest(testName, DEVICE, params):
try:
import traceback
@@ -202,8 +202,8 @@ def sendFeedback(testPath, testName, DEVICE, returnString, testPassed):
def print_log(testName, DEVICE, text):
time.ctime()
now = time.strftime('%Y.%m.%d %H:%M:%S')
print now + ' ' + DEVICE + ' - ' + testName + ': ' + text
print now + ' ' + DEVICE + ' - ' + testName + ': ' + str(text)
#launch the test
#from pshellTestGeneral import testUtils
#testUtil = testUtils()
@@ -6,8 +6,8 @@ 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 + ': ' + text
print now + ' ' + DEVICE + ' - ' + testName + ': ' + str(text)
#prepare and send feedback to calling tool
def sendFeedback(testPath, testName, DEVICE, returnString, testPassed):
print_log(testName, DEVICE, 'End of test. Result:')
@@ -113,6 +113,6 @@ def startTest(testName, DEVICE, params):
#launch the test
parameters = {}
#parameters = {}
startTest(test, device, parameters)