Closedown

This commit is contained in:
boccioli_m
2015-09-04 11:49:10 +02:00
parent 6371d9c202
commit ea22b6e80b
9 changed files with 265 additions and 59 deletions

Binary file not shown.

View File

@@ -960,6 +960,7 @@ public class TestingList extends Panel {
} else {
filterTests("");
}
//if only enabled tests are visible, disable the move buttons
this.jButtonMoveUp.setEnabled(!show);
this.jButtonMoveDown.setEnabled(!show);
}
@@ -1593,18 +1594,21 @@ public class TestingList extends Panel {
if (!sDeviceName.isEmpty()) {
showResult(sDeviceName, sTestPath, ccex.toString(), TestStatus.FAILURE.toString());
}
} catch (InterruptedException intEx) {
Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, intEx);
System.out.println(String.valueOf(intEx));
showResult(sDeviceName, sTestPath, "User interrupted test", TestStatus.FAILURE.toString());
} catch (Exception ex) {
Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex);
SwingUtils.showMessage(TestingList.this, "executeParallelTestsGroup()", ex.toString());
System.out.println(String.valueOf(ex));
showResult(sDeviceName, sTestPath, ex.toString(), TestStatus.FAILURE.toString());
}
}
} catch (Exception ex) {
SwingUtils.showMessage(TestingList.this, "executeParallelTestsGroup(), run thread", ex.toString());
logger.log(Level.SEVERE, ex.toString());
setToStopped();
}
}
return iRet;
}
}

View File

@@ -1,4 +0,0 @@
#Tue Sep 01 14:05:29 CEST 2015
name=defev
tests=jojo
description=vvff

View File

