From 7ae0abd3a048eba42b98b6a87b458134547a4cef Mon Sep 17 00:00:00 2001 From: sfop Date: Mon, 12 Jun 2017 11:46:48 +0200 Subject: [PATCH] Closedown --- devices/CurrentCamera.properties | 10 ++-- devices/camtool.properties | 10 ++-- plugins/GunScan.java | 1 + plugins/SchottkyScan.form | 2 +- plugins/SchottkyScan.java | 8 +++- script/RFscan/GunScan.py | 2 +- script/RFscan/SchottkyScan.py | 82 ++++++++++++++++---------------- 7 files changed, 59 insertions(+), 56 deletions(-) diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties index 8106071..ff73cb4 100644 --- a/devices/CurrentCamera.properties +++ b/devices/CurrentCamera.properties @@ -1,4 +1,4 @@ -#Mon Jun 12 09:33:46 CEST 2017 +#Mon Jun 12 11:46:08 CEST 2017 colormap=Flame colormapAutomatic=true colormapMax=137.0 @@ -21,9 +21,9 @@ rotation=0.0 rotationCrop=false scale=1.0 serverURL=localhost\:10000 -spatialCalOffsetX=-50.03909304143862 -spatialCalOffsetY=-50.048875855327466 -spatialCalScaleX=-1.0 -spatialCalScaleY=-1.0 +spatialCalOffsetX=-1057.4895329398094 +spatialCalOffsetY=-1420.5549062527236 +spatialCalScaleX=-8.510638153514359 +spatialCalScaleY=-8.235817137431614 spatialCalUnits=mm transpose=false diff --git a/devices/camtool.properties b/devices/camtool.properties index ec2c0d9..5d3d1e8 100644 --- a/devices/camtool.properties +++ b/devices/camtool.properties @@ -1,4 +1,4 @@ -#Fri Jun 09 16:25:46 CEST 2017 +#Mon Jun 12 11:22:00 CEST 2017 colormap=Flame colormapAutomatic=true colormapMax=578.797 @@ -18,9 +18,9 @@ roiY=0 rotation=0.0 rotationCrop=false scale=1.0 -spatialCalOffsetX=-50.03909304143862 -spatialCalOffsetY=-50.048875855327466 -spatialCalScaleX=-1.0 -spatialCalScaleY=-1.0 +spatialCalOffsetX=-861.4939970777481 +spatialCalOffsetY=-820.4883730911062 +spatialCalScaleX=-18.90359092620482 +spatialCalScaleY=-19.37984500632817 spatialCalUnits=mm transpose=false diff --git a/plugins/GunScan.java b/plugins/GunScan.java index 63d64de..b6eb8b7 100644 --- a/plugins/GunScan.java +++ b/plugins/GunScan.java @@ -328,6 +328,7 @@ public class GunScan extends Panel { runAsync("RFscan/GunScan", parameters).handle((ret, ex) -> { if (ex != null) { getLogger().info("Exception executing scan: " + ex); + showException((Exception) ex); } else { } diff --git a/plugins/SchottkyScan.form b/plugins/SchottkyScan.form index 0120c53..f545305 100644 --- a/plugins/SchottkyScan.form +++ b/plugins/SchottkyScan.form @@ -76,7 +76,7 @@ - + diff --git a/plugins/SchottkyScan.java b/plugins/SchottkyScan.java index c5e64d0..3d955db 100644 --- a/plugins/SchottkyScan.java +++ b/plugins/SchottkyScan.java @@ -17,6 +17,7 @@ import ch.psi.utils.State; import ch.psi.utils.swing.SwingUtils; import java.awt.Color; import java.util.ArrayList; +import java.util.List; import javax.swing.JSpinner; /** @@ -25,12 +26,14 @@ import javax.swing.JSpinner; public class SchottkyScan extends Panel { LinePlotErrorSeries series = new LinePlotErrorSeries("Values"); + Double rfPhase; + Double beamPhase; public SchottkyScan() { initComponents(); plot.setStyle(LinePlotJFree.Style.ErrorY); plot.addSeries(series); - plot.getAxis(Plot.AxisId.X).setLabel("Gun Phase"); + plot.getAxis(Plot.AxisId.X).setLabel("RF Gun Phase"); plot.getAxis(Plot.AxisId.Y).setLabel("SINEG01-DICT215:B1_CHARGE"); setPersistedComponents(SwingUtils.getComponentsByType(panelPars, JSpinner.class)); } @@ -132,7 +135,7 @@ public class SchottkyScan extends Panel { } }); - panelPars.setBorder(javax.swing.BorderFactory.createTitledBorder("Parameters (beam phase)")); + panelPars.setBorder(javax.swing.BorderFactory.createTitledBorder("Parameters (RF phase)")); spinnerStep.setModel(new javax.swing.SpinnerNumberModel(5.0d, 1.0d, 90.0d, 1.0d)); @@ -319,6 +322,7 @@ public class SchottkyScan extends Panel { parameters.add(spinnerStep.getValue()); parameters.add(spinnerSamples.getValue()); parameters.add(spinnerLatency.getValue()); + parameters.add(plot); try { //How to get a callback on the end of execution runAsync("RFscan/SchottkyScan", parameters).handle((ret, ex) -> { diff --git a/script/RFscan/GunScan.py b/script/RFscan/GunScan.py index 28a63ca..fb2e08c 100644 --- a/script/RFscan/GunScan.py +++ b/script/RFscan/GunScan.py @@ -45,7 +45,7 @@ try: 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 / abs(disp)) for val in r.getReadable(1)] + dE = [abs(energy0 * (val.mean / 1e6 / disp)) for val in r.getReadable(1)] finally: phase.write(phase0) #phase.close() diff --git a/script/RFscan/SchottkyScan.py b/script/RFscan/SchottkyScan.py index d573e35..ac45208 100644 --- a/script/RFscan/SchottkyScan.py +++ b/script/RFscan/SchottkyScan.py @@ -1,63 +1,61 @@ import ch.psi.pshell.epics.ControlledVariable as ControlledVariable if get_exec_pars().source == CommandSource.ui: - start = -10.0 - stop = 180.0 + start = -30.0 + stop = 30.0 step = 5.0 - nb = 3 - lat = 0.300 + nb = 1 + lat = 0.100 + plt = None else: start = args[0] stop = args[1] step = args[2] nb = int(args[3]) lat = args[4] + plt = args[5] -bphase = ControlledVariable("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:GET-BEAM-PHASE") -bphase.config.minValue =-180.0 -bphase.config.maxValue = 360.0 -bphase.config.precision = 3 -bphase.config.resolution = 1.0 -bphase.config.save() -bphase.initialize() -st = Stream("Schottky", dispatcher) -q = st.addScalar("Charge", "SINEG01-DICT215:B1_CHARGE", 1, 0) +phase = ControlledVariable("Phase", "SINEG01-RSYS:SET-VSUM-PHASE", "SINEG01-RSYS:GET-VSUM-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() +st = Stream("ICTstream", dispatcher) +q = st.addScalar("Charge", "SINEG01-DICT215:B1_CHARGE", 1, 0) st.initialize() st.start() -rphase = Channel("SINEG01-RSYS:GET-VSUM-PHASE", type = 'd', alias = 'RF phase') -bphase0 = bphase.read() +st.waitValueChange(10000) +phase0 = phase.read() try: - q_averager = create_averager(q, nb, 0.100) - rphase_averager = create_averager(rphase, nb, 0.100) - r = lscan(bphase, (q_averager, rphase_averager), start, stop, step, latency=lat) - beamphase = r.getPositions(0) - charge = [val.mean for val in r.getReadable(0)] - chargerms = [val.stdev for val in r.getReadable(0)] - rfphase = [val.mean for val in r.getReadable(1)] - rfphaserms = [val.stdev for val in r.getReadable(1)] + qb = create_averager(q, nb, 0.100) + r = lscan(phase, (qb), start, stop, step, latency=lat) + rf_phase = r.getPositions(0) + charge = [val.mean for val in r.getReadable(0)] + chargerms = [val.stdev for val in r.getReadable(0)] finally: - bphase.write(bphase0) - bphase.close() + phase.write(phase0) + phase.close() st.close() - q.close() - rphase.close() #Setting the return value -print "MAX CHARGE = " , max(charge) -index_max = charge.index(max(charge)) -print "INDEX = " , index_max -rphase_ref = rfphase[index_max] - 80 -bphase_ref = bphase[index_max] - 80 - -set_return([rphase_ref, bphase_ref]) +x = rf_phase +y = charge +index_max = y.index(max(y)) +phase_ref = x[index_max] - 80 +""" # save the entry in the logbook -#if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes": -# log_msg = "Start: %0.1f" % start + "deg\n" -# log_msg = log_msg + "Stop: %0.1f" % stop + "deg\n" -# log_msg = log_msg + "Step: %0.1f" % nb + "deg\n" -# log_msg = log_msg + "Nb samples: %0.0f" % nb + "\n" -# log_msg = log_msg + "Latency: %0.3f" % lat + "s\n" -# log_msg = log_msg + "Data file: " + get_exec_pars().path -# elog("Schottky Scan", log_msg, get_plot_snapshots()) +if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes": + log_msg = "Start: %0.1f" % start + "deg\n" + log_msg = log_msg + "Stop: %0.1f" % stop + "deg\n" + log_msg = log_msg + "Step: %0.1f" % step + "deg\n" + log_msg = log_msg + "Nb samples: %0.0f" % nb + "\n" + log_msg = log_msg + "Latency: %0.3f" % lat + "s\n" + log_msg = log_msg + "Data file: " + get_exec_pars().path + elog("Schottky Scan", log_msg, get_plot_snapshots()) +""" + +set_return(phase_ref) \ No newline at end of file