Improved documentation

This commit is contained in:
boccioli_m
2016-01-13 14:21:34 +01:00
parent 3bb7cc2ed7
commit 99e0ddc2fb

View File

@@ -31,20 +31,26 @@ def startTest(testName, DEVICE, params):
It must be indented to the same level as this comment
-----------------------------------
GETTING INPUTS:
If needed, the following variables are available:
-----------------------------------
If needed, the following global 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.
getParam is added automatically, one per parameter, when creating the new test.
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.
-----------------------------------
When the test has ended (error or success), this method must be called in order to return to pshell:
test.sendFeedback(ret,success) method that ends the testing script and gives the report to the calling application.
ret string, a text summarizing the result of the test.
success bool, True = test successful.
Examples:
whenever the code must quit (i.e. after an error), you must end with the following 3 lines:
@@ -58,11 +64,13 @@ def startTest(testName, DEVICE, params):
test.sendFeedback(ret, success) # Return to pshell
-----------------------------------
LOG INFO:
-----------------------------------
when some information must be shown on the log on pshell, use the following line:
test.log('text to log')
"""
########## Example (can be removed) ######
########## 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)
@@ -73,6 +81,7 @@ def startTest(testName, DEVICE, params):
# These parameters were automatically generated: you might need to change the casting.
#$testParameters
except:
# test failed, write the report into the variables ret and success and send feedback:
ret = 'Could not retrieve testing parameters - ' + traceback.format_exc()
success = False
test.sendFeedback(ret, success)
@@ -86,10 +95,6 @@ def startTest(testName, DEVICE, params):
# start plots. See further below how to add points to the plots (scan):
scan.start()
# IMPORTANT: if the test failed, write the report into the variables ret and success.
# for example, write the following:
ret = "Example - Error, the test failed because...."
success = False
try:
# set up connection to channels. "type" of data can be "d" (= double), "l" (= long).
pv_motor_msta = Channel(DEVICE + ':MOTOR.MSTA', type='d')
@@ -104,7 +109,7 @@ def startTest(testName, DEVICE, params):
test.sendFeedback(ret, success)
return
# send a command to a channel (it is translated to a caput):
pv_motor_com.put(1, timeout=None) # optionally, a timeout can be given.
pv_motor_com.put(1.0, timeout=None) # optionally, a timeout can be given.
# take 100 samples of the channels and plot them:
for sample in range(0, 100):
readback1 = sample #the x axis.