Files
sf-op/script/RFscan/gun_scan1.py
2017-01-19 14:22:53 +01:00

42 lines
1.4 KiB
Python

import ch.psi.pshell.epics.ControlledVariable as ControlledVariable
#start = caget("SINEG01-RSYS:SET-SCAN-START")
#stop = caget("SINEG01-RSYS:SET-SCAN-STOP")
#step = caget("SINEG01-RSYS:SET-SCAN-STEP")
#nb = caget("SINEG01-RSYS:SET-NUM-AVERAGE")
#lat = caget("SINEG01-RSYS:SET-SCAN-WAIT-TIME")
start = 0.0
stop = 350.0
step = 10.0
nb = 1
lat = 0.100
phase = ControlledVariable("Phase", "SINEG01-RSYS:SET-VSUM-PHASE-SIM", "SINEG01-RSYS:GET-VSUM-PHASE-SIM")
phase.config.minValue =-45.0
phase.config.maxValue = 360.0
phase.config.resolution = 0.5
phase.initialize()
#st = Stream("ICTstream", dispatcher)
#q = st.addScalar("Charge", "SINEG01-DICT215:B1_CHARGE-SIM", 1, 0)
#st.initialize()
q = Channel("SINEG01-DICT215:B1_CHARGE-SIM", type = 'd', alias='ICT-Q')
try:
#qb = create_averager(q, nb, 0.100)
r = lscan(phase, (q), 0, 360, 19, latency=0.1)
rf_phase = r.getPositions(0)
#charge = [val.mean for val in r.getReadable(0)]
charge = r.getReadable(0)
caput("SINEG01-RSYS:GET-PHASE-ARRAY", to_array(rf_phase,'d'))
caput("SINEG01-RSYS:GET-CHARGE-ARRAY", to_array(charge, 'd'))
finally:
phase.close()
q.close()
#st.close()
# Here the user needs to pick a phase as reference phase onset of charge emission
phase_ref = 27.3
phase_offset = - phase_ref
caput("SINEG01-RSYS:CALC-VSUM-PHASE-OFFSET", phase_offset)