Startup
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
#Wed May 31 15:42:57 CEST 2017
|
||||
maxValue=360.0
|
||||
minValue=-180.0
|
||||
offset=0.0
|
||||
precision=3
|
||||
resolution=1.0
|
||||
scale=1.0
|
||||
unit=deg
|
||||
@@ -1,10 +1,10 @@
|
||||
#Wed May 31 08:29:52 CEST 2017
|
||||
#Fri Jun 02 08:49:58 CEST 2017
|
||||
colormap=Flame
|
||||
colormapAutomatic=true
|
||||
colormapMax=35000.0
|
||||
colormapMin=300.0
|
||||
colormapAutomatic=false
|
||||
colormapMax=61.201
|
||||
colormapMin=0.0
|
||||
flipHorizontally=false
|
||||
flipVertically=true
|
||||
flipVertically=false
|
||||
grayscale=false
|
||||
imageHeight=1680
|
||||
imageWidth=1744
|
||||
@@ -21,9 +21,9 @@ rotation=0.0
|
||||
rotationCrop=false
|
||||
scale=1.0
|
||||
serverURL=localhost\:10000
|
||||
spatialCalOffsetX=-861.0
|
||||
spatialCalOffsetY=-820.0
|
||||
spatialCalScaleX=-18.90359168241966
|
||||
spatialCalScaleY=-19.37984496124031
|
||||
spatialCalOffsetX=-216.34895100768858
|
||||
spatialCalOffsetY=-231.41621563133825
|
||||
spatialCalScaleX=-26.85765457769588
|
||||
spatialCalScaleY=-27.12477389498874
|
||||
spatialCalUnits=mm
|
||||
transpose=false
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#Thu Jun 01 10:20:04 CEST 2017
|
||||
colormap=Flame
|
||||
colormapAutomatic=true
|
||||
colormapMax=NaN
|
||||
colormapMin=NaN
|
||||
flipHorizontally=false
|
||||
flipVertically=false
|
||||
grayscale=false
|
||||
imageHeight=1024
|
||||
imageWidth=1280
|
||||
invert=false
|
||||
regionStartX=1
|
||||
regionStartY=1
|
||||
rescaleFactor=1.0
|
||||
rescaleOffset=0.0
|
||||
roiHeight=-1
|
||||
roiWidth=-1
|
||||
roiX=0
|
||||
roiY=0
|
||||
rotation=0.0
|
||||
rotationCrop=false
|
||||
scale=1.0
|
||||
spatialCalOffsetX=-50.0
|
||||
spatialCalOffsetY=-50.0
|
||||
spatialCalScaleX=-1.0
|
||||
spatialCalScaleY=-1.0
|
||||
spatialCalUnits=mm
|
||||
transpose=false
|
||||
@@ -0,0 +1,28 @@
|
||||
#Wed May 31 11:41:34 CEST 2017
|
||||
colormap=Grayscale
|
||||
colormapAutomatic=false
|
||||
colormapMax=NaN
|
||||
colormapMin=NaN
|
||||
flipHorizontally=false
|
||||
flipVertically=false
|
||||
grayscale=false
|
||||
imageHeight=1024
|
||||
imageWidth=1280
|
||||
invert=false
|
||||
regionStartX=0
|
||||
regionStartY=0
|
||||
rescaleFactor=1.0
|
||||
rescaleOffset=0.0
|
||||
roiHeight=-1
|
||||
roiWidth=-1
|
||||
roiX=0
|
||||
roiY=0
|
||||
rotation=0.0
|
||||
rotationCrop=false
|
||||
scale=1.0
|
||||
spatialCalOffsetX=-50.0
|
||||
spatialCalOffsetY=-50.0
|
||||
spatialCalScaleX=1.0
|
||||
spatialCalScaleY=1.0
|
||||
spatialCalUnits=mm
|
||||
transpose=false
|
||||
@@ -1,4 +1,4 @@
|
||||
#Mon May 29 10:39:34 CEST 2017
|
||||
#Thu Jun 01 10:19:48 CEST 2017
|
||||
colormap=Flame
|
||||
colormapAutomatic=true
|
||||
colormapMax=255.0
|
||||
@@ -22,7 +22,7 @@ rotationCrop=false
|
||||
scale=1.0
|
||||
spatialCalOffsetX=-50.0
|
||||
spatialCalOffsetY=-50.0
|
||||
spatialCalScaleX=1.0
|
||||
spatialCalScaleY=1.0
|
||||
spatialCalScaleX=-1.0
|
||||
spatialCalScaleY=-1.0
|
||||
spatialCalUnits=mm
|
||||
transpose=false
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#Wed May 31 08:30:57 CEST 2017
|
||||
#Wed May 31 17:49:39 CEST 2017
|
||||
colormap=Flame
|
||||
colormapAutomatic=true
|
||||
colormapMax=578.797
|
||||
@@ -18,9 +18,9 @@ roiY=0
|
||||
rotation=0.0
|
||||
rotationCrop=false
|
||||
scale=1.0
|
||||
spatialCalOffsetX=-861.4939970777481
|
||||
spatialCalOffsetY=-820.4883730911062
|
||||
spatialCalScaleX=-18.90359092620482
|
||||
spatialCalScaleY=-19.37984500632817
|
||||
spatialCalOffsetX=-50.03909304143862
|
||||
spatialCalOffsetY=-50.048875855327466
|
||||
spatialCalScaleX=-1.0
|
||||
spatialCalScaleY=-1.0
|
||||
spatialCalUnits=mm
|
||||
transpose=false
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#Wed May 31 11:35:57 CEST 2017
|
||||
colormap=Grayscale
|
||||
colormapAutomatic=false
|
||||
colormapMax=NaN
|
||||
colormapMin=NaN
|
||||
flipHorizontally=false
|
||||
flipVertically=false
|
||||
grayscale=false
|
||||
imageHeight=0
|
||||
imageWidth=0
|
||||
invert=false
|
||||
regionStartX=0
|
||||
regionStartY=0
|
||||
rescaleFactor=1.0
|
||||
rescaleOffset=0.0
|
||||
roiHeight=-1
|
||||
roiWidth=-1
|
||||
roiX=0
|
||||
roiY=0
|
||||
rotation=0.0
|
||||
rotationCrop=false
|
||||
scale=1.0
|
||||
spatialCalOffsetX=-50.0
|
||||
spatialCalOffsetY=-50.0
|
||||
spatialCalScaleX=1.0
|
||||
spatialCalScaleY=1.0
|
||||
spatialCalUnits=mm
|
||||
transpose=false
|
||||
@@ -23,20 +23,17 @@
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="panelParameters" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="buttonRun" min="-2" pref="92" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="buttonAbort" min="-2" pref="92" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="centroidPlot" pref="443" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
|
||||
<Component id="progressBar" max="32767" attributes="0"/>
|
||||
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="buttonClear" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
|
||||
<Component id="buttonRun" linkSize="3" min="-2" pref="92" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="buttonAbort" linkSize="3" min="-2" pref="92" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="buttonClear" linkSize="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="centroidPlot" alignment="0" pref="443" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@@ -51,14 +48,10 @@
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="buttonRun" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="buttonAbort" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="buttonClear" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="centroidPlot" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Component id="buttonClear" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="progressBar" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Component id="panelParameters" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
@@ -114,35 +107,44 @@
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="spinnerStep" linkSize="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel4" linkSize="2" min="-2" pref="158" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="spinnerSettlingTime" linkSize="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="jLabel5" linkSize="2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="spinnerNumBackgrounds" linkSize="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel6" linkSize="2" min="-2" pref="158" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="spinnerNumImages" linkSize="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="103" alignment="0" groupAlignment="1" attributes="0">
|
||||
<Component id="radioBackSimple" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="checkBackground" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="36" max="-2" attributes="0"/>
|
||||
<Component id="radioBackMultiple" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="checkSaveImages" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="checkElog" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="jLabel7" min="-2" pref="158" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="spinnerSettlingTime" linkSize="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="jLabel5" linkSize="2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="spinnerNumBackgrounds" linkSize="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="jLabel4" min="-2" pref="75" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="comboSource" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="checkBackground" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="checkSaveImages" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="35" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="radioBackSimple" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="radioBackMultiple" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="127" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
@@ -169,8 +171,8 @@
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spinnerSettlingTime" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
@@ -188,11 +190,21 @@
|
||||
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spinnerNumBackgrounds" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="50" max="-2" attributes="0"/>
|
||||
<Component id="checkElog" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="checkSaveImages" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="69" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="checkSaveImages" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="25" pref="124" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="comboSource" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@@ -241,7 +253,7 @@
|
||||
<Component class="javax.swing.JLabel" name="jLabel4">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="4"/>
|
||||
<Property name="text" type="java.lang.String" value="Settling time:"/>
|
||||
<Property name="text" type="java.lang.String" value="Source:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="spinnerSettlingTime">
|
||||
@@ -259,7 +271,7 @@
|
||||
<Component class="javax.swing.JSpinner" name="spinnerNumBackgrounds">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||
<SpinnerModel initial="5" maximum="10" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
|
||||
<SpinnerModel initial="5" maximum="100" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
@@ -308,10 +320,21 @@
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="checkElog">
|
||||
<Component class="javax.swing.JLabel" name="jLabel7">
|
||||
<Properties>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="text" type="java.lang.String" value="ELOG"/>
|
||||
<Property name="horizontalAlignment" type="int" value="4"/>
|
||||
<Property name="text" type="java.lang.String" value="Settling time:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="comboSource">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="3">
|
||||
<StringItem index="0" value="camtool"/>
|
||||
<StringItem index="1" value="direct"/>
|
||||
<StringItem index="2" value="bpm"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
@@ -333,10 +356,5 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonClearActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JProgressBar" name="progressBar">
|
||||
<Properties>
|
||||
<Property name="maximum" type="int" value="1000"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
||||
@@ -2,23 +2,14 @@
|
||||
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
|
||||
*/
|
||||
|
||||
import ch.psi.pshell.device.DescStatsDouble;
|
||||
import ch.psi.pshell.plot.LinePlotErrorSeries;
|
||||
import ch.psi.pshell.core.Context;
|
||||
import ch.psi.pshell.plot.LinePlotJFree;
|
||||
import ch.psi.pshell.plot.Plot;
|
||||
import ch.psi.pshell.scan.Scan;
|
||||
import ch.psi.pshell.scan.ScanListener;
|
||||
import ch.psi.pshell.scan.ScanRecord;
|
||||
import ch.psi.pshell.scan.ScanResult;
|
||||
import ch.psi.pshell.ui.Panel;
|
||||
import ch.psi.pshell.ui.Plugin;
|
||||
import ch.psi.utils.Convert;
|
||||
import ch.psi.utils.State;
|
||||
import java.awt.Component;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/**
|
||||
@@ -29,51 +20,41 @@ public class GunSolenoidAlignment extends Panel {
|
||||
public GunSolenoidAlignment() {
|
||||
initComponents();
|
||||
centroidPlot.setStyle(LinePlotJFree.Style.ErrorXY);
|
||||
setPersistedComponents(new Component[]{spinnerI1, spinnerI2, spinnerStep, spinnerSettlingTime,
|
||||
checkSaveImages, spinnerNumImages, spinnerNumBackgrounds, checkBackground, radioBackSimple, radioBackMultiple});
|
||||
centroidPlot.clear();
|
||||
}
|
||||
boolean running;
|
||||
|
||||
ScanListener scanListener = new ScanListener() {
|
||||
public void onNewRecord(Scan scan, ScanRecord record) {
|
||||
try {
|
||||
if (running) {
|
||||
DescStatsDouble x = (DescStatsDouble) record.getValues()[0];
|
||||
DescStatsDouble y = (DescStatsDouble) record.getValues()[1];
|
||||
DescStatsDouble stdev_x = (DescStatsDouble) record.getValues()[2];
|
||||
DescStatsDouble stdev_y = (DescStatsDouble) record.getValues()[3];
|
||||
scanSeries.appendData(x.getMean(), y.getMean(), Math.abs(stdev_x.getMean()), Math.abs(stdev_y.getMean()));
|
||||
progressBar.setValue((int) (1000.0 * record.getIndex() / scan.getNumberOfRecords()));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
getLogger().log(Level.WARNING, null, ex);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//Overridable callbacks
|
||||
@Override
|
||||
public void onInitialize(int runCount) {
|
||||
progressBar.setValue(0);
|
||||
getContext().addScanListener(scanListener);
|
||||
centroidPlot.getAxis(Plot.AxisId.X).setLabel("Centroid Excursion");
|
||||
if (runCount==0){
|
||||
try {
|
||||
evalAsync("kill_camtool()", true).handle((ret, ex) -> {
|
||||
if (ex != null) {
|
||||
showException((Exception) ex);
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
} catch (Context.ContextStateException ex) {
|
||||
showException((Exception) ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChange(State state, State former) {
|
||||
|
||||
buttonAbort.setEnabled(state == State.Busy);
|
||||
buttonRun.setEnabled(state == State.Ready);
|
||||
if (state != State.Busy) {
|
||||
running = false;
|
||||
}
|
||||
|
||||
progressBar.setIndeterminate(!state.isInitialized());
|
||||
|
||||
buttonClear.setEnabled(state == State.Ready);
|
||||
|
||||
for (Component c : panelParameters.getComponents()) {
|
||||
if (!(c instanceof JPanel)){
|
||||
if (!(c instanceof JPanel)) {
|
||||
c.setEnabled(state == State.Ready);
|
||||
}
|
||||
}
|
||||
if (state == State.Ready){
|
||||
}
|
||||
if (state == State.Ready) {
|
||||
checkBackgroundActionPerformed(null);
|
||||
}
|
||||
}
|
||||
@@ -87,38 +68,6 @@ public class GunSolenoidAlignment extends Panel {
|
||||
protected void doUpdate() {
|
||||
}
|
||||
|
||||
LinePlotErrorSeries scanSeries;
|
||||
|
||||
int index = 1;
|
||||
|
||||
void onEndScan(ScanResult sr, List hx, List hy) {
|
||||
progressBar.setValue(1000);
|
||||
double[] x = (double[]) Convert.toDouble(hx);
|
||||
double[] y = (double[]) Convert.toDouble(hy);
|
||||
LinePlotErrorSeries hull = new LinePlotErrorSeries(scanSeries.getName() + "H", scanSeries.getColor());
|
||||
centroidPlot.addSeries(hull);
|
||||
hull.setData((double[]) Convert.toDouble(x), (double[]) Convert.toDouble(y));
|
||||
|
||||
//Add ELOG entry
|
||||
if (checkElog.isSelected()) {
|
||||
String file = Paths.get(getContext().getSetup().getContextPath(), "CentroidPlot.jpg").toString();
|
||||
try {
|
||||
Thread.sleep(250); //Some time to plot update
|
||||
centroidPlot.saveSnapshot(file , "jpg");
|
||||
evalAsync("elog('Gun solenoid current scan', gsa_log_msg, ['"+ file +"',])", true).handle((ret, ex) -> {
|
||||
if (ex != null){
|
||||
getLogger().log(Level.WARNING, null, ex);
|
||||
} else {
|
||||
getLogger().info("Success generating ELOG entry");
|
||||
}
|
||||
return null;
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
@@ -143,10 +92,10 @@ public class GunSolenoidAlignment extends Panel {
|
||||
radioBackMultiple = new javax.swing.JRadioButton();
|
||||
jLabel6 = new javax.swing.JLabel();
|
||||
spinnerNumImages = new javax.swing.JSpinner();
|
||||
checkElog = new javax.swing.JCheckBox();
|
||||
jLabel7 = new javax.swing.JLabel();
|
||||
comboSource = new javax.swing.JComboBox();
|
||||
centroidPlot = new ch.psi.pshell.plot.LinePlotJFree();
|
||||
buttonClear = new javax.swing.JButton();
|
||||
progressBar = new javax.swing.JProgressBar();
|
||||
|
||||
buttonRun.setText("Run");
|
||||
buttonRun.addActionListener(new java.awt.event.ActionListener() {
|
||||
@@ -181,13 +130,13 @@ public class GunSolenoidAlignment extends Panel {
|
||||
spinnerStep.setName("spinnerStep"); // NOI18N
|
||||
|
||||
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
|
||||
jLabel4.setText("Settling time:");
|
||||
jLabel4.setText("Source:");
|
||||
|
||||
spinnerSettlingTime.setModel(new javax.swing.SpinnerNumberModel(0.1d, 0.0d, 10.0d, 1.0d));
|
||||
|
||||
checkSaveImages.setText("Save images");
|
||||
|
||||
spinnerNumBackgrounds.setModel(new javax.swing.SpinnerNumberModel(5, 1, 10, 1));
|
||||
spinnerNumBackgrounds.setModel(new javax.swing.SpinnerNumberModel(5, 1, 100, 1));
|
||||
|
||||
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
|
||||
jLabel5.setText("Number of backgrounds:");
|
||||
@@ -212,8 +161,10 @@ public class GunSolenoidAlignment extends Panel {
|
||||
|
||||
spinnerNumImages.setModel(new javax.swing.SpinnerNumberModel(1, 1, 100, 1));
|
||||
|
||||
checkElog.setSelected(true);
|
||||
checkElog.setText("ELOG");
|
||||
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
|
||||
jLabel7.setText("Settling time:");
|
||||
|
||||
comboSource.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "camtool", "direct", "bpm" }));
|
||||
|
||||
javax.swing.GroupLayout panelParametersLayout = new javax.swing.GroupLayout(panelParameters);
|
||||
panelParameters.setLayout(panelParametersLayout);
|
||||
@@ -234,35 +185,41 @@ public class GunSolenoidAlignment extends Panel {
|
||||
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(spinnerStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(panelParametersLayout.createSequentialGroup()
|
||||
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(spinnerSettlingTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelParametersLayout.createSequentialGroup()
|
||||
.addComponent(jLabel5)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(spinnerNumBackgrounds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(panelParametersLayout.createSequentialGroup()
|
||||
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(spinnerNumImages, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(panelParametersLayout.createSequentialGroup()
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelParametersLayout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(radioBackSimple)
|
||||
.addComponent(checkBackground))
|
||||
.addGroup(panelParametersLayout.createSequentialGroup()
|
||||
.addGap(36, 36, 36)
|
||||
.addComponent(radioBackMultiple))
|
||||
.addComponent(checkSaveImages)
|
||||
.addComponent(checkElog))
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelParametersLayout.createSequentialGroup()
|
||||
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(spinnerSettlingTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelParametersLayout.createSequentialGroup()
|
||||
.addComponent(jLabel5)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(spinnerNumBackgrounds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelParametersLayout.createSequentialGroup()
|
||||
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(comboSource, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelParametersLayout.createSequentialGroup()
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(checkBackground)
|
||||
.addComponent(checkSaveImages)
|
||||
.addGroup(panelParametersLayout.createSequentialGroup()
|
||||
.addGap(35, 35, 35)
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(radioBackSimple)
|
||||
.addComponent(radioBackMultiple))))
|
||||
.addGap(127, 127, 127)))))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerI1, spinnerI2, spinnerNumBackgrounds, spinnerNumImages, spinnerSettlingTime, spinnerStep});
|
||||
|
||||
panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3, jLabel4, jLabel5, jLabel6});
|
||||
panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3, jLabel5, jLabel6});
|
||||
|
||||
panelParametersLayout.setVerticalGroup(
|
||||
panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
@@ -281,8 +238,8 @@ public class GunSolenoidAlignment extends Panel {
|
||||
.addComponent(spinnerStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel4)
|
||||
.addComponent(spinnerSettlingTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(spinnerSettlingTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel7))
|
||||
.addGap(4, 4, 4)
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel6)
|
||||
@@ -297,11 +254,17 @@ public class GunSolenoidAlignment extends Panel {
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel5)
|
||||
.addComponent(spinnerNumBackgrounds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(50, 50, 50)
|
||||
.addComponent(checkElog)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(checkSaveImages)
|
||||
.addContainerGap(69, Short.MAX_VALUE))
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelParametersLayout.createSequentialGroup()
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(checkSaveImages)
|
||||
.addGap(25, 124, Short.MAX_VALUE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelParametersLayout.createSequentialGroup()
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(comboSource, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel4))
|
||||
.addContainerGap())))
|
||||
);
|
||||
|
||||
centroidPlot.setLegendVisible(true);
|
||||
@@ -315,8 +278,6 @@ public class GunSolenoidAlignment extends Panel {
|
||||
}
|
||||
});
|
||||
|
||||
progressBar.setMaximum(1000);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
@@ -326,18 +287,19 @@ public class GunSolenoidAlignment extends Panel {
|
||||
.addComponent(panelParameters, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(centroidPlot, javax.swing.GroupLayout.DEFAULT_SIZE, 443, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(11, 11, 11)
|
||||
.addComponent(buttonRun, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(buttonAbort, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(12, 12, 12)
|
||||
.addComponent(progressBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(buttonClear))
|
||||
.addComponent(centroidPlot, javax.swing.GroupLayout.DEFAULT_SIZE, 443, Short.MAX_VALUE))
|
||||
.addComponent(buttonAbort, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonClear)))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonAbort, buttonClear, buttonRun});
|
||||
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
@@ -346,13 +308,10 @@ public class GunSolenoidAlignment extends Panel {
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(buttonRun)
|
||||
.addComponent(buttonAbort))
|
||||
.addComponent(buttonAbort)
|
||||
.addComponent(buttonClear))
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(centroidPlot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(buttonClear)
|
||||
.addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addComponent(centroidPlot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addComponent(panelParameters, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
@@ -370,11 +329,6 @@ public class GunSolenoidAlignment extends Panel {
|
||||
|
||||
private void buttonRunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRunActionPerformed
|
||||
try {
|
||||
progressBar.setValue(0);
|
||||
scanSeries = new LinePlotErrorSeries(String.valueOf(index++));
|
||||
centroidPlot.addSeries(scanSeries);
|
||||
scanSeries.setLinesVisible(false);
|
||||
scanSeries.setPointSize(4);
|
||||
running = true;
|
||||
|
||||
HashMap args = new HashMap();
|
||||
@@ -387,11 +341,17 @@ public class GunSolenoidAlignment extends Panel {
|
||||
args.put("number_backgrounds", spinnerNumBackgrounds.getValue());
|
||||
args.put("use_background", checkBackground.isSelected());
|
||||
args.put("multiple_background", radioBackMultiple.isSelected());
|
||||
args.put("do_elog", checkElog.isSelected());
|
||||
args.put("centroid_plot", centroidPlot);
|
||||
args.put("source", comboSource.getSelectedItem().toString());
|
||||
|
||||
runAsync("Alignment/Gun_solenoid_alignment", args).thenAccept((Object ret) -> {
|
||||
List l = (List) ret;
|
||||
onEndScan((ScanResult) l.get(0), (List) l.get(1), (List) l.get(2));
|
||||
runAsync("Alignment/Gun_solenoid_alignment", args).handle((ret, ex) -> {
|
||||
if (ex != null) {
|
||||
getLogger().info("Exception executing scan: " + ex);
|
||||
showException((Exception) ex);
|
||||
} else {
|
||||
}
|
||||
running = false;
|
||||
return ret;
|
||||
});
|
||||
|
||||
} catch (Exception ex) {
|
||||
@@ -408,7 +368,6 @@ public class GunSolenoidAlignment extends Panel {
|
||||
|
||||
private void buttonClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonClearActionPerformed
|
||||
try {
|
||||
index = 1;
|
||||
centroidPlot.clear();
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
@@ -422,16 +381,16 @@ public class GunSolenoidAlignment extends Panel {
|
||||
private javax.swing.JButton buttonRun;
|
||||
private ch.psi.pshell.plot.LinePlotJFree centroidPlot;
|
||||
private javax.swing.JCheckBox checkBackground;
|
||||
private javax.swing.JCheckBox checkElog;
|
||||
private javax.swing.JCheckBox checkSaveImages;
|
||||
private javax.swing.JComboBox comboSource;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JLabel jLabel3;
|
||||
private javax.swing.JLabel jLabel4;
|
||||
private javax.swing.JLabel jLabel5;
|
||||
private javax.swing.JLabel jLabel6;
|
||||
private javax.swing.JLabel jLabel7;
|
||||
private javax.swing.JPanel panelParameters;
|
||||
private javax.swing.JProgressBar progressBar;
|
||||
private javax.swing.JRadioButton radioBackMultiple;
|
||||
private javax.swing.JRadioButton radioBackSimple;
|
||||
private javax.swing.JSpinner spinnerI1;
|
||||
|
||||
@@ -21,22 +21,18 @@
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="panelParameters" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="buttonRun" min="-2" pref="92" max="-2" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="buttonRun" linkSize="3" min="-2" pref="92" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="buttonAbort" min="-2" pref="92" max="-2" attributes="0"/>
|
||||
<Component id="buttonAbort" linkSize="3" min="-2" pref="92" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="buttonClear" linkSize="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
|
||||
<Component id="progressBar" max="32767" attributes="0"/>
|
||||
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="buttonClear" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="centroidPlot" alignment="0" pref="412" max="32767" attributes="0"/>
|
||||
<Component id="centroidPlot" pref="412" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@@ -51,14 +47,10 @@
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="buttonRun" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="buttonAbort" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="buttonClear" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="centroidPlot" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Component id="buttonClear" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="progressBar" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Component id="panelParameters" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
@@ -96,53 +88,56 @@
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="12" pref="12" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="checkBackground" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="checkSaveImages" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="136" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="47" pref="47" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="radioBackMultiple" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="radioBackSimple" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel1" linkSize="2" min="-2" pref="158" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="spinnerI1" linkSize="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel2" linkSize="2" min="-2" pref="158" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="spinnerI2" linkSize="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel3" linkSize="2" min="-2" pref="158" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="spinnerStep" linkSize="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel4" linkSize="2" min="-2" pref="158" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="spinnerSettlingTime" linkSize="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="jLabel5" linkSize="2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="spinnerNumBackgrounds" linkSize="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel6" linkSize="2" min="-2" pref="158" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="spinnerNumImages" linkSize="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="103" alignment="0" groupAlignment="1" attributes="0">
|
||||
<Component id="radioBackSimple" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="checkBackground" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="jLabel5" linkSize="2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="36" max="-2" attributes="0"/>
|
||||
<Component id="radioBackMultiple" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel1" linkSize="2" min="-2" pref="158" max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" linkSize="2" min="-2" pref="158" max="-2" attributes="0"/>
|
||||
<Component id="jLabel3" linkSize="2" min="-2" pref="158" max="-2" attributes="0"/>
|
||||
<Component id="jLabel4" linkSize="2" min="-2" pref="158" max="-2" attributes="0"/>
|
||||
<Component id="jLabel6" linkSize="2" min="-2" pref="158" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="checkSaveImages" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="checkElog" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="spinnerNumImages" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spinnerStep" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spinnerSettlingTime" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spinnerNumBackgrounds" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spinnerI1" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spinnerI2" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<Component id="jLabel7" min="-2" pref="75" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="comboSource" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
@@ -188,11 +183,14 @@
|
||||
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spinnerNumBackgrounds" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="57" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="checkSaveImages" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="98" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="comboSource" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="checkElog" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="72" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@@ -259,7 +257,7 @@
|
||||
<Component class="javax.swing.JSpinner" name="spinnerNumBackgrounds">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||
<SpinnerModel initial="5" maximum="10" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
|
||||
<SpinnerModel initial="5" maximum="100" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
@@ -304,14 +302,25 @@
|
||||
<Component class="javax.swing.JSpinner" name="spinnerNumImages">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||
<SpinnerModel initial="0" maximum="10" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/>
|
||||
<SpinnerModel initial="1" maximum="100" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="checkElog">
|
||||
<Component class="javax.swing.JLabel" name="jLabel7">
|
||||
<Properties>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="text" type="java.lang.String" value="ELOG"/>
|
||||
<Property name="horizontalAlignment" type="int" value="4"/>
|
||||
<Property name="text" type="java.lang.String" value="Source:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="comboSource">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="3">
|
||||
<StringItem index="0" value="camtool"/>
|
||||
<StringItem index="1" value="direct"/>
|
||||
<StringItem index="2" value="bpm"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
@@ -333,10 +342,5 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonClearActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JProgressBar" name="progressBar">
|
||||
<Properties>
|
||||
<Property name="maximum" type="int" value="1000"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
||||
+91
-141
@@ -2,23 +2,12 @@
|
||||
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
|
||||
*/
|
||||
|
||||
import ch.psi.pshell.device.DescStatsDouble;
|
||||
import ch.psi.pshell.plot.LinePlotErrorSeries;
|
||||
import ch.psi.pshell.core.Context;
|
||||
import ch.psi.pshell.plot.LinePlotJFree;
|
||||
import ch.psi.pshell.plot.Plot;
|
||||
import ch.psi.pshell.scan.Scan;
|
||||
import ch.psi.pshell.scan.ScanListener;
|
||||
import ch.psi.pshell.scan.ScanRecord;
|
||||
import ch.psi.pshell.scan.ScanResult;
|
||||
import ch.psi.pshell.ui.Panel;
|
||||
import ch.psi.pshell.ui.Plugin;
|
||||
import ch.psi.utils.Convert;
|
||||
import ch.psi.utils.State;
|
||||
import java.awt.Component;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/**
|
||||
@@ -29,51 +18,44 @@ public class LaserGunAlignment extends Panel {
|
||||
public LaserGunAlignment() {
|
||||
initComponents();
|
||||
centroidPlot.setStyle(LinePlotJFree.Style.ErrorXY);
|
||||
setPersistedComponents(new Component[]{spinnerI1, spinnerI2, spinnerStep, spinnerSettlingTime,
|
||||
checkSaveImages, spinnerNumImages, spinnerNumBackgrounds, checkBackground, radioBackSimple, radioBackMultiple});
|
||||
centroidPlot.clear();
|
||||
}
|
||||
boolean running;
|
||||
|
||||
ScanListener scanListener = new ScanListener() {
|
||||
public void onNewRecord(Scan scan, ScanRecord record) {
|
||||
try {
|
||||
if (running) {
|
||||
DescStatsDouble x = (DescStatsDouble) record.getValues()[0];
|
||||
DescStatsDouble y = (DescStatsDouble) record.getValues()[1];
|
||||
DescStatsDouble stdev_x = (DescStatsDouble) record.getValues()[2];
|
||||
DescStatsDouble stdev_y = (DescStatsDouble) record.getValues()[3];
|
||||
scanSeries.appendData(x.getMean(), y.getMean(), Math.abs(stdev_x.getMean()), Math.abs(stdev_y.getMean()));
|
||||
progressBar.setValue((int) (1000.0 * record.getIndex() / scan.getNumberOfRecords()));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
getLogger().log(Level.WARNING, null, ex);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//Overridable callbacks
|
||||
@Override
|
||||
public void onInitialize(int runCount) {
|
||||
progressBar.setValue(0);
|
||||
getContext().addScanListener(scanListener);
|
||||
centroidPlot.getAxis(Plot.AxisId.X).setLabel("Centroid Excursion");
|
||||
if (runCount==0){
|
||||
try {
|
||||
evalAsync("kill_camtool()", true).handle((ret, ex) -> {
|
||||
if (ex != null) {
|
||||
showException((Exception) ex);
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
} catch (Context.ContextStateException ex) {
|
||||
showException((Exception) ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChange(State state, State former) {
|
||||
|
||||
buttonAbort.setEnabled(state == State.Busy);
|
||||
buttonRun.setEnabled(state == State.Ready);
|
||||
buttonClear.setEnabled(state == State.Ready);
|
||||
if (state != State.Busy) {
|
||||
running = false;
|
||||
}
|
||||
|
||||
progressBar.setIndeterminate(!state.isInitialized());
|
||||
|
||||
|
||||
for (Component c : panelParameters.getComponents()) {
|
||||
if (!(c instanceof JPanel)){
|
||||
if (!(c instanceof JPanel)) {
|
||||
c.setEnabled(state == State.Ready);
|
||||
}
|
||||
}
|
||||
if (state == State.Ready){
|
||||
}
|
||||
if (state == State.Ready) {
|
||||
checkBackgroundActionPerformed(null);
|
||||
}
|
||||
}
|
||||
@@ -87,37 +69,6 @@ public class LaserGunAlignment extends Panel {
|
||||
protected void doUpdate() {
|
||||
}
|
||||
|
||||
LinePlotErrorSeries scanSeries;
|
||||
|
||||
int index = 1;
|
||||
|
||||
void onEndScan(ScanResult sr, List hx, List hy) {
|
||||
progressBar.setValue(1000);
|
||||
double[] x = (double[]) Convert.toDouble(hx);
|
||||
double[] y = (double[]) Convert.toDouble(hy);
|
||||
LinePlotErrorSeries hull = new LinePlotErrorSeries(scanSeries.getName() + "H", scanSeries.getColor());
|
||||
centroidPlot.addSeries(hull);
|
||||
hull.setData((double[]) Convert.toDouble(x), (double[]) Convert.toDouble(y));
|
||||
//Add ELOG entry
|
||||
if (checkElog.isSelected()) {
|
||||
String file = Paths.get(getContext().getSetup().getContextPath(), "CentroidPlot.jpg").toString();
|
||||
try {
|
||||
Thread.sleep(250); //Some time to plot update
|
||||
centroidPlot.saveSnapshot(file , "jpg");
|
||||
evalAsync("elog('Gun solenoid current scan', gsa_log_msg, ['"+ file +"',])", true).handle((ret, ex) -> {
|
||||
if (ex != null){
|
||||
getLogger().log(Level.WARNING, null, ex);
|
||||
} else {
|
||||
getLogger().info("Success generating ELOG entry");
|
||||
}
|
||||
return null;
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
@@ -142,10 +93,10 @@ public class LaserGunAlignment extends Panel {
|
||||
radioBackMultiple = new javax.swing.JRadioButton();
|
||||
jLabel6 = new javax.swing.JLabel();
|
||||
spinnerNumImages = new javax.swing.JSpinner();
|
||||
checkElog = new javax.swing.JCheckBox();
|
||||
jLabel7 = new javax.swing.JLabel();
|
||||
comboSource = new javax.swing.JComboBox();
|
||||
centroidPlot = new ch.psi.pshell.plot.LinePlotJFree();
|
||||
buttonClear = new javax.swing.JButton();
|
||||
progressBar = new javax.swing.JProgressBar();
|
||||
|
||||
buttonRun.setText("Run");
|
||||
buttonRun.addActionListener(new java.awt.event.ActionListener() {
|
||||
@@ -186,7 +137,7 @@ public class LaserGunAlignment extends Panel {
|
||||
|
||||
checkSaveImages.setText("Save images");
|
||||
|
||||
spinnerNumBackgrounds.setModel(new javax.swing.SpinnerNumberModel(5, 1, 10, 1));
|
||||
spinnerNumBackgrounds.setModel(new javax.swing.SpinnerNumberModel(5, 1, 100, 1));
|
||||
|
||||
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
|
||||
jLabel5.setText("Number of backgrounds:");
|
||||
@@ -209,53 +160,57 @@ public class LaserGunAlignment extends Panel {
|
||||
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
|
||||
jLabel6.setText("Number of images:");
|
||||
|
||||
spinnerNumImages.setModel(new javax.swing.SpinnerNumberModel(0, 0, 10, 1));
|
||||
spinnerNumImages.setModel(new javax.swing.SpinnerNumberModel(1, 1, 100, 1));
|
||||
|
||||
checkElog.setSelected(true);
|
||||
checkElog.setText("ELOG");
|
||||
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
|
||||
jLabel7.setText("Source:");
|
||||
|
||||
comboSource.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "camtool", "direct", "bpm" }));
|
||||
|
||||
javax.swing.GroupLayout panelParametersLayout = new javax.swing.GroupLayout(panelParameters);
|
||||
panelParameters.setLayout(panelParametersLayout);
|
||||
panelParametersLayout.setHorizontalGroup(
|
||||
panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelParametersLayout.createSequentialGroup()
|
||||
.addGap(12, 12, 12)
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(checkBackground)
|
||||
.addComponent(checkSaveImages))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addGroup(panelParametersLayout.createSequentialGroup()
|
||||
.addGap(47, 47, 47)
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(radioBackMultiple)
|
||||
.addComponent(radioBackSimple))
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addGroup(panelParametersLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelParametersLayout.createSequentialGroup()
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(spinnerI1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(panelParametersLayout.createSequentialGroup()
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(spinnerI2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(panelParametersLayout.createSequentialGroup()
|
||||
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(spinnerStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(panelParametersLayout.createSequentialGroup()
|
||||
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(spinnerSettlingTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelParametersLayout.createSequentialGroup()
|
||||
.addComponent(jLabel5)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(spinnerNumBackgrounds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(panelParametersLayout.createSequentialGroup()
|
||||
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(spinnerNumImages, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(panelParametersLayout.createSequentialGroup()
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(radioBackSimple)
|
||||
.addComponent(checkBackground))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelParametersLayout.createSequentialGroup()
|
||||
.addComponent(jLabel5)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
|
||||
.addGroup(panelParametersLayout.createSequentialGroup()
|
||||
.addGap(36, 36, 36)
|
||||
.addComponent(radioBackMultiple))
|
||||
.addComponent(checkSaveImages)
|
||||
.addComponent(checkElog))
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(spinnerNumImages, 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)
|
||||
.addComponent(spinnerSettlingTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(spinnerNumBackgrounds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(spinnerI1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(spinnerI2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelParametersLayout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(comboSource, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
@@ -296,11 +251,13 @@ public class LaserGunAlignment extends Panel {
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel5)
|
||||
.addComponent(spinnerNumBackgrounds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(57, 57, 57)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(checkSaveImages)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(checkElog)
|
||||
.addContainerGap(72, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 98, Short.MAX_VALUE)
|
||||
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(comboSource, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel7))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
centroidPlot.setLegendVisible(true);
|
||||
@@ -314,8 +271,6 @@ public class LaserGunAlignment extends Panel {
|
||||
}
|
||||
});
|
||||
|
||||
progressBar.setMaximum(1000);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
@@ -325,18 +280,18 @@ public class LaserGunAlignment extends Panel {
|
||||
.addComponent(panelParameters, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(buttonRun, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(buttonAbort, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(12, 12, 12)
|
||||
.addComponent(progressBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(buttonAbort, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonClear))
|
||||
.addComponent(centroidPlot, javax.swing.GroupLayout.DEFAULT_SIZE, 412, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonAbort, buttonClear, buttonRun});
|
||||
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
@@ -345,13 +300,10 @@ public class LaserGunAlignment extends Panel {
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(buttonRun)
|
||||
.addComponent(buttonAbort))
|
||||
.addComponent(buttonAbort)
|
||||
.addComponent(buttonClear))
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(centroidPlot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(buttonClear)
|
||||
.addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addComponent(centroidPlot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addComponent(panelParameters, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
@@ -369,13 +321,7 @@ public class LaserGunAlignment extends Panel {
|
||||
|
||||
private void buttonRunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRunActionPerformed
|
||||
try {
|
||||
progressBar.setValue(0);
|
||||
scanSeries = new LinePlotErrorSeries(String.valueOf(index++));
|
||||
centroidPlot.addSeries(scanSeries);
|
||||
scanSeries.setLinesVisible(false);
|
||||
scanSeries.setPointSize(4);
|
||||
running = true;
|
||||
|
||||
HashMap args = new HashMap();
|
||||
args.put("phi1", spinnerI1.getValue());
|
||||
args.put("phi2", spinnerI2.getValue());
|
||||
@@ -386,12 +332,17 @@ public class LaserGunAlignment extends Panel {
|
||||
args.put("number_backgrounds", spinnerNumBackgrounds.getValue());
|
||||
args.put("use_background", checkBackground.isSelected());
|
||||
args.put("multiple_background", radioBackMultiple.isSelected());
|
||||
//args.put("zero_solenoids", checkZeroSolenoids.isSelected());
|
||||
args.put("do_elog", checkElog.isSelected());
|
||||
|
||||
runAsync("Alignment/Laser_gun_alignment", args).thenAccept((Object ret) -> {
|
||||
List l = (List) ret;
|
||||
onEndScan((ScanResult) l.get(0), (List) l.get(1), (List) l.get(2));
|
||||
args.put("centroid_plot", centroidPlot);
|
||||
args.put("source", comboSource.getSelectedItem().toString());
|
||||
|
||||
runAsync("Alignment/Laser_gun_alignment", args).handle((ret, ex) -> {
|
||||
if (ex != null) {
|
||||
getLogger().info("Exception executing scan: " + ex);
|
||||
showException((Exception) ex);
|
||||
} else {
|
||||
}
|
||||
running = false;
|
||||
return ret;
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
System.err.println(ex);
|
||||
@@ -408,7 +359,6 @@ public class LaserGunAlignment extends Panel {
|
||||
|
||||
private void buttonClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonClearActionPerformed
|
||||
try {
|
||||
index = 1;
|
||||
centroidPlot.clear();
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
@@ -422,16 +372,16 @@ public class LaserGunAlignment extends Panel {
|
||||
private javax.swing.JButton buttonRun;
|
||||
private ch.psi.pshell.plot.LinePlotJFree centroidPlot;
|
||||
private javax.swing.JCheckBox checkBackground;
|
||||
private javax.swing.JCheckBox checkElog;
|
||||
private javax.swing.JCheckBox checkSaveImages;
|
||||
private javax.swing.JComboBox comboSource;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JLabel jLabel3;
|
||||
private javax.swing.JLabel jLabel4;
|
||||
private javax.swing.JLabel jLabel5;
|
||||
private javax.swing.JLabel jLabel6;
|
||||
private javax.swing.JLabel jLabel7;
|
||||
private javax.swing.JPanel panelParameters;
|
||||
private javax.swing.JProgressBar progressBar;
|
||||
private javax.swing.JRadioButton radioBackMultiple;
|
||||
private javax.swing.JRadioButton radioBackSimple;
|
||||
private javax.swing.JSpinner spinnerI1;
|
||||
|
||||
+10
-197
@@ -3,20 +3,16 @@
|
||||
*/
|
||||
|
||||
import ch.psi.pshell.core.Context;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import ch.psi.pshell.ui.Panel;
|
||||
import ch.psi.pshell.imaging.ImageListener;
|
||||
import ch.psi.utils.State;
|
||||
import ch.psi.utils.IO;
|
||||
import ch.psi.utils.Chrono;
|
||||
import ch.psi.utils.swing.SwingUtils;
|
||||
import ch.psi.utils.swing.TextEditor;
|
||||
import ch.psi.pshell.epics.PsiCamera;
|
||||
import ch.psi.pshell.bs.Camtool;
|
||||
import ch.psi.pshell.core.JsonSerializer;
|
||||
import ch.psi.pshell.device.DescStatsDouble;
|
||||
import ch.psi.pshell.device.Device;
|
||||
import ch.psi.pshell.epics.ChannelInteger;
|
||||
@@ -38,7 +34,6 @@ import ch.psi.pshell.imaging.Renderer;
|
||||
import ch.psi.pshell.imaging.RendererListener;
|
||||
import ch.psi.pshell.imaging.RendererMode;
|
||||
import ch.psi.pshell.imaging.Source;
|
||||
import ch.psi.pshell.imaging.Utils;
|
||||
import ch.psi.pshell.scripting.InterpreterResult;
|
||||
import ch.psi.pshell.scripting.ScriptManager;
|
||||
import ch.psi.pshell.swing.ValueSelection;
|
||||
@@ -96,7 +91,6 @@ import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
|
||||
*/
|
||||
public class ScreenPanel extends Panel {
|
||||
|
||||
final String CONFIG_FOLDER = "/afs/psi.ch/intranet/SF/Applications/config/camtool_n";
|
||||
final String CAMERA_DEVICE_NAME = "CurrentCamera";
|
||||
boolean useCamtoolStats = true;
|
||||
|
||||
@@ -104,7 +98,6 @@ public class ScreenPanel extends Panel {
|
||||
ColormapSource camera;
|
||||
String cameraName;
|
||||
String cameraConfigJson;
|
||||
CameraConfig config;
|
||||
int polling = 1000;
|
||||
Overlay marker = null;
|
||||
JDialog histogramDialog;
|
||||
@@ -354,7 +347,8 @@ public class ScreenPanel extends Panel {
|
||||
//cmd = "source /opt/gfa/python\n" + cmd;
|
||||
//privateServer = Runtime.getRuntime().exec(new String[]{"bash", "-c", cmd});
|
||||
String cmd = "/opt/gfa/python-3.5/2.4.1/bin/python /opt/gfa/python-3.5/latest/bin/cam_server";
|
||||
cmd = cmd + " -p " + localServerPort + " -b " + CONFIG_FOLDER;
|
||||
String configFolder = (String) getContext().getClassByName("SfCamera").getMethod("getConfigFolder", new Class[]{}).invoke(null);
|
||||
cmd = cmd + " -p " + localServerPort + " -b " + configFolder;
|
||||
privateServer = Runtime.getRuntime().exec(cmd);
|
||||
//System.out.println("pid = " + Sys.getPid(privateServer));
|
||||
long start = System.currentTimeMillis();
|
||||
@@ -447,16 +441,11 @@ public class ScreenPanel extends Panel {
|
||||
startTimer(1000);
|
||||
}
|
||||
|
||||
DefaultComboBoxModel getCameraListFromFolder() {
|
||||
File[] cameraConfigFiles = new File[0];
|
||||
cameraConfigFiles = IO.listFiles(CONFIG_FOLDER, new String[]{"json"});
|
||||
Arrays.sort(cameraConfigFiles, (a, b) -> a.compareTo(b));
|
||||
DefaultComboBoxModel getCameraListFromFolder() throws Exception {
|
||||
ArrayList<String> cameras = (ArrayList<String>) getContext().getClassByName("SfCamera").getMethod("getCameras", new Class[]{}).invoke(null);
|
||||
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
||||
for (File file : cameraConfigFiles) {
|
||||
String prefix = IO.getPrefix(file);
|
||||
if (!prefix.startsWith("#") && !prefix.endsWith("_parameters")) {
|
||||
model.addElement(prefix);
|
||||
}
|
||||
for (String cam:cameras) {
|
||||
model.addElement(cam);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
@@ -551,116 +540,6 @@ public class ScreenPanel extends Panel {
|
||||
protected void doUpdate() {
|
||||
}
|
||||
|
||||
public static class CameraConfig {
|
||||
|
||||
public HashMap camera;
|
||||
|
||||
public HashMap getCalibration() {
|
||||
return (HashMap) camera.get("calibration");
|
||||
}
|
||||
|
||||
public ArrayList<Integer> getCalibrationRefMarker() {
|
||||
return (ArrayList<Integer>) getCalibration().get("reference_marker");
|
||||
}
|
||||
|
||||
public double getCalOffsetX() {
|
||||
ArrayList<Integer> calibration = getCalibrationRefMarker();
|
||||
double ret = -(calibration.get(0) + calibration.get(2)) / 2;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public double getCalOffsetY() {
|
||||
ArrayList<Integer> calibration = getCalibrationRefMarker();
|
||||
double ret = -(calibration.get(1) + calibration.get(3)) / 2;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public double getScaleX() {
|
||||
ArrayList<Integer> calibration = getCalibrationRefMarker();
|
||||
double width = Math.abs(calibration.get(2) - calibration.get(0));
|
||||
return getCalibrationWidth() / width;
|
||||
}
|
||||
|
||||
public double getScaleY() {
|
||||
ArrayList<Integer> calibration = getCalibrationRefMarker();
|
||||
double height = Math.abs(calibration.get(3) - calibration.get(1));
|
||||
return getCalibrationHeight() / height;
|
||||
}
|
||||
|
||||
public Double getCalibrationHeight() {
|
||||
return (Double) getCalibration().get("reference_marker_height");
|
||||
}
|
||||
|
||||
public Double getCalibrationWidth() {
|
||||
return (Double) getCalibration().get("reference_marker_width");
|
||||
}
|
||||
|
||||
public Double getCalibrationHorizontalAngle() {
|
||||
return (Double) getCalibration().get("horizontal_camera_angle");
|
||||
}
|
||||
|
||||
public Double getCalibrationVerticalAngle() {
|
||||
return (Double) getCalibration().get("vertical_camera_angle");
|
||||
}
|
||||
|
||||
public boolean getMirrorX() {
|
||||
Boolean ret = (Boolean) camera.get("mirror_x");
|
||||
return (ret == null) ? false : ret;
|
||||
}
|
||||
|
||||
public boolean getMirrorY() {
|
||||
Boolean ret = (Boolean) camera.get("mirror_y");
|
||||
return (ret == null) ? false : ret;
|
||||
}
|
||||
|
||||
public int getRotate() {
|
||||
Integer ret = (Integer) camera.get("rotate");
|
||||
return (ret == null) ? 0 : ret;
|
||||
}
|
||||
|
||||
public ArrayList<Integer> getRoi() {
|
||||
return (ArrayList<Integer>) camera.get("roi");
|
||||
}
|
||||
|
||||
public Boolean getRoiEnable() {
|
||||
if ((camera.get("roi_enable") == null) || (camera.get("roi") == null)) {
|
||||
return false;
|
||||
}
|
||||
return (Boolean) camera.get("roi_enable");
|
||||
}
|
||||
}
|
||||
|
||||
public static class CameraPars {
|
||||
|
||||
public HashMap parameter;
|
||||
|
||||
public Boolean getBackgroundSubtraction() {
|
||||
if (parameter.get("background_subtration") == null){
|
||||
return false;
|
||||
}
|
||||
return (Boolean) parameter.get("background_subtration");
|
||||
}
|
||||
|
||||
public ArrayList<Integer> getRoi() {
|
||||
return (ArrayList<Integer>) parameter.get("region_of_interest");
|
||||
}
|
||||
|
||||
public Boolean getRoiEnable() {
|
||||
ArrayList<Integer> roi = getRoi();
|
||||
return ((roi != null) && (roi.size()>=4));
|
||||
}
|
||||
|
||||
public HashMap getGoodRegion() {
|
||||
return (HashMap) parameter.get("good_region");
|
||||
}
|
||||
|
||||
public Double getThresholde() {
|
||||
return (Double) parameter.get("threshold");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Thread devicesInitTask;
|
||||
|
||||
void setCamera(String cameraName) throws IOException, InterruptedException {
|
||||
@@ -712,7 +591,8 @@ public class ScreenPanel extends Panel {
|
||||
}
|
||||
|
||||
try {
|
||||
Path configFile = Paths.get(CONFIG_FOLDER, cameraName + ".json");
|
||||
String configFolder = (String) getContext().getClassByName("SfCamera").getMethod("getConfigFolder", new Class[]{}).invoke(null);
|
||||
Path configFile = Paths.get(configFolder, cameraName + ".json");
|
||||
cameraConfigJson = configFile.toFile().exists() ? new String(Files.readAllBytes(configFile)) : null;
|
||||
|
||||
if (buttonCamtool.isSelected()) {
|
||||
@@ -725,67 +605,8 @@ public class ScreenPanel extends Panel {
|
||||
camera.getConfig().roiWidth = -1;
|
||||
camera.getConfig().roiHeight = -1;
|
||||
} else {
|
||||
if ((cameraConfigJson == null) && (buttonDirect.isSelected())) {
|
||||
throw new Exception("Cannot open camera config file: " + configFile.toFile());
|
||||
}
|
||||
|
||||
camera = new PsiCamera(CAMERA_DEVICE_NAME, cameraName);
|
||||
config = (CameraConfig) JsonSerializer.decode(cameraConfigJson, CameraConfig.class);
|
||||
|
||||
CameraPars cameraPars = null;
|
||||
camera.getConfig().roiX = 0; camera.getConfig().roiY = 0;
|
||||
camera.getConfig().roiWidth = -1; camera.getConfig().roiHeight =-1;
|
||||
|
||||
try{
|
||||
Path parsFile = Paths.get(CONFIG_FOLDER, cameraName + "_parameters.json");
|
||||
if (parsFile.toFile().exists()){
|
||||
String cameraParsJson = new String(Files.readAllBytes(parsFile));
|
||||
cameraPars = (CameraPars) JsonSerializer.decode(cameraParsJson, CameraPars.class);
|
||||
if (cameraPars.getRoiEnable()){
|
||||
camera.getConfig().roiX = cameraPars.getRoi().get(0);
|
||||
camera.getConfig().roiY = cameraPars.getRoi().get(2);
|
||||
camera.getConfig().roiWidth = cameraPars.getRoi().get(1);
|
||||
camera.getConfig().roiHeight = cameraPars.getRoi().get(3);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
camera.getConfig().flipHorizontally = config.getMirrorX();
|
||||
camera.getConfig().flipVertically = config.getMirrorY();
|
||||
//camera.getConfig().rotation = config.getRotate();
|
||||
//camera.getConfig().rotationCrop = true;
|
||||
switch (config.getRotate()) {
|
||||
case 1:
|
||||
camera.getConfig().rotation = 270;
|
||||
break;
|
||||
case 2:
|
||||
camera.getConfig().rotation = 180;
|
||||
break;
|
||||
case 3:
|
||||
camera.getConfig().rotation = 90;
|
||||
break;
|
||||
}
|
||||
camera.getConfig().rotationCrop = false;
|
||||
//if (config.getRoiEnable()){
|
||||
// camera.getConfig().roiX = config.getRoi().get(0);
|
||||
// camera.getConfig().roiY = config.getRoi().get(1);
|
||||
// camera.getConfig().roiWidth = config.getRoi().get(2);
|
||||
// camera.getConfig().roiHeight = config.getRoi().get(3);
|
||||
//}
|
||||
try {
|
||||
camera.getConfig().spatialCalOffsetX = config.getCalOffsetX();
|
||||
camera.getConfig().spatialCalOffsetY = config.getCalOffsetY();
|
||||
camera.getConfig().spatialCalScaleX = -config.getScaleX();
|
||||
camera.getConfig().spatialCalScaleY = -config.getScaleY();
|
||||
} catch (Exception ex) {
|
||||
camera.getConfig().spatialCalOffsetX = Double.NaN;
|
||||
camera.getConfig().spatialCalOffsetY = Double.NaN;
|
||||
camera.getConfig().spatialCalScaleX = Double.NaN;
|
||||
camera.getConfig().spatialCalScaleY = Double.NaN;
|
||||
}
|
||||
//camera = new SfCamera(CAMERA_DEVICE_NAME, cameraName);
|
||||
camera = (ColormapSource) getContext().getClassByName("SfCamera").getConstructor(new Class[]{String.class, String.class}).newInstance(new Object[]{CAMERA_DEVICE_NAME, cameraName});
|
||||
}
|
||||
camera.initialize();
|
||||
camera.assertInitialized();
|
||||
@@ -805,14 +626,6 @@ public class ScreenPanel extends Panel {
|
||||
|
||||
((Camtool) camera).startReceiver();
|
||||
} else {
|
||||
/*
|
||||
if (camera.getConfig() instanceof PsiCamera.PsiCameraConfig){
|
||||
if (camera.getConfig().isCalibrated()){
|
||||
camera.getConfig().spatialCalOffsetX += ((PsiCamera.PsiCameraConfig)camera.getConfig()).regionStartX;
|
||||
camera.getConfig().spatialCalOffsetY += ((PsiCamera.PsiCameraConfig)camera.getConfig()).regionStartY;
|
||||
}
|
||||
}
|
||||
*/
|
||||
if (polling <= 0) {
|
||||
camera.setMonitored(true);
|
||||
} else {
|
||||
|
||||
+52
-29
@@ -15,20 +15,29 @@ import javax.swing.DefaultComboBoxModel;
|
||||
|
||||
public class SfCamera extends PsiCamera{
|
||||
|
||||
final static String CONFIG_FOLDER = "/afs/psi.ch/intranet/SF/Applications/config/camtool_n";
|
||||
static String configFolder = "/afs/psi.ch/intranet/SF/Applications/config/camtool_n";
|
||||
|
||||
public static DefaultComboBoxModel getCameras() {
|
||||
public static String getConfigFolder() {
|
||||
return configFolder;
|
||||
}
|
||||
|
||||
public static void setConfigFolder(String value) {
|
||||
configFolder = value;
|
||||
}
|
||||
|
||||
public static ArrayList<String> getCameras() {
|
||||
ArrayList<String> ret = new ArrayList<>();
|
||||
File[] cameraConfigFiles = new File[0];
|
||||
cameraConfigFiles = IO.listFiles(CONFIG_FOLDER, new String[]{"json"});
|
||||
cameraConfigFiles = IO.listFiles(configFolder, new String[]{"json"});
|
||||
Arrays.sort(cameraConfigFiles, (a, b) -> a.compareTo(b));
|
||||
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
||||
for (File file : cameraConfigFiles) {
|
||||
String prefix = IO.getPrefix(file);
|
||||
if (!prefix.startsWith("#") && !prefix.endsWith("_parameters")) {
|
||||
model.addElement(prefix);
|
||||
ret.add(prefix);
|
||||
}
|
||||
}
|
||||
return model;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static class CameraConfig {
|
||||
@@ -67,12 +76,14 @@ public class SfCamera extends PsiCamera{
|
||||
return getCalibrationHeight() / height;
|
||||
}
|
||||
|
||||
public Double getCalibrationHeight() {
|
||||
return (Double) getCalibration().get("reference_marker_height");
|
||||
public Double getCalibrationHeight() {
|
||||
Double ret = (Double) getCalibration().get("reference_marker_height");
|
||||
return (ret == null) ? 100.0 : ret;
|
||||
}
|
||||
|
||||
public Double getCalibrationWidth() {
|
||||
return (Double) getCalibration().get("reference_marker_width");
|
||||
Double ret = (Double) getCalibration().get("reference_marker_width");
|
||||
return (ret == null) ? 100.0 : ret;
|
||||
}
|
||||
|
||||
public Double getCalibrationHorizontalAngle() {
|
||||
@@ -142,21 +153,39 @@ public class SfCamera extends PsiCamera{
|
||||
}
|
||||
|
||||
|
||||
public final CameraConfig cameraConfig;
|
||||
public final String cameraJson;
|
||||
CameraConfig setup;
|
||||
String json;
|
||||
public final String prefix;
|
||||
|
||||
public SfCamera(String name, String prefix) throws Exception {
|
||||
public SfCamera(String name, String prefix) {
|
||||
super(name, prefix);
|
||||
Path configFile = Paths.get(CONFIG_FOLDER, prefix + ".json");
|
||||
cameraJson = configFile.toFile().exists() ? new String(Files.readAllBytes(configFile)) : null;
|
||||
cameraConfig = (CameraConfig) JsonSerializer.decode(cameraJson, CameraConfig.class);
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public String getJson(){
|
||||
return json;
|
||||
}
|
||||
|
||||
public CameraConfig getSetup(){
|
||||
return setup;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInitialize() throws IOException, InterruptedException{
|
||||
super.doInitialize();
|
||||
Path configFile = Paths.get(configFolder, prefix + ".json");
|
||||
if (!configFile.toFile().exists()) {
|
||||
throw new IOException("Cannot open camera config file: " + configFile.toFile());
|
||||
}
|
||||
json = new String(Files.readAllBytes(configFile));
|
||||
setup = (CameraConfig) JsonSerializer.decode(json, CameraConfig.class);
|
||||
|
||||
CameraPars cameraPars = null;
|
||||
getConfig().roiX = 0; getConfig().roiY = 0;
|
||||
getConfig().roiWidth = -1; getConfig().roiHeight =-1;
|
||||
|
||||
try{
|
||||
Path parsFile = Paths.get(CONFIG_FOLDER, prefix + "_parameters.json");
|
||||
Path parsFile = Paths.get(configFolder, prefix + "_parameters.json");
|
||||
if (parsFile.toFile().exists()){
|
||||
String cameraParsJson = new String(Files.readAllBytes(parsFile));
|
||||
cameraPars = (CameraPars) JsonSerializer.decode(cameraParsJson, CameraPars.class);
|
||||
@@ -172,11 +201,11 @@ public class SfCamera extends PsiCamera{
|
||||
getLogger().log(Level.WARNING, null, ex);
|
||||
}
|
||||
|
||||
getConfig().flipHorizontally = cameraConfig.getMirrorX();
|
||||
getConfig().flipVertically = cameraConfig.getMirrorY();
|
||||
getConfig().flipHorizontally = setup.getMirrorX();
|
||||
getConfig().flipVertically = setup.getMirrorY();
|
||||
//getConfig().rotation = config.getRotate();
|
||||
//getConfig().rotationCrop = true;
|
||||
switch (cameraConfig.getRotate()) {
|
||||
switch (setup.getRotate()) {
|
||||
case 1:
|
||||
getConfig().rotation = 270;
|
||||
break;
|
||||
@@ -189,26 +218,20 @@ public class SfCamera extends PsiCamera{
|
||||
}
|
||||
getConfig().rotationCrop = false;
|
||||
try {
|
||||
getConfig().spatialCalOffsetX = cameraConfig.getCalOffsetX();
|
||||
getConfig().spatialCalOffsetY = cameraConfig.getCalOffsetY();
|
||||
getConfig().spatialCalOffsetX = setup.getCalOffsetX();
|
||||
getConfig().spatialCalOffsetY = setup.getCalOffsetY();
|
||||
} catch (Exception ex) {
|
||||
getConfig().spatialCalOffsetX = 0.0;
|
||||
getConfig().spatialCalOffsetY = 0.0;
|
||||
}
|
||||
try {
|
||||
getConfig().spatialCalScaleX = -cameraConfig.getScaleX();
|
||||
getConfig().spatialCalScaleY = -cameraConfig.getScaleY();
|
||||
} catch (Exception ex) {
|
||||
getLogger().log(Level.WARNING, null, ex);
|
||||
getConfig().spatialCalScaleX = -setup.getScaleX();
|
||||
getConfig().spatialCalScaleY = -setup.getScaleY();
|
||||
} catch (Exception ex) {
|
||||
getConfig().spatialCalScaleX = 1.0;
|
||||
getConfig().spatialCalScaleY = 1.0;
|
||||
}
|
||||
getConfig().save();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInitialize() throws IOException, InterruptedException{
|
||||
super.doInitialize();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,11 +10,14 @@
|
||||
|
||||
import datetime
|
||||
|
||||
mode = "camtool" # "camtool", "bpm" or "direct"
|
||||
is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before callin "run"
|
||||
|
||||
camera_name = "SINEG01-DSCR190"
|
||||
use_good_region=False
|
||||
do_elog = True
|
||||
|
||||
if get_exec_pars().source == CommandSource.ui:
|
||||
if not is_panel:
|
||||
source = "direct" # "camtool", "bpm" or "direct"
|
||||
I1 = 100.0
|
||||
I2 = 105.0
|
||||
dI = 1.0
|
||||
@@ -22,27 +25,45 @@ if get_exec_pars().source == CommandSource.ui:
|
||||
plot_image = False
|
||||
number_images = 5
|
||||
use_background = True
|
||||
multiple_background = True
|
||||
number_backgrounds = 5
|
||||
do_elog = False
|
||||
centroid_excursion_plot = True
|
||||
else:
|
||||
centroid_excursion_plot = False
|
||||
multiple_background = False
|
||||
number_backgrounds = 5
|
||||
plots = get_plots(title = "Centroid excursion")
|
||||
if len(plots)==0:
|
||||
centroid_plot = plot(None, title = "Centroid excursion")[0]
|
||||
centroid_plot.clear()
|
||||
else:
|
||||
centroid_plot = plots[0]
|
||||
|
||||
|
||||
kill_camtool()
|
||||
check_camtool()
|
||||
centroid_plot_index = 1 if ((len(centroid_plot.getAllSeries()) == 0) or (not globals().has_key("centroid_plot_index"))) else (centroid_plot_index + 1)
|
||||
print "Plot index: ", centroid_plot_index
|
||||
centroid_plot.setLegendVisible(True)
|
||||
centroid_plot.setStyle(centroid_plot.Style.ErrorXY)
|
||||
centroid_plot.getAxis(centroid_plot.AxisId.Y).setLabel("")
|
||||
centroid_plot.getAxis(centroid_plot.AxisId.X).setLabel("Centroid Excursion")
|
||||
scan_series = LinePlotErrorSeries(str(centroid_plot_index))
|
||||
centroid_plot.addSeries(scan_series)
|
||||
scan_series.setLinesVisible(False)
|
||||
scan_series.setPointSize(4)
|
||||
|
||||
#Simulation
|
||||
camera_name = "SLG-LCAM-C041"
|
||||
def laser_on():
|
||||
print "Laser On"
|
||||
def laser_off():
|
||||
print "Laser Off"
|
||||
def switch_off_magnets(magnets = None):
|
||||
pass
|
||||
add_device(DummyPositioner("gun_solenoid"), True)
|
||||
do_elog = False
|
||||
|
||||
laser_was_on = is_laser_on()
|
||||
original_gun_solenoid = gun_solenoid.read()
|
||||
|
||||
|
||||
original_gun_solenoid = gun_solenoid.read()
|
||||
multiple_background = multiple_background and use_background
|
||||
print "Parameters: ", I1, I2, dI, settling_time, plot_image, number_images, use_background, multiple_background, number_backgrounds
|
||||
|
||||
plot_name = datetime.datetime.fromtimestamp(time.time()).strftime('%H%M%S')
|
||||
|
||||
|
||||
if mode == "camtool":
|
||||
if source == "camtool":
|
||||
check_camtool()
|
||||
if use_background:
|
||||
laser_off()
|
||||
if not multiple_background:
|
||||
@@ -50,20 +71,28 @@ if mode == "camtool":
|
||||
camtool.grabBackground(camera_name, number_backgrounds)
|
||||
camtool.start(camera_name, 0, use_background, None, 0.0, None)
|
||||
else:
|
||||
if mode == "bpm":
|
||||
if source == "bpm":
|
||||
run("Devices/BpmStats")
|
||||
add_device(BpmStats("image_stats", camera_name), True)
|
||||
else:
|
||||
add_device(ImageStats(PsiCamera("image_stats", camera_name)), True)
|
||||
multiple_background = False
|
||||
use_background = False
|
||||
multiple_background = False
|
||||
use_background = False
|
||||
else:
|
||||
run("Devices/ImageStats")
|
||||
add_device(ImageStats("image_stats", camera_name), True)
|
||||
add_device(image_stats.source, True)
|
||||
image_stats.enableBackground(use_background)
|
||||
if use_background:
|
||||
laser_off()
|
||||
if not multiple_background:
|
||||
image_stats.grabBackground(number_backgrounds)
|
||||
image_stats.setNumberOfImages(max(number_images,1))
|
||||
|
||||
#switch_off_magnets()
|
||||
|
||||
# add here gun phase setting see wiki page
|
||||
|
||||
def before_sample():
|
||||
if mode == "camtool":
|
||||
def before_sample(position, scan):
|
||||
if source == "camtool":
|
||||
if multiple_background:
|
||||
camtool.stop()
|
||||
camtool.grabBackground(camera_name, number_backgrounds)
|
||||
@@ -71,9 +100,20 @@ def before_sample():
|
||||
laser_on()
|
||||
wait_camtool_message(number_images) #Wait filing the averager cache
|
||||
else:
|
||||
if multiple_background:
|
||||
image_stats.grabBackground(number_backgrounds)
|
||||
laser_on()
|
||||
image_stats.update()
|
||||
|
||||
def after_sample():
|
||||
def after_sample(record, scan):
|
||||
x = record.values[0]
|
||||
y = record.values[1]
|
||||
stdev_x = record.values[2]
|
||||
stdev_y = record.values[3]
|
||||
if source == "camtool":
|
||||
#x, y, stdev_x, stdev_y = x.mean, y.mean, stdev_x.mean, stdev_y.mean
|
||||
x, y, stdev_x, stdev_y = x.mean, y.mean, x.stdev, y.stdev
|
||||
scan_series.appendData(x, y, abs(stdev_x), abs(stdev_y));
|
||||
if multiple_background:
|
||||
laser_off()
|
||||
|
||||
@@ -82,37 +122,60 @@ if not multiple_background:
|
||||
laser_on()
|
||||
|
||||
try:
|
||||
if mode != "camtool":
|
||||
if source != "camtool":
|
||||
sensors = [image_stats.com_x_mean, image_stats.com_y_mean, image_stats.com_x_stdev, image_stats.com_y_stdev]
|
||||
if plot_image and (source == "direct"):
|
||||
sensors.append(image_stats.source.getDataMatrix())
|
||||
else:
|
||||
sensors = get_camtool_stats(number_images, good_region=use_good_region)
|
||||
|
||||
|
||||
sensors = get_camtool_stats(number_images, good_region=use_good_region)
|
||||
if plot_image:
|
||||
sensors.append(camtool.getDataMatrix())
|
||||
r = lscan(gun_solenoid, sensors , I1, I2, dI, settling_time, before_read = before_sample, after_read = after_sample)
|
||||
finally:
|
||||
if mode == "camtool": camtool.stop()
|
||||
if source == "camtool":
|
||||
camtool.stop()
|
||||
else:
|
||||
image_stats.stop()
|
||||
gun_solenoid.write(original_gun_solenoid)
|
||||
if laser_was_on:
|
||||
laser_on()
|
||||
else:
|
||||
laser_off()
|
||||
|
||||
|
||||
# take the result of the scan and generate convex hull plot
|
||||
if centroid_excursion_plot:
|
||||
(hx,hy)=add_convex_hull_plot ("Centroid excursion", r.getReadable(0),r.getReadable(1), plot_name)
|
||||
else:
|
||||
(hx,hy)= convex_hull(x=to_array(r.getReadable(0), 'd'), y=to_array(r.getReadable(1),'d'))
|
||||
hx.append(hx[0]); hy.append(hy[0])
|
||||
(hx,hy)= convex_hull(x=to_array(r.getReadable(0), 'd'), y=to_array(r.getReadable(1),'d'))
|
||||
hx.append(hx[0]); hy.append(hy[0])
|
||||
hx = Convert.toDouble(hx)
|
||||
hy = Convert.toDouble(hy)
|
||||
hull = LinePlotErrorSeries(scan_series.name + "H", scan_series.color);
|
||||
centroid_plot.addSeries(hull);
|
||||
hull.setData(hx, hy);
|
||||
|
||||
#Include metadata do hdf5
|
||||
path = get_exec_pars().scanPath
|
||||
|
||||
set_attribute(path, "Settling time", settling_time)
|
||||
set_attribute(path, "Images", number_images)
|
||||
set_attribute(path, "Background enabled", use_background)
|
||||
set_attribute(path, "Background multiple", multiple_background)
|
||||
set_attribute(path, "Background images", number_backgrounds)
|
||||
set_attribute(path, "Plot index", centroid_plot_index)
|
||||
|
||||
# save the entry in the logbook
|
||||
gsa_log_msg = "Data file: " + get_exec_pars().path
|
||||
gsa_log_msg = gsa_log_msg + "\nImages: " + str(number_images)
|
||||
gsa_log_msg = gsa_log_msg + "\nBackground: enabled=" + str(use_background) + " multiple=" + str(multiple_background) + " number=" + str(number_backgrounds)
|
||||
gsa_log_msg = gsa_log_msg + "\n\n" + r.print()
|
||||
if do_elog:
|
||||
elog("Gun solenoid current scan", gsa_log_msg , get_plot_snapshots())
|
||||
if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes":
|
||||
log_msg = "Data file: " + get_exec_pars().path
|
||||
log_msg = log_msg + "\nI1: " + str(I1)
|
||||
log_msg = log_msg + "\nI2: " + str(I2)
|
||||
log_msg = log_msg + "\ndI: " + str(dI)
|
||||
log_msg = log_msg + "\nSettling time: " + str(settling_time)
|
||||
log_msg = log_msg + "\nImages: " + str(number_images)
|
||||
log_msg = log_msg + "\nBackground: enabled=" + str(use_background) + " multiple=" + str(multiple_background) + " number=" + str(number_backgrounds)
|
||||
log_msg = log_msg + "\nPlot index: " + str(centroid_plot_index)
|
||||
log_msg = log_msg + "\n\n" + r.print()
|
||||
|
||||
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() + "/centroid_excursion.png")
|
||||
centroid_plot.saveSnapshot(file_name , "png")
|
||||
elog("Gun solenoid alignment", log_msg, [file_name,])
|
||||
|
||||
set_return([r, hx, hy])
|
||||
|
||||
@@ -10,11 +10,14 @@
|
||||
|
||||
import datetime
|
||||
|
||||
mode = "camtool" # "camtool", "bpm" or "direct"
|
||||
is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before callin "run"
|
||||
|
||||
camera_name = "SINEG01-DSCR190"
|
||||
use_good_region=False
|
||||
do_elog = True
|
||||
|
||||
if get_exec_pars().source == CommandSource.ui:
|
||||
if not is_panel:
|
||||
source = "camtool" # "camtool", "bpm" or "direct"
|
||||
phi1= 95.0
|
||||
phi2 = 100.0
|
||||
dphi = 1.0
|
||||
@@ -23,23 +26,46 @@ if get_exec_pars().source == CommandSource.ui:
|
||||
number_images = 5
|
||||
use_background = True
|
||||
multiple_background = False
|
||||
number_backgrounds = 5
|
||||
do_elog = False
|
||||
centroid_excursion_plot = True
|
||||
else:
|
||||
centroid_excursion_plot = False
|
||||
number_backgrounds = 5
|
||||
plots = get_plots(title = "Centroid excursion")
|
||||
if len(plots)==0:
|
||||
centroid_plot = plot(None, title = "Centroid excursion")[0]
|
||||
centroid_plot.clear()
|
||||
else:
|
||||
centroid_plot = plots[0]
|
||||
|
||||
kill_camtool()
|
||||
check_camtool()
|
||||
|
||||
centroid_plot_index = 1 if ((len(centroid_plot.getAllSeries()) == 0) or (not globals().has_key("centroid_plot_index"))) else (centroid_plot_index + 1)
|
||||
print "Plot index: ", centroid_plot_index
|
||||
centroid_plot.setLegendVisible(True)
|
||||
centroid_plot.setStyle(centroid_plot.Style.ErrorXY)
|
||||
centroid_plot.getAxis(centroid_plot.AxisId.Y).setLabel("")
|
||||
centroid_plot.getAxis(centroid_plot.AxisId.X).setLabel("Centroid Excursion")
|
||||
scan_series = LinePlotErrorSeries(str(centroid_plot_index))
|
||||
centroid_plot.addSeries(scan_series)
|
||||
scan_series.setLinesVisible(False)
|
||||
scan_series.setPointSize(4)
|
||||
|
||||
#Testing
|
||||
camera_name = "SLG-LCAM-C041"
|
||||
def laser_on():
|
||||
print "Laser On"
|
||||
def laser_off():
|
||||
print "Laser Off"
|
||||
def switch_off_magnets(magnets = None):
|
||||
pass
|
||||
add_device(DummyPositioner("gun_phase"), True)
|
||||
do_elog = False
|
||||
|
||||
laser_was_on = is_laser_on()
|
||||
original_phase = gun_phase.read()
|
||||
multiple_background = multiple_background and use_background
|
||||
print "Parameters: ", phi1, phi2, dphi, settling_time, plot_image, number_images, use_background, multiple_background, number_backgrounds
|
||||
|
||||
plot_name = datetime.datetime.fromtimestamp(time.time()).strftime('%H%M%S')
|
||||
|
||||
if mode == "camtool":
|
||||
if source == "camtool":
|
||||
#kill_camtool()
|
||||
check_camtool()
|
||||
if use_background:
|
||||
laser_off()
|
||||
if not multiple_background:
|
||||
@@ -47,20 +73,28 @@ if mode == "camtool":
|
||||
camtool.grabBackground(camera_name, number_backgrounds)
|
||||
camtool.start(camera_name, 0, use_background, None, 0.0, None)
|
||||
else:
|
||||
if mode == "bpm":
|
||||
if source == "bpm":
|
||||
run("Devices/BpmStats")
|
||||
add_device(BpmStats("image_stats", camera_name), True)
|
||||
multiple_background = False
|
||||
use_background = False
|
||||
else:
|
||||
add_device(ImageStats(PsiCamera("image_stats", camera_name)), True)
|
||||
multiple_background = False
|
||||
use_background = False
|
||||
run("Devices/ImageStats")
|
||||
add_device(ImageStats("image_stats", camera_name), True)
|
||||
add_device(image_stats.source, True)
|
||||
image_stats.enableBackground(use_background)
|
||||
if use_background:
|
||||
laser_off()
|
||||
if not multiple_background:
|
||||
image_stats.grabBackground(number_backgrounds)
|
||||
image_stats.setNumberOfImages(max(number_images,1))
|
||||
|
||||
#switch_off_magnets()
|
||||
|
||||
# add here gun phase setting see wiki page
|
||||
|
||||
def before_sample():
|
||||
if mode == "camtool":
|
||||
def before_sample(position, scan):
|
||||
if source == "camtool":
|
||||
if multiple_background:
|
||||
camtool.stop()
|
||||
camtool.grabBackground(camera_name, number_backgrounds)
|
||||
@@ -68,26 +102,42 @@ def before_sample():
|
||||
laser_on()
|
||||
wait_camtool_message(number_images) #Wait filing the averager cache
|
||||
else:
|
||||
if multiple_background:
|
||||
image_stats.grabBackground(number_backgrounds)
|
||||
laser_on()
|
||||
image_stats.update()
|
||||
|
||||
def after_sample():
|
||||
def after_sample(record, scan):
|
||||
x = record.values[0]
|
||||
y = record.values[1]
|
||||
stdev_x = record.values[2]
|
||||
stdev_y = record.values[3]
|
||||
if source == "camtool":
|
||||
#x, y, stdev_x, stdev_y = x.mean, y.mean, stdev_x.mean, stdev_y.mean
|
||||
x, y, stdev_x, stdev_y = x.mean, y.mean, x.stdev, y.stdev
|
||||
scan_series.appendData(x, y, abs(stdev_x), abs(stdev_y));
|
||||
if multiple_background:
|
||||
laser_off()
|
||||
laser_off()
|
||||
|
||||
r = None
|
||||
if not multiple_background:
|
||||
laser_on()
|
||||
|
||||
try:
|
||||
if mode != "camtool":
|
||||
if source != "camtool":
|
||||
sensors = [image_stats.com_x_mean, image_stats.com_y_mean, image_stats.com_x_stdev, image_stats.com_y_stdev]
|
||||
if plot_image and (source == "direct"):
|
||||
sensors.append(image_stats.source.getDataMatrix())
|
||||
else:
|
||||
sensors = get_camtool_stats(number_images, good_region=use_good_region)
|
||||
if plot_image:
|
||||
sensors.append(camtool.getDataMatrix())
|
||||
r = lscan(gun_phase, sensors , phi1, phi2, dphi, settling_time, before_read = before_sample, after_read = after_sample)
|
||||
finally:
|
||||
if mode == "camtool": camtool.stop()
|
||||
if source == "camtool":
|
||||
camtool.stop()
|
||||
else:
|
||||
image_stats.stop()
|
||||
gun_phase.write(original_phase)
|
||||
if laser_was_on:
|
||||
laser_on()
|
||||
@@ -95,23 +145,45 @@ else:
|
||||
laser_off()
|
||||
|
||||
# take the result of the scan and generate convex hull plot
|
||||
if centroid_excursion_plot:
|
||||
(hx,hy)=add_convex_hull_plot ("Centroid excursion", r.getReadable(0),r.getReadable(1), plot_name)
|
||||
else:
|
||||
(hx,hy)= convex_hull(x=to_array(r.getReadable(0), 'd'), y=to_array(r.getReadable(1),'d'))
|
||||
hx.append(hx[0]); hy.append(hy[0])
|
||||
(hx,hy)= convex_hull(x=to_array(r.getReadable(0), 'd'), y=to_array(r.getReadable(1),'d'))
|
||||
hx.append(hx[0]); hy.append(hy[0])
|
||||
hx = Convert.toDouble(hx)
|
||||
hy = Convert.toDouble(hy)
|
||||
hull = LinePlotErrorSeries(scan_series.name + "H", scan_series.color);
|
||||
centroid_plot.addSeries(hull);
|
||||
hull.setData(hx, hy);
|
||||
|
||||
#Include metadata do hdf5
|
||||
path = get_exec_pars().scanPath
|
||||
set_attribute(path, "phi1", phi1)
|
||||
set_attribute(path, "phi2", phi2)
|
||||
set_attribute(path, "dphi", dphi)
|
||||
set_attribute(path, "Settling time", settling_time)
|
||||
set_attribute(path, "Images", number_images)
|
||||
set_attribute(path, "Background enabled", use_background)
|
||||
set_attribute(path, "Background multiple", multiple_background)
|
||||
set_attribute(path, "Background images", number_backgrounds)
|
||||
set_attribute(path, "Plot index", centroid_plot_index)
|
||||
|
||||
print "Done"
|
||||
# save the entry in the logbook
|
||||
gsa_log_msg = "Data file: " + get_exec_pars().path
|
||||
gsa_log_msg = gsa_log_msg + "\nImages: " + str(number_images) + " Background: enabled=" + str(use_background) + " multiple=" + str(multiple_background) + " number=" + str(number_backgrounds)
|
||||
gsa_log_msg = gsa_log_msg + "\nPhase range: " + str(phi1) + " to " + str(phi2)
|
||||
gsa_log_msg = gsa_log_msg + "\nLaser position on cathod: " + str(caget("SLG-LCAM-C103:FIT-XPOS")) + "/" + str(caget("SLG-LCAM-C103:FIT-YPOS"))
|
||||
gsa_log_msg = gsa_log_msg + "\n\n" + r.print()
|
||||
if do_elog:
|
||||
elog("Laser alignment with phase scan", gsa_log_msg , get_plot_snapshots())
|
||||
if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes":
|
||||
log_msg = "Data file: " + get_exec_pars().path
|
||||
log_msg = log_msg + "\nI1: " + str(I1)
|
||||
log_msg = log_msg + "\nI2: " + str(I2)
|
||||
log_msg = log_msg + "\ndI: " + str(dI)
|
||||
log_msg = log_msg + "\nSettling time: " + str(settling_time)
|
||||
log_msg = log_msg + "\nImages: " + str(number_images)
|
||||
log_msg = log_msg + "\nBackground: enabled=" + str(use_background) + " multiple=" + str(multiple_background) + " number=" + str(number_backgrounds)
|
||||
log_msg = log_msg + "\nPlot index: " + str(centroid_plot_index)
|
||||
log_msg = log_msg + "\n\n" + r.print()
|
||||
|
||||
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() + "/centroid_excursion.png")
|
||||
centroid_plot.saveSnapshot(file_name , "png")
|
||||
elog("Laser alignment with phase scan", log_msg, [file_name,])
|
||||
|
||||
|
||||
set_return([r, hx, hy])
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ class BpmStats(DeviceBase):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
"""
|
||||
if __name__ == "__builtin__":
|
||||
add_device(BpmStats("bpm_com", "SINEG01-DBPM340"), True)
|
||||
bpm_com.setNumberOfImages(5)
|
||||
@@ -81,3 +81,4 @@ if __name__ == "__builtin__":
|
||||
print bpm_com.take(), bpm_com.com_x_mean.read(), bpm_com.com_y_mean.read()
|
||||
time.sleep(1)
|
||||
|
||||
"""
|
||||
@@ -1,6 +1,7 @@
|
||||
from startup import *
|
||||
from ijutils import *
|
||||
from mathutils import *
|
||||
import ch.psi.pshell.imaging.Filter as Filter
|
||||
from ch.psi.pshell.imaging.Overlays import *
|
||||
import ch.psi.pshell.imaging.Pen as Pen
|
||||
import java.awt.Color as Color
|
||||
@@ -12,6 +13,7 @@ from ch.psi.pshell.imaging.Utils import sub
|
||||
REMOVE_BACKGROUND = True
|
||||
PLOT_PROFILE = True
|
||||
|
||||
"""
|
||||
def get_centroid(source):
|
||||
bi = source.getImage()
|
||||
if bi is None:
|
||||
@@ -34,44 +36,8 @@ def get_centroid(source):
|
||||
ov = Crosshairs(Pen(Color.ORANGE), java.awt.Point(int(centroid[0]),int(centroid[1])), java.awt.Dimension(15,15))
|
||||
op.addOverlay(ov)
|
||||
return centroid
|
||||
|
||||
|
||||
|
||||
def arroff(a, value = "mean"):
|
||||
"""Subtract offset to all elemets in series.
|
||||
|
||||
Args:
|
||||
|
||||
a(list, tuple, array ...): subscriptable object containing numbers
|
||||
type(int or str, optional): value to subtract from the array, or "mean" or "min".
|
||||
|
||||
Returns:
|
||||
List
|
||||
|
||||
"""
|
||||
if value=="mean":
|
||||
value = mean(a)
|
||||
elif value=="min":
|
||||
value = min(a)
|
||||
return [x-value for x in a]
|
||||
|
||||
|
||||
def arrsubback(data, a, b):
|
||||
"""Subtract offset to all elemets in series.
|
||||
|
||||
Args:
|
||||
|
||||
a(list, tuple, array ...): subscriptable object containing numbers
|
||||
type(int or str, optional): value to subtract from the array, or "mean" or "min".
|
||||
|
||||
Returns:
|
||||
List
|
||||
|
||||
"""
|
||||
return [y-(a*y+b) for y in a]
|
||||
|
||||
|
||||
import ch.psi.pshell.imaging.Filter as Filter
|
||||
"""
|
||||
|
||||
|
||||
class SimulatedSource(Filter):
|
||||
def process(self, img, data):
|
||||
@@ -94,7 +60,13 @@ class SimulatedSource(Filter):
|
||||
class ImageStats(DeviceBase):
|
||||
def __init__(self, name, source):
|
||||
DeviceBase.__init__(self, name)
|
||||
self.source = source
|
||||
if isinstance(source, basestring):
|
||||
self.source = get_context().getClassByName("SfCamera")(source, source)
|
||||
self.private_source = True
|
||||
self.source.initialize()
|
||||
else:
|
||||
self.private_source = False
|
||||
self.source = source
|
||||
self.com_x_samples, self.com_y_samples = [], []
|
||||
self.rms_x_samples, self.rms_y_samples = [], []
|
||||
self.background = None
|
||||
@@ -122,7 +94,7 @@ class ImageStats(DeviceBase):
|
||||
set_device_alias(self.com_y_mean, name + " com y mean")
|
||||
set_device_alias(self.com_x_stdev, name + " com x stdev")
|
||||
set_device_alias(self.com_y_stdev, name + " com y stdev")
|
||||
self.bg_en = False
|
||||
#self.bg_en = False
|
||||
self.num_images = 5
|
||||
|
||||
class BackgroundSubtractor(Filter):
|
||||
@@ -135,6 +107,7 @@ class ImageStats(DeviceBase):
|
||||
self.backgroundFilter = BackgroundSubtractor(self)
|
||||
|
||||
self.initialize()
|
||||
self.start()
|
||||
|
||||
#class SourceListener (ImageListener):
|
||||
# def __init__(self, dev):
|
||||
@@ -154,17 +127,8 @@ class ImageStats(DeviceBase):
|
||||
self.rms_x_samples, self.rms_y_samples = [], []
|
||||
for i in range(self.num_images):
|
||||
if type(self.source) is not ch.psi.pshell.imaging.FileSource:
|
||||
#print "A"
|
||||
self.source.waitNext(5000)
|
||||
#print "B"
|
||||
#time.sleep(0.2)
|
||||
#print "Ok"
|
||||
#centroid = get_centroid(self.source)
|
||||
#print "cent ", centroid
|
||||
#if centroid is not None:
|
||||
# self.com_x_samples.append(centroid[0])
|
||||
# self.com_y_samples.append(centroid[1])
|
||||
|
||||
|
||||
x_profile = self.source.data.integrateVertically(True)
|
||||
x_profile_x = self.source.data.getRowSelectionX(True)
|
||||
|
||||
@@ -172,7 +136,7 @@ class ImageStats(DeviceBase):
|
||||
y_profile_x = self.source.data.getColSelectionX(True)
|
||||
|
||||
#Remove background
|
||||
if (self.bg_en == False) and REMOVE_BACKGROUND:
|
||||
if (self.source.backgroundEnabled == False) and REMOVE_BACKGROUND:
|
||||
(a, b, amp, com, sigma) = fit_gaussian_linear(x_profile, x_profile_x)
|
||||
x_profile = [x_profile[i]-(a*x_profile_x[i]+b) for i in range(len(x_profile))]
|
||||
(a, b, amp, com, sigma) = fit_gaussian_linear(y_profile, y_profile_x)
|
||||
@@ -187,44 +151,37 @@ class ImageStats(DeviceBase):
|
||||
p = get_plots("Profile")
|
||||
if (p is None) or (len(p)==0):
|
||||
p = plot([x_profile, y_profile], ["x_profile", "yprofile"], [x_profile_x,y_profile_x], title ="Profile")
|
||||
else:
|
||||
if p is not None:
|
||||
p[0].removeMarker(None)
|
||||
p[1].removeMarker(None)
|
||||
p[0].getSeries(0).setData(x_profile_x, x_profile)
|
||||
p[1].getSeries(0).setData(y_profile_x, y_profile)
|
||||
p[0].addMarker(com_x, None, "COM = " + str(com_x), Color.GREEN)
|
||||
p[1].addMarker(com_y, None, "COM = " + str(com_y), Color.GREEN)
|
||||
|
||||
|
||||
def setNumberOfImages(self, value):
|
||||
self.num_images = value
|
||||
|
||||
def enableBackground(self, value):
|
||||
self.bg_en = value
|
||||
self.source.filter = self.backgroundFilter if self.bg_en else None
|
||||
self.source.backgroundEnabled = value
|
||||
|
||||
def captureBackground(self, images):
|
||||
try:
|
||||
self.source.filter = None
|
||||
imgs = []
|
||||
for i in range(images):
|
||||
self.source.waitNext(5000)
|
||||
imgs.append(cam3.output)
|
||||
#TODO:
|
||||
self.background = cam3.output
|
||||
finally:
|
||||
self.enableBackground(self.bg_en)
|
||||
|
||||
|
||||
def grabBackground(self, images):
|
||||
self.source.captureBackground(images,0)
|
||||
|
||||
def doClose(self):
|
||||
print "close"
|
||||
self.source.filter = None
|
||||
#self.source.removeListener(self.listener)
|
||||
if self.private_source:
|
||||
self.source.close()
|
||||
else:
|
||||
self.source.backgroundEnabled = False
|
||||
|
||||
def start(self):
|
||||
pass
|
||||
if self.private_source:
|
||||
self.source.polling = 200
|
||||
self.source.waitNext(2000)
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
if self.private_source:
|
||||
self.source.polling = 0
|
||||
|
||||
|
||||
def get_simulated_source(img):
|
||||
@@ -235,16 +192,14 @@ def get_simulated_source(img):
|
||||
show_panel(simulated_source)
|
||||
return simulated_source
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
if __name__ == "__builtin__":
|
||||
#simulated_source = get_simulated_source(image)
|
||||
#print get_centroid(simulated_source)
|
||||
add_device(ImageStats("image_stats", "SLG-LCAM-C041"), True)
|
||||
add_device(image_stats.source, True)
|
||||
#cam3.waitNext(2000)
|
||||
|
||||
add_device(ImageStats("image_stats", cam3), True)
|
||||
cam3.waitNext(2000)
|
||||
image_stats.enableBackground(False)
|
||||
#for i in range (10):
|
||||
# image_stats.update()
|
||||
# print image_stats.take(), image_stats.com_x_mean.read(), image_stats.com_y_mean.read()
|
||||
@@ -253,9 +208,14 @@ if __name__ == "__builtin__":
|
||||
image_stats.setNumberOfImages(3)
|
||||
sensors = [image_stats.com_x_mean, image_stats.com_y_mean, image_stats.com_x_stdev, image_stats.com_y_stdev]
|
||||
|
||||
image_stats.captureBackground(5)
|
||||
#image_stats.enableBackground(True)
|
||||
|
||||
image_stats.grabBackground(1)
|
||||
|
||||
def before_sample():
|
||||
image_stats.update()
|
||||
tscan(sensors, 10, 0.1, before_read = before_sample)
|
||||
image_stats.enableBackground(False)
|
||||
try:
|
||||
tscan(sensors, 10, 0.1, before_read = before_sample)
|
||||
finally:
|
||||
image_stats.enableBackground(False)
|
||||
image_stats.stop()
|
||||
"""
|
||||
@@ -225,16 +225,16 @@ print msg
|
||||
# save the entry in the logbook
|
||||
if do_elog:
|
||||
if get_option("Generated data file:\n" + filename +"\n\n" + msg + "\n\n" + "Save to ELOG?", "YesNo") == "Yes":
|
||||
gsa_log_msg = "Data file: " + filename
|
||||
gsa_log_msg = gsa_log_msg + "\nWire Scanner: " + prefix
|
||||
gsa_log_msg = gsa_log_msg + "\nScan Type: " + str(scan_type)
|
||||
gsa_log_msg = gsa_log_msg + "\nRange: " + str(scan_range)
|
||||
gsa_log_msg = gsa_log_msg + "\nCycles: " + str(cycles)
|
||||
gsa_log_msg = gsa_log_msg + "\nWire Velocity: " + str(velocity)
|
||||
gsa_log_msg = gsa_log_msg + "\nBackground Measures: " + str(bkgrd)
|
||||
gsa_log_msg = gsa_log_msg + "\nBPMs: " + str(bpms)
|
||||
gsa_log_msg = gsa_log_msg + "\nBLMs: " + str(blms)
|
||||
log_msg = "Data file: " + filename
|
||||
log_msg = log_msg + "\nWire Scanner: " + prefix
|
||||
log_msg = log_msg + "\nScan Type: " + str(scan_type)
|
||||
log_msg = log_msg + "\nRange: " + str(scan_range)
|
||||
log_msg = log_msg + "\nCycles: " + str(cycles)
|
||||
log_msg = log_msg + "\nWire Velocity: " + str(velocity)
|
||||
log_msg = log_msg + "\nBackground Measures: " + str(bkgrd)
|
||||
log_msg = log_msg + "\nBPMs: " + str(bpms)
|
||||
log_msg = log_msg + "\nBLMs: " + str(blms)
|
||||
|
||||
gsa_log_msg = gsa_log_msg + "\n" + msg
|
||||
elog("Wire Scan", gsa_log_msg, snapshots)
|
||||
log_msg = log_msg + "\n" + msg
|
||||
elog("Wire Scan", log_msg, snapshots)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import ch.psi.pshell.epics.ControlledVariable as ControlledVariable
|
||||
|
||||
if get_exec_pars().source == CommandSource.ui:
|
||||
start = -100.0
|
||||
start = -10.0
|
||||
stop = 180.0
|
||||
step = 5.0
|
||||
nb = 3
|
||||
@@ -13,43 +13,41 @@ else:
|
||||
nb = int(args[3])
|
||||
lat = args[4]
|
||||
|
||||
phase = ControlledVariable("Phase", "SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:GET-BEAM-PHASE")
|
||||
#phase = ControlledVariable("Phase", "S10CB09-RSYS:SET-BEAM-PHASE", "S10CB09-RSYS:SET-BEAM-PHASE")
|
||||
phase.config.minValue =-180.0
|
||||
phase.config.maxValue = 360.0
|
||||
phase.config.precision = 3
|
||||
phase.config.resolution = 1.0
|
||||
phase.config.save()
|
||||
phase.initialize()
|
||||
st = Stream("ICTstream", dispatcher)
|
||||
q = st.addScalar("Charge", "SINEG01-DICT215:B1_CHARGE", 1, 0)
|
||||
bphase = ControlledVariable("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:GET-BEAM-PHASE")
|
||||
bphase.config.minValue =-180.0
|
||||
bphase.config.maxValue = 360.0
|
||||
bphase.config.precision = 3
|
||||
bphase.config.resolution = 1.0
|
||||
bphase.config.save()
|
||||
bphase.initialize()
|
||||
st = Stream("Schottky", dispatcher)
|
||||
q = st.addScalar("Charge", "SINEG01-DICT215:B1_CHARGE", 1, 0)
|
||||
st.initialize()
|
||||
st.start()
|
||||
#q = Channel("SINEG01-DICT215:B1_CHARGE", type = 'd', alias='ICT-Q')
|
||||
phase0 = phase.read()
|
||||
|
||||
print phase0
|
||||
|
||||
rphase = Channel("SINEG01-RSYS:GET-VSUM-PHASE", type = 'd', alias = 'RF phase')
|
||||
bphase0 = bphase.read()
|
||||
|
||||
try:
|
||||
qb = create_averager(q, nb, 0.100)
|
||||
r = lscan(phase, (qb), start, stop, step, latency=lat)
|
||||
rf_phase = r.getPositions(0)
|
||||
charge = [val.mean for val in r.getReadable(0)]
|
||||
chargerms = [val.stdev for val in r.getReadable(0)]
|
||||
q_averager = create_averager(q, nb, 0.100)
|
||||
rphase_averager = create_averager(rphase, nb, 0.100)
|
||||
r = lscan(bphase, (q_averager, rphase_averager), start, stop, step, latency=lat)
|
||||
beamphase = r.getPositions(0)
|
||||
charge = [val.mean for val in r.getReadable(0)]
|
||||
chargerms = [val.stdev for val in r.getReadable(0)]
|
||||
rfphase = [val.mean for val in r.getReadable(1)]
|
||||
rfphaserms = [val.stdev for val in r.getReadable(1)]
|
||||
finally:
|
||||
phase.write(phase0)
|
||||
phase.close()
|
||||
bphase.write(phase0)
|
||||
bphase.close()
|
||||
st.close()
|
||||
#q.close()
|
||||
q.close()
|
||||
rphase.close()
|
||||
|
||||
#Setting the return value
|
||||
x = rf_phase
|
||||
y = charge
|
||||
index_max = y.index(max(y))
|
||||
phase_ref = x[index_max] - 80
|
||||
index_max = charge.index(max(charge))
|
||||
rphase_ref = rfphase[index_max] - 80
|
||||
|
||||
set_return(phase_ref)
|
||||
set_return(rphase_ref)
|
||||
|
||||
# save the entry in the logbook
|
||||
#if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes":
|
||||
|
||||
@@ -1,49 +1,60 @@
|
||||
import ch.psi.pshell.epics.ControlledVariable as ControlledVariable
|
||||
|
||||
if get_exec_pars().source == CommandSource.ui:
|
||||
start = 50.0
|
||||
stop = 230.0
|
||||
start = -10.0
|
||||
stop = 180.0
|
||||
step = 5.0
|
||||
nb = 1
|
||||
lat = 0.100
|
||||
nb = 3
|
||||
lat = 0.300
|
||||
else:
|
||||
start = args[0]
|
||||
stop = args[1]
|
||||
step = args[2]
|
||||
nb = int(args[3])
|
||||
lat = args[4]
|
||||
|
||||
|
||||
phase = ControlledVariable("Phase", "SINEG01-RSYS:SET-VSUM-PHASE-SIM", "SINEG01-RSYS:GET-VSUM-PHASE-SIM")
|
||||
phase.config.minValue =-180.0
|
||||
phase.config.maxValue = 180.0
|
||||
phase.config.resolution = 0.5
|
||||
phase.initialize()
|
||||
bphase = ControlledVariable("Beam phase", "SINEG01-RSYS:SET-VSUM-PHASE-SIM", "SINEG01-RSYS:GET-VSUM-PHASE-SIM")
|
||||
bphase.config.minValue =-180.0
|
||||
bphase.config.maxValue = 360.0
|
||||
bphase.config.precision = 3
|
||||
bphase.config.resolution = 1.0
|
||||
bphase.config.save()
|
||||
bphase.initialize()
|
||||
st = Stream("Schottky stream", dispatcher)
|
||||
#q = st.addScalar("Charge", "SINEG01-DICT215:B1_CHARGE", 1, 0)
|
||||
#rphase = st.addScalar("RF phase", "SINEG01-RSYS:GET-VSUM-PHASE", 1, 0)
|
||||
st.initialize()
|
||||
st.start()
|
||||
q = Channel("SINEG01-DICT215:B1_CHARGE-SIM", type = 'd', alias = 'ICT-Q')
|
||||
rphase = Channel("SINEG01-RSYS:GET-BEAM-PHASE-SIM", type = 'd', alias = 'RF phase')
|
||||
|
||||
#st = Stream("ICTstream", dispatcher)
|
||||
#q = st.addScalar("Charge", "SINEG01-DICT215:B1_CHARGE-SIM", 1, 0)
|
||||
#st.initialize()
|
||||
#st.start(True)
|
||||
q = Channel("SINEG01-DICT215:B1_CHARGE-SIM", type = 'd', alias='ICT-Q')
|
||||
bphase0 = bphase.read()
|
||||
print bphase0
|
||||
print q.read()
|
||||
print rphase.read()
|
||||
|
||||
try:
|
||||
qb = create_averager(q, nb, 0.100)
|
||||
r = lscan(phase, (qb), start, stop, step, latency=lat)
|
||||
rf_phase = r.getPositions(0)
|
||||
charge = [val.mean for val in r.getReadable(0)]
|
||||
chargerms = [val.stdev for val in r.getReadable(0)]
|
||||
q_averager = create_averager(q, nb, 0.100)
|
||||
rphase_averager = create_averager(rphase, nb, 0.100)
|
||||
r = lscan(bphase, (q_averager, rphase_averager), start, stop, step, latency=lat)
|
||||
beamphase = r.getPositions(0)
|
||||
charge = [val.mean for val in r.getReadable(0)]
|
||||
chargerms = [val.stdev for val in r.getReadable(0)]
|
||||
rfphase = [val.mean for val in r.getReadable(1)]
|
||||
rfphaserms = [val.stdev for val in r.getReadable(1)]
|
||||
finally:
|
||||
phase.close()
|
||||
bphase.write(bphase0)
|
||||
bphase.close()
|
||||
st.close()
|
||||
q.close()
|
||||
#st.close()
|
||||
rphase.close()
|
||||
|
||||
#Setting the return value
|
||||
#set_return(50.0)
|
||||
y = charge
|
||||
x = rf_phase
|
||||
index_max = y.index(max(y))
|
||||
phase_ref = x[index_max] - 80
|
||||
phase_offset = - phase_ref
|
||||
caput("SINEG01-RSYS:CALC-VSUM-PHASE-OFFSET", phase_offset)
|
||||
index_max = charge.index(max(charge))
|
||||
rphase_ref = rfphase[index_max] - 80
|
||||
bphase_ref = beamphase[index_max] - 80
|
||||
|
||||
set_return(phase_ref)
|
||||
print rphase_ref
|
||||
print bphase_ref
|
||||
|
||||
set_return(rphase_ref)
|
||||
|
||||
+9
-14
@@ -8,7 +8,7 @@ from mathutils import PolynomialFunction, Gaussian, HarmonicOscillator
|
||||
|
||||
import java.awt.Color as Color
|
||||
|
||||
|
||||
|
||||
LASER_SETTLING_TIME = 3.0
|
||||
|
||||
def laser_on():
|
||||
@@ -165,19 +165,7 @@ def elog(title, message, attachments = [], author = None, category = "Info", dom
|
||||
if (err is not None) and err!="":
|
||||
raise Exception(err)
|
||||
print out
|
||||
|
||||
def get_plot_snapshots(title = None, file_type = "png", temp_path = get_context().setup.getContextPath()):
|
||||
"""
|
||||
Returns list with file names of plots snapshots from a plotting context.
|
||||
"""
|
||||
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
|
||||
ret = []
|
||||
for p in get_plots(title):
|
||||
file_name = os.path.abspath(temp_path + "/" + p.getTitle() + "." + file_type)
|
||||
p.saveSnapshot(file_name , file_type)
|
||||
ret.append(file_name)
|
||||
return ret
|
||||
|
||||
|
||||
|
||||
class Sinusoid(ReadonlyRegisterBase):
|
||||
def doRead(self):
|
||||
@@ -277,11 +265,18 @@ def get_camtool_stats(number_images=1, async = True, interval=-1, good_region =
|
||||
av.monitored = async
|
||||
ret.append(av)
|
||||
"""
|
||||
"""
|
||||
for dev in [CamtoolComX(), CamtoolComY(), CamtoolComErrorX(), CamtoolComErrorY()]:
|
||||
dev.initialize()
|
||||
av = create_averager (dev, number_images, 1/2.5)#(dev, number_images, interval)
|
||||
#av.monitored = async
|
||||
ret.append(av)
|
||||
"""
|
||||
for ident in [prefix+"x_center_of_mass", prefix+"y_center_of_mass", prefix+"x_rms", prefix+"y_rms"]:
|
||||
child = camtool.stream.getChild(ident)
|
||||
av = create_averager(child, number_images, interval)
|
||||
av.monitored = async
|
||||
ret.append(av)
|
||||
return ret
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user