Startup
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
|
||||
###### Init - DO NOT MODIFY THE CODE BELOW ######
|
||||
global print_log, sendFeedback, 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 + ': ' + 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):
|
||||
#get the path of this script
|
||||
import inspect
|
||||
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 #############
|
||||
print_log(testName, DEVICE, 'testpath B: ' + testPath )
|
||||
print_log(testName, DEVICE, 'parameters:' + str( params) )
|
||||
print_log(testName, DEVICE, 'device: ' + DEVICE )
|
||||
#scan = ManualScan(['time'], ['SetVB', 'ActualVB', 'ActualIB'] , [0.0], [30.0], [20])
|
||||
scan = ManualScan(['time'], ['SetVB', 'ActualVB', 'ActualIB'] )
|
||||
scan.setPlotName(plotName)
|
||||
scan.start()
|
||||
|
||||
#Creating channels: dimension 1
|
||||
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, testName, DEVICE, 'Unable to create channel - ' + traceback.format_exc(), False)
|
||||
return
|
||||
#Init
|
||||
SetRamp.put(10.0, timeout=None)
|
||||
|
||||
#set voltage to 0
|
||||
print_log(testName, DEVICE, '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_log(testName, DEVICE, '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)+')'
|
||||
success = 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 ps B completed'
|
||||
success = True
|
||||
|
||||
#reset output to 0V
|
||||
SetVA.put(0.0, timeout=None)
|
||||
#Closing channels
|
||||
SetVA.close()
|
||||
ActualVA.close()
|
||||
ActualIA.close()
|
||||
################ END OF YOUR CODE ################
|
||||
###### Final - DO NOT MODIFY THE CODE BELOW ######
|
||||
sendFeedback(testPath, testName, DEVICE, ret, success)
|
||||
|
||||
#launch the test
|
||||
parameters = {}
|
||||
startTest(test, device, parameters)
|
||||
|
||||
4
script/tests/tests/PS Tests/test without ioc 2/.config
Normal file
4
script/tests/tests/PS Tests/test without ioc 2/.config
Normal file
@@ -0,0 +1,4 @@
|
||||
#Mon Sep 07 10:48:01 CEST 2015
|
||||
name=test without ioc 2
|
||||
description=test that does not use any connection to IOC. It is useful to test pure pshell graphical features.
|
||||
parameters=repeatTimes\:3\:how many times the test is repeated;howManySamples\:300\:How many samples are plotted;delayBetweenSampleS\:0.05\:delay [s] between two samples;
|
||||
14
script/tests/tests/PS Tests/test without ioc 2/help.html
Normal file
14
script/tests/tests/PS Tests/test without ioc 2/help.html
Normal 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>
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
#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'
|
||||
success = 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="Data 1", 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("Data2"))
|
||||
|
||||
motor_msta = 0
|
||||
motor_val = 50
|
||||
increment = 1
|
||||
|
||||
max = 0
|
||||
maxPos = 0
|
||||
min = 0
|
||||
minPos = 0
|
||||
|
||||
for sample in range(0, howManySamples):
|
||||
readback1 = sample
|
||||
sleep( delayBetweenSampleS ) # Settling time
|
||||
#here we simulate getting values
|
||||
motor_msta = motor_msta + increment
|
||||
motor_val = motor_val - increment
|
||||
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 peaks
|
||||
if motor_msta - motor_val > max:
|
||||
max = motor_msta - motor_val
|
||||
maxPos = sample
|
||||
if motor_msta - motor_val < min:
|
||||
min = motor_msta - motor_val
|
||||
minPos = sample
|
||||
|
||||
|
||||
|
||||
import java.awt.Color
|
||||
p1[0].addMarker(maxPos, None, "Max=" + str(max), java.awt.Color.LIGHT_GRAY)
|
||||
p1[0].addMarker(minPos, None, "Min=" + str(min), 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)
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
#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'
|
||||
success = 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"
|
||||
success = True
|
||||
#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 (KeyboardInterrupt):
|
||||
#user stop error handler
|
||||
ret = 'Test stopped by user.'
|
||||
success = False
|
||||
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 ####
|
||||
4
script/tests/tests/PS Tests/test without ioc 3/.config
Normal file
4
script/tests/tests/PS Tests/test without ioc 3/.config
Normal file
@@ -0,0 +1,4 @@
|
||||
#Mon Sep 07 10:48:01 CEST 2015
|
||||
name=test without ioc 3
|
||||
description=test that does not use any connection to IOC. It is useful to test pure pshell graphical features.
|
||||
parameters=repeatTimes\:3\:how many times the test is repeated;howManySamples\:300\:How many samples are plotted;delayBetweenSampleS\:0.05\:delay [s] between two samples;
|
||||
14
script/tests/tests/PS Tests/test without ioc 3/help.html
Normal file
14
script/tests/tests/PS Tests/test without ioc 3/help.html
Normal 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>
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
#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'
|
||||
success = 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="Data 1", 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("Data2"))
|
||||
|
||||
motor_msta = 0
|
||||
motor_val = 50
|
||||
increment = 1
|
||||
|
||||
max = 0
|
||||
maxPos = 0
|
||||
min = 0
|
||||
minPos = 0
|
||||
|
||||
for sample in range(0, howManySamples):
|
||||
readback1 = sample
|
||||
sleep( delayBetweenSampleS ) # Settling time
|
||||
#here we simulate getting values
|
||||
motor_msta = motor_msta + increment
|
||||
motor_val = motor_val - increment
|
||||
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 peaks
|
||||
if motor_msta - motor_val > max:
|
||||
max = motor_msta - motor_val
|
||||
maxPos = sample
|
||||
if motor_msta - motor_val < min:
|
||||
min = motor_msta - motor_val
|
||||
minPos = sample
|
||||
|
||||
|
||||
|
||||
import java.awt.Color
|
||||
p1[0].addMarker(maxPos, None, "Max=" + str(max), java.awt.Color.LIGHT_GRAY)
|
||||
p1[0].addMarker(minPos, None, "Min=" + str(min), 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)
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
#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'
|
||||
success = 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"
|
||||
success = True
|
||||
#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 (KeyboardInterrupt):
|
||||
#user stop error handler
|
||||
ret = 'Test stopped by user.'
|
||||
success = False
|
||||
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 ####
|
||||
@@ -0,0 +1,147 @@
|
||||
#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'
|
||||
success = 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="Data 1", 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("Data2"))
|
||||
|
||||
motor_msta = 0
|
||||
motor_val = 50
|
||||
increment = 1
|
||||
|
||||
max = 0
|
||||
maxPos = 0
|
||||
min = 0
|
||||
minPos = 0
|
||||
|
||||
for sample in range(0, howManySamples):
|
||||
readback1 = sample
|
||||
sleep( delayBetweenSampleS ) # Settling time
|
||||
#here we simulate getting values
|
||||
motor_msta = motor_msta + increment
|
||||
motor_val = motor_val - increment
|
||||
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 peaks
|
||||
if motor_msta - motor_val > max:
|
||||
max = motor_msta - motor_val
|
||||
maxPos = sample
|
||||
if motor_msta - motor_val < min:
|
||||
min = motor_msta - motor_val
|
||||
minPos = sample
|
||||
|
||||
|
||||
|
||||
import java.awt.Color
|
||||
p1[0].addMarker(maxPos, None, "Max=" + str(max), java.awt.Color.LIGHT_GRAY)
|
||||
p1[0].addMarker(minPos, None, "Min=" + str(min), 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)
|
||||
|
||||
Reference in New Issue
Block a user