From e24d12473838ebe7417767c3bed6d5e6d314cb00 Mon Sep 17 00:00:00 2001 From: boccioli_m Date: Fri, 25 Aug 2017 16:26:35 +0200 Subject: [PATCH] Startup --- script/tests/config/test-bx84 | Bin 0 -> 14548 bytes script/tests/devices/bx84/.config | 4 + script/tests/tests.properties | 4 +- script/tests/tests/sad/rightleft/.config | 4 + script/tests/tests/sad/rightleft/help.html | 17 ++ script/tests/tests/sad/rightleft/rightleft.py | 170 ++++++++++++++++++ 6 files changed, 197 insertions(+), 2 deletions(-) create mode 100644 script/tests/config/test-bx84 create mode 100644 script/tests/devices/bx84/.config create mode 100644 script/tests/tests/sad/rightleft/.config create mode 100644 script/tests/tests/sad/rightleft/help.html create mode 100644 script/tests/tests/sad/rightleft/rightleft.py diff --git a/script/tests/config/test-bx84 b/script/tests/config/test-bx84 new file mode 100644 index 0000000000000000000000000000000000000000..560205343a249d5c3acaddd952498907e8371813 GIT binary patch literal 14548 zcmeHOL2Mhx6&+boVoQoDCoPIz+BpBR*Kv`r7a8a^5AEiHQKu|N|zFbcbeUey0*xg?h&sZg|1 z3ZS4J&FudF_syR_t3UtG{N^#4(u&N#$Eqw786h(_xN8FS_h0f)`G}4H_1$+xy}qTDro56D!N$%um#L*n15_0835i-yds1yYI%gC1%_zSwHfU9OF$p$ZH+v&N(-C}y}J zZ)KcvP~nbtl?aVvkg8F3V|JRXty(7BL+I1CFsJ5s%R*BWL^bz4O&N8AN`?6zH32nc zPGwM|l2^H;MWHG+rZ}yYg5(WH&D5)p3rHAjDNhdV4G?&E; zou0m2xRM|gfq&U4T%p3R2C~XEtprueAA{IgqzGvzOBFA2#eJ94FwnvPA7F+@70z^| z;#YDy?MIaYS2QS6ZFs1G?N%fdx4rTLs)Gz&H5NJa8p*H|8gZj&YTwJ)_e# zAtfy!p#&r19(H2A^;S2Cl;(*v7;#I~>^oqkAy*>s=<64j7cQO$IiN&OpR+HtgD?$a z?s6|eE#u2V8N@KH4QZ6k;5LlE5uj75_n?0jT4hSGg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@c{%QZo-r56ahjqX#MnXz*&Fv)kd%SRLAGA028O-j^mII=gBoZm1x$A4K-H z<^2~De2m2>FmIJ8m5t;@$U|S~kEluMG;3YZL1KFwGKg?!0uHf!2@kQL8 zJO|qe{{8D^{~xn+*-0{$BQKUYBFK@cn($0{gPdhH+%Mpuz#5ze;dMav4SU$8?pQ%i zQ_$B}o21Qqmo~_Z$K%5+a6kb!T(l1A4%zRo#zd@U9Q!1G zNAf&A*)tC(bLJsCalI%cUvXGbJE0aCx9mh9#wj?3z;#6+#Sbg+pvLP@WMLY!)NWZ?ez(e6Fz$M=s$Pw-rc`*=T5f^pCJv>cJh7* z@94(U?HjosYRCM+lP6Eg&z?Q&cHy%`Ch{b@O77ubPaZyeh`K#0e=@95}QnH + + +

Description

+move around a value and plot the result +

Parameters

+delay delay between 2 steps
+centre centre where to move around
+moveAround move right and left from centre
+steps steps of each move
+ +

Contact

