Files
sf-op/script/test/test.py
2017-06-02 11:10:37 +02:00

32 lines
1.1 KiB
Python

import ch.psi.pshell.epics.ControlledVariable as ControlledVariable
import ch.psi.pshell.epics.Camtool as Camtool
phase = ControlledVariable("Phase", "SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:GET-BEAM-PHASE")
phase.config.minValue =-180.0
phase.config.maxValue = 360.0
phase.config.precision = 3
phase.config.resolution = 1.0
phase.config.save()
phase.initialize()
kill_camtool()
check_camtool()
camtool.start("SINBD01-DSCR010")
wait_camtool_message()
x = camtool.stream.getChild("gr_x_fit_mean")
dx = camtool.stream.getChild("gr_x_fit_standard_deviation")
try:
xb = create_averager(x, nb, -1) # -1 event based, waits for the next value
dxb = create_averager(dx, nb, -1)
dxb.monitored=True # not blocking, will return last nb values
r = lscan(phase, [xb, dxb], start, stop, step , latency=lat)
rf_phase = r.getPositions(0)
E = [energy0 * (1 + val.mean / 1e6 / disp) for val in r.getReadable(0)]
dE = [energy0 * ( val.mean / 1e6 / disp) for val in r.getReadable(1)]
finally:
phase.write(phase0)
phase.close()
camtool.stop() # stops camtool but does not close it camtool is a global object