This commit is contained in:
root
2019-08-08 10:10:28 +02:00
parent 1f4edcbc88
commit 7f88d445af
37 changed files with 6480 additions and 501 deletions

View File

@@ -0,0 +1,22 @@
#Mon Jul 01 14:54:49 CEST 2019
S10CB04-DBLM240GainWsX1=0.6
S10CB04-DBLM240_saturation=39.4
S10DI01-DBLM045GainWsX1=0.8800000000000003
S10DI01-DBLM045GainWsX2=0.8800000000000003
S10DI01-DBLM045GainWsY1=0.7600000000000002
S10DI01-DBLM045GainWsY2=0.8800000000000003
S10DI01-DBLM045_saturation=245.5
S10DI02-DBLM025GainWsY2=0.9
S20SY03-DBLM110GainWsX1=0.8800000000000003
S20SY03-DBLM110GainWsY1=0.9200000000000004
SARCL02-DBLM135GainWsX1=0.9
SARCL02-DBLM135GainWsX2=0.8600000000000003
SARCL02-DBLM135GainWsY1=0.9556983528903381
SARCL02-DBLM135_saturation=314.9
SINDI02-DBLM025GainWsX1=0.6
SINDI02-DBLM025GainWsX2=0.6
SINDI02-DBLM025GainWsY1=0.6200000000000001
SINDI02-DBLM025GainWsY2=0.7593208544828762
SINDI02-DBLM025GainWsx=0.5397269806333481
SINDI02-DBLM025_saturation=1310.3
SINDI02-DBLM085GainWsX1=0.6800000000000002

View File

@@ -1,12 +1,15 @@
#Tue Mar 26 09:08:16 CET 2019
#Wed Aug 07 14:14:42 CEST 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\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=Blue
\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=false
colormapLogarithmic=false
colormapMax=107.0
colormapMin=88.0
colormapMax=65535.0
colormapMin=39864.0
flipHorizontally=false
flipVertically=false
grayscale=false
@@ -25,10 +28,10 @@ rotation=0.0
rotationCrop=false
scale=1.0
serverURL=null
spatialCalOffsetX=-640.3335070349141
spatialCalOffsetY=-512.4270225187656
spatialCalScaleX=-8.4375
spatialCalScaleY=-8.49609375
spatialCalOffsetX=-50.01953888237593
spatialCalOffsetY=-50.032030749519535
spatialCalScaleX=-1.0
spatialCalScaleY=-1.0
spatialCalUnits=null
t=
transpose=false

View File

@@ -1,9 +1,9 @@
#Tue Mar 19 14:50:41 CET 2019
#Mon Jul 29 16:11:27 CEST 2019
colormap=Flame
colormapAutomatic=true
colormapLogarithmic=false
colormapMax=1356.0
colormapMin=6.0
colormapMax=1023.0
colormapMin=0.0
flipHorizontally=false
flipVertically=false
grayscale=false
@@ -21,9 +21,9 @@ roiY=0
rotation=0.0
rotationCrop=false
scale=1.0
spatialCalOffsetX=-131.0
spatialCalOffsetY=-84.55263143586453
spatialCalScaleX=-15.559673602764423
spatialCalScaleY=-11.299434862638774
spatialCalOffsetX=-456.693006929345
spatialCalOffsetY=-219.4442130289473
spatialCalScaleX=-14.937285913160144
spatialCalScaleY=-11.834319139832656
spatialCalUnits=null
transpose=false

View File

@@ -1,12 +1,12 @@
#Thu Dec 13 16:46:27 CET 2018
defaultSpeed=6000.0
#Mon Jul 29 18:07:39 CEST 2019
defaultSpeed=2000.0
estbilizationDelay=0
hasEnable=false
homingType=None
maxSpeed=8000.0
maxValue=68500.0
maxSpeed=2000.0
maxValue=66050.0
minSpeed=50.0
minValue=-57027.0
minValue=-50603.0
offset=0.0
precision=1
resolution=0.1

View File

@@ -1,4 +1,4 @@
#Mon Mar 18 14:16:14 CET 2019
#Thu Jun 13 16:35:07 CEST 2019
colormap=Flame
colormapAutomatic=true
colormapLogarithmic=false

View File

@@ -1,4 +1,4 @@
#Tue Dec 18 10:10:12 CET 2018
#Thu Mar 28 11:27:51 CET 2019
colormap=Flame
colormapAutomatic=true
colormapLogarithmic=false
@@ -17,9 +17,9 @@ roiY=0
rotation=0.0
rotationCrop=false
scale=1.0
spatialCalOffsetX=-50.03903200624512
spatialCalOffsetY=-50.048780487804876
spatialCalScaleX=-1.0
spatialCalScaleY=-1.0
spatialCalOffsetX=479.5320512820513
spatialCalOffsetY=366.6079295154185
spatialCalScaleX=1.0
spatialCalScaleY=1.0
spatialCalUnits=mm
transpose=false

View File