@@ -18,6 +18,7 @@ def startTest(testName, DEVICE, params):
#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 #############
"""
@@ -132,4 +133,7 @@ def startTest(testName, DEVICE, params):
#launch the test
startTest(test, device, parameters)
################ END OF Final ####################
#### IF NEEDED, ADD YOUR FUNCTIONS HERE BELOW ####
#def yourCustomFunction:

View File

@@ -1,7 +1,4 @@
#Fri Sep 04 11:43:56 CEST 2015
name=Check Linearity
description=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
#optional parameters. Description is compulsory. Syntax:
#parameters=<parameter1Name>:<parameter1Value>:<Parameter 1 description>[;<parameter2Name>:<parameter2Value>:<Parameter 2 description>]
parameters=repeatTimes:2:Repeat N times;midPoint:41.0:Middle point A;spanFromMidPoint:3.0:B steps around middle point A;delayS:0:Delay between each oscillation [s]
parameters=repeatTimes\:2\:Repeat N times;midPoint\:41.0\:Middle point A;spanFromMidPoint\:10.0\:B steps around middle point A;delayS\:0\:Delay between each oscillation [s];

View File

@@ -1,58 +1,46 @@
#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
###### DO NOT MODIFY THE CODE BELOW ######
global print_log, sendFeedback, inspect, log, sys, inspect, os, traceback
###### Init - DO NOT MODIFY THE CODE BELOW ######
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)
#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'
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:
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 #######
#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:
print_log(testName, DEVICE, "Running test Motor Test 2 for device " + DEVICE + " with the following parameters:\n" + str(params))
middle = float(params["midPoint"]["value"])
loopTimes = int(params["repeatTimes"]["value"])
delayS = int(params["delayS"]["value"])
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"))
delayS = int(test.getParam("delayS"))
if(delayS<1): delayS=1
span = float(params["spanFromMidPoint"]["value"])
except:
ret = 'Could not retrieve testing parameters - ' + traceback.format_exc()
success = False
sendFeedback(testPath, testName, DEVICE, ret, success)
test.sendFeedback( ret, success)
return
#scan = ManualScan(['idX'], ['idMotorStatus', 'idLogicalPosition', 'idDiameter', 'idMotorPosition', 'idPotiRaw', 'idEncoderPosition', 'idBtvsRaw', 'idBtvsProc', 'idDiff01', 'idDiff02'] , [ 0.0], [ 3000.0], [20])
scan = ManualScan(['idX'], ['idMotorStatus', 'idMotorPosition', 'idEncoderPosition', 'idError'])
scan.setPlotName(plotName)
scan.setPlotName(plotName + " parameters")
scan.start()
#coloured plot (one colour per scan)
p1 = plot(None,name="Run0", context = plotName + " error")[0]
#Creating channels: dimension 1
try:
@@ -67,34 +55,49 @@ def startTest(testName, DEVICE, params):
except:
ret = 'Unable to create channel - ' + traceback.format_exc()
success = False
sendFeedback(testPath, testName, DEVICE, ret, success)
test.sendFeedback( ret, success)
return
#remove limits
idLimitH.put(999999.9, timeout=None)
idLimitL.put(-999999.9, timeout=None)
min = 9999999999
minPos = 0
max = 0
maxPos = 0
minDev = []
minDevPos = []
maxDev = []
maxDevPos = []
direction = 1.0
startDefault = middle - span
endDefault = middle + span
end = endDefault+1
#find position: it will be the middle point of the test
print_log(testName, DEVICE, 'Moving to middle point ' + str(middle) )
test.log( 'Moving to middle point ' + str(middle) )
idInkr.put(middle, timeout=None) # TODO: Set appropriate timeout
readback2 = idInkr.get()
if abs(readback2 - middle) > 1 : # TODO: Check accuracy
ret = 'Actor idInkr could not be set to the value ' + str(middle) + ' (current value: ' + str(readback2) + ')'
success = False
sendFeedback(testPath, testName, DEVICE, ret, success)
test.sendFeedback( ret, success)
return
start = readback2+direction
countSteps = 0
count = 0
print_log(testName, DEVICE, 'Moving around middle point (+-' + str(span) + ')' )
test.log( 'Moving around middle point (+-' + str(span) + ')' )
for setpoint1 in range(0, loopTimes*2):
count = count + 1
print_log(testName, DEVICE, 'Pausing ' + str(delayS) + 's' )
test.log( 'Pausing ' + str(delayS) + 's' )
sleep( delayS ) # Settling time
p1.addSeries(LinePlotSeries("Run"+str(count)))
maxDev.append(0)
maxDevPos.append(0)
minDev.append(9999999999)
minDevPos.append(0)
#RegionPositioner idInkr
for setpoint2 in frange(start, end, direction):
readback1 = setpoint1
@@ -104,7 +107,7 @@ def startTest(testName, DEVICE, params):
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
sendFeedback(testPath, testName, DEVICE, ret, success)
test.sendFeedback( ret, success)
return
#Detector idMotorStatus
detector1 = idMotorStatus.get()
@@ -119,21 +122,55 @@ def startTest(testName, DEVICE, params):
idDiff01 = a-b
countSteps = countSteps + 1
scan.append ([countSteps], [countSteps], [detector1, detector4, detector6, idDiff01])
p1.getSeries(count).appendData(setpoint2, idDiff01)
#compute min and max differences
if abs(idDiff01) > max:
max = abs(idDiff01)
maxPos = setpoint2
if abs(idDiff01) < min:
min = abs(idDiff01)
minPos = setpoint2
#compute min and max deviation
if abs(idDiff01) > maxDev[count-1]:
maxDev[count-1] = abs(idDiff01)
maxDevPos[count-1] = setpoint2
if abs(idDiff01) < minDev[count-1]:
minDev[count-1] = abs(idDiff01)
minDevPos[count-1] = setpoint2
if endH>0.0 or (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
print_log(testName, DEVICE, 'End of span (' + str(setpoint2) + '), changing direction to ' + str(direction) )
test.log( 'End of span (' + str(setpoint2) + '), changing direction to ' + str(direction) )
break
if endL>0.0 or ( 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
print_log(testName, DEVICE, 'End of span (' + str(setpoint2) + '), changing direction to ' + str(direction) )
test.log( 'End of span (' + str(setpoint2) + '), changing direction to ' + str(direction) )
break
#show differences in the plot
import java.awt.Color
p1.addMarker(maxPos, None, "Max=" + str(max), java.awt.Color.LIGHT_GRAY)
p1.addMarker(minPos, None, "Min=" + str(min), java.awt.Color.LIGHT_GRAY)
#show deviations in the plot
absMaxDev = 0
absMinDev = 9999999999
absMaxPos = 0
absMinPos = 0
for index in range(len(maxDev)):
if absMaxDev < maxDev[index]:
absMaxDev = maxDev[index]
absMaxPos = maxDevpos[index]
if absMinDev > minDev[index]:
absMinDev = minDev[index]
absMinPos = minDevPos[index]
p1.addMarker(absMaxPos, None, "MaxDev=" + str(absMaxDev), java.awt.Color.LIGHT_GRAY)
p1.addMarker(absMinPos, None, "MinDev=" + str(absMinDev), java.awt.Color.LIGHT_GRAY)
#set limits back
idLimitH.put(145.0, timeout=None)
idLimitL.put(0.0, timeout=None)
@@ -151,11 +188,11 @@ def startTest(testName, DEVICE, params):
############# END OF YOUR CODE ###########
###### DO NOT MODIFY THE CODE BELOW ######
sendFeedback(testPath, testName, DEVICE, ret, success)
test.sendFeedback( ret, success)
except:
ret = traceback.format_exc()
success = False
sendFeedback(testPath, testName, DEVICE, ret, success)
test.sendFeedback( ret, success)
return
#launch the test

View File

@@ -0,0 +1,4 @@
#Fri Sep 04 09:30:11 CEST 2015
name=test without ioc
parameters=repeatTimes\:2\:how many times the test is repeated;howManySamples\:300\:How many samples are plotted;delayBetweenSampleS\:0.05\:delay [s] between two samples;
description=test that does not use any connection to IOC. It is useful to test pure pshell graphical features.

View File

@@ -0,0 +1,14 @@
<html>
<body>
<h2>Description</h2>
test that does not use any connection to IOC. It is useful to test pure pshell graphical features.
<h2>Parameters</h2>
<code>repeatTimes </code>how many times the test is repeated<br/>
<code>howManySamples </code>How many samples are plotted<br/>
<code>delayBetweenSampleS </code>delay [s] between two samples<br/>
<h2>Contact</h2>
<a href="https://intranet.psi.ch/search/#?t=phonebook&q=boccioli_m">boccioli_m</a>
</html>
</body>

View File

@@ -0,0 +1,150 @@
#Test name: test without ioc
#test that does not use any connection to IOC. It is useful to test pure pshell graphical features.
###### 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 #############
#All the code in this section ## ..YOUR CODE.. ## can be modified/deleted.
#It must be indented at the same level as this comment
#-----------------------------------
# GETTING INPUTS:
#If needed, the following variables are available:
#testPath string, path of this test file
#testName string, name of this test
#DEVICE string, device for which the test must run (typically it is the beginning of a process variable name)
#-----------------------------------
# GETTING TEST PARAMETERS:
#if you need to get parameters for the test, use (casting may be necessary):
#myParamValue = test.getParam('myParamName')
#see the test config for the list of parameters specific to the test.
#-----------------------------------
# SETTING OUTPUTS:
#ret string, a text summarizing the result of the test. It must be set before the end of your code.
#success bool, True = test successful. It must be set before the end of your code.
#test.sendFeedback(ret,success) method that ends the testing script and gives the report to the calling application.
#Examples:
#
#whenever the code must quit (i.e. after an error), you must end with:
#ret = 'here is some info on what failed on the test'
#success = false
#test.sendFeedback(ret, success)
#
#whenever the code is finished successfully, you must end with:
#ret = 'here is some info on the success of the test'
#success = true
#test.sendFeedback(ret, success)
#-----------------------------------
# LOG INFO:
#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)
try:
test.log("Running test Initialise with the following parameters:")
test.log(params )
#If present, use the parameters here below for your test script
repeatTimes = int(test.getParam('repeatTimes')) ; howManySamples = int(test.getParam('howManySamples')) ; delayBetweenSampleS = float(test.getParam('delayBetweenSampleS')) ;
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)
scan.setPlotName(plotName + " Manual Scan")
#start plots. See further below how to add points to the plots
scan.start()
#in this example we initialise also a plot type to show how to add several curves on the same plot
p1 = plot(None,name="motor_msta", context = plotName + " Multi curves")[0]
#opionally set plot ranges
#p1.getAxis(p1.AxisId.X).setRange(0.0,80.0)
#p1.getAxis(p1.AxisId.Y).setRange(0.0,70.0)
p1.addSeries(LinePlotSeries("motor_val"))
motor_msta = 0
motor_val = 50
increment = 1
max = -1
maxPos = 0
min = 1000000000000
minPos = 0
from math import sin
for sample in range(0, howManySamples):
readback1 = sample
sleep( delayBetweenSampleS ) # Settling time
#here we simulate getting values
#just draw a saw
motor_msta = motor_msta + increment
#just draw a nice sinusoid
motor_val = sin(float(sample)/10.0)*10.0-10.0
if abs(motor_msta) >= 50:
increment = -1 * increment
#add values to manual scan
scan.append ([sample], [readback1], [motor_msta, motor_val] )
#add values to plot
p1.getSeries(0).appendData(sample, motor_msta)
p1.getSeries(1).appendData(sample, motor_val )
#compute min and max differences
if abs(motor_msta - motor_val) > max:
max = abs(motor_msta - motor_val)
maxPos = sample
if abs(motor_msta - motor_val) < min:
min = abs(motor_msta - motor_val)
minPos = sample
#show differences in the plot
import java.awt.Color
p1.addMarker(maxPos, None, "Max=" + str(max), java.awt.Color.LIGHT_GRAY)
p1.addMarker(minPos, None, "Min=" + str(min), java.awt.Color.LIGHT_GRAY)
# plots[0].addMarker(25, None, "Mark", java.awt.Color.LIGHT_GRAY)
#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.
################ End of Example ##########
################ 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)
################ END OF Final ####################
#### IF NEEDED, ADD YOUR FUNCTIONS HERE BELOW ####