Script execution

This commit is contained in:
voulot_d
2017-01-13 11:10:53 +01:00
parent b03474eb1d
commit d73b1f2f20

View File

@@ -7,7 +7,6 @@ if get_exec_pars().source == CommandSource.ui:
else:
prefix = args[0] + "-RSYS"
start = caget(prefix + ":SET-SCAN-START")
stop = caget(prefix + ":SET-SCAN-STOP")
step = caget(prefix + ":SET-SCAN-STEP")
@@ -16,7 +15,6 @@ nb = caget(prefix + ":SET-NUM-AVERAGE")
bpm_ch = caget(prefix + ":DBPM")
disp = caget(bpm_ch + ":DISPERSION")
energy0 = caget(bpm_ch + ":ENERGY")
#energy0 = caget("SINSB04-RACC100:ENERGY")
rf_phase_var = ControlledVariable("Phase", prefix + ":SET-VSUM-PHASE-SIM", prefix + ":GET-VSUM-PHASE-SIM")
rf_phase_var.config.minValue =-45.0
@@ -25,19 +23,17 @@ rf_phase_var.config.resolution = 0.5
rf_phase_var.initialize()
rf_ampl_rbk = Channel(prefix + ":GET-VSUM-AMPLT-SIM", type = 'd', alias='Amplitude Readback')
rf_ampl_rbk.write(1.0)
#rf_ampl_rbk.write(1.0)
rf_power_rbk = Channel(prefix + ":GET-KLY-POWER-SIM", type = 'd', alias='Power Readback')
bpm_x = Channel(bpm_ch + ":X1-SIMU", type = 'd', alias='BPM-X')
#bpm_x = Channel("SINSB04-RSYS:BPM-X1-SIM", type = 'd', alias='BPM-X')
bpm_x = Channel(bpm_ch + ":X1-SIMU", type = 'd', alias='BPM-X')
caput(prefix + ":GET-FIT-PHASE-ARRAY", to_array([0.0],'d'))
caput(prefix + ":GET-FIT-ENERGY-ARRAY", to_array([0.0],'d'))
caput(prefix + ":GET-FIT-PHASE-ARRAY", to_array([0.0],'d'))
caput(prefix + ":GET-FIT-ENERGY-ARRAY", to_array([0.0],'d'))
caput(prefix + ":CALC-VSUM-PHASE-OFFSET", float('nan'))
caput(prefix + ":CALC-VSUM-AMPLT-SCALE" , float('nan'))
caput(prefix + ":CALC-VOLT-POWER-SCALE" , float('nan'))
#update the plot dynamically
arr_phase,arr_energy = [],[]
def after(rec):
@@ -49,27 +45,22 @@ def after(rec):
try:
r = lscan(rf_phase_var, [rf_ampl_rbk, bpm_x], start, stop, step , latency=lat, after_read = after)
rf_phase = r.getPositions(0)
energy = [x/1000.0/disp*energy0 for x in r.getReadable(1)]
caput(prefix + ":GET-ENERGY-ARRAY", to_array(energy,'d'))
caput(prefix + ":GET-PHASE-ARRAY", to_array(rf_phase,'d'))
phase_fit_max = None
try:
(energy_max, angular_frequency, phase0, in_range, phase_fit_max, fit_x, fit_y) = hfit(energy , xdata = rf_phase)
except:
raise Exception("Fit failure")
caput(prefix + ":GET-ONCREST-VSUM-PHASE", phase_fit_max)
caput(prefix + ":GET-ONCREST-E-GAIN", energy_max)
caput(prefix + ":GET-FIT-PHASE-ARRAY", fit_x)
caput(prefix + ":GET-FIT-ENERGY-ARRAY", fit_y)
phase_min, phase_max = min(rf_phase), max(rf_phase)
if not (phase_min <= phase_fit_max <= phase_max):
raise Exception("Fit maximum outside scan range")
rf_phase_var.write(phase_fit_max)
time.sleep(lat)
ampl = rf_ampl_rbk.read()