@@ -253,39 +253,40 @@ public class ScreenPanel4 extends Panel {
return (double[]) Convert.toDouble(server.getValue(name));
}
Double getServerDouble(String name, StreamValue cache) {
return (Double) Convert.toDouble(cache.__getitem__(name));
}
double[] getServerDoubleArray(String name, StreamValue cache) {
return (double[]) Convert.toDouble(cache.__getitem__(name));
}
class ImageData {
class ImageData {
ImageData() {
if (server != null) {
cache = server.getStream().take();
String prefix = goodRegion ? "gr_" : "";
x_fit_mean = getServerDouble(prefix + "x_fit_mean", cache);
y_fit_mean = getServerDouble(prefix + "y_fit_mean", cache);
x_fit_standard_deviation = getServerDouble(prefix + "x_fit_standard_deviation", cache);
y_fit_standard_deviation = getServerDouble(prefix + "y_fit_standard_deviation", cache);
x_fit_gauss_function = getServerDoubleArray(prefix + "x_fit_gauss_function", cache);
y_fit_gauss_function = getServerDoubleArray(prefix + "y_fit_gauss_function", cache);
x_profile = getServerDoubleArray("x_profile", cache);
y_profile = getServerDoubleArray("y_profile", cache);
x_center_of_mass = getServerDouble("x_center_of_mass", cache);
y_center_of_mass = getServerDouble("y_center_of_mass", cache);
x_rms = getServerDouble("x_rms", cache);
y_rms = getServerDouble("y_rms", cache);
x_fit_mean = getDouble(prefix + "x_fit_mean");
y_fit_mean = getDouble(prefix + "y_fit_mean");
x_fit_standard_deviation = getDouble(prefix + "x_fit_standard_deviation");
y_fit_standard_deviation = getDouble(prefix + "y_fit_standard_deviation");
x_fit_gauss_function = getDoubleArray(prefix + "x_fit_gauss_function");
y_fit_gauss_function = getDoubleArray(prefix + "y_fit_gauss_function");
x_profile = getDoubleArray("x_profile");
y_profile = getDoubleArray("y_profile");
x_center_of_mass = getDouble("x_center_of_mass");
y_center_of_mass = getDouble("y_center_of_mass");
x_rms = getDouble("x_rms");
y_rms = getDouble("y_rms");
if (goodRegion) {
double[] gX2 = new double[x_profile.length];
Arrays.fill(gX2, Double.NaN);
try {
double x = getServerDoubleArray("gr_x_axis", cache)[0];
double[] axis = getDoubleArray("x_axis");
gr_x_axis = getDoubleArray("gr_x_axis");
double x = gr_x_axis[0];
gr_size_x = x_fit_gauss_function.length;
//If gr axis values are not identical, calculate the index...
gr_pos_x = (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageX(x) : x);
//But prefer checking the value to avoid raounding errors
for (int i=0;i<axis.length; i++){
if (almostEqual(axis[i], x, 10e-6)){
gr_pos_x = i;
}
}
System.arraycopy(x_fit_gauss_function, 0, gX2, gr_pos_x, gr_size_x);
} catch (Exception ex) {
}
@@ -293,20 +294,29 @@ public class ScreenPanel4 extends Panel {
double[] gY2 = new double[y_profile.length];
Arrays.fill(gY2, Double.NaN);
try {
double y = getServerDoubleArray("gr_y_axis", cache)[0];
double[] axis = getDoubleArray("y_axis");
gr_y_axis = getDoubleArray("gr_y_axis");
double y = gr_y_axis[0];
gr_size_y = y_fit_gauss_function.length;
//If gr axis values are not identical, calculate the index...
gr_pos_y = (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageY(y) : y);
System.arraycopy(y_fit_gauss_function, 0, gY2, gr_pos_y, y_fit_gauss_function.length);
//But prefer checking the value to avoid raounding errors
for (int i=0;i<axis.length; i++){
if (almostEqual(axis[i], y, 10e-6)){
gr_pos_y = i;
}
}
System.arraycopy(y_fit_gauss_function, 0, gY2, gr_pos_y, gr_size_y);
} catch (Exception ex) {
}
y_fit_gauss_function = gY2;
if (slicing) {
try {
int slices = getServerDouble("slice_amount").intValue();
int slices = getDouble("slice_amount").intValue();
sliceCenters = new PointDouble[slices];
for (int i = 0; i < slices; i++) {
double x = getServerDouble("slice_" + i + "_center_x");
double y = getServerDouble("slice_" + i + "_center_y");
double x = getDouble("slice_" + i + "_center_x");
double y = getDouble("slice_" + i + "_center_y");
sliceCenters[i] = new PointDouble(x, y);
}
} catch (Exception ex) {
@@ -327,14 +337,36 @@ public class ScreenPanel4 extends Panel {
public double[] x_fit_gauss_function;
public double[] y_profile;
public double[] y_fit_gauss_function;
public double[] gr_x_axis;
public double[] gr_y_axis;
public int gr_size_x;
public int gr_pos_x;
public int gr_size_y;
public int gr_pos_y;
public PointDouble[] sliceCenters;
public StreamValue cache;
Double getDouble(String name) {
try{
return (Double) Convert.toDouble(cache.__getitem__(name));
} catch (Exception ex){
return null;
}
}
double[] getDoubleArray(String name) {
try{
return (double[]) Convert.toDouble(cache.__getitem__(name));
} catch (Exception ex){
return null;
}
}
}
public static boolean almostEqual(double a, double b, double eps){
return Math.abs(a-b)<eps;
}
class Frame extends ImageData {
Frame(Data data) {
@@ -1680,10 +1712,10 @@ public class ScreenPanel4 extends Panel {
int height = data.getHeight();
int width = data.getWidth();
int profileSize = renderer.getProfileSize();
ImageData id = null;
if ((useServerStats) && (server != null)) {
try {
ImageData id = getFrame(data);
id = getFrame(data);
if (id == null) {
return null;
}
@@ -1763,7 +1795,7 @@ public class ScreenPanel4 extends Panel {
xp[i] = (int) (((pY[i] - minProfile) / rangeProfile) * profileSize);
}
if (goodRegion && id.gr_size_x > 0) {
if (goodRegion && id.gr_size_y > 0) {
xg = Arrays.copyOfRange(xg, id.gr_pos_y, id.gr_pos_y + id.gr_size_y);
yg = Arrays.copyOfRange(yg, id.gr_pos_y, id.gr_pos_y + id.gr_size_y);
}
@@ -1920,18 +1952,14 @@ public class ScreenPanel4 extends Panel {
textPosition = new Point(textPosition.x, textPosition.y + 34);
fOv = new Overlay[]{hgaussian, vgaussian, cross, textFit};
if (goodRegion) {
try {
double[] x = getServerDoubleArray("gr_x_axis");
double[] y = getServerDoubleArray("gr_y_axis");
double x1 = x[0];
double x2 = x[x.length - 1];
double y1 = y[0];
double y2 = y[y.length - 1];
if (goodRegion && (id != null)) {
try {
double[] x = id.gr_x_axis;
double[] y = id.gr_y_axis;
Overlays.Rect goodRegionOv = new Overlays.Rect(new Pen(penFit.getColor(), 0, Pen.LineStyle.dotted));
goodRegionOv.setCalibration(renderer.getCalibration());
goodRegionOv.setAbsolutePosition(new PointDouble(x1, y1));
goodRegionOv.setAbsoluteSize(new DimensionDouble(x2 - x1, y2 - y1));
goodRegionOv.setPosition(new Point(id.gr_pos_x, id.gr_pos_y));
goodRegionOv.setSize(new Dimension(id.gr_x_axis.length, id.gr_y_axis.length));
fOv = Arr.append(fOv, goodRegionOv);
if (slicing) {
@@ -2046,6 +2074,7 @@ public class ScreenPanel4 extends Panel {
Overlay[] getUserOverlays(Data data) {
ArrayList<Overlay> ret = new ArrayList<>();
if (server != null) {
ImageData id = getFrame(data);
for (UserOverlay uo : userOverlayConfig) {
try {
Overlay ov = uo.obj;
@@ -2053,8 +2082,8 @@ public class ScreenPanel4 extends Panel {
ov.setCalibration(renderer.getCalibration());
boolean valid = false;
if (ov instanceof Overlays.Polyline) {
double[] x = (uo.channels[0].equals("null")) ? null : getServerDoubleArray(uo.channels[0]);
double[] y = (uo.channels[1].equals("null")) ? null : getServerDoubleArray(uo.channels[1]);
double[] x = (uo.channels[0].equals("null")) ? null : id.getDoubleArray(uo.channels[0]);
double[] y = (uo.channels[1].equals("null")) ? null : id.getDoubleArray(uo.channels[1]);
if ((x != null) || (y != null)) {
if (x == null) {
x = (renderer.getCalibration() == null) ? Arr.indexesDouble(y.length) : renderer.getCalibration().getAxisX(y.length);
@@ -2066,14 +2095,14 @@ public class ScreenPanel4 extends Panel {
valid = true;
}
} else {
Double x = getServerDouble(uo.channels[0]);
Double y = getServerDouble(uo.channels[1]);
Double x = id.getDouble(uo.channels[0]);
Double y = id.getDouble(uo.channels[1]);
if ((x != null) && (y != null)) {
PointDouble position = new PointDouble(x, y);
ov.setAbsolutePosition(position);
if (!(ov instanceof Overlays.Crosshairs)) {
Double x2 = getServerDouble(uo.channels[2]);
Double y2 = getServerDouble(uo.channels[3]);
Double x2 = id.getDouble(uo.channels[2]);
Double y2 = id.getDouble(uo.channels[3]);
if ((x != null) && (y != null)) {
DimensionDouble size = new DimensionDouble(x2 - position.x, y2 - position.y);
ov.setAbsoluteSize(size);

1180
plugins/ScreenPanelBack.form Normal file

File diff suppressed because it is too large Load Diff

4218
plugins/ScreenPanelBack.java Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -50,7 +50,7 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
@@ -110,12 +110,8 @@
<Component id="buttonAbort" linkSize="2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<EmptySpace min="98" pref="98" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="98" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="panelStatus" min="-2" pref="324" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="comboBlm3" alignment="0" max="32767" attributes="0"/>
@@ -132,22 +128,29 @@
<Component id="comboBpm2" alignment="0" max="32767" attributes="0"/>
<Component id="comboBpm1" max="32767" attributes="0"/>
<Component id="comboBpm3" alignment="0" max="32767" attributes="0"/>
<Component id="comboScanType" max="32767" attributes="0"/>
<Component id="comboWireScanner" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="panelPosition" linkSize="4" alignment="0" min="-2" pref="90" max="-2" attributes="0"/>
<Component id="labelPosX" linkSize="4" alignment="0" min="-2" pref="90" max="-2" attributes="0"/>
<Component id="labelPosY" linkSize="4" alignment="0" min="-2" pref="90" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="panelRepRate" linkSize="4" min="-2" pref="92" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="panelPosition" linkSize="4" alignment="0" min="-2" pref="90" max="-2" attributes="0"/>
<Component id="labelPosX" linkSize="4" alignment="0" min="-2" pref="90" max="-2" attributes="0"/>
<Component id="labelPosY" linkSize="4" alignment="0" min="-2" pref="90" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="panelRepRate" linkSize="4" min="-2" pref="92" max="-2" attributes="0"/>
<EmptySpace type="separate" max="32767" attributes="0"/>
<Component id="jLabel12" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="ledHomed" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace type="separate" max="32767" attributes="0"/>
<Component id="jLabel12" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="ledHomed" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="checkFilterBeamOk" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace type="separate" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="buttonHoming" max="32767" attributes="0"/>
<Component id="buttonScannerPanel" linkSize="3" alignment="0" max="32767" attributes="0"/>
@@ -165,10 +168,18 @@
</Group>
</Group>
</Group>
<Component id="panelStatus" min="-2" pref="324" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="comboScanType" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jLabel22" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="comboAdaptive" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -184,6 +195,8 @@
<Group type="103" groupAlignment="3" attributes="0">
<Component id="comboScanType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="comboAdaptive" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel22" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
@@ -250,11 +263,20 @@
<Component id="jLabel16" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonRaw3" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="32767" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel11" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="panelPosition" linkSize="5" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="buttonScannerPanel" alignment="2" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="2" attributes="0">
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel11" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="buttonScannerPanel" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="2" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="checkFilterBeamOk" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="32767" attributes="0"/>
<Component id="panelPosition" linkSize="5" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
@@ -682,6 +704,32 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboAdaptive">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="3">
<StringItem index="0" value="Off"/>
<StringItem index="1" value="Gain"/>
<StringItem index="2" value="Gain+Range"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboAdaptiveActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel22">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Adaptive:"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkFilterBeamOk">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Filter Beam Ok"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>

View File

@@ -162,7 +162,8 @@ public class WireScan extends Panel {
checkSaveRaw.setEnabled(state==State.Ready);
buttonAbort.setEnabled(state==State.Busy);
comboScanType.setEnabled(validWireScan);
for (JComboBox cb : bpmCombos){
comboAdaptive.setEnabled(validWireScan);
for (JComboBox cb :bpmCombos){
cb.setEnabled(validWireScan && !isBackground());
}
for (JComboBox cb : blmCombos){
@@ -397,6 +398,9 @@ public class WireScan extends Panel {
labelVelX = new javax.swing.JLabel();
jLabel24 = new javax.swing.JLabel();
labelVelY = new javax.swing.JLabel();
comboAdaptive = new javax.swing.JComboBox();
jLabel22 = new javax.swing.JLabel();
checkFilterBeamOk = new javax.swing.JCheckBox();
plot.setTitle("");
@@ -611,6 +615,19 @@ public class WireScan extends Panel {
labelVelY.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
labelVelY.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
comboAdaptive.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Off", "Gain", "Gain+Range" }));
comboAdaptive.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
comboAdaptiveActionPerformed(evt);
}
});
jLabel22.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel22.setText("Adaptive:");
checkFilterBeamOk.setSelected(true);
checkFilterBeamOk.setText("Filter Beam Ok");
javax.swing.GroupLayout panelLeftLayout = new javax.swing.GroupLayout(panelLeft);
panelLeft.setLayout(panelLeftLayout);
panelLeftLayout.setHorizontalGroup(
@@ -671,9 +688,6 @@ public class WireScan extends Panel {
.addGroup(panelLeftLayout.createSequentialGroup()
.addGap(98, 98, 98)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelLeftLayout.createSequentialGroup()
.addComponent(panelStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(panelLeftLayout.createSequentialGroup()
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(comboBlm3, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
@@ -687,20 +701,24 @@ public class WireScan extends Panel {
.addComponent(comboBpm2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboBpm1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboBpm3, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboScanType, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboWireScanner, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(panelLeftLayout.createSequentialGroup()
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(panelPosition, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelPosX, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelPosY, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(panelLeftLayout.createSequentialGroup()
.addComponent(panelRepRate, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, Short.MAX_VALUE)
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(ledHomed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, Short.MAX_VALUE)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(panelPosition, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelPosX, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelPosY, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(panelLeftLayout.createSequentialGroup()
.addComponent(panelRepRate, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, Short.MAX_VALUE)
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(ledHomed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, Short.MAX_VALUE))
.addGroup(panelLeftLayout.createSequentialGroup()
.addComponent(checkFilterBeamOk)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(buttonHoming, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonScannerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
@@ -712,7 +730,14 @@ public class WireScan extends Panel {
.addComponent(jLabel24)
.addGroup(panelLeftLayout.createSequentialGroup()
.addGap(98, 98, 98)
.addComponent(labelVelY, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)))))))
.addComponent(labelVelY, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addComponent(panelStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(panelLeftLayout.createSequentialGroup()
.addComponent(comboScanType, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel22)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(comboAdaptive, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGap(0, 0, 0))
);
@@ -738,7 +763,9 @@ public class WireScan extends Panel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(comboScanType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addComponent(jLabel2)
.addComponent(comboAdaptive, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel22))
.addGap(18, 18, 18)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
@@ -792,11 +819,17 @@ public class WireScan extends Panel {
.addComponent(comboBlm3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel16)
.addComponent(buttonRaw3))
.addGap(18, 18, Short.MAX_VALUE)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel11)
.addComponent(panelPosition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonScannerPanel))
.addGroup(panelLeftLayout.createSequentialGroup()
.addGap(26, 26, 26)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel11)
.addComponent(buttonScannerPanel)))
.addGroup(panelLeftLayout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(checkFilterBeamOk)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(panelPosition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel13)
@@ -1057,6 +1090,9 @@ ChannelDouble channelEndY;
parameters.add(plot);
parameters.add(checkSaveRaw.isSelected());
parameters.add(spinnerBunch.getValue());
parameters.add(comboAdaptive.getSelectedIndex());
parameters.add(checkFilterBeamOk.isSelected());
runAsync("Diagnostics/WireScan", parameters).handle((ret, ex) -> {
if (ex != null) {
@@ -1192,6 +1228,10 @@ ChannelDouble channelEndY;
updateRawButtons();
}//GEN-LAST:event_comboBlm2ActionPerformed
private void comboAdaptiveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboAdaptiveActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_comboAdaptiveActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonAbort;
private javax.swing.JButton buttonCalibration;
@@ -1204,7 +1244,9 @@ ChannelDouble channelEndY;
private javax.swing.JButton buttonRaw3;
private javax.swing.JButton buttonScan;
private javax.swing.JButton buttonScannerPanel;
private javax.swing.JCheckBox checkFilterBeamOk;
private javax.swing.JCheckBox checkSaveRaw;
private javax.swing.JComboBox comboAdaptive;
private javax.swing.JComboBox comboBlm1;
private javax.swing.JComboBox comboBlm2;
private javax.swing.JComboBox comboBlm3;
@@ -1226,6 +1268,7 @@ ChannelDouble channelEndY;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel22;
private javax.swing.JLabel jLabel23;
private javax.swing.JLabel jLabel24;
private javax.swing.JLabel jLabel3;

View File

@@ -59,15 +59,23 @@
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel8" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel7" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel6" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel2" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel20" linkSize="1" alignment="0" pref="86" max="32767" attributes="0"/>
<Component id="jLabel9" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel10" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel11" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="buttonSetRange" linkSize="2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonSetGain" linkSize="2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="jLabel3" alignment="0" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel8" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel7" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel6" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel2" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel20" linkSize="1" alignment="0" pref="86" max="32767" attributes="0"/>
<Component id="jLabel9" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel10" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel11" linkSize="1" alignment="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
@@ -79,6 +87,7 @@
<Component id="spinnerSaturation" alignment="0" max="32767" attributes="0"/>
<Component id="spinnerRangeFactor" alignment="0" max="32767" attributes="0"/>
<Component id="spinnerInitialGain" alignment="0" max="32767" attributes="0"/>
<Component id="textBlm" alignment="0" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
@@ -98,7 +107,12 @@
<Component id="comboWire" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="70" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textBlm" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="47" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel6" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="spinnerRangeStart" alignment="2" min="-2" max="-2" attributes="0"/>
@@ -113,7 +127,12 @@
<Component id="jLabel11" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerInitialGain" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="70" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonSetRange" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonSetGain" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="27" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerScanPoints" alignment="3" min="-2" max="-2" attributes="0"/>
@@ -128,7 +147,7 @@
<Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerRangeFactor" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="78" max="32767" attributes="0"/>
<EmptySpace pref="76" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonAbort" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonScan" alignment="3" min="-2" max="-2" attributes="0"/>
@@ -172,6 +191,9 @@
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboWireScanner">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboWireScannerActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel20">
<Properties>
@@ -259,6 +281,33 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonSetRange">
<Properties>
<Property name="text" type="java.lang.String" value="Set Range"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonSetRangeActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonSetGain">
<Properties>
<Property name="text" type="java.lang.String" value="Set Gain"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonSetGainActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="BLM:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textBlm">
<Properties>
<Property name="editable" type="boolean" value="false"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>

View File

@@ -88,6 +88,10 @@ public class WireScanCalibration extends Panel {
spinnerRangeFactor = new javax.swing.JSpinner();
jLabel11 = new javax.swing.JLabel();
spinnerInitialGain = new javax.swing.JSpinner();
buttonSetRange = new javax.swing.JButton();
buttonSetGain = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
textBlm = new javax.swing.JTextField();
plot.setTitle("");
@@ -106,6 +110,12 @@ public class WireScanCalibration extends Panel {
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel2.setText("Wire:");
comboWireScanner.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
comboWireScannerActionPerformed(evt);
}
});
jLabel20.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel20.setText("Wire Scanner:");
@@ -143,6 +153,25 @@ public class WireScanCalibration extends Panel {
spinnerInitialGain.setModel(new javax.swing.SpinnerNumberModel(0.6d, 0.5d, 1.1d, 0.1d));
buttonSetRange.setText("Set Range");
buttonSetRange.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonSetRangeActionPerformed(evt);
}
});
buttonSetGain.setText("Set Gain");
buttonSetGain.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonSetGainActionPerformed(evt);
}
});
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel3.setText("BLM:");
textBlm.setEditable(false);
javax.swing.GroupLayout panelLeftLayout = new javax.swing.GroupLayout(panelLeft);
panelLeft.setLayout(panelLeftLayout);
panelLeftLayout.setHorizontalGroup(
@@ -156,15 +185,21 @@ public class WireScanCalibration extends Panel {
.addComponent(buttonAbort)
.addContainerGap())
.addGroup(panelLeftLayout.createSequentialGroup()
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel20, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE)
.addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(buttonSetRange)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonSetGain))
.addGroup(panelLeftLayout.createSequentialGroup()
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel20, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE)
.addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(comboWireScanner, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
@@ -174,12 +209,13 @@ public class WireScanCalibration extends Panel {
.addComponent(spinnerScanPoints)
.addComponent(spinnerSaturation)
.addComponent(spinnerRangeFactor)
.addComponent(spinnerInitialGain)))))
.addComponent(spinnerInitialGain)
.addComponent(textBlm)))))
);
panelLeftLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel10, jLabel11, jLabel2, jLabel20, jLabel6, jLabel7, jLabel8, jLabel9});
panelLeftLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonAbort, buttonScan});
panelLeftLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonAbort, buttonScan, buttonSetGain, buttonSetRange});
panelLeftLayout.setVerticalGroup(
panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -192,7 +228,11 @@ public class WireScanCalibration extends Panel {
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(comboWire, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addGap(70, 70, 70)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(textBlm, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(47, 47, 47)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel6)
.addComponent(spinnerRangeStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
@@ -204,7 +244,11 @@ public class WireScanCalibration extends Panel {
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11)
.addComponent(spinnerInitialGain, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(70, 70, 70)
.addGap(18, 18, 18)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonSetRange)
.addComponent(buttonSetGain))
.addGap(27, 27, 27)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(spinnerScanPoints, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
@@ -216,7 +260,7 @@ public class WireScanCalibration extends Panel {
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel10)
.addComponent(spinnerRangeFactor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 78, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 76, Short.MAX_VALUE)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonAbort)
.addComponent(buttonScan))
@@ -282,17 +326,71 @@ public class WireScanCalibration extends Panel {
}
}//GEN-LAST:event_buttonAbortActionPerformed
private void buttonSetRangeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetRangeActionPerformed
try {
String ws_blm = comboWireScanner.getSelectedItem().toString();
String ws_wire = comboWire.getSelectedItem().toString();
Object start = spinnerRangeStart.getValue();
Object end = spinnerRangeEnd.getValue();
switch (ws_wire){
case "X1": ws_wire = "W1X"; break;
case "Y1": ws_wire = "W1Y"; break;
case "X2": ws_wire = "W2X"; break;
case "Y2": ws_wire = "W2Y"; break;
}
//caput((ws_prefix + ":" + sel[wire] +"_START_SP"), start)
//caput((ws_prefix + ":" + sel[wire] +"_END_SP"), end)
String cmd = "caput('" + ws_blm + ":" + ws_wire + "_START_SP', " + start + ")";
System.out.println(cmd);
//eval(cmd, true);
cmd = "caput('" + ws_blm + ":" + ws_wire + "_END_SP', " + end + ")";
System.out.println(cmd);
//eval(cmd, true);
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonSetRangeActionPerformed
private void buttonSetGainActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetGainActionPerformed
try {
String ws_blm = textBlm.getText();
if (!(ws_blm==null) && (!ws_blm.isEmpty())){
String ws_wire = comboWire.getSelectedItem().toString();
Object val = spinnerInitialGain.getValue();
String cmd = "set_setting('" + ws_blm + "GainWs" + ws_wire + "', " + val + ")";
eval(cmd, true);
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonSetGainActionPerformed
private void comboWireScannerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboWireScannerActionPerformed
try {
String ws_prefix = comboWireScanner.getSelectedItem().toString();
String cmd = "get_wire_scanners_blms('" + ws_prefix + "')";
List blms=(List) eval(cmd, true);
textBlm.setText(blms.get(0).toString());
} catch (Exception ex) {
textBlm.setText("");
}
}//GEN-LAST:event_comboWireScannerActionPerformed
//String caqtdm = "caqtdm -noMsg -stylefile sfop.qss -attach";
String caqtdm = "caqtdm -noMsg -stylefile sfop.qss";
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonAbort;
private javax.swing.JButton buttonScan;
private javax.swing.JButton buttonSetGain;
private javax.swing.JButton buttonSetRange;
private javax.swing.JComboBox comboWire;
private javax.swing.JComboBox comboWireScanner;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
@@ -305,5 +403,6 @@ public class WireScanCalibration extends Panel {
private javax.swing.JSpinner spinnerRangeStart;
private javax.swing.JSpinner spinnerSaturation;
private javax.swing.JSpinner spinnerScanPoints;
private javax.swing.JTextField textBlm;
// End of variables declaration//GEN-END:variables
}

View File

@@ -156,8 +156,9 @@ elements = (
(DBPM, "SARCL02-DBPM110", 456.9100),
(DBLM, "SARCL02-DBLM135", 457.9854),
(DBPM, "SARCL02-DBPM220", 460.9609),
(DWSC, "SARCL02-DWSC235", 461.6270),
(DBPM, "SARCL02-DBPM260", 462.7569),
(DWSC, "SARCL02-DWSC270", 462.9769),
#(DWSC, "SARCL02-DWSC270", 462.9769),
(DBPM, "SARCL02-DBPM330", 466.6909),
(DBLM, "SARCL02-DBLM355", 467.686),
(DBPM, "SARCL02-DBPM470", 471.1067),
@@ -301,7 +302,7 @@ def get_camera_type(camera_name):
###################################################################################################
## BLMs in WS MODE
## BLMs
###################################################################################################
@@ -342,3 +343,62 @@ def get_blm_ws_att(blm):
string 15: 30 dB
"""
return caget(blm + ":WS_PMT_ATT_VOLTS", 'i')
def get_blm_loss(blm):
return caget(blm + ":B1_LOSS")
def get_blm_raw(blm):
return caget(blm + ":LOSS_SIGNAL_RAW")
def get_blm_baseline(blm):
return caget(blm + ":BASELINE_VAL")
def get_blm_range(blm):
raw =get_blm_raw(blm)
bl=get_blm_baseline(blm)
m = min(raw)
ret = (bl-m)/bl
ret = min(max(ret, 0.0), 1.0)
return ret
def set_blm_saturation(blm, val):
set_setting(blm + "_saturation", val)
def get_blm_saturation(blm):
ret = get_setting(blm + "_saturation")
return None if (ret is None) else float(ret)
def update_blm_saturation(blm):
set_setting(blm + "_saturation", get_blm_loss(blm))
def get_voltage_from_gain(gain):
#a=caget (blm+":AL1-MPS-GAIN-A", 'd')
#b=caget (blm+":AL1-MPS-GAIN-B", 'd')
a = caget("SINDI02-DBLM084:AL1-MPS-GAIN-A", 'd')
b = caget("SINDI02-DBLM084:AL1-MPS-GAIN-B", 'd')
return (math.log(gain) - math.log(a))/b
def get_gain_from_voltage(voltage):
a = caget("SINDI02-DBLM084:AL1-MPS-GAIN-A", 'd')
b = caget("SINDI02-DBLM084:AL1-MPS-GAIN-B", 'd')
return a*math.exp(b*voltage)
###################################################################################################
## WSCs
###################################################################################################
def write_ws_gain(blm, wire, val):
set_setting(blm + "GainWs" + wire, val)
def read_ws_gain(blm, wire):
return get_setting(blm + "GainWs" + wire)
def set_wire_scan_range(wsc, wire, start, end):
sel = {'X1':"W1X" , 'Y1': "W1Y", 'X2':"W2X", 'Y2' : "W2Y"}
start = min (max(start, -2000), 2000.0)
end = min (max(end, -2000), 2000.0)
caput((wsc + ":" + sel[wire] +"_START_SP"), start)
caput((wsc + ":" + sel[wire] +"_END_SP"), end)

View File

@@ -0,0 +1,12 @@
st = Stream("st1",dispatcher)
st.setFilter("SIN-CVME-TIFGUN-EVR0:BEAMOK == 1")
c = "SARCL02-DBLM135:LOSS_SIGNAL_RAW"
st.addWaveform(c, c, 1, 2048)
try:
st.initialize()
st.start()
st.waitCacheChange(10000) #Wait stream be running before starting scan
mscan(st, st.getReadables()[1], -1, line_plots= [c,], keep=False, save=False)
finally:
st.close()

View File

@@ -1,8 +1,10 @@
import traceback
has_args = get_exec_pars().source != CommandSource.ui #Must be checked before callin "run"
is_script = get_exec_pars().source == CommandSource.script
is_embedded = (get_exec_pars().getCommand(False).parent != None)
has_args = is_embedded or (get_exec_pars().source != CommandSource.ui)
STREAM_CREATION_RETRIES = 3
MAX_RANGE_STEP = 3
run("Devices/Elements")
run("Devices/WireScanner")
@@ -23,12 +25,19 @@ bkgrd = args[7] if has_args else 10
plt = args[8] if has_args else plot(None, title = "Wire Scan")[0]
save_raw = args[9] if has_args else False
bunch = args[10] if has_args else 1
do_elog = True if (has_args and (not is_script) and (plt is not None)) else False
print has_args, do_elog
adaptive = args[11] if has_args else 1 #0=Off, 1=Gain, 2=Gain+range
filter_beam_ok = (args[12] if has_args else True) if len(args)>12 else True
do_elog = True if (has_args and (not is_embedded) and (plt is not None)) else False
print has_args, is_embedded, do_elog
print "WireScan parameters: ", prefix, scan_type, scan_range, cycles, n_shot, bpms, blms, bkgrd, bunch
print "WireScan parameters: ", prefix, scan_type, scan_range, cycles, n_shot, bpms, blms, bkgrd, bunch, adaptive
#Adaptive mode parameters
MIN_GAIN, MAX_GAIN = 0.5, 1.1
INCREMENT_FACTOR = 0.5
SCAN_RANGE_FACTOR = 6
MAX_RANGE_STEP = 300
FILTER_BEAM_OK = True
SET_BLM_WS_MODE = True
SET_BLM_WS_SETTLING_TIME = 2.0
SET_BLM_WS_BS_READBACK_TIMEOUT = 10000 #ms
@@ -116,18 +125,27 @@ filename = get_exec_pars().path
#Stream creation
print "Starting stream..."
st = Stream("pulse_id", dispatcher)
for c in channels:
if c[1].endswith("LOSS_SIGNAL_RAW"):
st.addWaveform(c[0], c[1], int(100.0 / get_repetition_rate()), 0)
else:
st.addScalar(c[0], c[1], int(100.0 / get_repetition_rate()), 0)
st.initialize()
st.start()
st.waitCacheChange(10000) #Wait stream be running before starting scan
for retry in range(STREAM_CREATION_RETRIES):
try:
print "Starting stream..."
st = Stream("pulse_id", dispatcher)
for c in channels:
if c[1].endswith("LOSS_SIGNAL_RAW"):
st.addWaveform(c[0], c[1], int(100.0 / get_repetition_rate()), 0)
else:
st.addScalar(c[0], c[1], int(100.0 / get_repetition_rate()), 0)
st.initialize()
st.start()
st.waitCacheChange(10000) #Wait stream be running before starting scan
break
except:
print "Error starting stream"
print sys.exc_info()[1]
if retry >= (STREAM_CREATION_RETRIES-1):
raise
else:
print "Retrying"
class Timestamp(Readable):
def read(self):
return st.getTimestamp()
@@ -147,6 +165,8 @@ rec =None
def check_end_scan(record, scan):
global scan_complete,cur_cycle
global rec
if (rec is None) and (record is not None):
print "Started receiving from stream"
rec = record
if record[4]<1:
print "Data aquisition completed"
@@ -163,7 +183,9 @@ def check_end_scan(record, scan):
for i in range (len(blms)):
plt.getSeries(i).appendData(position, record[5 + i])
scanner.park(wait=True)
if scanner.take() != "At start":
print "Not at start: parking scanner"
scanner.park(wait=True)
#Process background
def do_background():
#Store Background
@@ -186,17 +208,18 @@ def set_blm_gain(scan_type, index):
scan_type = (WireScanner.WireX1 if index == 0 else WireScanner.WireY1)
if scan_type == WireScanner.Set2:
scan_type = (WireScanner.WireX2 if index == 0 else WireScanner.WireY2)
cfg_gain = get_setting(blms[0] + "GainWs" + scan_type)
cfg_gain = read_ws_gain (blms[0], scan_type)
print "cfg_gain = " , cfg_gain
if cfg_gain is not None:
set_blm_ws_gain(blms[0],cfg_gain)
print "Set = " , blms[0]
print "Set = " , blms[0], cfg_gain
#Scan
def do_scan(index):
global scan_complete, cur_cycle, wire
global scan_complete, cur_cycle, wire, rec
rec =None
wire = "y" if (index==1) or (scan_type in [WireScanner.WireY1, WireScanner.WireY2]) else "x"
if wire == "x":
scanner.set_velocity(velocity_x)
@@ -248,8 +271,13 @@ def do_scan(index):
#s=plt.getSeries(0)
#indexes = sorted(range(len(s.x)),key=lambda x:s.x[x])
#x,y = [s.x[x] for x in indexes], [s.y[x] for x in indexes]
#plot(y, xdata = x)
#plot(y, xdata = x)
if rec is None:
raise Exception("Didn't receive from stream")
if not scan_complete:
raise Exception("Scan didn't conmplete")
print "Calculating"
rec
calculate()
print "Ok"
img_file = os.path.abspath(filename + "_" + get_exec_pars().group[0:1] + ".png")
@@ -259,6 +287,7 @@ def do_scan(index):
snapshots.append(img_file)
print "Finished"
pars = []
msg = ""
ret = []
def calculate():
@@ -271,7 +300,7 @@ def calculate():
samples = [[], [], [], [], [], []]
for cycle in range (cycles):
pos_path = wire+"_" + ("%04d" % (cycle+1)) + "/data/w_pos"
print "Loading ", pos_path
print "Loading: ", pos_path
pos = load_data(pos_path+"/value")
path = wire+"_" + ("%04d" % (cycle+1)) + "/data/blm" + str(i+1)
print "Loading ", path
@@ -342,7 +371,63 @@ def calculate():
except:
traceback.print_exc()
gauss = [0.0] * SAMPLE_CHANNEL_SIZE
scanner.set_out_gauss(bunch,wire,gauss)
scanner.set_out_gauss(bunch,wire,gauss)
#com = stats[i][2][0]
#sigma = stats[i][3][0]
#saturration_loss = get_blm_saturation(blms[i])
#current_gain = get_blm_ws_gain(blms[i]) #read_ws_gain (blms[i], wire)
#current_loss = get_blm_loss(blms[i])
#global pars
#pars = [blms, com, sigma, saturration_loss, current_gain, current_loss]
com = stats[i][0][0]
rms = stats[i][1][0]
mn = stats[i][2][0]
sigma = stats[i][3][0]
(cur_x_range_min, cur_x_range_max) = (scan_range[0], scan_range[1]) if wire == "x" else (scan_range[2], scan_range[3])
x_range_min, x_range_max = mn - SCAN_RANGE_FACTOR * sigma, mn + SCAN_RANGE_FACTOR * sigma
off_min, off_max = (x_range_min - cur_x_range_min), (x_range_max - cur_x_range_max)
valid_range = (abs(off_min) < MAX_RANGE_STEP) and (abs(off_max) < MAX_RANGE_STEP)
valid_fitting = (com!=float('NaN')) and (mn!=float('NaN')) and \
(com>cur_x_range_min) and (com<cur_x_range_max) and \
(mn>cur_x_range_min) and (mn<cur_x_range_max)
print "Scan range: ", (cur_x_range_min, cur_x_range_max)
print "Valid fitting: ", valid_fitting
print "Valid range: ", valid_range
if adaptive > 0 and \
valid_fitting and \
(scan_type not in [WireScanner.Set1, WireScanner.Set2]):
new_gain, new_voltage = None, None
#desired_loss= 800
desired_loss= get_blm_saturation(blms[i])
current_voltage = get_blm_ws_gain(blms[i]) #read_ws_gain (blms[i], scan_type)
#current_loss = float(get_blm_loss(blms[i]))
current_loss = max(sig)
print "current_loss=", current_loss
current_gain = get_gain_from_voltage(current_voltage)
dg = current_gain * (desired_loss/ current_loss -1)
new_gain = current_gain + dg * INCREMENT_FACTOR
new_voltage = get_voltage_from_gain(new_gain)
new_voltage = max(min(new_voltage, MAX_GAIN),MIN_GAIN)
print "dg=", dg, " ng=", new_gain
if (new_voltage is not None) and (new_voltage != current_voltage):
logstr= "Adapting " + str(blms[i]) + " - " + str(scan_type) + "gain: " + str(new_voltage)
print logstr
log(logstr)
write_ws_gain(blms[i], scan_type, new_voltage)
set_blm_ws_gain(blms[i], new_voltage)
if adaptive > 1:
if valid_range:
new_min, new_max = (cur_x_range_min + INCREMENT_FACTOR*off_min), (cur_x_range_max + INCREMENT_FACTOR*off_max)
logstr= "Adapting range: " , new_min , " to " , new_max
set_wire_scan_range(prefix, scan_type, new_min, new_max)
print logstr
log(logstr)
except Exception, e:
print >> sys.stderr, traceback.format_exc()
msg += str(e)+ "\n"
@@ -374,7 +459,7 @@ try:
print "Reading background..."
do_background()
stream_filter = scanner.curr_cycl.get_name() + ">0"
if FILTER_BEAM_OK:
if filter_beam_ok:
stream_filter = stream_filter + " AND SIN-CVME-TIFGUN-EVR0:BEAMOK == 1"
st.setFilter(stream_filter)
print "Executing scan 1..."
@@ -383,6 +468,10 @@ try:
print "Executing scan 2..."
do_scan(1)
finally:
try:
scanner.park(wait=False)
except:
pass
if SET_BLM_WS_MODE and len(blms)>0:
stop_blm_ws(blms[0])
print "Closing scanner"

View File

@@ -29,44 +29,20 @@ OPT_STEP = 0.02
print "WireScanCalibration parameters: ", ws_prefix, ws_wire, range_start, range_end, n_shot, saturation, scan_range_factor, initial_gain
###################################################################################################
# Utilities
###################################################################################################
def write_ws_gain(val):
set_setting(ws_blm + "GainWs" + ws_wire, val)
def read_ws_gain():
return get_setting(ws_blm + "GainWs" + ws_wire)
def get_gain():
return get_blm_ws_gain(ws_blm)
def set_gain(val):
set_blm_ws_gain(ws_blm,val)
def set_wire_scan_range(wire, start, end):
sel = {'X1':"W1X" , 'Y1': "W1Y", 'X2':"W2X", 'Y2' : "W2Y"}
start = min (max(start, -2000), 2000.0)
end = min (max(end, -2000), 2000.0)
caput((ws_prefix + ":" + sel[wire] +"_START_SP"), start)
caput((ws_prefix + ":" + sel[wire] +"_END_SP"), end)
###################################################################################################
# Find COM
###################################################################################################
print "--------------- Find COM --------------- "
set_status("Performing wire scan to find initial COM...")
write_ws_gain(initial_gain)
set_gain(initial_gain)
write_ws_gain(ws_blm,ws_wire, initial_gain)
set_blm_ws_gain(ws_blm, initial_gain)
print "Setting gain=", initial_gain
#Calculate speed
x_min, x_max = range_start, range_end
#rr = get_repetition_rate()
#ws_speed = (x_max- x_min)*rr/n_shot
args = [ ws_prefix , ws_wire, [x_min, x_max, x_min, x_max], 1, n_shot, [], [ws_blm], 10, plt, False,1]
args = [ ws_prefix , ws_wire, [x_min, x_max, x_min, x_max], 1, n_shot, [], [ws_blm], 10, plt, False,1,0]
ret = run("Diagnostics/WireScan", args)
[rms_com, rms_sigma, com, sigma, pos_path, path] = ret
@@ -96,74 +72,96 @@ print "Starting stream..."
set_status("Creating stream for gain search..." )
st = Stream("blm_stream", dispatcher)
ch = ws_blm + ":B1_LOSS"
st.addScalar(ch, ch, int(100.0 / get_repetition_rate()), 0)
ch_int = ws_blm + ":B1_LOSS"
ch_raw = ws_blm + ":LOSS_SIGNAL_RAW"
st.addScalar(ch_int, ch_int, int(100.0 / get_repetition_rate()), 0)
st.addWaveform(ch_raw, ch_raw, int(100.0 / get_repetition_rate()), 0)
st.addScalar("blm1_ws_mode", ws_blm + ":WS_RUNNING", int(100.0 / get_repetition_rate()), 0)
st.initialize()
st.start()
st.waitCacheChange(10000) #Wait stream be running before starting scan
baseline=get_blm_baseline(ws_blm)
def change_blm_ws_gain(gain):
set_gain(gain)
#stop_blm_ws(ws_blm)
#st.getChild("blm1_ws_mode").waitValue(0, SET_BLM_WS_BS_READBACK_TIMEOUT)
#start_blm_ws(ws_blm, 600.0)
#st.getChild("blm1_ws_mode").waitValue(1, SET_BLM_WS_BS_READBACK_TIMEOUT)
set_blm_ws_gain(ws_blm, gain)
time.sleep(0.25)
def get_loss():
global ch
def get_loss_int():
samples = []
for i in range(10):
st.waitCacheChange(-1)
val = st.getValue(ch)
val = st.getValue(ch_int)
samples.append(val)
samples.remove(max(samples))#Remove max value
return max(samples)
def get_loss_range():
st.waitCacheChange(-1)
raw = st.getValue(ch_raw)
m = min(raw)
ret = (baseline-m)/baseline
ret = min(max(ret, 0.0), 1.0)
return ret
change_blm_ws_gain(MIN_GAIN)
time.sleep(2.0)
start_gain = get_gain()
pos = start_val = get_loss()
loss = get_loss()
pos = read_ws_gain(ws_blm, ws_wire)
loss = get_loss_int()
print "Current Gain = ", pos, "\nStart Loss = ", loss
"""
target = saturation * 0.8
print "Start Gain = ", start_gain
print "Start Loss = ", start_val
print "Target = ", target
set_status("Searching gain to match peak losses of " + str(target) + "...")
set_status("Searching gain to match peak losses of " + str(target) + "..."
try:
#Search loop
for pos in frange(MIN_GAIN, MAX_GAIN, OPT_STEP, True):
change_blm_ws_gain(pos)
loss = get_loss()
loss = get_loss_int()
print "Pos = ", pos, " Loss = ", loss
if loss>=target:
break
#stop_blm_ws(ws_blm)
break
finally:
stop_blm_ws(ws_blm)
print "Final Gain: ", pos
print "Final Loss: ", loss
print "Final Gain: ", pos, "\nFinal Loss: ", loss
result = "Loss value for final gain: " + str(loss) + " - Target value: " + str(target) + "\n"
if loss<target:
result = result + "Cannot reach target value. Setting gain to " + str(pos) + "\n"
else:
result = result + "Optimized gain: " + str(pos) + "\n"
"""
target = 0.9
loss_range = 0.0
blm_saturation = None
set_status("Searching loss range of " + str(target) + "...")
try:
#Search loop
for pos in frange(MIN_GAIN, MAX_GAIN, OPT_STEP, True):
change_blm_ws_gain(pos)
time.sleep(0.1)
loss_range = get_loss_range()
print "Pos = ", pos, " Loss Range= ", loss_range
if loss_range>=target:
print "Done..."
blm_saturation = get_loss_int()
set_blm_saturation(ws_blm,blm_saturation)
break
finally:
stop_blm_ws(ws_blm)
print "Final Gain: ", pos, "\nFinal Loss Range: ", loss_range , "\nBLM satiuration: ", blm_saturation
result = "Loss range for final gain: " + str(loss_range) + " - Target value: " + str(target) + "\n"
if blm_saturation is None:
result = result + "Cannot reach target value. Setting gain to " + str(pos) + "\n"
else:
result = result + "Optimized gain: " + str(pos) + " - BLM satiuration: " +str(blm_saturation) + "\n"
st.close()
write_ws_gain(pos)
write_ws_gain(ws_blm, ws_wire, pos)
time.sleep(1.0)
###################################################################################################
@@ -176,12 +174,12 @@ print "--------------- Optimize scan range --------------- "
set_status("Performing scan with optimal gain to define optimal range..." )
#caget(ws_blm+":SAT_RAW_SUM")
args = [ ws_prefix , ws_wire, [x_min, x_max, x_min, x_max], 1, n_shot, [], [ws_blm], 10, plt, False,1]
args = [ ws_prefix , ws_wire, [x_min, x_max, x_min, x_max], 1, n_shot, [], [ws_blm], 10, plt, False,1,0]
[rms_com, rms_sigma, com, sigma, pos_path, path] = run("Diagnostics/WireScan", args)
x_range_min, x_range_max = com - scan_range_factor * sigma, com + scan_range_factor * sigma
print "Optimized range: " , x_range_min , " to " , x_range_max
set_wire_scan_range(ws_wire, x_range_min, x_range_max)
set_wire_scan_range(ws_prefix, ws_wire, x_range_min, x_range_max)
result = result + "Optimized range: " + str(x_range_min) + " to " + str(x_range_max)

View File

@@ -0,0 +1,49 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("K", "SARUN08-UIND030:K_SET")
A2 = ChannelDouble("phi", "SARUN08-UPHS060:PHI_SET")
S1 = ChannelDouble("US", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
S2 = ChannelDouble("DS", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-DS")
A1.initialize()
A2.initialize()
S1.initialize()
S2.initialize()
A1_init = A1.read()
A2_init = A2.read()
A1i = A1_init-0.002
A1f = A1_init+0.002
A2i = A2_init-90.0
A2f = A2_init+90.0
nstep = 21
lat = 0.1
nav = 10
plt = plot(None, title="Output")[0]
plt.clear()
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Sensor1", Color.red))
def data_ok():
return (mps_beam_ok.read() == 1)
def after_sample(record, scan):
if not data_ok():
time.sleep(1.0)
record.invalidate()
print "Invalidating record: " + str(record)
else:
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
S2_averager.monitored=True
time.sleep(10.0)
r = ascan((A1,A2), (S1_averager, S2_averager), (A1i,A2i), (A1f,A2f), (nstep,nstep), latency=2.0, after_read = after_sample)
Act1 = r.getPositions(0)
S1mean = [val.mean for val in r.getReadable(0)]
S1rms = [val.stdev for val in r.getReadable(0)]
S2mean = [val.mean for val in r.getReadable(1)]
S2rmsn = [val.stdev for val in r.getReadable(1)]
finally:
A1.write(A1_init)
A1.close()
S1.close()
S2.close()

View File

@@ -0,0 +1,49 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("K", "SARUN06-UIND030:GM-X-SET")
A2 = ChannelDouble("phi", "SARUN08-UPHS060:PHI_SET")
S1 = ChannelDouble("US", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
S2 = ChannelDouble("DS", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-DS")
A1.initialize()
A2.initialize()
S1.initialize()
S2.initialize()
A1_init = A1.read()
A2_init = A2.read()
A1i = A1_init-0.002
A1f = A1_init+0.002
A2i = A2_init-90.0
A2f = A2_init+90.0
nstep = 21
lat = 0.1
nav = 10
plt = plot(None, title="Output")[0]
plt.clear()
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Sensor1", Color.red))
def data_ok():
return (mps_beam_ok.read() == 1)
def after_sample(record, scan):
if not data_ok():
time.sleep(1.0)
record.invalidate()
print "Invalidating record: " + str(record)
else:
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
S2_averager.monitored=True
time.sleep(10.0)
r = ascan((A1,A2), (S1_averager, S2_averager), (A1i,A2i), (A1f,A2f), (nstep,nstep), latency=2.0, after_read = after_sample)
Act1 = r.getPositions(0)
S1mean = [val.mean for val in r.getReadable(0)]
S1rms = [val.stdev for val in r.getReadable(0)]
S2mean = [val.mean for val in r.getReadable(1)]
S2rmsn = [val.stdev for val in r.getReadable(1)]
finally:
A1.write(A1_init)
A1.close()
S1.close()
S2.close()

View File

@@ -0,0 +1,36 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("S20SY02-MKDC050:I-SET", "S20SY02-MKDC050:I-SET")
S1 = ChannelDouble("SARUN02-DBPM070:Y1", "SARUN02-DBPM070:Y1")
S2 = ChannelDouble("SARUN02-DBPM070:X1", "SARUN02-DBPM070:X1")
S3 = ChannelDouble("SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-DS", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-DS")
A1.initialize()
S1.initialize()
S2.initialize()
S3.initialize()
A1_init = A1.read()
A1i =-0.1
A1f = 0.1
step = 0.01
lat1 = 1
lat2 = 1
nav = 10
plt = plot(None, title="Output")[0]
plt.clear()
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Sensor1", Color.red))
def after_sample(record, scan):
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat1)
A1.write(A1i)
time.sleep(2.0)
r = lscan(A1, (S1_averager), A1i, A1f, step, latency=lat2, after_read = after_sample)
Act1 = r.getPositions(0)
S1mean = [val.mean for val in r.getReadable(0)]
S1rms = [val.stdev for val in r.getReadable(0)]
finally:
A1.write(A1_init)
A1.close()
S1.close()
S2.close()
S3.close()

View File

@@ -1,5 +1,5 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("MK energy", "S20SY02-MK:ENERGY-SP")
A1 = ChannelDouble("MK energy", "S20SY02-MK:ENERGY-SP")
S1 = ChannelDouble("S20SY02-DBPM150:Y1", "S20SY02-DBPM150:Y1")
S2 = ChannelDouble("SATSY01-DBPM010:Y1", "SATSY01-DBPM010:Y1")
S3 = ChannelDouble("SATSY01-DBPM010:Q1", "SATSY01-DBPM010:Q1")

View File

@@ -1,38 +0,0 @@
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

@@ -1,167 +0,0 @@
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]
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]
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(150)
#cam_server.captureBackground(10) #Capturing background
cam_server.setBackgroundSubtraction(False)
#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
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 ps
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

@@ -1,25 +0,0 @@
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,38 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
#A1 = ChannelDouble("K value", "SARUN03-UIND030:K_SET")
A1 = ChannelDouble("Und. height", "SARUN14-UIND030:GM-Y-SET")
S1 = ChannelDouble("Energy per pulse (uJ)", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
A1.initialize()
S1.initialize()
A1_init = A1.read()
A1i = A1_init + 0.200*0
A1f = A1_init - 0.200*0
nstep = 11
lat = 1.0
nav = 5
#To put the motor on
#M1 = ChannelDouble("Motor on", "SARUN14-UIND030:GM-ONOFF")
#M1.initialize()
#M1.set(1)
plt = plot(None, title="Output")[0]
plt.clear()
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Sensor1", Color.red))
def after_sample(record, scan):
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
A1.write(A1i)
time.sleep(30.0)
r = lscan(A1, (S1_averager), A1i, A1f, nstep, latency=5.0, after_read = after_sample)
Act1 = r.getPositions(0)
S1mean = [val.mean for val in r.getReadable(0)]
S1rms = [val.stdev for val in r.getReadable(0)]
finally:
A1.write(A1_init)
A1.close()
S1.close()
M1.close()

View File

@@ -1,44 +1,31 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("K value", "SARUN12-UIND030:K_SET.VAL")
S1 = ChannelDouble("Energy per pulse (uJ)", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
S2 = ChannelDouble("HAMP", "SARFE10-PBPG050:HAMP-INTENSITY")
A1 = ChannelDouble("K value", "SARUN15-UIND030:K_SET")
S1 = ChannelDouble("Energy per pulse (uJ)", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
A1.initialize()
S1.initialize()
S2.initialize()
A1_init = A1.read()
K0 = 1.78*0.998
A1i = 1.764
A1f = 1.77
nstep = 41
lat = 1/25
nav = 100
A1i = A1_init - 0.005
A1f = A1_init + 0.005
nstep = 21
lat = 1.0
nav = 5
plt = plot(None, title="Output")[0]
plt.clear()
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Sensor1", Color.red))
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")
def after_sample(record, scan):
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
S2_averager.monitored=True
time.sleep(10.0)
r = lscan(A1, (S1_averager, S2_averager), A1i, A1f, nstep, latency=5.0, after_read = after_sample)
A1.write(A1i)
time.sleep(30.0)
r = lscan(A1, (S1_averager), A1i, A1f, nstep, latency=5.0, after_read = after_sample)
Act1 = r.getPositions(0)
S1mean = [val.mean for val in r.getReadable(0)]
S1rms = [val.stdev for val in r.getReadable(0)]
S2mean = [val.mean for val in r.getReadable(1)]
S2rmsn = [val.stdev for val in r.getReadable(1)]
finally:
A1.write(A1_init)
A1.close()
S1.close()
S2.close()

View File

@@ -1,17 +1,19 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Phase (deg.)", "SARUN11-UIND030:PHI_SET")
import ch.psi.pshell.device.DummyRegister as DummyRegister
A1 = ChannelDouble("Phase (deg.)", "SARUN03-UPHS060:PHI_SET")
S1 = ChannelDouble("energy per pulse (uJ)", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
S2 = ChannelDouble("HAMP", "SARFE10-PBPG050:HAMP-INTENSITY-CAL")
#S2 = ChannelDouble("HAMP", "SARFE10-PBPG050:HAMP-INTENSITY-CAL")
A1.initialize()
S1.initialize()
S2.initialize()
#S2.initialize()
A1_init = A1.read()
A1i = -180
A1f = 180
nstep = 72
lat = 0.05
nav = 40
A1i = 0.
A1f = 360.
nstep = 20
lat = 1.
nav = 10
plt = plot(None, title="Output")[0]
plt.clear()
plt.setStyle(plt.Style.ErrorY)
@@ -20,17 +22,17 @@ def after_sample(record, scan):
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
S2_averager.monitored=True
time.sleep(10.0)
r = lscan(A1, (S1_averager, S2_averager), A1i, A1f, nstep, latency=5.0, after_read = after_sample)
#S2_averager = create_averager(S2, nav, lat)
# S2_averager.monitored=True
r = lscan(A1, S1_averager, A1i, A1f, nstep, latency=2.0, after_read = after_sample)
#r = lscan(A1, (S1_averager , S2_averager), A1i, A1f, nstep, latency=5.0, after_read = after_sample)
Act1 = r.getPositions(0)
S1mean = [val.mean for val in r.getReadable(0)]
S1rms = [val.stdev for val in r.getReadable(0)]
S2mean = [val.mean for val in r.getReadable(1)]
S2rmsn = [val.stdev for val in r.getReadable(1)]
#S2mean = [val.mean for val in r.getReadable(1)]
#S2rmsn = [val.stdev for val in r.getReadable(1)]
finally:
A1.write(A1_init)
A1.close()
S1.close()
S2.close()
#S2.close()

View File

@@ -0,0 +1,31 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Y pos", "SARUN06-DBPM070:Y-REF-FB")
S1 = ChannelDouble("Energy per pulse (uJ)", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
A1.initialize()
S1.initialize()
A1_init = A1.read()
A1i = A1_init - 0.20
A1f = A1_init + 0.20
nstep = 21
lat = 1.0
nav = 5
plt = plot(None, title="Output")[0]
plt.clear()
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Sensor1", Color.red))
def after_sample(record, scan):
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
A1.write(A1i)
time.sleep(30.0)
r = lscan(A1, (S1_averager), A1i, A1f, nstep, latency=5.0, after_read = after_sample)
Act1 = r.getPositions(0)
S1mean = [val.mean for val in r.getReadable(0)]
S1rms = [val.stdev for val in r.getReadable(0)]
finally:
A1.write(A1_init)
A1.close()
S1.close()

View File

@@ -0,0 +1,31 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Y pos", "SARUN07-DBPM070:Y-REF-FB")
S1 = ChannelDouble("Energy per pulse (uJ)", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
A1.initialize()
S1.initialize()
A1_init = A1.read()
A1i = A1_init - 0.10
A1f = A1_init + 0.50
nstep = 21
lat = 1.0
nav = 5
plt = plot(None, title="Output")[0]
plt.clear()
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Sensor1", Color.red))
def after_sample(record, scan):
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
A1.write(A1i)
time.sleep(30.0)
r = lscan(A1, (S1_averager), A1i, A1f, nstep, latency=5.0, after_read = after_sample)
Act1 = r.getPositions(0)
S1mean = [val.mean for val in r.getReadable(0)]
S1rms = [val.stdev for val in r.getReadable(0)]
finally:
A1.write(A1_init)
A1.close()
S1.close()

View File

@@ -1,4 +1,4 @@
Eph1 = 10.8 # actual photon energy
Eph1 = 9.45 # actual photon energy
Eph2 = 12.0 # desired photon energy
do_elog = True

View File

@@ -7,7 +7,7 @@ from mathutils import fit_polynomial,fit_gaussian, fit_harmonic, calculate_peaks
from mathutils import PolynomialFunction, Gaussian, HarmonicOscillator
import java.awt.Color as Color
run("Devices/Elements")
###################################################################################################
# Layout setup

View File

@@ -0,0 +1,35 @@
number_of_frames = 3
module = 1
camera_name = "SARFE10-PPRM064"
st1 = Stream("st1", dispatcher)
def init_bs():
w,h = caget(camera_name + ":WIDTH", 'i'), caget(camera_name + ":HEIGHT", 'i')
st1.addScalar("GasDet", "SARFE10-PBPG050:", module, 0)
st1.addScalar("Y1", "SINEG01-DBPM340:Y1", module, 0)
st1.addScalar("Q1", "SINEG01-DBPM340:Q1", module, 0)
st1.addMatrix("VCC", camera_name + ":FPICTURE", module, 0, w,h)
st1.initialize()
st1.start()
st1.waitCacheChange(10000)
def init_cam():
cam_server.start(camera_name+ "_sp")
x = cam_server.stream.getChild("x_fit_mean")
y = cam_server.stream.getChild("y_fit_mean")
cam_server.stream.waitCacheChange(10000);
def scan_bs():
bscan (st1, number_of_frames, title = "BSscan", tag = "BSscan")
def scan_cam():
mscan (cam_server.stream, (x, y), number_of_frames, title = "CAMscan", tag = "CAMscan")
try:
parallelize(init_bs, init_cam)
parallelize(scan_bs, scan_cam)
finally:
st1.close()
#cam_server.stop()

19
script/test/TestWS.py Normal file
View File

@@ -0,0 +1,19 @@
run("Devices/Elements")
run("Devices/WireScanner")
#ws_prefix = "SINDI01-DWSC090"
ws_prefix = "S10DI01-DWSC010"
plt = plot(None, title = "Wire Scan Calibration")[0]
ws_wire = WireScanner.WireX1
range_start = -900
range_end = 100
n_shot = 200
ws_blm = get_wire_scanners_blms(ws_prefix )[0]
#Calculate speed
x_min, x_max = range_start, range_end
#rr = get_repetition_rate()
#ws_speed = (x_max- x_min)*rr/n_shot
for xx in range(10):
__args = [ ws_prefix , ws_wire, [x_min, x_max, x_min, x_max], 1, n_shot, [], [ws_blm], 1, plt, False,1,0]
ret = run("Diagnostics/WireScan", __args)

View File

@@ -0,0 +1,38 @@
blm = "S10DI01-DBLM045"
channels = ["S10DI01-DWSC010:CURR_CYCL","S10CB02-DBPM420:X1","S10DI01-DWSC010:SCANNING",blm+":WS_RUNNING", \
"S10CB02-DBPM420:Y1","S10DI01-DBLM015:B1_LOSS","S10CB02-DBPM420:Q1","S10BD01-DBPM020:Q1","S10DI01-DWSC010:ENC_1_BS", \
"S10BD01-DBPM020:X1","S10BD01-DBPM020:Y1",blm+":B1_LOSS","SIN-CVME-TIFGUN-EVR0:BEAMOK"]
blm = "SARCL02-DBLM135"
channels =[blm+":B1_LOSS", blm+":WS_RUNNING",
"SARCL01-DWSC160:CURR_CYCL","SARCL01-DWSC160:SCANNING","SARCL02-DBPM110:Q1","SARCL02-DBPM110:X1",
,"SARCL01-DBPM150:Y1","SARCL01-DBPM150:X1","SARCL01-DWSC160:ENC_1_BS","SARCL02-DBPM110:Y1",\
"SARCL01-DBPM150:Q1","SIN-CVME-TIFGUN-EVR0:BEAMOK",
#"SARCL02-DBLM355:B1_LOSS" ,
]
st1 = Stream("st1", dispatcher)
add_device(st1, force = True)
for channel in channels:
st1.addScalar(channel, channel, 10, 0)
st1.initialize()
st1.start(True)
try:
#bscan (st1, 10, title="bscan")
#tscan (st1.getReadables(), 10, 1, title="tscan")
x = st1.take()
start_blm_ws(blm, 55.5)
#TODO: Wait for stream variable indicate bllm is in ws mode
print "Waiting for WS mode..."
#time.sleep(SET_BLM_WS_SETTLING_TIME)
st1.getChild(blm+":WS_RUNNING").waitValue(1, SET_BLM_WS_BS_READBACK_TIMEOUT)
print "Ok"
finally:
stop_blm_ws(blm)
st1.close()

9
script/test/blm.py Normal file
View File

@@ -0,0 +1,9 @@
run("Devices/Elements")
plot(get_blm_raw("SINLH02-DBLM230"))
print get_blm_baseline("SINLH02-DBLM230")
print get_blm_range("SINLH02-DBLM230")
for blm in get_blms():
print blm, " - " , get_blm_baseline(blm), " - " , min(get_blm_raw(blm)), " - " , get_blm_range(blm)

View File

@@ -0,0 +1,34 @@
MIN_GAIN, MAX_GAIN = 0.5, 1.1
DECREMENT_STEP = 0.02
INCREMENT_FACTOR = 0.5
SCAN_RANGE_FACTOR = 6
MAX_RANGE_STEP = 200
new_gain, new_voltage = None, None
desired_loss=get_blm_saturation(blms[i])
current_voltage = get_blm_ws_gain(blms[i]) #read_ws_gain (blms[i], wire)
#current_loss = float(get_blm_loss(blms[i]))
current_loss = 1700
current_gain = get_gain_from_voltage(current_voltage)
if False: #current_loss > desired_loss:
#Gain must decrease. Fixed steps down
if current_voltage > MIN_GAIN:
new_gain = max(current_voltage - DECREMENT_STEP, MIN_GAIN)
else:
#Gain must be increasede. Step proportional to the difference
dg = current_gain * (desired_loss/ current_loss -1)
new_gain = current_gain + dg * INCREMENT_FACTOR
new_voltage = get_voltage_from_gain(new_gain)
new_voltage = max(min(new_voltage, MAX_GAIN),MIN_GAIN)
print "dg=", dg, " ng=", new_gain
if (new_voltage is not None) and (new_voltage != current_voltage):
logstr= "Adapting " , blms[i], " - ", wire, "gain: ", new_voltage
print logstr
log(logstr)
write_ws_gain(blms[i], wire, new_voltage)

1
script/wliw_scan.scan Normal file
View File

@@ -0,0 +1 @@
[ "Linear", [ [ "Channel", "S10BC02-MSEX130:I-SET", 0.0, 0.3, 0.1 ] ], [ [ "Channel", "SAROP21-PSCP-DRS1FNS:CH1:BOXCAR.VALG", 3, 1.0, "Enabled" ] ], false, [ ], "test_scan", 1, 1.0, 0.0, false, false, true, true, "/afs/psi.ch/intranet/SF/Applications/config/pshell_op/script/sext_data.h5", "", "Table", "h5", 0, null, null, "Positioner", false, true ]