This commit is contained in:
root
2019-03-26 11:40:34 +01:00
parent c98b03760f
commit 1f4edcbc88
14 changed files with 5878 additions and 35 deletions

View File

@@ -1,4 +1,4 @@
#Wed Feb 06 10:42:47 CET 2019
#Mon Mar 18 10:44:11 CET 2019
autoSaveScanData=true
commandExecutionEvents=false
createSessionFiles=false
@@ -13,6 +13,7 @@ dataServerPort=-1
depthDimension=0
devicePoolFile={config}/devices.properties
deviceUpdateStrategyFile={config}/update.properties
hideServerMessages=false
hostName=
instanceName=OP
logDaysToLive=30

View File

@@ -1,20 +1,20 @@
#Mon Mar 04 13:47:17 CET 2019
#Tue Mar 26 09:08:16 CET 2019
\u0000=
\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
colormap=Flame
colormapAutomatic=true
colormap=Blue
colormapAutomatic=false
colormapLogarithmic=false
colormapMax=18000.0
colormapMin=0.0
colormapMax=107.0
colormapMin=88.0
flipHorizontally=false
flipVertically=false
grayscale=false
imageHeight=1024
imageWidth=1280
imageHeight=494
imageWidth=659
invert=false
regionStartX=1
regionStartY=1
regionStartX=0
regionStartY=0
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=-1
@@ -25,10 +25,10 @@ rotation=0.0
rotationCrop=false
scale=1.0
serverURL=null
spatialCalOffsetX=-50.03903200624512
spatialCalOffsetY=-50.048780487804876
spatialCalScaleX=-1.0
spatialCalScaleY=-1.0
spatialCalOffsetX=-640.3335070349141
spatialCalOffsetY=-512.4270225187656
spatialCalScaleX=-8.4375
spatialCalScaleY=-8.49609375
spatialCalUnits=null
t=
transpose=false

View File

@@ -1,9 +1,9 @@
#Fri Mar 01 00:21:13 CET 2019
#Tue Mar 19 14:50:41 CET 2019
colormap=Flame
colormapAutomatic=true
colormapLogarithmic=false
colormapMax=10000.0
colormapMin=0.0
colormapMax=1356.0
colormapMin=6.0
flipHorizontally=false
flipVertically=false
grayscale=false
@@ -21,9 +21,9 @@ roiY=0
rotation=0.0
rotationCrop=false
scale=1.0
spatialCalOffsetX=-415.6307007415859
spatialCalOffsetY=-213.43204623518318
spatialCalScaleX=-15.057748904706497
spatialCalScaleY=-11.764705882352942
spatialCalOffsetX=-131.0
spatialCalOffsetY=-84.55263143586453
spatialCalScaleX=-15.559673602764423
spatialCalScaleY=-11.299434862638774
spatialCalUnits=null
transpose=false

View File

@@ -1,4 +1,4 @@
#Thu Feb 28 23:25:52 CET 2019
#Mon Mar 18 14:16:14 CET 2019
colormap=Flame
colormapAutomatic=true
colormapLogarithmic=false

View File