+Marco Boccioli
+Tel. 3078 + + + diff --git a/script/tests/tests/sad/rightleft/rightleft.py b/script/tests/tests/sad/rightleft/rightleft.py new file mode 100644 index 0000000..b06d8e0 --- /dev/null +++ b/script/tests/tests/sad/rightleft/rightleft.py @@ -0,0 +1,170 @@ +# Test name: rightleft +# move around a value and plot the result +# Copyright (c) 2015 Paul Scherrer Institute. All rights reserved. + +###### Init - DO NOT MODIFY THE CODE BELOW ###### +global sys, inspect, os, traceback +import sys, inspect, os, traceback + + +def startTest(testName, DEVICE, params): + """ + Main method running the test + """ + # by default, assume the test failed: + ret = 'Test failed' + status = False + # 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: + test = TestingTool(testName, testPath, DEVICE, params) + +################ END OF Init ##################### +######### WRITE YOUR CODE HERE BELOW ############# + + """ + All the code in this section # WRITE YOUR CODE HERE BELOW # is just an example and can be modified/deleted. + It must be indented to the same level as this comment. + ----------------------------------- + GETTING INPUTS: + ----------------------------------- + If needed, the following methods are available: + + test.getPath() string, path of this test file + test.getName() string, name of this test + test.getDeviceName() string, device for which the test must run (typically it is the beginning of a process variable name) + test.getPlotName() string, name to be given to the plot when using setPlotTitle(). Example: scan.setPlotTitle(test.getPlotName()) + ----------------------------------- + GETTING TEST PARAMETERS: + ----------------------------------- + if you need to get parameters for the test, use: + + myParamValue = test.getParam('myParamName') + + the calls to getParam are added to the code automatically, one per parameter, when creating the new test. + NOTE: Casting may be necessary. + See the test config for the list of parameters specific to the test. + ----------------------------------- + SETTING OUTPUTS: + ----------------------------------- + When the test has ended (error or success), this method must be called in order to return to pshell: + + test.sendFeedback(ret,success) + + ret string, a text summarizing the result of the test. + success bool, True = test successful. False = test failed. + ----------------------------------- + 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) ###### + + # print the list of parameters passed. If any error, stop and send feedback. + test.log("Example - Test name: " + test.getName()) + test.log("Example - Device name: " + test.getDeviceName() ) + try: + test.log("Running test with the following parameters:") + test.log(params) + # If present, use the parameters here below for your test script. + # These parameters were automatically generated: you might need to change the casting. + delay = float(test.getParam('delay')) ; centre = float(test.getParam('centre')) ; moveAround = float(test.getParam('moveAround')) ; steps = float(test.getParam('steps')) ; + 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) + return + + # loop to read channels for a while and plot the channels values. + # initialise plot tab with 2 plots: pass here the axis names: + scan = ManualScan(['sample'], ['Status (sta)', 'Position (VAL)']) + # set plot name(tab title): + scan.setPlotTitle(test.getPlotName()) + # start plots. See further below how to add points to the plots (scan): + scan.start() + + # inject a sinus into the plot, as example + from math import sin + motor_sta = 0 + # take 100 samples of a sinus and a jigsaw plot them: + for sample in range(0, 100): + readback1 = sample #the x axis. + sleep(delay) # settling time. + # get value (it is translated to a caget): + motor_sta = motor_sta + +1 + if motor_sta > 50: + motor_sta = 0 + # get value: + motor_val = sin(float(sample)/10.0)*10.0-10.0 + # add values to plot: + scan.append([readback1], [readback1], [motor_sta, motor_val]) + + # now try with data from real device: this part will most probably fail: correct the PV names with existing ones. + try: + # set up connection to channels. "type" of data can be "d" (= double), "l" (= long). + pv_motor_sta = Channel(test.getDeviceName() + ':ao' , type='d') + pv_motor_val = Channel(test.getDeviceName() + ':ai' , 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: + test.sendFeedback(ret, success) + return + # send a command to a channel (it is translated to a caput): uncomment this line below to try it + #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. + sleep(delay) # settling time. + # get value: + motor_val = pv_motor_val.put(sample) + # get value (it is translated to a caget): + motor_sta = pv_motor_sta.get() + # add values to plot: + scan.append([readback1], [readback1], [motor_sta, motor_val]) + + # Closing channels: all channels that were opened with Channel() must be closed before exit: + pv_motor_sta.close() + pv_motor_val.close() + + # 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 (KeyboardInterrupt): + # user stop error handler. + import traceback + ret = 'Test stopped by user.' + success = False + test.sendFeedback(ret, success) + except: + # generic error handler. + import traceback + 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 #### +# Indent to end left +# def yourCustomFunction: