Closedown

This commit is contained in:
sfop
2016-06-27 15:55:49 +02:00
parent 9e56d92e46
commit 573db41ab2
4 changed files with 139 additions and 31 deletions

View File

@@ -1,3 +1,3 @@
test2.java=enabled
test2.java=disabled
GunSolenoidAlignment.java=enabled
test.java=disabled

View File

@@ -21,14 +21,31 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="167" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="buttonRun" max="32767" attributes="0"/>
<Component id="buttonAbort" pref="92" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="centroidPlot" pref="0" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="155" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="buttonRun" max="32767" attributes="0"/>
<Component id="buttonAbort" pref="92" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="100" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="buttonClear" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
<EmptySpace min="-2" pref="100" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -37,15 +54,20 @@
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="41" max="-2" attributes="0"/>
<Component id="buttonRun" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="buttonAbort" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jPanel1" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="41" max="-2" attributes="0"/>
<Component id="buttonRun" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="buttonAbort" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="centroidPlot" min="-2" pref="289" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="buttonClear" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
@@ -189,7 +211,7 @@
<Component class="javax.swing.JSpinner" name="spinnerI1">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="100.0" maximum="150.0" minimum="50.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
<SpinnerModel initial="95.0" maximum="150.0" minimum="50.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
@@ -292,5 +314,19 @@
</Component>
</SubComponents>
</Container>
<Component class="ch.psi.pshell.plot.LinePlotJFree" name="centroidPlot">
<Properties>
<Property name="legendVisible" type="boolean" value="true"/>
<Property name="title" type="java.lang.String" value="Centroid"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonClear">
<Properties>
<Property name="text" type="java.lang.String" value="Clear"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonClearActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@@ -2,10 +2,16 @@
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
*/
import ch.psi.pshell.plot.LinePlotSeries;
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.Color;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -41,6 +47,23 @@ public class GunSolenoidAlignment extends Panel {
protected void doUpdate() {
}
int index=1;
void onEndScan(ScanResult sr){
ArrayList x = sr.getReadable(0);
ArrayList y = sr.getReadable(1);
LinePlotSeries s = new LinePlotSeries(String.valueOf(index++));
centroidPlot.addSeries(s);
System.out.println("END!");
s.setData((double[])Convert.toDouble(x), (double[])Convert.toDouble(y));
System.out.println("OK!");
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
@@ -65,6 +88,8 @@ public class GunSolenoidAlignment extends Panel {
radioBackMultiple = new javax.swing.JRadioButton();
jLabel6 = new javax.swing.JLabel();
spinnerNumImages = new javax.swing.JSpinner();
centroidPlot = new ch.psi.pshell.plot.LinePlotJFree();
buttonClear = new javax.swing.JButton();
buttonRun.setText("Run");
buttonRun.addActionListener(new java.awt.event.ActionListener() {
@@ -85,7 +110,7 @@ public class GunSolenoidAlignment extends Panel {
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel1.setText("I1:");
spinnerI1.setModel(new javax.swing.SpinnerNumberModel(100.0d, 50.0d, 150.0d, 1.0d));
spinnerI1.setModel(new javax.swing.SpinnerNumberModel(95.0d, 50.0d, 150.0d, 1.0d));
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel2.setText("I2:");
@@ -216,6 +241,16 @@ public class GunSolenoidAlignment extends Panel {
.addContainerGap(75, Short.MAX_VALUE))
);
centroidPlot.setLegendVisible(true);
centroidPlot.setTitle("Centroid");
buttonClear.setText("Clear");
buttonClear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonClearActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -223,24 +258,40 @@ public class GunSolenoidAlignment extends Panel {
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 167, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(buttonRun, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonAbort, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE))
.addGap(100, 100, 100))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(centroidPlot, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 155, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(buttonRun, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonAbort, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE))
.addGap(100, 100, 100))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(buttonClear)
.addContainerGap())))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(41, 41, 41)
.addComponent(buttonRun)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(buttonAbort))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addComponent(buttonAbort)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(centroidPlot, javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(buttonClear)
.addGap(9, 9, 9)))
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
@@ -267,8 +318,12 @@ public class GunSolenoidAlignment extends Panel {
args.put("number_backgrounds", spinnerNumBackgrounds.getValue());
args.put("use_background", checkBackground.isSelected());
args.put("multiple_background", radioBackMultiple.isSelected());
((Plugin)this).runAsync("Alignment/Gun_solenoid_alignment",args);
((Plugin)this).runAsync("Alignment/Gun_solenoid_alignment",args).thenAccept((Object t) -> {
System.out.println("Finish");
onEndScan((ScanResult) t);
});
} catch (Exception ex) {
System.out.println("Error " + ex.toString());
showException(ex);
}
}//GEN-LAST:event_buttonRunActionPerformed
@@ -279,10 +334,21 @@ public class GunSolenoidAlignment extends Panel {
spinnerNumBackgrounds.setEnabled(checkBackground.isSelected());
}//GEN-LAST:event_checkBackgroundActionPerformed
private void buttonClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonClearActionPerformed
try {
index=1;
centroidPlot.clear();
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonClearActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonAbort;
private javax.swing.JButton buttonClear;
private javax.swing.ButtonGroup buttonGroupBack;
private javax.swing.JButton buttonRun;
private ch.psi.pshell.plot.LinePlotJFree centroidPlot;
private javax.swing.JCheckBox checkBackground;
private javax.swing.JCheckBox checkSaveImages;
private javax.swing.JLabel jLabel1;

View File

@@ -101,10 +101,10 @@ mag = [ "SINEG01-MCRX120","SINEG01-MCRY120",
"SINEG01-MCRX220","SINEG01-MCRY220",
"SINEG01-MQUA310",
"SINEG01-MQUA320" ]
for m in mag:
caput(m + ":I-SET", 0.0)
for m in mag:
ccr(m)
#for m in mag:
# caput(m + ":I-SET", 0.0)
#for m in mag:
# ccr(m)
# add here gun phase setting see wiki page
@@ -122,10 +122,16 @@ finally:
# take the result of the scan and do the plots
#p = plot(r.getReadable(1), xdata=r.getReadable(0), title = "Centroid excursion")[0]
add_convex_hull_plot ("Centroid excursion", r.getReadable(0),r.getReadable(1), plot_name, False, (0,cam_img._width), (0,cam_img._height))
#add_convex_hull_plot ("Centroid excursion", r.getReadable(0),r.getReadable(1), plot_name, False, (0,cam_img._width), (0,cam_img._height))
# save the entry in the logbook
msg = str(r)
msg = msg + "\nFile: " + get_context().path
msg = msg + "\n\n" + r.print()
elog("Gun solenoid current scan", msg , get_plot_snapshots())
#elog("Gun solenoid current scan", msg , get_plot_snapshots())
print "DONE"
set_return(r)
print "QUIT"