@@ -35,6 +35,7 @@
<Component id="panelScanPars" max="32767" attributes="0"/>
<Component id="panelBeamPars" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel1" max="32767" attributes="0"/>
<Component id="jPanel2" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@@ -54,9 +55,11 @@
<Component id="panelScanPars" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelBeamPars" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="12" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonStart" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonAbort" alignment="3" min="-2" max="-2" attributes="0"/>
@@ -112,6 +115,11 @@
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Component id="spinnerStep" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="labelLatency1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Component id="spinnerThreshold" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
@@ -145,6 +153,11 @@
<Component id="spinnerLatency" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelLatency" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="spinnerThreshold" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelLatency1" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
@@ -229,6 +242,21 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerThreshold">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="500.0" maximum="10000.0" minimum="0.0" numberType="java.lang.Double" stepSize="100.0" type="number"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[64, 20]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="labelLatency1">
<Properties>
<Property name="text" type="java.lang.String" value="Threshold:"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelBeamPars">
@@ -334,7 +362,7 @@
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Set Phase"/>
<TitledBorder title="Set RF Phase"/>
</Border>
</Property>
</Properties>
@@ -394,5 +422,69 @@
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel2">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Set Laser Delay "/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonSetDelay" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="textOffset" min="-2" pref="69" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textOffset" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="buttonSetDelay" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="Offset:"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonSetDelay">
<Properties>
<Property name="text" type="java.lang.String" value="Set"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonSetDelayActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="textOffset">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@@ -7,6 +7,7 @@ import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import ch.psi.utils.swing.SwingUtils;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JSpinner;
/**
@@ -35,9 +36,11 @@ public class GunEnergyScan extends Panel {
spinnerStep.setEnabled(enabled);
spinnerSamples.setEnabled(enabled);
spinnerLatency.setEnabled(enabled);
spinnerThreshold.setEnabled(enabled);
spinnerDispersion.setEnabled(enabled);
spinnerEnergy.setEnabled(enabled);
buttonPhaseSet.setEnabled(enabled && !textRefPhase.getText().trim().isEmpty());
buttonSetDelay.setEnabled(enabled && !textOffset.getText().trim().isEmpty());
}
@Override
@@ -64,6 +67,8 @@ public class GunEnergyScan extends Panel {
labelLatency = new javax.swing.JLabel();
spinnerLatency = new javax.swing.JSpinner();
spinnerStop = new javax.swing.JSpinner();
spinnerThreshold = new javax.swing.JSpinner();
labelLatency1 = new javax.swing.JLabel();
panelBeamPars = new javax.swing.JPanel();
spinnerDispersion = new javax.swing.JSpinner();
labelEnergy = new javax.swing.JLabel();
@@ -76,6 +81,10 @@ public class GunEnergyScan extends Panel {
jLabel1 = new javax.swing.JLabel();
buttonPhaseSet = new javax.swing.JButton();
textRefPhase = new javax.swing.JTextField();
jPanel2 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
buttonSetDelay = new javax.swing.JButton();
textOffset = new javax.swing.JTextField();
setPreferredSize(new java.awt.Dimension(737, 445));
@@ -107,6 +116,11 @@ public class GunEnergyScan extends Panel {
spinnerStop.setMinimumSize(new java.awt.Dimension(53, 20));
spinnerStop.setPreferredSize(new java.awt.Dimension(64, 20));
spinnerThreshold.setModel(new javax.swing.SpinnerNumberModel(500.0d, 0.0d, 10000.0d, 100.0d));
spinnerThreshold.setPreferredSize(new java.awt.Dimension(64, 20));
labelLatency1.setText("Threshold:");
javax.swing.GroupLayout panelScanParsLayout = new javax.swing.GroupLayout(panelScanPars);
panelScanPars.setLayout(panelScanParsLayout);
panelScanParsLayout.setHorizontalGroup(
@@ -133,7 +147,11 @@ public class GunEnergyScan extends Panel {
.addGroup(panelScanParsLayout.createSequentialGroup()
.addComponent(labelStep)
.addGap(2, 2, 2)
.addComponent(spinnerStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(spinnerStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(panelScanParsLayout.createSequentialGroup()
.addComponent(labelLatency1)
.addGap(2, 2, 2)
.addComponent(spinnerThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
panelScanParsLayout.setVerticalGroup(
@@ -159,6 +177,10 @@ public class GunEnergyScan extends Panel {
.addGroup(panelScanParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spinnerLatency, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelLatency))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelScanParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spinnerThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelLatency1))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
@@ -219,7 +241,7 @@ public class GunEnergyScan extends Panel {
}
});
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Set Phase"));
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Set RF Phase"));
jLabel1.setText("Ref phase:");
@@ -261,6 +283,48 @@ public class GunEnergyScan extends Panel {
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Set Laser Delay "));
jLabel2.setText("Offset:");
buttonSetDelay.setText("Set");
buttonSetDelay.setEnabled(false);
buttonSetDelay.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonSetDelayActionPerformed(evt);
}
});
textOffset.setEditable(false);
textOffset.setHorizontalAlignment(javax.swing.JTextField.CENTER);
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonSetDelay)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textOffset, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(textOffset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(buttonSetDelay)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -277,7 +341,8 @@ public class GunEnergyScan extends Panel {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(panelScanPars, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(panelBeamPars, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 528, Short.MAX_VALUE)
.addContainerGap())
@@ -292,9 +357,11 @@ public class GunEnergyScan extends Panel {
.addComponent(panelScanPars, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelBeamPars, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonStart)
.addComponent(buttonAbort))))
@@ -314,17 +381,22 @@ public class GunEnergyScan extends Panel {
parameters.add(spinnerLatency.getValue());
parameters.add((Double) spinnerDispersion.getValue());
parameters.add((Double) spinnerEnergy.getValue());
parameters.add(plot);
parameters.add(plot);
parameters.add(spinnerThreshold.getValue());
try {
runAsync("RFscan/GunEnergyScan", parameters).handle((ret, ex) -> {
if (ex != null) {
getLogger().info("Exception executing scan: " + ex);
showException((Exception) ex);
} else {
List list = (List)ret;
try{
double phase = ((Number)ret).doubleValue();
double phase = ((Number)list.get(0)).doubleValue();
double offset = ((Number)list.get(1)).doubleValue();
textRefPhase.setText(String.format("%1.2f",phase));
textOffset.setText(String.format("%1.2f",offset));
buttonPhaseSet.setEnabled(true);
buttonSetDelay.setEnabled(true);
} catch (Exception e) {
showException(e);
}
@@ -354,7 +426,7 @@ public class GunEnergyScan extends Panel {
parameters.add(plot);
try {
//How to get a callback on the end of execution
runAsync("RFscan/GunEnergyScanSet", parameters).handle((ret, ex) -> {
runAsync("RFscan/GunEnergyScanRfSet", parameters).handle((ret, ex) -> {
if (ex != null) {
getLogger().info("Exception executing scan: " + ex);
showException((Exception) ex);
@@ -370,15 +442,45 @@ public class GunEnergyScan extends Panel {
}
}//GEN-LAST:event_buttonPhaseSetActionPerformed
private void buttonSetDelayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetDelayActionPerformed
try {
if (!textOffset.getText().isEmpty()){
Double offset = Double.parseDouble(textOffset.getText());
ArrayList parameters = new ArrayList();
parameters.add(offset);
parameters.add(plot);
try {
//How to get a callback on the end of execution
runAsync("RFscan/GunEnergyScanLasSet", parameters).handle((ret, ex) -> {
if (ex != null) {
getLogger().info("Exception executing scan: " + ex);
showException((Exception) ex);
}
return ret;
});
} catch (Exception ex) {
showException(ex);
}
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonSetDelayActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonAbort;
private javax.swing.JButton buttonPhaseSet;
private javax.swing.JButton buttonSetDelay;
private javax.swing.JButton buttonStart;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JLabel labelDispersion;
private javax.swing.JLabel labelEnergy;
private javax.swing.JLabel labelLatency;
private javax.swing.JLabel labelLatency1;
private javax.swing.JLabel labelSamples;
private javax.swing.JLabel labelStart;
private javax.swing.JLabel labelStep;
@@ -393,6 +495,8 @@ public class GunEnergyScan extends Panel {
private javax.swing.JSpinner spinnerStart;
private javax.swing.JSpinner spinnerStep;
private javax.swing.JSpinner spinnerStop;
private javax.swing.JSpinner spinnerThreshold;
private javax.swing.JTextField textOffset;
private javax.swing.JTextField textRefPhase;
// End of variables declaration//GEN-END:variables
}

1180
plugins/ScreenPanel4.form Normal file

File diff suppressed because it is too large Load Diff

4218
plugins/ScreenPanel4.java Normal file

File diff suppressed because it is too large Load Diff

BIN
plugins/resources/Scale.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

View File

@@ -0,0 +1,166 @@
import ch.psi.pshell.epics.Positioner as Positioner
dry_run = False
do_elog = True
is_panel = get_exec_pars().source != CommandSource.ui #must be check before run
USE_SCREEN_PANEL = False
run("CPython/wrapper")
#Parameters
if is_panel:
start = args[0]
stop = args[1]
step = args[2]
nb = int(args[3])
lat = args[4]
disp = args[5]
p0 = args[6]
plt = args[7]
thr = args[8]
else:
start = 85.0
stop = 95.0
step = 0.5
nb = 3
lat = 0.15
disp = -0.387
p0 = 7.1
plt = plot(None, title="Output")[0]
thr = 500
A = p0 / disp / 1e6
B = p0
#Plot setup
plt.clear()
plt.removeMarker(None)
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Momentum", Color.red))
plt.addSeries(LinePlotErrorSeries("Momentum Spread", Color.yellow, 2))
plt.getAxis(plt.AxisId.X).setLabel("Gun Beam Phase (deg)")
plt.getAxis(plt.AxisId.Y).setLabel("Momentum (MeV/c)")
plt.getAxis(plt.AxisId.Y2).setLabel("Momentum Spread (MeV/c)")
plt.setLegendVisible(True)
#Creating Phase positioner
if dry_run:
phase = Positioner("Gun Phase", "SINEG01-RSYS:SET-BEAM-PHASE-SIM", "SINEG01-RSYS:SET-BEAM-PHASE-SIM")
camera_name = "simulation"
else:
phase = Positioner("Gun Phase", "SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:GET-BEAM-PHASE")
camera_name = "SINBD01-DSCR010"
phase.config.minValue = -90.0
phase.config.maxValue = 360.0
phase.config.precision = 4
phase.config.resolution = 0.5
phase.config.rotation = True
phase.config.save()
phase.initialize()
phase0 = phase.read() % 360
#Camera setup
if USE_SCREEN_PANEL:
cam_server.start(camera_name+"_sp1", True) #True for shared pipeline
else:
cam_server.start(camera_name)
wait_cam_server_message()
x = cam_server.stream.getChild("x_center_of_mass")
dx = cam_server.stream.getChild("x_rms")
cam_server.setThreshold(thr)
cam_server.setBackgroundSubtraction(False)
#Creating averagers
x_averager = create_averager(x, nb, -1) # -1 event based, waits for the next value
dx_averager = create_averager(dx, nb, -1)
dx_averager.monitored = True # not blocking, will return last nb values
#Record callback: uptate of output plot
def after_sample(record, scan):
global A, B, plt
x_pos_mean, x_pos_stdev = record.values[0].mean, record.values[0].stdev
x_width_mean, x_width_stdev = record.values[1].mean, record.values[1].stdev
p_mean, p_stdev = A * x_pos_mean + B, abs(A) * x_pos_stdev
dp_mean, dp_stdev = abs(A) * x_width_mean, abs(A) * x_width_stdev
phase = ((record.positions[0] + 90) % 360) - 90 if start < 0 else record.positions[0]
plt.getSeries(0).appendData(phase, p_mean, p_stdev)
plt.getSeries(1).appendData(phase, dp_mean, dp_stdev)
#The scan loop
try:
phase.write(start)
time.sleep(2.0)
r = lscan(phase, [x_averager, dx_averager], start, stop, step , latency=lat, after_read = after_sample)
finally:
phase.write(phase0)
phase.close()
cam_server.stop() # stops cam_server but does not close it cam_server is a global object
ph = r.getPositions(0)
if start < 0:
ph = [((val + 90) % 360) -90 for val in ph ]
p = [A * val.mean + B for val in r.getReadable(0)]
dp = [abs(A) * val.mean for val in r.getReadable(1)]
#Fitting and plotting
try:
i = p.index(max(p))
a, b = max(i-6, 0), min(i+6, len(p))
(ph_p_max, p_max, ph_p_fit, p_fit, p_R2) = extremum(ph[a:b], p[a:b])
i = dp.index(min(dp))
a, b = max(i-6, 0), min(i+6, len(dp))
(ph_dp_min, dp_min, ph_dp_fit, dp_fit, dp_R2) = extremum(ph[a:b], dp[a:b])
plt.addSeries(LinePlotErrorSeries("Momentum Fit", plt.getSeries(0).color))
plt.addSeries(LinePlotErrorSeries("Momentum Spread Fit", plt.getSeries(1).color, 2))
plt.getSeries(2).setData(ph_p_fit, p_fit)
plt.getSeries(3).setData(ph_dp_fit, dp_fit)
plt.getSeries(2).setPointsVisible(False)
plt.getSeries(3).setPointsVisible(False)
plt.addMarker(ph_p_max, plt.AxisId.X, "%3.2f" % ph_p_max, plt.getSeries(0).color)
plt.addMarker(ph_dp_min, plt.AxisId.X, "%3.2f" % ph_dp_min, plt.getSeries(1).color)
except:
raise Exception("Fit failure")
# Calculating laser offset in deg
las_offset_deg = ph_dp_min - 90.0
#Saving metadata
save_dataset( "scan 1/processed/p" , p )
set_attribute( "scan 1/processed/p" , "p max" , p_max )
set_attribute( "scan 1/processed/p" , "p max phase" , ph_p_max )
set_attribute( "scan 1/processed/p" , "p fit R2" , p_R2 )
set_attribute( "scan 1/processed/p" , "Unit" , "MeV" )
save_dataset( "scan 1/processed/dp" , dp )
set_attribute( "scan 1/processed/dp" , "dp min" , dp_min )
set_attribute( "scan 1/processed/dp" , "dp min phase" , ph_dp_min )
set_attribute( "scan 1/processed/dp" , "dp fit R2" , dp_R2 )
set_attribute( "scan 1/processed/dp" , "Unit" , "MeV" )
#Elog entry
if do_elog:
if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes":
title = "Gun Energy Scan"
Laser = str(caget("SLG-LGEN:WHICH_LASER"))
log_msg = "Data file: " + get_exec_pars().path + "\n\n"
log_msg = log_msg + "Laser: " + Laser + "\n"
if Laser == "Alcor":
log_msg = log_msg + "Energy plate Alcor: %0.2f" % caget("SLGTH01-LMRM-M074:MOT.RBV") + " deg \n"
elif Laser == "Jaguar":
log_msg = log_msg + "Energy plate Jaguar: %0.2f" % caget("SLGJG-LMRM-M031:MOT.RBV") + " deg \n"
elif Laser == "Both":
log_msg = log_msg + "Energy plate Alcor: %0.2f" % caget("SLGTH01-LMRM-M074:MOT.RBV") + " deg \n"
log_msg = log_msg + "Energy plate Jaguar: %0.2f" % caget("SLGJG-LMRM-M031:MOT.RBV") + " deg \n"
if caget("SLGTV-LMTO-M053:MOT-ACT-POS") == "IRIS":
log_msg = log_msg + "Collimator: IRIS %0.2f" % caget("SLGTV-LAPP:SIZE-GET") + " mm \n"
else:
log_msg = log_msg + "Collimator: " + str(caget("SLGTV-LMTO-M053:MOT-ACT-POS")) + "\n"
log_msg = log_msg + "Charge B1: %0.2f" % caget("SINEG01-DICT215:B1_CHARGE-OP") + " pC at %0.2f" % phase0 + " deg beam phase\n"
log_msg = log_msg + "Charge B2: %0.2f" % caget("SINEG01-DICT215:B2_CHARGE-OP") + " pC at %0.2f" % phase0 + " deg beam phase\n"
log_msg = log_msg + "p-max: %0.2f" % p_max + " MeV/c at %0.2f" % ph_p_max + " deg beam phase\n"
log_msg = log_msg + "dp-min: %0.4f" % dp_min + " MeV/c at %0.2f" % ph_dp_min + " deg beam phase\n"
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
file_name = os.path.abspath(get_context().setup.getContextPath() + "/GunEnergyScanPlot.png")
plt.saveSnapshot(file_name , "png")
elog(title, log_msg, [file_name,])
set_return([ph_dp_min, las_offset_deg])

View File

@@ -0,0 +1,38 @@
dry_run = False
do_elog = True
if get_exec_pars().source == CommandSource.ui:
las_offset_deg = 0.0
plt = None
else:
las_offset_deg = args[0]
plt = args[1]
Laser = caget("SLG-LGEN:WHICH_LASER")
cur_las_delay = 0.0
if Laser == "Alcor":
cur_las_delay = caget("SLGOS01-TSPL-ALC:CURR_DELTA_T")
elif Laser == "Jaguar":
cur_las_delay = caget("SLGJG-TSPL-JAG:CURR_DELTA_T")
new_las_delay = cur_las_delay - 333.467 * las_offset_deg / 360.0
if not dry_run:
if Laser == "Alcor":
caput("SLGOS01-TSPL-ALC:NEW_DELTA_T" , new_las_delay )
caput("SLGOS01-TSPL-ALC:SET_NEW_PHASE.PROC" , 1 )
elif Laser == "Jaguar":
caput("SLGJG-TSPL-JAG:NEW_DELTA_T" , new_las_delay )
caput("SLGJG-TSPL-JAG:SET_NEW_PHASE.PROC" , 1 )
if do_elog:
title = "Set laser delay"
log_msg = ""
if Laser == "Alcor":
log_msg = "SLGOS01-TSPL-ALC:NEW_DELTA_T: %12.4f" % new_las_delay + " ps (was %12.4f" % cur_las_delay + " ps)\n"
elif Laser == "Jaguar":
log_msg = "SLGJG-TSPL-JAG:NEW_DELTA_T: %12.4f" % new_las_delay + " ps (was %12.4f" % cur_las_delay + " ps)\n"
attachments = []
if plt is not None:
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
file_name = os.path.abspath(get_context().setup.getContextPath() + "/GunEnergyScanLasSet.png")
plt.saveSnapshot(file_name , "png")
attachments = [file_name]
elog(title, log_msg, attachments)
show_message("Success setting laser delay")

View File

@@ -65,10 +65,10 @@ else:
wait_cam_server_message()
x = cam_server.stream.getChild("x_center_of_mass")
dx = cam_server.stream.getChild("x_rms")
cam_server.setThreshold(500)
cam_server.setThreshold(150)
#cam_server.captureBackground(10) #Capturing background
cam_server.setBackgroundSubtraction(False)
#cam_server.setRoi([144,482,1431,706]) #X, Y, W, H # something wrong thereto be fixed
#cam_server.setRoi([144,482,1431,706]) #X, Y, W, H # something wrong there to be fixed
#Creating averagers
x_averager = create_averager(x, nb, -1) # -1 event based, waits for the next value

View File

@@ -0,0 +1,25 @@
dry_run = False
do_elog = True
if get_exec_pars().source == CommandSource.ui:
bph_ref_user = 90.0
plt = None
else:
bph_ref_user = args[0]
plt = args[1]
phase_offset_old = caget("SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE")
phase_offset_new = phase_offset_old - (bph_ref_user - 90.0)
if not dry_run:
caput("SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE" , phase_offset_new )
caput("SINEG01-RSYS:CMD-LOAD-CALIB-BEAM" , 1 )
if do_elog:
title = "Set gun phase"
log_msg = "SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE: %8.2f" % phase_offset_new + " deg (was %8.2f" % phase_offset_old + " deg)\n"
attachments = []
if plt is not None:
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
file_name = os.path.abspath(get_context().setup.getContextPath() + "/GunEnergyScanRfSet.png")
plt.saveSnapshot(file_name , "png")
attachments = [file_name]
elog(title, log_msg, attachments)
show_message("Success setting phase reference")

View File

@@ -0,0 +1,19 @@
run("Devices/Elements")
blms = get_blms() #["S10BC01-DBLM065"]
plots = []
names = []
for b in blms:
try:
b = b + ":LOSS_SIGNAL_RAW"
plots.append(caget(b))
names.append (b)
except:
print "Error reading " + str(b)
plot(plots, names)
#plots = get_plot_snapshots()
#print plots
##elog("BLM PMT-waveform", "", plots)