Closedown
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
ShottkyScan.java=enabled
|
||||
GunScan.java=disabled
|
||||
ShottkyScan.java=disabled
|
||||
Correlation.java=disabled
|
||||
Cameras.java=disabled
|
||||
ScreenPanel.java=disabled
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="linePlotJFree1" pref="393" max="32767" attributes="0"/>
|
||||
<Component id="plot" pref="393" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
@@ -37,7 +37,7 @@
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jPanel1" max="32767" attributes="0"/>
|
||||
<Component id="linePlotJFree1" pref="383" max="32767" attributes="0"/>
|
||||
<Component id="plot" pref="383" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
@@ -212,7 +212,7 @@
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="ch.psi.pshell.plot.LinePlotJFree" name="linePlotJFree1">
|
||||
<Component class="ch.psi.pshell.plot.LinePlotJFree" name="plot">
|
||||
<Properties>
|
||||
<Property name="title" type="java.lang.String" value=""/>
|
||||
</Properties>
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
* Copyright (c) 2014-2017 Paul Scherrer Institute. All rights reserved.
|
||||
*/
|
||||
|
||||
import ch.psi.pshell.plot.LinePlotSeries;
|
||||
import ch.psi.pshell.plot.Plot;
|
||||
import ch.psi.pshell.scan.Scan;
|
||||
import ch.psi.pshell.scan.ScanListener;
|
||||
import ch.psi.pshell.scan.ScanRecord;
|
||||
import ch.psi.pshell.ui.Panel;
|
||||
import ch.psi.pshell.ui.Plugin;
|
||||
import ch.psi.utils.State;
|
||||
@@ -13,9 +18,12 @@ import java.util.logging.Logger;
|
||||
*
|
||||
*/
|
||||
public class ShottkyScan extends Panel {
|
||||
|
||||
LinePlotSeries series = new LinePlotSeries("Values");
|
||||
|
||||
public ShottkyScan() {
|
||||
initComponents();
|
||||
plot.getAxis(Plot.AxisId.X).setLabel("Phase");
|
||||
plot.getAxis(Plot.AxisId.Y).setLabel("Charge");
|
||||
}
|
||||
|
||||
//Overridable callbacks
|
||||
@@ -34,7 +42,7 @@ public class ShottkyScan extends Panel {
|
||||
spinnerStep.setEnabled(buttonStart.isEnabled());
|
||||
spinnerSamples.setEnabled(buttonStart.isEnabled());
|
||||
spinnerLatency.setEnabled(buttonStart.isEnabled());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,6 +54,43 @@ public class ShottkyScan extends Panel {
|
||||
@Override
|
||||
protected void doUpdate() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
getContext().addScanListener(scanListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
getContext().removeScanListener(scanListener);
|
||||
super.onStop();
|
||||
|
||||
}
|
||||
|
||||
|
||||
ScanListener scanListener = new ScanListener() {
|
||||
@Override
|
||||
public void onScanStarted(Scan scan, String plotTitle) {
|
||||
if ("ShottkyScan".equals(getContext().getExecutionPars().getName())){
|
||||
plot.removeMarker(null);
|
||||
series.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewRecord(Scan scan, ScanRecord record) {
|
||||
if ("ShottkyScan".equals(getContext().getExecutionPars().getName())){
|
||||
series.appendData((Double)record.getPositions()[0], (Double)record.getValues()[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScanEnded(Scan scan, Exception ex) {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
@@ -64,7 +109,7 @@ public class ShottkyScan extends Panel {
|
||||
spinnerSamples = new javax.swing.JSpinner();
|
||||
jLabel4 = new javax.swing.JLabel();
|
||||
spinnerStart = new javax.swing.JSpinner();
|
||||
linePlotJFree1 = new ch.psi.pshell.plot.LinePlotJFree();
|
||||
plot = new ch.psi.pshell.plot.LinePlotJFree();
|
||||
|
||||
buttonStart.setText("Start");
|
||||
buttonStart.addActionListener(new java.awt.event.ActionListener() {
|
||||
@@ -167,7 +212,7 @@ public class ShottkyScan extends Panel {
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
linePlotJFree1.setTitle("");
|
||||
plot.setTitle("");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
@@ -182,7 +227,7 @@ public class ShottkyScan extends Panel {
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(linePlotJFree1, javax.swing.GroupLayout.DEFAULT_SIZE, 393, Short.MAX_VALUE)
|
||||
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 393, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
@@ -194,7 +239,7 @@ public class ShottkyScan extends Panel {
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(linePlotJFree1, javax.swing.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE))
|
||||
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE))
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(buttonStart)
|
||||
@@ -248,7 +293,7 @@ public class ShottkyScan extends Panel {
|
||||
private javax.swing.JLabel jLabel4;
|
||||
private javax.swing.JLabel jLabel5;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private ch.psi.pshell.plot.LinePlotJFree linePlotJFree1;
|
||||
private ch.psi.pshell.plot.LinePlotJFree plot;
|
||||
private javax.swing.JSpinner spinnerLatency;
|
||||
private javax.swing.JSpinner spinnerSamples;
|
||||
private javax.swing.JSpinner spinnerStart;
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
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")
|
||||
|
||||
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()
|
||||
#st.start(True)
|
||||
q = Channel("SINEG01-DICT215:B1_CHARGE-SIM", type = 'd', alias='ICT-Q')
|
||||
|
||||
try:
|
||||
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)]
|
||||
finally:
|
||||
phase.close()
|
||||
q.close()
|
||||
#st.close()
|
||||
|
||||
# Here the user needs to pick a phase as reference phase (onset of charge emission)
|
||||
phase_ref = 80.0
|
||||
phase_offset = - phase_ref
|
||||
caput("SINEG01-RSYS:CALC-VSUM-PHASE-OFFSET", phase_offset)
|
||||
@@ -1,76 +0,0 @@
|
||||
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")
|
||||
|
||||
disp = caget("SINBD01-DSCR010:DISPERSION") # to be implemented in OM soft channels
|
||||
energy0 = caget("SINBD01-DSCR010:ENERGY")
|
||||
|
||||
phase = ControlledVariable("Phase", "SINEG01-RSYS:SET-VSUM-PHASE", "SINEG01-RSYS:GET-VSUM-PHASE")
|
||||
phase.config.minValue =-45.0
|
||||
phase.config.maxValue = 360.0
|
||||
phase.config.resolution = 0.5
|
||||
phase.initialize()
|
||||
|
||||
V = Channel("SINEG01-RSYS:GET-VSUM-AMPLT-SIM", type = 'd', alias='Amplitude Readback')
|
||||
P = Channel("SINEG01-RSYS:GET-KLY-POWER-SIM", type = 'd', alias='Power Readback')
|
||||
|
||||
#st = Stream("camstream", dispatcher)
|
||||
#x = st.addScalar("SCR-X", scr_ch + ":camtool.pipeline.x_stats_gr.com_egu", 1, 0)
|
||||
#dx = st.addScalar("SCR-DX", scr_ch + ":camtool.pipeline.x_stats_gr.rms_egu", 1, 0)
|
||||
#st1.initialize()
|
||||
|
||||
#camtool = Camtool(url)
|
||||
#camtool.startPipeline(camera_name)
|
||||
#camtool.startReceiver()
|
||||
#x = camtool.getValue("x_fit_mean")
|
||||
|
||||
|
||||
|
||||
try:
|
||||
xb = create_averager(x, nb, 0.100)
|
||||
dxb = create_averager(dx, nb, 0.100)
|
||||
r = lscan(phase, [xb, dxb], start, stop, step , latency=lat, after_read = after)
|
||||
rf_phase = r.getPositions(0)
|
||||
E = [val.mean/1000.0/disp*energy0 for val in r.getReadable(0)]
|
||||
dE = [val.mean/1000.0/disp*energy0 for val in r.getReadable(1)]
|
||||
caput("SINEG01-RSYS:GET-PHASE-ARRAY", to_array(rf_phase,'d'))
|
||||
caput("SINEG01-RSYS:GET-CHARGE-ARRAY", to_array(charge, '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("SINEG01-RSYS:GET-ONCREST-VSUM-PHASE", phase_fit_max)
|
||||
caput("SINEG01-RSYS:GET-ONCREST-E-GAIN", energy_max)
|
||||
caput("SINEG01-RSYS:GET-FIT-PHASE-ARRAY", fit_x)
|
||||
caput("SINEG01-RSYS: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")
|
||||
phase.write(phase_fit_max)
|
||||
time.sleep(lat)
|
||||
Ampl = V.read()
|
||||
Power = P.read()
|
||||
caput("SINEG01-RSYS:GET-ONCREST-VSUM-AMPLT", Ampl)
|
||||
caput("SINEG01-RSYS:GET-ONCREST-KLY-POWER", Power)
|
||||
finally:
|
||||
phase.close()
|
||||
V.close()
|
||||
P.close()
|
||||
st.close()
|
||||
|
||||
print ("------------------------------------")
|
||||
print ("Valid fit")
|
||||
|
||||
energy_gain = energy_max
|
||||
phase_offset = 90 - phase_fit_max
|
||||
amplitude_scale = energy_gain / Ampl
|
||||
power_scale = Power / math.pow(Ampl,2)
|
||||
|
||||
caput("SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE", phase_offset)
|
||||
caput("SINEG01-RSYS:SET-VSUM-AMPLT-SCALE", amplitude_scale)
|
||||
caput("SINEG01-RSYS:SET-VOLT-POWER-SCALE", power_scale)
|
||||
Reference in New Issue
Block a user