This commit is contained in:
gac-x04sa
2018-01-25 12:47:27 +01:00
parent b0ab5848b6
commit 09537b00a1
4 changed files with 811 additions and 47 deletions
+1
View File
@@ -1,2 +1,3 @@
SampleSearch.java=enabled
Omega.java=enabled
Pilatus.java=enabled
+374
View File
@@ -0,0 +1,374 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="32" max="-2" attributes="0"/>
<Component id="buttonStart" min="-2" pref="102" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="39" max="-2" attributes="0"/>
<Component id="buttonAbort" min="-2" pref="102" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="72" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel8" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelX" min="-2" pref="103" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel9" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelY" min="-2" pref="103" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel10" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelZ" min="-2" pref="103" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel11" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelOmega" min="-2" pref="103" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="0" pref="62" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="97" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="panelX" min="-2" max="-2" attributes="0"/>
<Component id="jLabel8" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="panelY" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel9" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="panelZ" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel10" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="panelOmega" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel11" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace type="separate" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonStart" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonAbort" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="15" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel1">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Parameters"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<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="jLabel2" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerXmax" linkSize="2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel3" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerYmin" linkSize="2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel4" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerYmax" linkSize="2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel5" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerSampleSize" linkSize="2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerXmin" linkSize="2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel6" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerResolution" linkSize="2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel7" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerOmegaStart" linkSize="2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel12" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerZStart" linkSize="2" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="checkSimulation" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="31" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerXmin" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerXmax" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerYmin" alignment="3" min="-2" max="-2" attributes="0"/>
</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="spinnerYmax" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerSampleSize" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerResolution" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerOmegaStart" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel12" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerZStart" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="48" max="32767" attributes="0"/>
<Component id="checkSimulation" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Sample size(mm):"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerXmin">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="-1.0" maximum="3.0" minimum="-3.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerXmax">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="1.0" maximum="3.0" minimum="-3.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerSampleSize">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.25" maximum="0.4" minimum="0.1" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Xmin (mm):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Xmax(mm):"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerYmax">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="1.0" maximum="3.0" minimum="-3.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Ymin(mm):"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerYmin">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="-1.0" maximum="3.0" minimum="-3.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Ymax(mm):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Scan resolution(mm)"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerResolution">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.01" maximum="0.2" minimum="0.001" numberType="java.lang.Double" stepSize="0.01" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel7">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Omega start(deg)"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerOmegaStart">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="57.0" maximum="360.0" minimum="-360.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel12">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Z start(mm)"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerZStart">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" maximum="3.0" minimum="-3.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkSimulation">
<Properties>
<Property name="text" type="java.lang.String" value="Diode simulated"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="buttonStart">
<Properties>
<Property name="text" type="java.lang.String" value="Start"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonStartActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonAbort">
<Properties>
<Property name="text" type="java.lang.String" value="Abort"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonAbortActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel8">
<Properties>
<Property name="text" type="java.lang.String" value="Sample X:"/>
</Properties>
</Component>
<Component class="ch.psi.pshell.swing.MotorReadoutPanel" name="panelX">
<Properties>
<Property name="readOnly" type="boolean" value="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel9">
<Properties>
<Property name="text" type="java.lang.String" value="Sample Y:"/>
</Properties>
</Component>
<Component class="ch.psi.pshell.swing.MotorReadoutPanel" name="panelY">
<Properties>
<Property name="readOnly" type="boolean" value="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel10">
<Properties>
<Property name="text" type="java.lang.String" value="Sample Z:"/>
</Properties>
</Component>
<Component class="ch.psi.pshell.swing.MotorReadoutPanel" name="panelZ">
<Properties>
<Property name="readOnly" type="boolean" value="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel11">
<Properties>
<Property name="text" type="java.lang.String" value="Omega:"/>
</Properties>
</Component>
<Component class="ch.psi.pshell.swing.MotorReadoutPanel" name="panelOmega">
<Properties>
<Property name="readOnly" type="boolean" value="true"/>
</Properties>
</Component>
</SubComponents>
</Form>
+372
View File
@@ -0,0 +1,372 @@
/*
* Copyright (c) 2014-2017 Paul Scherrer Institute. All rights reserved.
*/
import ch.psi.pshell.device.Device;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import ch.psi.utils.swing.SwingUtils;
import java.util.HashMap;
/**
*
*/
public class SampleSearch extends Panel {
public SampleSearch() {
initComponents();
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
panelX.setDevice((Device) getDevice("scx"));
panelY.setDevice((Device) getDevice("scy"));
panelZ.setDevice((Device) getDevice("scz"));
panelOmega.setDevice((Device) getDevice("scr"));
}
@Override
public void onStateChange(State state, State former) {
buttonStart.setEnabled(state == State.Ready);
buttonAbort.setEnabled(state.isRunning());
}
@Override
public void onExecutedFile(String fileName, Object result) {
}
//Callback to perform update - in event thread
@Override
protected void doUpdate() {
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();
spinnerXmin = new javax.swing.JSpinner();
spinnerXmax = new javax.swing.JSpinner();
spinnerSampleSize = new javax.swing.JSpinner();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
spinnerYmax = new javax.swing.JSpinner();
jLabel3 = new javax.swing.JLabel();
spinnerYmin = new javax.swing.JSpinner();
jLabel4 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
spinnerResolution = new javax.swing.JSpinner();
jLabel7 = new javax.swing.JLabel();
spinnerOmegaStart = new javax.swing.JSpinner();
jLabel12 = new javax.swing.JLabel();
spinnerZStart = new javax.swing.JSpinner();
checkSimulation = new javax.swing.JCheckBox();
buttonStart = new javax.swing.JButton();
buttonAbort = new javax.swing.JButton();
jLabel8 = new javax.swing.JLabel();
panelX = new ch.psi.pshell.swing.MotorReadoutPanel();
jLabel9 = new javax.swing.JLabel();
panelY = new ch.psi.pshell.swing.MotorReadoutPanel();
jLabel10 = new javax.swing.JLabel();
panelZ = new ch.psi.pshell.swing.MotorReadoutPanel();
jLabel11 = new javax.swing.JLabel();
panelOmega = new ch.psi.pshell.swing.MotorReadoutPanel();
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Parameters"));
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel5.setText("Sample size(mm):");
spinnerXmin.setModel(new javax.swing.SpinnerNumberModel(-1.0d, -3.0d, 3.0d, 1.0d));
spinnerXmax.setModel(new javax.swing.SpinnerNumberModel(1.0d, -3.0d, 3.0d, 1.0d));
spinnerSampleSize.setModel(new javax.swing.SpinnerNumberModel(0.25d, 0.1d, 0.4d, 1.0d));
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel1.setText("Xmin (mm):");
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel2.setText("Xmax(mm):");
spinnerYmax.setModel(new javax.swing.SpinnerNumberModel(1.0d, -3.0d, 3.0d, 1.0d));
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel3.setText("Ymin(mm):");
spinnerYmin.setModel(new javax.swing.SpinnerNumberModel(-1.0d, -3.0d, 3.0d, 1.0d));
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel4.setText("Ymax(mm):");
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel6.setText("Scan resolution(mm)");
spinnerResolution.setModel(new javax.swing.SpinnerNumberModel(0.01d, 0.001d, 0.2d, 0.01d));
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel7.setText("Omega start(deg)");
spinnerOmegaStart.setModel(new javax.swing.SpinnerNumberModel(57.0d, -360.0d, 360.0d, 1.0d));
jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel12.setText("Z start(mm)");
spinnerZStart.setModel(new javax.swing.SpinnerNumberModel(0.0d, -3.0d, 3.0d, 1.0d));
checkSimulation.setText("Diode simulated");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerXmax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerYmin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerYmax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerSampleSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerXmin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerResolution, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerOmegaStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerZStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(checkSimulation))
.addGap(31, 31, 31))
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel12, jLabel2, jLabel3, jLabel4, jLabel5, jLabel6, jLabel7});
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerOmegaStart, spinnerResolution, spinnerSampleSize, spinnerXmax, spinnerXmin, spinnerYmax, spinnerYmin, spinnerZStart});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(spinnerXmin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(spinnerXmax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(spinnerYmin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(spinnerYmax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(spinnerSampleSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(spinnerResolution, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(spinnerOmegaStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel12)
.addComponent(spinnerZStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 48, Short.MAX_VALUE)
.addComponent(checkSimulation)
.addContainerGap())
);
buttonStart.setText("Start");
buttonStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonStartActionPerformed(evt);
}
});
buttonAbort.setText("Abort");
buttonAbort.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonAbortActionPerformed(evt);
}
});
jLabel8.setText("Sample X:");
panelX.setReadOnly(true);
jLabel9.setText("Sample Y:");
panelY.setReadOnly(true);
jLabel10.setText("Sample Z:");
panelZ.setReadOnly(true);
jLabel11.setText("Omega:");
panelOmega.setReadOnly(true);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(32, 32, 32)
.addComponent(buttonStart, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(39, 39, 39)
.addComponent(buttonAbort, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(72, 72, 72)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelX, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel9)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelY, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel10)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelZ, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelOmega, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 62, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGap(97, 97, 97)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(panelX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(panelY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel9))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(panelZ, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(panelOmega, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel11))))
.addGap(18, 18, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonStart)
.addComponent(buttonAbort))
.addContainerGap(15, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed
try {
if ((Double)spinnerXmax.getValue() <= (Double)spinnerXmin.getValue()){
throw new Exception ("Invalid range");
}
HashMap<String, Object> pars = new HashMap<>();
pars.put("X_MIN", spinnerXmin.getValue());
pars.put("X_MAX", spinnerXmax.getValue());
pars.put("Y_MIN", spinnerYmin.getValue());
pars.put("Y_MAX", spinnerYmax.getValue());
pars.put("MIN_SAMPLE_SIZE", spinnerSampleSize.getValue());
pars.put("SCAN_RESOLUTION", spinnerResolution.getValue());
pars.put("OMEGA_START", spinnerOmegaStart.getValue());
pars.put("Z_START", spinnerZStart.getValue());
pars.put("SIMULATION", checkSimulation.isSelected());
this.runAsync("scans/SampleSearch", pars).handle((ok, ex) -> {
if (ex != null) {
showException((Exception) ex);
} else {
SwingUtils.showMessage(this, "Success", "Sample was successfully centered");
}
return ok;
});
} catch (Exception ex) {
this.showException(ex);
}
}//GEN-LAST:event_buttonStartActionPerformed
private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed
try {
this.abort();
} catch (Exception ex) {
this.showException(ex);
}
}//GEN-LAST:event_buttonAbortActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonAbort;
private javax.swing.JButton buttonStart;
private javax.swing.JCheckBox checkSimulation;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
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.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private ch.psi.pshell.swing.MotorReadoutPanel panelOmega;
private ch.psi.pshell.swing.MotorReadoutPanel panelX;
private ch.psi.pshell.swing.MotorReadoutPanel panelY;
private ch.psi.pshell.swing.MotorReadoutPanel panelZ;
private javax.swing.JSpinner spinnerOmegaStart;
private javax.swing.JSpinner spinnerResolution;
private javax.swing.JSpinner spinnerSampleSize;
private javax.swing.JSpinner spinnerXmax;
private javax.swing.JSpinner spinnerXmin;
private javax.swing.JSpinner spinnerYmax;
private javax.swing.JSpinner spinnerYmin;
private javax.swing.JSpinner spinnerZStart;
// End of variables declaration//GEN-END:variables
}
+64 -47
View File
@@ -1,18 +1,20 @@
import mathutils
import plotutils
SIMULATION = True
X_MIN = scx.minValue / 2
X_MAX = scx.maxValue / 2
Y_MIN = scy.minValue / 2
Y_MAX = scy.maxValue / 2
if get_exec_pars().source == CommandSource.ui:
SIMULATION = True
X_MIN = scx.minValue / 2
X_MAX = scx.maxValue / 2
Y_MIN = scy.minValue / 2
Y_MAX = scy.maxValue / 2
MIN_SAMPLE_SIZE = 0.25
SCAN_RESOLUTION = 0.01
OMEGA_START = 57.0
Z_START = 0.0
MAX_SAMPLE_SIZE = 0.4
MIN_SAMPLE_SIZE = 0.25
SCAN_RESOLUTION = 0.01
OMEGA_START = 57.0
y_step = MIN_SAMPLE_SIZE * 0.5
sensor = scd_sim if SIMULATION else scd
@@ -25,64 +27,79 @@ def plot_fit(normalization, mean_val, sigma, xdata):
plotutils.plot_function(get_plots(None)[0], gaussian, "Fit", xdata)
scr.move(OMEGA_START)
scz.move(Z_START)
step=0
for y in frange(Y_MIN, Y_MAX, y_step):
scy.move(y)
scan_range = [X_MIN, X_MAX] if (step % 2==0) else [X_MAX, X_MIN]
scx.moveAsync(scan_range[0])
scy.move(y)
r = cscan(scx, sensor, scan_range[0], scan_range[1], SCAN_RESOLUTION, latency = DIODE_SETTLING_TIME)
try:
xdata,ydata = enforce_monotonic(r.getPositions(0)), r.getReadable(0)
(offset, normalization, mean_val, sigma) = mathutils.fit_gaussian_offset(ydata, xdata)
(offset, normalization, mean_val_x, sigma) = mathutils.fit_gaussian_offset(ydata, xdata)
if ((normalization-offset) < offset * 1.20) or (sigma > 0.5):
raise Exception("Invalid x fit")
plot_fit(normalization, mean_val, sigma, xdata)
print "Found x center at ", mean_val
scx.move(mean_val)
plot_fit(normalization, mean_val_x, sigma, xdata)
print "Found x center at ", mean_val_x
scx.move(mean_val_x)
break
except:
print "Invalid x fit for y=", y, ": ", sys.exc_info()[0]
step += 1
r = cscan(scy, sensor, y-MAX_SAMPLE_SIZE/2, Y_MAX+MAX_SAMPLE_SIZE/2, SCAN_RESOLUTION, latency = DIODE_SETTLING_TIME)
r = cscan(scy, sensor, max(y-MAX_SAMPLE_SIZE/2, scy.minValue), min(Y_MAX+MAX_SAMPLE_SIZE/2, scy.maxValue), SCAN_RESOLUTION, latency = DIODE_SETTLING_TIME)
xdata,ydata = enforce_monotonic(r.getPositions(0)), r.getReadable(0)
(offset, normalization, mean_val, sigma) = mathutils.fit_gaussian_offset(ydata, xdata)
try:
(offset, normalization, mean_val_y, sigma) = mathutils.fit_gaussian_offset(ydata, xdata)
except:
raise Exception ("Invalid y fit: ", sys.exc_info()[0])
if ((normalization-offset) < offset * 1.20) or (sigma > 0.5):
raise Exception("Invalid x fit")
plot_fit(normalization, mean_val, sigma, xdata)
print "Found y center at ", mean_val
scy.move(mean_val)
raise Exception("Invalid y fit")
plot_fit(normalization, mean_val_y, sigma, xdata)
print "Found y center at ", mean_val_y
scy.move(mean_val_y)
print "Success finding center at x=", scx.read(), " y=", scy.read()
print "Success finding center at x=", mean_val_x, " y=", mean_val_y
scr.move(OMEGA_START-15.0)
r = cscan(scx, sensor, X_MIN, X_MAX, SCAN_RESOLUTION, latency = DIODE_SETTLING_TIME)
xdata,ydata = enforce_monotonic(r.getPositions(0)), r.getReadable(0)
(offset, normalization, mean_minus_15, sigma) = mathutils.fit_gaussian_offset(ydata, xdata)
if ((normalization-offset) < offset * 1.20) or (sigma > 0.5):
raise Exception("Invalid x fit on z search -15deg")
plot_fit(normalization, mean_minus_15, sigma, xdata)
print "Found x center at -15deg at ", mean_minus_15
scr.move(OMEGA_START+15.0)
r = cscan(scx, sensor, X_MIN, X_MAX, SCAN_RESOLUTION, latency = DIODE_SETTLING_TIME)
xdata,ydata = enforce_monotonic(r.getPositions(0)), r.getReadable(0)
(offset, normalization, mean_plus_15, sigma) = mathutils.fit_gaussian_offset(ydata, xdata)
if ((normalization-offset) < offset * 1.20) or (sigma > 0.5):
raise Exception("Invalid x fit on z search +15deg")
plot_fit(normalization, mean_minus_15, sigma, xdata)
print "Found x center at +15deg at ", mean_plus_15
scr.move(OMEGA_START)
z_offset = 0.5 * (mean_minus_15 - mean_plus_15) / math.tan(math.radians(15.0))
print "Calculated z offset = ", z_offset
scz.moveRel(z_offset)
try:
scr.move(OMEGA_START-15.0)
r = cscan(scx, sensor, X_MIN, X_MAX, SCAN_RESOLUTION, latency = DIODE_SETTLING_TIME)
xdata,ydata = enforce_monotonic(r.getPositions(0)), r.getReadable(0)
try:
(offset, normalization, mean_minus_15, sigma) = mathutils.fit_gaussian_offset(ydata, xdata)
except:
raise Exception ("Invalid x fit on z search -15deg: ", sys.exc_info()[0])
if ((normalization-offset) < offset * 1.20) or (sigma > 0.5):
raise Exception("Invalid x fit on z search -15deg")
plot_fit(normalization, mean_minus_15, sigma, xdata)
print "Found x center at -15deg at ", mean_minus_15
scr.move(OMEGA_START+15.0)
r = cscan(scx, sensor, X_MAX, X_MIN, SCAN_RESOLUTION, latency = DIODE_SETTLING_TIME)
xdata,ydata = enforce_monotonic(r.getPositions(0)), r.getReadable(0)
try:
(offset, normalization, mean_plus_15, sigma) = mathutils.fit_gaussian_offset(ydata, xdata)
except:
raise Exception ("Invalid x fit on z search +15deg: ", sys.exc_info()[0])
if ((normalization-offset) < offset * 1.20) or (sigma > 0.5):
raise Exception("Invalid x fit on z search +15deg")
plot_fit(normalization, mean_minus_15, sigma, xdata)
print "Found x center at +15deg at ", mean_plus_15
scr.move(OMEGA_START)
z_offset = 0.5 * (mean_minus_15 - mean_plus_15) / math.tan(math.radians(15.0))
print "Calculated z offset = ", z_offset
scz.moveRel(z_offset)
finally:
scx.move(mean_val_x)
scy.move(mean_val_y)
print "Centering successfull"