added plot example to template
This commit is contained in:
@@ -62,6 +62,14 @@ def startTest(testName, DEVICE, params):
|
||||
sendFeedback(testPath, testName, DEVICE, ret, success)
|
||||
return
|
||||
|
||||
#example: 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)
|
||||
#start plots. See further below how to add points to the plots
|
||||
scan.start()
|
||||
|
||||
#IMPORTANT: if the test resulted with an error, write the following:
|
||||
ret = "Example - Error, the test failed because...."
|
||||
@@ -69,7 +77,33 @@ def startTest(testName, DEVICE, params):
|
||||
#IMPORTANT: if the test was successful, write the following:
|
||||
ret = "Example - Test successful, here some detail: ..."
|
||||
success = True
|
||||
|
||||
#set up connection to channels. "type" of data can be "d" (= double), "l" (= long)
|
||||
try:
|
||||
pv_motor_msta = Channel(DEVICE+':MOTOR.MSTA', type = 'd')
|
||||
pv_motor_val = Channel(DEVICE+':MOTOR.VAL' , type = 'd')
|
||||
except:
|
||||
#prepare return information: return text
|
||||
ret = 'Unable to create channel - ' + traceback.format_exc()
|
||||
#prepare return information: return success
|
||||
success = False
|
||||
#send return information
|
||||
sendFeedback(testPath, testName, DEVICE, ret, success)
|
||||
return
|
||||
#take 100 samples of the channels
|
||||
for sample in range(0, 100):
|
||||
readback1 = sample
|
||||
sleep( 0.1 ) # Settling time
|
||||
#get value
|
||||
motor_msta = pv_motor_msta.get()
|
||||
#get value
|
||||
motor_val = pv_motor_val.get()
|
||||
#add values to plot
|
||||
scan.append ([sample], [readback1], [detmotor_msta, motor_val] )
|
||||
|
||||
#Closing channels
|
||||
pv_motor_msta.close()
|
||||
pv_motor_val.close()
|
||||
|
||||
#once the test is finished, no need to do anything. The code below yours will do the rest.
|
||||
################ END OF YOUR CODE ################
|
||||
###### Final - DO NOT MODIFY THE CODE BELOW ######
|
||||
|
||||
Reference in New Issue
Block a user