GAP = "SARUN03-UPHS060" SAMPLES = 10 TOLERANCE = 0.01 TIMEOUT = 10.0 #intensity = Channel("SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US", alias = "gas det") #gap = Channel(GAP + ":GAP_SP", alias = "gap") readout = Channel(GAP + ":GAP") av = create_averager("ca://SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US", SAMPLES, interval =0.1, name = "gas det") def before(position, scan): caput(GAP + ":GO", 1) start = time.time() while abs(readout.read() - GAP.read()) > TOLERANCE: time.sleep(0.1) if time.time() - start > TIMEOUT: raise Exception ("Timeout waiting gap change") ret = lscan ("ca://" + GAP + ":GAP_SP?name=gap", av, 14, 16, 20, latency=20.0, before_read=before) #run("CPython/wrapper") #xdata = ret.getPositions(0) #ydata = ret.getReadable(0) #(fit_amplitude, fit_phase_deg, fit_offset, ph_crest, fit_x, fit_y) = hfitoff(ydata , xdata) #print fit_amplitude, fit_phase_deg, fit_offset #plt = get_plots()[0] #if plt is not None: # plt.addSeries(LinePlotErrorSeries("fit")) # plt.getSeries(1).setData(fit_x, fit_y) # plt.getSeries(1).setPointsVisible(False) # plt.setLegendVisible(True)